7 #include "art/Framework/Core/ModuleMacros.h"
8 #include "art/Framework/Core/EDAnalyzer.h"
118 #include "art/Framework/Principal/Event.h"
119 #include "fhiclcpp/ParameterSet.h"
120 #include "art/Framework/Principal/Handle.h"
121 #include "art/Framework/Services/Registry/ServiceHandle.h"
122 #include "art_root_io/TFileService.h"
123 #include "art_root_io/TFileDirectory.h"
124 #include "messagefacility/MessageLogger/MessageLogger.h"
136 namespace lar_pandora
155 m_trackLabel = pset.get<std::string>(
"TrackModule",
"pandora");
156 m_showerLabel = pset.get<std::string>(
"ShowerModule",
"pandora");
164 mf::LogDebug(
"LArPandora") <<
" *** PFParticleAnalysis::beginJob() *** " << std::endl;
167 art::ServiceHandle<art::TFileService const>
tfs;
169 m_pRecoTree = tfs->make<TTree>(
"pandora",
"LAr PFParticles");
232 std::cout <<
" *** PFParticleAnalysis::analyze(...) *** " << std::endl;
311 std::cout <<
" PFParticles: " << particleVector.size() << std::endl;
313 if (particleVector.empty())
354 for (
unsigned int n = 0;
n < particleVector.size(); ++
n)
356 const art::Ptr<recob::PFParticle> particle = particleVector.at(
n);
359 m_self = particle->Self();
362 m_parent = (particle->IsPrimary() ? -1 : particle->Parent());
412 PFParticlesToClusters::const_iterator cIter = particlesToClusters.find(particle);
413 if (particlesToClusters.end() != cIter)
417 PFParticlesToSpacePoints::const_iterator pIter = particlesToSpacePoints.find(particle);
418 if (particlesToSpacePoints.end() != pIter)
422 PFParticlesToHits::const_iterator hIter = particlesToHits.find(particle);
423 if (particlesToHits.end() != hIter)
424 m_hits = hIter->second.size();
427 PFParticlesToVertices::const_iterator vIter = particlesToVertices.find(particle);
428 if (particlesToVertices.end() != vIter)
431 if (!vertexVector.empty())
434 std::cout <<
" Warning: Found particle with more than one associated vertex " << std::endl;
436 const art::Ptr<recob::Vertex>
vertex = *(vertexVector.begin());
437 double xyz[3] = {0.0, 0.0, 0.0} ;
448 PFParticlesToT0s::const_iterator t0Iter = particlesToT0s.find(particle);
449 if (particlesToT0s.end() != t0Iter)
451 const T0Vector &t0Vector = t0Iter->second;
452 if (!t0Vector.empty())
455 std::cout <<
" Warning: Found particle with more than one associated T0 " << std::endl;
457 const art::Ptr<anab::T0>
t0 = *(t0Vector.begin());
463 PFParticlesToTracks::const_iterator trkIter = particlesToTracks.find(particle);
464 if (particlesToTracks.end() != trkIter)
467 if (!trackVector.empty())
470 std::cout <<
" Warning: Found particle with more than one associated track " << std::endl;
472 const art::Ptr<recob::Track>
track = *(trackVector.begin());
473 const auto &trackVtxPosition = track->Vertex();
474 const auto &trackVtxDirection = track->VertexDirection();
475 const auto &trackEndPosition = track->End();
476 const auto &trackEndDirection = track->EndDirection();
496 TracksToHits::const_iterator trkIter2 = tracksToHits.find(track);
497 if (tracksToHits.end() != trkIter2)
503 PFParticlesToShowers::const_iterator shwIter = particlesToShowers.find(particle);
504 if (particlesToShowers.end() != shwIter)
507 if (!showerVector.empty())
510 std::cout <<
" Warning: Found particle with more than one associated shower " << std::endl;
512 const art::Ptr<recob::Shower>
shower = *(showerVector.begin());
513 const TVector3 &showerVtxPosition = shower->ShowerStart();
514 const TVector3 &showerVtxDirection = shower->Direction();
530 ShowersToHits::const_iterator shwIter2 = showersToHits.find(shower);
531 if (showersToHits.end() != shwIter2)
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.
bool m_printDebug
switch for print statements (TODO: use message service!)
static void BuildPFParticleMap(const PFParticleVector &particleVector, PFParticleMap &particleMap)
Build particle maps for reconstructed particles.
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< recob::PFParticle >, ClusterVector > PFParticlesToClusters
std::vector< art::Ptr< recob::Shower > > ShowerVector
process_name use argoneut_mc_hitfinder track
PFParticleAnalysis(fhicl::ParameterSet const &pset)
Constructor.
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
std::map< art::Ptr< recob::PFParticle >, VertexVector > PFParticlesToVertices
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
PFParticleAnalysis class.
std::map< art::Ptr< recob::PFParticle >, T0Vector > PFParticlesToT0s
std::map< art::Ptr< recob::PFParticle >, ShowerVector > PFParticlesToShowers
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::map< art::Ptr< recob::Shower >, HitVector > ShowersToHits
static void CollectShowers(const art::Event &evt, const std::string &label, ShowerVector &showerVector, PFParticlesToShowers &particlesToShowers)
Collect the reconstructed PFParticles and associated Showers from the ART event record.
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
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.
void reconfigure(fhicl::ParameterSet const &pset)
std::vector< art::Ptr< recob::Track > > TrackVector
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
std::map< art::Ptr< recob::Track >, HitVector > TracksToHits
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.
Provides recob::Track data product.
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
std::vector< art::Ptr< recob::Vertex > > VertexVector
void analyze(const art::Event &evt)
art::ServiceHandle< art::TFileService > tfs
static int GetGeneration(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the generation of this particle (first generation if primary)
std::vector< art::Ptr< anab::T0 > > T0Vector
std::string m_showerLabel
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.
virtual ~PFParticleAnalysis()
Destructor.
helper function for LArPandoraInterface producer module
double m_trkstraightlength
BEGIN_PROLOG could also be cout
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::string m_particleLabel