13 m_pProducer(pProducer),
15 m_labels(inputLabels),
16 m_shouldProduceT0s(shouldProduceT0s),
24 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::LArPandoraEvent -- Repeated input PFParticles!" << std::endl;
104 return filteredEvent;
145 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::Merge - Can't merge LArPandoraEvents with differing shift values." << std::endl;
235 std::map< size_t, art::Ptr< recob::PFParticle > > idToPFParticleMap;
242 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetPFParticleHierarchy -- Repeated PFParticle in heirarchy map!" << std::endl;
244 for (
const size_t & daughterId :
part->Daughters())
246 if (idToPFParticleMap.find(daughterId) == idToPFParticleMap.end())
247 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetPFParticleHierarchy -- Can't access map entry for daughter of PFParticle supplied." << std::endl;
251 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetPFParticleHierarchy -- Can't have the same daughter twice!" << std::endl;
264 if (
part->IsPrimary())
265 primaryPFParticles.push_back(
part);
275 unsigned int pdg = std::abs(
part->PdgCode());
276 bool isNeutrino = (pdg ==
nue || pdg ==
numu || pdg ==
nutau);
278 if ((shouldProduceNeutrinos && isNeutrino) || (!shouldProduceNeutrinos && !isNeutrino))
279 outputPFParticles.push_back(
part);
298 if (cosmicTags.size() != 1)
299 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetFilteredParticlesByCRTag -- Found " << cosmicTags.size() <<
" CR tags for a PFParticle (require 1)." << std::endl;
304 if ((shouldProduceNeutrinos && isNeutrino) || (!shouldProduceNeutrinos && !isNeutrino))
305 outputPFParticles.push_back(
part);
316 if (std::find(filteredParticles.begin(), filteredParticles.end(), it->first) == filteredParticles.end())
continue;
318 if (! outputPFParticleDaughterMap.insert(PFParticlesToPFParticles::value_type(it->first, it->second)).second)
319 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetFilteredHierarchyMap -- Can't add multiple map entries for same PFParticle" << std::endl;
330 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetIdToPFParticleMap -- Can't insert multiple entries with the same Id" << std::endl;
347 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetDownstreamPFParticles -- Could not find PFParticle in the hierarchy map" << std::endl;
349 if (std::find(downstreamPFParticles.begin(), downstreamPFParticles.end(),
part) == downstreamPFParticles.end())
350 downstreamPFParticles.push_back(part);
362 if (existingMap.find(
part) == existingMap.end())
363 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::FillPFParticleToOriginIdMap -- Can't access map entry for PFParticle supplied." << std::endl;
366 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::FillPFParticleToOriginIdMap -- Can't add multiple map entries for same PFParticle" << std::endl;
375 unsigned int maxID = 0;
376 if (mapToMerge.size() != 0)
378 maxID = std::max_element(mapToMerge.begin(), mapToMerge.end(), [](
const std::pair<art::Ptr<recob::PFParticle>,
unsigned int> &p1,
const std::pair< art::Ptr<recob::PFParticle>,
unsigned int> &p2) {
return p1.second < p2.second;})->second;
383 if (!mapToMerge.insert(std::map<
art::Ptr<recob::PFParticle>,
unsigned int>::value_type(it->first, it->second + maxID + 1)).second)
384 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::MergePFParticleToOriginIdMap - Can't merge collections containing repeated PFParticles." << std::endl;
393 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleLabel, pfParticleProducerLabel));
394 m_labels.insert(std::map< LabelType, std::string >::value_type(SpacePointLabel, pfParticleProducerLabel));
395 m_labels.insert(std::map< LabelType, std::string >::value_type(ClusterLabel, pfParticleProducerLabel));
396 m_labels.insert(std::map< LabelType, std::string >::value_type(VertexLabel, pfParticleProducerLabel));
397 m_labels.insert(std::map< LabelType, std::string >::value_type(TrackLabel, pfParticleProducerLabel));
398 m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerLabel, pfParticleProducerLabel));
399 m_labels.insert(std::map< LabelType, std::string >::value_type(T0Label, pfParticleProducerLabel));
400 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleMetadataLabel, pfParticleProducerLabel));
401 m_labels.insert(std::map< LabelType, std::string >::value_type(PCAxisLabel, pfParticleProducerLabel));
402 m_labels.insert(std::map< LabelType, std::string >::value_type(HitLabel, hitProducerLabel));
404 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToSpacePointLabel, pfParticleProducerLabel));
405 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToClusterLabel, pfParticleProducerLabel));
406 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToVertexLabel, pfParticleProducerLabel));
407 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToTrackLabel, pfParticleProducerLabel));
408 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToShowerLabel, pfParticleProducerLabel));
409 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToT0Label, pfParticleProducerLabel));
410 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToMetadataLabel, pfParticleProducerLabel));
411 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToPCAxisLabel, pfParticleProducerLabel));
412 m_labels.insert(std::map< LabelType, std::string >::value_type(SpacePointToHitLabel, pfParticleProducerLabel));
413 m_labels.insert(std::map< LabelType, std::string >::value_type(ClusterToHitLabel, pfParticleProducerLabel));
414 m_labels.insert(std::map< LabelType, std::string >::value_type(TrackToHitLabel, pfParticleProducerLabel));
415 m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerToHitLabel, pfParticleProducerLabel));
416 m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerToPCAxisLabel, pfParticleProducerLabel));
422 const std::string &hitProducerLabel)
424 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleLabel, pfParticleProducerLabel));
425 m_labels.insert(std::map< LabelType, std::string >::value_type(SpacePointLabel, pfParticleProducerLabel));
426 m_labels.insert(std::map< LabelType, std::string >::value_type(ClusterLabel, pfParticleProducerLabel));
427 m_labels.insert(std::map< LabelType, std::string >::value_type(VertexLabel, pfParticleProducerLabel));
428 m_labels.insert(std::map< LabelType, std::string >::value_type(TrackLabel, trackProducerLabel));
429 m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerLabel, showerProducerLabel));
430 m_labels.insert(std::map< LabelType, std::string >::value_type(T0Label, pfParticleProducerLabel));
431 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleMetadataLabel, pfParticleProducerLabel));
432 m_labels.insert(std::map< LabelType, std::string >::value_type(PCAxisLabel, showerProducerLabel));
433 m_labels.insert(std::map< LabelType, std::string >::value_type(HitLabel, hitProducerLabel));
435 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToSpacePointLabel, pfParticleProducerLabel));
436 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToClusterLabel, pfParticleProducerLabel));
437 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToVertexLabel, pfParticleProducerLabel));
438 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToTrackLabel, trackProducerLabel));
439 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToShowerLabel, showerProducerLabel));
440 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToT0Label, pfParticleProducerLabel));
441 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToMetadataLabel, pfParticleProducerLabel));
442 m_labels.insert(std::map< LabelType, std::string >::value_type(PFParticleToPCAxisLabel, showerProducerLabel));
443 m_labels.insert(std::map< LabelType, std::string >::value_type(SpacePointToHitLabel, pfParticleProducerLabel));
444 m_labels.insert(std::map< LabelType, std::string >::value_type(ClusterToHitLabel, pfParticleProducerLabel));
445 m_labels.insert(std::map< LabelType, std::string >::value_type(TrackToHitLabel, trackProducerLabel));
446 m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerToHitLabel, showerProducerLabel));
447 m_labels.insert(std::map< LabelType, std::string >::value_type(ShowerToPCAxisLabel, showerProducerLabel));
503 m_labels[PFParticleMetadataLabel] = label;
517 m_labels[PFParticleToSpacePointLabel] = label;
524 m_labels[PFParticleToClusterLabel] = label;
531 m_labels[PFParticleToVertexLabel] = label;
538 m_labels[PFParticleToTrackLabel] = label;
545 m_labels[PFParticleToShowerLabel] = label;
552 m_labels[PFParticleToT0Label] = label;
559 m_labels[PFParticleToPCAxisLabel] = label;
566 m_labels[SpacePointToHitLabel] = label;
573 m_labels[ClusterToHitLabel] = label;
594 m_labels[ShowerToPCAxisLabel] = label;
void GetPFParticleHierarchy()
Get the mapping from PFParticles to their daughters.
ShowersToHits m_showerHitMap
The input associations: Shower -> Hit.
void GetFilteredAssociationMap(const std::vector< art::Ptr< T > > &collectionT, const std::vector< art::Ptr< U > > &collectionU, const std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &inputAssociationTtoU, std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &outputAssociationTtoU) const
Gets the mapping between two filtered collections.
SpacePointVector m_spacePoints
The input collection of SpacePoints.
MetadataVector m_metadata
The input collection of PFParticle metadata.
void WriteAssociation(const std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &associationMap, const std::vector< art::Ptr< T > > &collectionT, const std::vector< art::Ptr< U > > &collectionU, const bool thisProducesU=true) const
Write a given association to the event.
void SetSpacePointToHitProducerLabel(const std::string &label)
ShowerVector m_showers
The input collection of Showers.
void SetVertexProducerLabel(const std::string &label)
LArPandoraEvent(art::EDProducer *pProducer, art::Event *pEvent, const Labels &inputLabels, const bool shouldProduceT0s=false, const size_t shift=100000)
Constructor from an art::Event.
const std::string & GetLabel(const LabelType &type) const
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
LabelType
Label type enumeration.
ClustersToHits m_clusterHitMap
The input associations: Cluster -> Hit.
void SetPFParticleToShowerProducerLabel(const std::string &label)
PFParticlesToVertices m_pfParticleVertexMap
The input associations: PFParticle -> Vertex.
PFParticlesToMetadata m_pfParticleMetadataMap
The input associations: PFParticle -> Metadata.
void SetClusterProducerLabel(const std::string &label)
ShowersToPCAxes m_showerPCAxisMap
The input associations: PCAxis -> Shower.
void SetMetadataProducerLabel(const std::string &label)
void FillPFParticleToOriginIdMap(const std::map< art::Ptr< recob::PFParticle >, unsigned int > &existingMap)
Fills the PFParticleToOriginIdMap using an existing map from another LArPandoraEvent.
void GetAssociationMap(const Labels::LabelType &inputLabel, art::Handle< std::vector< T > > &inputHandleT, std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &outputAssociationMap) const
Get the mapping between two collections using the specified label.
Labels(const std::string &pfParticleProducerLabel, const std::string &hitProducerLabel)
Minimal parametrised constructor. Sets all collection labels to be the same as the PFParticle produce...
void SetPFParticleToVertexProducerLabel(const std::string &label)
void GetCollections()
Get the collections and associations from m_pEvent with the required labels.
void GetCollection(const Labels::LabelType &inputLabel, art::Handle< std::vector< T > > &outputHandle, std::vector< art::Ptr< T > > &outputCollection) const
Gets a given collection from m_pEvent with the label supplied.
VertexVector m_vertices
The input collection of Vertices.
void SetPFParticleToSpacePointProducerLabel(const std::string &label)
PFParticlesToPFParticles m_pfParticleDaughterMap
The mapping from parent to daughter PFParticles.
LArPandoraEvent FilterByPdgCode(const bool shouldProduceNeutrinos) const
Produce a copy of the event keeping only the collections that are associated with a top-level particl...
std::map< art::Ptr< recob::PFParticle >, unsigned int > m_pfParticleToOriginIdMap
Mapping between PFParticles, and an ID for the LArPandoraEvent from which they originated (to keep tr...
void WriteCollection(const std::vector< art::Ptr< T > > &collection) const
Write a given collection to the event.
void SetPFParticleToPCAxisProducerLabel(const std::string &label)
HitVector m_hits
The input collection of Hits.
std::map< art::Ptr< recob::PFParticle >, std::vector< art::Ptr< recob::PFParticle > > > PFParticlesToPFParticles
PFParticlesToT0s m_pfParticleT0Map
The input associations: PFParticle -> T0.
void GetFilteredParticlesByCRTag(const bool shouldProduceNeutrinos, const std::string &tagProducerLabel, const PFParticleVector &inputPFParticles, PFParticleVector &outputPFParticles) const
Filters PFParticles based on their Pdg from the inputPFParticles.
PFParticlesToSpacePoints m_pfParticleSpacePointMap
The input associations: PFParticle -> SpacePoint.
A description of all outputs from an instance of pandora with functionality to filter and merge multi...
void SetTrackProducerLabel(const std::string &label)
void MergeAssociation(std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &associationToMerge, const std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &association) const
Append an association to another association.
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
TrackVector m_tracks
The input collection of Tracks.
PFParticlesToTracks m_pfParticleTrackMap
The input associations: PFParticle -> Track.
void SetSpacePointProducerLabel(const std::string &label)
art::Event * m_pEvent
The event to consider.
void GetFilteredHierarchyMap(const PFParticleVector &filteredParticles, const PFParticlesToPFParticles &unfilteredPFParticleDaughterMap, PFParticlesToPFParticles &outputPFParticleDaughterMap) const
Filters the hierarchy map using a given vector of filteredParticles.
void SetClusterToHitProducerLabel(const std::string &label)
T0Vector m_t0s
The input collection of T0s.
void SetShowerProducerLabel(const std::string &label)
void MergeCollection(std::vector< art::Ptr< T > > &collectionToMerge, const std::vector< art::Ptr< T > > &collection) const
Append a collection onto an other collection.
PCAxisVector m_pcAxes
The input collection of PCAxes.
SpacePointsToHitVector m_spacePointHitMap
The input associations: SpacePoint -> Hit.
ClusterVector m_clusters
The input collection of Clusters.
void GetFilteredParticlesByPdgCode(const bool shouldProduceNeutrinos, const PFParticleVector &inputPFParticles, PFParticleVector &outputPFParticles) const
Filters PFParticles based on their Pdg from the inputPFParticles.
void GetDownstreamPFParticles(const PFParticleVector &inputPFParticles, PFParticleVector &downstreamPFParticles) const
Get particles downstream of any particle in an input vector.
PFParticleVector m_pfParticles
The input collection of PFParticles.
void SetShowerToHitProducerLabel(const std::string &label)
void SetPFParticleToClusterProducerLabel(const std::string &label)
void MergePFParticleToOriginIdMap(std::map< art::Ptr< recob::PFParticle >, unsigned int > &mapToMerge, const std::map< art::Ptr< recob::PFParticle >, unsigned int > &mapToAdd) const
Merge two PFParticle to origin ID maps ensuring no ID collisions.
void GetIdToPFParticleMap(std::map< size_t, art::Ptr< recob::PFParticle > > &idToPFParticleMap) const
Produce a mapping between PFParticles and their ID.
art::EDProducer * m_pProducer
The producer which should write the output collections and associations.
void CollectAssociated(const art::Ptr< T > &anObject, const std::map< art::Ptr< T >, std::vector< art::Ptr< U > > > &associationTtoU, std::vector< art::Ptr< U > > &associatedU) const
Collects all objects of type U associated to a given object of type T.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
std::vector< art::Ptr< anab::CosmicTag > > CosmicTagVector
Class to handle the required producer labels.
void SetT0ProducerLabel(const std::string &label)
LArPandoraEvent FilterByCRTag(const bool shouldProduceNeutrinos, const std::string &tagProducerLabel) const
Produce a copy of the event keeping only the collections that are associated with a top-level particl...
TracksToHits m_trackHitMap
The input associations: Track -> Hit.
void SetPCAxisProducerLabel(const std::string &label)
Labels m_labels
A set of labels describing the producers for each input collection.
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
void SetShowerToPCAxisProducerLabel(const std::string &label)
PFParticlesToPCAxes m_pfParticlePCAxisMap
The input associations: PFParticle -> PCAxis.
void SetPFParticleToT0ProducerLabel(const std::string &label)
LArPandoraEvent Merge(const LArPandoraEvent &other) const
Merge collections from two events into one.
PFParticlesToClusters m_pfParticleClusterMap
The input associations: PFParticle -> Cluster.
void SetTrackToHitProducerLabel(const std::string &label)
CosmicTagID_t & CosmicType()
cet::coded_exception< error, detail::translate > exception
void SetPFParticleToTrackProducerLabel(const std::string &label)
Event finding and building.
const size_t m_shift
Amount by which to shift PFParticle IDs when merging two reconstructions of the same event...
void GetPrimaryPFParticles(PFParticleVector &primaryPFParticles) const
Filters primary PFParticles from the m_pfParticles.
bool m_shouldProduceT0s
If T0s should be produced (usually only true for use cases with multiple drift volumes) ...
PFParticlesToShowers m_pfParticleShowerMap
The input associations: PFParticle -> Shower.
void WriteToEvent() const
Write (put) the collections in this LArPandoraEvent to the art::Event.