Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 objets 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 42 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 58 of file LArPandoraEvent.h.

Definition at line 63 of file LArPandoraEvent.h.

Definition at line 84 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 49 of file LArPandoraEvent.h.

Definition at line 61 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 52 of file LArPandoraEvent.h.

Definition at line 69 of file LArPandoraEvent.h.

Definition at line 62 of file LArPandoraEvent.h.

Definition at line 70 of file LArPandoraEvent.h.

Definition at line 74 of file LArPandoraEvent.h.

Definition at line 80 of file LArPandoraEvent.h.

Definition at line 81 of file LArPandoraEvent.h.

Definition at line 79 of file LArPandoraEvent.h.

Definition at line 77 of file LArPandoraEvent.h.

Definition at line 75 of file LArPandoraEvent.h.

Definition at line 82 of file LArPandoraEvent.h.

Definition at line 78 of file LArPandoraEvent.h.

Definition at line 76 of file LArPandoraEvent.h.

Definition at line 68 of file LArPandoraEvent.h.

Definition at line 88 of file LArPandoraEvent.h.

Definition at line 89 of file LArPandoraEvent.h.

Definition at line 66 of file LArPandoraEvent.h.

Definition at line 86 of file LArPandoraEvent.h.

Definition at line 64 of file LArPandoraEvent.h.

Definition at line 85 of file LArPandoraEvent.h.

Definition at line 71 of file LArPandoraEvent.h.

Definition at line 67 of file LArPandoraEvent.h.

Definition at line 87 of file LArPandoraEvent.h.

Definition at line 65 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 14 of file LArPandoraEvent.cxx.

14  :
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.

25  :
26  m_pProducer(event.m_pProducer),
27  m_pEvent(event.m_pEvent),
28  m_labels(event.m_labels),
29  m_shouldProduceT0s(event.m_shouldProduceT0s),
30  m_hits(event.m_hits)
31 {
32  m_pfParticles = selectedPFParticles;
33 
34  // Only collect objects associated to a selected particles
35  for (const auto &part : selectedPFParticles)
36  {
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 
47  this->CollectAssociated(part, event.m_pfParticleT0Map, m_t0s);
48  }
49 
50  // Filter the association maps from the input event to only include objects associated to the selected particles
59  this->GetFilteredAssociationMap(m_spacePoints, event.m_hits, event.m_spacePointHitMap, m_spacePointHitMap);
60  this->GetFilteredAssociationMap(m_clusters, event.m_hits, event.m_clusterHitMap, m_clusterHitMap);
61  this->GetFilteredAssociationMap(m_slices, event.m_hits, event.m_sliceHitMap, m_sliceHitMap);
62  this->GetFilteredAssociationMap(m_tracks, event.m_hits, event.m_trackHitMap, m_trackHitMap);
63  this->GetFilteredAssociationMap(m_showers, event.m_hits, event.m_showerHitMap, m_showerHitMap);
65 
68 }
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 objets 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.
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 393 of file LArPandoraEvent.h.

395 {
396  if (associationLtoR.find(anObject) == associationLtoR.end())
397  throw cet::exception("LArPandora") << " LArPandoraEvent::CollectAssociated -- Can not find association for object supplied." << std::endl;
398 
399  for (const auto &entry : associationLtoR.at(anObject))
400  {
401  // Ensure we don't repeat objects in the output collection
402  if (std::find(associatedR.begin(), associatedR.end(), entry.first) == associatedR.end())
403  associatedR.push_back(entry.first);
404  }
405 }
QList< Entry > entry
type * at(uint i) const
Definition: qlist.h:94
QCollection::Item first()
Definition: qglist.cpp:807
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
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 343 of file LArPandoraEvent.h.

