All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LArPandoraEvent.cxx
Go to the documentation of this file.
1 /**
2  * @file larpandora/LArPandoraEventBuilding/LArPandoraEvent.cxx
3  *
4  * @brief A description of all outputs from an instance of pandora with functionality to filter outputs
5  */
6 
8 
9 namespace lar_pandora
10 {
11 
12 LArPandoraEvent::LArPandoraEvent(art::EDProducer *pProducer, art::Event *pEvent, const Labels &inputLabels, const bool shouldProduceT0s) :
13  m_pProducer(pProducer),
14  m_pEvent(pEvent),
15  m_labels(inputLabels),
16  m_shouldProduceT0s(shouldProduceT0s)
17 {
18  this->GetCollections();
19 }
20 
21 //------------------------------------------------------------------------------------------------------------------------------------------
22 
23 LArPandoraEvent::LArPandoraEvent(const LArPandoraEvent &event, const PFParticleVector &selectedPFParticles) :
24  m_pProducer(event.m_pProducer),
25  m_pEvent(event.m_pEvent),
26  m_labels(event.m_labels),
27  m_shouldProduceT0s(event.m_shouldProduceT0s),
28  m_hits(event.m_hits)
29 {
30  m_pfParticles = selectedPFParticles;
31 
32  // Only collect objects associated to a selected particles
33  for (const auto &part : selectedPFParticles)
34  {
43 
45  this->CollectAssociated(part, event.m_pfParticleT0Map, m_t0s);
46  }
47 
48  // Filter the association maps from the input event to only include objects associated to the selected particles
63 
66 }
67 
68 //------------------------------------------------------------------------------------------------------------------------------------------
69 
71 {
81 
96 
98  {
99  this->WriteCollection(m_t0s);
101  }
102 }
103 
104 //------------------------------------------------------------------------------------------------------------------------------------------
105 
107 {
118 
133 
134  if (m_shouldProduceT0s)
135  {
138  }
139 }
140 
141 //------------------------------------------------------------------------------------------------------------------------------------------
142 //------------------------------------------------------------------------------------------------------------------------------------------
143 
144 LArPandoraEvent::Labels::Labels(const std::string &pfParticleProducerLabel, const std::string &hitProducerLabel)
145 {
146  m_labels.emplace(PFParticleLabel, pfParticleProducerLabel);
147  m_labels.emplace(SpacePointLabel, pfParticleProducerLabel);
148  m_labels.emplace(ClusterLabel, pfParticleProducerLabel);
149  m_labels.emplace(VertexLabel, pfParticleProducerLabel);
150  m_labels.emplace(SliceLabel, pfParticleProducerLabel);
151  m_labels.emplace(TrackLabel, pfParticleProducerLabel);
152  m_labels.emplace(ShowerLabel, pfParticleProducerLabel);
153  m_labels.emplace(T0Label, pfParticleProducerLabel);
154  m_labels.emplace(PFParticleMetadataLabel, pfParticleProducerLabel);
155  m_labels.emplace(PCAxisLabel, pfParticleProducerLabel);
156  m_labels.emplace(HitLabel, hitProducerLabel);
157 
158  m_labels.emplace(PFParticleToSpacePointLabel, pfParticleProducerLabel);
159  m_labels.emplace(PFParticleToClusterLabel, pfParticleProducerLabel);
160  m_labels.emplace(PFParticleToVertexLabel, pfParticleProducerLabel);
161  m_labels.emplace(PFParticleToSliceLabel, pfParticleProducerLabel);
162  m_labels.emplace(PFParticleToTrackLabel, pfParticleProducerLabel);
163  m_labels.emplace(PFParticleToShowerLabel, pfParticleProducerLabel);
164  m_labels.emplace(PFParticleToT0Label, pfParticleProducerLabel);
165  m_labels.emplace(PFParticleToMetadataLabel, pfParticleProducerLabel);
166  m_labels.emplace(PFParticleToPCAxisLabel, pfParticleProducerLabel);
167  m_labels.emplace(SpacePointToHitLabel, pfParticleProducerLabel);
168  m_labels.emplace(ClusterToHitLabel, pfParticleProducerLabel);
169  m_labels.emplace(SliceToHitLabel, pfParticleProducerLabel);
170  m_labels.emplace(TrackToHitLabel, pfParticleProducerLabel);
171  m_labels.emplace(ShowerToHitLabel, pfParticleProducerLabel);
172  m_labels.emplace(ShowerToPCAxisLabel, pfParticleProducerLabel);
173 }
174 
175 //------------------------------------------------------------------------------------------------------------------------------------------
176 
177 LArPandoraEvent::Labels::Labels(const std::string &pfParticleProducerLabel, const std::string &trackProducerLabel, const std::string &showerProducerLabel,
178  const std::string &hitProducerLabel)
179 {
180  m_labels.emplace(PFParticleLabel, pfParticleProducerLabel);
181  m_labels.emplace(SpacePointLabel, pfParticleProducerLabel);
182  m_labels.emplace(ClusterLabel, pfParticleProducerLabel);
183  m_labels.emplace(VertexLabel, pfParticleProducerLabel);
184  m_labels.emplace(SliceLabel, pfParticleProducerLabel);
185  m_labels.emplace(TrackLabel, trackProducerLabel);
186  m_labels.emplace(ShowerLabel, showerProducerLabel);
187  m_labels.emplace(T0Label, pfParticleProducerLabel);
188  m_labels.emplace(PFParticleMetadataLabel, pfParticleProducerLabel);
189  m_labels.emplace(PCAxisLabel, showerProducerLabel);
190  m_labels.emplace(HitLabel, hitProducerLabel);
191 
192  m_labels.emplace(PFParticleToSpacePointLabel, pfParticleProducerLabel);
193  m_labels.emplace(PFParticleToClusterLabel, pfParticleProducerLabel);
194  m_labels.emplace(PFParticleToVertexLabel, pfParticleProducerLabel);
195  m_labels.emplace(PFParticleToSliceLabel, pfParticleProducerLabel);
196  m_labels.emplace(PFParticleToTrackLabel, trackProducerLabel);
197  m_labels.emplace(PFParticleToShowerLabel, showerProducerLabel);
198  m_labels.emplace(PFParticleToT0Label, pfParticleProducerLabel);
199  m_labels.emplace(PFParticleToMetadataLabel, pfParticleProducerLabel);
200  m_labels.emplace(PFParticleToPCAxisLabel, showerProducerLabel);
201  m_labels.emplace(SpacePointToHitLabel, pfParticleProducerLabel);
202  m_labels.emplace(ClusterToHitLabel, pfParticleProducerLabel);
203  m_labels.emplace(SliceToHitLabel, pfParticleProducerLabel);
204  m_labels.emplace(TrackToHitLabel, trackProducerLabel);
205  m_labels.emplace(ShowerToHitLabel, showerProducerLabel);
206  m_labels.emplace(ShowerToPCAxisLabel, showerProducerLabel);
207 }
208 
209 //------------------------------------------------------------------------------------------------------------------------------------------
210 
211 const std::string & LArPandoraEvent::Labels::GetLabel(const LabelType type) const
212 {
213  if (m_labels.find(type) == m_labels.end())
214  throw cet::exception("LArPandora") << " LArPandoraEvent::GetLabel -- Label map doesn't contain label of requested type" << std::endl;
215 
216  return m_labels.at(type);
217 }
218 
219 //------------------------------------------------------------------------------------------------------------------------------------------
220 
221 void LArPandoraEvent::Labels::SetLabel(const LabelType type, const std::string &label)
222 {
223  m_labels[type] = label;
224 }
225 
226 } // namespace lar_pandora
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 -&gt; Vertex.
LArPandoraEvent class.
ClusterCollection m_clusters
The input collection of Clusters.
T0Collection m_t0s
The input collection of T0s.
SliceToHitAssoc m_sliceHitMap
The input associations: Slice -&gt; Hit.
SpacePointToHitAssoc m_spacePointHitMap
The input associations: SpacePoint -&gt; Hit.
PFParticleToTrackAssoc m_pfParticleTrackMap
The input associations: PFParticle -&gt; Track.
PFParticleToClusterAssoc m_pfParticleClusterMap
The input associations: PFParticle -&gt; Cluster.
PFParticleToPCAxisAssoc m_pfParticlePCAxisMap
The input associations: PFParticle -&gt; 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...
void SetLabel(const LabelType type, const std::string &label)
Set the label of a given type.
LArPandoraEvent(art::EDProducer *pProducer, art::Event *pEvent, const Labels &inputLabels, const bool shouldProduceT0s=false)
Constructor from an art::Event.
PCAxisCollection m_pcAxes
The input collection of PCAxes.
PFParticleCollection m_pfParticles
The input collection of PFParticles.
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 GetCollections()
Get the collections and associations from m_pEvent with the required labels.
ClusterToHitAssoc m_clusterHitMap
The input associations: Cluster -&gt; 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 -&gt; Metadata.
A description of all outputs from an instance of pandora with functionality to filter and merge multi...
SpacePointCollection m_spacePoints
The input collection of SpacePoints.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
ShowerToHitAssoc m_showerHitMap
The input associations: Shower -&gt; Hit.
PFParticleToT0Assoc m_pfParticleT0Map
The input associations: PFParticle -&gt; T0.
PFParticleToSliceAssoc m_pfParticleSliceMap
The input associations: PFParticle -&gt; 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 -&gt; Shower.
Class to handle the required producer labels.
TrackToHitAssoc m_trackHitMap
The input associations: Track -&gt; Hit.
SliceCollection m_slices
The input collection of Slices.
PFParticleToShowerAssoc m_pfParticleShowerMap
The input associations: PFParticle -&gt; Shower.
Labels m_labels
A set of labels describing the producers for each input collection.
BEGIN_PROLOG pandoraTrackGausCryoW PFParticleLabel
void GetCollection(const Labels::LabelType &inputLabel, Collection< T > &outputCollection) const
Gets a given collection from m_pEvent with the label supplied.
void WriteCollection(const Collection< T > &collection) const
Write a given collection to the event.
VertexCollection m_vertices
The input collection of Vertices.
const std::string & GetLabel(const LabelType type) const
Get the label of a given type.
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.
std::map< LabelType, std::string > m_labels
Map holding the labels.
PFParticleToSpacePointAssoc m_pfParticleSpacePointMap
The input associations: PFParticle -&gt; SpacePoint.
bool m_shouldProduceT0s
If T0s should be produced (usually only true for use cases with multiple drift volumes) ...
void WriteToEvent() const
Write (put) the collections in this LArPandoraEvent to the art::Event.