20 #include "art_root_io/TFileService.h" 26 #include "TEfficiency.h" 27 #include "TGraphAsymmErrors.h" 31 #define MAX_SHOWERS 1000 44 void endJob()
override;
45 void beginRun(
const art::Run& run)
override;
61 bool insideFV(
double vertex[4]);
62 void doEfficiencies();
107 TEfficiency* h_Eff_Ev = 0;
108 TEfficiency* h_Eff_Ev_dEdx = 0;
109 TEfficiency* h_Eff_Ee = 0;
110 TEfficiency* h_Eff_Ee_dEdx = 0;
111 TEfficiency* h_Eff_Pe = 0;
112 TEfficiency* h_Eff_theta = 0;
208 double MC_incoming_P[4];
209 double MC_lepton_startMomentum[4];
210 double MC_lepton_endMomentum[4];
211 double MC_lepton_startXYZT[4];
212 double MC_lepton_endXYZT[4];
277 cout <<
"job begin..." << endl;
280 auto const*
geo = lar::providerFrom<geo::Geometry>();
290 auto const world = tpc.GetCenter();
291 if (minx > world.X() - tpc.HalfWidth()) minx = world.X() - tpc.HalfWidth();
292 if (maxx < world.X() + tpc.HalfWidth()) maxx = world.X() + tpc.HalfWidth();
293 if (miny > world.Y() - tpc.HalfHeight()) miny = world.Y() - tpc.HalfHeight();
294 if (maxy < world.Y() + tpc.HalfHeight()) maxy = world.Y() + tpc.HalfHeight();
295 if (minz > world.Z() - tpc.Length() / 2.) minz = world.Z() - tpc.Length() / 2.;
296 if (maxz < world.Z() + tpc.Length() / 2.) maxz = world.Z() + tpc.Length() / 2.;
306 std::cout <<
"Fiducial volume:" 314 double E_bins[21] = {0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4, 4.5, 5.0,
315 5.5, 6.0, 7.0, 8.0, 10.0, 12.0, 14.0, 17.0, 20.0, 25.0};
316 double theta_bin[44] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.,
317 11., 12., 13., 14., 15., 16., 17., 18., 19., 20., 22.,
318 24., 26., 28., 30., 32., 34., 36., 38., 40., 42., 44.,
319 46., 48., 50., 55., 60., 65., 70., 75., 80., 85., 90.};
323 tfs->make<TH1D>(
"h_Ev_den",
324 "Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",
329 tfs->make<TH1D>(
"h_Ev_num",
330 "Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",
335 tfs->make<TH1D>(
"h_Ev_num_dEdx",
336 "Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",
342 tfs->make<TH1D>(
"h_Ee_den",
343 "Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",
348 tfs->make<TH1D>(
"h_Ee_num",
349 "Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",
354 tfs->make<TH1D>(
"h_Ee_num_dEdx",
355 "Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",
362 "Electron Momentum; Electron Momentum (GeV); Shower reconstruction Efficiency",
368 "Electron Momentum; Electron Momentum (GeV); Shower reconstruction Efficiency",
375 "CosTheta; CosTheta w.r.t beam direction (Degrees); Shower reconstruction Efficiency",
381 "CosTheta; CosTheta w.r.t beam direction (Degrees); Shower reconstruction Efficiency",
387 "h_Efrac_shContamination",
"Efrac Lepton; Energy fraction (contamination);", 60, 0, 1.2);
390 tfs->make<TH1D>(
"h_Efrac_shPurity",
"Efrac Lepton; Energy fraction (Purity);", 60, 0, 1.2);
393 tfs->make<TH1D>(
"h_Ecomplet_lepton",
"Ecomplet Lepton; Shower Completeness;", 60, 0, 1.2);
397 tfs->make<TH1D>(
"h_HighestHitsProducedParticlePDG_NueCC",
398 "PDG Code; PDG Code;",
404 tfs->make<TH1D>(
"h_HighestHitsProducedParticlePDG_bkg",
405 "PDG Code; PDG Code;",
412 "h_Efrac_NueCCPurity",
"Efrac NueCC; Energy fraction (Purity);", 60, 0, 1.2);
415 tfs->make<TH1D>(
"h_Ecomplet_NueCC",
"Ecomplet NueCC; Shower Completeness;", 60, 0, 1.2);
419 "h_Efrac_bkgPurity",
"Efrac bkg; Energy fraction (Purity);", 60, 0, 1.2);
422 tfs->make<TH1D>(
"h_Ecomplet_bkg",
"Ecomplet bkg; Shower Completeness;", 60, 0, 1.2);
426 tfs->make<TH1D>(
"h_esh_bestplane_NueCC",
"Best plane; Best plane;", 4, -0.5, 3.5);
428 tfs->make<TH1D>(
"h_esh_bestplane_NC",
"Best plane; Best plane;", 4, -0.5, 3.5);
430 "dE/dX; Electron or Positron dE/dX (MeV/cm);",
435 "dE/dX; Electron or Positron dE/dX (MeV/cm);",
440 tfs->make<TH1D>(
"h_dEdX_photon_NueCC",
"dE/dX; photon dE/dX (MeV/cm);", 100, 0.0, 15.0);
442 tfs->make<TH1D>(
"h_dEdX_photon_NC",
"dE/dX; photon dE/dX (MeV/cm);", 100, 0.0, 15.0);
444 tfs->make<TH1D>(
"h_dEdX_proton_NueCC",
"dE/dX; proton dE/dX (MeV/cm);", 100, 0.0, 15.0);
446 tfs->make<TH1D>(
"h_dEdX_proton_NC",
"dE/dX; proton dE/dX (MeV/cm);", 100, 0.0, 15.0);
448 tfs->make<TH1D>(
"h_dEdX_neutron_NueCC",
"dE/dX; neutron dE/dX (MeV/cm);", 100, 0.0, 15.0);
450 tfs->make<TH1D>(
"h_dEdX_neutron_NC",
"dE/dX; neutron dE/dX (MeV/cm);", 100, 0.0, 15.0);
452 "h_dEdX_chargedpion_NueCC",
"dE/dX; charged pion dE/dX (MeV/cm);", 100, 0.0, 15.0);
454 "h_dEdX_chargedpion_NC",
"dE/dX; charged pion dE/dX (MeV/cm);", 100, 0.0, 15.0);
456 "h_dEdX_neutralpion_NueCC",
"dE/dX; neutral pion dE/dX (MeV/cm);", 100, 0.0, 15.0);
458 "h_dEdX_neutralpion_NC",
"dE/dX; neutral pion dE/dX (MeV/cm);", 100, 0.0, 15.0);
460 "h_dEdX_everythingelse_NueCC",
"dE/dX; everythingelse dE/dX (MeV/cm);", 100, 0.0, 15.0);
462 "h_dEdX_everythingelse_NC",
"dE/dX; everythingelse dE/dX (MeV/cm);", 100, 0.0, 15.0);
465 tfs->make<TH1D>(
"h_dEdXasymm_electronorpositron_NueCC",
466 "dE/dX asymmetry; Electron or Positron dE/dX asymmetry;",
471 "h_dEdXasymm_photon_NC",
"dE/dX asymmetry; photon dE/dx asymmetry;", 60, 0.0, 1.2);
474 tfs->make<TH1D>(
"h_mpi0_electronorpositron_NueCC",
475 "m(#gamma#gamma); Electron or Positron dE/dX (MeV/cm);",
480 "h_mpi0_photon_NC",
"m(#gamma#gamma); Electron or Positron dE/dX (MeV/cm);", 100, 0, 1);
503 h_mpi0_photon_NC->Sumw2();
505 h_trklike_em = tfs->make<TH1D>(
"h_trklike_em",
"EM hits; Track-like Score;", 100, 0, 1);
507 tfs->make<TH1D>(
"h_trklike_nonem",
"Non-EM hits; Track-like Score;", 100, 0, 1);
511 tfs->make<TH1D>(
"h_CosThetaShDirwrtTrueparticle_electronorpositron_NueCC",
512 "CosTheta; cos#theta;",
517 tfs->make<TH1D>(
"h_CosThetaShDirwrtTrueparticle_electronorpositron_NC",
518 "CosTheta;cos#theta;",
523 "h_CosThetaShDirwrtTrueparticle_photon_NueCC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
525 "h_CosThetaShDirwrtTrueparticle_photon_NC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
527 "h_CosThetaShDirwrtTrueparticle_proton_NueCC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
529 "h_CosThetaShDirwrtTrueparticle_proton_NC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
531 "h_CosThetaShDirwrtTrueparticle_chargedpion_NueCC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
533 "h_CosThetaShDirwrtTrueparticle_chargedpion_NC",
"CosTheta;cos#theta;", 110, -1.1, 1.1);
537 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_electronorpositron_NueCC",
538 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
543 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_electronorpositron_NueCC",
544 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
549 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_electronorpositron_NueCC",
550 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
556 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_electronorpositron_NC",
557 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
562 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_electronorpositron_NC",
563 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
568 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_electronorpositron_NC",
569 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
575 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_photon_NueCC",
576 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
581 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_photon_NueCC",
582 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
587 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_photon_NueCC",
588 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
594 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_photon_NC",
595 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
600 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_photon_NC",
601 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
606 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_photon_NC",
607 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
613 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleEndXDiff_photon_NueCC",
614 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
619 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleEndYDiff_photon_NueCC",
620 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
625 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleEndZDiff_photon_NueCC",
626 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
632 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleEndXDiff_photon_NC",
633 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
638 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleEndYDiff_photon_NC",
639 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
644 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleEndZDiff_photon_NC",
645 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
651 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_proton_NueCC",
652 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
657 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_proton_NueCC",
658 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
663 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_proton_NueCC",
664 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
670 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_proton_NC",
671 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
676 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_proton_NC",
677 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
682 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_proton_NC",
683 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
689 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_chargedpion_NueCC",
690 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
695 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_chargedpion_NueCC",
696 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
701 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_chargedpion_NueCC",
702 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
708 tfs->make<TH1D>(
"h_ShStartXwrtTrueparticleStartXDiff_chargedpion_NC",
709 "ShVx-TrueParticleVx; ShVx-TrueParticleVx (cm);",
714 tfs->make<TH1D>(
"h_ShStartYwrtTrueparticleStartYDiff_chargedpion_NC",
715 "ShVy-TrueParticleVy; ShVy-TrueParticleVy (cm);",
720 tfs->make<TH1D>(
"h_ShStartZwrtTrueparticleStartZDiff_chargedpion_NC",
721 "ShVz-TrueParticleVz; ShVz-TrueParticleVz (cm);",
727 h_CosThetaShDirwrtTrueparticle_electronorpositron_NueCC->Sumw2();
778 fEventTree =
new TTree(
"Event",
"Event Tree from Sim & Reco");
833 mf::LogInfo(
"NeutrinoShowerEff") <<
"begin run..." << endl;
841 Event =
event.id().event();
844 bool isFiducial =
false;
846 auto const clockData =
863 std::vector<art::Ptr<simb::MCTruth>> MCtruthlist;
868 int MCinteractions = MCtruthlist.size();
869 for (
int i = 0; i < MCinteractions; i++) {
870 MCtruth = MCtruthlist[i];
875 else if (nu.
CCNC() == 1)
883 const TLorentzVector& nu_momentum = nu.
Nu().
Momentum(0);
899 particle = ipar->second;
901 particle->
Mother() == 0) {
902 const TLorentzVector& lepton_momentum = particle->
Momentum(0);
903 const TLorentzVector& lepton_position = particle->
Position(0);
904 const TLorentzVector& lepton_positionEnd = particle->
EndPosition();
905 const TLorentzVector& lepton_momentumEnd = particle->
EndMomentum();
916 if (!isFiducial)
return;
925 theta_e *= (180.0 / 3.14159);
931 h_Ee_den->Fill(MC_lepton_startMomentum[3]);
948 std::vector<art::Ptr<recob::Shower>> showerlist;
952 std::vector<art::Ptr<recob::Hit>> all_hits;
959 double Efrac_contamination = 999.0;
960 double Efrac_contaminationNueCC = 999.0;
962 double Ecomplet_lepton = 0.0;
963 double Ecomplet_NueCC = 0.0;
964 int ParticlePDG_HighestShHits = 0;
965 int shower_bestplane = 0;
966 double Showerparticlededx_inbestplane = 0.0;
967 double dEdxasymm_largestshw = -1.;
969 int showerPDGwithHighestHitsforFillingdEdX =
972 double ShAngle = -9999.0, ShVxTrueParticleVxDiff = -9999.0, ShVyTrueParticleVyDiff = -9999.0,
973 ShVzTrueParticleVzDiff = -9999.0, ShStartVxTrueParticleEndVxDiff = -9999.0,
974 ShStartVyTrueParticleEndVyDiff = -9999.0, ShStartVzTrueParticleEndVzDiff = -9999.0;
994 for (
size_t j = 0; j < shower->
Energy().size(); j++)
996 for (
size_t j = 0; j < shower->
MIPEnergy().size(); j++)
998 for (
size_t j = 0; j < shower->
dEdx().size(); j++)
1001 double dEdxasymm = -1;
1008 for (
int j = 0; j < 3; ++j) {
1010 if (j >=
int(shower->
Energy().size()))
continue;
1012 maxE = shower->
Energy()[j];
1013 dEdx1 = shower->
dEdx()[j];
1016 if (dEdx0 || dEdx1) { dEdxasymm =
std::abs(dEdx0 - dEdx1) / (dEdx0 + dEdx1); }
1040 std::vector<art::Ptr<recob::Hit>> sh_hits = sh_hitsAll.at(i);
1042 if (!sh_hits.size()) {
1046 std::vector<art::Ptr<recob::PFParticle>> pfps;
1050 std::vector<art::Ptr<recob::Cluster>> clusters;
1056 if (fmps.isValid()) {
1057 std::vector<art::Ptr<recob::PFParticle>> pfs = fmps.at(i);
1058 for (
size_t ipf = 0; ipf < pfs.size(); ++ipf) {
1059 if (fmcp.isValid()) {
1060 std::vector<art::Ptr<recob::Cluster>> clus = fmcp.at(pfs[ipf].key());
1061 for (
size_t iclu = 0; iclu < clus.size(); ++iclu) {
1062 if (fmhc.isValid()) {
1063 std::vector<art::Ptr<recob::Hit>>
hits = fmhc.at(clus[iclu].key());
1064 for (
size_t ihit = 0; ihit < hits.size(); ++ihit) {
1065 sh_hits.push_back(hits[ihit]);
1075 double tmpEfrac_contamination =
1078 double tmpEcomplet = 0;
1080 int tmp_nHits = sh_hits.size();
1082 truthMatcher(clockData, all_hits, sh_hits, particle, tmpEfrac_contamination, tmpEcomplet);
1083 if (!particle)
continue;
1086 sh_purity[i] = 1 - tmpEfrac_contamination;
1093 if (tmp_nHits > nHits) {
1095 dEdxasymm_largestshw = dEdxasymm;
1097 Ecomplet_NueCC = tmpEcomplet;
1098 Efrac_contaminationNueCC = tmpEfrac_contamination;
1104 (ShDirMag * particle->
P());
1106 ShVxTrueParticleVxDiff =
sh_start_X[i] - particle->
Vx();
1107 ShVyTrueParticleVyDiff =
sh_start_Y[i] - particle->
Vy();
1108 ShVzTrueParticleVzDiff =
sh_start_Z[i] - particle->
Vz();
1111 if (ShVxTrueParticleVxDiff > 5)
1112 ShVxTrueParticleVxDiff = 4.99;
1113 else if (ShVxTrueParticleVxDiff < -5)
1114 ShVxTrueParticleVxDiff = -5;
1115 if (ShVyTrueParticleVyDiff > 5)
1116 ShVyTrueParticleVyDiff = 4.99;
1117 else if (ShVyTrueParticleVyDiff < -5)
1118 ShVyTrueParticleVyDiff = -5;
1119 if (ShVzTrueParticleVzDiff > 5)
1120 ShVzTrueParticleVzDiff = 4.99;
1121 else if (ShVzTrueParticleVzDiff < -5)
1122 ShVzTrueParticleVzDiff = -5;
1124 ShStartVxTrueParticleEndVxDiff =
sh_start_X[i] - particle->
EndX();
1125 ShStartVyTrueParticleEndVyDiff =
sh_start_Y[i] - particle->
EndY();
1126 ShStartVzTrueParticleEndVzDiff =
sh_start_Z[i] - particle->
EndZ();
1128 if (
std::abs(particle->
PdgCode()) == 11) { ParticlePDG_HighestShHits = 1; }
1129 else if (particle->
PdgCode() == 22) {
1130 ParticlePDG_HighestShHits = 2;
1133 ParticlePDG_HighestShHits = 3;
1139 if (shower_bestplane < 0 || shower_bestplane >=
int(shower->
dEdx().size())) {
1141 for (
size_t i = 0; i < shower->
dEdx().size(); ++i) {
1142 if (shower->
dEdx()[i]) {
1143 shower_bestplane = i;
1148 if (shower_bestplane < 0 || shower_bestplane >=
int(shower->
dEdx().size())) {
1150 shower_bestplane = 0;
1153 if (shower_bestplane >= 0 and shower_bestplane <
int(shower->
dEdx().size()))
1154 Showerparticlededx_inbestplane = shower->
dEdx()[shower_bestplane];
1157 showerPDGwithHighestHitsforFillingdEdX = 1;
1159 else if (particle->
PdgCode() == 22) {
1160 showerPDGwithHighestHitsforFillingdEdX = 2;
1162 else if (particle->
PdgCode() == 2212) {
1163 showerPDGwithHighestHitsforFillingdEdX = 3;
1165 else if (particle->
PdgCode() == 2112) {
1166 showerPDGwithHighestHitsforFillingdEdX = 4;
1169 showerPDGwithHighestHitsforFillingdEdX = 5;
1171 else if (particle->
PdgCode() == 111) {
1172 showerPDGwithHighestHitsforFillingdEdX = 6;
1175 showerPDGwithHighestHitsforFillingdEdX = 7;
1185 if (tmpEcomplet > Ecomplet_lepton) {
1187 Ecomplet_lepton = tmpEcomplet;
1189 Efrac_contamination = tmpEfrac_contamination;
1190 MClepton_reco = particle;
1196 if (p1.Mag() && p2.Mag()) {
sh_mpi0 = sqrt(pow(p1.Mag() + p2.Mag(), 2) - (p1 + p2).Mag2()); }
1200 if (MClepton_reco && MClepton) {
1207 if (Efrac_contamination < fMaxEfrac && Ecomplet_lepton >
fMinCompleteness) {
1211 h_Ee_num->Fill(MC_lepton_startMomentum[3]);
1214 if (Showerparticlededx_inbestplane > 1 && Showerparticlededx_inbestplane < 3) {
1226 if (ParticlePDG_HighestShHits > 0) {
1231 if (showerPDGwithHighestHitsforFillingdEdX == 1)
1239 ShVxTrueParticleVxDiff);
1241 ShVyTrueParticleVyDiff);
1243 ShVzTrueParticleVzDiff);
1249 else if (showerPDGwithHighestHitsforFillingdEdX == 2)
1261 else if (showerPDGwithHighestHitsforFillingdEdX == 3)
1270 else if (showerPDGwithHighestHitsforFillingdEdX == 4)
1274 else if (showerPDGwithHighestHitsforFillingdEdX == 5)
1282 else if (showerPDGwithHighestHitsforFillingdEdX == 6)
1286 else if (showerPDGwithHighestHitsforFillingdEdX == 7)
1292 else if (!
MC_isCC && isFiducial) {
1295 if (ParticlePDG_HighestShHits > 0) {
1300 if (showerPDGwithHighestHitsforFillingdEdX == 1)
1309 else if (showerPDGwithHighestHitsforFillingdEdX == 2)
1326 else if (showerPDGwithHighestHitsforFillingdEdX == 3)
1335 else if (showerPDGwithHighestHitsforFillingdEdX == 4)
1339 else if (showerPDGwithHighestHitsforFillingdEdX == 5)
1347 else if (showerPDGwithHighestHitsforFillingdEdX == 6)
1351 else if (showerPDGwithHighestHitsforFillingdEdX == 7)
1358 checkCNNtrkshw<4>(clockData, event, all_hits);
1376 std::map<int, double> trkID_E;
1377 for (
size_t j = 0; j < shower_hits.size(); ++j) {
1380 for (
size_t k = 0; k < TrackIDs.size(); k++) {
1381 if (trkID_E.find(
std::abs(TrackIDs[k].trackID)) == trkID_E.end())
1382 trkID_E[
std::abs(TrackIDs[k].trackID)] = 0;
1383 trkID_E[
std::abs(TrackIDs[k].trackID)] += TrackIDs[k].energy;
1386 double max_E = -999.0;
1387 double total_E = 0.0;
1389 double partial_E = 0.0;
1391 if (
empty(trkID_E))
return;
1394 total_E += ii->second;
1395 if ((ii->second) > max_E) {
1396 partial_E = ii->second;
1398 TrackID = ii->first;
1403 Efrac = 1 - (partial_E / total_E);
1406 double totenergy = 0;
1407 for (
size_t k = 0; k < all_hits.size(); ++k) {
1410 for (
size_t l = 0; l < TrackIDs.size(); ++l) {
1411 if (
std::abs(TrackIDs[l].trackID) ==
TrackID) { totenergy += TrackIDs[l].energy; }
1414 Ecomplet = partial_E / totenergy;
1423 double x = vertex[0];
1424 double y = vertex[1];
1425 double z = vertex[2];
1441 TGraphAsymmErrors* grEff_Ev =
h_Eff_Ev->CreateGraph();
1442 grEff_Ev->Write(
"grEff_Ev");
1448 TGraphAsymmErrors* grEff_Ev_dEdx =
h_Eff_Ev_dEdx->CreateGraph();
1449 grEff_Ev_dEdx->Write(
"grEff_Ev_dEdx");
1455 TGraphAsymmErrors* grEff_Ee =
h_Eff_Ee->CreateGraph();
1456 grEff_Ee->Write(
"grEff_Ee");
1462 TGraphAsymmErrors* grEff_Ee_dEdx =
h_Eff_Ee_dEdx->CreateGraph();
1463 grEff_Ee_dEdx->Write(
"grEff_Ee_dEdx");
1469 TGraphAsymmErrors* grEff_Pe =
h_Eff_Pe->CreateGraph();
1470 grEff_Pe->Write(
"grEff_Pe");
1475 TGraphAsymmErrors* grEff_theta =
h_Eff_theta->CreateGraph();
1476 grEff_theta->Write(
"grEff_theta");
1496 int trkLikeIdx = hitResults->getIndex(
"track");
1497 int emLikeIdx = hitResults->getIndex(
"em");
1498 if ((trkLikeIdx < 0) || (emLikeIdx < 0)) {
1500 <<
"No em/track labeled columns in MVA data products." << std::endl;
1503 for (
size_t i = 0; i < all_hits.size(); ++i) {
1505 bool isEMparticle =
false;
1508 if (!TrackIDs.size())
continue;
1510 int trkid = INT_MAX;
1512 for (
size_t k = 0; k < TrackIDs.size(); k++) {
1513 if (TrackIDs[k].
energy > maxE) {
1514 maxE = TrackIDs[k].energy;
1515 trkid = TrackIDs[k].trackID;
1518 if (trkid != INT_MAX) {
1525 isEMparticle =
true;
1529 auto vout = hitResults->getOutput(all_hits[i]);
1530 double trk_like = -1, trk_or_em = vout[trkLikeIdx] + vout[emLikeIdx];
1531 if (trk_or_em > 0) {
1532 trk_like = vout[trkLikeIdx] / trk_or_em;
1541 std::cout <<
"Couldn't get hitResults." << std::endl;
1574 for (
int j = 0; j < 3; j++) {
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
Utilities related to art service access.
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
list_type::const_iterator const_iterator
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]
constexpr auto abs(T v)
Returns the absolute value of the argument.
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
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
int InteractionType() const
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
Declaration of cluster object.
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
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
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.
Namespace collecting geometry-related classes utilities.
double sh_MIPenergy[MAX_SHOWERS][3]
TEfficiency * h_Eff_theta
TH1D * h_dEdX_photon_NueCC
TH1D * h_dEdX_everythingelse_NueCC
const TLorentzVector & EndMomentum() const
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
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
TH1D * h_ShStartZwrtTrueparticleEndZDiff_photon_NC
Event finding and building.
TH1D * h_CosThetaShDirwrtTrueparticle_electronorpositron_NueCC
int sh_nHits[MAX_SHOWERS]
double MC_lepton_endXYZT[4]