All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
icarus::crt::CrtOpHitMatchAnalysis Class Reference
Inheritance diagram for icarus::crt::CrtOpHitMatchAnalysis:

Public Types

using CRTHit = sbn::crt::CRTHit
 

Public Member Functions

 CrtOpHitMatchAnalysis (fhicl::ParameterSet const &p)
 
 CrtOpHitMatchAnalysis (CrtOpHitMatchAnalysis const &)=delete
 
 CrtOpHitMatchAnalysis (CrtOpHitMatchAnalysis &&)=delete
 
CrtOpHitMatchAnalysisoperator= (CrtOpHitMatchAnalysis const &)=delete
 
CrtOpHitMatchAnalysisoperator= (CrtOpHitMatchAnalysis &&)=delete
 
void analyze (art::Event const &e) override
 

Private Member Functions

bool HitCompare (const art::Ptr< CRTHit > &h1, const art::Ptr< CRTHit > &h2)
 
void ClearVecs ()
 

Private Attributes

const double LAR_PROP_DELAY = 1.0/(30.0/1.38)
 
art::InputTag fGenLabel
 
art::InputTag fSimLabel
 
art::InputTag fOpHitModuleLabel
 
art::InputTag fOpFlashModuleLabel0
 
art::InputTag fOpFlashModuleLabel1
 
art::InputTag fOpFlashModuleLabel2
 
art::InputTag fOpFlashModuleLabel3
 
art::InputTag fCrtHitModuleLabel
 
art::InputTag fCrtTrackModuleLabel
 
double fCoinWindow
 
double fOpDelay
 
double fCrtDelay
 
int fFlashPeThresh
 
int fHitPeThresh
 
double fFlashVelocity
 
double fFlashZOffset
 
double fHitVelocityMax
 
double fHitVelocityMin
 
CRTBackTrackerbt
 
CRTCommonUtilscrtutil
 
map< int, art::InputTag > fFlashLabels
 
TTree * fMatchTree
 
TTree * fHitTree
 
TTree * fFlashTree
 
int fNCrt
 
vector< vector< double > > fCrtXYZT
 
vector< vector< double > > fCrtXYZErr
 
vector< int > fCrtRegion
 
vector< double > fCrtPE
 
vector< double > fTofHit
 
vector< double > fTofFlash
 
vector< double > fTofFlashHit
 
vector< double > fDistHit
 
vector< double > fDistFlash
 
vector< double > fDistFlashHit
 
vector< double > fTofPeHit
 
vector< double > fTofPeFlash
 
vector< double > fTofPeFlashHit
 
vector< vector< double > > fTofXYZTHit
 
vector< vector< double > > fTofXYZTFlash
 
vector< vector< double > > fTofXYZTFlashHit
 
vector< int > fTofTpcHit
 
vector< int > fTofTpcFlash
 
vector< bool > fMatchHit
 
vector< bool > fMatchFlash
 
vector< double > fTrueDist
 
vector< double > fTrueTOF
 
vector< vector< double > > fEnterXYZT
 
vector< vector< double > > fPMTXYZT
 
vector< int > fHitPDG
 
vector< bool > fIV
 
vector< bool > fAV
 
vector< bool > fFV
 
bool fNu
 
bool fNuCC
 
double fNuE
 
double fNuXYZT [4]
 
bool fNuIV
 
bool fNuAV
 
bool fNuFV
 
vector< bool > fTrackFilt
 
int fNHit
 
vector< double > fHitPE
 
vector< int > fHitChan
 
vector< vector< double > > fHitXYZT
 
int fNFlash
 
vector< int > fFlashTPC
 
vector< vector< double > > fFlashXYZT
 
vector< double > fFlashPE
 
vector< int > fFlashNHit
 
vector< double > fFlashMeanPE
 
vector< double > fFlashRmsPE
 
vector< vector< double > > fFlashDelta
 
geo::GeometryCore const * fGeometryService
 pointer to Geometry provider More...
 

Detailed Description

Definition at line 61 of file CrtOpHitMatchAnalysis_module.cc.

Member Typedef Documentation

Definition at line 64 of file CrtOpHitMatchAnalysis_module.cc.

Constructor & Destructor Documentation

CrtOpHitMatchAnalysis::CrtOpHitMatchAnalysis ( fhicl::ParameterSet const &  p)
explicit

Definition at line 175 of file CrtOpHitMatchAnalysis_module.cc.

