61 void GetPFParticleIdMap(
const PFParticleHandle &pfParticleHandle, PFParticleIdMap &pfParticleMap);
115 #include "Pandora/PdgTable.h" 145 if (!pfParticleHandle.
isValid())
147 mf::LogDebug(
"ConsolidatedPFParticleAnalysisTemplate") <<
" Failed to find the PFParticles." << std::endl;
162 std::vector< art::Ptr<recob::PFParticle> > crParticles;
163 std::vector< art::Ptr<recob::PFParticle> > nuParticles;
171 std::vector< art::Ptr<recob::Track> > tracks;
172 std::vector< art::Ptr<recob::Shower> > showers;
176 std::cout <<
"Consolidated event summary:" << std::endl;
177 std::cout <<
" - Number of primary cosmic-ray PFParticles : " << crParticles.size() << std::endl;
178 std::cout <<
" - Number of neutrino final-state PFParticles : " << nuParticles.size() << std::endl;
179 std::cout <<
" ... of which are track-like : " << tracks.size() << std::endl;
180 std::cout <<
" ... of which are showers-like : " << showers.size() << std::endl;
187 for (
unsigned int i = 0; i < pfParticleHandle->size(); ++i)
190 if (!pfParticleMap.insert(PFParticleIdMap::value_type(pParticle->
Self(), pParticle)).second)
192 throw cet::exception(
"ConsolidatedPFParticleAnalysisTemplate") <<
" Unable to get PFParticle ID map, the input PFParticle collection has repeat IDs!";
204 for (
unsigned int i = 0; i < pfParticleHandle->size(); ++i)
206 const std::vector< art::Ptr<larpandoraobj::PFParticleMetadata> > &pfParticleMetadataList(pfPartToMetadataAssoc.at(i));
207 if (!pfParticleMetadataList.empty())
210 for (
unsigned int j=0; j<pfParticleMetadataList.size(); ++j)
214 if (!pfParticlePropertiesMap.empty())
215 std::cout <<
" Found PFParticle " << pParticle->
Self() <<
" with: " << std::endl;
217 std::cout <<
" - " << it->first <<
" = " << it->second << std::endl;
235 const int pdg(pParticle->
PdgCode());
236 const bool isNeutrino(std::abs(pdg) == pandora::NU_E || std::abs(pdg) == pandora::NU_MU || std::abs(pdg) == pandora::NU_TAU);
241 crParticles.push_back(pParticle);
247 if (!nuParticles.empty())
249 throw cet::exception(
"ConsolidatedPFParticleAnalysisTemplate") <<
" This event contains multiple reconstructed neutrinos!";
253 for (
const size_t daughterId : pParticle->
Daughters())
255 if (pfParticleMap.find(daughterId) == pfParticleMap.end())
256 throw cet::exception(
"ConsolidatedPFParticleAnalysisTemplate") <<
" Invalid PFParticle collection!";
258 nuParticles.push_back(pfParticleMap.at(daughterId));
273 const std::vector< art::Ptr<recob::Track> > associatedTracks(pfPartToTrackAssoc.at(pParticle.key()));
274 const std::vector< art::Ptr<recob::Shower> > associatedShowers(pfPartToShowerAssoc.at(pParticle.key()));
275 const unsigned int nTracks(associatedTracks.size());
276 const unsigned int nShowers(associatedShowers.size());
279 if (nTracks == 0 && nShowers == 0)
281 mf::LogDebug(
"ConsolidatedPFParticleAnalysisTemplate") <<
" No tracks or showers were associated to PFParticle " << pParticle->Self() << std::endl;
286 if (nTracks == 1 && nShowers == 0)
288 tracks.push_back(associatedTracks.front());
293 if (nTracks == 0 && nShowers == 1)
295 showers.push_back(associatedShowers.front());
299 throw cet::exception(
"ConsolidatedPFParticleAnalysisTemplate") <<
" There were " << nTracks <<
" tracks and " << nShowers <<
" showers associated with PFParticle " << pParticle->Self();
void CollectTracksAndShowers(const PFParticleVector &particles, const PFParticleHandle &pfParticleHandle, const art::Event &evt, TrackVector &tracks, ShowerVector &showers)
Collect associated tracks and showers to particles in an input particle vector.
const std::vector< size_t > & Daughters() const
Returns the collection of daughter particles.
size_t Self() const
Returns the index of this particle.
std::vector< art::Ptr< recob::Track > > TrackVector
std::string m_pandoraLabel
The label for the pandora producer.
void reconfigure(fhicl::ParameterSet const &pset)
Configure memeber variables using FHiCL parameters.
std::vector< art::Ptr< recob::Shower > > ShowerVector
int PdgCode() const
Return the type of particle as a PDG ID.
std::map< std::string, float > PropertiesMap
std::string m_showerLabel
The label for the shower producer from PFParticles.
ConsolidatedPFParticleAnalysisTemplate(fhicl::ParameterSet const &pset)
Constructor.
#define DEFINE_ART_MODULE(klass)
Provides recob::Track data product.
std::map< size_t, art::Ptr< recob::PFParticle > > PFParticleIdMap
T get(std::string const &key) const
std::string m_trackLabel
The label for the track producer from PFParticles.
ConsolidatedPFParticleAnalysisTemplate class.
bool IsPrimary() const
Returns whether the particle is the root of the flow.
bool m_printOutScores
Option to investigate the associations to scores for PFParticles.
EDAnalyzer(Table< Config > const &config)
void PrintOutScores(const art::Event &evt, const PFParticleHandle &pfParticleHandle) const
Print out scores in PFParticleMetadata.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
void analyze(const art::Event &evt)
Analyze an event!
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
void GetFinalStatePFParticleVectors(const PFParticleIdMap &pfParticleMap, PFParticleVector &crParticles, PFParticleVector &nuParticles)
Produce a mapping from PFParticle ID to the art ptr to the PFParticle itself for fast navigation...
void GetPFParticleIdMap(const PFParticleHandle &pfParticleHandle, PFParticleIdMap &pfParticleMap)
Produce a mapping from PFParticle ID to the art ptr to the PFParticle itself for fast navigation...
art::Handle< std::vector< recob::PFParticle > > PFParticleHandle
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
cet::coded_exception< error, detail::translate > exception