16 #ifndef MuonTrackingEff_Module 17 #define MuonTrackingEff_Module 48 #include "TDirectory.h" 51 #include "TEfficiency.h" 52 #include "TGraphAsymmErrors.h" 56 #define MAX_TRACKS 1000 76 void processEff(
const art::Event& evt,
bool &isFiducial);
86 bool insideFV(
double vertex[4]);
88 void doEfficiencies();
100 double MCTruthMuonVertex[4];
108 double MCTruthMuonThetaXZ=0;
109 double MCTruthMuonThetaYZ=0;
114 int CountMCTruthMuon=0;
117 int CountGoodLeadingMuonTrack=0;
118 int CountNoRecoTracks=0;
119 int CountNoMuonTracks=0;
120 int CountBadLeadingMuonTrack=0;
121 int CountCompleteness=0;
123 int CountTrackLengthTooShort=0;
124 int CountTrackLengthTooLong=0;
126 int CountBadLeadingMuonTrackAndOnlyOneMuonTrack=0;
127 int CountBadLeadingMuonTrackButLeadingPlusSecondGood=0;
128 int CountBadLeadingMuonTrackAndLeadingPlusSecondBad=0;
130 int CountBadLeadingMuonTrackAndLeadingPlusSecondBadCompleteness=0;
131 int CountBadLeadingMuonTrackAndLeadingPlusSecondBadPurity=0;
132 int CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooShort=0;
133 int CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooLong=0;
135 int CountBadLeadingMuonTrackAndOnlyOneMuonTrackCompleteness=0;
136 int CountBadLeadingMuonTrackAndOnlyOneMuonTrackPurity=0;
137 int CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooShort=0;
138 int CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooLong=0;
143 int GoodEvents1MuonTrack=0;
144 int GoodEvents2MuonTrack=0;
145 int GoodEvents3MuonTrack=0;
146 int GoodEvents4OrMoreMuonTrack=0;
148 int BadEvents0MuonTrack=0;
149 int BadEvents1MuonTrack=0;
150 int BadEvents2MuonTrack=0;
151 int BadEvents3MuonTrack=0;
152 int BadEvents4OrMoreMuonTrack=0;
281 int ThetaXZBinMax=360;
284 int ThetaYZBinMin=-90;
285 int ThetaYZBinMax=90;
287 int NSinThetaYZBins=18;
288 int SinThetaYZBinMin=-1;
289 int SinThetaYZBinMax=1;
291 int NCriteriaBins=13;
292 double CriteriaBinMin=-0.25;
293 double CriteriaBinMax=6.25;
295 int NRecoTracksBins=19;
296 double RecoTracksBinMin=-0.25;
297 double RecoTracksBinMax=9.25;
304 : EDAnalyzer(parameterSet)
315 fMCTruthModuleLabel = p.
get<std::string>(
"MCTruthModuleLabel");
316 fTrackModuleLabel = p.
get<std::string>(
"TrackModuleLabel");
317 fMuonPDGCode = p.
get<
int>(
"MuonPDGCode");
318 fFidVolCutX = p.
get<
float>(
"FidVolCutX");
319 fFidVolCutY = p.
get<
float>(
"FidVolCutY");
320 fFidVolCutZ = p.
get<
float>(
"FidVolCutZ");
324 std::cout<<
"job begin..."<<std::endl;
326 auto const*
geo = lar::providerFrom<geo::Geometry>();
335 for (
size_t i = 0; i<
geo->NTPC(); ++i){
336 double local[3] = {0.,0.,0.};
337 double world[3] = {0.,0.,0.};
340 if (minx>world[0]-
geo->DetHalfWidth(i))
341 minx = world[0]-
geo->DetHalfWidth(i);
342 if (maxx<world[0]+
geo->DetHalfWidth(i))
343 maxx = world[0]+
geo->DetHalfWidth(i);
344 if (miny>world[1]-
geo->DetHalfHeight(i))
345 miny = world[1]-
geo->DetHalfHeight(i);
346 if (maxy<world[1]+
geo->DetHalfHeight(i))
347 maxy = world[1]+
geo->DetHalfHeight(i);
348 if (minz>world[2]-
geo->DetLength(i)/2.)
349 minz = world[2]-
geo->DetLength(i)/2.;
350 if (maxz<world[2]+
geo->DetLength(i)/2.)
351 maxz = world[2]+
geo->DetLength(i)/2.;
361 std::cout<<
"Fiducial volume:"<<
"\n" 362 <<fFidVolXmin<<
"\t< x <\t"<<fFidVolXmax<<
"\n" 363 <<fFidVolYmin<<
"\t< y <\t"<<fFidVolYmax<<
"\n" 364 <<fFidVolZmin<<
"\t< z <\t"<<fFidVolZmax<<
"\n";
369 gStyle->SetTitleOffset (1.3,
"Y");
372 h_Purity = tfs->
make<TH1D>(
"h_Purity",
"All events: Purity vs. # events; Purity; # events",60,0,1.2);
374 h_Completeness = tfs->
make<TH1D>(
"h_Completeness",
"All events: Completeness vs # events; Completeness; # events",60,0,1.2);
375 h_Completeness->SetLineColor(kBlue);
377 h_TrackRes = tfs->
make<TH1D>(
"h_TrackRes",
"All events: L_{reco}/L_{truth} vs. # events; L_{reco}/L_{truth}; # events;",75,0,1.5);
378 h_TrackRes->SetLineColor(kRed);
380 h_TotalRecoEnergy = tfs->
make<TH1D>(
"h_TotalRecoEnergy",
"All events: Total reco energy (sum of all hits in all tracks) vs. # events; E_{reco., tot.} [MeV]; # events",100,0,1000);
382 h_TruthLength = tfs->
make<TH1D>(
"h_TruthLength",
"All events: truth muon length vs. # events; truth muon length [cm]; # events",100,0,300);
384 h_VertexRes = tfs->
make<TH1D>(
"h_VertexRes",
"All events: Vertex residuals vs. # events; #Delta vertex_{truth-teco} [cm]; # events", 300,0,300);
386 h_DirectionRes = tfs->
make<TH1D>(
"h_DirectionRes",
"All events: Angular residuals vs. # events; #Delta#theta_{truth-reco} [#circ]; # events", 180,0,180);
404 h_Completeness->Sumw2();
406 h_TotalRecoEnergy->Sumw2();
407 h_TruthLength->Sumw2();
408 h_VertexRes->Sumw2();
409 h_DirectionRes->Sumw2();
411 h_Efficiency_SinThetaYZ->Sumw2();
412 h_SinThetaYZ_den->Sumw2();
413 h_SinThetaYZ_num->Sumw2();
415 h_Efficiency_ThetaXZ->Sumw2();
416 h_ThetaXZ_den->Sumw2();
417 h_ThetaXZ_num->Sumw2();
419 h_Efficiency_ThetaYZ->Sumw2();
420 h_ThetaYZ_den->Sumw2();
421 h_ThetaYZ_num->Sumw2();
427 h_Efficiency_ThetaXZ_ThetaYZ->SetOption(
"colz");
430 h_ThetaXZ_ThetaYZ_den->SetOption(
"colz");
433 h_ThetaXZ_ThetaYZ_num->SetOption(
"colz");
436 h_FailedReconstruction_ThetaXZ_ThetaYZ->SetOption(
"colz");
440 h_Efficiency_ThetaXZ_SinThetaYZ->SetOption(
"colz");
443 h_ThetaXZ_SinThetaYZ_den->SetOption(
"colz");
446 h_ThetaXZ_SinThetaYZ_num->SetOption(
"colz");
449 h_FailedReconstruction_ThetaXZ_SinThetaYZ->SetOption(
"colz");
453 h_Efficiency_ThetaXZ_ThetaYZ_LeadingPlusSecond->SetOption(
"colz");
456 h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk->SetOption(
"colz");
459 h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk_num->SetOption(
"colz");
463 h_Efficiency_ThetaXZ_SinThetaYZ_LeadingPlusSecond->SetOption(
"colz");
466 h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk->SetOption(
"colz");
469 h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk_num->SetOption(
"colz");
473 h_Efficiency_ThetaXZ_ThetaYZ_DifferenceLeadingAndLeadingPlusSecond->SetOption(
"colz");
477 h_NoRecoTrackAtAll_ThetaXZ_SinThetaYZ->SetOption(
"colz");
480 h_NoMuonTrack_ThetaXZ_SinThetaYZ->SetOption(
"colz");
483 h_TrackTooShort_ThetaXZ_SinThetaYZ->SetOption(
"colz");
486 h_TrackTooLong_ThetaXZ_SinThetaYZ->SetOption(
"colz");
489 h_Completeness_ThetaXZ_SinThetaYZ->SetOption(
"colz");
492 h_Purity_ThetaXZ_SinThetaYZ->SetOption(
"colz");
496 h_Criteria_NRecoTrack->SetOption(
"colz");
499 h_Criteria_NRecoTrack_num->SetOption(
"colz");
502 h_Criteria_NRecoTrack_den->SetOption(
"colz");
506 h_Criteria_NMuonTrack->SetOption(
"colz");
509 h_Criteria_NMuonTrack_num->SetOption(
"colz");
512 h_Criteria_NMuonTrack_den->SetOption(
"colz");
515 h_NoMuonTrack_MaxTrackLength_PDGCode = tfs->
make<TH2D>(
"h_NoMuonTrack_MaxTrackLength_PDGCode",
"Events with no muon track: L_{reco, max} vs. PDG Code; L_{reco} [cm]; PDG Code",100,0.,200.,200,-100.,100.);
516 h_NoMuonTrack_MaxTrackLength_PDGCode->SetOption(
"colz");
519 h_MuonTrackStitching_TrackRes_Completeness = tfs->
make<TH2D>(
"h_MuonTrackStitching_TrackRes_Completeness",
"All events: L_{reco}/L_{truth} (leading) vs. Completeness (leading); L_{reco}/L_{truth} (leading); Completeness (leading)",150,0.,1.5,150,0.,1.5);
520 h_MuonTrackStitching_TrackRes_Completeness->SetOption(
"colz");
522 h_MuonTrackStitching_TrackResLeading_TrackResSecond = tfs->
make<TH2D>(
"h_MuonTrackStitching_TrackResLeading_TrackResSecond",
"All events: L_{reco}/L_{truth} (leading) vs. L_{reco}/L_{truth} (second); L_{reco}/L_{truth} (leading); L_{reco}/L_{truth} (second)",150,0.,1.5,150,0.,1.5);
523 h_MuonTrackStitching_TrackResLeading_TrackResSecond->SetOption(
"colz");
525 h_MuonTrackStitching_Distance_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_Distance_Angle",
"All events: distance vs. angle b/w leading and second muon track; Distance [cm]; Angle [#circ]",100,0.,100.,100,0.,180.);
526 h_MuonTrackStitching_Distance_Angle->SetOption(
"colz");
528 h_MuonTrackStitching_TrackResSecondMuon_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_TrackResSecondMuon_Angle",
"All events: L_{reco}/L_{truth} (second) vs. angle; L_{reco}/L_{truth} (second); Angle [#circ]",150,0.,1.5,180,0,180.);
529 h_MuonTrackStitching_TrackResSecondMuon_Angle->SetOption(
"colz");
531 h_MuonTrackStitching_CompletenessSecondMuon_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_CompletenessSecondMuon_Angle",
"All events: Completeness (second) vs. angle; Completeness (second); Angle [#circ]",120,0.,1.2,180,0,180.);
532 h_MuonTrackStitching_CompletenessSecondMuon_Angle->SetOption(
"colz");
534 h_MuonTrackStitching_CriteriaTwoTracks_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_CriteriaTwoTracks_Angle",
"All events: CriteriaTwoTracks vs. angle; Criteria; Angle [#circ]",7,0.75,4.25,180,0,180.);
535 h_MuonTrackStitching_CriteriaTwoTracks_Angle->SetOption(
"colz");
538 h_MuonTrackStitching_FailedCriteria_TrackRes_Completeness = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteria_TrackRes_Completeness",
"Bad events: L_{reco}/L_{truth} (leading) vs. Completeness (leading); L_{reco}/L_{truth} (leading); Completeness (leading)",150,0.,1.5,150,0.,1.5);
539 h_MuonTrackStitching_FailedCriteria_TrackRes_Completeness->SetOption(
"colz");
541 h_MuonTrackStitching_FailedCriteria_Distance_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteria_Distance_Angle",
"Bad events: distance vs. angle b/w leading and second muon track; Distance [cm]; Angle [#circ]",100,0.,100.,100,0.,180.);
542 h_MuonTrackStitching_FailedCriteria_Distance_Angle->SetOption(
"colz");
544 h_MuonTrackStitching_FailedCriteria_TrackResLeading_TrackResSecond = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteria_TrackResLeading_TrackResSecond",
"Bad events: L_{reco}/L_{truth} (leading) vs. L_{reco}/L_{truth} (second); L_{reco}/L_{truth} (leading); L_{reco}/L_{truth} (second)",150,0.,1.5,150,0.,1.5);
545 h_MuonTrackStitching_FailedCriteria_TrackResLeading_TrackResSecond->SetOption(
"colz");
547 h_MuonTrackStitching_FailedCriteria_CompletenessLeading_CompletenessSecond = tfs->
make<TH2D>(
"*h_MuonTrackStitching_FailedCriteria_CompletenessLeading_CompletenessSecond",
"Bad events: Completeness (leading) vs. Completeness (second); Completeness (leading); Completeness (second)",150,0.,1.5,150,0.,1.5);
548 h_MuonTrackStitching_FailedCriteria_CompletenessLeading_CompletenessSecond->SetOption(
"colz");
550 h_MuonTrackStitching_FailedCriteria_TrackResSecondMuon_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteria_TrackResSecondMuon_Angle",
"Bad events: L_{reco}/L_{truth} (second) vs. angle; L_{reco}/L_{truth} (second); Angle [#circ]",150,0.,1.5,180,0,180.);
551 h_MuonTrackStitching_FailedCriteria_TrackResSecondMuon_Angle->SetOption(
"colz");
553 h_MuonTrackStitching_FailedCriteria_CompletenessSecondMuon_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteria_CompletenessSecondMuon_Angle",
"Bad events: Completeness (second) vs. angle; Completeness (second); Angle [#circ]",120,0.,1.2,180,0,180.);
554 h_MuonTrackStitching_FailedCriteria_CompletenessSecondMuon_Angle->SetOption(
"colz");
556 h_MuonTrackStitching_FailedCriteria_CriteriaTwoTracks_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteria_CriteriaTwoTracks_Angle",
"Bad events: CriteriaTwoTracks vs. angle; Criteria; Angle [#circ]",7,0.75,4.25,180,0,180.);
557 h_MuonTrackStitching_FailedCriteria_CriteriaTwoTracks_Angle->SetOption(
"colz");
560 h_MuonTrackStitching_MatchedCriteria_TrackRes_Completeness = tfs->
make<TH2D>(
"h_MuonTrackStitching_MatchedCriteria_TrackRes_Completeness",
"Good events: L_{reco}/L_{truth} (leading) vs. Completeness (leading); L_{reco}/L_{truth} (leading); Completeness (leading)",150,0.,1.5,150,0.,1.5);
561 h_MuonTrackStitching_MatchedCriteria_TrackRes_Completeness->SetOption(
"colz");
563 h_MuonTrackStitching_MatchedCriteria_Distance_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_MatchedCriteria_Distance_Angle",
"Good events: distance vs. angle b/w leading and second muon track; Distance [cm]; Angle [#circ]",100,0.,100.,100,0.,180.);
564 h_MuonTrackStitching_MatchedCriteria_Distance_Angle->SetOption(
"colz");
566 h_MuonTrackStitching_MatchedCriteria_TrackResLeading_TrackResSecond = tfs->
make<TH2D>(
"h_MuonTrackStitching_MatchedCriteria_TrackResLeading_TrackResSecond",
"Good events: L_{reco}/L_{truth} (leading) vs. L_{reco}/L_{truth} (second); L_{reco}/L_{truth} (leading); L_{reco}/L_{truth} (second)",150,0.,1.5,150,0.,1.5);
567 h_MuonTrackStitching_MatchedCriteria_TrackResLeading_TrackResSecond->SetOption(
"colz");
569 h_MuonTrackStitching_MatchedCriteria_CriteriaTwoTracks_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_MatchedCriteria_CriteriaTwoTracks_Angle",
"Good events: CriteriaTwoTracks vs. angle b/w leading and second muon track; Criteria; Angle [#circ]",7,0.75,4.25,100,0.,180.);
570 h_MuonTrackStitching_MatchedCriteria_CriteriaTwoTracks_Angle->SetOption(
"colz");
573 h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackRes_Completeness = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackRes_Completeness",
"Bad events but leading + second is good: L_{reco}/L_{truth} (leading) vs. Completeness (leading); L_{reco}/L_{truth} (leading); Completeness (leading)",150,0.,1.5,150,0.,1.5);
574 h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackRes_Completeness->SetOption(
"colz");
576 h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_Distance_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_Distance_Angle",
"Bad events but leading + second is good: distance vs. angle b/w leading and second muon track; Distance [cm]; Angle [#circ]",100,0.,100.,100,0.,180.);
577 h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_Distance_Angle->SetOption(
"colz");
579 h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackResLeading_TrackResSecond = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackResLeading_TrackResSecond",
"Bad events but leading + second is good: L_{reco}/L_{truth} (leading) vs. L_{reco}/L_{truth} (second); L_{reco}/L_{truth} (leading); L_{reco}/L_{truth} (second)",150,0.,1.5,150,0.,1.5);
580 h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackResLeading_TrackResSecond->SetOption(
"colz");
583 h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackRes_Completeness = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackRes_Completeness",
"Bad events and leading + second is bad: L_{reco}/L_{truth} (leading) vs. Completeness (leading); L_{reco}/L_{truth} (leading); Completeness (leading)",150,0.,1.5,150,0.,1.5);
584 h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackRes_Completeness->SetOption(
"colz");
586 h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_Distance_Angle = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_Distance_Angle",
"Bad events and leading + second is bad: distance vs. angle b/w leading and second muon track; Distance [cm]; Angle [#circ]",100,0.,100.,100,0.,180.);
587 h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_Distance_Angle->SetOption(
"colz");
589 h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackResLeading_TrackResSecond = tfs->
make<TH2D>(
"h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackResLeading_TrackResSecond",
"Bad events and leading + second is bad: L_{reco}/L_{truth} (leading) vs. L_{reco}/L_{truth} (second); L_{reco}/L_{truth} (leading); L_{reco}/L_{truth} (second)",150,0.,1.5,150,0.,1.5);
590 h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackResLeading_TrackResSecond->SetOption(
"colz");
603 mf::LogInfo(
"MuonTrackingEff")<<
"begin run..."<<std::endl;
609 bool isFiducial =
false;
623 particle = ipar->second;
625 if( particle->
Mother() == 0 ){
626 const TLorentzVector& positionStart = particle->
Position(0);
627 positionStart.GetXYZT(MCTruthMuonVertex);
631 MCTruthMuonParticle = particle;
632 MCTruthMuonID = particle->
TrackId();
633 MCTruthMuonMomentum = sqrt(pow(particle->
Momentum().Px(),2)+pow(particle->
Momentum().Py(),2)+pow(particle->
Momentum().Pz(),2));
637 MCTruthMuonThetaXZ = (180.0/3.14159)*atan(particle->
Momentum().Px()/particle->
Momentum().Pz());
641 MCTruthMuonThetaXZ = 180.0 + (180.0/3.14159)*atan(particle->
Momentum().Px()/particle->
Momentum().Pz());
645 MCTruthMuonThetaXZ = 180.0 + (180.0/3.14159)*atan(particle->
Momentum().Px()/particle->
Momentum().Pz());
649 MCTruthMuonThetaXZ = 360.0 + (180.0/3.14159)*atan(particle->
Momentum().Px()/particle->
Momentum().Pz());
655 double MCTruthLengthMuon =
truthLength(MCTruthMuonParticle);
656 h_TruthLength->Fill(MCTruthLengthMuon);
661 isFiducial =
insideFV( MCTruthMuonVertex );
662 if( !isFiducial )
return;
665 if( MCTruthMuonParticle ){
666 h_ThetaXZ_den->Fill(MCTruthMuonThetaXZ);
667 h_ThetaYZ_den->Fill(MCTruthMuonThetaYZ);
668 h_SinThetaYZ_den->Fill(sin((3.14159/180.)*MCTruthMuonThetaYZ));
669 h_ThetaXZ_ThetaYZ_den->Fill(MCTruthMuonThetaXZ,MCTruthMuonThetaYZ);
670 h_ThetaXZ_SinThetaYZ_den->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
683 if(! event.
getByLabel(fTrackModuleLabel, TrackListHandle))
return;
684 std::vector<art::Ptr<recob::Track> > TrackList;
686 int NRecoTracks = TrackList.size();
688 if( NRecoTracks == 0 ){
689 LOG_DEBUG(
"MuonTrackingEff")<<
"There are no reco tracks... bye";
690 std::cout <<
"There are no reco tracks! MCTruthMuonThetaXZ: " << std::endl;
693 h_FailedReconstruction_ThetaXZ_ThetaYZ->Fill(MCTruthMuonThetaXZ,MCTruthMuonThetaYZ);
694 h_FailedReconstruction_ThetaXZ_SinThetaYZ->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
695 h_NoRecoTrackAtAll_ThetaXZ_SinThetaYZ->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
696 h_Criteria_NRecoTrack_num->Fill(Criteria,static_cast<double>(NRecoTracks));
697 h_Criteria_NMuonTrack_num->Fill(Criteria,static_cast<double>(NMuonTracks));
701 LOG_DEBUG(
"MuonTrackingEff")<<
"Found this many reco tracks "<<NRecoTracks;
705 double PurityLeadingMuon=0.;
706 double CompletenessLeadingMuon=0.;
707 double RecoLengthLeadingMuon=0.;
710 double RecoLengthSecondMuon=0.;
711 double CompletenessSecondMuon=0.;
712 double PuritySecondMuon=0.;
715 double TrackLengthMuonSum=0.;
716 double tmpTotalRecoEnergy=0.;
718 double MaxLengthNoRecoMuon=0;
719 int PDGCodeMaxLengthNoRecoMuon=0;
723 std::vector<art::Ptr<recob::Hit>> tmp_TrackHits = track_hits.at(0);
724 std::vector<art::Ptr<recob::Hit>> AllHits;
730 for(
int i=0; i<NRecoTracks; i++) {
732 std::vector<art::Ptr<recob::Hit>> TrackHits = track_hits.at(i);
734 double tmpCompleteness=0.;
737 truthMatcher(AllHits, TrackHits, particle, tmpPurity, tmpCompleteness, tmpTotalRecoEnergy);
739 if (!particle) { std::cout <<
"ERROR: Truth matcher didn't find a particle!" << std::endl;
continue;}
743 MaxLengthNoRecoMuon = track->
Length();
744 PDGCodeMaxLengthNoRecoMuon = particle->
PdgCode();
750 TrackLengthMuonSum+=track->
Length();
754 CompletenessLeadingMuon = tmpCompleteness;
755 PurityLeadingMuon = tmpPurity;
756 RecoLengthLeadingMuon = track->
Length();
757 TrackLeadingMuon =
track;
759 RecoMuonParticle = particle;
763 if(NMuonTracks>=2 && tmpCompleteness > CompletenessLeadingMuon )
766 CompletenessSecondMuon = CompletenessLeadingMuon;
767 PuritySecondMuon = PurityLeadingMuon;
768 RecoLengthSecondMuon = RecoLengthLeadingMuon;
769 TrackSecondMuon = TrackLeadingMuon;
771 CompletenessLeadingMuon = tmpCompleteness;
772 PurityLeadingMuon = tmpPurity;
773 RecoLengthLeadingMuon = track->
Length();
774 TrackLeadingMuon =
track;
776 RecoMuonParticle = particle;
779 else if(NMuonTracks>=2 && tmpCompleteness < CompletenessLeadingMuon && tmpCompleteness > CompletenessSecondMuon)
781 CompletenessSecondMuon = tmpCompleteness;
782 PuritySecondMuon = tmpPurity;
783 RecoLengthSecondMuon = track->
Length();
784 TrackSecondMuon =
track;
789 h_TotalRecoEnergy->Fill(tmpTotalRecoEnergy);
796 if( RecoMuonParticle && MCTruthMuonParticle )
799 h_Purity->Fill(PurityLeadingMuon);
800 h_Completeness->Fill(CompletenessLeadingMuon);
801 h_TrackRes->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon);
803 std::cout <<
"TrackLeadingMuon->Vertex().X(): " << TrackLeadingMuon->
Vertex().X() << std::endl;
804 std::cout <<
"MCTruthMuonParticle->Vz(): " << MCTruthMuonParticle->
Vz() << std::endl;
805 std::cout <<
" " << std::endl;
807 double DistanceBetweenTruthAndRecoTrack;
808 double AngleBetweenTruthAndRecoTrack;
811 h_VertexRes->Fill(DistanceBetweenTruthAndRecoTrack);
812 h_DirectionRes->Fill(AngleBetweenTruthAndRecoTrack);
814 h_MuonTrackStitching_TrackRes_Completeness->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon, CompletenessLeadingMuon);
817 double DistanceBetweenTracks;
818 double AngleBetweenTracks;
819 double CriteriaTwoTracks;
823 h_MuonTrackStitching_TrackResLeading_TrackResSecond->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon,RecoLengthSecondMuon/MCTruthLengthMuon);
824 h_MuonTrackStitching_Distance_Angle->Fill(DistanceBetweenTracks,AngleBetweenTracks);
825 h_MuonTrackStitching_TrackResSecondMuon_Angle->Fill(RecoLengthSecondMuon/MCTruthLengthMuon,AngleBetweenTracks);
826 h_MuonTrackStitching_CompletenessSecondMuon_Angle->Fill(CompletenessSecondMuon,AngleBetweenTracks);
827 h_MuonTrackStitching_CriteriaTwoTracks_Angle->Fill(CriteriaTwoTracks, AngleBetweenTracks);
831 if(CompletenessLeadingMuon < 0.5)
835 h_Completeness_ThetaXZ_SinThetaYZ->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
836 h_Criteria_NRecoTrack_num->Fill(Criteria,static_cast<double>(NRecoTracks));
837 h_Criteria_NMuonTrack_num->Fill(Criteria,static_cast<double>(NMuonTracks));
840 if(PurityLeadingMuon < 0.5)
844 h_Purity_ThetaXZ_SinThetaYZ->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
845 h_Criteria_NRecoTrack_num->Fill(Criteria,static_cast<double>(NRecoTracks));
846 h_Criteria_NMuonTrack_num->Fill(Criteria,static_cast<double>(NMuonTracks));
849 if(RecoLengthLeadingMuon/MCTruthLengthMuon < 0.75)
851 CountTrackLengthTooShort++;
853 h_TrackTooShort_ThetaXZ_SinThetaYZ->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
854 h_Criteria_NRecoTrack_num->Fill(Criteria,static_cast<double>(NRecoTracks));
855 h_Criteria_NMuonTrack_num->Fill(Criteria,static_cast<double>(NMuonTracks));
858 if(RecoLengthLeadingMuon/MCTruthLengthMuon > 1.25)
860 CountTrackLengthTooLong++;
862 h_TrackTooLong_ThetaXZ_SinThetaYZ->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
863 h_Criteria_NRecoTrack_num->Fill(Criteria,static_cast<double>(NRecoTracks));
864 h_Criteria_NMuonTrack_num->Fill(Criteria,static_cast<double>(NMuonTracks));
887 if(CompletenessLeadingMuon < 0.5 || PurityLeadingMuon < 0.5 || RecoLengthLeadingMuon/MCTruthLengthMuon < 0.75 || RecoLengthLeadingMuon/MCTruthLengthMuon > 1.25)
889 CountBadLeadingMuonTrack++;
890 h_FailedReconstruction_ThetaXZ_ThetaYZ->Fill(MCTruthMuonThetaXZ,MCTruthMuonThetaYZ);
891 h_FailedReconstruction_ThetaXZ_SinThetaYZ->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
892 h_MuonTrackStitching_FailedCriteria_TrackRes_Completeness->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon, CompletenessLeadingMuon);
895 if(NMuonTracks==1) {BadEvents1MuonTrack++;}
896 if(NMuonTracks==2) {BadEvents2MuonTrack++;}
897 if(NMuonTracks==3) {BadEvents3MuonTrack++;}
898 if(NMuonTracks==4) {BadEvents4OrMoreMuonTrack++;}
902 double AngleBetweenTracks;
903 double DistanceBetweenTracks;
904 double CriteriaTwoTracks;
907 if(AngleBetweenTracks>160.)
909 std::cout <<
"EventCounter: " << EventCounter << std::endl;
910 std::cout <<
"Angle b/w tracks: " << AngleBetweenTracks << std::endl;
911 std::cout <<
"CriteriaTwoTracks: " << CriteriaTwoTracks << std::endl;
912 std::cout <<
"CompletenessLeadingMuon: " << CompletenessLeadingMuon << std::endl;
913 std::cout <<
"CompletenessSecondMuon: " << CompletenessSecondMuon << std::endl;
914 std::cout <<
"PurityLeadingMuon: " << PurityLeadingMuon << std::endl;
915 std::cout <<
"PuritySecondMuon: " << PuritySecondMuon << std::endl;
916 std::cout <<
"TrackLeadingMuon: " << RecoLengthLeadingMuon/MCTruthLengthMuon << std::endl;
917 std::cout <<
"TrackResSecondMuon: " << RecoLengthSecondMuon/MCTruthLengthMuon << std::endl;
918 std::cout <<
"TrackID leading: " << TrackLeadingMuon->
ID() << std::endl;
919 std::cout <<
"TrackID second: " << TrackSecondMuon->
ID() << std::endl;
922 h_MuonTrackStitching_FailedCriteria_Distance_Angle->Fill(DistanceBetweenTracks,AngleBetweenTracks);
923 h_MuonTrackStitching_FailedCriteria_TrackResLeading_TrackResSecond->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon,RecoLengthSecondMuon/MCTruthLengthMuon);
924 h_MuonTrackStitching_FailedCriteria_CompletenessLeading_CompletenessSecond->Fill(CompletenessLeadingMuon,CompletenessSecondMuon);
925 h_MuonTrackStitching_FailedCriteria_TrackResSecondMuon_Angle->Fill(RecoLengthSecondMuon/MCTruthLengthMuon, AngleBetweenTracks);
926 h_MuonTrackStitching_FailedCriteria_CompletenessSecondMuon_Angle->Fill(CompletenessSecondMuon, AngleBetweenTracks);
927 h_MuonTrackStitching_FailedCriteria_CriteriaTwoTracks_Angle->Fill(CriteriaTwoTracks, AngleBetweenTracks);
928 if( (CompletenessLeadingMuon+CompletenessSecondMuon) >= 0.5 && PurityLeadingMuon >= 0.5 && PuritySecondMuon >= 0.5 && (RecoLengthLeadingMuon+RecoLengthSecondMuon)/MCTruthLengthMuon >= 0.75 && (RecoLengthLeadingMuon+RecoLengthSecondMuon)/MCTruthLengthMuon <= 1.25 ) {
929 CountBadLeadingMuonTrackButLeadingPlusSecondGood++;
930 h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk->Fill(MCTruthMuonThetaXZ,MCTruthMuonThetaYZ);
931 h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
933 h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackRes_Completeness->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon, CompletenessLeadingMuon);
934 h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackResLeading_TrackResSecond->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon,RecoLengthSecondMuon/MCTruthLengthMuon);
935 h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_Distance_Angle->Fill(DistanceBetweenTracks,AngleBetweenTracks);
937 if (( CompletenessLeadingMuon+CompletenessSecondMuon) < 0.5 || PurityLeadingMuon < 0.5 || PuritySecondMuon < 0.5 || (RecoLengthLeadingMuon+RecoLengthSecondMuon)/MCTruthLengthMuon < 0.75 || (RecoLengthLeadingMuon+RecoLengthSecondMuon)/MCTruthLengthMuon > 1.25 )
939 CountBadLeadingMuonTrackAndLeadingPlusSecondBad++;
941 h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackRes_Completeness->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon, CompletenessLeadingMuon);
942 h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackResLeading_TrackResSecond->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon,RecoLengthSecondMuon/MCTruthLengthMuon);
943 h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_Distance_Angle->Fill(DistanceBetweenTracks,AngleBetweenTracks);
945 if((CompletenessLeadingMuon+CompletenessSecondMuon) < 0.5) {CountBadLeadingMuonTrackAndLeadingPlusSecondBadCompleteness++;}
946 if(PurityLeadingMuon < 0.5 || PuritySecondMuon < 0.5 ) {CountBadLeadingMuonTrackAndLeadingPlusSecondBadPurity++;}
947 if((RecoLengthLeadingMuon+RecoLengthSecondMuon)/MCTruthLengthMuon < 0.75) {CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooShort++;}
948 if((RecoLengthLeadingMuon+RecoLengthSecondMuon)/MCTruthLengthMuon > 1.25) {CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooLong++;}
951 else if(NMuonTracks==1)
953 CountBadLeadingMuonTrackAndOnlyOneMuonTrack++;
954 if(CompletenessLeadingMuon < 0.5) {CountBadLeadingMuonTrackAndOnlyOneMuonTrackCompleteness++;}
955 if(PurityLeadingMuon < 0.5) {CountBadLeadingMuonTrackAndOnlyOneMuonTrackPurity++;}
956 if(RecoLengthLeadingMuon/MCTruthLengthMuon < 0.75) {CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooShort++;}
957 if(RecoLengthLeadingMuon/MCTruthLengthMuon > 1.25) {CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooLong++;}
961 if(CompletenessLeadingMuon >= 0.5 && PurityLeadingMuon >= 0.5 && RecoLengthLeadingMuon/MCTruthLengthMuon >= 0.75 && RecoLengthLeadingMuon/MCTruthLengthMuon <= 1.25)
963 CountGoodLeadingMuonTrack++;
965 h_ThetaXZ_num->Fill(MCTruthMuonThetaXZ);
966 h_ThetaYZ_num->Fill(MCTruthMuonThetaYZ);
967 h_SinThetaYZ_num->Fill(sin((3.14159/180.)*MCTruthMuonThetaYZ));
968 h_ThetaXZ_ThetaYZ_num->Fill(MCTruthMuonThetaXZ,MCTruthMuonThetaYZ);
969 h_ThetaXZ_SinThetaYZ_num->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
970 h_Criteria_NRecoTrack_num->Fill(Criteria,static_cast<double>(NRecoTracks));
971 h_Criteria_NMuonTrack_num->Fill(Criteria,static_cast<double>(NMuonTracks));
973 h_MuonTrackStitching_MatchedCriteria_TrackRes_Completeness->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon, CompletenessLeadingMuon);
975 if(NMuonTracks==1) {GoodEvents1MuonTrack++;}
976 if(NMuonTracks==2) {GoodEvents2MuonTrack++;}
977 if(NMuonTracks==3) {GoodEvents3MuonTrack++;}
978 if(NMuonTracks==4) {GoodEvents4OrMoreMuonTrack++;}
982 h_MuonTrackStitching_MatchedCriteria_TrackResLeading_TrackResSecond->Fill(RecoLengthLeadingMuon/MCTruthLengthMuon,RecoLengthSecondMuon/MCTruthLengthMuon);
984 double AngleBetweenTracks;
985 double DistanceBetweenTracks;
986 double CriteriaTwoTracks;
988 h_MuonTrackStitching_MatchedCriteria_Distance_Angle->Fill(DistanceBetweenTracks,AngleBetweenTracks);
989 h_MuonTrackStitching_MatchedCriteria_CriteriaTwoTracks_Angle->Fill(CriteriaTwoTracks, AngleBetweenTracks);
994 if( !RecoMuonParticle && MCTruthMuonParticle )
997 BadEvents0MuonTrack++;
999 h_NoMuonTrack_ThetaXZ_SinThetaYZ->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
1000 h_FailedReconstruction_ThetaXZ_ThetaYZ->Fill(MCTruthMuonThetaXZ,MCTruthMuonThetaYZ);
1001 h_FailedReconstruction_ThetaXZ_SinThetaYZ->Fill(MCTruthMuonThetaXZ,sin((3.14159/180.)*MCTruthMuonThetaYZ));
1002 h_Criteria_NRecoTrack_num->Fill(Criteria,static_cast<double>(NRecoTracks));
1003 h_Criteria_NMuonTrack_num->Fill(Criteria,static_cast<double>(NMuonTracks));
1004 h_NoMuonTrack_MaxTrackLength_PDGCode->Fill(MaxLengthNoRecoMuon, static_cast<double>(PDGCodeMaxLengthNoRecoMuon));
1013 std::map<int,double> trkID_E;
1014 for(
size_t j = 0; j < track_hits.size(); ++j){
1017 for(
size_t k = 0; k < TrackIDs.size(); k++){
1018 trkID_E[TrackIDs[k].trackID] += TrackIDs[k].energy;
1024 double max_E = -999.0;
1025 double TotalEnergyTrack = 0.0;
1027 double PartialEnergyTrackID=0.0;
1030 if( !trkID_E.size() ) {
1035 TotalEnergyTrack += ii->second;
1036 if((ii->second)>max_E){
1037 PartialEnergyTrackID = ii->second;
1039 TrackID = ii->first;
1040 if( TrackID < 0 ) E_em += ii->second;
1047 if( TrackID < 0 ) {
return;}
1050 Purity = PartialEnergyTrackID/TotalEnergyTrack;
1054 for(
size_t k = 0; k < AllHits.size(); ++k){
1057 for(
size_t l = 0; l < TrackIDs.size(); ++l){
1058 if(TrackIDs[l].trackID==TrackID) TotalRecoEnergy += TrackIDs[l].energy;
1061 Completeness = PartialEnergyTrackID/TotalRecoEnergy;
1067 TempDistanceBetweenTracks = sqrt(pow(Track1->
End().X()-Track2->
Vertex().X(),2) + pow(Track1->
End().Y()-Track2->
Vertex().Y(),2) + pow(Track1->
End().Z()-Track2->
Vertex().Z(),2));
1069 TempCriteriaTwoTracks = 1.;
1071 if(TempDistanceBetweenTracks > sqrt(pow(Track1->
End().X()-Track2->
End().X(),2) + pow(Track1->
End().Y()-Track2->
End().Y(),2) + pow(Track1->
End().Z()-Track2->
End().Z(),2)))
1073 TempDistanceBetweenTracks = sqrt(pow(Track1->
End().X()-Track2->
End().X(),2) + pow(Track1->
End().Y()-Track2->
End().Y(),2) + pow(Track1->
End().Z()-Track2->
End().Z(),2));
1075 TempCriteriaTwoTracks = 2.;
1078 if(TempDistanceBetweenTracks > sqrt(pow(Track1->
Vertex().X()-Track2->
End().X(),2) + pow(Track1->
Vertex().Y()-Track2->
End().Y(),2) + pow(Track1->
Vertex().Z()-Track2->
End().Z(),2)))
1080 TempDistanceBetweenTracks = sqrt(pow(Track1->
Vertex().X()-Track2->
End().X(),2) + pow(Track1->
Vertex().Y()-Track2->
End().Y(),2) + pow(Track1->
Vertex().Z()-Track2->
End().Z(),2));
1082 TempCriteriaTwoTracks = 3.;
1085 if(TempDistanceBetweenTracks > sqrt(pow(Track1->
Vertex().X()-Track2->
Vertex().X(),2) + pow(Track1->
Vertex().Y()-Track2->
Vertex().Y(),2) + pow(Track1->
Vertex().Z()-Track2->
Vertex().Z(),2)))
1087 TempDistanceBetweenTracks = sqrt(pow(Track1->
Vertex().X()-Track2->
Vertex().X(),2) + pow(Track1->
Vertex().Y()-Track2->
Vertex().Y(),2) + pow(Track1->
Vertex().Z()-Track2->
Vertex().Z(),2));
1089 TempCriteriaTwoTracks = 4.;
1096 TempDistanceBetweenTruthAndRecoTrack = sqrt(pow(Track->
Vertex().X() - MCparticle->
Vx(),2) + pow(Track->
Vertex().Y() - MCparticle->
Vy(),2) + pow(Track->
Vertex().Z() - MCparticle->
Vz(),2));
1098 TempAngleBeetweenTruthAndRecoTrack=0;
1107 if( !MCparticle )
return -999.0;
1109 std::vector<double> TPCLengthHits(numberTrajectoryPoints, 0);
1110 int FirstHit=0, LastHit=0;
1111 double TPCLength = 0.0;
1112 bool BeenInVolume =
false;
1114 for(
unsigned int MCHit=0; MCHit < TPCLengthHits.size(); ++MCHit) {
1115 const TLorentzVector& tmpPosition= MCparticle->
Position(MCHit);
1116 double const tmpPosArray[]={tmpPosition[0],tmpPosition[1],tmpPosition[2]};
1117 if (MCHit!=0) TPCLengthHits[MCHit] = sqrt( pow( (MCparticle->
Vx(MCHit-1)-MCparticle->
Vx(MCHit)),2)+ pow( (MCparticle->
Vy(MCHit-1)-MCparticle->
Vy(MCHit)),2)+ pow( (MCparticle->
Vz(MCHit-1)-MCparticle->
Vz(MCHit)),2));
1136 if( !BeenInVolume ) {
1137 BeenInVolume =
true;
1142 for (
int Hit = FirstHit+1; Hit <= LastHit; ++Hit ) TPCLength += TPCLengthHits[Hit];
1148 double x = vertex[0];
1149 double y = vertex[1];
1150 double z = vertex[2];
1152 if (x>fFidVolXmin && x<fFidVolXmax&&
1153 y>fFidVolYmin && y<fFidVolYmax&&
1154 z>fFidVolZmin && z<fFidVolZmax)
1161 std::cout << std::endl;
1163 std::cout <<
"EventCounter: " <<
"\t" << EventCounter << std::endl;
1165 std::cout <<
"CountMCTruthMuon: " <<
"\t" << CountMCTruthMuon <<
" = " << 100*
static_cast<double>(
CountMCTruthMuon)/static_cast<double>(EventCounter) <<
"%" << std::endl;
1167 std::cout <<
"CountGoodLeadingMuonTrack (=good events): " <<
"\t" << CountGoodLeadingMuonTrack <<
"/" << CountMCTruthMuon <<
" = " << 100*
static_cast<double>(
CountGoodLeadingMuonTrack)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1169 std::cout <<
"CountBadLeadingMuonTrack+CountNoRecoTracks+CountNoMuonTracks (=bad events): " <<
"\t" << CountBadLeadingMuonTrack+CountNoRecoTracks+CountNoMuonTracks <<
" = " << 100*
static_cast<double>(CountBadLeadingMuonTrack+CountNoRecoTracks+
CountNoMuonTracks)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1171 std::cout <<
"CountNoRecoTracks+CountNoMuonTracks: " <<
"\t" << CountNoRecoTracks+CountNoMuonTracks <<
" = " << 100*
static_cast<double>(CountNoRecoTracks+
CountNoMuonTracks)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1173 std::cout <<
"CountTrackLengthTooShort: " <<
"\t" << CountTrackLengthTooShort <<
" = " << 100*
static_cast<double>(
CountTrackLengthTooShort)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1176 std::cout <<
"CountCompleteness: " <<
"\t" << CountCompleteness <<
" = " << 100*
static_cast<double>(
CountCompleteness)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1178 std::cout <<
"CountTrackLengthTooLong: " <<
"\t" << CountTrackLengthTooLong <<
" = " << 100*
static_cast<double>(
CountTrackLengthTooLong)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1180 std::cout <<
"CountPurity: " <<
"\t" << CountPurity <<
" = " << 100*
static_cast<double>(
CountPurity)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1183 std::cout << std::endl;
1185 std::cout <<
"GoodLeadingMuonTrack+CountBadLeadingMuonTrackButLeadingPlusSecondGood (=good events after stitching): " <<
"\t" << CountGoodLeadingMuonTrack+CountBadLeadingMuonTrackButLeadingPlusSecondGood <<
"/" << CountMCTruthMuon <<
" = " << 100*
static_cast<double>(CountGoodLeadingMuonTrack+
CountBadLeadingMuonTrackButLeadingPlusSecondGood)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1187 std::cout <<
"CountBadLeadingMuonTrack+CountNoRecoTracks+CountNoMuonTracks-CountBadLeadingMuonTrackButLeadingPlusSecondGood (=bad events after stitching) : " <<
"\t" << CountBadLeadingMuonTrack+CountNoRecoTracks+CountNoMuonTracks-CountBadLeadingMuonTrackButLeadingPlusSecondGood <<
" = " << 100*
static_cast<double>(CountBadLeadingMuonTrack+CountNoRecoTracks+CountNoMuonTracks-
CountBadLeadingMuonTrackButLeadingPlusSecondGood)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1189 std::cout << std::endl;
1191 std::cout <<
"CountBadLeadingMuonTrackButLeadingPlusSecondGood: " <<
"\t" << CountBadLeadingMuonTrackButLeadingPlusSecondGood <<
" = " << 100*
static_cast<double>(
CountBadLeadingMuonTrackButLeadingPlusSecondGood)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1193 std::cout <<
"CountBadLeadingMuonTrackAndOnlyOneMuonTrack: " <<
"\t" << CountBadLeadingMuonTrackAndOnlyOneMuonTrack <<
" = " << 100*
static_cast<double>(
CountBadLeadingMuonTrackAndOnlyOneMuonTrack)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1196 std::cout <<
"CountBadLeadingMuonTrackAndLeadingPlusSecondBad: " <<
"\t" << CountBadLeadingMuonTrackAndLeadingPlusSecondBad <<
" = " << 100*
static_cast<double>(
CountBadLeadingMuonTrackAndLeadingPlusSecondBad)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1198 std::cout <<
"CountNoRecoTracks: " <<
"\t" << CountNoRecoTracks <<
" = " << 100*
static_cast<double>(
CountNoRecoTracks)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1200 std::cout <<
"CountNoMuonTracks: " <<
"\t" << CountNoMuonTracks <<
" = " << 100*
static_cast<double>(
CountNoMuonTracks)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1202 std::cout << std::endl;
1204 std::cout <<
"CountBadLeadingMuonTrackAndOnlyOneMuonTrackCompleteness: " << CountBadLeadingMuonTrackAndOnlyOneMuonTrackCompleteness << std::endl;
1205 std::cout <<
"CountBadLeadingMuonTrackAndOnlyOneMuonTrackPurity: " << CountBadLeadingMuonTrackAndOnlyOneMuonTrackPurity << std::endl;
1206 std::cout <<
"CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooShort: " << CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooShort << std::endl;
1207 std::cout <<
"CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooLong: " << CountBadLeadingMuonTrackAndOnlyOneMuonTrackTrackTooLong << std::endl;
1209 std::cout << std::endl;
1211 std::cout <<
"CountBadLeadingMuonTrackAndLeadingPlusSecondBadCompleteness: " <<
"\t" << CountBadLeadingMuonTrackAndLeadingPlusSecondBadCompleteness <<
" = " << 100*
static_cast<double>(
CountBadLeadingMuonTrackAndLeadingPlusSecondBadCompleteness)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1213 std::cout <<
"CountBadLeadingMuonTrackAndLeadingPlusSecondBadPurity: " <<
"\t" << CountBadLeadingMuonTrackAndLeadingPlusSecondBadPurity <<
" = " << 100*
static_cast<double>(
CountBadLeadingMuonTrackAndLeadingPlusSecondBadPurity)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1215 std::cout <<
"CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooShort: " <<
"\t" << CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooShort <<
" = " << 100*
static_cast<double>(
CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooShort)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1217 std::cout <<
"CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooLong: " <<
"\t" << CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooLong <<
" = " << 100*
static_cast<double>(
CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooLong)/static_cast<double>(CountMCTruthMuon) <<
"%" << std::endl;
1219 std::cout << std::endl;
1221 std::cout <<
"GoodEvents1MuonTrack: " << GoodEvents1MuonTrack << std::endl;
1222 std::cout <<
"GoodEvents2MuonTrack: " << GoodEvents2MuonTrack << std::endl;
1223 std::cout <<
"GoodEvents3MuonTrack: " << GoodEvents3MuonTrack << std::endl;
1224 std::cout <<
"GoodEvents4OrMoreMuonTrack: " << GoodEvents4OrMoreMuonTrack << std::endl;
1226 std::cout <<
"BadEvents0MuonTrack: " << BadEvents0MuonTrack << std::endl;
1227 std::cout <<
"BadEvents1MuonTrack: " << BadEvents1MuonTrack << std::endl;
1228 std::cout <<
"BadEvents2MuonTrack: " << BadEvents2MuonTrack << std::endl;
1229 std::cout <<
"BadEvents3MuonTrack: " << BadEvents3MuonTrack << std::endl;
1230 std::cout <<
"BadEvents4OrMoreMuonTrack: " << BadEvents4OrMoreMuonTrack << std::endl;
1240 h_Criteria_NRecoTrack_den->SetBinContent(1+2*i,1+2*j,CountNoRecoTracks);
1241 h_Criteria_NMuonTrack_den->SetBinContent(1+2*i,1+2*j,CountNoRecoTracks);
1245 h_Criteria_NRecoTrack_den->SetBinContent(1+2*i,1+2*j,CountNoMuonTracks);
1246 h_Criteria_NMuonTrack_den->SetBinContent(1+2*i,1+2*j,CountNoMuonTracks);
1250 h_Criteria_NRecoTrack_den->SetBinContent(1+2*i,1+2*j,CountCompleteness);
1251 h_Criteria_NMuonTrack_den->SetBinContent(1+2*i,1+2*j,CountCompleteness);
1255 h_Criteria_NRecoTrack_den->SetBinContent(1+2*i,1+2*j,CountPurity);
1256 h_Criteria_NMuonTrack_den->SetBinContent(1+2*i,1+2*j,CountPurity);
1260 h_Criteria_NRecoTrack_den->SetBinContent(1+2*i,1+2*j,CountTrackLengthTooShort);
1261 h_Criteria_NMuonTrack_den->SetBinContent(1+2*i,1+2*j,CountTrackLengthTooShort);
1265 h_Criteria_NRecoTrack_den->SetBinContent(1+2*i,1+2*j,CountTrackLengthTooLong);
1266 h_Criteria_NMuonTrack_den->SetBinContent(1+2*i,1+2*j,CountTrackLengthTooLong);
1270 h_Criteria_NRecoTrack_den->SetBinContent(1+2*i,1+2*j,CountRecoMuon);
1271 h_Criteria_NMuonTrack_den->SetBinContent(1+2*i,1+2*j,CountRecoMuon);
1277 h_Efficiency_ThetaXZ->Divide(h_ThetaXZ_num,h_ThetaXZ_den,1,1,
"");
1278 h_Efficiency_ThetaYZ->Divide(h_ThetaYZ_num,h_ThetaYZ_den,1,1,
"");
1279 h_Efficiency_SinThetaYZ->Divide(h_SinThetaYZ_num,h_SinThetaYZ_den,1,1,
"");
1281 h_Efficiency_ThetaXZ_ThetaYZ->Divide(h_ThetaXZ_ThetaYZ_num, h_ThetaXZ_ThetaYZ_den, 1, 1,
"");
1282 h_Efficiency_ThetaXZ_SinThetaYZ->Divide(h_ThetaXZ_SinThetaYZ_num, h_ThetaXZ_SinThetaYZ_den, 1, 1,
"");
1284 h_Criteria_NRecoTrack->Divide(h_Criteria_NRecoTrack_num, h_Criteria_NRecoTrack_den, 1, 1,
"");
1285 h_Criteria_NMuonTrack->Divide(h_Criteria_NMuonTrack_num, h_Criteria_NMuonTrack_den, 1, 1,
"");
1287 h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk_num->Add(h_ThetaXZ_ThetaYZ_num,1);
1288 h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk_num->Add(h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk,1);
1289 h_Efficiency_ThetaXZ_ThetaYZ_LeadingPlusSecond->Divide(h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk_num,h_ThetaXZ_ThetaYZ_den, 1, 1,
"");
1291 h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk_num->Add(h_ThetaXZ_SinThetaYZ_num,1);
1292 h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk_num->Add(h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk,1);
1293 h_Efficiency_ThetaXZ_SinThetaYZ_LeadingPlusSecond->Divide(h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk_num,h_ThetaXZ_SinThetaYZ_den, 1, 1,
"");
1295 h_Efficiency_ThetaXZ_ThetaYZ_DifferenceLeadingAndLeadingPlusSecond->Add(h_Efficiency_ThetaXZ_ThetaYZ_LeadingPlusSecond,1);
1296 h_Efficiency_ThetaXZ_ThetaYZ_DifferenceLeadingAndLeadingPlusSecond->Add(h_Efficiency_ThetaXZ_ThetaYZ,-1);
1303 #endif // MuonTrackingEff_Module
TH2D * h_MuonTrackStitching_TrackRes_Completeness
TH2D * h_NoRecoTrackAtAll_ThetaXZ_SinThetaYZ
TH2D * h_NoMuonTrack_ThetaXZ_SinThetaYZ
TH2D * h_Completeness_ThetaXZ_SinThetaYZ
Store parameters for running LArG4.
const simb::MCParticle * TrackIdToParticle_P(int const &id)
int CountBadLeadingMuonTrackButLeadingPlusSecondGood
unsigned int NumberTrajectoryPoints() const
const TLorentzVector & Position(const int i=0) const
virtual const ::detinfo::ElecClock & TPCClock() const =0
Lends a constant TPC clock with time set to trigger time.
TH2D * h_TrackTooLong_ThetaXZ_SinThetaYZ
void FuncDistanceAndAngleBetweenTruthAndRecoTrack(const simb::MCParticle *&MCparticle, art::Ptr< recob::Track > Track, double &TempDistanceBetweenTruthAndRecoTrack, double &TempAngleBeetweenTruthAndRecoTrack)
TVector3 VertexDirection() const
Covariance matrices are either set or not.
const std::vector< sim::TrackIDE > HitToTrackIDEs(recob::Hit const &hit)
int CountBadLeadingMuonTrackAndLeadingPlusSecondBadPurity
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< TrackID > TrackIDs
TH1D * h_Efficiency_ThetaXZ
TH2D * h_TrackTooShort_ThetaXZ_SinThetaYZ
TH2D * h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk
int CountTrackLengthTooShort
list_type::const_iterator const_iterator
TH2D * h_MuonTrackStitching_Distance_Angle
TH2D * h_MuonTrackStitching_FailedCriteria_CriteriaTwoTracks_Angle
Geometry information for a single TPC.
TH2D * h_NoMuonTrack_MaxTrackLength_PDGCode
TH2D * h_MuonTrackStitching_MatchedCriteria_TrackResLeading_TrackResSecond
TH2D * h_Efficiency_ThetaXZ_SinThetaYZ_LeadingPlusSecond
TH2D * h_Criteria_NRecoTrack_num
TH2D * h_MuonTrackStitching_FailedCriteria_Distance_Angle
bool get(SelectorBase const &, Handle< PROD > &result) const
TH2D * h_ThetaXZ_ThetaYZ_LeadingPlusSecondOk_num
TH2D * h_MuonTrackStitching_MatchedCriteria_TrackRes_Completeness
void reconfigure(fhicl::ParameterSet const &pset)
TH1D * h_Efficiency_ThetaYZ
art::ServiceHandle< geo::Geometry > geom
int CountBadLeadingMuonTrackAndOnlyOneMuonTrack
TH2D * h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk
TH2D * h_MuonTrackStitching_MatchedCriteria_CriteriaTwoTracks_Angle
TH2D * h_MuonTrackStitching_FailedCriteria_CompletenessSecondMuon_Angle
TH2D * h_MuonTrackStitching_FailedCriteria_CompletenessLeading_CompletenessSecond
bool insideFV(double vertex[4])
TH2D * h_FailedReconstruction_ThetaXZ_SinThetaYZ
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
TH2D * h_MuonTrackStitching_FailedCriteria_TrackRes_Completeness
std::string fMCTruthModuleLabel
TH2D * h_MuonTrackStitching_TrackResLeading_TrackResSecond
double Length(size_t p=0) const
Access to various track properties.
TH2D * h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackResLeading_TrackResSecond
#define DEFINE_ART_MODULE(klass)
TH2D * h_Efficiency_ThetaXZ_ThetaYZ_DifferenceLeadingAndLeadingPlusSecond
T get(std::string const &key) const
int CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooShort
TH2D * h_Efficiency_ThetaXZ_ThetaYZ
TH2D * h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_TrackRes_Completeness
void processEff(const art::Event &evt, bool &isFiducial)
int CountGoodLeadingMuonTrack
TH2D * h_Criteria_NMuonTrack_den
virtual unsigned int NumberTimeSamples() const =0
void FuncDistanceAndAngleBetweenTracks(art::Ptr< recob::Track > Track1, art::Ptr< recob::Track > Track2, double &TempDistanceBetweenTracks, double &TempAngleBetweenTracks, double &TempCriteriaTwoTracks)
The data type to uniquely identify a TPC.
TH1D * h_Efficiency_SinThetaYZ
Provides recob::Track data product.
Definition of data types for geometry description.
TH2D * h_ThetaXZ_SinThetaYZ_den
Detector simulation of raw signals on wires.
Conversion of times between different formats and references.
TH2D * h_MuonTrackStitching_FailedCriteria_TrackResSecondMuon_Angle
double Vx(const int i=0) const
int CountBadLeadingMuonTrackAndLeadingPlusSecondBad
TH2D * h_Criteria_NMuonTrack
T * make(ARGS...args) const
TH2D * h_Efficiency_ThetaXZ_ThetaYZ_LeadingPlusSecond
TH2D * h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackResLeading_TrackResSecond
TH2D * h_ThetaXZ_SinThetaYZ_LeadingPlusSecondOk_num
double TickPeriod() const
A single tick period in microseconds.
int CountBadLeadingMuonTrackAndLeadingPlusSecondBadTrackTooLong
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
TH2D * h_Criteria_NRecoTrack_den
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
TH2D * h_Purity_ThetaXZ_SinThetaYZ
TH2D * h_ThetaXZ_ThetaYZ_num
TH2D * h_MuonTrackStitching_FailedCriteriaAndLeadingPlusSecondBad_Distance_Angle
int CountTrackLengthTooLong
TH2D * h_ThetaXZ_ThetaYZ_den
TVector3 Vertex() const
Covariance matrices are either set or not.
const TLorentzVector & Momentum(const int i=0) const
void beginRun(const art::Run &run)
TH2D * h_MuonTrackStitching_CompletenessSecondMuon_Angle
TVector3 EndDirection() const
Covariance matrices are either set or not.
double Vz(const int i=0) const
TH2D * h_Efficiency_ThetaXZ_SinThetaYZ
TH2D * h_Criteria_NRecoTrack
const sim::ParticleList & ParticleList()
TH2D * h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_TrackRes_Completeness
TH2D * h_FailedReconstruction_ThetaXZ_ThetaYZ
double truthLength(const simb::MCParticle *MCparticle)
TH2D * h_MuonTrackStitching_FailedCriteria_TrackResLeading_TrackResSecond
void truthMatcher(std::vector< art::Ptr< recob::Hit >> AllHits, std::vector< art::Ptr< recob::Hit >> track_hits, const simb::MCParticle *&MCparticle, double &Purity, double &Completeness, double &TotalRecoEnergy)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
virtual ~MuonTrackingEff()
TH2D * h_MuonTrackStitching_CriteriaTwoTracks_Angle
Namespace collecting geometry-related classes utilities.
TH2D * h_Criteria_NMuonTrack_num
TVector3 End() const
Covariance matrices are either set or not.
TH2D * h_MuonTrackStitching_TrackResSecondMuon_Angle
int CountBadLeadingMuonTrackAndLeadingPlusSecondBadCompleteness
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
double MCTruthMuonMomentum
TH2D * h_ThetaXZ_SinThetaYZ_num
double Vy(const int i=0) const
TH2D * h_MuonTrackStitching_MatchedCriteria_Distance_Angle
Event finding and building.
void analyze(const art::Event &evt)
TH2D * h_MuonTrackStitching_FailedCriteriaButLeadingPlusSecondGood_Distance_Angle
std::string fTrackModuleLabel