176  : EDAnalyzer{p} ,
177  fGenLabel(p.get<art::InputTag>("GenLabel","generator")),
178  fSimLabel(p.get<art::InputTag>("SimLabel","largeant")),
179  fOpHitModuleLabel(p.get<art::InputTag>("OpHitModuleLabel","ophit")),
180  fOpFlashModuleLabel0(p.get<art::InputTag>("OpFlashModuleLabel0","opflashTPC0")),
181  fOpFlashModuleLabel1(p.get<art::InputTag>("OpFlashModuleLabel1","opflashTPC1")),
182  fOpFlashModuleLabel2(p.get<art::InputTag>("OpFlashModuleLabel2","opflashTPC2")),
183  fOpFlashModuleLabel3(p.get<art::InputTag>("OpFlashModuleLabel3","opflashTPC3")),
184  fCrtHitModuleLabel(p.get<art::InputTag>("CrtHitModuleLabel","crthit")),
185  fCrtTrackModuleLabel(p.get<art::InputTag>("CrtTrackModuleLabel","crttrack")),
186  fCoinWindow(p.get<double>("CoincidenceWindow",60.0)),
187  fOpDelay(p.get<double>("OpDelay",55.1)),
188  fCrtDelay(p.get<double>("CrtDelay",1.6e6)),
189  fFlashPeThresh(p.get<int>("FlashPeThresh",9000)),
190  fHitPeThresh(p.get<int>("HitPeThresh",700)),
191  fFlashVelocity(p.get<double>("FlashVelocityThresh",-40.)),
192  fFlashZOffset(p.get<double>("FlashZOffset",0.)),
193  fHitVelocityMax(p.get<double>("HitVelocityMax",20.)),
194  fHitVelocityMin(p.get<double>("HitVelocityMin",1.)),
195  bt(new CRTBackTracker(p.get<fhicl::ParameterSet>("CRTBackTrack"))),
196  crtutil(new CRTCommonUtils())
197 {
202 
203  // Get a pointer to the geometry service provider.
204  fGeometryService = lar::providerFrom<geo::Geometry>();
205 
206  art::ServiceHandle<art::TFileService> tfs;
207 
208  fMatchTree = tfs->make<TTree>("matchTree","CRTHit - OpHit/Flash matching analysis");
209  fHitTree = tfs->make<TTree>("hitTree", "OpHit info");
210  fFlashTree = tfs->make<TTree>("flashTree", "OpFlash info");
211 
212  fHitTree->Branch("nhit", &fNHit, "nOpHit/I");
213  fHitTree->Branch("xyzt", &fHitXYZT);
214  fHitTree->Branch("pe", &fHitPE);
215  fHitTree->Branch("chan", &fHitChan);
216 
217  fFlashTree->Branch("nflash", &fNFlash, "nOpFlash/I");
218  fFlashTree->Branch("tpc", &fFlashTPC);
219  fFlashTree->Branch("xyzt", &fFlashXYZT);
220  fFlashTree->Branch("totpe", &fFlashPE);
221  fFlashTree->Branch("nhit", &fFlashNHit);
222  fFlashTree->Branch("meanpe", &fFlashMeanPE);
223  fFlashTree->Branch("rmspe", &fFlashRmsPE);
224  fFlashTree->Branch("delta", &fFlashDelta);
225 
226  fMatchTree->Branch("ncrt", &fNCrt, "nCrtHit/I");
227  fMatchTree->Branch("crtXYZT", &fCrtXYZT);
228  fMatchTree->Branch("crtXYZErr", &fCrtXYZErr);
229  fMatchTree->Branch("crtPE", &fCrtPE);
230  fMatchTree->Branch("crtRegion", &fCrtRegion);
231  fMatchTree->Branch("tofHit", &fTofHit);
232  fMatchTree->Branch("tofFlash", &fTofFlash);
233  fMatchTree->Branch("tofFlashHit", &fTofFlashHit);
234  fMatchTree->Branch("peHit", &fTofPeHit);
235  fMatchTree->Branch("peFlash", &fTofPeFlash);
236  fMatchTree->Branch("peFlashHit", &fTofPeFlashHit);
237  fMatchTree->Branch("xyztHit", &fTofXYZTHit);
238  fMatchTree->Branch("xyztFlash", &fTofXYZTFlash);
239  fMatchTree->Branch("xyztFlashHit", &fTofXYZTFlashHit);
240  fMatchTree->Branch("distHit", &fDistHit);
241  fMatchTree->Branch("distFlash", &fDistFlash);
242  fMatchTree->Branch("distFlashHit", &fDistFlashHit);
243  fMatchTree->Branch("tpcHit", &fTofTpcHit);
244  fMatchTree->Branch("tpcFlash", &fTofTpcFlash);
245  fMatchTree->Branch("matchHit", &fMatchHit);
246  fMatchTree->Branch("matchFlash", &fMatchFlash);
247  fMatchTree->Branch("distTrue", &fTrueDist);
248  fMatchTree->Branch("tofTrue", &fTrueTOF);
249  fMatchTree->Branch("enterXYZT", &fEnterXYZT);
250  fMatchTree->Branch("pmtXYZT", &fPMTXYZT);
251  fMatchTree->Branch("crtPDG", &fHitPDG);
252  fMatchTree->Branch("crtIV", &fIV);
253  fMatchTree->Branch("crtAV", &fAV);
254  fMatchTree->Branch("crtFV", &fFV);
255  fMatchTree->Branch("nu", &fNu, "nu/O");
256  fMatchTree->Branch("nuCC", &fNuCC, "nuCC/O");
257  fMatchTree->Branch("nuE", &fNuE, "nuE/D");
258  fMatchTree->Branch("nuXYZT", fNuXYZT, "nuXYZT[4]/D");
259  fMatchTree->Branch("nuIV", &fNuIV, "nuIV/O");
260  fMatchTree->Branch("nuAV", &fNuAV, "nuAV/O");
261  fMatchTree->Branch("nuFV", &fNuFV, "nuFV/O");
262  fMatchTree->Branch("trackfilt", &fTrackFilt);
263 
264  //fClock = lar::providerFrom<detinfo::DetectorClocksService>();
265 }
pdgs p
Definition: selectors.fcl:22
geo::GeometryCore const * fGeometryService
pointer to Geometry provider
art::ServiceHandle< art::TFileService > tfs
icarus::crt::CrtOpHitMatchAnalysis::CrtOpHitMatchAnalysis ( CrtOpHitMatchAnalysis const &  )
delete
icarus::crt::CrtOpHitMatchAnalysis::CrtOpHitMatchAnalysis ( CrtOpHitMatchAnalysis &&  )
delete

Member Function Documentation

void CrtOpHitMatchAnalysis::analyze ( art::Event const &  e)
override

Definition at line 267 of file CrtOpHitMatchAnalysis_module.cc.

