#include <CompareToReroot.h>
Inheritance diagram for CompareToReroot:

Public Member Functions | |
| CompareToReroot () | |
| ~CompareToReroot () | |
| JobCResult | Ana (const MomNavigator *mom) |
Private Attributes | |
| TFile * | fFile |
| TTree * | fTree |
| HitCompare * | fHitCompare |
Definition at line 20 of file CompareToReroot.h.
| CompareToReroot::CompareToReroot | ( | ) |
Definition at line 37 of file CompareToReroot.cxx.
00038 { 00039 // Open a file/tree 00040 fFile = new TFile("reroot_compare.root","RECREATE"); 00041 fTree = new TTree("comp","comp"); 00042 fHitCompare = new HitCompare; 00043 fTree->Branch("branch","HitCompare",&fHitCompare,32000,1); 00044 }
| CompareToReroot::~CompareToReroot | ( | ) |
| JobCResult CompareToReroot::Ana | ( | const MomNavigator * | mom | ) | [virtual] |
Implement this for read only access to the MomNavigator
Reimplemented from JobCModule.
Definition at line 58 of file CompareToReroot.cxx.
References DigiScintHit::DE(), DigiScintHit::DS(), LogCounter::fCount, fFile, fHitCompare, RecDataRecord< T >::FindComponent(), RecDataRecord< T >::FindTemporary(), MomNavigator::FragmentIter(), fTree, PlexStripEndId::GetEncoded(), PlexStripEndId::GetEnd(), RerootExodus::GetFLSDigitList(), UgliStripHandle::GetHalfLength(), DigiPE::GetPixelSpotId(), PlexPlaneId::GetPlane(), SimSnarlRecord::GetSimSnarlHeader(), PlexStripEndId::GetStrip(), PlexHandle::GetStripEndId(), UgliGeomHandle::GetStripHandle(), DigiPE::GetTime(), RecHeader::GetVldContext(), REROOT_FLSDigit::ICell(), REROOT_FLSDigit::IExtr(), LogCounter::Increment(), REROOT_FLSDigit::IPln(), PlexStripEndId::IsValid(), Msg::kError, JobCResult::kFailed, StripEnd::kNegative, JobCResult::kPassed, StripEnd::kPositive, JobCResult::kWarning, MSG, RerootExodus::PECAB2SEId(), REROOT_FLSDigit::RawA(), REROOT_FLSDigit::RawB(), PlexStripEndId::SetEnd(), REROOT_FLSDigit::SignalPEA(), REROOT_FLSDigit::SignalPEB(), DigiScintHit::StripEndId(), DigiScintHit::T1(), REROOT_FLSDigit::TDCA(), REROOT_FLSDigit::TDCB(), and DigiScintHit::X1().
00059 { 00060 //====================================================================== 00061 // Fill entries in a tree. 00062 //====================================================================== 00063 00064 // 00065 SimSnarlRecord* simsnarl = 0; 00066 TObject* tobj; 00067 TIter fragiter = mom->FragmentIter(); 00068 PlexStripEndId seid; 00069 Float_t adc; 00070 Int_t isAB; 00071 static int event=0; 00072 event++; 00073 00074 // Get the simsnarl. 00075 while( ( tobj = fragiter.Next() ) ) { 00076 simsnarl = dynamic_cast<SimSnarlRecord*>(tobj); 00077 if(simsnarl) break; 00078 } 00079 const SimSnarlHeader* simHeader = simsnarl->GetSimSnarlHeader(); 00080 if(simHeader ==0){ 00081 MSG("Photon",Msg::kError) << "Cannot find SimSnarlHeader in SimSnarl." << endl; 00082 return JobCResult::kFailed; 00083 } 00084 00085 // We need a context to do table lookups 00086 VldContext simContext = simHeader->GetVldContext(); 00087 PlexHandle plex(simContext); 00088 00089 // Get the DigiScintHits. 00090 // Get the scint hit array. 00091 const TObjArray* hitArray = 00092 dynamic_cast<const TObjArray*>(simsnarl->FindComponent(0,"DigiScintHits")); 00093 if(hitArray==0) { 00094 cout << "Can't find scint hit array.\n"; 00095 return JobCResult::kPassed; 00096 }; 00097 00098 00099 // Build a map of stripend. 00100 std::map<int,HitCompare> hmap; 00101 std::map<int,HitCompare>::iterator hmapit; 00102 00103 // put scint hits in. 00104 TIter hitarrayIter(hitArray); 00105 while( (tobj = hitarrayIter.Next()) ) { 00106 const DigiScintHit* scinthit = dynamic_cast<DigiScintHit*>(tobj); 00107 if(scinthit) { 00108 seid = scinthit->StripEndId(); 00109 seid.SetEnd(StripEnd::kPositive); 00110 int index1 = seid.GetEncoded(); 00111 seid.SetEnd(StripEnd::kNegative); 00112 int index2 = seid.GetEncoded(); 00113 // put it on both ends. 00114 hmap[index1].nhits++; 00115 hmap[index1].hit_de += scinthit->DE(); 00116 hmap[index1].hit_ds += scinthit->DS(); 00117 hmap[index1].hit_x = scinthit->X1(); 00118 hmap[index1].hit_t = scinthit->T1(); 00119 00120 hmap[index2].nhits++; 00121 hmap[index2].hit_de += scinthit->DE(); 00122 hmap[index2].hit_ds += scinthit->DS(); 00123 hmap[index2].hit_x = scinthit->X1(); 00124 hmap[index2].hit_t = scinthit->T1(); 00125 } 00126 } 00127 00128 // put in the reroot stuff. 00129 // Prepare to loop over REROOT digits 00130 const TClonesArray *flsdigits = RerootExodus::GetFLSDigitList(); 00131 REROOT_FLSDigit *flsdigit = 0; 00132 TIter diter(flsdigits); 00133 00134 00135 Float_t ADAMO_RNULL = 699050. * (Float_t) (16<<26); // 699050*16.0**26 00136 while ( ( flsdigit = (REROOT_FLSDigit*) diter.Next() ) ) { 00137 // process A side 00138 adc = flsdigit->RawA(); 00139 isAB = 0; 00140 if ( adc > 0.0 && adc < ADAMO_RNULL ) { 00141 seid = RerootExodus::PECAB2SEId(flsdigit->IPln(),flsdigit->IExtr(), 00142 flsdigit->ICell(),isAB); 00143 00144 if(flsdigit->SignalPEA()>0) { 00145 int index = seid.GetEncoded(); 00146 hmap[index].adc_reroot += adc; 00147 hmap[index].tdc_reroot = flsdigit->TDCA(); 00148 hmap[index].pe_reroot += flsdigit->SignalPEA(); 00149 } 00150 } 00151 00152 // process B side 00153 adc = flsdigit->RawB(); 00154 isAB = 1; 00155 if ( adc > 0.0 && adc < ADAMO_RNULL ) { 00156 seid = RerootExodus::PECAB2SEId(flsdigit->IPln(),flsdigit->IExtr(), 00157 flsdigit->ICell(),isAB); 00158 if(flsdigit->SignalPEB()>0) { 00159 int index = seid.GetEncoded(); 00160 hmap[index].adc_reroot += adc; 00161 hmap[index].tdc_reroot = flsdigit->TDCB(); 00162 hmap[index].pe_reroot += flsdigit->SignalPEB(); 00163 } 00164 } 00165 } 00166 00167 00168 00169 // Get the DigiPes. 00170 const TObjArray* peListObj = 00171 dynamic_cast<const TObjArray*>(simsnarl->FindTemporary(0,"DigiListPe")); 00172 if(peListObj == 0) { 00173 MSG("DetSim",Msg::kError) << "Cannot find DigiPE list in the SimSnarl. Aborting." << endl; 00174 return JobCResult::kWarning; 00175 } 00176 00177 TObjArrayIter itr(peListObj); 00178 DigiPE* digipe; 00179 while( (digipe = dynamic_cast<DigiPE*>(itr.Next()))!=0 ) { 00180 int index = plex.GetStripEndId(digipe->GetPixelSpotId()).GetEncoded(); 00181 float t = digipe->GetTime()*1e9; 00182 if( t < (hmap[index].tfirst_photon)) hmap[index].tfirst_photon = t; 00183 hmap[index].tmean_photon += t; 00184 hmap[index].pe_photon +=1; 00185 }; 00186 00187 00188 UgliGeomHandle ugli(simContext); 00189 00190 // Finish up 00191 for(hmapit = hmap.begin(); hmapit!=hmap.end(); hmapit++){ 00192 seid = PlexStripEndId(hmapit->first); 00193 hmapit->second.event = event; 00194 hmapit->second.plane = seid.GetPlane(); 00195 hmapit->second.strip = seid.GetStrip(); 00196 hmapit->second.end = seid.GetEnd(); 00197 00198 if(seid.IsValid()) { 00199 UgliStripHandle ustrip = ugli.GetStripHandle(seid); 00200 if(ustrip.IsValid()) { 00201 hmapit->second.halflength = ustrip.GetHalfLength(); 00202 hmapit->second.pigtail = ustrip.WlsPigtail(seid.GetEnd()); 00203 hmapit->second.clear = ustrip.ClearFiber(seid.GetEnd()); 00204 } 00205 } 00206 if(hmapit->second.pe_photon >0) 00207 hmapit->second.tmean_photon /= (float) hmapit->second.pe_photon; 00208 } 00209 00210 // And fill. 00211 00212 double tot_photon = 0; 00213 double tot_reroot = 0; 00214 for(hmapit = hmap.begin(); hmapit!=hmap.end(); hmapit++){ 00215 seid = PlexStripEndId(hmapit->first); 00216 // fill other end. 00217 seid.SetEnd( (seid.GetEnd()==StripEnd::kPositive)?StripEnd::kNegative:StripEnd::kPositive); 00218 int index = seid.GetEncoded(); 00219 hmapit->second.pe_reroot_2 = hmap[index].pe_reroot; 00220 hmapit->second.adc_reroot_2 = hmap[index].adc_reroot; 00221 hmapit->second.tdc_reroot_2 = hmap[index].tdc_reroot; 00222 hmapit->second.pe_photon_2 = hmap[index].pe_photon; 00223 hmapit->second.tfirst_photon_2 = hmap[index].tfirst_photon; 00224 hmapit->second.tmean_photon_2 = hmap[index].tmean_photon; 00225 00226 tot_photon += hmapit->second.pe_photon; 00227 tot_reroot += hmapit->second.pe_reroot; 00228 fHitCompare = &(hmapit->second); 00229 fTree->Fill(); 00230 } 00231 00232 static LogCounter counter; 00233 if(counter.Increment()) { 00234 fTree->AutoSave(); 00235 cout << counter.fCount << endl; 00236 } 00237 fFile->Write(); 00238 00239 static double tot_photon_running = 0; 00240 static double tot_reroot_running = 0; 00241 tot_photon_running += tot_photon; 00242 tot_reroot_running += tot_reroot; 00243 cout << "PhotonTotal: " << tot_photon << "\t RunningTotal:" << tot_photon_running << endl; 00244 cout << "RerootTotal: " << tot_reroot << "\t RunningTotal:" << tot_reroot_running << endl; 00245 cout << "Ratio: " << tot_photon/tot_reroot << "\t RunningTotal:" << tot_photon_running/tot_reroot_running << endl; 00246 00247 return JobCResult::kPassed; // kNoDecision, kFailed, etc. 00248 }
TFile* CompareToReroot::fFile [private] |
HitCompare* CompareToReroot::fHitCompare [private] |
TTree* CompareToReroot::fTree [private] |
1.4.7