LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_pandora::LArPandoraEvent Class Reference

LArPandoraEvent class. More...

#include "LArPandoraEvent.h"

Classes

class  Labels
 Class to handle the required producer labels. More...
 

Public Types

template<typename T >
using Collection = std::vector< art::Ptr< T >>
 Shorthand for a collection of objects of type T. More...
 
template<typename R , typename D >
using PairVector = std::vector< std::pair< art::Ptr< R >, D >>
 
template<typename L , typename R , typename D >
using Association = std::map< art::Ptr< L >, PairVector< R, D >>
 General purpose short-hand with optional D parameter. More...
 
typedef Collection< recob::HitHitCollection
 
typedef Collection< recob::PFParticlePFParticleCollection
 
typedef Collection< recob::ClusterClusterCollection
 
typedef Collection< recob::SpacePointSpacePointCollection
 
typedef Collection< recob::VertexVertexCollection
 
typedef Collection< recob::SliceSliceCollection
 
typedef Collection< recob::TrackTrackCollection
 
typedef Collection< recob::ShowerShowerCollection
 
typedef Collection< recob::PCAxisPCAxisCollection
 
typedef Collection< larpandoraobj::PFParticleMetadataPFParticleMetadataCollection
 
typedef Collection< anab::T0T0Collection
 
typedef Association< recob::PFParticle, recob::Cluster, void * > PFParticleToClusterAssoc
 
typedef Association< recob::PFParticle, recob::SpacePoint, void * > PFParticleToSpacePointAssoc
 
typedef Association< recob::PFParticle, recob::Vertex, void * > PFParticleToVertexAssoc
 
typedef Association< recob::PFParticle, recob::Slice, void * > PFParticleToSliceAssoc
 
typedef Association< recob::PFParticle, recob::Track, void * > PFParticleToTrackAssoc
 
typedef Association< recob::PFParticle, recob::Shower, void * > PFParticleToShowerAssoc
 
typedef Association< recob::PFParticle, recob::PCAxis, void * > PFParticleToPCAxisAssoc
 
typedef Association< recob::PFParticle, larpandoraobj::PFParticleMetadata, void * > PFParticleToPFParticleMetadataAssoc
 
typedef Association< recob::PFParticle, anab::T0, void * > PFParticleToT0Assoc
 
typedef Association< recob::Cluster, recob::Hit, void * > ClusterToHitAssoc
 
typedef Association< recob::SpacePoint, recob::Hit, void * > SpacePointToHitAssoc
 
typedef Association< recob::Slice, recob::Hit, void * > SliceToHitAssoc
 
typedef Association< recob::Track, recob::Hit, recob::TrackHitMetaTrackToHitAssoc
 
typedef Association< recob::Shower, recob::Hit, void * > ShowerToHitAssoc
 
typedef Association< recob::Shower, recob::PCAxis, void * > ShowerToPCAxisAssoc
 

Public Member Functions

 LArPandoraEvent (art::EDProducer *pProducer, art::Event *pEvent, const Labels &inputLabels, const bool shouldProduceT0s=false)
 Constructor from an art::Event. More...
 
 LArPandoraEvent (const LArPandoraEvent &event, const PFParticleVector &selectedPFParticles)
 Construct by copying an existing LArPandoraEvent, replacing the collections and associations by any objects associated with a PFParticle in the selection supplied. More...
 
void WriteToEvent () const
 Write (put) the collections in this LArPandoraEvent to the art::Event. More...
 

Private Member Functions

void GetCollections ()
 Get the collections and associations from m_pEvent with the required labels. More...
 
template<typename T >
void GetCollection (const Labels::LabelType &inputLabel, Collection< T > &outputCollection) const
 Gets a given collection from m_pEvent with the label supplied. More...
 
template<typename L , typename R , typename D >
void GetAssociationMap (const Collection< L > &collectionL, const Labels::LabelType &inputLabel, Association< L, R, D > &outputAssociationMap) const
 Get the mapping between two collections with metadata using the specified label. More...
 
template<typename L , typename R >
void GetAssociationMap (const Collection< L > &collectionL, const Labels::LabelType &inputLabel, Association< L, R, void * > &outputAssociationMap) const
 Get the mapping between two collections with metadata using the specified label. More...
 
template<typename L , typename R , typename D >
void CollectAssociated (const art::Ptr< L > &anObject, const Association< L, R, D > &associationLtoR, Collection< R > &associatedR) const
 Collects all objects of type R with metadata D associated to a given object of type L. More...
 
template<typename L , typename R , typename D >
void GetFilteredAssociationMap (const Collection< L > &collectionL, const Collection< R > &collectionR, const Association< L, R, D > &inputAssociationLtoR, Association< L, R, D > &outputAssociationLtoR) const
 Gets the filtered mapping from objects in collectionL to objects that also exist in collectionR using a "superset" input association. More...
 
template<typename T >
void WriteCollection (const Collection< T > &collection) const
 Write a given collection to the event. More...
 
template<typename L , typename R , typename D >
void WriteAssociation (const Association< L, R, D > &associationMap, const Collection< L > &collectionL, const Collection< R > &collectionR, const bool thisProducesR=true) const
 Write a given association to the event. More...
 
template<typename L , typename R >
void WriteAssociation (const Association< L, R, void * > &associationMap, const Collection< L > &collectionL, const Collection< R > &collectionR, const bool thisProducesR=true) const
 Write a given association to the event. More...
 
template<typename T >
size_t GetIndex (const art::Ptr< T > object, const Collection< T > &collection) const
 Get the index of an objet in a given collection. More...
 

