290 bool isMC = !
evt.isRealData();
299 if (!highestChargeShower.isAvailable() || highestChargeShower.isNull()) {
300 mf::LogWarning(
"RegCNNAna")<<
" Cannot access the electron shower which is needed for this energy reconstruction method.\n" 308 const double hadronicObservedCharge(eventObservedCharge-electronObservedCharge);
318 if (!longestTrack.isAvailable() || longestTrack.isNull()) {
319 mf::LogWarning(
"RegCNNAna")<<
" Cannot access the muon track which is needed for this energy reconstruction method.\n" 326 const double hadronicObservedCharge(eventObservedCharge-leptonObservedCharge);
335 std::vector<art::Ptr<simb::MCTruth> > mclist;
338 if (mctruthListHandle)
343 std::vector<art::Ptr<recob::Hit> > hits;
351 std::vector<art::Ptr<recob::Track> > trackDir;
357 if (trackHandleDir.isValid()) {
359 for (
int itrack= 0; itrack<
n_track_pad; ++itrack) {
366 if (fmtrkDir.isValid()) {
367 std::vector<art::Ptr<recob::Hit> > vhit = fmtrkDir.at(itrack);
368 std::unordered_map<const simb::MCParticle*, double> mcEMap;
369 for (
size_t ihit= 0; ihit< vhit.size(); ++ihit) {
371 for (
size_t e= 0;
e< trackIDs.size(); ++
e) {
375 std::vector<std::pair<const simb::MCParticle*, double> > trkTrue =
get_sortedMCParticle(mcEMap);
376 if (trkTrue.size()> 0) {
378 all_track_true_pdg_mom[itrack] = trkTrue[0].first->Mother()==0 ? -1 : trueParticles[trkTrue[0].first->Mother()]->PdgCode();
379 TVector3 v3_true(trkTrue[0].first->Momentum().Vect());
389 std::vector<art::Ptr<recob::Shower> > showersDir;
395 if (showerHandleDir.isValid()) {
397 for (
int ishower= 0; ishower<
n_showers; ++ishower) {
404 if (fmshDir.isValid()) {
405 std::vector<art::Ptr<recob::Hit> > vhit = fmshDir.at(ishower);
406 std::unordered_map<const simb::MCParticle*, double> mcEMap;
407 for (
size_t ihit= 0; ihit< vhit.size(); ++ihit) {
409 for (
size_t e= 0;
e< trackIDs.size(); ++
e) {
413 std::vector<std::pair<const simb::MCParticle*, double> > shwTrue =
get_sortedMCParticle(mcEMap);
414 if (shwTrue.size()> 0) {
416 all_shower_true_pdg_mom[ishower] = shwTrue[0].first->Mother()==0 ? -1 : trueParticles[shwTrue[0].first->Mother()]->PdgCode();
417 TVector3 v3_true(shwTrue[0].first->Momentum().Vect());
434 auto cnnresultListHandle =
evt.getHandle<std::vector<cnn::RegCNNResult>>(itag1);
438 auto RegCnnProngResultListHandle =
evt.getHandle<std::vector<cnn::RegCNNResult>>(itag2);
442 auto RegCnnDirResultListHandle =
evt.getHandle<std::vector<cnn::RegCNNResult> >(itag3);
450 if (mclist.size()>0) {
452 for(
size_t iList = 0; (iList < mclist.size()) && (neutrino_i <
kMax) ; ++iList) {
453 if (mclist[iList]->NeutrinoSet()) {
483 if (pdg > 2000000000) {
491 case 111 : ++
nPizero[neutrino_i];
break;
492 case 211 : ++
nPion[neutrino_i];
break;
493 case 2112 : ++
nNeutron[neutrino_i];
break;
494 case 2212 : ++
nProton[neutrino_i];
break;
513 bool fid_flag =
false;
514 for(
size_t iHit = 0; iHit < hits.size(); ++iHit)
523 if (peakT > 4482.) fid_flag =
true;
525 if (tpc < 4 && wire < 5) fid_flag =
true;
526 if (tpc > 19 && wire > 474) fid_flag =
true;
530 if (!fid_flag)
InDet = 1;
543 if (!engrecoHandle.failedToGet())
545 ErecoNu = engrecoHandle->fNuLorentzVector.E();
546 RecoLepEnNu = engrecoHandle->fLepLorentzVector.E();
547 RecoHadEnNu = engrecoHandle->fHadLorentzVector.E();
554 if (!cnnresultListHandle.failedToGet())
556 if (!cnnresultListHandle->empty())
558 const std::vector<float>& v = (*cnnresultListHandle)[0].fOutput;
560 for (
unsigned int ii = 0; ii < 3; ii++){
566 if (!RegCnnProngResultListHandle.failedToGet())
568 if (!RegCnnProngResultListHandle->empty())
570 const std::vector<float>& v = (*RegCnnProngResultListHandle)[0].fOutput;
575 if (!RegCnnDirResultListHandle.failedToGet()) {
576 if (!RegCnnDirResultListHandle->empty()) {
577 const std::vector<float>& v = (*RegCnnDirResultListHandle)[0].fOutput;
578 for (
unsigned int i= 0; i< v.size(); ++i) {
585 for (
int itrack= 0; itrack<
n_track_pad; ++itrack) {
596 double cosTheta = dot/norm_regcnn_dir/norm_true_dir;
603 for (
int ishower= 0; ishower<
n_showers; ++ishower) {
614 double cosTheta = dot/norm_regcnn_dir/norm_true_dir;
double E(const int i=0) const
double all_shower_true_px[kMax]
float regcnn_nue_dir_diff
double GetMomentumMultiScatterChi2(art::Ptr< recob::Track > const &trk)
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
const simb::MCParticle * TrackIdToParticle_P(int id) const
geo::WireID WireID() const
const simb::MCParticle & Nu() const
art::Ptr< recob::Shower > GetHighestChargeShower(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const art::Event &event)
std::vector< std::pair< const simb::MCParticle *, double > > get_sortedMCParticle(std::unordered_map< const simb::MCParticle *, double > mcEMap)
double all_shower_true_pz[kMax]
Vector_t VertexDirection() const
static std::vector< art::Ptr< recob::Hit > > GetHits(const art::Event &evt, const std::string &label)
Get the hits from the event.
std::vector< const simb::MCParticle * > MCTruthToParticles_Ps(art::Ptr< simb::MCTruth > const &mct) const
int all_track_true_pdg[kMax]
WireID_t Wire
Index of the wire within its plane.
std::string fRegCNNModuleLabel
std::string fTrackToHitLabel
static std::vector< art::Ptr< recob::Hit > > GetHits(const art::Ptr< recob::Track > &pTrack, const art::Event &evt, const std::string &label)
Get the hits associated with the track.
double fUncorrectedMuMomMCS
double nuvtxy_truth[kMax]
double all_track_true_py[kMax]
const simb::MCParticle & Lepton() const
float regcnn_prong_energy
double lepEng_truth[kMax]
double nuvtxx_truth[kMax]
int all_track_true_pdg_mom[kMax]
double all_track_pz[kMax]
double all_shower_pz[kMax]
int all_shower_true_pdg[kMax]
double fUncorrectedHadEnFromShw
std::string fRegCNNProngModuleLabel
std::string fRegCNNDirModuleLabel
const TVector3 & Direction() const
static double LifetimeCorrectedTotalHitCharge(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Hit > > &hits)
get the total hit charge, corrected for lifetime
PlaneID_t Plane
Index of the plane within its TPC.
Detector simulation of raw signals on wires.
const sim::ParticleList & ParticleList() const
std::string fMCGenModuleLabel
double Vx(const int i=0) const
art::ServiceHandle< cheat::BackTrackerService > backtracker
std::string fShowerToHitLabel
float PeakTime() const
Time of the signal peak, in tick units.
double all_track_py[kMax]
double fUncorrectedElectronEnergy
static std::vector< art::Ptr< recob::Hit > > GetHits(const art::Ptr< recob::Shower > &pShower, const art::Event &evt, const std::string &label)
Get the hits associated with the shower.
double all_track_true_pz[kMax]
double all_shower_px[kMax]
const TLorentzVector & Momentum(const int i=0) const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
art::Ptr< recob::Track > GetLongestTrack(const art::Event &event)
double Vz(const int i=0) const
std::string fRegCNNDirResultLabel
double CalculateEnergyFromCharge(const double charge)
Converts deposited charge into energy by converting to number of electrons and correcting for average...
int all_shower_true_pdg_mom[kMax]
std::string fRegCNNResultLabel
double all_shower_py[kMax]
std::string fHitsModuleLabel
std::string fTrackLabelDir
std::string fEnergyRecoNuLabel
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
TPCID_t TPC
Index of the TPC within its cryostat.
double nuvtxz_truth[kMax]
Event generator information.
double all_track_px[kMax]
std::string fShowerLabelDir
double all_track_true_px[kMax]
art::ServiceHandle< cheat::ParticleInventoryService > particleinventory
double all_shower_true_py[kMax]
double Vy(const int i=0) const
std::string fRegCNNProngResultLabel
QTextStream & endl(QTextStream &s)
static std::vector< art::Ptr< recob::Hit > > GetHitsOnPlane(const std::vector< art::Ptr< recob::Hit >> &hits, const geo::PlaneID::PlaneID_t planeID)
Get all hits on a specific plane.