7#ifndef LAR_PANDORA_OUTPUT_H
8#define LAR_PANDORA_OUTPUT_H
10#include "art/Persistency/Common/PtrMaker.h"
11#include "lardata/Utilities/AssociationUtil.h"
15 class PFParticleMetadata;
19 class ClusterParamsAlgBase;
25#include "lardataobj/AnalysisBase/T0.h"
26#include "lardataobj/RecoBase/Cluster.h"
27#include "lardataobj/RecoBase/PFParticle.h"
28#include "lardataobj/RecoBase/PFParticleMetadata.h"
29#include "lardataobj/RecoBase/Slice.h"
30#include "lardataobj/RecoBase/SpacePoint.h"
31#include "lardataobj/RecoBase/Vertex.h"
36 class GeometryUtilities;
57 typedef std::unique_ptr<std::vector<larpandoraobj::PFParticleMetadata>>
61 typedef std::unique_ptr<art::Assns<recob::PFParticle, larpandoraobj::PFParticleMetadata>>
63 typedef std::unique_ptr<art::Assns<recob::PFParticle, recob::SpacePoint>>
65 typedef std::unique_ptr<art::Assns<recob::PFParticle, recob::Cluster>>
67 typedef std::unique_ptr<art::Assns<recob::PFParticle, recob::Vertex>>
70 typedef std::unique_ptr<art::Assns<recob::PFParticle, recob::Slice>>
129 const std::string& name,
251 template <
typename T>
252 static size_t GetId(
const T*
const pT,
const std::list<const T*>& tList);
262 template <
typename T>
263 static size_t GetId(
const T*
const pT,
const std::vector<const T*>& tVector);
307 const std::string& instanceLabel,
327 const std::string& instanceLabel,
350 const std::string& instanceLabel,
370 const art::Event& event,
371 const std::string& instanceLabel,
385 const std::string& instanceLabel,
405 const art::Event& event,
406 const std::string& instanceLabel,
433 const art::Event& event,
434 const std::string& instanceLabel,
452 const art::Event& event,
453 const std::string& instanceLabel,
468 static void BuildT0s(
const art::Event& event,
469 const std::string& instanceLabel,
493 const size_t spacePointId);
517 util::GeometryUtilities
const& gser,
522 std::vector<HitVector>& hitVectors,
524 cluster::ClusterParamsAlgBase& algo);
539 static recob::Cluster
BuildCluster(util::GeometryUtilities
const& gser,
543 cluster::ClusterParamsAlgBase& algo);
569 static bool BuildT0(
const art::Event& event,
583 template <
typename A,
typename B>
585 const std::string& instanceLabel,
588 std::unique_ptr<art::Assns<A, B>>& association);
598 template <
typename A,
typename B>
600 const std::string& instanceLabel,
603 std::unique_ptr<art::Assns<A, B>>& association);
613 template <
typename A,
typename B>
615 const std::string& instanceLabel,
617 const std::vector<art::Ptr<B>>& bVector,
618 std::unique_ptr<art::Assns<A, B>>& association);
623 template <
typename T>
626 typename std::list<const T*>::const_iterator it(std::find(tList.begin(), tList.end(), pT));
628 if (it == tList.end())
629 throw cet::exception(
"LArPandora")
630 <<
" LArPandoraOutput::GetId --- can't find the id of supplied object";
632 return static_cast<size_t>(std::distance(tList.begin(), it));
637 template <
typename T>
640 typename std::vector<const T*>::const_iterator it(
641 std::find(tVector.begin(), tVector.end(), pT));
643 if (it == tVector.end())
644 throw cet::exception(
"LArPandora")
645 <<
" LArPandoraOutput::GetId --- can't find the id of supplied object";
647 return static_cast<size_t>(std::distance(tVector.begin(), it));
652 template <
typename A,
typename B>
654 const std::string& instanceLabel,
657 std::unique_ptr<art::Assns<A, B>>& association)
659 const art::PtrMaker<A> makePtrA(event, instanceLabel);
660 art::Ptr<A> pA(makePtrA(idA));
662 const art::PtrMaker<B> makePtrB(event, instanceLabel);
663 art::Ptr<B> pB(makePtrB(idB));
665 association->addSingle(pA, pB);
670 template <
typename A,
typename B>
672 const std::string& instanceLabel,
675 std::unique_ptr<art::Assns<A, B>>& association)
677 IdToIdVectorMap::const_iterator it(aToBMap.find(idA));
678 if (it == aToBMap.end())
679 throw cet::exception(
"LArPandora")
680 <<
" LArPandoraOutput::AddAssociation --- id doesn't exists in the assocaition map";
682 const art::PtrMaker<A> makePtrA(event, instanceLabel);
683 art::Ptr<A> pA(makePtrA(idA));
685 const art::PtrMaker<B> makePtrB(event, instanceLabel);
686 for (
const size_t idB : it->second) {
687 art::Ptr<B> pB(makePtrB(idB));
688 association->addSingle(pA, pB);
694 template <
typename A,
typename B>
696 const std::string& instanceLabel,
698 const std::vector<art::Ptr<B>>& bVector,
699 std::unique_ptr<art::Assns<A, B>>& association)
701 const art::PtrMaker<A> makePtrA(event, instanceLabel);
702 art::Ptr<A> pA(makePtrA(idA));
704 for (
const art::Ptr<B>& pB : bVector)
705 association->addSingle(pA, pB);
Interface class for LArPandora producer modules, which reconstruct recob::PFParticles from recob::Hit...
helper function for LArPandoraInterface producer module
Header file for the pandora api class.
void Validate() const
Check the parameters and throw an exception if they are not valid.
std::string m_testBeamInteractionVerticesInstanceLabel
The label for the test beam interaction vertices.
std::string m_allOutcomesInstanceLabel
The label for the instance producing all outcomes.
std::string m_hitfinderModuleLabel
The hit finder module label.
bool m_shouldProduceTestBeamInteractionVertices
Whether to write the test beam interaction vertices in a separate collection.
bool m_isNeutrinoRecoOnlyNoSlicing
If we are running the neutrino reconstruction only with no slicing.
Settings()
Default constructor.
bool m_shouldProduceAllOutcomes
If all outcomes should be produced in separate collections (choose false if you only require the cons...
const pandora::Pandora * m_pPrimaryPandora
bool m_shouldProduceSlices
Whether to produce output slices e.g. may not want to do this if only (re)processing single slices.
bool m_shouldRunStitching
static pandora::VertexVector CollectVertices(const pandora::PfoVector &pfoVector, IdToIdVectorMap &pfoToVerticesMap, std::function< const pandora::Vertex *const(const pandora::ParticleFlowObject *const)> fCriteria)
Collect all vertices contained in the input pfo list Order is guaranteed provided pfoVector is ordere...
std::unique_ptr< art::Assns< recob::PFParticle, recob::Cluster > > PFParticleToClusterCollection
static void AssociateAdditionalVertices(const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, const IdToIdVectorMap &pfoToVerticesMap, PFParticleToVertexCollection &outputParticlesToVertices)
Convert Create the associations between pre-existing PFParticle and additional vertices.
static void AddAssociation(const art::Event &event, const std::string &instanceLabel, const size_t idA, const size_t idB, std::unique_ptr< art::Assns< A, B > > &association)
Add an association between objects with two given ids.
static bool IsClearCosmic(const pandora::ParticleFlowObject *const pPfo)
Check if the input pfo is an unambiguous cosmic ray.
std::unique_ptr< art::Assns< recob::PFParticle, recob::Vertex > > PFParticleToVertexCollection
static recob::Cluster BuildCluster(util::GeometryUtilities const &gser, const size_t id, const HitVector &hitVector, const HitList &isolatedHits, cluster::ClusterParamsAlgBase &algo)
Build an ART cluster from an input vector of ART hits.
static void ProduceArtOutput(const Settings &settings, const IdToHitMap &idToHitMap, art::Event &evt)
Convert the Pandora PFOs into ART clusters and write into ART event.
std::unique_ptr< art::Assns< recob::PFParticle, recob::SpacePoint > > PFParticleToSpacePointCollection
static void GetHitsInCluster(const pandora::Cluster *const pCluster, pandora::CaloHitVector &sortedHits)
Collect a sorted list of all 2D hits in a cluster.
std::unique_ptr< std::vector< recob::Cluster > > ClusterCollection
static art::Ptr< recob::Hit > GetHit(const IdToHitMap &idToHitMap, const pandora::CaloHit *const pCaloHit)
Look up ART hit from an input Pandora hit.
static void BuildT0s(const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, T0Collection &outputT0s, PFParticleToT0Collection &outputParticlesToT0s)
Calculate the T0 of each pfos and add them to the output vector Create the associations between PFPar...
std::unique_ptr< art::Assns< recob::Cluster, recob::Hit > > ClusterToHitCollection
std::unique_ptr< std::vector< larpandoraobj::PFParticleMetadata > > PFParticleMetadataCollection
std::unique_ptr< std::vector< recob::Slice > > SliceCollection
static void CopyAllHitsToSingleSlice(const Settings &settings, const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, const IdToHitMap &idToHitMap, SliceCollection &outputSlices, PFParticleToSliceCollection &outputParticlesToSlices, SliceToHitCollection &outputSlicesToHits)
Ouput a single slice containing all of the input hits.
static pandora::PfoVector CollectPfos(const pandora::Pandora *const pPrimaryPandora)
Collect the current pfos (including all downstream pfos) from the master pandora instance.
static pandora::ClusterList CollectClusters(const pandora::PfoVector &pfoVector, IdToIdVectorMap &pfoToClustersMap)
Collect a sorted list of all 2D clusters contained in the input pfo list Order is guaranteed provided...
static recob::PFParticle BuildPFParticle(const pandora::ParticleFlowObject *const pPfo, const size_t pfoId, const pandora::PfoVector &pfoVector)
Convert from a pfo to and ART PFParticle.
static void BuildSlices(const Settings &settings, const pandora::Pandora *const pPrimaryPandora, const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, const IdToHitMap &idToHitMap, SliceCollection &outputSlices, PFParticleToSliceCollection &outputParticlesToSlices, SliceToHitCollection &outputSlicesToHits)
Build slices - collections of hits which each describe a single particle hierarchy.
std::unique_ptr< std::vector< recob::PFParticle > > PFParticleCollection
static unsigned int BuildDummySlice(SliceCollection &outputSlices)
Build a new slice object with dummy information.
static bool GetPandoraInstance(const pandora::Pandora *const pPrimaryPandora, const std::string &name, const pandora::Pandora *&pPandoraInstance)
Get the address of a pandora instance with a given name.
static recob::SpacePoint BuildSpacePoint(const pandora::CaloHit *const pCaloHit, const size_t spacePointId)
Convert from a pandora 3D hit to an ART spacepoint.
std::map< size_t, IdVector > IdToIdVectorMap
static bool IsFromSlice(const pandora::ParticleFlowObject *const pPfo)
Check if the input pfo is from a slice.
static void Collect3DHits(const pandora::ParticleFlowObject *const pPfo, pandora::CaloHitVector &caloHits)
Collect a sorted vector of all 3D hits in the input pfo.
std::unique_ptr< std::vector< recob::SpacePoint > > SpacePointCollection
static void GetPandoraToArtHitMap(const pandora::ClusterList &clusterList, const pandora::CaloHitList &threeDHitList, const IdToHitMap &idToHitMap, CaloHitToArtHitMap &pandoraHitToArtHitMap)
Collect all 2D and 3D hits that were used / produced in the reconstruction and map them to their corr...
static void BuildPFParticles(const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, const IdToIdVectorMap &pfoToVerticesMap, const IdToIdVectorMap &pfoToThreeDHitsMap, const IdToIdVectorMap &pfoToArtClustersMap, PFParticleCollection &outputParticles, PFParticleToVertexCollection &outputParticlesToVertices, PFParticleToSpacePointCollection &outputParticlesToSpacePoints, PFParticleToClusterCollection &outputParticlesToClusters)
Convert between pfos and PFParticles and add them to the output vector Create the associations betwee...
static void BuildVertices(const pandora::VertexVector &vertexVector, VertexCollection &outputVertices)
Convert pandora vertices to ART vertices and add them to the output vector.
static void BuildSpacePoints(const art::Event &event, const std::string &instanceLabel, const pandora::CaloHitList &threeDHitList, const CaloHitToArtHitMap &pandoraHitToArtHitMap, SpacePointCollection &outputSpacePoints, SpacePointToHitCollection &outputSpacePointsToHits)
Convert pandora 3D hits to ART spacepoints and add them to the output vector Create the associations ...
std::unique_ptr< std::vector< recob::Vertex > > VertexCollection
static void GetPandoraSlices(const pandora::Pandora *const pPrimaryPandora, pandora::PfoVector &slicePfos)
Get the slice pfos - one pfo per slice.
std::unique_ptr< art::Assns< recob::PFParticle, recob::Slice > > PFParticleToSliceCollection
static unsigned int BuildSlice(const pandora::ParticleFlowObject *const pParentPfo, const art::Event &event, const std::string &instanceLabel, const IdToHitMap &idToHitMap, SliceCollection &outputSlices, SliceToHitCollection &outputSlicesToHits)
Build a new slice object from a PFO, this can be a top-level parent in a hierarchy or a "slice PFO" f...
static size_t GetId(const T *const pT, const std::list< const T * > &tList)
Find the index of an input object in an input list. Throw an exception if it doesn't exist.
std::vector< size_t > IdVector
std::unique_ptr< art::Assns< recob::Slice, recob::Hit > > SliceToHitCollection
static unsigned int GetSliceIndex(const pandora::ParticleFlowObject *const pPfo)
Get the index of the slice from which this pfo was produced.
static pandora::PfoVector CollectAllPfoOutcomes(const pandora::Pandora *const pPrimaryPandora)
Collect the pfos (including all downstream pfos) from the master and daughter pandora instances.
static recob::Vertex BuildVertex(const pandora::Vertex *const pVertex, const size_t vertexId)
Convert from a pandora vertex to an ART vertex.
static void BuildParticleMetadata(const art::Event &event, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, PFParticleMetadataCollection &outputParticleMetadata, PFParticleToMetadataCollection &outputParticlesToMetadata)
Build metadata objects from a list of input pfos.
std::unique_ptr< std::vector< anab::T0 > > T0Collection
std::unique_ptr< art::Assns< recob::PFParticle, larpandoraobj::PFParticleMetadata > > PFParticleToMetadataCollection
static void BuildClusters(const art::Event &event, const std::string &instanceLabel, const pandora::ClusterList &clusterList, const CaloHitToArtHitMap &pandoraHitToArtHitMap, const IdToIdVectorMap &pfoToClustersMap, ClusterCollection &outputClusters, ClusterToHitCollection &outputClustersToHits, IdToIdVectorMap &pfoToArtClustersMap)
Convert pandora 2D clusters to ART clusters and add them to the output vector Create the associations...
std::unique_ptr< art::Assns< recob::SpacePoint, recob::Hit > > SpacePointToHitCollection
std::unique_ptr< art::Assns< recob::PFParticle, anab::T0 > > PFParticleToT0Collection
static bool BuildT0(const art::Event &event, const pandora::ParticleFlowObject *const pPfo, const pandora::PfoVector &pfoVector, size_t &nextId, anab::T0 &t0)
If required, build a T0 for the input pfo.
std::map< const pandora::CaloHit *, art::Ptr< recob::Hit > > CaloHitToArtHitMap
ParticleFlowObject class.
std::vector< art::Ptr< recob::Hit > > HitVector
std::map< int, art::Ptr< recob::Hit > > IdToHitMap
std::set< art::Ptr< recob::Hit > > HitList
ObjectCreationHelper< ClusterParameters, ClusterMetadata, pandora::Cluster > Cluster
std::vector< const CaloHit * > CaloHitVector
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< const ParticleFlowObject * > PfoVector
MANAGED_CONTAINER< const CaloHit * > CaloHitList
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList
std::vector< const Vertex * > VertexVector