60 PFParticleIdMap& pfParticleMap);
78 PFParticleVector& crParticles,
79 PFParticleVector& nuParticles);
91 const PFParticleHandle& pfParticleHandle,
94 ShowerVector& showers);
112 #include "art_root_io/TFileDirectory.h" 113 #include "art_root_io/TFileService.h" 120 #include "Pandora/PdgTable.h" 151 if (!pfParticleHandle.
isValid()) {
153 <<
" Failed to find the PFParticles." << std::endl;
167 std::vector<art::Ptr<recob::PFParticle>> crParticles;
168 std::vector<art::Ptr<recob::PFParticle>> nuParticles;
176 std::vector<art::Ptr<recob::Track>> tracks;
177 std::vector<art::Ptr<recob::Shower>> showers;
181 std::cout <<
"Consolidated event summary:" << std::endl;
182 std::cout <<
" - Number of primary cosmic-ray PFParticles : " << crParticles.size()
184 std::cout <<
" - Number of neutrino final-state PFParticles : " << nuParticles.size()
186 std::cout <<
" ... of which are track-like : " << tracks.size() << std::endl;
187 std::cout <<
" ... of which are showers-like : " << showers.size() << std::endl;
196 for (
unsigned int i = 0; i < pfParticleHandle->size(); ++i) {
198 if (!pfParticleMap.insert(PFParticleIdMap::value_type(pParticle->
Self(), pParticle)).second) {
200 <<
" Unable to get PFParticle ID map, the input PFParticle collection has repeat IDs!";
215 for (
unsigned int i = 0; i < pfParticleHandle->size(); ++i) {
216 const std::vector<art::Ptr<larpandoraobj::PFParticleMetadata>>& pfParticleMetadataList(
217 pfPartToMetadataAssoc.at(i));
218 if (!pfParticleMetadataList.empty()) {
220 for (
unsigned int j = 0; j < pfParticleMetadataList.size(); ++j) {
222 pfParticleMetadataList.at(j));
224 pfParticleMetadata->GetPropertiesMap());
225 if (!pfParticlePropertiesMap.empty())
226 std::cout <<
" Found PFParticle " << pParticle->
Self() <<
" with: " << std::endl;
228 pfParticlePropertiesMap.begin();
229 it != pfParticlePropertiesMap.end();
231 std::cout <<
" - " << it->first <<
" = " << it->second << std::endl;
252 const int pdg(pParticle->
PdgCode());
253 const bool isNeutrino(
std::abs(pdg) == pandora::NU_E ||
std::abs(pdg) == pandora::NU_MU ||
258 crParticles.push_back(pParticle);
264 if (!nuParticles.empty()) {
266 <<
" This event contains multiple reconstructed neutrinos!";
270 for (
const size_t daughterId : pParticle->
Daughters()) {
271 if (pfParticleMap.find(daughterId) == pfParticleMap.end())
273 <<
" Invalid PFParticle collection!";
275 nuParticles.push_back(pfParticleMap.at(daughterId));
294 const std::vector<art::Ptr<recob::Track>> associatedTracks(
295 pfPartToTrackAssoc.at(pParticle.key()));
296 const std::vector<art::Ptr<recob::Shower>> associatedShowers(
297 pfPartToShowerAssoc.at(pParticle.key()));
298 const unsigned int nTracks(associatedTracks.size());
299 const unsigned int nShowers(associatedShowers.size());
302 if (nTracks == 0 && nShowers == 0) {
304 <<
" No tracks or showers were associated to PFParticle " << pParticle->Self()
310 if (nTracks == 1 && nShowers == 0) {
311 tracks.push_back(associatedTracks.front());
316 if (nTracks == 0 && nShowers == 1) {
317 showers.push_back(associatedShowers.front());
322 <<
" There were " << nTracks <<
" tracks and " << nShowers
323 <<
" 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.
std::vector< art::Ptr< recob::Shower > > ShowerVector
size_t Self() const
Returns the index of this particle.
std::string m_pandoraLabel
The label for the pandora producer.
void reconfigure(fhicl::ParameterSet const &pset)
Configure memeber variables using FHiCL parameters.
std::map< size_t, art::Ptr< recob::PFParticle > > PFParticleIdMap
constexpr auto abs(T v)
Returns the absolute value of the argument.
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.
EDAnalyzer(fhicl::ParameterSet const &pset)
ConsolidatedPFParticleAnalysisTemplate(fhicl::ParameterSet const &pset)
Constructor.
bool isValid() const noexcept
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
Provides recob::Track data product.
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.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
art::Handle< std::vector< recob::PFParticle > > PFParticleHandle
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
void PrintOutScores(const art::Event &evt, const PFParticleHandle &pfParticleHandle) const
Print out scores in PFParticleMetadata.
std::vector< art::Ptr< recob::Track > > TrackVector
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...
cet::coded_exception< error, detail::translate > exception