516 evt,
m_particleLabel, spacePointVector, spacePointsToHits, hitsToSpacePoints);
562 std::cout <<
" RecoNeutrinos: " << recoNeutrinoVector.size() <<
std::endl;
563 std::cout <<
" RecoParticles: " << recoParticleVector.size() <<
std::endl;
589 if (trueHitsToParticles.empty()) {
591 throw cet::exception(
"LArPandora") <<
" PFParticleMonitoring::analyze - no sim channels " 592 "found, backtracker module must be set in FHiCL " 609 std::cout <<
" TrueParticles: " << particlesToTruth.size() <<
std::endl;
610 std::cout <<
" TrueEvents: " << truthToParticles.size() <<
std::endl;
611 std::cout <<
" MatchedParticles: " << trueParticlesToHits.size() <<
std::endl;
614 if (trueParticlesToHits.empty()) {
634 iterEnd = recoParticleVector.end();
655 recoParticleMap, recoParticlesToHits, recoNeutrinosToHits, recoHitsToNeutrinos);
657 truthToParticles, trueParticlesToHits, trueNeutrinosToHits, trueHitsToNeutrinos);
662 recoNeutrinosToHits, trueHitsToNeutrinos, matchedNeutrinos, matchedNeutrinoHits);
665 iterEnd = trueNeutrinosToHits.end();
669 const HitVector& trueHitVector = iter->second;
671 if (trueHitVector.empty())
continue;
679 m_mcPdg = trueParticle.PdgCode();
694 m_mcDirX = trueParticle.Px() / trueParticle.P();
695 m_mcDirY = trueParticle.Py() / trueParticle.P();
696 m_mcDirZ = trueParticle.Pz() / trueParticle.P();
747 hIterEnd1 = trueHitVector.end();
750 if (recoHitsToNeutrinos.find(*hIter1) == recoHitsToNeutrinos.end())
755 if (matchedNeutrinos.end() != pIter1) {
765 std::cout <<
" Warning: Found neutrino with an invalid PDG code " <<
std::endl;
768 if (recoParticlesToHits.end() != pIter2) {
769 const HitVector& recoHitVector = pIter2->second;
772 hIterEnd2 = recoHitVector.end();
775 if (trueHitsToNeutrinos.find(*hIter2) == trueHitsToNeutrinos.end())
780 if (matchedNeutrinoHits.end() != pIter3) {
781 const HitVector& matchedHitVector = pIter3->second;
794 recoParticlesToVertices.find(recoParticle);
795 if (recoParticlesToVertices.end() != pIter4) {
797 if (!vertexVector.empty()) {
799 std::cout <<
" Warning: Found particle with more than one associated vertex " 803 double xyz[3] = {0.0, 0.0, 0.0};
804 recoVertex->
XYZ(xyz);
824 std::cout <<
" MCNeutrino [" <<
m_index <<
"]" 840 recoParticlesToHits, trueHitsToParticles, matchedParticles, matchedParticleHits);
844 iterEnd = trueParticlesToHits.end();
848 const HitVector& trueHitVector = iter->second;
850 if (trueHitVector.empty())
continue;
943 const double Ptot(trueParticle->
P(startT));
957 if (particlesToTruth.end() == nuIter)
958 throw cet::exception(
"LArPandora") <<
" PFParticleMonitoring::analyze --- Found a true " 959 "particle without any ancestry information ";
966 m_mcIsCC = ((
simb::kCC == neutrino.CCNC()) ? 1 : 0);
975 m_mcParentPdg = ((parentParticle != trueParticle) ? parentParticle->PdgCode() : 0);
984 bool foundSpacePoints(
false);
987 hIterEnd1 = trueHitVector.end();
993 if (hitsToSpacePoints.end() == hIter2)
continue;
996 const double X(spacepoint->
XYZ()[0]);
998 if (!foundSpacePoints) {
1001 foundSpacePoints =
true;
1011 hIterEnd1 = trueHitVector.end();
1012 hIter1 != hIterEnd1;
1014 if (recoHitsToParticles.find(*hIter1) == recoHitsToParticles.end())
1025 if (matchedParticles.end() != pIter1) {
1040 if (recoParticlesToHits.end() == pIter2)
1042 <<
" PFParticleMonitoring::analyze --- Found a reco particle without any hits ";
1044 const HitVector& recoHitVector = pIter2->second;
1047 hIterEnd2 = recoHitVector.end();
1048 hIter2 != hIterEnd2;
1050 if (trueHitsToParticles.find(*hIter2) == trueHitsToParticles.end())
1055 if (matchedParticleHits.end() == pIter3)
1056 throw cet::exception(
"LArPandora") <<
" PFParticleMonitoring::analyze --- Found a " 1057 "matched true particle without matched hits ";
1059 const HitVector& matchedHitVector = pIter3->second;
1072 if (recoParticlesToVertices.end() != pIter4) {
1074 if (!vertexVector.empty()) {
1076 std::cout <<
" Warning: Found particle with more than one associated vertex " 1080 double xyz[3] = {0.0, 0.0, 0.0};
1081 recoVertex->
XYZ(xyz);
1091 if (recoParticlesToTracks.end() != pIter5) {
1093 if (!trackVector.empty()) {
1095 std::cout <<
" Warning: Found particle with more than one associated track " 1099 const auto& vtxPosition = recoTrack->
Vertex();
1100 const auto& endPosition = recoTrack->
End();
1118 m_pfoIsStitched = (particlesToT0s.end() != particlesToT0s.find(recoParticle));
1129 std::cout <<
" MCParticle [" <<
m_index <<
"]" 1130 <<
" trueNu=" << m_mcNuPdg <<
", truePdg=" <<
m_mcPdg double E(const int i=0) const
static void BuildPFParticleHitMaps(const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps.
void XYZ(double *xyz) const
Legacy method to access vertex position, preserved to avoid breaking code. Please try to use Vertex::...
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCParticle > > HitsToMCParticles
const simb::MCNeutrino & GetNeutrino() const
int CountHitsByType(const int view, const HitVector &hitVector) const
Count the number of reconstructed hits in a given wire plane.
static void BuildPFParticleMap(const PFParticleVector &particleVector, PFParticleMap &particleMap)
Build particle maps for reconstructed particles.
double Py(const int i=0) const
static int GetParentNeutrino(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the parent neutrino PDG code (or zero for cosmics) for a given reconstructed particle...
bool m_useDaughterPFParticles
void GetRecoToTrueMatches(const PFParticlesToHits &recoNeutrinosToHits, const HitsToMCTruth &trueHitsToNeutrinos, MCTruthToPFParticles &matchedNeutrinos, MCTruthToHits &matchedNeutrinoHits) const
Perform matching between true and reconstructed neutrino events.
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
std::string m_backtrackerLabel
std::map< art::Ptr< simb::MCTruth >, HitVector > MCTruthToHits
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
std::string m_geantModuleLabel
static art::Ptr< recob::PFParticle > GetFinalStatePFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the final-state parent particle by navigating up the chain of parent/daughter associations...
double Px(const int i=0) const
Vector_t VertexDirection() const
std::map< art::Ptr< simb::MCParticle >, art::Ptr< recob::PFParticle > > MCParticlesToPFParticles
int PdgCode() const
Return the type of particle as a PDG ID.
bool m_addDaughterMCParticles
std::string Process() const
static art::Ptr< recob::PFParticle > GetParentPFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the top-level parent particle by navigating up the chain of parent/daughter associations...
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
std::map< art::Ptr< recob::PFParticle >, VertexVector > PFParticlesToVertices
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
void BuildTrueNeutrinoHitMaps(const MCTruthToMCParticles &truthToParticles, const MCParticlesToHits &trueParticlesToHits, MCTruthToHits &trueNeutrinosToHits, HitsToMCTruth &trueHitsToNeutrinos) const
Build mapping from true neutrinos to hits.
std::map< int, art::Ptr< simb::MCParticle > > MCParticleMap
bool m_useDaughterMCParticles
std::string m_hitfinderLabel
static void CollectSpacePoints(const art::Event &evt, const std::string &label, SpacePointVector &spacePointVector, SpacePointsToHits &spacePointsToHits)
Collect the reconstructed SpacePoints and associated hits from the ART event record.
double GetLength(const art::Ptr< simb::MCParticle > trueParticle, const int startT, const int endT) const
Find the length of the true particle trajectory through the active region of the detector.
int m_nTrueWithoutRecoHits
True hits which don't belong to any reconstructed particle - "available".
std::map< art::Ptr< recob::PFParticle >, T0Vector > PFParticlesToT0s
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCTruth > > HitsToMCTruth
double Length(size_t p=0) const
Access to various track properties.
static art::Ptr< simb::MCParticle > GetParentMCParticle(const MCParticleMap &particleMap, const art::Ptr< simb::MCParticle > daughterParticle)
Return the top-level parent particle by navigating up the chain of parent/daughter associations...
void BuildRecoNeutrinoHitMaps(const PFParticleMap &recoParticleMap, const PFParticlesToHits &recoParticlesToHits, PFParticlesToHits &recoNeutrinosToHits, HitsToPFParticles &recoHitsToNeutrinos) const
Build mapping from reconstructed neutrinos to hits.
std::map< art::Ptr< simb::MCParticle >, HitVector > MCParticlesToHits
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
std::map< art::Ptr< simb::MCTruth >, art::Ptr< recob::PFParticle > > MCTruthToPFParticles
double P(const int i=0) const
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
Point_t const & Vertex() const
bool m_printDebug
switch for print statements (TODO: use message service!)
static void CollectVertices(const art::Event &evt, const std::string &label, VertexVector &vertexVector, PFParticlesToVertices &particlesToVertices)
Collect the reconstructed PFParticles and associated Vertices from the ART event record.
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::SpacePoint > > HitsToSpacePoints
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
std::vector< art::Ptr< recob::Track > > TrackVector
static int max(int a, int b)
static void CollectTracks(const art::Event &evt, const std::string &label, TrackVector &trackVector, PFParticlesToTracks &particlesToTracks)
Collect the reconstructed PFParticles and associated Tracks from the ART event record.
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
void GetStartAndEndPoints(const art::Ptr< simb::MCParticle > trueParticle, int &startT, int &endT) const
Find the start and end points of the true particle in the active region of detector.
static void CollectHits(const art::Event &evt, const std::string &label, HitVector &hitVector)
Collect the reconstructed Hits from the ART event record.
Detector simulation of raw signals on wires.
static void SelectNeutrinoPFParticles(const PFParticleVector &inputParticles, PFParticleVector &outputParticles)
Select reconstructed neutrino particles from a list of all reconstructed particles.
std::string m_particleLabel
double Vx(const int i=0) const
std::vector< art::Ptr< recob::Hit > > HitVector
double m_pfoStraightLength
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
double m_mcStraightLength
double Pz(const int i=0) const
double Vz(const int i=0) const
const Double32_t * XYZ() const
std::vector< art::Ptr< recob::Vertex > > VertexVector
EventNumber_t event() const
Point_t const & End() const
Planes which measure W (third view for Bo, MicroBooNE, etc).
std::vector< art::Ptr< anab::T0 > > T0Vector
static void CollectT0s(const art::Event &evt, const std::string &label, T0Vector &t0Vector, PFParticlesToT0s &particlesToT0s)
Collect a vector of T0s from the ART event record.
bool m_addDaughterPFParticles
static void BuildMCParticleHitMaps(const art::Event &evt, const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
Event generator information.
static void CollectMCParticles(const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
Collect a vector of MCParticle objects from the ART event record.
static art::Ptr< simb::MCParticle > GetFinalStateMCParticle(const MCParticleMap &particleMap, const art::Ptr< simb::MCParticle > daughterParticle)
Return the final-state parent particle by navigating up the chain of parent/daughter associations...
int m_nRecoWithoutTrueHits
Reconstructed hits which don't belong to any true particle - "missing".
double Vy(const int i=0) const
static bool IsFinalState(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Determine whether a particle has been reconstructed as a final-state particle.
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > SpacePointsToHits
cet::coded_exception< error, detail::translate > exception
bool m_disableRealDataCheck
Whether to check if the input file contains real data before accessing MC information.
QTextStream & endl(QTextStream &s)
static void BuildMCParticleMap(const MCParticleVector &particleVector, MCParticleMap &particleMap)
Build particle maps for true particles.