315 mf::LogDebug(
"LArPandora") <<
" *** PFParticleMonitoring::beginJob() *** " << std::endl;
400 std::cout <<
" *** PFParticleMonitoring::analyze(...) *** " << std::endl;
479 std::cout <<
" Run: " <<
m_run << std::endl;
480 std::cout <<
" Event: " <<
m_event << std::endl;
489 std::cout <<
" Hits: " << hitVector.size() << std::endl;
499 std::cout <<
" SpacePoints: " << spacePointVector.size() << std::endl;
508 std::cout <<
" Tracks: " << recoTrackVector.size() << std::endl;
523 std::cout <<
" Vertices: " << recoVertexVector.size() << std::endl;
539 std::cout <<
" RecoNeutrinos: " << recoNeutrinoVector.size() << std::endl;
540 std::cout <<
" RecoParticles: " << recoParticleVector.size() << std::endl;
559 if (trueHitsToParticles.empty())
562 throw cet::exception(
"LArPandora") <<
" PFParticleMonitoring::analyze - no sim channels found, backtracker module must be set in FHiCL " << std::endl;
565 trueParticlesToHits, trueHitsToParticles,
572 std::cout <<
" TrueParticles: " << particlesToTruth.size() << std::endl;
573 std::cout <<
" TrueEvents: " << truthToParticles.size() << std::endl;
574 std::cout <<
" MatchedParticles: " << trueParticlesToHits.size() << std::endl;
577 if (trueParticlesToHits.empty())
626 this->
GetRecoToTrueMatches(recoNeutrinosToHits, trueHitsToNeutrinos, matchedNeutrinos, matchedNeutrinoHits);
631 const HitVector &trueHitVector = iter->second;
633 if (trueHitVector.empty())
643 m_mcPdg = trueParticle.PdgCode();
658 m_mcDirX = trueParticle.Px() / trueParticle.P();
659 m_mcDirY = trueParticle.Py() / trueParticle.P();
660 m_mcDirZ = trueParticle.Pz() / trueParticle.P();
710 for (
HitVector::const_iterator hIter1 = trueHitVector.begin(), hIterEnd1 = trueHitVector.end(); hIter1 != hIterEnd1; ++hIter1)
712 if (recoHitsToNeutrinos.find(*hIter1) == recoHitsToNeutrinos.end())
717 if (matchedNeutrinos.end() != pIter1)
728 std::cout <<
" Warning: Found neutrino with an invalid PDG code " << std::endl;
731 if (recoParticlesToHits.end() != pIter2)
733 const HitVector &recoHitVector = pIter2->second;
735 for (
HitVector::const_iterator hIter2 = recoHitVector.begin(), hIterEnd2 = recoHitVector.end(); hIter2 != hIterEnd2; ++hIter2)
737 if (trueHitsToNeutrinos.find(*hIter2) == trueHitsToNeutrinos.end())
742 if (matchedNeutrinoHits.end() != pIter3)
744 const HitVector &matchedHitVector = pIter3->second;
757 if (recoParticlesToVertices.end() != pIter4)
760 if (!vertexVector.empty())
763 std::cout <<
" Warning: Found particle with more than one associated vertex " << std::endl;
766 double xyz[3] = {0.0, 0.0, 0.0} ;
767 recoVertex->
XYZ(xyz);
783 std::cout <<
" MCNeutrino [" <<
m_index <<
"]" 797 this->
GetRecoToTrueMatches(recoParticlesToHits, trueHitsToParticles, matchedParticles, matchedParticleHits);
803 const HitVector &trueHitVector = iter->second;
805 if (trueHitVector.empty())
900 const double Ptot(trueParticle->
P(startT));
915 if (particlesToTruth.end() == nuIter)
916 throw cet::exception(
"LArPandora") <<
" PFParticleMonitoring::analyze --- Found a true particle without any ancestry information ";
941 bool foundSpacePoints(
false);
943 for (
HitVector::const_iterator hIter1 = trueHitVector.begin(), hIterEnd1 = trueHitVector.end(); hIter1 != hIterEnd1; ++hIter1)
948 if (hitsToSpacePoints.end() == hIter2)
952 const double X(spacepoint->
XYZ()[0]);
954 if (!foundSpacePoints)
958 foundSpacePoints =
true;
968 for (
HitVector::const_iterator hIter1 = trueHitVector.begin(), hIterEnd1 = trueHitVector.end(); hIter1 != hIterEnd1; ++hIter1)
970 if (recoHitsToParticles.find(*hIter1) == recoHitsToParticles.end())
981 if (matchedParticles.end() != pIter1)
995 if (recoParticlesToHits.end() == pIter2)
996 throw cet::exception(
"LArPandora") <<
" PFParticleMonitoring::analyze --- Found a reco particle without any hits ";
998 const HitVector &recoHitVector = pIter2->second;
1000 for (
HitVector::const_iterator hIter2 = recoHitVector.begin(), hIterEnd2 = recoHitVector.end(); hIter2 != hIterEnd2; ++hIter2)
1002 if (trueHitsToParticles.find(*hIter2) == trueHitsToParticles.end())
1007 if (matchedParticleHits.end() == pIter3)
1008 throw cet::exception(
"LArPandora") <<
" PFParticleMonitoring::analyze --- Found a matched true particle without matched hits ";
1010 const HitVector &matchedHitVector = pIter3->second;
1023 if (recoParticlesToVertices.end() != pIter4)
1026 if (!vertexVector.empty())
1029 std::cout <<
" Warning: Found particle with more than one associated vertex " << std::endl;
1032 double xyz[3] = {0.0, 0.0, 0.0} ;
1033 recoVertex->
XYZ(xyz);
1043 if (recoParticlesToTracks.end() != pIter5)
1046 if (!trackVector.empty())
1049 std::cout <<
" Warning: Found particle with more than one associated track " << std::endl;
1052 const TVector3 &vtxPosition = recoTrack->
Vertex();
1053 const TVector3 &endPosition = recoTrack->
End();
1071 m_pfoIsStitched = (particlesToT0s.end() != particlesToT0s.find(recoParticle));
1078 std::cout <<
" MCParticle [" <<
m_index <<
"]" 1094 iter1 != iterEnd1; ++iter1)
1102 if (trueParticlesToHits.end() == iter3)
1105 const HitVector &hitVector = iter3->second;
1110 trueHitsToNeutrinos[hit] = trueNeutrino;
1111 trueNeutrinosToHits[trueNeutrino].push_back(hit);
1131 if (recoParticlesToHits.end() == iter2)
1134 const HitVector &hitVector = iter2->second;
1139 recoHitsToNeutrinos[hit] = recoNeutrino;
1140 recoNeutrinosToHits[recoNeutrino].push_back(hit);
1152 this->
GetRecoToTrueMatches(recoNeutrinosToHits, trueHitsToNeutrinos, matchedNeutrinos, matchedNeutrinoHits, recoVeto, trueVeto);
1160 bool foundMatches(
false);
1163 iter1 != iterEnd1; ++iter1)
1166 if (vetoReco.count(recoNeutrino) > 0)
1169 const HitVector &hitVector = iter1->second;
1178 if (trueHitsToNeutrinos.end() == iter3)
1182 if (vetoTrue.count(trueNeutrino) > 0)
1185 truthContributionMap[trueNeutrino].push_back(hit);
1191 iter4 != iterEnd4; ++iter4)
1193 if ((truthContributionMap.end() == mIter) || (iter4->second.size() > mIter->second.size()))
1199 if (truthContributionMap.end() != mIter)
1205 if ((matchedNeutrinoHits.end() == iter5) || (mIter->second.size() > iter5->second.size()))
1207 matchedNeutrinos[trueNeutrino] = recoNeutrino;
1208 matchedNeutrinoHits[trueNeutrino] = mIter->second;
1209 foundMatches =
true;
1218 pIter != pIterEnd; ++pIter)
1220 vetoTrue.insert(pIter->first);
1221 vetoReco.insert(pIter->second);
1225 this->
GetRecoToTrueMatches(recoNeutrinosToHits, trueHitsToNeutrinos, matchedNeutrinos, matchedNeutrinoHits, vetoReco, vetoTrue);
1235 this->
GetRecoToTrueMatches(recoParticlesToHits, trueHitsToParticles, matchedParticles, matchedHits, recoVeto, trueVeto);
1243 bool foundMatches(
false);
1246 iter1 != iterEnd1; ++iter1)
1249 if (vetoReco.count(recoParticle) > 0)
1252 const HitVector &hitVector = iter1->second;
1261 if (trueHitsToParticles.end() == iter3)
1265 if (vetoTrue.count(trueParticle) > 0)
1268 truthContributionMap[trueParticle].push_back(hit);
1274 iter4 != iterEnd4; ++iter4)
1276 if ((truthContributionMap.end() == mIter) || (iter4->second.size() > mIter->second.size()))
1282 if (truthContributionMap.end() != mIter)
1288 if ((matchedHits.end() == iter5) || (mIter->second.size() > iter5->second.size()))
1290 matchedParticles[trueParticle] = recoParticle;
1291 matchedHits[trueParticle] = mIter->second;
1292 foundMatches =
true;
1301 pIter != pIterEnd; ++pIter)
1303 vetoTrue.insert(pIter->first);
1304 vetoReco.insert(pIter->second);
1308 this->
GetRecoToTrueMatches(recoParticlesToHits, trueHitsToParticles, matchedParticles, matchedHits, vetoReco, vetoTrue);
1320 if (hit->
View() == view)
1333 bool foundStartPosition(
false);
1337 for (
int nt = 0; nt < numTrajectoryPoints; ++nt)
1341 double pos[3] = {particle->
Vx(nt), particle->
Vy(nt), particle->
Vz(nt)};
1349 if (!foundStartPosition)
1352 foundStartPosition =
true;
1360 if (!foundStartPosition)
1373 for (
int nt = startT; nt < endT; ++nt)
1375 const double dx(particle->
Vx(nt+1) - particle->
Vx(nt));
1376 const double dy(particle->
Vy(nt+1) - particle->
Vy(nt));
1377 const double dz(particle->
Vz(nt+1) - particle->
Vz(nt));
1378 length += sqrt(dx * dx + dy * dy + dz * dz);
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::...
unsigned int NumberTrajectoryPoints() const
void analyze(const art::Event &evt)
std::map< art::Ptr< simb::MCTruth >, HitVector > MCTruthToHits
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.
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > SpacePointsToHits
double Py(const int i=0) const
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
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...
std::map< art::Ptr< simb::MCTruth >, art::Ptr< recob::PFParticle > > MCTruthToPFParticles
bool m_useDaughterPFParticles
Encapsulate the construction of a single cyostat.
void GetRecoToTrueMatches(const PFParticlesToHits &recoNeutrinosToHits, const HitsToMCTruth &trueHitsToNeutrinos, MCTruthToPFParticles &matchedNeutrinos, MCTruthToHits &matchedNeutrinoHits) const
Perform matching between true and reconstructed neutrino events.
TVector3 VertexDirection() const
Covariance matrices are either set or not.
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
std::string m_backtrackerLabel
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
Declaration of signal hit object.
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
std::map< int, art::Ptr< simb::MCParticle > > MCParticleMap
int PdgCode() const
Return the type of particle as a PDG ID.
geo::View_t View() const
View for the plane of the hit.
std::map< art::Ptr< simb::MCParticle >, art::Ptr< recob::PFParticle > > MCParticlesToPFParticles
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::vector< art::Ptr< simb::MCParticle > > MCParticleVector
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
void BuildTrueNeutrinoHitMaps(const MCTruthToMCParticles &truthToParticles, const MCParticlesToHits &trueParticlesToHits, MCTruthToHits &trueNeutrinosToHits, HitsToMCTruth &trueHitsToNeutrinos) const
Build mapping from true neutrinos to hits.
std::set< art::Ptr< recob::PFParticle > > PFParticleSet
geo::TPCGeo const & PositionToTPC(geo::Point_t const &point) const
Returns the TPC at specified location.
std::vector< art::Ptr< recob::Track > > TrackVector
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.
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
static void BuildMCParticleHitMaps(const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
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".
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.
#define DEFINE_ART_MODULE(klass)
std::map< art::Ptr< recob::PFParticle >, T0Vector > PFParticlesToT0s
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::SpacePoint > > HitsToSpacePoints
double P(const int i=0) const
T get(std::string const &key) const
std::set< art::Ptr< simb::MCTruth > > MCTruthSet
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::PFParticle >, VertexVector > PFParticlesToVertices
PFParticleMonitoring(fhicl::ParameterSet const &pset)
Constructor.
std::vector< art::Ptr< anab::T0 > > T0Vector
EDAnalyzer(Table< Config > const &config)
Declaration of cluster object.
Provides recob::Track data product.
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.
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
std::vector< art::Ptr< recob::Hit > > HitVector
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
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.
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
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
double m_pfoStraightLength
T * make(ARGS...args) const
std::map< art::Ptr< simb::MCParticle >, HitVector > MCParticlesToHits
const double * XYZ() const
Utility object to perform functions of association.
Encapsulate the construction of a single detector plane.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
TVector3 Vertex() const
Covariance matrices are either set or not.
double m_mcStraightLength
double Pz(const int i=0) const
double Vz(const int i=0) const
EventNumber_t event() const
void reconfigure(fhicl::ParameterSet const &pset)
Planes which measure W (third view for Bo, MicroBooNE, etc).
PFParticleMonitoring class.
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
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.
TVector3 End() const
Covariance matrices are either set or not.
helper function for LArPandoraInterface producer module
std::set< art::Ptr< simb::MCParticle > > MCParticleSet
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".
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCParticle > > HitsToMCParticles
double Vy(const int i=0) const
art framework interface to geometry description
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::Hit >, art::Ptr< simb::MCTruth > > HitsToMCTruth
cet::coded_exception< error, detail::translate > exception
Encapsulate the construction of a single detector plane.
virtual ~PFParticleMonitoring()
Destructor.
std::vector< art::Ptr< recob::Vertex > > VertexVector
static void BuildMCParticleMap(const MCParticleVector &particleVector, MCParticleMap &particleMap)
Build particle maps for true particles.