7 #ifndef LAR_PANDORA_OUTPUT_H
8 #define LAR_PANDORA_OUTPUT_H
10 #include "art/Persistency/Common/PtrMaker.h"
15 class PFParticleMetadata;
18 namespace cluster {
class ClusterParamsAlgBase; }
31 #include "Api/PandoraApi.h"
34 class GeometryUtilities;
42 namespace lar_pandora {
55 typedef std::unique_ptr<std::vector<larpandoraobj::PFParticleMetadata>>
59 typedef std::unique_ptr<art::Assns<recob::PFParticle, larpandoraobj::PFParticleMetadata>>
61 typedef std::unique_ptr<art::Assns<recob::PFParticle, recob::SpacePoint>>
63 typedef std::unique_ptr<art::Assns<recob::PFParticle, recob::Cluster>>
65 typedef std::unique_ptr<art::Assns<recob::PFParticle, recob::Vertex>>
68 typedef std::unique_ptr<art::Assns<recob::PFParticle, recob::Slice>>
127 const std::string&
name,
128 const pandora::Pandora*& pPandoraInstance);
137 pandora::PfoVector& slicePfos);
146 static bool IsClearCosmic(
const pandora::ParticleFlowObject*
const pPfo);
155 static bool IsFromSlice(
const pandora::ParticleFlowObject*
const pPfo);
164 static unsigned int GetSliceIndex(
const pandora::ParticleFlowObject*
const pPfo);
173 static pandora::PfoVector
CollectPfos(
const pandora::Pandora*
const pPrimaryPandora);
190 static void CollectPfos(
const pandora::PfoList& parentPfoList, pandora::PfoVector& pfoVector);
203 const pandora::PfoVector& pfoVector,
205 std::function<
const pandora::Vertex*
const(
const pandora::ParticleFlowObject*
const)>
217 static pandora::ClusterList
CollectClusters(
const pandora::PfoVector& pfoVector,
226 static void Collect3DHits(
const pandora::ParticleFlowObject*
const pPfo,
227 pandora::CaloHitVector& caloHits);
238 static pandora::CaloHitList
Collect3DHits(
const pandora::PfoVector& pfoVector,
249 template <
typename T>
250 static size_t GetId(
const T*
const pT,
const std::list<const T*>& tList);
260 template <
typename T>
261 static size_t GetId(
const T*
const pT,
const std::vector<const T*>& tVector);
272 const pandora::CaloHitList& threeDHitList,
283 const pandora::CaloHit*
const pCaloHit);
305 const std::string& instanceLabel,
306 const pandora::CaloHitList& threeDHitList,
325 const std::string& instanceLabel,
326 const pandora::ClusterList& clusterList,
348 const std::string& instanceLabel,
349 const pandora::PfoVector& pfoVector,
368 const art::Event& event,
369 const std::string& instanceLabel,
370 const pandora::PfoVector& pfoVector,
383 const std::string& instanceLabel,
384 const pandora::PfoVector& pfoVector,
402 const pandora::Pandora*
const pPrimaryPandora,
403 const art::Event& event,
404 const std::string& instanceLabel,
405 const pandora::PfoVector& pfoVector,
431 const art::Event& event,
432 const std::string& instanceLabel,
433 const pandora::PfoVector& pfoVector,
449 static unsigned int BuildSlice(
const pandora::ParticleFlowObject*
const pParentPfo,
450 const art::Event& event,
451 const std::string& instanceLabel,
466 static void BuildT0s(
const art::Event& event,
467 const std::string& instanceLabel,
468 const pandora::PfoVector& pfoVector,
491 const size_t spacePointId);
500 pandora::CaloHitVector& sortedHits);
516 const pandora::Cluster*
const pCluster,
517 const pandora::ClusterList& clusterList,
520 std::vector<HitVector>& hitVectors,
554 const pandora::PfoVector& pfoVector);
567 static bool BuildT0(
const art::Event& event,
568 const pandora::ParticleFlowObject*
const pPfo,
569 const pandora::PfoVector& pfoVector,
581 template <
typename A,
typename B>
583 const std::string& instanceLabel,
586 std::unique_ptr<art::Assns<A, B>>& association);
596 template <
typename A,
typename B>
598 const std::string& instanceLabel,
601 std::unique_ptr<art::Assns<A, B>>& association);
611 template <
typename A,
typename B>
613 const std::string& instanceLabel,
616 std::unique_ptr<art::Assns<A, B>>& association);
621 template <
typename T>
625 typename std::list<const T*>::const_iterator it(std::find(tList.begin(), tList.end(), pT));
627 if (it == tList.end())
628 throw cet::exception(
"LArPandora")
629 <<
" LArPandoraOutput::GetId --- can't find the id of supplied object";
631 return static_cast<size_t>(
std::distance(tList.begin(), it));
636 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>
655 const std::string& instanceLabel,
658 std::unique_ptr<art::Assns<A, B>>& association)
660 const art::PtrMaker<A> makePtrA(event, instanceLabel);
661 art::Ptr<A> pA(makePtrA(idA));
663 const art::PtrMaker<B> makePtrB(event, instanceLabel);
664 art::Ptr<B> pB(makePtrB(idB));
666 association->addSingle(pA, pB);
671 template <
typename A,
typename B>
674 const std::string& instanceLabel,
677 std::unique_ptr<art::Assns<A, B>>& association)
679 IdToIdVectorMap::const_iterator it(aToBMap.find(idA));
680 if (it == aToBMap.end())
681 throw cet::exception(
"LArPandora")
682 <<
" LArPandoraOutput::AddAssociation --- id doesn't exists in the assocaition map";
684 const art::PtrMaker<A> makePtrA(event, instanceLabel);
685 art::Ptr<A> pA(makePtrA(idA));
687 const art::PtrMaker<B> makePtrB(event, instanceLabel);
688 for (
const size_t idB : it->second) {
689 art::Ptr<B> pB(makePtrB(idB));
690 association->addSingle(pA, pB);
696 template <
typename A,
typename B>
699 const std::string& instanceLabel,
702 std::unique_ptr<art::Assns<A, B>>& association)
704 const art::PtrMaker<A> makePtrA(event, instanceLabel);
705 art::Ptr<A> pA(makePtrA(idA));
707 for (
const art::Ptr<B>& pB : bVector)
708 association->addSingle(pA, pB);
713 #endif // LAR_PANDORA_OUTPUT_H
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...
static recob::SpacePoint BuildSpacePoint(const pandora::CaloHit *const pCaloHit, const size_t spacePointId)
Convert from a pandora 3D hit to an ART spacepoint.
Interface class for LArPandora producer modules, which reconstruct recob::PFParticles from recob::Hit...
void Validate() const
Check the parameters and throw an exception if they are not valid.
static void GetPandoraSlices(const pandora::Pandora *const pPrimaryPandora, pandora::PfoVector &slicePfos)
Get the slice pfos - one pfo per slice.
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.
const pandora::Pandora * m_pPrimaryPandora
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.
std::unique_ptr< std::vector< larpandoraobj::PFParticleMetadata > > PFParticleMetadataCollection
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...
std::unique_ptr< art::Assns< recob::PFParticle, recob::Slice > > PFParticleToSliceCollection
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...
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 ...
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...
std::unique_ptr< std::vector< recob::Slice > > SliceCollection
std::unique_ptr< std::vector< recob::PFParticle > > PFParticleCollection
static unsigned int BuildDummySlice(SliceCollection &outputSlices)
Build a new slice object with dummy information.
Settings()
Default constructor.
std::string m_testBeamInteractionVerticesInstanceLabel
The label for the test beam interaction vertices.
std::unique_ptr< std::vector< recob::Vertex > > VertexCollection
std::string m_allOutcomesInstanceLabel
The label for the instance producing all outcomes.
std::map< size_t, IdVector > IdToIdVectorMap
static void GetHitsInCluster(const pandora::Cluster *const pCluster, pandora::CaloHitVector &sortedHits)
Collect a sorted list of all 2D hits in a cluster.
Set of hits with a 2D structure.
std::unique_ptr< art::Assns< recob::PFParticle, larpandoraobj::PFParticleMetadata > > PFParticleToMetadataCollection
std::map< int, art::Ptr< recob::Hit > > IdToHitMap
static art::Ptr< recob::Hit > GetHit(const IdToHitMap &idToHitMap, const pandora::CaloHit *const pCaloHit)
Look up ART hit from an input Pandora hit.
bool m_isNeutrinoRecoOnlyNoSlicing
If we are running the neutrino reconstruction only with no slicing.
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...
static bool IsFromSlice(const pandora::ParticleFlowObject *const pPfo)
Check if the input pfo is from a slice.
Definition of vertex object for LArSoft.
static recob::Vertex BuildVertex(const pandora::Vertex *const pVertex, const size_t vertexId)
Convert from a pandora vertex to an ART vertex.
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.
std::string m_hitfinderModuleLabel
The hit finder module label.
Algorithm collection class computing cluster parameters.
std::unique_ptr< art::Assns< recob::Slice, recob::Hit > > SliceToHitCollection
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< size_t > IdVector
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
static unsigned int GetSliceIndex(const pandora::ParticleFlowObject *const pPfo)
Get the index of the slice from which this pfo was produced.
std::unique_ptr< art::Assns< recob::PFParticle, anab::T0 > > PFParticleToT0Collection
static void BuildVertices(const pandora::VertexVector &vertexVector, VertexCollection &outputVertices)
Convert pandora vertices to ART vertices and add them to the output vector.
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::unique_ptr< art::Assns< recob::SpacePoint, recob::Hit > > SpacePointToHitCollection
static pandora::PfoVector CollectPfos(const pandora::Pandora *const pPrimaryPandora)
Collect the current pfos (including all downstream pfos) from the master pandora instance.
static bool IsClearCosmic(const pandora::ParticleFlowObject *const pPfo)
Check if the input pfo is an unambiguous cosmic ray.
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< std::vector< recob::Cluster > > ClusterCollection
std::map< const pandora::CaloHit *, art::Ptr< recob::Hit > > CaloHitToArtHitMap
std::unique_ptr< art::Assns< recob::PFParticle, recob::Vertex > > PFParticleToVertexCollection
Declaration of cluster object.
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 void Collect3DHits(const pandora::ParticleFlowObject *const pPfo, pandora::CaloHitVector &caloHits)
Collect a sorted vector of all 3D hits in the input pfo.
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...
bool m_shouldProduceTestBeamInteractionVertices
Whether to write the test beam interaction vertices in a separate collection.
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.
std::unique_ptr< art::Assns< recob::PFParticle, recob::SpacePoint > > PFParticleToSpacePointCollection
std::vector< art::Ptr< recob::Hit > > HitVector
Hierarchical representation of particle flow.
bool m_shouldRunStitching
std::unique_ptr< std::vector< anab::T0 > > T0Collection
bool m_shouldProduceAllOutcomes
If all outcomes should be produced in separate collections (choose false if you only require the cons...
bool m_shouldProduceSlices
Whether to produce output slices e.g. may not want to do this if only (re)processing single slices...
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.
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 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 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< recob::SpacePoint > > SpacePointCollection
std::set< art::Ptr< recob::Hit > > HitList
helper function for LArPandoraInterface producer module
static pandora::PfoVector CollectAllPfoOutcomes(const pandora::Pandora *const pPrimaryPandora)
Collect the pfos (including all downstream pfos) from the master and daughter pandora instances...
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.
std::array< float, 2 > VertexVector(const recob::Vertex &vert, const geo::PlaneID &plane, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
std::unique_ptr< art::Assns< recob::Cluster, recob::Hit > > ClusterToHitCollection