7 #ifndef LAR_PANDORA_EVENT_H 8 #define LAR_PANDORA_EVENT_H 1 51 template <
typename R,
typename D>
52 using PairVector = std::vector< std::pair< art::Ptr<R>,
D > >;
57 template <
typename L,
typename R,
typename D>
201 template <
typename T>
211 template <
typename L,
typename R,
typename D>
222 template <
typename L,
typename R>
233 template <
typename L,
typename R,
typename D>
246 template <
typename L,
typename R,
typename D>
255 template <
typename T>
266 template <
typename L,
typename R,
typename D>
268 const bool thisProducesR =
true)
const;
278 template <
typename L,
typename R>
280 const bool thisProducesR =
true)
const;
331 template <
typename T>
336 for (
unsigned int i = 0; i != handle->size(); i++)
337 outputCollection.emplace_back(handle, i);
342 template <
typename L,
typename R,
typename D>
349 for (
const auto &
entry : *assocHandle)
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;
357 for (
const auto &objectL : collectionL)
358 outputAssociationMap[objectL];
361 for (
const auto &
entry : *assocHandle)
367 template <
typename L,
typename R>
374 for (
const auto &
entry : *assocHandle)
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;
382 for (
const auto &objectL : collectionL)
383 outputAssociationMap[objectL];
386 for (
const auto &
entry : *assocHandle)
387 outputAssociationMap.at(
entry.
first).emplace_back(
entry.second,
nullptr);
392 template <
typename L,
typename R,
typename D>
396 if (associationLtoR.find(anObject) == associationLtoR.end())
397 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::CollectAssociated -- Can not find association for object supplied." <<
std::endl;
399 for (
const auto &
entry : associationLtoR.at(anObject))
402 if (std::find(associatedR.begin(), associatedR.end(),
entry.
first) == associatedR.end())
409 template <
typename L,
typename R,
typename D>
413 for (
const auto &objectL : collectionL)
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;
418 if (outputAssociationLtoR.find(objectL) != outputAssociationLtoR.end())
419 throw cet::exception(
"LArPandora") <<
" LArPandoraEvent::GetFilteredAssociationMap -- Repeated objects in input collectionL" <<
std::endl;
421 for (
const auto &
entry : inputAssociationLtoR.at(objectL))
423 if (std::find(collectionR.begin(), collectionR.end(),
entry.
first) == collectionR.end())
426 outputAssociationLtoR[objectL].push_back(
entry);
433 template <
typename T>
436 std::unique_ptr<std::vector<T> >
output(
new std::vector<T>);
438 for (
const auto &
object : collection)
439 output->push_back(*
object);
446 template <
typename L,
typename R,
typename D>
448 const Collection<R> &collectionR,
const bool thisProducesR)
const 458 for (
auto it = associationMap.begin(); it != associationMap.end(); ++it)
460 const auto indexL(this->
GetIndex(it->first, collectionL));
461 const auto outputPtrL(makePtrL(indexL));
463 for (
const auto &
entry : it->second)
466 const auto &objectD(
entry.second);
471 const auto indexR(this->
GetIndex(objectR, collectionR));
472 outputAssn->addSingle(outputPtrL, makePtrR(indexR), objectD);
476 outputAssn->addSingle(outputPtrL, objectR, objectD);
486 template <
typename L,
typename R>
488 const Collection<R> &collectionR,
const bool thisProducesR)
const 498 for (
auto it = associationMap.begin(); it != associationMap.end(); ++it)
500 const auto indexL(this->
GetIndex(it->first, collectionL));
501 const auto outputPtrL(makePtrL(indexL));
503 for (
const auto &
entry : it->second)
510 const auto indexR(this->
GetIndex(objectR, collectionR));
511 outputAssn->addSingle(outputPtrL, makePtrR(indexR));
515 outputAssn->addSingle(outputPtrL, objectR);
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;
532 return static_cast<size_t>(
std::distance(collection.begin(), it));
537 #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.
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 objets 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
QCollection::Item first()
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
Collection< anab::T0 > T0Collection
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Association< recob::SpacePoint, recob::Hit, void * > SpacePointToHitAssoc
art::Event * m_pEvent
The event to consider.
PFParticleToT0Assoc m_pfParticleT0Map
The input associations: PFParticle -> T0.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
Association< recob::PFParticle, recob::Shower, void * > PFParticleToShowerAssoc
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.
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.
Declaration of signal hit object.
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.
Provides recob::Track data product.
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.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Event finding and building.
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.