268 {
269  //art::ServiceHandle<cheat::PhotonBackTrackerService> pbt;
270  //fTTrig = fClock->TriggerTime();
271 
272  geo::CryostatGeo const& cryo0 = fGeometryService->Cryostat(0);
273  geo::CryostatGeo const& cryo1 = fGeometryService->Cryostat(1);
274  geo::TPCGeo const& tpc00 = cryo0.TPC(0);
275  geo::TPCGeo const& tpc01 = cryo0.TPC(1);
276  geo::TPCGeo const& tpc10 = cryo1.TPC(0);
277  geo::TPCGeo const& tpc11 = cryo1.TPC(1);
278  ClearVecs();
279 
280  auto const& mctruths = //vector of MCTruths from GENIE
281  *e.getValidHandle<vector<simb::MCTruth>>(fGenLabel);
282 
283  fNuIV = false;
284  fNuAV = false;
285  fNuFV = false;
286  if(mctruths[0].GeneratorInfo().generator==simb::Generator_t::kGENIE){
287  fNu = true;
288  auto const& nu = mctruths[0].GetNeutrino();
289  const TLorentzVector xyzt = nu.Nu().Position(0);
290  fNuE = nu.Nu().E();
291  fNuCC = nu.CCNC();
292  fNuXYZT[0] = xyzt.X();
293  fNuXYZT[1] = xyzt.Y();
294  fNuXYZT[2] = xyzt.Z();
295  fNuXYZT[3] = xyzt.T();
296  double point[3];
297  for(int i=0; i<3; i++) point[i] = fNuXYZT[i];
298  if(cryo0.ContainsPosition(point) || cryo1.ContainsPosition(point)){
299  fNuIV = true;
300  if(tpc00.ContainsPosition(point) ||
301  tpc01.ContainsPosition(point) ||
302  tpc10.ContainsPosition(point) ||
303  tpc11.ContainsPosition(point) ) {
304 
305  fNuIV = false;
306  fNuAV = true;
307  fNuFV = true;
308  }
309  }
310  }
311  else{
312  fNu = false;
313  fNuE = DBL_MAX;
314  fNuCC = false;
315  for(int i=0; i<4; i++)
316  fNuXYZT[i] = DBL_MAX;
317  }
318 
319  auto const& simparticles = //vector of MCParticles from G4
320  *e.getValidHandle<vector<simb::MCParticle>>(fSimLabel);
321 
322  //loop over G4 tracks
323  map<int,const simb::MCParticle*> particleMap;
324  for(auto const& particle : simparticles){
325 
326  particleMap[particle.TrackId()] = &particle;
327 
328  }//G4 tracks
329 
330  //OpHits
331  art::Handle< std::vector<recob::OpHit> > opHitListHandle;
332  std::vector< art::Ptr<recob::OpHit> > opHitList;
333  if( e.getByLabel(fOpHitModuleLabel,opHitListHandle) )
334  art::fill_ptr_vector(opHitList, opHitListHandle);
335 
336  fNHit = opHitList.size();
337  for(auto const& ophit : opHitList){
338  double t = ophit->PeakTime()*1e3-fOpDelay;
339  fHitPE.push_back(ophit->PE());
340  fHitChan.push_back(ophit->OpChannel());
341  double pos[3];
342  fGeometryService->OpDetGeoFromOpChannel(ophit->OpChannel()).GetCenter(pos);
343  vector<double> xyzt = {pos[0],pos[1],pos[2],t};
344  fHitXYZT.push_back(xyzt);
345  }
346 
347  fHitTree->Fill();
348 
349  //OpFlash
350  map<int, art::Handle< std::vector<recob::OpFlash> > > flashHandles;
351  std::map<int,std::vector< art::Ptr<recob::OpFlash> >> opFlashLists;
352  fNFlash = 0;
353  for(int i=0; i<4; i++) {
354  if( e.getByLabel(fFlashLabels[i],flashHandles[i]) )
355  art::fill_ptr_vector(opFlashLists[i], flashHandles[i]);
356  }
357 
358  for(auto const& flashList : opFlashLists) {
359  fNFlash += flashList.second.size();
360 
361  for(size_t iflash=0; iflash<flashList.second.size(); iflash++) {
362  auto const& flash = flashList.second[iflash];
363 
364  vector<double> xyzt;
365  xyzt.push_back(0.);
366  xyzt.push_back(flash->YCenter());
367  xyzt.push_back(flash->ZCenter());
368  xyzt.push_back(flash->Time()*1e3-fOpDelay);
369  fFlashXYZT.push_back(xyzt);
370  fFlashPE.push_back(flash->TotalPE());
371  fFlashTPC.push_back(flashList.first);
372  auto const& pes = flash->PEs();
373  fFlashNHit.push_back(pes.size());
374  fFlashMeanPE.push_back(fFlashPE.back()/fFlashNHit.back());
375  double rms2=0.;
376  for(auto const& pe : pes)
377  rms2 += pow((pe-fFlashMeanPE.back()),2);
378  rms2*=1.0/(fFlashNHit.back()-1);
379  fFlashRmsPE.push_back(sqrt(rms2));
380  vector<double> delta = {0., flash->YWidth(),flash->ZWidth(),flash->TimeWidth()};
381  fFlashDelta.push_back(delta);
382 
383  /*vector<art::Ptr<recob::OpHit>> hits = findManyHits.at(iflash);
384  for(auto const& hit : hits) {
385  double tPmt = hit->PeakTime()*1.e3-fOpDelay;
386  if( tPmt < flashHitT) {
387  flashHitT = tPmt;
388  flashHitPE = hit->PE();
389 
390  //FlashHit position/time
391  geo::OpDetGeo const& opDet = cryo0.OpDet(hit->OpChannel());
392  double pos[3];
393  opDet.GetCenter(pos);
394  flashHitxyzt.clear();
395  for(int i=0; i<3; i++) flashHitxyzt.push_back(pos[i]);
396  flashHitxyzt.push_back(flashHitT);
397 
398  //FlashHit distance
399  TVector3 rflashHit(pos[0],pos[1],pos[2]);
400  TVector3 vdiffHit = rcrt-rflashHit;
401  flashHitDiff = vdiffHit.Mag();
402  }
403  }//loop over flash hits*/
404 
405  }
406  }
407 
408  fFlashTree->Fill();
409 
410  //CRTracks
411  art::Handle< std::vector<sbn::crt::CRTTrack> > crtTrackListHandle;
412  std::vector< art::Ptr<sbn::crt::CRTTrack> > crtTrackList;
413  if( e.getByLabel(fCrtTrackModuleLabel,crtTrackListHandle))
414  art::fill_ptr_vector(crtTrackList, crtTrackListHandle);
415 
416  art::FindManyP<CRTHit> findManyHits(
417  crtTrackListHandle, e, fCrtTrackModuleLabel);
418 
419 
420  //get time-ordered(ascending) vector of hits for each track
421  std::vector<std::vector<art::Ptr<CRTHit>>> trackhits;
422  for(size_t itrk=0; itrk<crtTrackList.size(); itrk++){
423 
424  std::vector<art::Ptr<CRTHit>> trkhits = findManyHits.at(itrk);
425  std::sort(trkhits.begin(),trkhits.end(),
426  [](const art::Ptr<CRTHit>& a, const art::Ptr<CRTHit>& b)->bool
427  {
428  return a->ts0_ns < b->ts0_ns;
429  });
430 
431  trackhits.push_back(trkhits);
432 
433  }//for tracks
434 
435 
436  //CRTHits
437  art::Handle< std::vector<CRTHit> > crtHitListHandle;
438  std::vector< art::Ptr<CRTHit> > crtHitList;
439  if( e.getByLabel(fCrtHitModuleLabel,crtHitListHandle))
440  art::fill_ptr_vector(crtHitList, crtHitListHandle);
441 
442  fNCrt = crtHitList.size();
443 
444  for(auto const& crt : crtHitList){
445 
446  bool trackfilt=false;
447  for(auto const& trkhits: trackhits){
448  for(size_t ihit=1; ihit<trkhits.size(); ihit++) {
449  if(HitCompare(trkhits[ihit],crt)){
450  trackfilt = true;
451  break;
452  }
453  }
454  if(trackfilt)
455  break;
456  }
457  fTrackFilt.push_back(trackfilt);
458 
459  vector<double> xyzt, xyzerr;
460  TVector3 rcrt(crt->x_pos,crt->y_pos,crt->z_pos);
461 
462  xyzt.push_back(rcrt.X());
463  xyzt.push_back(rcrt.Y());
464  xyzt.push_back(rcrt.Z());
465  double tcrt = (int32_t)crt->ts0_ns - fCrtDelay;
466  xyzt.push_back(tcrt);
467  fCrtXYZT.push_back(xyzt);
468 
469  xyzerr.push_back(crt->x_err);
470  xyzerr.push_back(crt->y_err);
471  xyzerr.push_back(crt->z_err);
472  fCrtXYZErr.push_back(xyzerr);
473 
474  fCrtPE.push_back(crt->peshit);
475  fCrtRegion.push_back(crtutil->AuxDetRegionNameToNum(crt->tagger));
476 
477  // -- get truth info --
478  //get trackID associated with CRTHit
479  int trackID = bt->TrueIdFromTotalEnergy(e,*crt);
480  bool firstIV=false, firstAV=false, firstFV=false;
481 
482  //if trackID exists in particle map
483  if(particleMap.find(abs(trackID))!=particleMap.end()){
484  auto const& particle = particleMap[abs(trackID)];
485  fHitPDG.push_back(particle->PdgCode());
486  for(size_t i=0; i<particle->NumberTrajectoryPoints(); i++){
487  const TLorentzVector& pos = particle->Position(i);
488  double point[3] = {pos.X(),pos.Y(),pos.Z()};
489  if(cryo0.ContainsPosition(point)) {
490  firstIV = true;
491  if(!firstAV && (tpc00.ContainsPosition(point) ||
492  tpc01.ContainsPosition(point)) ) {
493  double opDetPos[3];
494  (cryo0.OpDet(cryo0.GetClosestOpDet(point))).GetCenter(opDetPos);
495  double ddirect = sqrt(pow(opDetPos[0]-rcrt.X(),2)
496  + pow(opDetPos[1]-rcrt.Y(),2)
497  + pow(opDetPos[2]-rcrt.Z(),2));
498  double dprop = sqrt(pow(opDetPos[0]-pos[0],2)
499  + pow(opDetPos[1]-pos[1],2)
500  + pow(opDetPos[2]-pos[2],2));
501  double tprop = pos.T() + dprop*LAR_PROP_DELAY;
502  fTrueDist.push_back(ddirect);
503  fTrueTOF.push_back(tcrt-tprop);
504  vector<double> tmp1 = {pos.X(),pos.Y(),pos.Z(),pos.T()};
505  vector<double> tmp2 = {opDetPos[0],opDetPos[1],opDetPos[2],tprop};
506  fEnterXYZT.push_back(tmp1);
507  fPMTXYZT.push_back(tmp2);
508  firstIV = false;
509  firstAV = true;
510  firstFV = true;
511  }//if AV
512  }//if IV
513  if(!firstAV && cryo1.ContainsPosition(point)){
514  if(!firstAV && (tpc10.ContainsPosition(point) ||
515  tpc11.ContainsPosition(point)) ) {
516  double opDetPos[3];
517  (cryo1.OpDet(cryo0.GetClosestOpDet(point))).GetCenter(opDetPos);
518  double ddirect = sqrt(pow(opDetPos[0]-rcrt.X(),2)
519  + pow(opDetPos[1]-rcrt.Y(),2)
520  + pow(opDetPos[2]-rcrt.Z(),2));
521  double dprop = sqrt(pow(opDetPos[0]-pos[0],2)
522  + pow(opDetPos[1]-pos[1],2)
523  + pow(opDetPos[2]-pos[2],2));
524  double tprop = pos.T() + dprop*LAR_PROP_DELAY;
525  fTrueDist.push_back(ddirect);
526  fTrueTOF.push_back(tcrt-tprop);
527  vector<double> tmp1 = {pos.X(),pos.Y(),pos.Z(),pos.T()};
528  vector<double> tmp2 = {opDetPos[0],opDetPos[1],opDetPos[2],tprop};
529  fEnterXYZT.push_back(tmp1);
530  fPMTXYZT.push_back(tmp2);
531  firstIV = false;
532  firstAV = true;
533  firstFV = true;
534  }//if AV
535  }//if IV
536  if(firstAV) break;
537  }//for traj points
538  }
539  else {
540  std::cout << "CRTHit trackID " << trackID << " not found in particle map!" << std::endl;
541  fHitPDG.push_back(INT_MAX);
542  fTrueDist.push_back(DBL_MAX);
543  fTrueTOF.push_back(DBL_MAX);
544  fEnterXYZT.push_back({DBL_MAX,DBL_MAX,DBL_MAX,DBL_MAX});
545  fPMTXYZT.push_back({DBL_MAX,DBL_MAX,DBL_MAX,DBL_MAX});
546  }
547  fIV.push_back(firstIV);
548  fAV.push_back(firstAV);
549  fFV.push_back(firstFV);
550  if(!firstAV&&fHitPDG.back()!=INT_MAX){
551  fTrueDist.push_back(DBL_MAX);
552  fTrueTOF.push_back(DBL_MAX);
553  fEnterXYZT.push_back({DBL_MAX,DBL_MAX,DBL_MAX,DBL_MAX});
554  fPMTXYZT.push_back({DBL_MAX,DBL_MAX,DBL_MAX,DBL_MAX});
555  }//end get truth info
556 
557  // -- flash match --
558  int matchtpc = -1;
559  double tdiff = DBL_MAX, rdiff=DBL_MAX, peflash=DBL_MAX;
560  bool matched=false;
561  xyzt.clear();
562  double flashHitT = DBL_MAX, flashHitPE=DBL_MAX, flashHitDiff=DBL_MAX;
563  vector<double> flashHitxyzt;
564 
565  for(auto const& flashList : opFlashLists) {
566 
567  art::FindManyP<recob::OpHit> findManyHits(
568  flashHandles[flashList.first], e, fFlashLabels[flashList.first]);
569 
570  for(size_t iflash=0; iflash<flashList.second.size(); iflash++) {
571 
572  auto const& flash = flashList.second[iflash];
573  if(flash->TotalPE()<fFlashPeThresh){
574  continue;
575  }
576 
577  double tflash = flash->Time()*1e3-fOpDelay;
578  TVector3 rflash(0,flash->YCenter(),flash->ZCenter());
579  TVector3 vdiff = rcrt-rflash;
580  if(abs(tcrt-tflash)<abs(tdiff)) {
581  peflash = flash->TotalPE();
582  tdiff = tcrt-tflash;
583  rdiff = vdiff.Mag();
584  xyzt.clear();
585  xyzt.push_back(rflash.X());
586  xyzt.push_back(rflash.Y());
587  xyzt.push_back(rflash.Z());
588  xyzt.push_back(tflash);
589  matched = true;
590  matchtpc = flashList.first;
591 
592  vector<art::Ptr<recob::OpHit>> hits = findManyHits.at(iflash);
593  for(auto const& hit : hits) {
594  double tPmt = hit->PeakTime()*1.e3-fOpDelay;
595  if( tPmt < flashHitT) {
596  flashHitT = tPmt;
597  flashHitPE = hit->PE();
598 
599  //FlashHit position/time
600  double pos[3];
601  fGeometryService->OpDetGeoFromOpChannel(hit->OpChannel()).GetCenter(pos);
602  flashHitxyzt.clear();
603  for(int i=0; i<3; i++) flashHitxyzt.push_back(pos[i]);
604  flashHitxyzt.push_back(flashHitT);
605 
606  //FlashHit distance
607  TVector3 rflashHit(pos[0],pos[1],pos[2]);
608  TVector3 vdiffHit = rcrt-rflashHit;
609  flashHitDiff = vdiffHit.Mag();
610  }
611  }//loop over flash hits
612 
613  }//if minimum tdiff
614  }//for OpFlash in this flash list
615  }//for flash lists
616  if(!matched) {
617  peflash = DBL_MAX;
618  for(int i=0; i<4; i++) xyzt.push_back(DBL_MAX);
619  }
620 
621  fMatchFlash.push_back(matched);
622  fTofFlash.push_back(tdiff);
623  fTofPeFlash.push_back(peflash);
624  fTofXYZTFlash.push_back(xyzt);
625  fDistFlash.push_back(rdiff);
626  fTofTpcFlash.push_back(matchtpc);
627  fTofFlashHit.push_back(tcrt-flashHitT);
628  fTofPeFlashHit.push_back(flashHitPE);
629  fTofXYZTFlashHit.push_back(flashHitxyzt);
630  fDistFlashHit.push_back(flashHitDiff);
631 
632  // -- match OpHits to CRTHits --
633  tdiff = DBL_MAX;
634  matched = false;
635  peflash = DBL_MAX;
636  rdiff = DBL_MAX;
637  xyzt.clear();
638 
639  double pemax = 0.;
640  for(auto const& hit : opHitList) {
641  double thit = hit->PeakTime()*1e3-fOpDelay;
642  if(hit->PE()<fHitPeThresh){
643  continue;
644  }
645 
646  //if(abs(tcrt-thit)<abs(tdiff)) {
647  if(abs(tcrt-thit)<fCoinWindow && hit->PE()>pemax) {
648  pemax = hit->PE();
649 
650  //hitXYZT
651  double pos[3];
652  fGeometryService->OpDetGeoFromOpChannel(hit->OpChannel()).GetCenter(pos);
653 
654  //distHit
655  TVector3 rhit (pos[0],pos[1],pos[2]);
656  TVector3 vdiff = rcrt-rhit;
657 
658  //double vel = abs(vdiff.Mag()/(tcrt-thit));
659  //if(vel>fHitVelocityMax || vel<fHitVelocityMin)
660  // continue;
661  rdiff = vdiff.Mag();
662  peflash = hit->PE();
663  tdiff = tcrt-thit;
664  xyzt.clear();
665  for(int i=0; i<3; i++) xyzt.push_back(pos[i]);
666  xyzt.push_back(thit);
667 
668  matched = true;
669 
670  }//if min tof
671  }//for OpHits
672  if(!matched) {
673  tdiff = DBL_MAX;
674  peflash = DBL_MAX;
675  rdiff = DBL_MAX;
676  xyzt.clear();
677  for(int i=0; i<4; i++) xyzt.push_back(DBL_MAX);
678  }
679 
680  fMatchHit.push_back(matched);
681  fTofHit.push_back(tdiff);
682  fTofPeHit.push_back(peflash);
683  fTofXYZTHit.push_back(xyzt);
684  fDistHit.push_back(rdiff);
685  fTofTpcHit.push_back(matchtpc);
686  }//for CRTHits
687 
688  fMatchTree->Fill();
689 
690 }//analyze
unsigned int GetClosestOpDet(geo::Point_t const &point) const
Geometry information for a single TPC.
Definition: TPCGeo.h:38
process_name hit
Definition: cheaterreco.fcl:51
Geometry information for a single cryostat.
Definition: CryostatGeo.h:43
process_name gaushit a
T abs(T value)
const OpDetGeo & OpDet(unsigned int iopdet) const
Return the iopdet&#39;th optical detector in the cryostat.
bool HitCompare(const art::Ptr< CRTHit > &h1, const art::Ptr< CRTHit > &h2)
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
BEGIN_PROLOG opflashCryoW opflashCryoW triggerfilterBNB triggerfilterNuMI triggerfilterOffbeamBNB triggerfilterOffbeamNuMI triggerfilterUnknown roifinder roifinder2d gaushitTPCEE gaushitTPCWE purityana1 ophit
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
Definition: CryostatGeo.cxx:93
do i e
static double tdiff(const art::Timestamp &ts1, const art::Timestamp &ts2)
int TrueIdFromTotalEnergy(const art::Event &event, const CRTData &data)
geo::GeometryCore const * fGeometryService
pointer to Geometry provider
process_name crt
BEGIN_PROLOG SN nu
OpDetGeo const & OpDetGeoFromOpChannel(unsigned int OpChannel) const
Returns the geo::OpDetGeo object for the given channel number.
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
BEGIN_PROLOG could also be cout
void CrtOpHitMatchAnalysis::ClearVecs ( )
private