Private Attributes

art::EDProducerm_pProducer
 The producer which should write the output collections and associations. More...
 
art::Eventm_pEvent
 The event to consider. More...
 
Labels m_labels
 A set of labels describing the producers for each input collection. More...
 
bool m_shouldProduceT0s
 If T0s should be produced (usually only true for use cases with multiple drift volumes) More...
 
PFParticleCollection m_pfParticles
 The input collection of PFParticles. More...
 
SpacePointCollection m_spacePoints
 The input collection of SpacePoints. More...
 
ClusterCollection m_clusters
 The input collection of Clusters. More...
 
VertexCollection m_vertices
 The input collection of Vertices. More...
 
SliceCollection m_slices
 The input collection of Slices. More...
 
TrackCollection m_tracks
 The input collection of Tracks. More...
 
ShowerCollection m_showers
 The input collection of Showers. More...
 
T0Collection m_t0s
 The input collection of T0s. More...
 
PFParticleMetadataCollection m_metadata
 The input collection of PFParticle metadata. More...
 
PCAxisCollection m_pcAxes
 The input collection of PCAxes. More...
 
HitCollection m_hits
 The input collection of Hits. More...
 
PFParticleToSpacePointAssoc m_pfParticleSpacePointMap
 The input associations: PFParticle -> SpacePoint. More...
 
PFParticleToClusterAssoc m_pfParticleClusterMap
 The input associations: PFParticle -> Cluster. More...
 
PFParticleToVertexAssoc m_pfParticleVertexMap
 The input associations: PFParticle -> Vertex. More...
 
PFParticleToSliceAssoc m_pfParticleSliceMap
 The input associations: PFParticle -> Slice. More...
 
PFParticleToTrackAssoc m_pfParticleTrackMap
 The input associations: PFParticle -> Track. More...
 
PFParticleToShowerAssoc m_pfParticleShowerMap
 The input associations: PFParticle -> Shower. More...
 
PFParticleToT0Assoc m_pfParticleT0Map
 The input associations: PFParticle -> T0. More...
 
PFParticleToPFParticleMetadataAssoc m_pfParticleMetadataMap
 The input associations: PFParticle -> Metadata. More...
 
PFParticleToPCAxisAssoc m_pfParticlePCAxisMap
 The input associations: PFParticle -> PCAxis. More...
 
SpacePointToHitAssoc m_spacePointHitMap
 The input associations: SpacePoint -> Hit. More...
 
ClusterToHitAssoc m_clusterHitMap
 The input associations: Cluster -> Hit. More...
 
SliceToHitAssoc m_sliceHitMap
 The input associations: Slice -> Hit. More...
 
TrackToHitAssoc m_trackHitMap
 The input associations: Track -> Hit. More...
 
ShowerToHitAssoc m_showerHitMap
 The input associations: Shower -> Hit. More...
 
ShowerToPCAxisAssoc m_showerPCAxisMap
 The input associations: PCAxis -> Shower. More...
 

Detailed Description

LArPandoraEvent class.

Definition at line 45 of file LArPandoraEvent.h.

Member Typedef Documentation

template<typename L , typename R , typename D >
using lar_pandora::LArPandoraEvent::Association = std::map<art::Ptr<L>, PairVector<R, D>>

General purpose short-hand with optional D parameter.

Definition at line 60 of file LArPandoraEvent.h.

template<typename T >
using lar_pandora::LArPandoraEvent::Collection = std::vector<art::Ptr<T>>

Shorthand for a collection of objects of type T.

Definition at line 51 of file LArPandoraEvent.h.

template<typename R , typename D >
using lar_pandora::LArPandoraEvent::PairVector = std::vector<std::pair<art::Ptr<R>, D>>

Definition at line 54 of file LArPandoraEvent.h.

Constructor & Destructor Documentation

lar_pandora::LArPandoraEvent::LArPandoraEvent ( art::EDProducer pProducer,
art::Event pEvent,
const Labels inputLabels,
const bool  shouldProduceT0s = false 
)

Constructor from an art::Event.

Parameters
pProducerpointer to the producer to write the output
pEventpointer to the event to process
inputLabellabels for the producers of the input collections
shouldProduceT0sif T0s should be produced (usually only for multiple drift volume use cases)

Definition at line 11 of file LArPandoraEvent.cxx.

References GetCollections().

15  : m_pProducer(pProducer)
16  , m_pEvent(pEvent)
17  , m_labels(inputLabels)
18  , m_shouldProduceT0s(shouldProduceT0s)
19  {
20  this->GetCollections();
21  }
void GetCollections()
Get the collections and associations from m_pEvent with the required labels.
art::Event * m_pEvent
The event to consider.
art::EDProducer * m_pProducer
The producer which should write the output collections and associations.
Labels m_labels
A set of labels describing the producers for each input collection.
bool m_shouldProduceT0s
If T0s should be produced (usually only true for use cases with multiple drift volumes) ...
lar_pandora::LArPandoraEvent::LArPandoraEvent ( const LArPandoraEvent event,
const PFParticleVector selectedPFParticles 
)

Construct by copying an existing LArPandoraEvent, replacing the collections and associations by any objects associated with a PFParticle in the selection supplied.

Parameters
eventinput event to copy and filter
pfParticleVectorinput vector of selected particles

Definition at line 25 of file LArPandoraEvent.cxx.

