18 #include "art_root_io/TFileService.h" 19 #include "canvas/Persistency/Common/FindManyP.h" 24 #include "TEfficiency.h" 25 #include "TGraphAsymmErrors.h" 29 #define MAX_SHOWERS 1000 42 void endJob()
override;
59 bool insideFV(
double vertex[4]);
60 void doEfficiencies();
105 TEfficiency* h_Eff_Ev = 0;
106 TEfficiency* h_Eff_Ev_dEdx = 0;
107 TEfficiency* h_Eff_Ee = 0;
108 TEfficiency* h_Eff_Ee_dEdx = 0;
109 TEfficiency* h_Eff_Pe = 0;
110 TEfficiency* h_Eff_theta = 0;
206 double MC_incoming_P[4];
207 double MC_lepton_startMomentum[4];
208 double MC_lepton_endMomentum[4];
209 double MC_lepton_startXYZT[4];
210 double MC_lepton_endXYZT[4];
276 cout <<
"job begin..." <<
endl;
279 auto const*
geo = lar::providerFrom<geo::Geometry>();
288 for (
size_t i = 0; i <
geo->NTPC(); ++i) {
289 double local[3] = {0., 0., 0.};
290 double world[3] = {0., 0., 0.};
293 if (minx > world[0] -
geo->DetHalfWidth(i)) minx = world[0] -
geo->DetHalfWidth(i);
294 if (maxx < world[0] +
geo->DetHalfWidth(i)) maxx = world[0] +
geo->DetHalfWidth(i);
295 if (miny > world[1] -
geo->DetHalfHeight(i)) miny = world[1] -
geo->DetHalfHeight(i);
296 if (maxy < world[1] +
geo->DetHalfHeight(i)) maxy = world[1] +
geo->DetHalfHeight(i);
297 if (minz > world[2] -
geo->DetLength(i) / 2.) minz = world[2] -
geo->DetLength(i) / 2.;
298 if (maxz < world[2] +
geo->DetLength(i) / 2.) maxz = world[2] +
geo->DetLength(i) / 2.;
308 std::cout <<
"Fiducial volume:" 316 double E_bins[21] = {0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4, 4.5, 5.0,
317 5.5, 6.0, 7.0, 8.0, 10.0, 12.0, 14.0, 17.0, 20.0, 25.0};
318 double theta_bin[44] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.,
319 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 22.,
320 24., 26., 28., 30., 32., 34., 36., 38., 40., 42., 44.,
321 46., 48., 50., 55., 60., 65., 70., 75., 80., 85., 90.};
325 tfs->make<TH1D>(
"h_Ev_den",
326 "Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",
331 tfs->make<TH1D>(
"h_Ev_num",
332 "Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",
337 tfs->make<TH1D>(
"h_Ev_num_dEdx",
338 "Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",
344 tfs->make<TH1D>(
"h_Ee_den",
345 "Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",
350 tfs->make<TH1D>(
"h_Ee_num",
351 "Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",
356 tfs->make<TH1D>(
"h_Ee_num_dEdx",
357 "Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",
364 "Electron Momentum; Electron Momentum (GeV); Shower reconstruction Efficiency",
370 "Electron Momentum; Electron Momentum (GeV); Shower reconstruction Efficiency",
377 "CosTheta; CosTheta w.r.t beam direction (Degrees); Shower reconstruction Efficiency",
383 "CosTheta; CosTheta w.r.t beam direction (Degrees); Shower reconstruction Efficiency",
389 "h_Efrac_shContamination",
"Efrac Lepton; Energy fraction (contamination);", 60, 0, 1.2);
392 tfs->make<TH1D>(
"h_Efrac_shPurity",
"Efrac Lepton; Energy fraction (Purity);", 60, 0, 1.2);
395 tfs->make<TH1D>(
"h_Ecomplet_lepton",
"Ecomplet Lepton; Shower Completeness;", 60, 0, 1.2);
399 tfs->make<TH1D>(
"h_HighestHitsProducedParticlePDG_NueCC",
400 "PDG Code; PDG Code;",
406 tfs->make<TH1D>(
"h_HighestHitsProducedParticlePDG_bkg",
407 "PDG Code; PDG Code;",
414 "h_Efrac_NueCCPurity",
"Efrac NueCC; Energy fraction (Purity);", 60, 0, 1.2);
417 tfs->make<TH1D>(
"h_Ecomplet_NueCC",
"Ecomplet NueCC; Shower Completeness;", 60, 0, 1.2);
421 "h_Efrac_bkgPurity",
"Efrac bkg; Energy fraction (Purity);", 60, 0, 1.2);
424 tfs->make<TH1D>(
"h_Ecomplet_bkg",
"Ecomplet bkg; Shower Completeness;", 60, 0, 1.2);
428 tfs->make<TH1D>(
"h_esh_bestplane_NueCC",
"Best plane; Best plane;", 4, -0.5, 3.5);
430 tfs->make<TH1D>(
"h_esh_bestplane_NC",
"Best plane; Best plane;", 4, -0.5, 3.5);
432 "dE/dX; Electron or Positron dE/dX (MeV/cm);",
437 "dE/dX; Electron or Positron dE/dX (MeV/cm);",
442 tfs->make<TH1D>(
"h_dEdX_photon_NueCC",
"dE/dX; photon dE/dX (MeV/cm);", 100, 0.0, 15.0);
444 tfs->make<TH1D>(
"h_dEdX_photon_NC",
"dE/dX; photon dE/dX (MeV/cm);", 100, 0.0, 15.0);
446 tfs->make<TH1D>(
"h_dEdX_proton_NueCC",
"dE/dX; proton dE/dX (MeV/cm);", 100, 0.0, 15.0);
448 tfs->make<TH1D>(
"h_dEdX_proton_NC",
"dE/dX; proton dE/dX (MeV/cm);", 100, 0.0, 15.0);
450 tfs->make<TH1D>(
"h_dEdX_neutron_NueCC",
"dE/dX; neutron dE/dX (MeV/cm);", 100, 0.0, 15.0);
452 tfs->make<TH1D>(
"h_dEdX_neutron_NC",
"dE/dX; neutron dE/dX (MeV/cm);", 100, 0.0, 15.0);
454 "h_dEdX_chargedpion_NueCC",
"dE/dX; charged pion dE/dX (MeV/cm);", 100, 0.0, 15.0);
456 "h_dEdX_chargedpion_NC",
"dE/dX; charged pion dE/dX (MeV/cm);", 100, 0.0, 15.0);
458 "h_dEdX_neutralpion_NueCC",
"dE/dX; neutral pion dE/dX (MeV/cm);", 100, 0.0, 15.0);
460 "h_dEdX_neutralpion_NC",
"dE/dX; neutral pion dE/dX (MeV/cm);", 100, 0.0, 15.0);
462 "h_dEdX_everythingelse_NueCC",
"dE/dX; everythingelse dE/dX (MeV/cm);", 100, 0.0, 15.0);
464 "h_dEdX_everythingelse_NC",
"dE/dX; everythingelse dE/dX (MeV/cm);", 100, 0.0, 15.0);
467 tfs->make<TH1D>(
"h_dEdXasymm_electronorpositron_NueCC",
468 "dE/dX asymmetry; Electron or Positron dE/dX asymmetry;",
473 "h_dEdXasymm_photon_NC",
"dE/dX asymmetry; photon dE/dx asymmetry;", 60, 0.0, 1.2);
476 tfs->make<TH1D>(
"h_mpi0_electronorpositron_NueCC",
477 "m(#gamma#gamma); Electron or Positron dE/dX (MeV/cm);",
482 "h_mpi0_photon_NC",
"m(#gamma#gamma); Electron or Positron dE/dX (MeV/cm);", 100, 0, 1);
505 h_mpi0_photon_NC->Sumw2();
507 h_trklike_em = tfs->make<TH1D>(
"h_trklike_em",
"EM hits; Track-like Score;", 100, 0, 1);
509 tfs->make<TH1D>(
"h_trklike_nonem",
"Non-EM hits; Track-like Score;", 100, 0, 1);
513 tfs->make<TH1D>(
"h_CosThetaShDirwrtTrueparticle_electronorpositron_NueCC",
514 "CosTheta; cos#theta;",
519 tfs->make<TH1D>(
"h_CosThetaShDirwrtTrueparticle_electronorpositron_NC",
520 "CosTheta;cos#theta;",
525 "h_CosThetaShDirwrtTrueparticle_photon_NueCC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
527 "h_CosThetaShDirwrtTrueparticle_photon_NC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
529 "h_CosThetaShDirwrtTrueparticle_proton_NueCC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
531 "h_CosThetaShDirwrtTrueparticle_proton_NC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
533 "h_CosThetaShDirwrtTrueparticle_chargedpion_NueCC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
535 "h_CosThetaShDirwrtTrueparticle_chargedpion_NC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
539 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_electronorpositron_NueCC",
540 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
545 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_electronorpositron_NueCC",
546 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
551 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_electronorpositron_NueCC",
552 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
558 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_electronorpositron_NC",
559 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
564 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_electronorpositron_NC",
565 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
570 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_electronorpositron_NC",
571 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
577 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_photon_NueCC",
578 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
583 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_photon_NueCC",
584 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
589 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_photon_NueCC",
590 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
596 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_photon_NC",
597 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
602 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_photon_NC",
603 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
608 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_photon_NC",
609 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
615 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleEndXDiff_photon_NueCC",
616 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
621 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleEndYDiff_photon_NueCC",
622 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
627 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleEndZDiff_photon_NueCC",
628 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
634 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleEndXDiff_photon_NC",
635 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
640 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleEndYDiff_photon_NC",
641 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
646 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleEndZDiff_photon_NC",
647 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
653 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_proton_NueCC",
654 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
659 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_proton_NueCC",
660 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
665 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_proton_NueCC",
666 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
672 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_proton_NC",
673 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
678 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_proton_NC",
679 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
684 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_proton_NC",
685 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
691 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_chargedpion_NueCC",
692 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
697 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_chargedpion_NueCC",
698 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
703 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_chargedpion_NueCC",
704 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
710 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_chargedpion_NC",
711 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
716 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_chargedpion_NC",
717 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
722 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_chargedpion_NC",
723 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
729 h_CosThetaShDirwrtTrueparticle_electronorpositron_NueCC->Sumw2();
780 fEventTree =
new TTree(
"Event",
"Event Tree from Sim & Reco");
846 Event =
event.id().event();
849 bool isFiducial =
false;
851 auto const clockData =
869 std::vector<art::Ptr<simb::MCTruth>> MCtruthlist;
874 int MCinteractions = MCtruthlist.size();
875 for (
int i = 0; i < MCinteractions; i++) {
876 MCtruth = MCtruthlist[i];
881 else if (nu.
CCNC() == 1)
889 const TLorentzVector& nu_momentum = nu.
Nu().
Momentum(0);
901 const sim::ParticleList& plist = pi_serv->
ParticleList();
905 particle = ipar->second;
907 particle->
Mother() == 0) {
908 const TLorentzVector& lepton_momentum = particle->
Momentum(0);
909 const TLorentzVector& lepton_position = particle->
Position(0);
910 const TLorentzVector& lepton_positionEnd = particle->
EndPosition();
911 const TLorentzVector& lepton_momentumEnd = particle->
EndMomentum();
922 if (!isFiducial)
return;
931 theta_e *= (180.0 / 3.14159);
937 h_Ee_den->Fill(MC_lepton_startMomentum[3]);
954 std::vector<art::Ptr<recob::Shower>> showerlist;
958 std::vector<art::Ptr<recob::Hit>> all_hits;
965 double Efrac_contamination = 999.0;
966 double Efrac_contaminationNueCC = 999.0;
968 double Ecomplet_lepton = 0.0;
969 double Ecomplet_NueCC = 0.0;
970 int ParticlePDG_HighestShHits = 0;
971 int shower_bestplane = 0;
972 double Showerparticlededx_inbestplane = 0.0;
973 double dEdxasymm_largestshw = -1.;
975 int showerPDGwithHighestHitsforFillingdEdX =
978 double ShAngle = -9999.0, ShVxTrueParticleVxDiff = -9999.0, ShVyTrueParticleVyDiff = -9999.0,
979 ShVzTrueParticleVzDiff = -9999.0, ShStartVxTrueParticleEndVxDiff = -9999.0,
980 ShStartVyTrueParticleEndVyDiff = -9999.0, ShStartVzTrueParticleEndVzDiff = -9999.0;
1000 for (
size_t j = 0; j < shower->
Energy().size(); j++)
1002 for (
size_t j = 0; j < shower->
MIPEnergy().size(); j++)
1004 for (
size_t j = 0; j < shower->
dEdx().size(); j++)
1007 double dEdxasymm = -1;
1014 for (
int j = 0; j < 3; ++j) {
1016 if (j >=
int(shower->
Energy().size()))
continue;
1017 if (shower->
Energy()[j] > maxE) {
1018 maxE = shower->
Energy()[j];
1019 dEdx1 = shower->
dEdx()[j];
1022 if (dEdx0 || dEdx1) { dEdxasymm =
std::abs(dEdx0 - dEdx1) / (dEdx0 + dEdx1); }
1046 std::vector<art::Ptr<recob::Hit>> sh_hits = sh_hitsAll.at(i);
1048 if (!sh_hits.size()) {
1052 std::vector<art::Ptr<recob::PFParticle>> pfps;
1056 std::vector<art::Ptr<recob::Cluster>> clusters;
1062 if (fmps.isValid()) {
1063 std::vector<art::Ptr<recob::PFParticle>> pfs = fmps.at(i);
1064 for (
size_t ipf = 0; ipf < pfs.size(); ++ipf) {
1065 if (fmcp.isValid()) {
1066 std::vector<art::Ptr<recob::Cluster>> clus = fmcp.at(pfs[ipf].
key());
1067 for (
size_t iclu = 0; iclu < clus.size(); ++iclu) {
1068 if (fmhc.isValid()) {
1069 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(clus[iclu].
key());
1070 for (
size_t ihit = 0; ihit < hits.size(); ++ihit) {
1071 sh_hits.push_back(hits[ihit]);
1081 double tmpEfrac_contamination =
1084 double tmpEcomplet = 0;
1086 int tmp_nHits = sh_hits.size();
1088 truthMatcher(clockData, all_hits, sh_hits, particle, tmpEfrac_contamination, tmpEcomplet);
1089 if (!particle)
continue;
1092 sh_purity[i] = 1 - tmpEfrac_contamination;
1099 if (tmp_nHits > nHits) {
1101 dEdxasymm_largestshw = dEdxasymm;
1103 Ecomplet_NueCC = tmpEcomplet;
1104 Efrac_contaminationNueCC = tmpEfrac_contamination;
1110 (ShDirMag * particle->
P());
1112 ShVxTrueParticleVxDiff =
sh_start_X[i] - particle->
Vx();
1113 ShVyTrueParticleVyDiff =
sh_start_Y[i] - particle->
Vy();
1114 ShVzTrueParticleVzDiff =
sh_start_Z[i] - particle->
Vz();
1117 if (ShVxTrueParticleVxDiff > 5)
1118 ShVxTrueParticleVxDiff = 4.99;
1119 else if (ShVxTrueParticleVxDiff < -5)
1120 ShVxTrueParticleVxDiff = -5;
1121 if (ShVyTrueParticleVyDiff > 5)
1122 ShVyTrueParticleVyDiff = 4.99;
1123 else if (ShVyTrueParticleVyDiff < -5)
1124 ShVyTrueParticleVyDiff = -5;
1125 if (ShVzTrueParticleVzDiff > 5)
1126 ShVzTrueParticleVzDiff = 4.99;
1127 else if (ShVzTrueParticleVzDiff < -5)
1128 ShVzTrueParticleVzDiff = -5;
1130 ShStartVxTrueParticleEndVxDiff =
sh_start_X[i] - particle->
EndX();
1131 ShStartVyTrueParticleEndVyDiff =
sh_start_Y[i] - particle->
EndY();
1132 ShStartVzTrueParticleEndVzDiff =
sh_start_Z[i] - particle->
EndZ();
1134 if (
std::abs(particle->
PdgCode()) == 11) { ParticlePDG_HighestShHits = 1; }
1135 else if (particle->
PdgCode() == 22) {
1136 ParticlePDG_HighestShHits = 2;
1139 ParticlePDG_HighestShHits = 3;
1145 if (shower_bestplane < 0 || shower_bestplane >=
int(shower->
dEdx().size())) {
1147 for (
size_t i = 0; i < shower->
dEdx().size(); ++i) {
1148 if (shower->
dEdx()[i]) {
1149 shower_bestplane = i;
1154 if (shower_bestplane < 0 || shower_bestplane >=
int(shower->
dEdx().size())) {
1156 shower_bestplane = 0;
1159 if (shower_bestplane >= 0 and shower_bestplane <
int(shower->
dEdx().size()))
1160 Showerparticlededx_inbestplane = shower->
dEdx()[shower_bestplane];
1163 showerPDGwithHighestHitsforFillingdEdX = 1;
1165 else if (particle->
PdgCode() == 22) {
1166 showerPDGwithHighestHitsforFillingdEdX = 2;
1168 else if (particle->
PdgCode() == 2212) {
1169 showerPDGwithHighestHitsforFillingdEdX = 3;
1171 else if (particle->
PdgCode() == 2112) {
1172 showerPDGwithHighestHitsforFillingdEdX = 4;
1175 showerPDGwithHighestHitsforFillingdEdX = 5;
1177 else if (particle->
PdgCode() == 111) {
1178 showerPDGwithHighestHitsforFillingdEdX = 6;
1181 showerPDGwithHighestHitsforFillingdEdX = 7;
1191 if (tmpEcomplet > Ecomplet_lepton) {
1193 Ecomplet_lepton = tmpEcomplet;
1195 Efrac_contamination = tmpEfrac_contamination;
1196 MClepton_reco = particle;
1202 if (p1.Mag() && p2.Mag()) {
sh_mpi0 = sqrt(
pow(p1.Mag() + p2.Mag(), 2) - (p1 + p2).Mag2()); }
1206 if (MClepton_reco && MClepton) {
1213 if (Efrac_contamination < fMaxEfrac && Ecomplet_lepton >
fMinCompleteness) {
1217 h_Ee_num->Fill(MC_lepton_startMomentum[3]);
1220 if (Showerparticlededx_inbestplane > 1 && Showerparticlededx_inbestplane < 3) {
1232 if (ParticlePDG_HighestShHits > 0) {
1237 if (showerPDGwithHighestHitsforFillingdEdX == 1)
1245 ShVxTrueParticleVxDiff);
1247 ShVyTrueParticleVyDiff);
1249 ShVzTrueParticleVzDiff);
1255 else if (showerPDGwithHighestHitsforFillingdEdX == 2)
1267 else if (showerPDGwithHighestHitsforFillingdEdX == 3)
1276 else if (showerPDGwithHighestHitsforFillingdEdX == 4)
1280 else if (showerPDGwithHighestHitsforFillingdEdX == 5)
1288 else if (showerPDGwithHighestHitsforFillingdEdX == 6)
1292 else if (showerPDGwithHighestHitsforFillingdEdX == 7)
1298 else if (!
MC_isCC && isFiducial) {
1301 if (ParticlePDG_HighestShHits > 0) {
1306 if (showerPDGwithHighestHitsforFillingdEdX == 1)
1315 else if (showerPDGwithHighestHitsforFillingdEdX == 2)
1332 else if (showerPDGwithHighestHitsforFillingdEdX == 3)
1341 else if (showerPDGwithHighestHitsforFillingdEdX == 4)
1345 else if (showerPDGwithHighestHitsforFillingdEdX == 5)
1353 else if (showerPDGwithHighestHitsforFillingdEdX == 6)
1357 else if (showerPDGwithHighestHitsforFillingdEdX == 7)
1364 checkCNNtrkshw<4>(clockData,
event, all_hits);
1383 std::map<int, double> trkID_E;
1384 for (
size_t j = 0; j < shower_hits.size(); ++j) {
1387 for (
size_t k = 0;
k < TrackIDs.size();
k++) {
1388 if (trkID_E.find(
std::abs(TrackIDs[
k].trackID)) == trkID_E.end())
1389 trkID_E[
std::abs(TrackIDs[k].trackID)] = 0;
1390 trkID_E[
std::abs(TrackIDs[k].trackID)] += TrackIDs[
k].energy;
1393 double max_E = -999.0;
1394 double total_E = 0.0;
1396 double partial_E = 0.0;
1398 if (
empty(trkID_E))
return;
1401 total_E += ii->second;
1402 if ((ii->second) > max_E) {
1403 partial_E = ii->second;
1405 TrackID = ii->first;
1410 Efrac = 1 - (partial_E / total_E);
1413 double totenergy = 0;
1414 for (
size_t k = 0;
k < all_hits.size(); ++
k) {
1417 for (
size_t l = 0;
l < TrackIDs.size(); ++
l) {
1418 if (
std::abs(TrackIDs[
l].trackID) ==
TrackID) { totenergy += TrackIDs[
l].energy; }
1421 Ecomplet = partial_E / totenergy;
1431 double x = vertex[0];
1432 double y = vertex[1];
1433 double z = vertex[2];
1450 TGraphAsymmErrors* grEff_Ev =
h_Eff_Ev->CreateGraph();
1451 grEff_Ev->Write(
"grEff_Ev");
1457 TGraphAsymmErrors* grEff_Ev_dEdx =
h_Eff_Ev_dEdx->CreateGraph();
1458 grEff_Ev_dEdx->Write(
"grEff_Ev_dEdx");
1464 TGraphAsymmErrors* grEff_Ee =
h_Eff_Ee->CreateGraph();
1465 grEff_Ee->Write(
"grEff_Ee");
1471 TGraphAsymmErrors* grEff_Ee_dEdx =
h_Eff_Ee_dEdx->CreateGraph();
1472 grEff_Ee_dEdx->Write(
"grEff_Ee_dEdx");
1478 TGraphAsymmErrors* grEff_Pe =
h_Eff_Pe->CreateGraph();
1479 grEff_Pe->Write(
"grEff_Pe");
1484 TGraphAsymmErrors* grEff_theta =
h_Eff_theta->CreateGraph();
1485 grEff_theta->Write(
"grEff_theta");
1506 int trkLikeIdx = hitResults->getIndex(
"track");
1507 int emLikeIdx = hitResults->getIndex(
"em");
1508 if ((trkLikeIdx < 0) || (emLikeIdx < 0)) {
1510 <<
"No em/track labeled columns in MVA data products." <<
std::endl;
1513 for (
size_t i = 0; i < all_hits.size(); ++i) {
1515 bool isEMparticle =
false;
1518 if (!TrackIDs.size())
continue;
1520 int trkid = INT_MAX;
1522 for (
size_t k = 0;
k < TrackIDs.size();
k++) {
1523 if (TrackIDs[
k].
energy > maxE) {
1524 maxE = TrackIDs[
k].energy;
1525 trkid = TrackIDs[
k].trackID;
1528 if (trkid != INT_MAX) {
1535 isEMparticle =
true;
1539 auto vout = hitResults->getOutput(all_hits[i]);
1540 double trk_like = -1, trk_or_em = vout[trkLikeIdx] + vout[emLikeIdx];
1541 if (trk_or_em > 0) {
1542 trk_like = vout[trkLikeIdx] / trk_or_em;
1551 std::cout <<
"Couldn't get hitResults." <<
std::endl;
1585 for (
int j = 0; j < 3; j++) {
def analyze(root, level, gtrees, gbranches, doprint)
double sh_length[MAX_SHOWERS]
TH1D * h_ShStartXwrtTrueparticleStartXDiff_electronorpositron_NC
void checkCNNtrkshw(detinfo::DetectorClocksData const &clockData, const art::Event &evt, std::vector< art::Ptr< recob::Hit >> all_hits)
const TVector3 & ShowerStart() const
const TLorentzVector & Position(const int i=0) const
const simb::MCNeutrino & GetNeutrino() const
TH1D * h_CosThetaShDirwrtTrueparticle_photon_NC
TH1D * h_ShStartZwrtTrueparticleStartZDiff_proton_NueCC
TH1D * h_ShStartXwrtTrueparticleEndXDiff_photon_NC
double Py(const int i=0) const
double sh_energy[MAX_SHOWERS][3]
TH1D * h_dEdX_electronorpositron_NueCC
const TLorentzVector & EndPosition() const
TH1D * h_ShStartXwrtTrueparticleStartXDiff_chargedpion_NC
TH1D * h_ShStartYwrtTrueparticleEndYDiff_photon_NC
double sh_direction_X[MAX_SHOWERS]
TH1D * h_dEdX_everythingelse_NC
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< TrackID > TrackIDs
const simb::MCParticle * TrackIdToParticle_P(int id) const
TH1D * h_dEdX_neutron_NueCC
TH1D * h_CosThetaShDirwrtTrueparticle_proton_NC
const simb::MCParticle & Nu() const
TH1D * h_ShStartYwrtTrueparticleStartYDiff_electronorpositron_NC
Geometry information for a single TPC.
const std::vector< double > & Energy() const
TH1D * h_HighestHitsProducedParticlePDG_NueCC
double Px(const int i=0) const
double sh_dEdx[MAX_SHOWERS][3]
art::InputTag fMCTruthModuleLabel
void analyze(const art::Event &evt) override
TH1D * h_ShStartZwrtTrueparticleEndZDiff_photon_NueCC
TH1D * h_dEdXasymm_photon_NC
void truthMatcher(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> all_hits, std::vector< art::Ptr< recob::Hit >> shower_hits, const simb::MCParticle *&MCparticle, double &Efrac, double &Ecomplet)
TH1D * h_ShStartXwrtTrueparticleStartXDiff_chargedpion_NueCC
TH1D * h_ShStartZwrtTrueparticleStartZDiff_chargedpion_NC
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
TH1D * h_ShStartXwrtTrueparticleStartXDiff_electronorpositron_NueCC
TH1D * h_mpi0_electronorpositron_NueCC
TH1D * h_CosThetaShDirwrtTrueparticle_electronorpositron_NC
TH1D * h_ShStartXwrtTrueparticleStartXDiff_proton_NC
TH1D * h_ShStartXwrtTrueparticleStartXDiff_photon_NueCC
TH1D * h_CosThetaShDirwrtTrueparticle_photon_NueCC
TH1D * h_ShStartYwrtTrueparticleStartYDiff_electronorpositron_NueCC
TH1D * h_ShStartYwrtTrueparticleStartYDiff_proton_NueCC
TEfficiency * h_Eff_Ev_dEdx
int InteractionType() const
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
QTextStream & reset(QTextStream &s)
TH1D * h_ShStartZwrtTrueparticleStartZDiff_chargedpion_NueCC
TH1D * h_dEdX_chargedpion_NueCC
const simb::MCParticle & Lepton() const
TH1D * h_ShStartYwrtTrueparticleEndYDiff_photon_NueCC
const std::vector< double > & dEdx() const
#define DEFINE_ART_MODULE(klass)
const std::vector< double > & MIPEnergy() const
TH1D * h_ShStartZwrtTrueparticleStartZDiff_photon_NC
double sh_purity[MAX_SHOWERS]
TH1D * h_ShStartZwrtTrueparticleStartZDiff_proton_NC
double sh_completeness[MAX_SHOWERS]
art::InputTag fShowerModuleLabel
double P(const int i=0) const
T get(std::string const &key) const
art::InputTag fHitModuleLabel
int sh_bestplane[MAX_SHOWERS]
int sh_hasPrimary_e[MAX_SHOWERS]
double sh_dEdxasymm[MAX_SHOWERS]
double sh_direction_Z[MAX_SHOWERS]
TH1D * h_esh_bestplane_NC
double sh_start_Y[MAX_SHOWERS]
TEfficiency * h_Eff_Ee_dEdx
bool insideFV(double vertex[4])
double sh_direction_Y[MAX_SHOWERS]
const TVector3 & Direction() const
double sh_start_X[MAX_SHOWERS]
TH1D * h_CosThetaShDirwrtTrueparticle_proton_NueCC
TH1D * h_ShStartYwrtTrueparticleStartYDiff_photon_NueCC
TH1D * h_ShStartZwrtTrueparticleStartZDiff_photon_NueCC
TH1D * h_CosThetaShDirwrtTrueparticle_chargedpion_NC
TH1D * h_ShStartYwrtTrueparticleStartYDiff_chargedpion_NC
TH1D * h_CosThetaShDirwrtTrueparticle_chargedpion_NueCC
Detector simulation of raw signals on wires.
double sh_start_Z[MAX_SHOWERS]
const sim::ParticleList & ParticleList() const
double MC_lepton_endMomentum[4]
TH1D * h_dEdX_neutralpion_NueCC
TH1D * h_ShStartZwrtTrueparticleStartZDiff_electronorpositron_NueCC
TH1D * h_dEdX_neutralpion_NC
TH1D * h_Efrac_NueCCPurity
double Vx(const int i=0) const
double MC_lepton_startMomentum[4]
TH1D * h_ShStartXwrtTrueparticleEndXDiff_photon_NueCC
TH1D * h_HighestHitsProducedParticlePDG_bkg
TH1D * h_ShStartYwrtTrueparticleStartYDiff_chargedpion_NueCC
TH1D * h_dEdX_electronorpositron_NC
art::InputTag fCNNEMModuleLabel
Contains all timing reference information for the detector.
TH1D * h_ShStartXwrtTrueparticleStartXDiff_proton_NueCC
double MC_lepton_startXYZT[4]
void processEff(detinfo::DetectorClocksData const &clockData, const art::Event &evt, bool &isFiducial)
TH1D * h_ShStartYwrtTrueparticleStartYDiff_proton_NC
std::vector< sim::TrackIDE > HitToEveTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
const TLorentzVector & Momentum(const int i=0) const
double Pz(const int i=0) const
TH1D * h_dEdXasymm_electronorpositron_NueCC
double Vz(const int i=0) const
TH1D * h_esh_bestplane_NueCC
TH1D * h_dEdX_chargedpion_NC
TH1D * h_dEdX_proton_NueCC
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
TH1D * h_ShStartXwrtTrueparticleStartXDiff_photon_NC
void beginRun(const art::Run &run) override
TH1D * h_ShStartYwrtTrueparticleStartYDiff_photon_NC
TH1D * h_Efrac_shContamination
double sh_Efrac_contamination[MAX_SHOWERS]
TH1D * h_ShStartZwrtTrueparticleStartZDiff_electronorpositron_NC
Event generator information.
LArSoft geometry interface.
double sh_MIPenergy[MAX_SHOWERS][3]
TEfficiency * h_Eff_theta
TH1D * h_dEdX_photon_NueCC
TH1D * h_dEdX_everythingelse_NueCC
const TLorentzVector & EndMomentum() const
void LocalToWorld(const double *tpc, double *world) const
Transform point from local TPC frame to world frame.
art::ServiceHandle< geo::Geometry const > geom
static std::unique_ptr< MVAReader > create(const art::Event &evt, const art::InputTag &tag)
double Vy(const int i=0) const
cet::coded_exception< error, detail::translate > exception
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
TH1D * h_ShStartZwrtTrueparticleEndZDiff_photon_NC
QTextStream & endl(QTextStream &s)
Event finding and building.
TH1D * h_CosThetaShDirwrtTrueparticle_electronorpositron_NueCC
int sh_nHits[MAX_SHOWERS]
double MC_lepton_endXYZT[4]