Definition at line 692 of file CrtOpHitMatchAnalysis_module.cc.

693 {
694  //matchTree
695  fCrtXYZT.clear();
696  fCrtXYZErr.clear();
697  fCrtRegion.clear();
698  fCrtPE.clear();
699  fTofHit.clear();
700  fTofFlash.clear();
701  fTofFlashHit.clear();
702  fDistHit.clear();
703  fDistFlash.clear();
704  fDistFlashHit.clear();
705  fTofPeHit.clear();
706  fTofPeFlash.clear();
707  fTofPeFlashHit.clear();
708  fTofXYZTHit.clear();
709  fTofXYZTFlash.clear();
710  fTofXYZTFlashHit.clear();
711  fTofTpcHit.clear();
712  fTofTpcFlash.clear();
713  fMatchHit.clear();
714  fMatchFlash.clear();
715  fTrueDist.clear();
716  fTrueTOF.clear();
717  fEnterXYZT.clear();
718  fPMTXYZT.clear();
719  fHitPDG.clear();
720  fIV.clear();
721  fAV.clear();
722  fFV.clear();
723  fTrackFilt.clear();
724 
725  //hitTree
726  fHitXYZT.clear();
727  fHitPE.clear();
728  fHitChan.clear();
729 
730  //flashTree
731  fFlashTPC.clear();
732  fFlashXYZT.clear();
733  fFlashPE.clear();
734  fFlashMeanPE.clear();
735  fFlashRmsPE.clear();
736  fFlashDelta.clear();
737 
738 }
bool CrtOpHitMatchAnalysis::HitCompare ( const art::Ptr< CRTHit > &  h1,
const art::Ptr< CRTHit > &  h2 
)
private