References CollectAssociated(), GetFilteredAssociationMap(), m_clusterHitMap, m_clusters, m_hits, m_metadata, m_pcAxes, m_pfParticleClusterMap, m_pfParticleMetadataMap, m_pfParticlePCAxisMap, m_pfParticles, m_pfParticleShowerMap, m_pfParticleSliceMap, m_pfParticleSpacePointMap, m_pfParticleT0Map, m_pfParticleTrackMap, m_pfParticleVertexMap, m_shouldProduceT0s, m_showerHitMap, m_showerPCAxisMap, m_showers, m_sliceHitMap, m_slices, m_spacePointHitMap, m_spacePoints, m_t0s, m_trackHitMap, m_tracks, m_vertices, and part.

27  : m_pProducer(event.m_pProducer)
28  , m_pEvent(event.m_pEvent)
29  , m_labels(event.m_labels)
30  , m_shouldProduceT0s(event.m_shouldProduceT0s)
31  , m_hits(event.m_hits)
32  {
33  m_pfParticles = selectedPFParticles;
34 
35  // Only collect objects associated to a selected particles
36  for (const auto& part : selectedPFParticles) {
37  this->CollectAssociated(part, event.m_pfParticleSpacePointMap, m_spacePoints);
38  this->CollectAssociated(part, event.m_pfParticleClusterMap, m_clusters);
39  this->CollectAssociated(part, event.m_pfParticleVertexMap, m_vertices);
40  this->CollectAssociated(part, event.m_pfParticleSliceMap, m_slices);
41  this->CollectAssociated(part, event.m_pfParticleTrackMap, m_tracks);
42  this->CollectAssociated(part, event.m_pfParticleShowerMap, m_showers);
43  this->CollectAssociated(part, event.m_pfParticlePCAxisMap, m_pcAxes);
44  this->CollectAssociated(part, event.m_pfParticleMetadataMap, m_metadata);
45 
46  if (m_shouldProduceT0s) this->CollectAssociated(part, event.m_pfParticleT0Map, m_t0s);
47  }
48 
49  // Filter the association maps from the input event to only include objects associated to the selected particles
51  m_pfParticles, m_spacePoints, event.m_pfParticleSpacePointMap, m_pfParticleSpacePointMap);
53  m_pfParticles, m_clusters, event.m_pfParticleClusterMap, m_pfParticleClusterMap);
55  m_pfParticles, m_vertices, event.m_pfParticleVertexMap, m_pfParticleVertexMap);
57  m_pfParticles, m_slices, event.m_pfParticleSliceMap, m_pfParticleSliceMap);
59  m_pfParticles, m_tracks, event.m_pfParticleTrackMap, m_pfParticleTrackMap);
61  m_pfParticles, m_showers, event.m_pfParticleShowerMap, m_pfParticleShowerMap);
63  m_pfParticles, m_pcAxes, event.m_pfParticlePCAxisMap, m_pfParticlePCAxisMap);
65  m_pfParticles, m_metadata, event.m_pfParticleMetadataMap, m_pfParticleMetadataMap);
67  m_spacePoints, event.m_hits, event.m_spacePointHitMap, m_spacePointHitMap);
69  m_clusters, event.m_hits, event.m_clusterHitMap, m_clusterHitMap);
70  this->GetFilteredAssociationMap(m_slices, event.m_hits, event.m_sliceHitMap, m_sliceHitMap);
71  this->GetFilteredAssociationMap(m_tracks, event.m_hits, event.m_trackHitMap, m_trackHitMap);
72  this->GetFilteredAssociationMap(m_showers, event.m_hits, event.m_showerHitMap, m_showerHitMap);
74  m_showers, m_pcAxes, event.m_showerPCAxisMap, m_showerPCAxisMap);
75 
78  m_pfParticles, m_t0s, event.m_pfParticleT0Map, m_pfParticleT0Map);
79  }
HitCollection m_hits
The input collection of Hits.
PFParticleToVertexAssoc m_pfParticleVertexMap
The input associations: PFParticle -> Vertex.
ClusterCollection m_clusters
The input collection of Clusters.
T0Collection m_t0s
The input collection of T0s.
SliceToHitAssoc m_sliceHitMap
The input associations: Slice -> Hit.
SpacePointToHitAssoc m_spacePointHitMap
The input associations: SpacePoint -> Hit.
PFParticleToTrackAssoc m_pfParticleTrackMap
The input associations: PFParticle -> Track.
PFParticleToClusterAssoc m_pfParticleClusterMap
The input associations: PFParticle -> Cluster.
PFParticleToPCAxisAssoc m_pfParticlePCAxisMap
The input associations: PFParticle -> PCAxis.
void GetFilteredAssociationMap(const Collection< L > &collectionL, const Collection< R > &collectionR, const Association< L, R, D > &inputAssociationLtoR, Association< L, R, D > &outputAssociationLtoR) const
Gets the filtered mapping from objects in collectionL to objects that also exist in collectionR using...
PCAxisCollection m_pcAxes
The input collection of PCAxes.
PFParticleCollection m_pfParticles
The input collection of PFParticles.
ClusterToHitAssoc m_clusterHitMap
The input associations: Cluster -> Hit.
void CollectAssociated(const art::Ptr< L > &anObject, const Association< L, R, D > &associationLtoR, Collection< R > &associatedR) const
Collects all objects of type R with metadata D associated to a given object of type L...
PFParticleToPFParticleMetadataAssoc m_pfParticleMetadataMap
The input associations: PFParticle -> Metadata.
TString part[npart]
Definition: Style.C:32
SpacePointCollection m_spacePoints
The input collection of SpacePoints.
ShowerToHitAssoc m_showerHitMap
The input associations: Shower -> Hit.
art::Event * m_pEvent
The event to consider.
PFParticleToT0Assoc m_pfParticleT0Map
The input associations: PFParticle -> T0.
PFParticleToSliceAssoc m_pfParticleSliceMap
The input associations: PFParticle -> Slice.
ShowerToPCAxisAssoc m_showerPCAxisMap
The input associations: PCAxis -> Shower.
art::EDProducer * m_pProducer
The producer which should write the output collections and associations.
TrackToHitAssoc m_trackHitMap
The input associations: Track -> Hit.
SliceCollection m_slices
The input collection of Slices.
PFParticleToShowerAssoc m_pfParticleShowerMap
The input associations: PFParticle -> Shower.
Labels m_labels
A set of labels describing the producers for each input collection.
VertexCollection m_vertices
The input collection of Vertices.
ShowerCollection m_showers
The input collection of Showers.
PFParticleMetadataCollection m_metadata
The input collection of PFParticle metadata.
Event finding and building.
TrackCollection m_tracks
The input collection of Tracks.
PFParticleToSpacePointAssoc m_pfParticleSpacePointMap
The input associations: PFParticle -> SpacePoint.
bool m_shouldProduceT0s
If T0s should be produced (usually only true for use cases with multiple drift volumes) ...

Member Function Documentation

template<typename L , typename R , typename D >
void lar_pandora::LArPandoraEvent::CollectAssociated ( const art::Ptr< L > &  anObject,
const Association< L, R, D > &  associationLtoR,
Collection< R > &  associatedR 
) const
inlineprivate

Collects all objects of type R with metadata D associated to a given object of type L.

Parameters
anObjectan input object of type L with which we want to collect associated objects of type R with metadata D
associationLtoRthe general input association between objects of type L and R
associatedRoutput vector of objects of type R associated with anObject

Definition at line 425 of file LArPandoraEvent.h.

Referenced by LArPandoraEvent().

428  {
429  if (associationLtoR.find(anObject) == associationLtoR.end())
430  throw cet::exception("LArPandora")
431  << " LArPandoraEvent::CollectAssociated -- Can not find association for object supplied."
432  << std::endl;
433 
434  for (const auto& entry : associationLtoR.at(anObject)) {
435  // Ensure we don't repeat objects in the output collection
436  if (std::find(associatedR.begin(), associatedR.end(), entry.first) == associatedR.end())
437  associatedR.push_back(entry.first);
438  }
439  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename L , typename R , typename D >
void lar_pandora::LArPandoraEvent::GetAssociationMap ( const Collection< L > &  collectionL,
const Labels::LabelType inputLabel,
Association< L, R, D > &  outputAssociationMap 
) const
inlineprivate

Get the mapping between two collections with metadata using the specified label.

Parameters
collectionLthe collection from which the associations should be retrieved
inputLabela label for the producer of the association required
outputAssociationMapoutput mapping between the two data types supplied (L -> R + D)

Definition at line 368 of file LArPandoraEvent.h.

Referenced by GetCollections().

371  {
372  const auto& assocHandle(
374 
375  // Check that there are no associaions from objects not in collectionL
376  for (const auto& entry : *assocHandle) {
377  auto it(std::find(collectionL.begin(), collectionL.end(), entry.first));
378  if (it == collectionL.end())
379  throw cet::exception("LArPandora") << " LArPandoraEvent::GetAssociationMap -- Found object "
380  "in association that isn't in the supplied collection"
381  << std::endl;
382  }
383 
384  // Ensure there is an entry for every object of type L
385  for (const auto& objectL : collectionL)
386  outputAssociationMap[objectL];
387 
388  // Fill the association map
389  for (const auto& entry : *assocHandle)
390  outputAssociationMap.at(entry.first).emplace_back(entry.second, *entry.data);
391  }
art::Event * m_pEvent
The event to consider.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Labels m_labels
A set of labels describing the producers for each input collection.
const std::string & GetLabel(const LabelType type) const
Get the label of a given type.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename L , typename R >
void lar_pandora::LArPandoraEvent::GetAssociationMap ( const Collection< L > &  collectionL,
const Labels::LabelType inputLabel,
Association< L, R, void * > &  outputAssociationMap 
) const
inlineprivate

Get the mapping between two collections with metadata using the specified label.

Parameters
collectionLthe collection from which the associations should be retrieved
inputLabela label for the producer of the association required
outputAssociationMapoutput mapping between the two data types supplied (L -> R no metadata)

Definition at line 396 of file LArPandoraEvent.h.

400  {
401  const auto& assocHandle(
403 
404  // Check that there are no associaions from objects not in collectionL
405  for (const auto& entry : *assocHandle) {
406  auto it(std::find(collectionL.begin(), collectionL.end(), entry.first));
407  if (it == collectionL.end())
408  throw cet::exception("LArPandora") << " LArPandoraEvent::GetAssociationMap -- Found object "
409  "in association that isn't in the supplied collection"
410  << std::endl;
411  }
412 
413  // Ensure there is an entry for every object of type L
414  for (const auto& objectL : collectionL)
415  outputAssociationMap[objectL];
416 
417  // Fill the association map
418  for (const auto& entry : *assocHandle)
419  outputAssociationMap.at(entry.first).emplace_back(entry.second, nullptr);
420  }
art::Event * m_pEvent
The event to consider.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Labels m_labels
A set of labels describing the producers for each input collection.
const std::string & GetLabel(const LabelType type) const
Get the label of a given type.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T >
void lar_pandora::LArPandoraEvent::GetCollection ( const Labels::LabelType inputLabel,
Collection< T > &  outputCollection 
) const
inlineprivate

Gets a given collection from m_pEvent with the label supplied.

Parameters
inputLabela label for the producer of the collection required
outputCollectionthe required collection

Definition at line 356 of file LArPandoraEvent.h.

Referenced by GetCollections().

358  {
359  const auto& handle(m_pEvent->getValidHandle<std::vector<T>>(m_labels.GetLabel(inputLabel)));
360 
361  for (unsigned int i = 0; i != handle->size(); i++)
362  outputCollection.emplace_back(handle, i);
363  }
art::Event * m_pEvent
The event to consider.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Labels m_labels
A set of labels describing the producers for each input collection.
const std::string & GetLabel(const LabelType type) const
Get the label of a given type.
void lar_pandora::LArPandoraEvent::GetCollections ( )
private

Get the collections and associations from m_pEvent with the required labels.

Definition at line 118 of file LArPandoraEvent.cxx.

References lar_pandora::LArPandoraEvent::Labels::ClusterLabel, lar_pandora::LArPandoraEvent::Labels::ClusterToHitLabel, GetAssociationMap(), GetCollection(), lar_pandora::LArPandoraEvent::Labels::HitLabel, m_clusterHitMap, m_clusters, m_hits, m_metadata, m_pcAxes, m_pfParticleClusterMap, m_pfParticleMetadataMap, m_pfParticlePCAxisMap, m_pfParticles, m_pfParticleShowerMap, m_pfParticleSliceMap, m_pfParticleSpacePointMap, m_pfParticleT0Map, m_pfParticleTrackMap, m_pfParticleVertexMap, m_shouldProduceT0s, m_showerHitMap, m_showerPCAxisMap, m_showers, m_sliceHitMap, m_slices, m_spacePointHitMap, m_spacePoints, m_t0s, m_trackHitMap, m_tracks, m_vertices, lar_pandora::LArPandoraEvent::Labels::PCAxisLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleMetadataLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleToClusterLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleToMetadataLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleToPCAxisLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleToShowerLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleToSliceLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleToSpacePointLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleToT0Label, lar_pandora::LArPandoraEvent::Labels::PFParticleToTrackLabel, lar_pandora::LArPandoraEvent::Labels::PFParticleToVertexLabel, lar_pandora::LArPandoraEvent::Labels::ShowerLabel, lar_pandora::LArPandoraEvent::Labels::ShowerToHitLabel, lar_pandora::LArPandoraEvent::Labels::ShowerToPCAxisLabel, lar_pandora::LArPandoraEvent::Labels::SliceLabel, lar_pandora::LArPandoraEvent::Labels::SliceToHitLabel, lar_pandora::LArPandoraEvent::Labels::SpacePointLabel, lar_pandora::LArPandoraEvent::Labels::SpacePointToHitLabel, lar_pandora::LArPandoraEvent::Labels::T0Label, lar_pandora::LArPandoraEvent::Labels::TrackLabel, lar_pandora::LArPandoraEvent::Labels::TrackToHitLabel, and lar_pandora::LArPandoraEvent::Labels::VertexLabel.

Referenced by LArPandoraEvent().

119  {
130 
131  this->GetAssociationMap(
133  this->GetAssociationMap(
140  this->GetAssociationMap(
148 
149  if (m_shouldProduceT0s) {
152  }
153  }
HitCollection m_hits
The input collection of Hits.
PFParticleToVertexAssoc m_pfParticleVertexMap
The input associations: PFParticle -> Vertex.
ClusterCollection m_clusters
The input collection of Clusters.
T0Collection m_t0s
The input collection of T0s.
SliceToHitAssoc m_sliceHitMap
The input associations: Slice -> Hit.
SpacePointToHitAssoc m_spacePointHitMap
The input associations: SpacePoint -> Hit.
PFParticleToTrackAssoc m_pfParticleTrackMap
The input associations: PFParticle -> Track.
PFParticleToClusterAssoc m_pfParticleClusterMap
The input associations: PFParticle -> Cluster.
PFParticleToPCAxisAssoc m_pfParticlePCAxisMap
The input associations: PFParticle -> PCAxis.
PCAxisCollection m_pcAxes
The input collection of PCAxes.
PFParticleCollection m_pfParticles
The input collection of PFParticles.
ClusterToHitAssoc m_clusterHitMap
The input associations: Cluster -> Hit.
PFParticleToPFParticleMetadataAssoc m_pfParticleMetadataMap
The input associations: PFParticle -> Metadata.
SpacePointCollection m_spacePoints
The input collection of SpacePoints.
ShowerToHitAssoc m_showerHitMap
The input associations: Shower -> Hit.
PFParticleToT0Assoc m_pfParticleT0Map
The input associations: PFParticle -> T0.
PFParticleToSliceAssoc m_pfParticleSliceMap
The input associations: PFParticle -> Slice.
void GetAssociationMap(const Collection< L > &collectionL, const Labels::LabelType &inputLabel, Association< L, R, D > &outputAssociationMap) const
Get the mapping between two collections with metadata using the specified label.
ShowerToPCAxisAssoc m_showerPCAxisMap
The input associations: PCAxis -> Shower.
TrackToHitAssoc m_trackHitMap
The input associations: Track -> Hit.
SliceCollection m_slices
The input collection of Slices.
PFParticleToShowerAssoc m_pfParticleShowerMap
The input associations: PFParticle -> Shower.
void GetCollection(const Labels::LabelType &inputLabel, Collection< T > &outputCollection) const
Gets a given collection from m_pEvent with the label supplied.
VertexCollection m_vertices
The input collection of Vertices.
ShowerCollection m_showers
The input collection of Showers.
PFParticleMetadataCollection m_metadata
The input collection of PFParticle metadata.
TrackCollection m_tracks
The input collection of Tracks.
PFParticleToSpacePointAssoc m_pfParticleSpacePointMap
The input associations: PFParticle -> SpacePoint.
bool m_shouldProduceT0s
If T0s should be produced (usually only true for use cases with multiple drift volumes) ...
template<typename L , typename R , typename D >
void lar_pandora::LArPandoraEvent::GetFilteredAssociationMap ( const Collection< L > &  collectionL,
const Collection< R > &  collectionR,
const Association< L, R, D > &  inputAssociationLtoR,
Association< L, R, D > &  outputAssociationLtoR 
) const
inlineprivate

Gets the filtered mapping from objects in collectionL to objects that also exist in collectionR using a "superset" input association.

Parameters
collectionLa first filtered collection
collectionRa second filtered collection
inputAssociationLtoRmapping between the two unfiltered collections
outputAssociationLtoRmapping between the two filtered collections
Returns
mapping between the filtered collections

Definition at line 444 of file LArPandoraEvent.h.

Referenced by LArPandoraEvent().

449  {
450  for (const auto& objectL : collectionL) {
451  if (inputAssociationLtoR.find(objectL) == inputAssociationLtoR.end())
452  throw cet::exception("LArPandora")
453  << " LArPandoraEvent::GetFilteredAssociationMap -- Can not find association for object "
454  "in supplied collection."
455  << std::endl;
456 
457  if (outputAssociationLtoR.find(objectL) != outputAssociationLtoR.end())
458  throw cet::exception("LArPandora")
459  << " LArPandoraEvent::GetFilteredAssociationMap -- Repeated objects in input collectionL"
460  << std::endl;
461 
462  for (const auto& entry : inputAssociationLtoR.at(objectL)) {
463  if (std::find(collectionR.begin(), collectionR.end(), entry.first) == collectionR.end())
464  continue;
465 
466  outputAssociationLtoR[objectL].push_back(entry);
467  }
468  }
469  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T >
size_t lar_pandora::LArPandoraEvent::GetIndex ( const art::Ptr< T >  object,
const Collection< T > &  collection 
) const
inlineprivate

Get the index of an objet in a given collection.

Parameters
objectthe object to search for
collectionthe collection to search through
Returns
the index of the object in the collection

Definition at line 562 of file LArPandoraEvent.h.

564  {
565  const auto it(std::find(collection.begin(), collection.end(), object));
566  if (it == collection.end())
567  throw cet::exception("LArPandora")
568  << " LArPandoraEvent::GetIndex -- Can't find input object in the supplied collection."
569  << std::endl;
570 
571  return static_cast<size_t>(std::distance(collection.begin(), it));
572  }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename L , typename R , typename D >
void lar_pandora::LArPandoraEvent::WriteAssociation ( const Association< L, R, D > &  associationMap,
const Collection< L > &  collectionL,
const Collection< R > &  collectionR,
const bool  thisProducesR = true 
) const
inlineprivate

Write a given association to the event.

Parameters
associationMapthe association to write from objects of type L -> R + D
collectionLthe collection of type L that has been written
collectionRthe collection of type R that has been written
thisProducesRwill this producer produce collectionR of was it produced by a different module?

Definition at line 487 of file LArPandoraEvent.h.

Referenced by WriteToEvent().

491  {
492  // The output assocation to populate
493  std::unique_ptr<art::Assns<L, R, D>> outputAssn(new art::Assns<L, R, D>);
494 
495  // NB. The art::Ptrs in the stored collections refer to the producer that originally created the objects (e.g. Pandora pat-rec). To make
496  // correct associations, we need to make new art::Ptrs to refer to the *copies* of the objects made by this producer. This is done using
497  // the PtrMaker utility.
498  const art::PtrMaker<L> makePtrL(*m_pEvent);
499 
500  for (auto it = associationMap.begin(); it != associationMap.end(); ++it) {
501  const auto indexL(this->GetIndex(it->first, collectionL));
502  const auto outputPtrL(makePtrL(indexL));
503 
504  for (const auto& entry : it->second) {
505  const auto& objectR(entry.first);
506  const auto& objectD(entry.second);
507 
508  if (thisProducesR) {
509  const art::PtrMaker<R> makePtrR(*m_pEvent);
510  const auto indexR(this->GetIndex(objectR, collectionR));
511  outputAssn->addSingle(outputPtrL, makePtrR(indexR), objectD);
512  }
513  else {
514  outputAssn->addSingle(outputPtrL, objectR, objectD);
515  }
516  }
517  }
518 
519  m_pEvent->put(std::move(outputAssn));
520  }
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
art::Event * m_pEvent
The event to consider.
size_t GetIndex(const art::Ptr< T > object, const Collection< T > &collection) const
Get the index of an objet in a given collection.
template<typename L , typename R >
void lar_pandora::LArPandoraEvent::WriteAssociation ( const Association< L, R, void * > &  associationMap,
const Collection< L > &  collectionL,
const Collection< R > &  collectionR,
const bool  thisProducesR = true 
) const
inlineprivate

Write a given association to the event.

Parameters
associationMapthe association to write from objects of type L -> R (no metadata)
collectionLthe collection of type L that has been written
collectionRthe collection of type R that has been written
thisProducesRwill this producer produce collectionR of was it produced by a different module?

Definition at line 525 of file LArPandoraEvent.h.

529  {
530  // The output assocation to populate
531  std::unique_ptr<art::Assns<L, R>> outputAssn(new art::Assns<L, R>);
532 
533  // NB. The art::Ptrs in the stored collections refer to the producer that originally created the objects (e.g. Pandora pat-rec). To make
534  // correct associations, we need to make new art::Ptrs to refer to the *copies* of the objects made by this producer. This is done using
535  // the PtrMaker utility.
536  const art::PtrMaker<L> makePtrL(*m_pEvent);
537 
538  for (auto it = associationMap.begin(); it != associationMap.end(); ++it) {
539  const auto indexL(this->GetIndex(it->first, collectionL));
540  const auto outputPtrL(makePtrL(indexL));
541 
542  for (const auto& entry : it->second) {
543  const auto& objectR(entry.first);
544 
545  if (thisProducesR) {
546  const art::PtrMaker<R> makePtrR(*m_pEvent);
547  const auto indexR(this->GetIndex(objectR, collectionR));
548  outputAssn->addSingle(outputPtrL, makePtrR(indexR));
549  }
550  else {
551  outputAssn->addSingle(outputPtrL, objectR);
552  }
553  }
554  }
555 
556  m_pEvent->put(std::move(outputAssn));
557  }
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
art::Event * m_pEvent
The event to consider.
size_t GetIndex(const art::Ptr< T > object, const Collection< T > &collection) const
Get the index of an objet in a given collection.
template<typename T >
void lar_pandora::LArPandoraEvent::WriteCollection ( const Collection< T > &  collection) const
inlineprivate

Write a given collection to the event.

Parameters
collectionthe collection to write

Definition at line 474 of file LArPandoraEvent.h.

Referenced by WriteToEvent().

475  {
476  std::unique_ptr<std::vector<T>> output(new std::vector<T>);
477 
478  for (const auto& object : collection)
479  output->push_back(*object);
480 
481  m_pEvent->put(std::move(output));
482  }
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
art::Event * m_pEvent
The event to consider.
void lar_pandora::LArPandoraEvent::WriteToEvent ( ) const

Write (put) the collections in this LArPandoraEvent to the art::Event.

Definition at line 83 of file LArPandoraEvent.cxx.

References m_clusterHitMap, m_clusters, m_hits, m_metadata, m_pcAxes, m_pfParticleClusterMap, m_pfParticleMetadataMap, m_pfParticlePCAxisMap, m_pfParticles, m_pfParticleShowerMap, m_pfParticleSliceMap, m_pfParticleSpacePointMap, m_pfParticleT0Map, m_pfParticleTrackMap, m_pfParticleVertexMap, m_shouldProduceT0s, m_showerHitMap, m_showerPCAxisMap, m_showers, m_sliceHitMap, m_slices, m_spacePointHitMap, m_spacePoints, m_t0s, m_trackHitMap, m_tracks, m_vertices, WriteAssociation(), and WriteCollection().

Referenced by lar_pandora::CollectionSplitting::produce(), and lar_pandora::LArPandoraExternalEventBuilding::produce().

84  {
94 
109 
110  if (m_shouldProduceT0s) {
111  this->WriteCollection(m_t0s);
113  }
114  }
HitCollection m_hits
The input collection of Hits.
void WriteAssociation(const Association< L, R, D > &associationMap, const Collection< L > &collectionL, const Collection< R > &collectionR, const bool thisProducesR=true) const
Write a given association to the event.
PFParticleToVertexAssoc m_pfParticleVertexMap
The input associations: PFParticle -> Vertex.
ClusterCollection m_clusters
The input collection of Clusters.
T0Collection m_t0s
The input collection of T0s.
SliceToHitAssoc m_sliceHitMap
The input associations: Slice -> Hit.
SpacePointToHitAssoc m_spacePointHitMap
The input associations: SpacePoint -> Hit.
PFParticleToTrackAssoc m_pfParticleTrackMap
The input associations: PFParticle -> Track.
PFParticleToClusterAssoc m_pfParticleClusterMap
The input associations: PFParticle -> Cluster.
PFParticleToPCAxisAssoc m_pfParticlePCAxisMap
The input associations: PFParticle -> PCAxis.
PCAxisCollection m_pcAxes
The input collection of PCAxes.
PFParticleCollection m_pfParticles
The input collection of PFParticles.
ClusterToHitAssoc m_clusterHitMap
The input associations: Cluster -> Hit.
PFParticleToPFParticleMetadataAssoc m_pfParticleMetadataMap
The input associations: PFParticle -> Metadata.
SpacePointCollection m_spacePoints
The input collection of SpacePoints.
ShowerToHitAssoc m_showerHitMap
The input associations: Shower -> Hit.
PFParticleToT0Assoc m_pfParticleT0Map
The input associations: PFParticle -> T0.
PFParticleToSliceAssoc m_pfParticleSliceMap
The input associations: PFParticle -> Slice.
ShowerToPCAxisAssoc m_showerPCAxisMap
The input associations: PCAxis -> Shower.
TrackToHitAssoc m_trackHitMap
The input associations: Track -> Hit.
SliceCollection m_slices
The input collection of Slices.
PFParticleToShowerAssoc m_pfParticleShowerMap
The input associations: PFParticle -> Shower.
void WriteCollection(const Collection< T > &collection) const
Write a given collection to the event.
VertexCollection m_vertices
The input collection of Vertices.
ShowerCollection m_showers
The input collection of Showers.
PFParticleMetadataCollection m_metadata
The input collection of PFParticle metadata.
TrackCollection m_tracks
The input collection of Tracks.
PFParticleToSpacePointAssoc m_pfParticleSpacePointMap
The input associations: PFParticle -> SpacePoint.
bool m_shouldProduceT0s
If T0s should be produced (usually only true for use cases with multiple drift volumes) ...

Member Data Documentation

ClusterToHitAssoc lar_pandora::LArPandoraEvent::m_clusterHitMap
private

The input associations: Cluster -> Hit.

Definition at line 346 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

ClusterCollection lar_pandora::LArPandoraEvent::m_clusters
private

The input collection of Clusters.

Definition at line 319 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

HitCollection lar_pandora::LArPandoraEvent::m_hits
private

The input collection of Hits.

Definition at line 327 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

Labels lar_pandora::LArPandoraEvent::m_labels
private

A set of labels describing the producers for each input collection.

Definition at line 312 of file LArPandoraEvent.h.

Referenced by lar_pandora::LArPandoraEvent::Labels::GetLabel(), lar_pandora::LArPandoraEvent::Labels::Labels(), and lar_pandora::LArPandoraEvent::Labels::SetLabel().

PFParticleMetadataCollection lar_pandora::LArPandoraEvent::m_metadata
private

The input collection of PFParticle metadata.

Definition at line 325 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PCAxisCollection lar_pandora::LArPandoraEvent::m_pcAxes
private

The input collection of PCAxes.

Definition at line 326 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

art::Event* lar_pandora::LArPandoraEvent::m_pEvent
private

The event to consider.

Definition at line 311 of file LArPandoraEvent.h.

PFParticleToClusterAssoc lar_pandora::LArPandoraEvent::m_pfParticleClusterMap
private

The input associations: PFParticle -> Cluster.

Definition at line 333 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PFParticleToPFParticleMetadataAssoc lar_pandora::LArPandoraEvent::m_pfParticleMetadataMap
private

The input associations: PFParticle -> Metadata.

Definition at line 342 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PFParticleToPCAxisAssoc lar_pandora::LArPandoraEvent::m_pfParticlePCAxisMap
private

The input associations: PFParticle -> PCAxis.

Definition at line 344 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PFParticleCollection lar_pandora::LArPandoraEvent::m_pfParticles
private

The input collection of PFParticles.

Definition at line 317 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PFParticleToShowerAssoc lar_pandora::LArPandoraEvent::m_pfParticleShowerMap
private

The input associations: PFParticle -> Shower.

Definition at line 339 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PFParticleToSliceAssoc lar_pandora::LArPandoraEvent::m_pfParticleSliceMap
private

The input associations: PFParticle -> Slice.

Definition at line 336 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PFParticleToSpacePointAssoc lar_pandora::LArPandoraEvent::m_pfParticleSpacePointMap
private

The input associations: PFParticle -> SpacePoint.

Definition at line 331 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PFParticleToT0Assoc lar_pandora::LArPandoraEvent::m_pfParticleT0Map
private

The input associations: PFParticle -> T0.

Definition at line 340 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PFParticleToTrackAssoc lar_pandora::LArPandoraEvent::m_pfParticleTrackMap
private

The input associations: PFParticle -> Track.

Definition at line 337 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

PFParticleToVertexAssoc lar_pandora::LArPandoraEvent::m_pfParticleVertexMap
private

The input associations: PFParticle -> Vertex.

Definition at line 335 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

art::EDProducer* lar_pandora::LArPandoraEvent::m_pProducer
private

The producer which should write the output collections and associations.

Definition at line 310 of file LArPandoraEvent.h.

bool lar_pandora::LArPandoraEvent::m_shouldProduceT0s
private

If T0s should be produced (usually only true for use cases with multiple drift volumes)

Definition at line 314 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

ShowerToHitAssoc lar_pandora::LArPandoraEvent::m_showerHitMap
private

The input associations: Shower -> Hit.

Definition at line 349 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

ShowerToPCAxisAssoc lar_pandora::LArPandoraEvent::m_showerPCAxisMap
private

The input associations: PCAxis -> Shower.

Definition at line 350 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

ShowerCollection lar_pandora::LArPandoraEvent::m_showers
private

The input collection of Showers.

Definition at line 323 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

SliceToHitAssoc lar_pandora::LArPandoraEvent::m_sliceHitMap
private

The input associations: Slice -> Hit.

Definition at line 347 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

SliceCollection lar_pandora::LArPandoraEvent::m_slices
private

The input collection of Slices.

Definition at line 321 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

SpacePointToHitAssoc lar_pandora::LArPandoraEvent::m_spacePointHitMap
private

The input associations: SpacePoint -> Hit.

Definition at line 345 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

SpacePointCollection lar_pandora::LArPandoraEvent::m_spacePoints
private

The input collection of SpacePoints.

Definition at line 318 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

T0Collection lar_pandora::LArPandoraEvent::m_t0s
private

The input collection of T0s.

Definition at line 324 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

TrackToHitAssoc lar_pandora::LArPandoraEvent::m_trackHitMap
private

The input associations: Track -> Hit.

Definition at line 348 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

TrackCollection lar_pandora::LArPandoraEvent::m_tracks
private

The input collection of Tracks.

Definition at line 322 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().

VertexCollection lar_pandora::LArPandoraEvent::m_vertices
private

The input collection of Vertices.

Definition at line 320 of file LArPandoraEvent.h.

Referenced by GetCollections(), LArPandoraEvent(), and WriteToEvent().


The documentation for this class was generated from the following files: