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);
double sh_length[MAX_SHOWERS]
TH1D * h_ShStartXwrtTrueparticleStartXDiff_electronorpositron_NC
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
TH1D * h_dEdX_neutron_NueCC
TH1D * h_CosThetaShDirwrtTrueparticle_proton_NC
const simb::MCParticle & Nu() const
TH1D * h_ShStartYwrtTrueparticleStartYDiff_electronorpositron_NC
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
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
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
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
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]
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
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
TH1D * h_ShStartXwrtTrueparticleStartXDiff_proton_NueCC
double MC_lepton_startXYZT[4]
TH1D * h_ShStartYwrtTrueparticleStartYDiff_proton_NC
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
TH1D * h_ShStartYwrtTrueparticleStartYDiff_photon_NC
TH1D * h_Efrac_shContamination
double sh_Efrac_contamination[MAX_SHOWERS]
TH1D * h_ShStartZwrtTrueparticleStartZDiff_electronorpositron_NC
Event generator information.
double sh_MIPenergy[MAX_SHOWERS][3]
TH1D * h_dEdX_photon_NueCC
TH1D * h_dEdX_everythingelse_NueCC
const TLorentzVector & EndMomentum() const
double Vy(const int i=0) const
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]