7 #include "art/Framework/Core/ModuleMacros.h" 
    8 #include "art/Framework/Core/EDAnalyzer.h" 
  104 #include "art/Framework/Principal/Event.h" 
  105 #include "fhiclcpp/ParameterSet.h" 
  106 #include "art/Framework/Principal/Handle.h" 
  107 #include "art/Framework/Services/Registry/ServiceHandle.h" 
  108 #include "art_root_io/TFileService.h" 
  109 #include "art_root_io/TFileDirectory.h" 
  110 #include "canvas/Persistency/Common/FindManyP.h" 
  111 #include "messagefacility/MessageLogger/MessageLogger.h" 
  115 #include "Pandora/PdgTable.h" 
  119 namespace lar_pandora
 
  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)
 
  189         const art::Ptr<recob::PFParticle> pParticle(pfParticleHandle, 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!";
 
  202     art::FindManyP< larpandoraobj::PFParticleMetadata > pfPartToMetadataAssoc(pfParticleHandle, evt, 
m_pandoraLabel);
 
  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())
 
  209             const art::Ptr<recob::PFParticle> pParticle(pfParticleHandle, i);
 
  210             for (
unsigned int j=0; j<pfParticleMetadataList.size(); ++j)
 
  212                 const art::Ptr<larpandoraobj::PFParticleMetadata> &pfParticleMetadata(pfParticleMetadataList.at(j));
 
  214                 if (!pfParticlePropertiesMap.empty())
 
  215                     std::cout << 
" Found PFParticle " << pParticle->Self() << 
" with: " << std::endl;
 
  216                 for (larpandoraobj::PFParticleMetadata::PropertiesMap::const_iterator it = pfParticlePropertiesMap.begin(); it != pfParticlePropertiesMap.end(); ++it)
 
  217                     std::cout << 
"  - " << it->first << 
" = " << it->second << std::endl;
 
  227     for (PFParticleIdMap::const_iterator it = pfParticleMap.begin(); it != pfParticleMap.end(); ++it)
 
  229         const art::Ptr<recob::PFParticle> pParticle(it->second);
 
  232         if (!pParticle->IsPrimary()) 
continue;
 
  235         const int pdg(pParticle->PdgCode());
 
  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));
 
  268     art::FindManyP< recob::Track > pfPartToTrackAssoc(pfParticleHandle, evt, 
m_trackLabel);
 
  269     art::FindManyP< recob::Shower > pfPartToShowerAssoc(pfParticleHandle, evt, 
m_showerLabel);
 
  271     for (
const art::Ptr<recob::PFParticle> &pParticle : particles)
 
  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. 
 
ClusterModuleLabel join with tracks
 
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
 
std::map< std::string, float > PropertiesMap
 
std::string m_showerLabel
The label for the shower producer from PFParticles. 
 
ConsolidatedPFParticleAnalysisTemplate(fhicl::ParameterSet const &pset)
Constructor. 
 
std::map< size_t, art::Ptr< recob::PFParticle > > PFParticleIdMap
 
std::string m_trackLabel
The label for the track producer from PFParticles. 
 
ConsolidatedPFParticleAnalysisTemplate class. 
 
bool m_printOutScores
Option to investigate the associations to scores for PFParticles. 
 
Provides recob::Track data product. 
 
void PrintOutScores(const art::Event &evt, const PFParticleHandle &pfParticleHandle) const 
Print out scores in PFParticleMetadata. 
 
void analyze(const art::Event &evt)
Analyze an event! 
 
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
 
BEGIN_PROLOG could also be cout