Definition at line 741 of file CrtOpHitMatchAnalysis_module.cc.

741  {
742 
743  if(hit1->ts1_ns != hit2->ts1_ns) return false;
744  if(hit1->plane != hit2->plane) return false;
745  if(hit1->x_pos != hit2->x_pos) return false;
746  if(hit1->y_pos != hit2->y_pos) return false;
747  if(hit1->z_pos != hit2->z_pos) return false;
748  if(hit1->x_err != hit2->x_err) return false;
749  if(hit1->y_err != hit2->y_err) return false;
750  if(hit1->z_err != hit2->z_err) return false;
751  if(hit1->tagger != hit2->tagger) return false;
752 
753  return true;
754 
755 }
CrtOpHitMatchAnalysis& icarus::crt::CrtOpHitMatchAnalysis::operator= ( CrtOpHitMatchAnalysis const &  )
delete
CrtOpHitMatchAnalysis& icarus::crt::CrtOpHitMatchAnalysis::operator= ( CrtOpHitMatchAnalysis &&  )
delete

Member Data Documentation

CRTBackTracker* icarus::crt::CrtOpHitMatchAnalysis::bt
private

Definition at line 107 of file CrtOpHitMatchAnalysis_module.cc.

CRTCommonUtils* icarus::crt::CrtOpHitMatchAnalysis::crtutil
private

