7 #ifndef LAR_PANDORA_EVENT_H
8 #define LAR_PANDORA_EVENT_H 1
29 #include "art/Framework/Principal/Event.h"
30 #include "art/Persistency/Common/PtrMaker.h"
31 #include "canvas/Persistency/Common/Assns.h"
32 #include "canvas/Persistency/Common/Ptr.h"
55 template <
typename R,
typename D>
56 using PairVector = std::vector< std::pair< art::Ptr<R>, D > >;
61 template <
typename L,
typename R,
typename D>
138 Labels(
const std::string &pfParticleProducerLabel,
const std::string &hitProducerLabel);
145 Labels(
const std::string &pfParticleProducerLabel,
const std::string &trackProducerLabel,
const std::string &showerProducerLabel,
146 const std::string &hitProducerLabel);
177 LArPandoraEvent(art::EDProducer *pProducer, art::Event *pEvent,
const Labels &inputLabels,
const bool shouldProduceT0s =
false);
205 template <
typename T>
215 template <
typename L,
typename R,
typename D>
226 template <
typename L,
typename R>
237 template <
typename L,
typename R,
typename D>
250 template <
typename L,
typename R,
typename D>
259 template <
typename T>
270 template <
typename L,
typename R,
typename D>
272 const bool thisProducesR =
true)
const;
282 template <
typename L,
typename R>
284 const bool thisProducesR =
true)
const;
335 template <
typename T>
340 for (
unsigned int i = 0; i != handle->size(); i++)
341 outputCollection.emplace_back(handle, i);
346 template <
typename L,
typename R,
typename D>
353 for (
const auto &entry : *assocHandle)
355 auto it(std::find(collectionL.begin(), collectionL.end(), entry.first));
356 if (it == collectionL.end())
357 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetAssociationMap -- Found object in association that isn't in the supplied collection" << std::endl;
361 for (
const auto &objectL : collectionL)
362 outputAssociationMap[objectL];
365 for (
const auto &entry : *assocHandle)
366 outputAssociationMap.at(entry.first).emplace_back(entry.second, *entry.data);
371 template <
typename L,
typename R>
378 for (
const auto &entry : *assocHandle)
380 auto it(std::find(collectionL.begin(), collectionL.end(), entry.first));
381 if (it == collectionL.end())
382 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetAssociationMap -- Found object in association that isn't in the supplied collection" << std::endl;
386 for (
const auto &objectL : collectionL)
387 outputAssociationMap[objectL];
390 for (
const auto &entry : *assocHandle)
391 outputAssociationMap.at(entry.first).emplace_back(entry.second,
nullptr);
396 template <
typename L,
typename R,
typename D>
400 if (associationLtoR.find(anObject) == associationLtoR.end())
401 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::CollectAssociated -- Can not find association for object supplied." << std::endl;
403 for (
const auto &entry : associationLtoR.at(anObject))
406 if (std::find(associatedR.begin(), associatedR.end(), entry.first) == associatedR.end())
407 associatedR.push_back(entry.first);
413 template <
typename L,
typename R,
typename D>
417 for (
const auto &objectL : collectionL)
419 if (inputAssociationLtoR.find(objectL) == inputAssociationLtoR.end())
420 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetFilteredAssociationMap -- Can not find association for object in supplied collection." << std::endl;
422 if (outputAssociationLtoR.find(objectL) != outputAssociationLtoR.end())
423 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetFilteredAssociationMap -- Repeated objects in input collectionL" << std::endl;
425 for (
const auto &entry : inputAssociationLtoR.at(objectL))
427 if (std::find(collectionR.begin(), collectionR.end(), entry.first) == collectionR.end())
430 outputAssociationLtoR[objectL].push_back(entry);
437 template <
typename T>
440 std::unique_ptr<std::vector<T> >
output(
new std::vector<T>);
442 for (
const auto &
object : collection)
443 output->push_back(*
object);
450 template <
typename L,
typename R,
typename D>
452 const Collection<R> &collectionR,
const bool thisProducesR)
const
455 std::unique_ptr<art::Assns<L, R, D> > outputAssn(
new art::Assns<L, R, D>);
460 const art::PtrMaker<L> makePtrL(*
m_pEvent);
462 for (
auto it = associationMap.begin(); it != associationMap.end(); ++it)
464 const auto indexL(this->
GetIndex(it->first, collectionL));
465 const auto outputPtrL(makePtrL(indexL));
467 for (
const auto &entry : it->second)
469 const auto &objectR(entry.first);
470 const auto &objectD(entry.second);
474 const art::PtrMaker<R> makePtrR(*
m_pEvent);
475 const auto indexR(this->
GetIndex(objectR, collectionR));
476 outputAssn->addSingle(outputPtrL, makePtrR(indexR), objectD);
480 outputAssn->addSingle(outputPtrL, objectR, objectD);
485 m_pEvent->put(std::move(outputAssn));
490 template <
typename L,
typename R>
492 const Collection<R> &collectionR,
const bool thisProducesR)
const
495 std::unique_ptr<art::Assns<L, R> > outputAssn(
new art::Assns<L, R>);
500 const art::PtrMaker<L> makePtrL(*
m_pEvent);
502 for (
auto it = associationMap.begin(); it != associationMap.end(); ++it)
504 const auto indexL(this->
GetIndex(it->first, collectionL));
505 const auto outputPtrL(makePtrL(indexL));
507 for (
const auto &entry : it->second)
509 const auto &objectR(entry.first);
513 const art::PtrMaker<R> makePtrR(*
m_pEvent);
514 const auto indexR(this->
GetIndex(objectR, collectionR));
515 outputAssn->addSingle(outputPtrL, makePtrR(indexR));
519 outputAssn->addSingle(outputPtrL, objectR);
524 m_pEvent->put(std::move(outputAssn));
532 const auto it(std::find(collection.begin(), collection.end(), object));
533 if (it == collection.end())
534 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetIndex -- Can't find input object in the supplied collection." << std::endl;
536 return static_cast<size_t>(
std::distance(collection.begin(), it));
541 #endif // #ifndef LAR_PANDORA_EVENT_H
Association< recob::PFParticle, recob::PCAxis, void * > PFParticleToPCAxisAssoc
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.
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.
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...
Association< recob::Shower, recob::PCAxis, void * > ShowerToPCAxisAssoc
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.
Association< recob::PFParticle, recob::Track, void * > PFParticleToTrackAssoc
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 -> Hit.
std::vector< art::Ptr< T > > Collection
Shorthand for a collection of objects of type T.
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...
Association< recob::Slice, recob::Hit, void * > SliceToHitAssoc
Collection< recob::PCAxis > PCAxisCollection
std::vector< std::pair< art::Ptr< R >, D > > PairVector
Association< recob::Track, recob::Hit, recob::TrackHitMeta > TrackToHitAssoc
PFParticleToPFParticleMetadataAssoc m_pfParticleMetadataMap
The input associations: PFParticle -> Metadata.
Collection< recob::SpacePoint > SpacePointCollection
Collection< recob::Hit > HitCollection
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
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
Collection< anab::T0 > T0Collection
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
Provides recob::Track data product.
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.
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.
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
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.
std::map< art::Ptr< L >, PairVector< R, D > > Association
General purpose short-hand with optional D parameter.
void GetCollection(const Labels::LabelType &inputLabel, Collection< T > &outputCollection) const
Gets a given collection from m_pEvent with the label supplied.
Collection< recob::PFParticle > PFParticleCollection
Collection< recob::Vertex > VertexCollection
void WriteCollection(const Collection< T > &collection) const
Write a given collection to the event.
VertexCollection m_vertices
The input collection of Vertices.
helper function for LArPandoraInterface producer module
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.
Collection< recob::Track > TrackCollection
size_t GetIndex(const art::Ptr< T > object, const Collection< T > &collection) const
Get the index of an objet in a given collection.
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) ...
void WriteToEvent() const
Write (put) the collections in this LArPandoraEvent to the art::Event.