20 #include "nusimdata/SimulationBase/MCParticle.h"
21 #include "nusimdata/SimulationBase/MCTruth.h"
25 #include "art/Framework/Core/EDAnalyzer.h"
26 #include "art/Framework/Principal/Event.h"
27 #include "art/Framework/Principal/Handle.h"
28 #include "art/Framework/Services/Registry/ServiceHandle.h"
29 #include "art_root_io/TFileService.h"
30 #include "art/Framework/Core/ModuleMacros.h"
31 #include "canvas/Persistency/Common/FindManyP.h"
32 #include "canvas/Utilities/Exception.h"
35 #include "messagefacility/MessageLogger/MessageLogger.h"
36 #include "fhiclcpp/ParameterSet.h"
37 #include "fhiclcpp/types/Table.h"
38 #include "fhiclcpp/types/Atom.h"
39 #include "cetlib/pow.h"
45 #include "TLorentzVector.h"
47 #include "TGeoManager.h"
75 int ProcessToICode(
string const&
p);
126 virtual void beginRun(
const art::Run& run)
override;
127 virtual void analyze (
const art::Event& event)
override;
334 , fSimulationProducerLabel(
p.get<art::InputTag>(
"SimulationLabel",
"largeant"))
335 , fCRTSimHitProducerLabel(
p.get<art::InputTag>(
"CRTSimHitLabel",
"crthit"))
336 , fCRTTrueHitProducerLabel(
p.get<art::InputTag>(
"CRTTrueHitLabel",
"crttruehit"))
337 , fCRTDetSimProducerLabel(
p.get<art::InputTag>(
"CRTDetSimLabel",
"crtdaq"))
338 , fCRTSimTrackProducerLabel(
p.get<art::InputTag>(
"CRTSimTrackLabel",
"crttrack"))
339 , fPDGs(
p.get<vector<int>>(
"PDGs"))
340 , fMinMomenta(
p.get<vector<float>>(
"MinMomenta"))
341 , fMaxMomenta(
p.get<vector<float>>(
"MaxMomenta"))
342 , bt(
p.get<fhicl::ParameterSet>(
"CRTBackTrack"))
345 fGeometryService = lar::providerFrom<geo::Geometry>();
346 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataForJob();
353 std::cout <<
" starting analysis job" << std::endl;
357 art::ServiceHandle<art::TFileService>
tfs;
360 fCosmicDisplayNtuple = tfs->make<TTree>(
"DisplayTree",
"track information for ROOT event display");
361 fGenNtuple = tfs->make<TTree>(
"GenTree",
"truth information from the generator");
363 fRegionsNtuple = tfs->make<TTree>(
"RegTree",
"Info about particles crossing boundaries");
366 fTrueCRTHitNtuple = tfs->make<TTree>(
"TrueCRTHitTree",
"CRT hits from truth info");
367 fSimTrackNtuple = tfs->make<TTree>(
"SimTrackTree",
"Simulated CRTTracks");
382 fGenNtuple->Branch(
"event", &
fEvent,
"event/I");
383 fGenNtuple->Branch(
"run", &
fRun,
"run/I");
384 fGenNtuple->Branch(
"subRun", &
fSubRun,
"subRun/I");
385 fGenNtuple->Branch(
"nGen", &
fNGen,
"nGen/I");
386 fGenNtuple->Branch(
"trackID", &
fGenTrack);
387 fGenNtuple->Branch(
"pdg", &
fGenPDG);
394 fSimulationNtuple->Branch(
"event", &
fEvent,
"event/I");
395 fSimulationNtuple->Branch(
"run", &
fRun,
"run/I");
396 fSimulationNtuple->Branch(
"subRun", &
fSubRun,
"subrun/I");
397 fSimulationNtuple->Branch(
"nPoints" , &
fSimHits,
"nPoints/I");
398 fSimulationNtuple->Branch(
"trackID", &
fSimTrackID,
"trackID/I");
399 fSimulationNtuple->Branch(
"pdg", &
fSimPDG,
"pdg/I");
400 fSimulationNtuple->Branch(
"trackLength", &
fTrackLength,
"trackLenth/F");
401 fSimulationNtuple->Branch(
"process", &
fSimProcess,
"process/I");
402 fSimulationNtuple->Branch(
"endProcess", &
fSimEndProcess,
"endProcess/I");
403 fSimulationNtuple->Branch(
"parentPDG", &
fParentPDG,
"parentPDG/I");
404 fSimulationNtuple->Branch(
"parentE", &
fParentE,
"parentE/F");
405 fSimulationNtuple->Branch(
"progenitor", &
fProgenitor,
"progenitor/I");
409 fSimulationNtuple->Branch(
"auxDetID", &
fAuxDetID);
410 fSimulationNtuple->Branch(
"auxDetEDep", &
fADEDep);
411 fSimulationNtuple->Branch(
"auxDetdEdx", &
fADdEdx);
413 fSimulationNtuple->Branch(
"auxDetEnterXYZT", &
fADEnterXYZT);
414 fSimulationNtuple->Branch(
"auxDetExitXYZT", &
fADExitXYZT);
415 fSimulationNtuple->Branch(
"auxDetEnterPE", &
fADEnterPE);
416 fSimulationNtuple->Branch(
"auxDetExitPE", &
fADExitPE);
417 fSimulationNtuple->Branch(
"auxDetRegion", &
fAuxDetReg);
418 fSimulationNtuple->Branch(
"mac5", &
fADMac);
419 fSimulationNtuple->Branch(
"adType", &
fADType);
421 fSimulationNtuple->Branch(
"startXYZT",
fStartXYZT,
"startXYZT[4]/F");
422 fSimulationNtuple->Branch(
"endXYZT",
fEndXYZT,
"endXYZT[4]/F");
423 fSimulationNtuple->Branch(
"startPE",
fStartPE,
"startPE[4]/F");
424 fSimulationNtuple->Branch(
"endPE",
fEndPE,
"endPE[4]/F");
425 fSimulationNtuple->Branch(
"nChan", &
fNAuxDet,
"nChan/I");
426 fSimulationNtuple->Branch(
"mother", &
fMother,
"mother/I");
427 fSimulationNtuple->Branch(
"nDaught", &
fNDaught,
"nDaught/I");
430 fRegionsNtuple->Branch(
"event", &
fEvent,
"event/I");
431 fRegionsNtuple->Branch(
"run", &
fRun,
"run/I");
432 fRegionsNtuple->Branch(
"subRun", &
fSubRun,
"subRun/I");
433 fRegionsNtuple->Branch(
"nReg", &
fNReg,
"nReg/I");
434 fRegionsNtuple->Branch(
"fiducial", &
fRegFid,
"fiducial/I");
435 fRegionsNtuple->Branch(
"active", &
fRegActive,
"active/I");
436 fRegionsNtuple->Branch(
"inactive", &
fRegInactive,
"inactive/I");
437 fRegionsNtuple->Branch(
"crts", &
fRegCRTs,
"crts/I");
439 fRegionsNtuple->Branch(
"pdg", &
fRegPDG,
"pdg/I");
440 fRegionsNtuple->Branch(
"trackID", &
fRegTrkID,
"trackID/I");
441 fRegionsNtuple->Branch(
"eDep", &
fRegEDep);
442 fRegionsNtuple->Branch(
"dL", &
fRegdL);
447 fRegionsNtuple->Branch(
"exitPE", &
fRegExitPE);
454 fDetSimNtuple->Branch(
"event", &
fEvent,
"event/I");
455 fDetSimNtuple->Branch(
"run", &
fRun,
"run/I");
456 fDetSimNtuple->Branch(
"subRun", &
fSubRun,
"subRun/I");
457 fDetSimNtuple->Branch(
"nAbove", &
fNAbove,
"nAbove/I");
458 fDetSimNtuple->Branch(
"t0", &
fT0,
"t0/I");
459 fDetSimNtuple->Branch(
"t1", &
fT1,
"t1/I");
460 fDetSimNtuple->Branch(
"adc",
fADC,
"adc[64]/I");
461 fDetSimNtuple->Branch(
"maxAdc", &
fMaxAdc,
"maxAdc/I");
462 fDetSimNtuple->Branch(
"maxChan", &
fMaxChan,
"maxChan/I");
463 fDetSimNtuple->Branch(
"trackID", &
fTrackID);
464 fDetSimNtuple->Branch(
"detPDG", &
fDetPDG);
465 fDetSimNtuple->Branch(
"entry", &
fEntry,
"entry/I");
466 fDetSimNtuple->Branch(
"mac5", &
fMac5,
"mac5/I");
467 fDetSimNtuple->Branch(
"region", &
fFEBReg,
"region/I");
468 fDetSimNtuple->Branch(
"subSys", &
fDetSubSys,
"subSys/I");
471 fSimHitNtuple->Branch(
"event", &
fEvent,
"event/I");
472 fSimHitNtuple->Branch(
"run", &
fRun,
"run/I");
473 fSimHitNtuple->Branch(
"subRun", &
fSubRun,
"subRun/I");
474 fSimHitNtuple->Branch(
"nHit", &
fNHit,
"nHit/I");
475 fSimHitNtuple->Branch(
"x", &
fXHit,
"x/F");
476 fSimHitNtuple->Branch(
"y", &
fYHit,
"y/F");
477 fSimHitNtuple->Branch(
"z", &
fZHit,
"z/F");
478 fSimHitNtuple->Branch(
"xErr", &
fXHitErr,
"xErr/F");
479 fSimHitNtuple->Branch(
"yErr", &
fYHitErr,
"yErr/F");
480 fSimHitNtuple->Branch(
"zErr", &
fZHitErr,
"zErr/F");
481 fSimHitNtuple->Branch(
"t0", &
fT0Hit,
"t0/F");
482 fSimHitNtuple->Branch(
"t1", &
fT1Hit,
"t1/F");
483 fSimHitNtuple->Branch(
"region", &
fHitReg,
"region/I");
484 fSimHitNtuple->Branch(
"subSys", &
fHitSubSys,
"subSys/I");
485 fSimHitNtuple->Branch(
"trackID", &
fHitTrk);
486 fSimHitNtuple->Branch(
"pdg", &
fHitPDG);
487 fSimHitNtuple->Branch(
"modID", &
fHitMod);
488 fSimHitNtuple->Branch(
"stripID", &
fHitStrip);
489 fSimHitNtuple->Branch(
"nFeb", &
fNHitFeb,
"nFeb/I");
490 fSimHitNtuple->Branch(
"hitPe", &
fHitPe);
491 fSimHitNtuple->Branch(
"totPe", &
fHitTotPe,
"totPe/F");
492 fSimHitNtuple->Branch(
"rmsPe", &
fHitPeRms,
"rmsPe/F");
495 fTrueCRTHitNtuple->Branch(
"event", &
fEvent,
"event/I");
496 fTrueCRTHitNtuple->Branch(
"run", &
fRun,
"run/I");
497 fTrueCRTHitNtuple->Branch(
"subRun", &
fSubRun,
"subRun/I");
498 fTrueCRTHitNtuple->Branch(
"nHit", &
fTrueNHit,
"nHit/I");
499 fTrueCRTHitNtuple->Branch(
"x", &
fTrueXHit,
"x/F");
500 fTrueCRTHitNtuple->Branch(
"y", &
fTrueYHit,
"y/F");
501 fTrueCRTHitNtuple->Branch(
"z", &
fTrueZHit,
"z/F");
502 fTrueCRTHitNtuple->Branch(
"xErr", &
fTrueXHitErr,
"xErr/F");
503 fTrueCRTHitNtuple->Branch(
"yErr", &
fTrueYHitErr,
"yErr/F");
504 fTrueCRTHitNtuple->Branch(
"zErr", &
fTrueZHitErr,
"zErr/F");
505 fTrueCRTHitNtuple->Branch(
"t0", &
fTrueT0Hit,
"t0/F");
506 fTrueCRTHitNtuple->Branch(
"t1", &
fTrueT1Hit,
"t1/F");
507 fTrueCRTHitNtuple->Branch(
"region", &
fTrueHitReg,
"region/I");
509 fTrueCRTHitNtuple->Branch(
"trackID", &
fTrueHitTrk);
513 fTrueCRTHitNtuple->Branch(
"nFeb", &
fTrueNHitFeb,
"nFeb/I");
514 fTrueCRTHitNtuple->Branch(
"hitPe", &
fTrueHitPe);
515 fTrueCRTHitNtuple->Branch(
"totPe", &
fTrueHitTotPe,
"totPe/F");
516 fTrueCRTHitNtuple->Branch(
"rmsPe", &
fTrueHitPeRms,
"rmsPe/F");
518 fSimTrackNtuple->Branch(
"ntrack", &
fNSimTrack,
"ntrack/I");
519 fSimTrackNtuple->Branch(
"pe", &
fSimTrackPE,
"pe/F");
522 fSimTrackNtuple->Branch(
"end",
fSimTrackEnd,
"end[3]/F");
523 fSimTrackNtuple->Branch(
"l", &
fSimTrackL,
"l/F");
539 std::cout <<
"beginning run" << std::endl;
545 MF_LOG_DEBUG(
"CRT") <<
"beginning analyis" <<
'\n';
549 throw cet::exception(
"CRTSimAnalysis")
550 <<
" PDG/Momtenta values not set correctly in fhicl - lists have different sizes"
551 <<
" Line " << __LINE__ <<
" in file " << __FILE__ << std::endl;
555 fEvent =
event.id().event();
563 art::Handle< vector<simb::MCTruth>> genHandle;
566 art::Handle< vector<simb::MCParticle> > particleHandle;
567 map< int, const simb::MCParticle*> particleMap;
569 if (!event.getByLabel(
"generator", genHandle)) {
570 std::cout <<
"could not get handle to gen objects!!!" << std::endl;
580 throw cet::exception(
"CRTSimAnalysis")
581 <<
" No simb::MCParticle objects in this event - "
582 <<
" Line " << __LINE__ <<
" in file " << __FILE__ << std::endl;
586 art::Handle<vector<sim::AuxDetSimChannel> > auxDetSimChannelHandle;
588 throw cet::exception(
"CRTSimAnalysis")
589 <<
" No sim::AuxDetSimChannel objects in this event - "
590 <<
" Line " << __LINE__ <<
" in file " << __FILE__ << std::endl;
593 if((*genHandle).size()>1)
594 throw cet::exception(
"CRTSimAnalysis") <<
"gen stage MCParticle vector has more than 1 entry!" <<
'\n';
596 auto const& truth = (*genHandle)[0];
597 fNGen = truth.NParticles();
605 for (
int i=0; i<
fNGen; i++ )
607 auto const& part = truth.GetParticle(i);
610 fGenPDG.push_back(part.PdgCode());
612 const TLorentzVector startPos = part.Position(0);
613 const TLorentzVector endPos = part.EndPosition();
614 const TLorentzVector startMom = part.Momentum(0);
615 const TLorentzVector endMom = part.EndMomentum();
617 fGenStartXYZT.push_back({startPos.X(),startPos.Y(),startPos.Z(),startPos.T()});
618 fGenEndXYZT.push_back({endPos.X(),endPos.Y(),endPos.Z(),endPos.T()});
619 fGenStartPE.push_back({startMom.Px(),startMom.Py(),startMom.Pz(),startMom.E()});
620 fGenEndPE.push_back({endMom.Px(),endMom.Py(),endMom.Pz(),endMom.E()});
629 for (
auto const& particle : (*particleHandle) )
633 particleMap.insert(std::make_pair(particle.TrackId(),&particle));
636 std::cout <<
"event " <<
fEvent <<
" with " << particleMap.size() <<
" MCParticles" << std::endl;
648 for (
auto const& particle : (*particleHandle) )
651 vector<int>::iterator it =
fPDGs.begin();
652 const TLorentzVector& momentumStart = particle.Momentum(0);
653 const double p = (momentumStart.Vect()).Mag();
659 while (it!=
fPDGs.end()) {
661 index = (size_t)(it -
fPDGs.begin());
685 fNDaught = particle.NumberDaughters();
690 map<int,const simb::MCParticle*>::const_iterator it = particleMap.find(
fMother);
691 if(it==particleMap.end()){
699 int tmpID=it->second->Mother();
701 map<int,const simb::MCParticle*>::iterator it2 = particleMap.begin();
704 else while(it2!=particleMap.end()&&ctr<particleMap.size()){
705 it2=particleMap.find(tmpID);
706 if(it2!=particleMap.end()){
707 if(it2->second->PdgCode()==13||it2->second->PdgCode()==-13){
711 tmpID = it2->second->Mother();
715 if(ctr==particleMap.size())
std::cout<<
"manual break!"<<std::endl;
730 fSimHits = particle.NumberTrajectoryPoints();
736 const TLorentzVector& positionStart = particle.Position(0);
737 const TLorentzVector& positionEnd = particle.Position(last);
739 const TLorentzVector& momentumEnd = particle.Momentum(last);
745 momentumEnd.GetXYZT(
fEndPE );
778 for (
unsigned int i=0; i<
fSimHits; i++){
779 const TLorentzVector& pos = particle.Position(i);
780 const TLorentzVector& posnext = particle.Position(i+1);
781 const TLorentzVector& mom = particle.Momentum(i);
782 const double point[3] = {pos.X(),pos.Y(),pos.Z()};
783 const double pointnext[3] = {posnext.X(),posnext.Y(),posnext.Z()};
784 double opDetPos[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
785 double entryPos[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX};
786 double entryT = -FLT_MAX;
787 bool active0 =
false, active1 =
false, activenext0 =
false, activenext1 =
false;
790 fCDxyzt.push_back({pos.X(),pos.Y(),pos.Z(),pos.T()});
791 fCDpe.push_back({mom.Px(),mom.Py(),mom.Pz(),mom.E()});
792 fCDSlopes.push_back({mom.Px()/mom.P(), mom.Py()/mom.P(), mom.Pz()/mom.P()});
804 if ( (oldreg!=10&&!active0&&!active1) || (active0&&oldreg!=5) || (active1&&oldreg!=6)) {
806 fRegEntryPE.push_back({mom.Px(),mom.Py(),mom.Pz(),mom.E()});
807 fRegEntrySlope.push_back({mom.Px()/mom.P(), mom.Py()/mom.P(), mom.Pz()/mom.P()});
809 if (active0) oldreg = 5;
810 if (active1) oldreg = 6;
814 if (!cryo0.
ContainsPosition(pointnext) || (oldreg==10&&(activenext0||activenext1))
816 || (active0 && !activenext0) || (active1&&!activenext1) ){
821 fRegExitXYZT.push_back({pos.X(),pos.Y(),pos.Z(),pos.T()});
822 fRegExitPE.push_back({mom.Px(),mom.Py(),mom.Pz(),mom.E()});
823 fRegExitSlope.push_back({mom.Px()/mom.P(), mom.Py()/mom.P(), mom.Pz()/mom.P()});
844 std::cout <<
"entry/exit point size mismatch! " <<
850 for (
int index=0; index<3; index++) entryPos[index] =
fRegEntryXYZT[fNReg][index];
856 + pow(opDetPos[1]-entryPos[1],2)
857 + pow(opDetPos[2]-entryPos[2],2)));
859 for (
int index=0; index<3; index++)
fRegOpDetXYZT[fNReg].push_back(opDetPos[index]);
874 if ( (oldreg!=12&&!active0&&!active1) || (active0&&oldreg!=7) || (active1&&oldreg!=8)) {
876 fRegEntryPE.push_back({mom.Px(),mom.Py(),mom.Pz(),mom.E()});
877 fRegEntrySlope.push_back({mom.Px()/mom.P(), mom.Py()/mom.P(), mom.Pz()/mom.P()});
879 if (active0) oldreg = 7;
880 if (active1) oldreg = 8;
883 if (!cryo1.
ContainsPosition(pointnext) || (oldreg==12&&(activenext0||activenext1))
885 || (active0 && !activenext0) || (active1&&!activenext1) ){
890 fRegExitXYZT.push_back({pos.X(),pos.Y(),pos.Z(),pos.T()});
891 fRegExitPE.push_back({mom.Px(),mom.Py(),mom.Pz(),mom.E()});
892 fRegExitSlope.push_back({mom.Px()/mom.P(), mom.Py()/mom.P(), mom.Pz()/mom.P()});
916 for (
int index=0; index<3; index++) entryPos[index] =
fRegEntryXYZT[fNReg][index];
922 + pow(opDetPos[1]-entryPos[1],2)
923 + pow(opDetPos[2]-entryPos[2],2)));
925 for (
int index=0; index<3; index++)
fRegOpDetXYZT[fNReg].push_back(opDetPos[index]);
941 map< int, vector<double> > regCRTEnter, regCRTExit, regCRTEnterPE, regCRTExitPE;
961 for (
auto const& channel : (*auxDetSimChannelHandle) )
964 auto const& auxDetIDEs = channel.AuxDetIDEs();
967 for (
auto const& ide : auxDetIDEs )
972 if ( ide.energyDeposited * 1.0e6 < 50 )
continue;
974 size_t adid = channel.AuxDetID();
996 double dx = ide.entryX-ide.exitX;
997 double dy = ide.entryY-ide.exitY;
998 double dz = ide.entryZ-ide.exitZ;
999 double adlength = sqrt(dx*dx+dy*dy+dz*dz);
1000 if ( adlength < 0.0001)
continue;
1003 fADEDep.push_back(ide.energyDeposited);
1005 fAuxDetID.push_back(channel.AuxDetID());
1007 fADEnterXYZT.push_back({ide.entryX,ide.entryY,ide.entryZ,ide.entryT});
1008 fADExitXYZT.push_back({ide.exitX,ide.exitY,ide.exitZ,ide.exitT});
1010 double pmag = sqrt(pow(ide.exitMomentumX,2)+pow(ide.exitMomentumY,2)+pow(ide.exitMomentumZ,2));
1011 fADExitPE.push_back({ide.exitMomentumX,ide.exitMomentumY,ide.exitMomentumZ,pmag});
1017 if (regCRTEnter[
fAuxDetReg[fNAuxDet]][3] > ide.entryT) {
1027 if (regCRTExit.find(
fAuxDetReg[fNAuxDet])!=regCRTExit.end()) {
1028 if (regCRTExit[
fAuxDetReg[fNAuxDet]][3] < ide.exitT){
1046 for(
auto it=regCRTEnter.begin(); it!=regCRTEnter.end(); it++) {
1049 fRegEntryXYZT.push_back({(it->second)[0],(it->second)[1],(it->second)[2],(it->second)[3]});
1050 fRegExitXYZT.push_back({regCRTExit[it->first][0],regCRTExit[it->first][1],regCRTExit[it->first][2],
1051 regCRTExit[it->first][3]});
1055 fRegEntryPE.push_back({regCRTEnterPE[it->first][0],regCRTEnterPE[it->first][1],
1056 regCRTEnterPE[it->first][2], regCRTEnterPE[it->first][3]});
1057 fRegExitPE.push_back({regCRTExitPE[it->first][0],regCRTExitPE[it->first][1],
1058 regCRTExitPE[it->first][2], regCRTExitPE[it->first][3]});
1074 for(
int i = 1; (i <= (int)
fNReg) &&
flag; i++)
1077 for (
int j=0; j < ((int)
fNReg -1); j++)
1096 for (
int k=0;
k<4;
k++) {
1131 art::Handle<vector<CRTData>> crtDetSimHandle;
1134 vector<art::Ptr<CRTData>> febdata;
1135 art::fill_ptr_vector(febdata,crtDetSimHandle);
1136 mf::LogPrint(
"CRTSimAnalysis") <<
"found " << febdata.size() <<
" CRTData" <<
'\n';
1138 for (
auto const& data : febdata ) {
1139 fMac5 = data->fMac5;
1150 bool passfilter =
false;
1159 for(
int ch=0; ch<64; ch++) {
1160 fADC[ch] = data->fAdc[ch];
1171 if (particleMap.find(trk) != particleMap.end() ){
1172 fDetPDG.push_back(particleMap[trk]->PdgCode());
1191 mf::LogWarning(
"CRTSimAnalysis") <<
"CRTData products not found! (expected if gen/G4 step)" <<
'\n';
1195 art::Handle<vector<CRTHit>> crtSimHitHandle;
1199 vector<art::Ptr<CRTHit>> crtSimHits;
1200 art::fill_ptr_vector(crtSimHits,crtSimHitHandle);
1202 mf::LogPrint(
"CRTSimAnalysis") <<
"found " << crtSimHits.size() <<
" sim CRTHits" <<
'\n';
1203 for (
auto const&
hit : crtSimHits )
1223 uint8_t mactmp =
hit->feb_id[0];
1227 bool passfilter=
false;
1231 for(
auto const& mactopes :
hit->pesmap){
1233 for(
auto const& chanpe : mactopes.second) {
1237 fHitPe.push_back(chanpe.second);
1246 if ( particleMap.find(trk) != particleMap.end()) {
1247 fHitPDG.push_back(particleMap[trk]->PdgCode());
1264 mf::LogWarning(
"CRTSimAnalysis")
1265 <<
"CRTHit products not found! (expected if gen/G4/detsim step)" <<
'\n';
1268 art::Handle<vector<CRTHit>> crtTrueHitHandle;
1272 vector<art::Ptr<CRTHit>> crtTrueHits;
1273 art::fill_ptr_vector(crtTrueHits,crtTrueHitHandle);
1275 mf::LogPrint(
"CRTSimAnalysis") <<
"found " << crtTrueHits.size() <<
" true CRTHits" <<
'\n';
1276 for (
auto const&
hit : crtTrueHits )
1296 uint8_t mactmp =
hit->feb_id[0];
1300 bool passfilter=
false;
1304 for(
auto const& mactopes :
hit->pesmap){
1305 for(
auto const& chanpe : mactopes.second) {
1317 if ( particleMap.find(trk) != particleMap.end()){
1318 fTrueHitPDG.push_back(particleMap[trk]->PdgCode());
1335 mf::LogWarning(
"CRTSimAnalysis") <<
"true CRTHit products not found" <<
'\n';
1338 art::Handle<vector<sbn::crt::CRTTrack>> crtSimTrackHandle;
1342 vector<art::Ptr<sbn::crt::CRTTrack>> crtTracks;
1343 art::fill_ptr_vector(crtTracks,crtSimTrackHandle);
1346 art::FindManyP<CRTHit> findManyHits(
1349 mf::LogPrint(
"CRTSimAnalysis") <<
"found " << crtTracks.size() <<
" sim CRTTracks" <<
'\n';
1350 for (
size_t itrk=0; itrk<crtTracks.size(); itrk++ )
1352 auto const& trk = crtTracks[itrk];
1365 auto const& trkhits = findManyHits.at(itrk);
1367 uint32_t tstart=UINT32_MAX;
1369 size_t ihit_start=0, ihit_end=0;
1370 for(
size_t ihit=0; ihit<trkhits.size(); ihit++){
1371 if(trkhits[ihit]->ts0_ns<tstart) {
1373 tstart = trkhits[ihit]->ts0_ns;
1375 if(trkhits[ihit]->ts0_ns>tend){
1377 tend = trkhits[ihit]->ts0_ns;
1397 mf::LogWarning(
"CRTSimAnalysis") <<
"no CRTTrack products not found" <<
'\n';
1410 int ProcessToICode(
string const&
p)
1414 if(p==
"primary") icode=0;
1417 if(p==
"eBrem") icode=1;
1418 if(p==
"muBrems") icode=2;
1419 if(p==
"annihil") icode=3;
1420 if(p==
"muMinusCaptureAtRest") icode=4;
1421 if(p==
"nCapture") icode=5;
1422 if(p==
"hBertiniCaptureAtRest") icode=6;
1423 if(p==
"photonNuclear") icode=7;
1424 if(p==
"muonNuclear") icode=8;
1425 if(p==
"neutronInelastic") icode=9;
1426 if(p==
"protonInelastic") icode=10;
1427 if(p==
"pi-Inelastic") icode=11;
1428 if(p==
"Decay") icode=12;
1431 if (p==
"muIoni") icode=13;
1432 if (p==
"eIoni") icode=14;
1433 if (p==
"hIoni") icode=15;
1434 if (p==
"compt") icode=16;
1435 if (p==
"conv") icode=17;
1436 if (p==
"muPairProd") icode=18;
1437 if (p==
"phot") icode=19;
1439 if (p==
"hadElastic") icode=20;
1441 if (p==
"LArVoxelReadoutScoringProcess") icode=30;
1442 if (p==
"CoupledTransportation") icode=31;
string MacToRegion(uint8_t mac)
Store parameters for running LArG4.
vector< float > fMinMomenta
unsigned int GetClosestOpDet(geo::Point_t const &point) const
vector< vector< double > > fRegEntryXYZT
float fTrueXHitErr
stat error of CRT hit reco X (cm)
int fSimTrackID
GEANT ID of the particle being processed.
Utilities related to art service access.
art::InputTag fSimulationProducerLabel
The name of the producer that tracked simulated particles through the detector.
TTree * fTrueCRTHitNtuple
int fEntry
front-end board entry number (reset for each event)
float fXHit
signal inducing particle(s)' PDG code
then echo unknown compiler flag
float fZHitErr
stat error of CRT hit reco Z (cm)
vector< uint32_t > fAuxDetID
Global CRT module ID.
vector< int > fTrueHitPDG
art::InputTag fCRTTrueHitProducerLabel
float fT1Hit
hit time w.r.t. PPS
int fNSimTrack
number of simulated CRT tracks for this event
Declaration of signal hit object.
vector< vector< double > > fCDxyzt
vector< double > fADdEdx
average dEdx for particle traversing CRT strip
vector< vector< double > > fGenStartXYZT
Geometry information for a single TPC.
vector< int > fTrueHitMod
float fYHit
reconstructed Y position of CRT hit (cm)
int GetAuxDetTypeCode(size_t adid)
TTree * fSimulationNtuple
tuple with simulated data
void GetCenter(double *xyz, double localz=0.0) const
geo::GeometryCore const * fGeometryService
pointer to Geometry provider
size_t MacToAuxDetID(uint8_t mac, int chan)
vector< float > fTrueHitPe
Geometry information for a single cryostat.
vector< int > fTrueHitStrip
int fNHit
number of CRT hits for this event
CRTCommonUtils * fCrtutils
CRTSimAnalysis(fhicl::ParameterSet const &p)
Constructor: configures the module (see the Config structure above)
uint32_t fNAuxDet
Number of scintillator strips hit.
virtual void analyze(const art::Event &event) override
float fEndPE[4]
(Px,Py,Pz,E) at the true end of the particle
int AuxDetRegionNameToNum(string reg)
int fHitReg
region code of CRT hit
int fT0
signal time w.r.t. global event time
virtual void beginRun(const art::Run &run) override
Access the description of auxiliary detector geometry.
int fTrueHitReg
region code of CRT hit
vector< vector< double > > fRegExitSlope
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Access the description of detector geometry.
int fEvent
number of the event being processed
int fMother
G4 track ID of mother that directly produced this MCParticle.
TTree * fCosmicDisplayNtuple
for ROOT based event display
vector< vector< double > > fRegExitPE
object containing MC truth information necessary for making RawDigits and doing back tracking ...
int fNDaught
number of daughters belonging to this MCParticle
float fTrueZHitErr
stat error of CRT hit reco Z (cm)
int fSimProcess
process that created the particle (e.g. brehmstralung)
float fTrueYHitErr
stat error of CRT hit reco Y (cm)
art::InputTag fCRTDetSimProducerLabel
uint32_t fSimHits
number of trajectory points for each MCParticle
const OpDetGeo & OpDet(unsigned int iopdet) const
Return the iopdet'th optical detector in the cryostat.
int fProgenitor
G4 track ID of the primary particle that ultimately led to this one.
int fRun
number of the run being processed
float fTrueYHit
reconstructed Y position of CRT hit (cm)
int fTriggerOffset
(units of ticks) time of expected neutrino event
int fMac5
Mac5 address for this front-end board.
vector< vector< double > > fADEnterXYZT
4-position of entry into CRT strip
vector< int > fPDGs
PDG code of particle we'll focus on.
virtual void beginJob() override
vector< uint32_t > fADMac
Mac5 address of the CRT module.
pair< uint8_t, uint8_t > ADToMac(size_t adid)
vector< double > fADTrackLength
Track length in CRT strip (cm)
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
float fTrackLength
total track length for each MCParticle
float fStartPE[4]
(Px,Py,Pz,E) at the true start of the particle
vector< double > fADEDep
Energy deposited in CRT strip (GeV)
vector< vector< double > > fGenEndXYZT
float fSimTrackHitStart[4]
vector< vector< double > > fCDpe
4-momentum
int fSimPDG
PDG ID of the particle being processed.
static const int LAR_PROP_DELAY
float fZHit
reconstructed Z position of CRT hit (cm)
Description of geometry of one entire detector.
Declaration of cluster object.
Definition of data types for geometry description.
vector< vector< double > > fCDSlopes
direction cosines
art::InputTag fCRTSimTrackProducerLabel
vector< double > fRegDistToOpDet
vector< double > fRegEDep
int fADC[64]
signal amplitude
vector< vector< double > > fRegEntryPE
uint32_t fTrueNHit
number of CRT hits for this event
vector< vector< double > > fADEnterPE
4-position of entry into CRT strip
bool InFiducialY(double y, double neg_margin, double pos_margin) const
Returns whether TPC fiducial volume contains world y coordinate.
int fT1
signal time w.r.t. PPS
string GetAuxDetRegion(size_t adid)
float fTrueXHit
reconstructed X position of CRT hit (cm)
int fFEBReg
CRT region for this front-end board.
vector< uint32_t > fAuxDetReg
CRT region code.
float fEndXYZT[4]
(x,y,z,t) of the true end of the particle
float fXHitErr
stat error of CRT hit reco X (cm)
vector< int > fTrackID
track ID(s) of particle that produced the signal
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
float fYHitErr
stat error of CRT hit reco Y (cm)
vector< int > fRegRegions
vector< vector< double > > fADExitXYZT
4-position of exit from CRT strip
vector< int > fTrueHitTrk
int MacToTypeCode(uint8_t mac)
int ChannelToAuxDetSensitiveID(uint8_t mac, int chan)
vector< float > fMaxMomenta
vector< vector< double > > fRegEntrySlope
int fSimEndProcess
process the killed the particle (e.g. annihilation)
object containing MC truth information necessary for making RawDigits and doing back tracking ...
std::vector< int > AllTrueIds(const art::Event &event, const CRTData &data)
float fTrueT1Hit
hit time w.r.t. global event time
float fStartXYZT[4]
(x,y,z,t) of the true start of the particle
art::InputTag fCRTSimHitProducerLabel
The name of the producer that created hits.
art::ServiceHandle< art::TFileService > tfs
float fT0Hit
hit time w.r.t. global event time
bool InFiducialX(double x, double neg_margin, double pos_margin) const
Returns whether TPC fiducial volume contains world x coordinate.
vector< int > fRegOpDetID
float fTrueZHit
reconstructed Z position of CRT hit (cm)
vector< uint32_t > fADType
bool InFiducialZ(double z, double neg_margin, double pos_margin) const
Returns whether TPC fiducial volume contains world z coordinate.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
vector< vector< double > > fADExitPE
4-position of exit from CRT strip
float fTrueT0Hit
hit time w.r.t. global event time
vector< vector< double > > fGenStartPE
vector< vector< double > > fRegExitXYZT
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
art framework interface to geometry description
BEGIN_PROLOG could also be cout
vector< vector< double > > fRegOpDetXYZT
vector< uint32_t > fAuxDetSensitiveID
Strip ID in module.
vector< vector< double > > fGenEndPE