345 {
346  const auto &assocHandle(m_pEvent->getValidHandle<art::Assns<L, R, D> >(m_labels.GetLabel(inputLabel)));
347 
348  // Check that there are no associaions from objects not in collectionL
349  for (const auto &entry : *assocHandle)
350  {
351  auto it(std::find(collectionL.begin(), collectionL.end(), entry.first));
352  if (it == collectionL.end())
353  throw cet::exception("LArPandora") << " LArPandoraEvent::GetAssociationMap -- Found object in association that isn't in the supplied collection" << std::endl;
354  }
355 
356  // Ensure there is an entry for every object of type L
357  for (const auto &objectL : collectionL)
358  outputAssociationMap[objectL];
359 
360  // Fill the association map
361  for (const auto &entry : *assocHandle)
362  outputAssociationMap.at(entry.first).emplace_back(entry.second, *entry.data);
363 }
QList< Entry > entry
QCollection::Item first()
Definition: qglist.cpp:807
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
art::Event * m_pEvent
The event to consider.
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
QTextStream & endl(QTextStream &s)
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 368 of file LArPandoraEvent.h.

370 {
371  const auto &assocHandle(m_pEvent->getValidHandle<art::Assns<L, R> >(m_labels.GetLabel(inputLabel)));
372 
373  // Check that there are no associaions from objects not in collectionL
374  for (const auto &entry : *assocHandle)
375  {
376  auto it(std::find(collectionL.begin(), collectionL.end(), entry.first));
377  if (it == collectionL.end())
378  throw cet::exception("LArPandora") << " LArPandoraEvent::GetAssociationMap -- Found object in association that isn't in the supplied collection" << std::endl;
379  }
380 
381  // Ensure there is an entry for every object of type L
382  for (const auto &objectL : collectionL)
383  outputAssociationMap[objectL];
384 
385  // Fill the association map
386  for (const auto &entry : *assocHandle)
387  outputAssociationMap.at(entry.first).emplace_back(entry.second, nullptr);
388 }
QList< Entry > entry
QCollection::Item first()
Definition: qglist.cpp:807
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
art::Event * m_pEvent
The event to consider.
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
QTextStream & endl(QTextStream &s)
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 332 of file LArPandoraEvent.h.

333 {
334  const auto &handle(m_pEvent->getValidHandle<std::vector<T> >(m_labels.GetLabel(inputLabel)));
335 
336  for (unsigned int i = 0; i != handle->size(); i++)
337  outputCollection.emplace_back(handle, i);
338 }
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
art::Event * m_pEvent
The event to consider.
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 108 of file LArPandoraEvent.cxx.

109 {
120 
135 
136  if (m_shouldProduceT0s)
137  {
140  }
141 }
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 objets 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 410 of file LArPandoraEvent.h.

412 {
413  for (const auto &objectL : collectionL)
414  {
415  if (inputAssociationLtoR.find(objectL) == inputAssociationLtoR.end())
416  throw cet::exception("LArPandora") << " LArPandoraEvent::GetFilteredAssociationMap -- Can not find association for object in supplied collection." << std::endl;
417 
418  if (outputAssociationLtoR.find(objectL) != outputAssociationLtoR.end())
419  throw cet::exception("LArPandora") << " LArPandoraEvent::GetFilteredAssociationMap -- Repeated objects in input collectionL" << std::endl;
420 
421  for (const auto &entry : inputAssociationLtoR.at(objectL))
422  {
423  if (std::find(collectionR.begin(), collectionR.end(), entry.first) == collectionR.end())
424  continue;
425 
426  outputAssociationLtoR[objectL].push_back(entry);
427  }
428  }
429 }
QList< Entry > entry
type * at(uint i) const
Definition: qlist.h:94
QCollection::Item first()
Definition: qglist.cpp:807
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
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 526 of file LArPandoraEvent.h.

527 {
528  const auto it(std::find(collection.begin(), collection.end(), object));
529  if (it == collection.end())
530  throw cet::exception("LArPandora") << " LArPandoraEvent::GetIndex -- Can't find input object in the supplied collection." << std::endl;
531 
532  return static_cast<size_t>(std::distance(collection.begin(), it));
533 }
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
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 447 of file LArPandoraEvent.h.

449 {
450  // The output assocation to populate
451  std::unique_ptr<art::Assns<L, R, D> > outputAssn(new art::Assns<L, R, D>);
452 
453  // NB. The art::Ptrs in the stored collections refer to the producer that originally created the objects (e.g. Pandora pat-rec). To make
454  // 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
455  // the PtrMaker utility.
456  const art::PtrMaker<L> makePtrL(*m_pEvent);
457 
458  for (auto it = associationMap.begin(); it != associationMap.end(); ++it)
459  {
460  const auto indexL(this->GetIndex(it->first, collectionL));
461  const auto outputPtrL(makePtrL(indexL));
462 
463  for (const auto &entry : it->second)
464  {
465  const auto &objectR(entry.first);
466  const auto &objectD(entry.second);
467 
468  if (thisProducesR)
469  {
470  const art::PtrMaker<R> makePtrR(*m_pEvent);
471  const auto indexR(this->GetIndex(objectR, collectionR));
472  outputAssn->addSingle(outputPtrL, makePtrR(indexR), objectD);
473  }
474  else
475  {
476  outputAssn->addSingle(outputPtrL, objectR, objectD);
477  }
478  }
479  }
480 
481  m_pEvent->put(std::move(outputAssn));
482 }
QList< Entry > entry
QCollection::Item first()
Definition: qglist.cpp:807
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
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 487 of file LArPandoraEvent.h.

489 {
490  // The output assocation to populate
491  std::unique_ptr<art::Assns<L, R> > outputAssn(new art::Assns<L, R>);
492 
493  // NB. The art::Ptrs in the stored collections refer to the producer that originally created the objects (e.g. Pandora pat-rec). To make
494  // 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
495  // the PtrMaker utility.
496  const art::PtrMaker<L> makePtrL(*m_pEvent);
497 
498  for (auto it = associationMap.begin(); it != associationMap.end(); ++it)
499  {
500  const auto indexL(this->GetIndex(it->first, collectionL));
501  const auto outputPtrL(makePtrL(indexL));
502 
503  for (const auto &entry : it->second)
504  {
505  const auto &objectR(entry.first);
506 
507  if (thisProducesR)
508  {
509  const art::PtrMaker<R> makePtrR(*m_pEvent);
510  const auto indexR(this->GetIndex(objectR, collectionR));
511  outputAssn->addSingle(outputPtrL, makePtrR(indexR));
512  }
513  else
514  {
515  outputAssn->addSingle(outputPtrL, objectR);
516  }
517  }
518  }
519 
520  m_pEvent->put(std::move(outputAssn));
521 }
QList< Entry > entry
QCollection::Item first()
Definition: qglist.cpp:807
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
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 434 of file LArPandoraEvent.h.

435 {
436  std::unique_ptr<std::vector<T> > output(new std::vector<T>);
437 
438  for (const auto &object : collection)
439  output->push_back(*object);
440 
442 }
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
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 72 of file LArPandoraEvent.cxx.

73 {
83 
98 
100  {
101  this->WriteCollection(m_t0s);
103  }
104 }
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 322 of file LArPandoraEvent.h.

ClusterCollection lar_pandora::LArPandoraEvent::m_clusters
private

The input collection of Clusters.

Definition at line 301 of file LArPandoraEvent.h.

HitCollection lar_pandora::LArPandoraEvent::m_hits
private

The input collection of Hits.

Definition at line 309 of file LArPandoraEvent.h.

Labels lar_pandora::LArPandoraEvent::m_labels
private

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

Definition at line 295 of file LArPandoraEvent.h.

PFParticleMetadataCollection lar_pandora::LArPandoraEvent::m_metadata
private

The input collection of PFParticle metadata.

Definition at line 307 of file LArPandoraEvent.h.

PCAxisCollection lar_pandora::LArPandoraEvent::m_pcAxes
private

The input collection of PCAxes.

Definition at line 308 of file LArPandoraEvent.h.

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

The event to consider.

Definition at line 294 of file LArPandoraEvent.h.

PFParticleToClusterAssoc lar_pandora::LArPandoraEvent::m_pfParticleClusterMap
private

The input associations: PFParticle -> Cluster.

Definition at line 313 of file LArPandoraEvent.h.

PFParticleToPFParticleMetadataAssoc lar_pandora::LArPandoraEvent::m_pfParticleMetadataMap
private

The input associations: PFParticle -> Metadata.

Definition at line 319 of file LArPandoraEvent.h.

PFParticleToPCAxisAssoc lar_pandora::LArPandoraEvent::m_pfParticlePCAxisMap
private

The input associations: PFParticle -> PCAxis.

Definition at line 320 of file LArPandoraEvent.h.

PFParticleCollection lar_pandora::LArPandoraEvent::m_pfParticles
private

The input collection of PFParticles.

Definition at line 299 of file LArPandoraEvent.h.

PFParticleToShowerAssoc lar_pandora::LArPandoraEvent::m_pfParticleShowerMap
private

The input associations: PFParticle -> Shower.

Definition at line 317 of file LArPandoraEvent.h.

PFParticleToSliceAssoc lar_pandora::LArPandoraEvent::m_pfParticleSliceMap
private

The input associations: PFParticle -> Slice.

Definition at line 315 of file LArPandoraEvent.h.

PFParticleToSpacePointAssoc lar_pandora::LArPandoraEvent::m_pfParticleSpacePointMap
private

The input associations: PFParticle -> SpacePoint.

Definition at line 312 of file LArPandoraEvent.h.

PFParticleToT0Assoc lar_pandora::LArPandoraEvent::m_pfParticleT0Map
private

The input associations: PFParticle -> T0.

Definition at line 318 of file LArPandoraEvent.h.

PFParticleToTrackAssoc lar_pandora::LArPandoraEvent::m_pfParticleTrackMap
private

The input associations: PFParticle -> Track.

Definition at line 316 of file LArPandoraEvent.h.

PFParticleToVertexAssoc lar_pandora::LArPandoraEvent::m_pfParticleVertexMap
private

The input associations: PFParticle -> Vertex.

Definition at line 314 of file LArPandoraEvent.h.

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

The producer which should write the output collections and associations.

Definition at line 293 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 296 of file LArPandoraEvent.h.

ShowerToHitAssoc lar_pandora::LArPandoraEvent::m_showerHitMap
private

The input associations: Shower -> Hit.

Definition at line 325 of file LArPandoraEvent.h.

ShowerToPCAxisAssoc lar_pandora::LArPandoraEvent::m_showerPCAxisMap
private

The input associations: PCAxis -> Shower.

Definition at line 326 of file LArPandoraEvent.h.

ShowerCollection lar_pandora::LArPandoraEvent::m_showers
private

The input collection of Showers.

Definition at line 305 of file LArPandoraEvent.h.

SliceToHitAssoc lar_pandora::LArPandoraEvent::m_sliceHitMap
private

The input associations: Slice -> Hit.

Definition at line 323 of file LArPandoraEvent.h.

SliceCollection lar_pandora::LArPandoraEvent::m_slices
private

The input collection of Slices.

Definition at line 303 of file LArPandoraEvent.h.

SpacePointToHitAssoc lar_pandora::LArPandoraEvent::m_spacePointHitMap
private

The input associations: SpacePoint -> Hit.

Definition at line 321 of file LArPandoraEvent.h.

SpacePointCollection lar_pandora::LArPandoraEvent::m_spacePoints
private

The input collection of SpacePoints.

Definition at line 300 of file LArPandoraEvent.h.

T0Collection lar_pandora::LArPandoraEvent::m_t0s
private

The input collection of T0s.

Definition at line 306 of file LArPandoraEvent.h.

TrackToHitAssoc lar_pandora::LArPandoraEvent::m_trackHitMap
private

The input associations: Track -> Hit.

Definition at line 324 of file LArPandoraEvent.h.

TrackCollection lar_pandora::LArPandoraEvent::m_tracks
private

The input collection of Tracks.

Definition at line 304 of file LArPandoraEvent.h.

VertexCollection lar_pandora::LArPandoraEvent::m_vertices
private

The input collection of Vertices.

Definition at line 302 of file LArPandoraEvent.h.


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