Definition at line 108 of file CrtOpHitMatchAnalysis_module.cc.

vector<bool> icarus::crt::CrtOpHitMatchAnalysis::fAV
private

Definition at line 144 of file CrtOpHitMatchAnalysis_module.cc.

double icarus::crt::CrtOpHitMatchAnalysis::fCoinWindow
private

Definition at line 97 of file CrtOpHitMatchAnalysis_module.cc.

double icarus::crt::CrtOpHitMatchAnalysis::fCrtDelay
private

Definition at line 99 of file CrtOpHitMatchAnalysis_module.cc.

art::InputTag icarus::crt::CrtOpHitMatchAnalysis::fCrtHitModuleLabel
private

Definition at line 94 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fCrtPE
private

Definition at line 121 of file CrtOpHitMatchAnalysis_module.cc.

vector<int> icarus::crt::CrtOpHitMatchAnalysis::fCrtRegion
private

Definition at line 120 of file CrtOpHitMatchAnalysis_module.cc.

art::InputTag icarus::crt::CrtOpHitMatchAnalysis::fCrtTrackModuleLabel
private

Definition at line 95 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fCrtXYZErr
private

Definition at line 119 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fCrtXYZT
private

Definition at line 118 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fDistFlash
private

Definition at line 126 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fDistFlashHit
private

