869 art::Handle<std::vector<simb::MCTruth>> MCtruthHandle;
871 std::vector<art::Ptr<simb::MCTruth>> MCtruthlist;
872 art::fill_ptr_vector(MCtruthlist, MCtruthHandle);
873 art::Ptr<simb::MCTruth> MCtruth;
876 int MCinteractions = MCtruthlist.size();
877 for (
int i = 0; i < MCinteractions; i++) {
878 MCtruth = MCtruthlist[i];
879 if (MCtruth->NeutrinoSet()) {
880 simb::MCNeutrino
nu = MCtruth->GetNeutrino();
883 else if (nu.CCNC() == 1)
885 simb::MCParticle neutrino = nu.Nu();
891 const TLorentzVector& nu_momentum = nu.Nu().Momentum(0);
893 const TLorentzVector&
vertex = neutrino.Position(0);
895 simb::MCParticle lepton = nu.Lepton();
901 simb::MCParticle* MClepton = NULL;
902 art::ServiceHandle<cheat::ParticleInventoryService const> pi_serv;
903 const sim::ParticleList& plist = pi_serv->ParticleList();
904 simb::MCParticle* particle = 0;
906 for (sim::ParticleList::const_iterator ipar = plist.begin(); ipar != plist.end(); ++ipar) {
907 particle = ipar->second;
909 particle->Mother() == 0) {
910 const TLorentzVector& lepton_momentum = particle->Momentum(0);
911 const TLorentzVector& lepton_position = particle->Position(0);
912 const TLorentzVector& lepton_positionEnd = particle->EndPosition();
913 const TLorentzVector& lepton_momentumEnd = particle->EndMomentum();
924 if (!isFiducial)
return;
933 theta_e *= (180.0 / 3.14159);
939 h_Ee_den->Fill(MC_lepton_startMomentum[3]);
950 art::Handle<std::vector<recob::Shower>> showerHandle;
952 mf::LogError(
"NeutrinoShowerEff")
956 std::vector<art::Ptr<recob::Shower>> showerlist;
957 art::fill_ptr_vector(showerlist, showerHandle);
959 art::Handle<std::vector<recob::Hit>> hitHandle;
960 std::vector<art::Ptr<recob::Hit>> all_hits;
961 if (event.getByLabel(
fHitModuleLabel, hitHandle)) { art::fill_ptr_vector(all_hits, hitHandle); }
967 double Efrac_contamination = 999.0;
968 double Efrac_contaminationNueCC = 999.0;
970 double Ecomplet_lepton = 0.0;
971 double Ecomplet_NueCC = 0.0;
972 int ParticlePDG_HighestShHits = 0;
973 int shower_bestplane = 0;
974 double Showerparticlededx_inbestplane = 0.0;
975 double dEdxasymm_largestshw = -1.;
977 int showerPDGwithHighestHitsforFillingdEdX =
980 double ShAngle = -9999.0, ShVxTrueParticleVxDiff = -9999.0, ShVyTrueParticleVyDiff = -9999.0,
981 ShVzTrueParticleVzDiff = -9999.0, ShStartVxTrueParticleEndVxDiff = -9999.0,
982 ShStartVyTrueParticleEndVyDiff = -9999.0, ShStartVzTrueParticleEndVzDiff = -9999.0;
984 const simb::MCParticle* MClepton_reco = NULL;
993 art::Ptr<recob::Shower>
shower = showerlist[i];
1002 for (
size_t j = 0; j < shower->Energy().size(); j++)
1004 for (
size_t j = 0; j < shower->MIPEnergy().size(); j++)
1006 for (
size_t j = 0; j < shower->dEdx().size(); j++)
1007 sh_dEdx[i][j] = shower->dEdx()[j];
1009 double dEdxasymm = -1;
1011 if (shower->best_plane() >= 0 && shower->best_plane() < int(shower->dEdx().size())) {
1012 dEdx0 = shower->dEdx()[shower->best_plane()];
1016 for (
int j = 0; j < 3; ++j) {
1017 if (j == shower->best_plane())
continue;
1018 if (j >=
int(shower->Energy().size()))
continue;
1019 if (shower->Energy()[j] > maxE) {
1020 maxE = shower->Energy()[j];
1021 dEdx1 = shower->dEdx()[j];
1024 if (dEdx0 || dEdx1) { dEdxasymm =
std::abs(dEdx0 - dEdx1) / (dEdx0 + dEdx1); }
1027 if (shower->best_plane() >= 0 && shower->best_plane() < int(shower->Energy().size())) {
1028 if (shower->Energy()[shower->best_plane()] > E1st) {
1033 E1st = shower->Energy()[shower->best_plane()];
1034 p1[0] = E1st * shower->Direction().X();
1035 p1[1] = E1st * shower->Direction().Y();
1036 p1[2] = E1st * shower->Direction().Z();
1039 if (shower->Energy()[shower->best_plane()] > E2nd) {
1040 E2nd = shower->Energy()[shower->best_plane()];
1041 p2[0] = E2nd * shower->Direction().X();
1042 p2[1] = E2nd * shower->Direction().Y();
1043 p2[2] = E2nd * shower->Direction().Z();
1048 std::vector<art::Ptr<recob::Hit>> sh_hits = sh_hitsAll.at(i);
1050 if (!sh_hits.size()) {
1053 art::Handle<std::vector<recob::PFParticle>> pfpHandle;
1054 std::vector<art::Ptr<recob::PFParticle>> pfps;
1055 if (event.getByLabel(
fShowerModuleLabel, pfpHandle)) art::fill_ptr_vector(pfps, pfpHandle);
1057 art::Handle<std::vector<recob::Cluster>> clusterHandle;
1058 std::vector<art::Ptr<recob::Cluster>> clusters;
1060 art::fill_ptr_vector(clusters, clusterHandle);
1064 if (fmps.isValid()) {
1065 std::vector<art::Ptr<recob::PFParticle>> pfs = fmps.at(i);
1066 for (
size_t ipf = 0; ipf < pfs.size(); ++ipf) {
1067 if (fmcp.isValid()) {
1068 std::vector<art::Ptr<recob::Cluster>> clus = fmcp.at(pfs[ipf].key());
1069 for (
size_t iclu = 0; iclu < clus.size(); ++iclu) {
1070 if (fmhc.isValid()) {
1071 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(clus[iclu].key());
1072 for (
size_t ihit = 0; ihit < hits.size(); ++ihit) {
1073 sh_hits.push_back(hits[ihit]);
1082 const simb::MCParticle* particle;
1083 double tmpEfrac_contamination =
1086 double tmpEcomplet = 0;
1088 int tmp_nHits = sh_hits.size();
1090 truthMatcher(clockData, all_hits, sh_hits, particle, tmpEfrac_contamination, tmpEcomplet);
1091 if (!particle)
continue;
1094 sh_purity[i] = 1 - tmpEfrac_contamination;
1098 sh_pdg[i] = particle->PdgCode();
1101 if (tmp_nHits > nHits) {
1103 dEdxasymm_largestshw = dEdxasymm;
1105 Ecomplet_NueCC = tmpEcomplet;
1106 Efrac_contaminationNueCC = tmpEfrac_contamination;
1112 (ShDirMag * particle->P());
1114 ShVxTrueParticleVxDiff =
sh_start_X[i] - particle->Vx();
1115 ShVyTrueParticleVyDiff =
sh_start_Y[i] - particle->Vy();
1116 ShVzTrueParticleVzDiff =
sh_start_Z[i] - particle->Vz();
1119 if (ShVxTrueParticleVxDiff > 5)
1120 ShVxTrueParticleVxDiff = 4.99;
1121 else if (ShVxTrueParticleVxDiff < -5)
1122 ShVxTrueParticleVxDiff = -5;
1123 if (ShVyTrueParticleVyDiff > 5)
1124 ShVyTrueParticleVyDiff = 4.99;
1125 else if (ShVyTrueParticleVyDiff < -5)
1126 ShVyTrueParticleVyDiff = -5;
1127 if (ShVzTrueParticleVzDiff > 5)
1128 ShVzTrueParticleVzDiff = 4.99;
1129 else if (ShVzTrueParticleVzDiff < -5)
1130 ShVzTrueParticleVzDiff = -5;
1132 ShStartVxTrueParticleEndVxDiff =
sh_start_X[i] - particle->EndX();
1133 ShStartVyTrueParticleEndVyDiff =
sh_start_Y[i] - particle->EndY();
1134 ShStartVzTrueParticleEndVzDiff =
sh_start_Z[i] - particle->EndZ();
1136 if (
std::abs(particle->PdgCode()) == 11) { ParticlePDG_HighestShHits = 1; }
1137 else if (particle->PdgCode() == 22) {
1138 ParticlePDG_HighestShHits = 2;
1141 ParticlePDG_HighestShHits = 3;
1146 shower_bestplane = shower->best_plane();
1147 if (shower_bestplane < 0 || shower_bestplane >=
int(shower->dEdx().size())) {
1149 for (
size_t i = 0; i < shower->dEdx().size(); ++i) {
1150 if (shower->dEdx()[i]) {
1151 shower_bestplane = i;
1156 if (shower_bestplane < 0 || shower_bestplane >=
int(shower->dEdx().size())) {
1158 shower_bestplane = 0;
1161 if (shower_bestplane >= 0
and shower_bestplane <
int(shower->dEdx().size()))
1162 Showerparticlededx_inbestplane = shower->dEdx()[shower_bestplane];
1164 if (
std::abs(particle->PdgCode()) == 11) {
1165 showerPDGwithHighestHitsforFillingdEdX = 1;
1167 else if (particle->PdgCode() == 22) {
1168 showerPDGwithHighestHitsforFillingdEdX = 2;
1170 else if (particle->PdgCode() == 2212) {
1171 showerPDGwithHighestHitsforFillingdEdX = 3;
1173 else if (particle->PdgCode() == 2112) {
1174 showerPDGwithHighestHitsforFillingdEdX = 4;
1176 else if (
std::abs(particle->PdgCode()) == 211) {
1177 showerPDGwithHighestHitsforFillingdEdX = 5;
1179 else if (particle->PdgCode() == 111) {
1180 showerPDGwithHighestHitsforFillingdEdX = 6;
1183 showerPDGwithHighestHitsforFillingdEdX = 7;
1193 if (tmpEcomplet > Ecomplet_lepton) {
1195 Ecomplet_lepton = tmpEcomplet;
1197 Efrac_contamination = tmpEfrac_contamination;
1198 MClepton_reco = particle;
1204 if (p1.Mag() && p2.Mag()) {
sh_mpi0 = sqrt(pow(p1.Mag() + p2.Mag(), 2) - (p1 + p2).Mag2()); }
1208 if (MClepton_reco && MClepton) {
1215 if (Efrac_contamination < fMaxEfrac && Ecomplet_lepton >
fMinCompleteness) {
1219 h_Ee_num->Fill(MC_lepton_startMomentum[3]);
1222 if (Showerparticlededx_inbestplane > 1 && Showerparticlededx_inbestplane < 3) {
1234 if (ParticlePDG_HighestShHits > 0) {
1239 if (showerPDGwithHighestHitsforFillingdEdX == 1)
1247 ShVxTrueParticleVxDiff);
1249 ShVyTrueParticleVyDiff);
1251 ShVzTrueParticleVzDiff);
1257 else if (showerPDGwithHighestHitsforFillingdEdX == 2)
1269 else if (showerPDGwithHighestHitsforFillingdEdX == 3)
1278 else if (showerPDGwithHighestHitsforFillingdEdX == 4)
1282 else if (showerPDGwithHighestHitsforFillingdEdX == 5)
1290 else if (showerPDGwithHighestHitsforFillingdEdX == 6)
1294 else if (showerPDGwithHighestHitsforFillingdEdX == 7)
1300 else if (!
MC_isCC && isFiducial) {
1303 if (ParticlePDG_HighestShHits > 0) {
1308 if (showerPDGwithHighestHitsforFillingdEdX == 1)
1317 else if (showerPDGwithHighestHitsforFillingdEdX == 2)
1334 else if (showerPDGwithHighestHitsforFillingdEdX == 3)
1343 else if (showerPDGwithHighestHitsforFillingdEdX == 4)
1347 else if (showerPDGwithHighestHitsforFillingdEdX == 5)
1355 else if (showerPDGwithHighestHitsforFillingdEdX == 6)
1359 else if (showerPDGwithHighestHitsforFillingdEdX == 7)
1366 checkCNNtrkshw<4>(clockData, event, all_hits);
double sh_length[MAX_SHOWERS]
TH1D * h_ShStartXwrtTrueparticleStartXDiff_electronorpositron_NC
TH1D * h_CosThetaShDirwrtTrueparticle_photon_NC
TH1D * h_ShStartZwrtTrueparticleStartZDiff_proton_NueCC
TH1D * h_ShStartXwrtTrueparticleEndXDiff_photon_NC
double sh_energy[MAX_SHOWERS][3]
TH1D * h_dEdX_electronorpositron_NueCC
TH1D * h_ShStartXwrtTrueparticleStartXDiff_chargedpion_NC
TH1D * h_ShStartYwrtTrueparticleEndYDiff_photon_NC
double sh_direction_X[MAX_SHOWERS]
TH1D * h_dEdX_everythingelse_NC
TH1D * h_dEdX_neutron_NueCC
TH1D * h_CosThetaShDirwrtTrueparticle_proton_NC
TH1D * h_ShStartYwrtTrueparticleStartYDiff_electronorpositron_NC
TH1D * h_HighestHitsProducedParticlePDG_NueCC
double sh_dEdx[MAX_SHOWERS][3]
art::InputTag fMCTruthModuleLabel
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
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
TH1D * h_ShStartZwrtTrueparticleStartZDiff_chargedpion_NueCC
TH1D * h_dEdX_chargedpion_NueCC
TH1D * h_ShStartYwrtTrueparticleEndYDiff_photon_NueCC
TH1D * h_ShStartZwrtTrueparticleStartZDiff_photon_NC
double sh_purity[MAX_SHOWERS]
TH1D * h_ShStartZwrtTrueparticleStartZDiff_proton_NC
double sh_completeness[MAX_SHOWERS]
art::InputTag fShowerModuleLabel
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]
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
TH1D * h_esh_bestplane_NC
double sh_start_Y[MAX_SHOWERS]
bool insideFV(double vertex[4])
double sh_direction_Y[MAX_SHOWERS]
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
double sh_start_Z[MAX_SHOWERS]
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 MC_lepton_startMomentum[4]
TH1D * h_ShStartXwrtTrueparticleEndXDiff_photon_NueCC
TH1D * h_HighestHitsProducedParticlePDG_bkg
TH1D * h_ShStartYwrtTrueparticleStartYDiff_chargedpion_NueCC
TH1D * h_dEdX_electronorpositron_NC
TH1D * h_ShStartXwrtTrueparticleStartXDiff_proton_NueCC
double MC_lepton_startXYZT[4]
TH1D * h_ShStartYwrtTrueparticleStartYDiff_proton_NC
TH1D * h_dEdXasymm_electronorpositron_NueCC
TH1D * h_esh_bestplane_NueCC
TH1D * h_dEdX_chargedpion_NC
TH1D * h_dEdX_proton_NueCC
TH1D * h_ShStartXwrtTrueparticleStartXDiff_photon_NC
TH1D * h_ShStartYwrtTrueparticleStartYDiff_photon_NC
TH1D * h_Efrac_shContamination
double sh_Efrac_contamination[MAX_SHOWERS]
TH1D * h_ShStartZwrtTrueparticleStartZDiff_electronorpositron_NC
double sh_MIPenergy[MAX_SHOWERS][3]
TH1D * h_dEdX_photon_NueCC
TH1D * h_dEdX_everythingelse_NueCC
physics associatedGroupsWithLeft p1
BEGIN_PROLOG could also be cout
TH1D * h_ShStartZwrtTrueparticleEndZDiff_photon_NC
TH1D * h_CosThetaShDirwrtTrueparticle_electronorpositron_NueCC
int sh_nHits[MAX_SHOWERS]
double MC_lepton_endXYZT[4]