7 #ifndef LAR_PANDORA_EVENT_H 8 #define LAR_PANDORA_EVENT_H 1 36 typedef std::vector< art::Ptr<larpandoraobj::PFParticleMetadata> >
MetadataVector;
37 typedef std::map< art::Ptr<recob::PFParticle>, std::vector< art::Ptr<larpandoraobj::PFParticleMetadata> > >
PFParticlesToMetadata;
40 typedef std::map< art::Ptr<recob::PFParticle>, std::vector< art::Ptr<recob::PCAxis> > >
PFParticlesToPCAxes;
42 typedef std::map< art::Ptr<recob::Shower>, std::vector< art::Ptr<recob::PCAxis> > >
ShowersToPCAxes;
91 Labels(
const std::string &pfParticleProducerLabel,
const std::string &hitProducerLabel);
98 Labels(
const std::string &pfParticleProducerLabel,
const std::string &trackProducerLabel,
const std::string &showerProducerLabel,
99 const std::string &hitProducerLabel);
200 template <
typename T>
210 template <
typename T,
typename U>
254 PFParticlesToPFParticles &outputPFParticleDaughterMap)
const;
293 template <
typename T,
typename U>
307 template <
typename T,
typename U>
316 template <
typename T>
327 template <
typename T,
typename U>
338 unsigned int> &mapToAdd)
const;
346 template <
typename T>
355 template <
typename T,
typename U>
401 template <
typename T>
406 for (
unsigned int i = 0; i != outputHandle->size(); i++)
409 outputCollection.push_back(
object);
415 template <
typename T,
typename U>
421 for (
unsigned int iT = 0; iT < inputHandleT->size(); iT++)
425 if (outputAssociationMap.find(objectT) == outputAssociationMap.end())
427 std::vector< art::Ptr< U > > emptyVect;
432 outputAssociationMap[objectT].push_back(objectU);
438 template <
typename T,
typename U>
442 if (associationTtoU.find(anObject) == associationTtoU.end())
443 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::CollectAssociated -- Can not find association for object supplied." << std::endl;
445 std::vector<art::Ptr<U> > associatedObjects = associationTtoU.at(anObject);
446 associatedU.insert(associatedU.end(), associatedObjects.begin(), associatedObjects.end());
451 template <
typename T,
typename U>
457 std::vector<art::Ptr<U> > emptyVector;
459 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetFilteredAssociationMap -- Can not have multiple association map entries for a single object." << std::endl;
461 for (
art::Ptr< U > objectU : inputAssociationTtoU.at(objectT))
463 typename std::vector<art::Ptr<U> >
::const_iterator associatedObjectIter = std::find(collectionU.begin(), collectionU.end(), objectU);
464 if (associatedObjectIter == collectionU.end())
467 outputAssociationTtoU[objectT].push_back(objectU);
474 template <
typename T>
477 std::unique_ptr<std::vector<T> > output(
new std::vector<T>);
480 output->push_back(*
object);
488 std::unique_ptr<std::vector<recob::PFParticle> > output(
new std::vector<recob::PFParticle>);
494 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::WriteCollection -- PFParticle ID exceeds shift value of " <<
m_shift <<
". Can't merge the collections!" << std::endl;
497 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::WriteCollection -- Can't find supplied PFParticle in the PFParticle to origin ID map." << std::endl;
500 const size_t adjustedSelf(
part->Self() + offset);
502 size_t adjustedParent =
part->Parent();
504 adjustedParent += offset;
506 const std::vector<size_t> &daughters(
part->Daughters());
507 std::vector<size_t> adjustedDaughters;
508 for (
unsigned int d = 0;
d < daughters.size();
d++)
509 adjustedDaughters.push_back(daughters[
d] + offset);
512 output->push_back(adjustedPart);
520 template <
typename T,
typename U>
529 typename std::vector<art::Ptr<T> >
::const_iterator itT = std::find(collectionT.begin(), collectionT.end(), it-> first);
530 if (itT == collectionT.end())
531 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::WriteAssociation -- association map contains object not in collectionT." << std::endl;
533 art::Ptr<T> newObjectT(makePtrT(std::distance(collectionT.begin(), itT)));
541 typename std::vector<art::Ptr<U> >
::const_iterator itU = std::find(collectionU.begin(), collectionU.end(), objectU);
542 if (itU == collectionU.end())
543 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::WriteAssociation -- association map contains object not in collectionU." << std::endl;
545 art::Ptr<U> newObjectU(makePtrU(std::distance(collectionU.begin(), itU)));
560 template <
typename T>
563 collectionToMerge.insert(collectionToMerge.end(), collection.begin(), collection.end());
568 template <
typename T,
typename U>
572 associationToMerge.insert(association.begin(), association.end());
577 #endif // #ifndef LAR_PANDORA_EVENT_H
void GetPFParticleHierarchy()
Get the mapping from PFParticles to their daughters.
ShowersToHits m_showerHitMap
The input associations: Shower -> Hit.
std::map< art::Ptr< recob::SpacePoint >, std::vector< art::Ptr< recob::Hit > > > SpacePointsToHitVector
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)
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
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
static constexpr size_t kPFParticlePrimary
Define index to signify primary particle.
std::map< art::Ptr< recob::Shower >, HitVector > ShowersToHits
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
Declaration of signal hit object.
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)
std::map< art::Ptr< recob::Track >, HitVector > TracksToHits
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)
std::map< art::Ptr< recob::PFParticle >, std::vector< art::Ptr< larpandoraobj::PFParticleMetadata > > > PFParticlesToMetadata
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)
std::vector< art::Ptr< recob::Track > > TrackVector
PFParticlesToPFParticles m_pfParticleDaughterMap
The mapping from parent to daughter PFParticles.
ProductID put(std::unique_ptr< PROD > &&product)
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...
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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.
Provides recob::Track data product.
void SetTrackProducerLabel(const std::string &label)
std::map< art::Ptr< recob::PFParticle >, T0Vector > PFParticlesToT0s
std::map< art::Ptr< recob::Cluster >, HitVector > ClustersToHits
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< art::Ptr< larpandoraobj::PFParticleMetadata > > MetadataVector
TrackVector m_tracks
The input collection of Tracks.
PFParticlesToTracks m_pfParticleTrackMap
The input associations: PFParticle -> Track.
std::map< art::Ptr< recob::PFParticle >, VertexVector > PFParticlesToVertices
void SetSpacePointProducerLabel(const std::string &label)
std::vector< art::Ptr< anab::T0 > > T0Vector
void SetPFParticleToMetadataProducerLabel(const std::string &label)
art::Event * m_pEvent
The event to consider.
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
std::vector< art::Ptr< recob::PCAxis > > PCAxisVector
Declaration of cluster object.
std::map< art::Ptr< recob::PFParticle >, ShowerVector > PFParticlesToShowers
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)
std::vector< art::Ptr< recob::Shower > > ShowerVector
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
T0Vector m_t0s
The input collection of T0s.
std::vector< art::Ptr< recob::Hit > > HitVector
std::map< art::Ptr< recob::PFParticle >, TrackVector > PFParticlesToTracks
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.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
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)
Hierarchical representation of particle flow.
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.
Utility object to perform functions of association.
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
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::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
void SetShowerToPCAxisProducerLabel(const std::string &label)
std::map< art::Ptr< recob::Shower >, std::vector< art::Ptr< recob::PCAxis > > > ShowersToPCAxes
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.
std::map< art::Ptr< recob::PFParticle >, std::vector< art::Ptr< recob::PCAxis > > > PFParticlesToPCAxes
helper function for LArPandoraInterface producer module
PFParticlesToClusters m_pfParticleClusterMap
The input associations: PFParticle -> Cluster.
void SetTrackToHitProducerLabel(const std::string &label)
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.
std::map< LabelType, std::string > m_labels
Map holding the labels.
std::vector< art::Ptr< recob::Vertex > > VertexVector
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.