Definition at line 127 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fDistHit
private

Definition at line 125 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fEnterXYZT
private

Definition at line 140 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fFlashDelta
private

Definition at line 169 of file CrtOpHitMatchAnalysis_module.cc.

map<int,art::InputTag> icarus::crt::CrtOpHitMatchAnalysis::fFlashLabels
private

Definition at line 110 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fFlashMeanPE
private

Definition at line 167 of file CrtOpHitMatchAnalysis_module.cc.

vector<int> icarus::crt::CrtOpHitMatchAnalysis::fFlashNHit
private

Definition at line 166 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fFlashPE
private

Definition at line 165 of file CrtOpHitMatchAnalysis_module.cc.

int icarus::crt::CrtOpHitMatchAnalysis::fFlashPeThresh
private

Definition at line 100 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fFlashRmsPE
private

Definition at line 168 of file CrtOpHitMatchAnalysis_module.cc.

vector<int> icarus::crt::CrtOpHitMatchAnalysis::fFlashTPC
private

Definition at line 163 of file CrtOpHitMatchAnalysis_module.cc.

TTree* icarus::crt::CrtOpHitMatchAnalysis::fFlashTree
private

Definition at line 114 of file CrtOpHitMatchAnalysis_module.cc.

double icarus::crt::CrtOpHitMatchAnalysis::fFlashVelocity
private

Definition at line 102 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fFlashXYZT
private

Definition at line 164 of file CrtOpHitMatchAnalysis_module.cc.

double icarus::crt::CrtOpHitMatchAnalysis::fFlashZOffset
private

Definition at line 103 of file CrtOpHitMatchAnalysis_module.cc.

vector<bool> icarus::crt::CrtOpHitMatchAnalysis::fFV
private

Definition at line 145 of file CrtOpHitMatchAnalysis_module.cc.

art::InputTag icarus::crt::CrtOpHitMatchAnalysis::fGenLabel
private

Definition at line 87 of file CrtOpHitMatchAnalysis_module.cc.

geo::GeometryCore const* icarus::crt::CrtOpHitMatchAnalysis::fGeometryService
private

pointer to Geometry provider

Definition at line 171 of file CrtOpHitMatchAnalysis_module.cc.

vector<int> icarus::crt::CrtOpHitMatchAnalysis::fHitChan
private

Definition at line 158 of file CrtOpHitMatchAnalysis_module.cc.

vector<int> icarus::crt::CrtOpHitMatchAnalysis::fHitPDG
private

Definition at line 142 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fHitPE
private

Definition at line 157 of file CrtOpHitMatchAnalysis_module.cc.

int icarus::crt::CrtOpHitMatchAnalysis::fHitPeThresh
private

Definition at line 101 of file CrtOpHitMatchAnalysis_module.cc.

TTree* icarus::crt::CrtOpHitMatchAnalysis::fHitTree
private

Definition at line 113 of file CrtOpHitMatchAnalysis_module.cc.

double icarus::crt::CrtOpHitMatchAnalysis::fHitVelocityMax
private

Definition at line 104 of file CrtOpHitMatchAnalysis_module.cc.

double icarus::crt::CrtOpHitMatchAnalysis::fHitVelocityMin
private

Definition at line 105 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fHitXYZT
private

Definition at line 159 of file CrtOpHitMatchAnalysis_module.cc.

vector<bool> icarus::crt::CrtOpHitMatchAnalysis::fIV
private

Definition at line 143 of file CrtOpHitMatchAnalysis_module.cc.

vector<bool> icarus::crt::CrtOpHitMatchAnalysis::fMatchFlash
private

Definition at line 137 of file CrtOpHitMatchAnalysis_module.cc.

vector<bool> icarus::crt::CrtOpHitMatchAnalysis::fMatchHit
private

Definition at line 136 of file CrtOpHitMatchAnalysis_module.cc.

TTree* icarus::crt::CrtOpHitMatchAnalysis::fMatchTree
private

Definition at line 112 of file CrtOpHitMatchAnalysis_module.cc.

int icarus::crt::CrtOpHitMatchAnalysis::fNCrt
private

Definition at line 117 of file CrtOpHitMatchAnalysis_module.cc.

int icarus::crt::CrtOpHitMatchAnalysis::fNFlash
private

Definition at line 162 of file CrtOpHitMatchAnalysis_module.cc.

int icarus::crt::CrtOpHitMatchAnalysis::fNHit
private

Definition at line 156 of file CrtOpHitMatchAnalysis_module.cc.

bool icarus::crt::CrtOpHitMatchAnalysis::fNu
private

Definition at line 146 of file CrtOpHitMatchAnalysis_module.cc.

bool icarus::crt::CrtOpHitMatchAnalysis::fNuAV
private

Definition at line 151 of file CrtOpHitMatchAnalysis_module.cc.

bool icarus::crt::CrtOpHitMatchAnalysis::fNuCC
private

Definition at line 147 of file CrtOpHitMatchAnalysis_module.cc.

double icarus::crt::CrtOpHitMatchAnalysis::fNuE
private

Definition at line 148 of file CrtOpHitMatchAnalysis_module.cc.

bool icarus::crt::CrtOpHitMatchAnalysis::fNuFV
private

Definition at line 152 of file CrtOpHitMatchAnalysis_module.cc.

bool icarus::crt::CrtOpHitMatchAnalysis::fNuIV
private

Definition at line 150 of file CrtOpHitMatchAnalysis_module.cc.

double icarus::crt::CrtOpHitMatchAnalysis::fNuXYZT[4]
private

Definition at line 149 of file CrtOpHitMatchAnalysis_module.cc.

double icarus::crt::CrtOpHitMatchAnalysis::fOpDelay
private

Definition at line 98 of file CrtOpHitMatchAnalysis_module.cc.

art::InputTag icarus::crt::CrtOpHitMatchAnalysis::fOpFlashModuleLabel0
private

Definition at line 90 of file CrtOpHitMatchAnalysis_module.cc.

art::InputTag icarus::crt::CrtOpHitMatchAnalysis::fOpFlashModuleLabel1
private

Definition at line 91 of file CrtOpHitMatchAnalysis_module.cc.

art::InputTag icarus::crt::CrtOpHitMatchAnalysis::fOpFlashModuleLabel2
private

Definition at line 92 of file CrtOpHitMatchAnalysis_module.cc.

art::InputTag icarus::crt::CrtOpHitMatchAnalysis::fOpFlashModuleLabel3
private

Definition at line 93 of file CrtOpHitMatchAnalysis_module.cc.

art::InputTag icarus::crt::CrtOpHitMatchAnalysis::fOpHitModuleLabel
private

Definition at line 89 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fPMTXYZT
private

Definition at line 141 of file CrtOpHitMatchAnalysis_module.cc.

art::InputTag icarus::crt::CrtOpHitMatchAnalysis::fSimLabel
private

Definition at line 88 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fTofFlash
private

Definition at line 123 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fTofFlashHit
private

Definition at line 124 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fTofHit
private

Definition at line 122 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fTofPeFlash
private

Definition at line 129 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fTofPeFlashHit
private

Definition at line 130 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fTofPeHit
private

Definition at line 128 of file CrtOpHitMatchAnalysis_module.cc.

vector<int> icarus::crt::CrtOpHitMatchAnalysis::fTofTpcFlash
private

Definition at line 135 of file CrtOpHitMatchAnalysis_module.cc.

vector<int> icarus::crt::CrtOpHitMatchAnalysis::fTofTpcHit
private

Definition at line 134 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fTofXYZTFlash
private

Definition at line 132 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fTofXYZTFlashHit
private

Definition at line 133 of file CrtOpHitMatchAnalysis_module.cc.

vector<vector<double> > icarus::crt::CrtOpHitMatchAnalysis::fTofXYZTHit
private

Definition at line 131 of file CrtOpHitMatchAnalysis_module.cc.

vector<bool> icarus::crt::CrtOpHitMatchAnalysis::fTrackFilt
private

Definition at line 153 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fTrueDist
private

Definition at line 138 of file CrtOpHitMatchAnalysis_module.cc.

vector<double> icarus::crt::CrtOpHitMatchAnalysis::fTrueTOF
private

Definition at line 139 of file CrtOpHitMatchAnalysis_module.cc.

const double icarus::crt::CrtOpHitMatchAnalysis::LAR_PROP_DELAY = 1.0/(30.0/1.38)
private

Definition at line 81 of file CrtOpHitMatchAnalysis_module.cc.


The documentation for this class was generated from the following file: