7 #ifndef LAR_PANDORA_EVENT_H 8 #define LAR_PANDORA_EVENT_H 1 53 template <
typename R,
typename D>
54 using PairVector = std::vector<std::pair<art::Ptr<R>, D>>;
59 template <
typename L,
typename R,
typename D>
135 Labels(
const std::string& pfParticleProducerLabel,
const std::string& hitProducerLabel);
142 Labels(
const std::string& pfParticleProducerLabel,
143 const std::string& trackProducerLabel,
144 const std::string& showerProducerLabel,
145 const std::string& hitProducerLabel);
162 void SetLabel(
const LabelType type,
const std::string& label);
178 const Labels& inputLabels,
179 const bool shouldProduceT0s =
false);
193 void WriteToEvent()
const;
199 void GetCollections();
207 template <
typename T>
217 template <
typename L,
typename R,
typename D>
229 template <
typename L,
typename R>
241 template <
typename L,
typename R,
typename D>
242 void CollectAssociated(
const art::Ptr<L>& anObject,
256 template <
typename L,
typename R,
typename D>
257 void GetFilteredAssociationMap(
const Collection<L>& collectionL,
267 template <
typename T>
278 template <
typename L,
typename R,
typename D>
282 const bool thisProducesR =
true)
const;
292 template <
typename L,
typename R>
296 const bool thisProducesR =
true)
const;
306 template <
typename T>
330 PFParticleToSpacePointAssoc
332 PFParticleToClusterAssoc
334 PFParticleToVertexAssoc
338 PFParticleToShowerAssoc
343 PFParticleToPCAxisAssoc
355 template <
typename T>
359 const auto& handle(m_pEvent->getValidHandle<std::vector<T>>(m_labels.GetLabel(inputLabel)));
361 for (
unsigned int i = 0; i != handle->size(); i++)
362 outputCollection.emplace_back(handle, i);
367 template <
typename L,
typename R,
typename D>
368 inline void LArPandoraEvent::GetAssociationMap(
const Collection<L>& collectionL,
372 const auto& assocHandle(
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" 385 for (
const auto& objectL : collectionL)
386 outputAssociationMap[objectL];
389 for (
const auto& entry : *assocHandle)
390 outputAssociationMap.at(entry.first).emplace_back(entry.second, *entry.data);
395 template <
typename L,
typename R>
396 inline void LArPandoraEvent::GetAssociationMap(
401 const auto& assocHandle(
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" 414 for (
const auto& objectL : collectionL)
415 outputAssociationMap[objectL];
418 for (
const auto& entry : *assocHandle)
419 outputAssociationMap.at(entry.first).emplace_back(entry.second,
nullptr);
424 template <
typename L,
typename R,
typename D>
425 inline void LArPandoraEvent::CollectAssociated(
const art::Ptr<L>& anObject,
429 if (associationLtoR.find(anObject) == associationLtoR.end())
431 <<
" LArPandoraEvent::CollectAssociated -- Can not find association for object supplied." 434 for (
const auto& entry : associationLtoR.at(anObject)) {
436 if (std::find(associatedR.begin(), associatedR.end(), entry.first) == associatedR.end())
437 associatedR.push_back(entry.first);
443 template <
typename L,
typename R,
typename D>
444 inline void LArPandoraEvent::GetFilteredAssociationMap(
450 for (
const auto& objectL : collectionL) {
451 if (inputAssociationLtoR.find(objectL) == inputAssociationLtoR.end())
453 <<
" LArPandoraEvent::GetFilteredAssociationMap -- Can not find association for object " 454 "in supplied collection." 457 if (outputAssociationLtoR.find(objectL) != outputAssociationLtoR.end())
459 <<
" LArPandoraEvent::GetFilteredAssociationMap -- Repeated objects in input collectionL" 462 for (
const auto& entry : inputAssociationLtoR.at(objectL)) {
463 if (std::find(collectionR.begin(), collectionR.end(), entry.first) == collectionR.end())
466 outputAssociationLtoR[objectL].push_back(entry);
473 template <
typename T>
474 inline void LArPandoraEvent::WriteCollection(
const Collection<T>& collection)
const 476 std::unique_ptr<std::vector<T>> output(
new std::vector<T>);
478 for (
const auto&
object : collection)
479 output->push_back(*
object);
481 m_pEvent->put(std::move(output));
486 template <
typename L,
typename R,
typename D>
490 const bool thisProducesR)
const 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));
504 for (
const auto& entry : it->second) {
505 const auto& objectR(entry.first);
506 const auto& objectD(entry.second);
510 const auto indexR(this->GetIndex(objectR, collectionR));
511 outputAssn->addSingle(outputPtrL, makePtrR(indexR), objectD);
514 outputAssn->addSingle(outputPtrL, objectR, objectD);
519 m_pEvent->put(std::move(outputAssn));
524 template <
typename L,
typename R>
528 const bool thisProducesR)
const 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));
542 for (
const auto& entry : it->second) {
543 const auto& objectR(entry.first);
547 const auto indexR(this->GetIndex(objectR, collectionR));
548 outputAssn->addSingle(outputPtrL, makePtrR(indexR));
551 outputAssn->addSingle(outputPtrL, objectR);
556 m_pEvent->put(std::move(outputAssn));
561 template <
typename T>
565 const auto it(std::find(collection.begin(), collection.end(), object));
566 if (it == collection.end())
568 <<
" LArPandoraEvent::GetIndex -- Can't find input object in the supplied collection." 571 return static_cast<size_t>(std::distance(collection.begin(), it));
576 #endif // #ifndef LAR_PANDORA_EVENT_H
Association< recob::PFParticle, recob::PCAxis, void * > PFParticleToPCAxisAssoc
HitCollection m_hits
The input collection of Hits.
PFParticleToVertexAssoc m_pfParticleVertexMap
The input associations: PFParticle -> Vertex.
Collection< recob::Cluster > ClusterCollection
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.
Declaration of signal hit object.
LabelType
Label type enumeration.
Association< recob::Cluster, recob::Hit, void * > ClusterToHitAssoc
Association< recob::PFParticle, recob::SpacePoint, void * > PFParticleToSpacePointAssoc
PFParticleToTrackAssoc m_pfParticleTrackMap
The input associations: PFParticle -> Track.
Collection< larpandoraobj::PFParticleMetadata > PFParticleMetadataCollection
PFParticleToClusterAssoc m_pfParticleClusterMap
The input associations: PFParticle -> Cluster.
PFParticleToPCAxisAssoc m_pfParticlePCAxisMap
The input associations: PFParticle -> PCAxis.
Association< recob::Shower, recob::PCAxis, void * > ShowerToPCAxisAssoc
Association< recob::PFParticle, recob::Track, void * > PFParticleToTrackAssoc
PCAxisCollection m_pcAxes
The input collection of PCAxes.
PFParticleCollection m_pfParticles
The input collection of PFParticles.
ClusterToHitAssoc m_clusterHitMap
The input associations: Cluster -> Hit.
Association< recob::Slice, recob::Hit, void * > SliceToHitAssoc
Collection< recob::PCAxis > PCAxisCollection
Association< recob::Track, recob::Hit, recob::TrackHitMeta > TrackToHitAssoc
PFParticleToPFParticleMetadataAssoc m_pfParticleMetadataMap
The input associations: PFParticle -> Metadata.
Collection< recob::SpacePoint > SpacePointCollection
Collection< recob::Hit > HitCollection
SpacePointCollection m_spacePoints
The input collection of SpacePoints.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
ShowerToHitAssoc m_showerHitMap
The input associations: Shower -> Hit.
Association< recob::PFParticle, anab::T0, void * > PFParticleToT0Assoc
std::vector< art::Ptr< T >> Collection
Shorthand for a collection of objects of type T.
Collection< anab::T0 > T0Collection
Provides recob::Track data product.
Association< recob::SpacePoint, recob::Hit, void * > SpacePointToHitAssoc
art::Event * m_pEvent
The event to consider.
PFParticleToT0Assoc m_pfParticleT0Map
The input associations: PFParticle -> T0.
Association< recob::PFParticle, recob::Shower, void * > PFParticleToShowerAssoc
Declaration of cluster object.
Association< recob::PFParticle, recob::Vertex, void * > PFParticleToVertexAssoc
Association< recob::PFParticle, larpandoraobj::PFParticleMetadata, void * > PFParticleToPFParticleMetadataAssoc
Collection< recob::Slice > SliceCollection
Collection< recob::Shower > ShowerCollection
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.
Association< recob::Shower, recob::Hit, void * > ShowerToHitAssoc
Association< recob::PFParticle, recob::Cluster, void * > PFParticleToClusterAssoc
Class to handle the required producer labels.
TrackToHitAssoc m_trackHitMap
The input associations: Track -> Hit.
std::vector< std::pair< art::Ptr< R >, D >> PairVector
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.
std::map< art::Ptr< L >, PairVector< R, D >> Association
General purpose short-hand with optional D parameter.
Collection< recob::PFParticle > PFParticleCollection
Collection< recob::Vertex > VertexCollection
VertexCollection m_vertices
The input collection of Vertices.
helper function for LArPandoraInterface producer module
ShowerCollection m_showers
The input collection of Showers.
PFParticleMetadataCollection m_metadata
The input collection of PFParticle metadata.
cet::coded_exception< error, detail::translate > exception
Event finding and building.
TrackCollection m_tracks
The input collection of Tracks.
Collection< recob::Track > TrackCollection
Association< recob::PFParticle, recob::Slice, void * > PFParticleToSliceAssoc
std::map< LabelType, std::string > m_labels
Map holding the labels.
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) ...