LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_pandora::LArPandoraOutput Class Reference

#include "LArPandoraOutput.h"

Classes

class  Settings
 Settings class. More...
 

Public Types

typedef std::vector< size_t > IdVector
 
typedef std::map< size_t, IdVectorIdToIdVectorMap
 
typedef std::map< const pandora::CaloHit *, art::Ptr< recob::Hit > > CaloHitToArtHitMap
 
typedef std::unique_ptr< std::vector< recob::PFParticle > > PFParticleCollection
 
typedef std::unique_ptr< std::vector< recob::Vertex > > VertexCollection
 
typedef std::unique_ptr< std::vector< recob::Cluster > > ClusterCollection
 
typedef std::unique_ptr< std::vector< recob::SpacePoint > > SpacePointCollection
 
typedef std::unique_ptr< std::vector< anab::T0 > > T0Collection
 
typedef std::unique_ptr< std::vector< larpandoraobj::PFParticleMetadata > > PFParticleMetadataCollection
 
typedef std::unique_ptr< std::vector< recob::Slice > > SliceCollection
 
typedef std::unique_ptr< art::Assns< recob::PFParticle, larpandoraobj::PFParticleMetadata > > PFParticleToMetadataCollection
 
typedef std::unique_ptr< art::Assns< recob::PFParticle, recob::SpacePoint > > PFParticleToSpacePointCollection
 
typedef std::unique_ptr< art::Assns< recob::PFParticle, recob::Cluster > > PFParticleToClusterCollection
 
typedef std::unique_ptr< art::Assns< recob::PFParticle, recob::Vertex > > PFParticleToVertexCollection
 
typedef std::unique_ptr< art::Assns< recob::PFParticle, anab::T0 > > PFParticleToT0Collection
 
typedef std::unique_ptr< art::Assns< recob::PFParticle, recob::Slice > > PFParticleToSliceCollection
 
typedef std::unique_ptr< art::Assns< recob::Cluster, recob::Hit > > ClusterToHitCollection
 
typedef std::unique_ptr< art::Assns< recob::SpacePoint, recob::Hit > > SpacePointToHitCollection
 
typedef std::unique_ptr< art::Assns< recob::Slice, recob::Hit > > SliceToHitCollection
 

Static Public Member Functions

static void ProduceArtOutput (const Settings &settings, const IdToHitMap &idToHitMap, art::Event &evt)
 Convert the Pandora PFOs into ART clusters and write into ART event. More...
 

Static Private Member Functions

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. More...
 
static void GetPandoraSlices (const pandora::Pandora *const pPrimaryPandora, pandora::PfoVector &slicePfos)
 Get the slice pfos - one pfo per slice. More...
 
static bool IsClearCosmic (const pandora::ParticleFlowObject *const pPfo)
 Check if the input pfo is an unambiguous cosmic ray. More...
 
static bool IsFromSlice (const pandora::ParticleFlowObject *const pPfo)
 Check if the input pfo is from a slice. More...
 
static unsigned int GetSliceIndex (const pandora::ParticleFlowObject *const pPfo)
 Get the index of the slice from which this pfo was produced. More...
 
static pandora::PfoVector CollectPfos (const pandora::Pandora *const pPrimaryPandora)
 Collect the current pfos (including all downstream pfos) from the master pandora instance. More...
 
static pandora::PfoVector CollectAllPfoOutcomes (const pandora::Pandora *const pPrimaryPandora)
 Collect the pfos (including all downstream pfos) from the master and daughter pandora instances. More...
 
static void CollectPfos (const pandora::PfoList &parentPfoList, pandora::PfoVector &pfoVector)
 Collect a sorted list of all downstream pfos of an input list of parent. More...
 
static pandora::VertexVector CollectVertices (const pandora::PfoVector &pfoVector, IdToIdVectorMap &pfoToVerticesMap)
 Collect all vertices contained in the input pfo list Order is guaranteed provided pfoVector is ordered. More...
 
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 pfoVector is ordered. More...
 
static void Collect3DHits (const pandora::ParticleFlowObject *const pPfo, pandora::CaloHitVector &caloHits)
 Collect a sorted vector of all 3D hits in the input pfo. More...
 
static pandora::CaloHitList Collect3DHits (const pandora::PfoVector &pfoVector, IdToIdVectorMap &pfoToThreeDHitsMap)
 Collect a sorted list of all 3D hits contained in the input pfo list Order is guaranteed provided pfoVector is ordered. More...
 
template<typename T >
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. More...
 
template<typename T >
static size_t GetId (const T *const pT, const std::vector< const T * > &tVector)
 Find the index of an input object in an input vector. Throw an exception if it doesn't exist. More...
 
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 corresponding ART hit. More...
 
static art::Ptr< recob::HitGetHit (const IdToHitMap &idToHitMap, const pandora::CaloHit *const pCaloHit)
 Look up ART hit from an input Pandora hit. More...
 
static void BuildVertices (const pandora::VertexVector &vertexVector, VertexCollection &outputVertices)
 Convert pandora vertices to ART vertices and add them to the output vector. More...
 
static void BuildSpacePoints (const art::Event &event, const art::EDProducer *const pProducer, 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 between spacepoints and hits. More...
 
static void BuildClusters (const art::Event &event, const art::EDProducer *const pProducer, 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 between clusters and hits. For multiple drift volumes, each pandora cluster can correspond to multiple ART clusters. More...
 
static void BuildPFParticles (const art::Event &event, const art::EDProducer *const pProducer, 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 between PFParticle and vertices, spacepoints and clusters. More...
 
static void BuildParticleMetadata (const art::Event &event, const art::EDProducer *const pProducer, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, PFParticleMetadataCollection &outputParticleMetadata, PFParticleToMetadataCollection &outputParticlesToMetadata)
 Build metadata objects from a list of input pfos. More...
 
static void BuildSlices (const Settings &settings, const pandora::Pandora *const pPrimaryPandora, const art::Event &event, const art::EDProducer *const pProducer, 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. More...
 
static unsigned int BuildDummySlice (SliceCollection &outputSlices)
 Build a new slice object with dummy information. More...
 
static void CopyAllHitsToSingleSlice (const Settings &settings, const art::Event &event, const art::EDProducer *const pProducer, 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. More...
 
static unsigned int BuildSlice (const pandora::ParticleFlowObject *const pParentPfo, const art::Event &event, const art::EDProducer *const pProducer, 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" from the slicing instance. More...
 
static void BuildT0s (const art::Event &event, const art::EDProducer *const pProducer, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, T0Collection &outputT0s, const CaloHitToArtHitMap &pandoraHitToArtHitMap, PFParticleToT0Collection &outputParticlesToT0s)
 Calculate the T0 of each pfos and add them to the output vector Create the associations between PFParticle and T0s. More...
 
static recob::Vertex BuildVertex (const pandora::Vertex *const pVertex, const size_t vertexId)
 Convert from a pandora vertex to an ART vertex. More...
 
static recob::SpacePoint BuildSpacePoint (const pandora::CaloHit *const pCaloHit, const size_t spacePointId)
 Convert from a pandora 3D hit to an ART spacepoint. More...
 
static void GetHitsInCluster (const pandora::Cluster *const pCluster, pandora::CaloHitVector &sortedHits)
 Collect a sorted list of all 2D hits in a cluster. More...
 
static std::vector< recob::ClusterBuildClusters (const pandora::Cluster *const pCluster, const pandora::ClusterList &clusterList, const CaloHitToArtHitMap &pandoraHitToArtHitMap, IdToIdVectorMap &pandoraClusterToArtClustersMap, std::vector< HitVector > &hitVectors, size_t &nextId, cluster::ClusterParamsAlgBase &algo)
 Convert from a pandora 2D cluster to a vector of ART clusters (produce multiple if the cluster is split over drift volumes) More...
 
static recob::Cluster BuildCluster (const size_t id, const HitVector &hitVector, const HitList &isolatedHits, cluster::ClusterParamsAlgBase &algo)
 Build an ART cluster from an input vector of ART hits. More...
 
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. More...
 
static bool BuildT0 (const pandora::ParticleFlowObject *const pPfo, const pandora::PfoVector &pfoVector, size_t &nextId, const CaloHitToArtHitMap &pandoraHitToArtHitMap, anab::T0 &t0)
 If required, build a T0 for the input pfo. More...
 
static double CalculateT0 (const art::Ptr< recob::Hit > hit, const pandora::CaloHit *const pCaloHit)
 Convert X0 correction into T0 correction. More...
 
template<typename A , typename B >
static void AddAssociation (const art::Event &event, const art::EDProducer *const pProducer, 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. More...
 
template<typename A , typename B >
static void AddAssociation (const art::Event &event, const art::EDProducer *const pProducer, const std::string &instanceLabel, const size_t idA, const IdToIdVectorMap &aToBMap, std::unique_ptr< art::Assns< A, B > > &association)
 Add associations between input objects. More...
 
template<typename A , typename B >
static void AddAssociation (const art::Event &event, const art::EDProducer *const pProducer, const std::string &instanceLabel, const size_t idA, const std::vector< art::Ptr< B > > &bVector, std::unique_ptr< art::Assns< A, B > > &association)
 Add associations between input objects. More...
 

Detailed Description

Definition at line 31 of file LArPandoraOutput.h.

Member Typedef Documentation

typedef std::map<const pandora::CaloHit *, art::Ptr<recob::Hit> > lar_pandora::LArPandoraOutput::CaloHitToArtHitMap

Definition at line 36 of file LArPandoraOutput.h.

typedef std::unique_ptr< std::vector<recob::Cluster> > lar_pandora::LArPandoraOutput::ClusterCollection

Definition at line 40 of file LArPandoraOutput.h.

Definition at line 35 of file LArPandoraOutput.h.

typedef std::vector<size_t> lar_pandora::LArPandoraOutput::IdVector

Definition at line 34 of file LArPandoraOutput.h.

Definition at line 38 of file LArPandoraOutput.h.

typedef std::unique_ptr< std::vector<recob::Slice> > lar_pandora::LArPandoraOutput::SliceCollection

Definition at line 44 of file LArPandoraOutput.h.

Definition at line 41 of file LArPandoraOutput.h.

typedef std::unique_ptr< std::vector<anab::T0> > lar_pandora::LArPandoraOutput::T0Collection

Definition at line 42 of file LArPandoraOutput.h.

typedef std::unique_ptr< std::vector<recob::Vertex> > lar_pandora::LArPandoraOutput::VertexCollection

Definition at line 39 of file LArPandoraOutput.h.

Member Function Documentation

template<typename A , typename B >
void lar_pandora::LArPandoraOutput::AddAssociation ( const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const size_t  idA,
const size_t  idB,
std::unique_ptr< art::Assns< A, B > > &  association 
)
inlinestaticprivate

Add an association between objects with two given ids.

Parameters
eventthe ART event
pProducerthe address of the producer module
idAthe id of an object of type A
idBthe id of an object of type B to associate to the first object
associationthe output association to update

Definition at line 559 of file LArPandoraOutput.h.

Referenced by BuildClusters(), BuildParticleMetadata(), BuildPFParticles(), BuildSlice(), BuildSlices(), BuildSpacePoints(), BuildT0s(), and CopyAllHitsToSingleSlice().

561 {
562  const art::PtrMaker<A> makePtrA(event, *pProducer, instanceLabel);
563  art::Ptr<A> pA(makePtrA(idA));
564 
565  const art::PtrMaker<B> makePtrB(event, *pProducer, instanceLabel);
566  art::Ptr<B> pB(makePtrB(idB));
567 
568  association->addSingle(pA, pB);
569 }
Definition: fwd.h:25
template<typename A , typename B >
void lar_pandora::LArPandoraOutput::AddAssociation ( const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const size_t  idA,
const IdToIdVectorMap aToBMap,
std::unique_ptr< art::Assns< A, B > > &  association 
)
inlinestaticprivate

Add associations between input objects.

Parameters
eventthe ART event
pProducerthe address of the producer module
idAthe id of an object of type A
aToBMapthe input mapping from IDs of objects of type A to IDs of objects of type B to associate
associationthe output association to update

Definition at line 574 of file LArPandoraOutput.h.

576 {
577  IdToIdVectorMap::const_iterator it(aToBMap.find(idA));
578  if (it == aToBMap.end())
579  throw cet::exception("LArPandora") << " LArPandoraOutput::AddAssociation --- id doesn't exists in the assocaition map";
580 
581  const art::PtrMaker<A> makePtrA(event, *pProducer, instanceLabel);
582  art::Ptr<A> pA(makePtrA(idA));
583 
584  const art::PtrMaker<B> makePtrB(event, *pProducer, instanceLabel);
585  for (const size_t idB : it->second)
586  {
587  art::Ptr<B> pB(makePtrB(idB));
588  association->addSingle(pA, pB);
589  }
590 }
intermediate_table::const_iterator const_iterator
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename A , typename B >
void lar_pandora::LArPandoraOutput::AddAssociation ( const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const size_t  idA,
const std::vector< art::Ptr< B > > &  bVector,
std::unique_ptr< art::Assns< A, B > > &  association 
)
inlinestaticprivate

Add associations between input objects.

Parameters
eventthe ART event
pProducerthe address of the producer module
idAthe id of an object of type A
bVectorthe input vector of IDs of objects of type B to associate
associationthe output association to update

Definition at line 595 of file LArPandoraOutput.h.

598 {
599  const art::PtrMaker<A> makePtrA(event, *pProducer, instanceLabel);
600  art::Ptr<A> pA(makePtrA(idA));
601 
602  for (const art::Ptr<B> &pB : bVector)
603  association->addSingle(pA, pB);
604 }
Definition: fwd.h:25
recob::Cluster lar_pandora::LArPandoraOutput::BuildCluster ( const size_t  id,
const HitVector hitVector,
const HitList isolatedHits,
cluster::ClusterParamsAlgBase algo 
)
staticprivate

Build an ART cluster from an input vector of ART hits.

Parameters
idthe id code for the cluster
hitVectorthe input vector of hits
isolatedHitsthe input list of isolated hits
algoalgorithm set to fill cluster members
Returns
the ART cluster

If you don't know which algorithm to pick, StandardClusterParamsAlg is a good default. The hits that are isolated (that is, present in isolatedHits) are not fed to the cluster parameter algorithms.

Definition at line 817 of file LArPandoraOutput.cxx.

References geo::kUnknown, max, cluster::ClusterCreator::move(), recob::Cluster::Sentry, and cluster::ClusterParamsAlgBase::SetHits().

Referenced by BuildClusters().

818 {
819  if (hitVector.empty())
820  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildCluster --- No input hits were provided ";
821 
822  // Fill list of cluster properties
824  geo::PlaneID planeID;
825 
826  double startWire(+std::numeric_limits<float>::max()), sigmaStartWire(0.0);
827  double startTime(+std::numeric_limits<float>::max()), sigmaStartTime(0.0);
828  double endWire(-std::numeric_limits<float>::max()), sigmaEndWire(0.0);
829  double endTime(-std::numeric_limits<float>::max()), sigmaEndTime(0.0);
830 
831  std::vector<recob::Hit const*> hits_for_params;
832  hits_for_params.reserve(hitVector.size());
833 
834  for (const art::Ptr<recob::Hit> &hit : hitVector)
835  {
836  const double thisWire(hit->WireID().Wire);
837  const double thisWireSigma(0.5);
838  const double thisTime(hit->PeakTime());
839  const double thisTimeSigma(double(2.*hit->RMS()));
840  const geo::View_t thisView(hit->View());
841  const geo::PlaneID thisPlaneID(hit->WireID().planeID());
842 
843  if (geo::kUnknown == view)
844  {
845  view = thisView;
846  planeID = thisPlaneID;
847  }
848 
849  if (!(thisView == view && thisPlaneID == planeID))
850  {
851  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildCluster --- Input hits have inconsistent plane IDs ";
852  }
853 
854  hits_for_params.push_back(&*hit);
855 
856  if (isolatedHits.count(hit))
857  continue;
858 
859  if (thisWire < startWire || (thisWire == startWire && thisTime < startTime))
860  {
861  startWire = thisWire;
862  sigmaStartWire = thisWireSigma;
863  startTime = thisTime;
864  sigmaStartTime = thisTimeSigma;
865  }
866 
867  if (thisWire > endWire || (thisWire == endWire && thisTime > endTime))
868  {
869  endWire = thisWire;
870  sigmaEndWire = thisWireSigma;
871  endTime = thisTime;
872  sigmaEndTime = thisTimeSigma;
873  }
874 
875  }
876 
877  // feed the algorithm with all the cluster hits
878  algo.SetHits(hits_for_params);
879 
880  // create the recob::Cluster directly in the vector
882  algo, // algo
883  startWire, // start_wire
884  sigmaStartWire, // sigma_start_wire
885  startTime, // start_tick
886  sigmaStartTime, // sigma_start_tick
887  endWire, // end_wire
888  sigmaEndWire, // sigma_end_wire
889  endTime, // end_tick
890  sigmaEndTime, // sigma_end_tick
891  id, // ID
892  view, // view
893  planeID, // plane
894  recob::Cluster::Sentry // sentry
895  ).move();
896 }
Class managing the creation of a new recob::Cluster object.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Unknown view.
Definition: geo_types.h:83
The data type to uniquely identify a Plane.
Definition: geo_types.h:250
static const SentryArgument_t Sentry
An instance of the sentry object.
Definition: Cluster.h:182
Int_t max
Definition: plot.C:27
Detector simulation of raw signals on wires.
virtual void SetHits(std::vector< recob::Hit const * > const &hits)=0
Sets the list of input hits.
recob::Cluster && move()
Prepares the constructed hit to be moved away.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraOutput::BuildClusters ( const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const pandora::ClusterList &  clusterList,
const CaloHitToArtHitMap pandoraHitToArtHitMap,
const IdToIdVectorMap pfoToClustersMap,
ClusterCollection outputClusters,
ClusterToHitCollection outputClustersToHits,
IdToIdVectorMap pfoToArtClustersMap 
)
staticprivate

Convert pandora 2D clusters to ART clusters and add them to the output vector Create the associations between clusters and hits. For multiple drift volumes, each pandora cluster can correspond to multiple ART clusters.

Parameters
eventthe art event
pProducerthe address of the producer module
clusterListthe input list of 2D pandora clusters to convert
pandoraHitToArtHitMapthe input mapping from pandora hits to ART hits
pfoToClustersMapthe input mapping from pfo ID to cluster IDs
outputClustersthe output vector of clusters
outputClustersToHitsthe output associations between clusters and hits
pfoToArtClustersMapthe output mapping from pfo ID to art cluster ID

Definition at line 487 of file LArPandoraOutput.cxx.

References AddAssociation().

Referenced by ProduceArtOutput().

490 {
491  cluster::StandardClusterParamsAlg clusterParamAlgo;
492 
493  // Produce the art clusters
494  size_t nextClusterId(0);
495  IdToIdVectorMap pandoraClusterToArtClustersMap;
496  for (const pandora::Cluster *const pCluster : clusterList)
497  {
498  std::vector<HitVector> hitVectors;
499  const std::vector<recob::Cluster> clusters(LArPandoraOutput::BuildClusters(pCluster, clusterList, pandoraHitToArtHitMap, pandoraClusterToArtClustersMap, hitVectors, nextClusterId, clusterParamAlgo));
500 
501  if (hitVectors.size() != clusters.size())
502  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildClusters --- invalid hit vectors for clusters produced ";
503 
504  for (unsigned int i = 0; i < clusters.size(); ++i)
505  {
506  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, nextClusterId - 1, hitVectors.at(i), outputClustersToHits);
507  outputClusters->push_back(clusters.at(i));
508  }
509  }
510 
511  // Get mapping from pfo id to art cluster id
512  for (IdToIdVectorMap::const_iterator it = pfoToClustersMap.begin(); it != pfoToClustersMap.end(); ++it)
513  {
514  if (!pfoToArtClustersMap.insert(IdToIdVectorMap::value_type(it->first, {})).second)
515  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildClusters --- repeated pfo ids ";
516 
517  for (const size_t pandoraClusterId : it->second)
518  {
519  IdToIdVectorMap::const_iterator it2(pandoraClusterToArtClustersMap.find(pandoraClusterId));
520 
521  if (it2 == pandoraClusterToArtClustersMap.end())
522  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildClusters --- found a pandora cluster with no associated recob cluster ";
523 
524  for (const size_t recobClusterId : it2->second)
525  pfoToArtClustersMap.at(it->first).push_back(recobClusterId);
526  }
527  }
528 }
static void AddAssociation(const art::Event &event, const art::EDProducer *const pProducer, 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::map< size_t, IdVector > IdToIdVectorMap
Algorithm collection class computing cluster parameters.
static void BuildClusters(const art::Event &event, const art::EDProducer *const pProducer, 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...
intermediate_table::const_iterator const_iterator
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< recob::Cluster > lar_pandora::LArPandoraOutput::BuildClusters ( const pandora::Cluster *const  pCluster,
const pandora::ClusterList &  clusterList,
const CaloHitToArtHitMap pandoraHitToArtHitMap,
IdToIdVectorMap pandoraClusterToArtClustersMap,
std::vector< HitVector > &  hitVectors,
size_t &  nextId,
cluster::ClusterParamsAlgBase algo 
)
staticprivate

Convert from a pandora 2D cluster to a vector of ART clusters (produce multiple if the cluster is split over drift volumes)

Parameters
pClusterthe input cluster
clusterListthe input list of clusters
pandoraHitToArtHitMapthe input mapping from pandora hits to ART hits
pandoraClusterToArtClustersMapoutput mapping from pandora cluster ID to art cluster IDs
hitVectorsthe output vectors of hits for each cluster produced used to produce associations
algoalgorithm set to fill cluster members
thevector of ART clusters

Definition at line 765 of file LArPandoraOutput.cxx.

References BuildCluster(), GetHitsInCluster(), GetId(), and recob::Hit::WireID().

768 {
769  std::vector<recob::Cluster> clusters;
770 
771  // Get the cluster ID and set up the map entry
772  const size_t clusterId(LArPandoraOutput::GetId(pCluster, clusterList));
773  if (!pandoraClusterToArtClustersMap.insert(IdToIdVectorMap::value_type(clusterId, {})).second)
774  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildClusters --- repeated clusters in input list ";
775 
776  pandora::CaloHitVector sortedHits;
777  LArPandoraOutput::GetHitsInCluster(pCluster, sortedHits);
778 
779  HitArray hitArray; // hits organised by drift volume
780  HitList isolatedHits;
781 
782  for (const pandora::CaloHit *const pCaloHit2D : sortedHits)
783  {
784  CaloHitToArtHitMap::const_iterator it(pandoraHitToArtHitMap.find(pCaloHit2D));
785  if (it == pandoraHitToArtHitMap.end())
786  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildClusters --- couldn't find art hit for input pandora hit ";
787 
788  const art::Ptr<recob::Hit> hit(it->second);
789 
790  const geo::WireID wireID(hit->WireID());
791  const unsigned int volID(100000 * wireID.Cryostat + wireID.TPC);
792  hitArray[volID].push_back(hit);
793 
794  if (pCaloHit2D->IsIsolated())
795  isolatedHits.insert(hit);
796  }
797 
798  if (hitArray.empty())
799  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildClusters --- found a cluster with no hits ";
800 
801  for (const HitArray::value_type &hitArrayEntry : hitArray)
802  {
803  const HitVector &clusterHits(hitArrayEntry.second);
804 
805  clusters.push_back(LArPandoraOutput::BuildCluster(nextId, clusterHits, isolatedHits, algo));
806  hitVectors.push_back(clusterHits);
807  pandoraClusterToArtClustersMap.at(clusterId).push_back(nextId);
808 
809  nextId++;
810  }
811 
812  return clusters;
813 }
static recob::Cluster BuildCluster(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 GetHitsInCluster(const pandora::Cluster *const pCluster, pandora::CaloHitVector &sortedHits)
Collect a sorted list of all 2D hits in a cluster.
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&#39;t exist...
intermediate_table::const_iterator const_iterator
std::map< int, HitVector > HitArray
std::vector< art::Ptr< recob::Hit > > HitVector
Detector simulation of raw signals on wires.
std::set< art::Ptr< recob::Hit > > HitList
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned int lar_pandora::LArPandoraOutput::BuildDummySlice ( SliceCollection outputSlices)
staticprivate

Build a new slice object with dummy information.

Parameters
outputSlicesthe output collection of slices to populate

Definition at line 634 of file LArPandoraOutput.cxx.

References max.

Referenced by BuildSlice(), and CopyAllHitsToSingleSlice().

635 {
636  // Make a slice with dummy properties
637  const float bogusFloat(std::numeric_limits<float>::max());
638  const recob::tracking::Point_t bogusPoint(bogusFloat, bogusFloat, bogusFloat);
639  const recob::tracking::Vector_t bogusVector(bogusFloat, bogusFloat, bogusFloat);
640 
641  const unsigned int sliceIndex(outputSlices->size());
642  outputSlices->emplace_back(sliceIndex, bogusPoint, bogusVector, bogusPoint, bogusPoint, bogusFloat, bogusFloat);
643 
644  return sliceIndex;
645 }
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space. See recob::tracking::Coord_t for more details on the ...
Definition: TrackingTypes.h:29
Int_t max
Definition: plot.C:27
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
Definition: TrackingTypes.h:26
void lar_pandora::LArPandoraOutput::BuildParticleMetadata ( const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const pandora::PfoVector &  pfoVector,
PFParticleMetadataCollection outputParticleMetadata,
PFParticleToMetadataCollection outputParticlesToMetadata 
)
staticprivate

Build metadata objects from a list of input pfos.

Parameters
eventthe art event
pProducerthe address of the producer module
pfoVectorthe input list of pfos
outputParticleMetadatathe output vector of PFParticleMetadata
outputParticlesToMetadatathe output associations between PFParticles and metadata

Definition at line 557 of file LArPandoraOutput.cxx.

References AddAssociation(), and lar_pandora::LArPandoraHelper::GetPFParticleMetadata().

Referenced by ProduceArtOutput().

560 {
561  for (unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
562  {
563  const pandora::ParticleFlowObject *const pPfo(pfoVector.at(pfoId));
564 
565  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, pfoId, outputParticleMetadata->size(), outputParticlesToMetadata);
567  outputParticleMetadata->push_back(pPFParticleMetadata);
568  }
569 }
static void AddAssociation(const art::Event &event, const art::EDProducer *const pProducer, 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.
Metadata associated to PFParticles.
static larpandoraobj::PFParticleMetadata GetPFParticleMetadata(const pandora::ParticleFlowObject *const pPfo)
recob::PFParticle lar_pandora::LArPandoraOutput::BuildPFParticle ( const pandora::ParticleFlowObject *const  pPfo,
const size_t  pfoId,
const pandora::PfoVector &  pfoVector 
)
staticprivate

Convert from a pfo to and ART PFParticle.

Parameters
pPfothe input pfo to convert
pfoIdthe id of the pfo to produce
pfoVectorthe input list of pfos
theART PFParticle

Definition at line 721 of file LArPandoraOutput.cxx.

References GetId(), and recob::PFParticle::kPFParticlePrimary.

Referenced by BuildPFParticles().

722 {
723  // Get parent Pfo ID
724  const pandora::PfoList &parentList(pPfo->GetParentPfoList());
725  if (parentList.size() > 1)
726  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildPFParticle --- this pfo has multiple parent particles ";
727 
728  const size_t parentId(parentList.empty() ? recob::PFParticle::kPFParticlePrimary : LArPandoraOutput::GetId(parentList.front(), pfoVector));
729 
730  // Get daughters Pfo IDs
731  std::vector<size_t> daughterIds;
732  for (const pandora::ParticleFlowObject *const pDaughterPfo : pPfo->GetDaughterPfoList())
733  daughterIds.push_back(LArPandoraOutput::GetId(pDaughterPfo, pfoVector));
734 
735  std::sort(daughterIds.begin(), daughterIds.end());
736 
737  return recob::PFParticle(pPfo->GetParticleId(), pfoId, parentId, daughterIds);
738 }
static constexpr size_t kPFParticlePrimary
Define index to signify primary particle.
Definition: PFParticle.h:61
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&#39;t exist...
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraOutput::BuildPFParticles ( const art::Event event,
const art::EDProducer *const  pProducer,
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 
)
staticprivate

Convert between pfos and PFParticles and add them to the output vector Create the associations between PFParticle and vertices, spacepoints and clusters.

Parameters
eventthe art event
pProducerthe address of the producer module
pfoVectorthe input list of pfos to convert
pfoToVerticesMapthe input mapping from pfo ID to vertex IDs
pfoToThreeDHitsMapthe input mapping from pfo ID to 3D hit IDs
pfoToArtClustersMapthe input mapping from pfo ID to ART cluster IDs
outputParticlethe output vector of PFParticles
outputParticlesToVerticesthe output associations between PFParticles and vertices
outputParticlesToSpacePointsthe output associations between PFParticles and spacepoints
outputParticlesToClustersthe output associations between PFParticles and clusters

Definition at line 532 of file LArPandoraOutput.cxx.

References AddAssociation(), and BuildPFParticle().

Referenced by ProduceArtOutput().

536 {
537  for (unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
538  {
539  const pandora::ParticleFlowObject *const pPfo(pfoVector.at(pfoId));
540 
541  outputParticles->push_back(LArPandoraOutput::BuildPFParticle(pPfo, pfoId, pfoVector));
542 
543  // Associations from PFParticle
544  if (pfoToVerticesMap.find(pfoId) != pfoToVerticesMap.end())
545  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, pfoId, pfoToVerticesMap, outputParticlesToVertices);
546 
547  if (pfoToThreeDHitsMap.find(pfoId) != pfoToThreeDHitsMap.end())
548  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, pfoId, pfoToThreeDHitsMap, outputParticlesToSpacePoints);
549 
550  if (pfoToArtClustersMap.find(pfoId) != pfoToArtClustersMap.end())
551  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, pfoId, pfoToArtClustersMap, outputParticlesToClusters);
552  }
553 }
static void AddAssociation(const art::Event &event, const art::EDProducer *const pProducer, 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 recob::PFParticle BuildPFParticle(const pandora::ParticleFlowObject *const pPfo, const size_t pfoId, const pandora::PfoVector &pfoVector)
Convert from a pfo to and ART PFParticle.
unsigned int lar_pandora::LArPandoraOutput::BuildSlice ( const pandora::ParticleFlowObject *const  pParentPfo,
const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const IdToHitMap idToHitMap,
SliceCollection outputSlices,
SliceToHitCollection outputSlicesToHits 
)
staticprivate

Build a new slice object from a PFO, this can be a top-level parent in a hierarchy or a "slice PFO" from the slicing instance.

Parameters
pParentPfothe parent pfo from which to build the slice
eventthe art event
pProducerthe address of the pandora producer
instanceLabelthe label for the collections to be produced
idToHitMapinput mapping from pandora hit ID to ART hit
outputSlicesthe output collection of slices to populate
outputSlicesToHitsthe output association from slices to hits

Definition at line 671 of file LArPandoraOutput.cxx.

References AddAssociation(), BuildDummySlice(), lar_content::LArPfoHelper::GetAllConnectedPfos(), lar_content::LArPfoHelper::GetCaloHits(), GetHit(), lar_content::LArPfoHelper::GetIsolatedCaloHits(), hits(), and lar_content::LArPfoHelper::SortByNHits().

Referenced by BuildSlices().

674 {
675  const unsigned int sliceIndex(LArPandoraOutput::BuildDummySlice(outputSlices));
676 
677  // Collect the pfos connected to the input primary pfos
678  pandora::PfoList pfosInSlice;
679  lar_content::LArPfoHelper::GetAllConnectedPfos(pParentPfo, pfosInSlice);
680  pfosInSlice.sort(lar_content::LArPfoHelper::SortByNHits);
681 
682  // Collect the hits from the pfos in all views
683  pandora::CaloHitList hits;
684  for (const pandora::ParticleFlowObject *const pPfo : pfosInSlice)
685  {
686  for (const pandora::HitType &hitType : {pandora::TPC_VIEW_U, pandora::TPC_VIEW_V, pandora::TPC_VIEW_W})
687  {
688  lar_content::LArPfoHelper::GetCaloHits(pPfo, hitType, hits);
690  }
691  }
692 
693  // Add the associations to the hits
694  for (const pandora::CaloHit *const pCaloHit : hits)
695  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, sliceIndex, {LArPandoraOutput::GetHit(idToHitMap, pCaloHit)}, outputSlicesToHits);
696 
697  return sliceIndex;
698 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
static unsigned int BuildDummySlice(SliceCollection &outputSlices)
Build a new slice object with dummy information.
static void AddAssociation(const art::Event &event, const art::EDProducer *const pProducer, 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 art::Ptr< recob::Hit > GetHit(const IdToHitMap &idToHitMap, const pandora::CaloHit *const pCaloHit)
Look up ART hit from an input Pandora hit.
void hits()
Definition: readHits.C:15
static void GetIsolatedCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of isolated calo hits of a particular hit type from a list of pfos.
static void GetAllConnectedPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively including all daughters and parents associated with those pf...
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.
void lar_pandora::LArPandoraOutput::BuildSlices ( const Settings settings,
const pandora::Pandora *const  pPrimaryPandora,
const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const pandora::PfoVector &  pfoVector,
const IdToHitMap idToHitMap,
SliceCollection outputSlices,
PFParticleToSliceCollection outputParticlesToSlices,
SliceToHitCollection outputSlicesToHits 
)
staticprivate

Build slices - collections of hits which each describe a single particle hierarchy.

Parameters
settingsthe settings
pPrimaryPandorathe primary pandora instance
eventthe art event
pProducerthe address of the pandora producer
instanceLabelthe label for the collections to be produced
pfoVectorthe input vector of all pfos to be output
idToHitMapinput mapping from pandora hit ID to ART hit
outputSlicesthe output collection of slices to populate
outputParticlesToSlicesthe output association from particles to slices
outputSlicesToHitsthe output association from slices to hits

Definition at line 573 of file LArPandoraOutput.cxx.

References AddAssociation(), BuildSlice(), CopyAllHitsToSingleSlice(), GetPandoraSlices(), lar_content::LArPfoHelper::GetParentPfo(), GetSliceIndex(), IsFromSlice(), and lar_pandora::LArPandoraOutput::Settings::m_isNeutrinoRecoOnlyNoSlicing.

Referenced by ProduceArtOutput().

577 {
578  // Check for the special case in which there are no slices, and only the neutrino reconstruction was used on all hits
579  if (settings.m_isNeutrinoRecoOnlyNoSlicing)
580  {
581  LArPandoraOutput::CopyAllHitsToSingleSlice(settings, event, pProducer, instanceLabel, pfoVector, idToHitMap, outputSlices, outputParticlesToSlices, outputSlicesToHits);
582  return;
583  }
584 
585  // Collect the slice pfos - one per slice (if there is no slicing instance, this vector will be empty)
586  pandora::PfoVector slicePfos;
587  LArPandoraOutput::GetPandoraSlices(pPrimaryPandora, slicePfos);
588 
589  // Make one slice per Pandora Slice pfo
590  for (const pandora::ParticleFlowObject *const pSlicePfo : slicePfos)
591  LArPandoraOutput::BuildSlice(pSlicePfo, event, pProducer, instanceLabel, idToHitMap, outputSlices, outputSlicesToHits);
592 
593  // Make a slice for every remaining pfo hierarchy that wasn't already in a slice
594  std::unordered_map<const pandora::ParticleFlowObject *, unsigned int> parentPfoToSliceIndexMap;
595  for (unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
596  {
597  const pandora::ParticleFlowObject *const pPfo(pfoVector.at(pfoId));
598 
599  // If this PFO is the parent of a hierarchy we have yet to use, then add a new slice
601  continue;
602 
603  if (lar_content::LArPfoHelper::GetParentPfo(pPfo) != pPfo)
604  continue;
605 
606  if (!parentPfoToSliceIndexMap.emplace(pPfo, LArPandoraOutput::BuildSlice(pPfo, event, pProducer, instanceLabel, idToHitMap, outputSlices, outputSlicesToHits)).second)
607  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildSlices --- found repeated primary particles ";
608  }
609 
610  // Add the associations from PFOs to slices
611  for (unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
612  {
613  const pandora::ParticleFlowObject *const pPfo(pfoVector.at(pfoId));
614 
615  // For PFOs that are from a Pandora slice, add the association and move on to the next PFO
617  {
618  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, pfoId, LArPandoraOutput::GetSliceIndex(pPfo), outputParticlesToSlices);
619  continue;
620  }
621 
622  // Get the parent of the particle
623  const pandora::ParticleFlowObject *const pParent(lar_content::LArPfoHelper::GetParentPfo(pPfo));
624  if (parentPfoToSliceIndexMap.find(pParent) == parentPfoToSliceIndexMap.end())
625  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildSlices --- found pfo without a parent in the input list ";
626 
627  // Add the association from the PFO to the slice
628  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, pfoId, parentPfoToSliceIndexMap.at(pParent), outputParticlesToSlices);
629  }
630 }
static void CopyAllHitsToSingleSlice(const Settings &settings, const art::Event &event, const art::EDProducer *const pProducer, 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 GetPandoraSlices(const pandora::Pandora *const pPrimaryPandora, pandora::PfoVector &slicePfos)
Get the slice pfos - one pfo per slice.
static void AddAssociation(const art::Event &event, const art::EDProducer *const pProducer, 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 IsFromSlice(const pandora::ParticleFlowObject *const pPfo)
Check if the input pfo is from a slice.
static unsigned int BuildSlice(const pandora::ParticleFlowObject *const pParentPfo, const art::Event &event, const art::EDProducer *const pProducer, 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 const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
static unsigned int GetSliceIndex(const pandora::ParticleFlowObject *const pPfo)
Get the index of the slice from which this pfo was produced.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
recob::SpacePoint lar_pandora::LArPandoraOutput::BuildSpacePoint ( const pandora::CaloHit *const  pCaloHit,
const size_t  spacePointId 
)
staticprivate

Convert from a pandora 3D hit to an ART spacepoint.

Parameters
pCaloHitthe input hit
spacePointIdthe id of the space-point to produce
theART spacepoint

Definition at line 900 of file LArPandoraOutput.cxx.

Referenced by BuildSpacePoints().

901 {
902  if (pandora::TPC_3D != pCaloHit->GetHitType())
903  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildSpacePoint --- trying to build a space point from a 2D hit";
904 
905  const pandora::CartesianVector point(pCaloHit->GetPositionVector());
906  double xyz[3] = { point.GetX(), point.GetY(), point.GetZ() };
907 
908  // ATTN using dummy information
909  double dxdydz[6] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // TODO: Fill in the error matrix
910  double chi2(0.0);
911 
912  return recob::SpacePoint(xyz, dxdydz, chi2, spacePointId);
913 }
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraOutput::BuildSpacePoints ( const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const pandora::CaloHitList &  threeDHitList,
const CaloHitToArtHitMap pandoraHitToArtHitMap,
SpacePointCollection outputSpacePoints,
SpacePointToHitCollection outputSpacePointsToHits 
)
staticprivate

Convert pandora 3D hits to ART spacepoints and add them to the output vector Create the associations between spacepoints and hits.

Parameters
eventthe art event
pProducerthe address of the producer module
threeDHitListthe input list of 3D hits to convert
pandoraHitToArtHitMapthe input mapping from pandora hits to ART hits
outputSpacePointsthe output vector of spacepoints
outputSpacePointsToHitsthe output associations between spacepoints and hits

Definition at line 465 of file LArPandoraOutput.cxx.

References AddAssociation(), and BuildSpacePoint().

Referenced by ProduceArtOutput().

468 {
469  pandora::CaloHitVector threeDHitVector;
470  threeDHitVector.insert(threeDHitVector.end(), threeDHitList.begin(), threeDHitList.end());
471 
472  for (unsigned int hitId = 0; hitId < threeDHitVector.size(); hitId++)
473  {
474  const pandora::CaloHit *const pCaloHit(threeDHitVector.at(hitId));
475 
476  CaloHitToArtHitMap::const_iterator it(pandoraHitToArtHitMap.find(pCaloHit));
477  if (it == pandoraHitToArtHitMap.end())
478  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildSpacePoints --- found a pandora hit without a corresponding art hit ";
479 
480  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, hitId, {it->second}, outputSpacePointsToHits);
481  outputSpacePoints->push_back(LArPandoraOutput::BuildSpacePoint(pCaloHit, hitId));
482  }
483 }
static recob::SpacePoint BuildSpacePoint(const pandora::CaloHit *const pCaloHit, const size_t spacePointId)
Convert from a pandora 3D hit to an ART spacepoint.
static void AddAssociation(const art::Event &event, const art::EDProducer *const pProducer, 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.
intermediate_table::const_iterator const_iterator
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool lar_pandora::LArPandoraOutput::BuildT0 ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::PfoVector &  pfoVector,
size_t &  nextId,
const CaloHitToArtHitMap pandoraHitToArtHitMap,
anab::T0 t0 
)
staticprivate

If required, build a T0 for the input pfo.

Parameters
pPfothe input pfo
pfoVectorthe input list of pfos
nextIdthe ID of the T0 - will be incremented if the t0 was produced
pandoraHitToArtHitMapthe input mapping from pandora hits to ART hits
t0the output T0
Returns
if a T0 was produced (calculated from the stitching hit shift distance)

Definition at line 917 of file LArPandoraOutput.cxx.

References CalculateT0(), Collect3DHits(), and GetId().

Referenced by BuildT0s().

919 {
920  pandora::CaloHitVector sorted3DHits;
921  LArPandoraOutput::Collect3DHits(pPfo, sorted3DHits);
922 
923  double sumT(0.), sumN(0.);
924 
925  for (const pandora::CaloHit *const pCaloHit3D : sorted3DHits)
926  {
927  if (pandora::TPC_3D != pCaloHit3D->GetHitType())
928  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildT0 --- found a 2D hit in a 3D cluster";
929 
930  const pandora::CaloHit *const pCaloHit2D = static_cast<const pandora::CaloHit*>(pCaloHit3D->GetParentAddress());
931 
932  CaloHitToArtHitMap::const_iterator it(pandoraHitToArtHitMap.find(pCaloHit2D));
933  if (it == pandoraHitToArtHitMap.end())
934  throw cet::exception("LArPandora") << " LArPandoraOutput::BuildClusters --- couldn't find art hit for input pandora hit ";
935 
936  const art::Ptr<recob::Hit> hit(it->second);
937 
938  HitVector spacePointHits;
939  spacePointHits.push_back(hit);
940 
941  // ATTN: We assume that the 2D Pandora hits have been shifted
942  sumT += LArPandoraOutput::CalculateT0(hit, pCaloHit2D);
943  sumN += 1.;
944  }
945 
946  // ATTN: T0 values are currently calculated in nanoseconds relative to the trigger offset. Only non-zero values are outputted.
947  const double T0((sumN > 0. && std::fabs(sumT) > sumN) ? (sumT / sumN) : 0.);
948 
949  if (std::fabs(T0) <= std::numeric_limits<double>::epsilon()) return false;
950 
951  // Output T0 objects [arguments are: time (nanoseconds); trigger type (3 for TPC stitching!); pfparticle SelfID code; T0 ID code]
952  t0 = anab::T0(T0, 3, LArPandoraOutput::GetId(pPfo, pfoVector), nextId++);
953 
954  return true;
955 }
static double CalculateT0(const art::Ptr< recob::Hit > hit, const pandora::CaloHit *const pCaloHit)
Convert X0 correction into T0 correction.
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&#39;t exist...
Definition: T0.h:19
intermediate_table::const_iterator const_iterator
static void Collect3DHits(const pandora::ParticleFlowObject *const pPfo, pandora::CaloHitVector &caloHits)
Collect a sorted vector of all 3D hits in the input pfo.
std::vector< art::Ptr< recob::Hit > > HitVector
Detector simulation of raw signals on wires.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraOutput::BuildT0s ( const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const pandora::PfoVector &  pfoVector,
T0Collection outputT0s,
const CaloHitToArtHitMap pandoraHitToArtHitMap,
PFParticleToT0Collection outputParticlesToT0s 
)
staticprivate

Calculate the T0 of each pfos and add them to the output vector Create the associations between PFParticle and T0s.

Parameters
eventthe art event
pProducerthe address of the producer module
pfoVectorthe input list of pfos
outputT0sthe output vector of T0s
pandoraHitToArtHitMapthe input mapping from pandora hits to ART hits
outputParticlesToT0sthe output associations between PFParticles and T0s

Definition at line 702 of file LArPandoraOutput.cxx.

References AddAssociation(), and BuildT0().

Referenced by ProduceArtOutput().

705 {
706  size_t nextT0Id(0);
707  for (unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
708  {
709  const pandora::ParticleFlowObject *const pPfo(pfoVector.at(pfoId));
710 
711  anab::T0 t0;
712  if (!LArPandoraOutput::BuildT0(pPfo, pfoVector, nextT0Id, pandoraHitToArtHitMap, t0)) continue;
713 
714  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, pfoId, nextT0Id - 1, outputParticlesToT0s);
715  outputT0s->push_back(t0);
716  }
717 }
code to link reconstructed objects back to the MC truth information
static void AddAssociation(const art::Event &event, const art::EDProducer *const pProducer, 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.
Definition: T0.h:19
static bool BuildT0(const pandora::ParticleFlowObject *const pPfo, const pandora::PfoVector &pfoVector, size_t &nextId, const CaloHitToArtHitMap &pandoraHitToArtHitMap, anab::T0 &t0)
If required, build a T0 for the input pfo.
recob::Vertex lar_pandora::LArPandoraOutput::BuildVertex ( const pandora::Vertex *const  pVertex,
const size_t  vertexId 
)
staticprivate

Convert from a pandora vertex to an ART vertex.

Parameters
pVertexthe input vertex
vertexIdthe id of the vertex to produce
theART vertex

Definition at line 742 of file LArPandoraOutput.cxx.

Referenced by BuildVertices().

743 {
744  double pos[3] = {pVertex->GetPosition().GetX(), pVertex->GetPosition().GetY(), pVertex->GetPosition().GetZ()};
745  return recob::Vertex(pos, vertexId);
746 }
Definition of vertex object for LArSoft.
Definition: Vertex.h:35
void lar_pandora::LArPandoraOutput::BuildVertices ( const pandora::VertexVector &  vertexVector,
VertexCollection outputVertices 
)
staticprivate

Convert pandora vertices to ART vertices and add them to the output vector.

Parameters
vertexVectorthe input list of pandora vertices
outputVerticesthe output vector of ART vertices

Definition at line 457 of file LArPandoraOutput.cxx.

References BuildVertex().

Referenced by ProduceArtOutput().

458 {
459  for (size_t vertexId = 0; vertexId < vertexVector.size(); ++vertexId)
460  outputVertices->push_back(LArPandoraOutput::BuildVertex(vertexVector.at(vertexId), vertexId));
461 }
static recob::Vertex BuildVertex(const pandora::Vertex *const pVertex, const size_t vertexId)
Convert from a pandora vertex to an ART vertex.
double lar_pandora::LArPandoraOutput::CalculateT0 ( const art::Ptr< recob::Hit hit,
const pandora::CaloHit *const  pCaloHit 
)
staticprivate

Convert X0 correction into T0 correction.

Parameters
hitthe input ART hit
pCaloHitthe output Pandora hit
Returns
T0 relative to input hit in nanoseconds

Definition at line 959 of file LArPandoraOutput.cxx.

References geo::GeometryCore::Cryostat(), dir, geo::kNegX, recob::Hit::PeakTime(), geo::CryostatGeo::TPC(), and recob::Hit::WireID().

Referenced by BuildT0().

960 {
962  auto const* theDetector = lar::providerFrom<detinfo::DetectorPropertiesService>();
963 
964  const geo::WireID hit_WireID(hit->WireID());
965  const geo::TPCGeo &theTpc = theGeometry->Cryostat(hit_WireID.Cryostat).TPC(hit_WireID.TPC);
966 
967  // Calculate shift in x position between input and output hits
968  const double input_xpos_cm(theDetector->ConvertTicksToX(hit->PeakTime(), hit_WireID.Plane, hit_WireID.TPC, hit_WireID.Cryostat));
969  const double output_xpos_dm(pCaloHit->GetPositionVector().GetX());
970  const double x0_cm(output_xpos_dm - input_xpos_cm);
971 
972  // The ingredients for the T0 calculation all come from the detector properties service
973  const double dir((theTpc.DriftDirection() == geo::kNegX) ? 1.0 : -1.0);
974  const double cm_per_tick(theDetector->GetXTicksCoefficient());
975  const double ns_per_tick(theDetector->SamplingRate());
976 
977  // This calculation should give the T0 in nanoseconds relative to the initial 2D hit
978  return (- dir * x0_cm * ns_per_tick / cm_per_tick);
979 }
geo::WireID WireID() const
Initial tdc tick for hit.
Definition: Hit.h:234
Geometry information for a single TPC.
Definition: TPCGeo.h:37
Drift towards negative X values.
Definition: geo_types.h:109
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
float PeakTime() const
Time of the signal peak, in tick units.
Definition: Hit.h:219
TDirectory * dir
Definition: macro.C:5
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc&#39;th TPC in the cryostat.
void lar_pandora::LArPandoraOutput::Collect3DHits ( const pandora::ParticleFlowObject *const  pPfo,
pandora::CaloHitVector &  caloHits 
)
staticprivate

Collect a sorted vector of all 3D hits in the input pfo.

Parameters
pPfothe input pfo
caloHitsthe sorted output vector of 3D hits

Definition at line 381 of file LArPandoraOutput.cxx.

References lar_content::LArPfoHelper::GetCaloHits(), and lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by BuildT0(), Collect3DHits(), and ProduceArtOutput().

382 {
383  // Get the sorted list of 3D hits associated with the pfo
384  pandora::CaloHitList threeDHits;
385  lar_content::LArPfoHelper::GetCaloHits(pPfo, pandora::TPC_3D, threeDHits);
386 
387  caloHits.insert(caloHits.end(), threeDHits.begin(), threeDHits.end());
388  std::sort(caloHits.begin(), caloHits.end(), lar_content::LArClusterHelper::SortHitsByPosition);
389 }
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.
pandora::CaloHitList lar_pandora::LArPandoraOutput::Collect3DHits ( const pandora::PfoVector &  pfoVector,
IdToIdVectorMap pfoToThreeDHitsMap 
)
staticprivate

Collect a sorted list of all 3D hits contained in the input pfo list Order is guaranteed provided pfoVector is ordered.

Parameters
pfoVectorthe input list of pfos
pfoToThreeDHitsMapthe output mapping from pfo ID to 3D hit IDs
Returns
the list of 3D hits collected

Definition at line 352 of file LArPandoraOutput.cxx.

References Collect3DHits().

353 {
354  pandora::CaloHitList caloHitList;
355 
356  for (unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
357  {
358  const pandora::ParticleFlowObject *const pPfo(pfoVector.at(pfoId));
359 
360  if (!pfoToThreeDHitsMap.insert(IdToIdVectorMap::value_type(pfoId, {})).second)
361  throw cet::exception("LArPandora") << " LArPandoraOutput::Collect3DHits --- repeated pfos in input list ";
362 
363  pandora::CaloHitVector sorted3DHits;
364  LArPandoraOutput::Collect3DHits(pPfo, sorted3DHits);
365 
366  for (const pandora::CaloHit *const pCaloHit3D : sorted3DHits)
367  {
368  if (pandora::TPC_3D != pCaloHit3D->GetHitType()) // TODO decide if this is required, or should I just insert them?
369  throw cet::exception("LArPandora") << " LArPandoraOutput::Collect3DHits --- found a 2D hit in a 3D cluster";
370 
371  pfoToThreeDHitsMap.at(pfoId).push_back(caloHitList.size());
372  caloHitList.push_back(pCaloHit3D);
373  }
374  }
375 
376  return caloHitList;
377 }
static void Collect3DHits(const pandora::ParticleFlowObject *const pPfo, pandora::CaloHitVector &caloHits)
Collect a sorted vector of all 3D hits in the input pfo.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
pandora::PfoVector lar_pandora::LArPandoraOutput::CollectAllPfoOutcomes ( const pandora::Pandora *const  pPrimaryPandora)
staticprivate

Collect the pfos (including all downstream pfos) from the master and daughter pandora instances.

Parameters
pPrimaryPandoraaddress of master pandora instance
Returns
a sorted list of all pfos to convert to ART PFParticles

Definition at line 178 of file LArPandoraOutput.cxx.

References CollectPfos(), GetPandoraInstance(), GetPandoraSlices(), IsClearCosmic(), and util::flags::to_string().

Referenced by ProduceArtOutput().

179 {
180  pandora::PfoList collectedPfos;
181 
182  // Get the list of slice pfos - one per slice
183  pandora::PfoVector slicePfos;
184  LArPandoraOutput::GetPandoraSlices(pPrimaryPandora, slicePfos);
185 
186  // Identify the pandora worker instances by their name
187  const pandora::Pandora *pSliceNuWorker(nullptr);
188  if (!LArPandoraOutput::GetPandoraInstance(pPrimaryPandora, "SliceNuWorker", pSliceNuWorker))
189  throw cet::exception("LArPandora") << " LArPandoraOutput::CollectAllPfoOutcomes--- Can't find slice nu worker instance. ";
190 
191  const pandora::Pandora *pSliceCRWorker(nullptr);
192  if (!LArPandoraOutput::GetPandoraInstance(pPrimaryPandora, "SliceCRWorker", pSliceCRWorker))
193  throw cet::exception("LArPandora") << " LArPandoraOutput::CollectAllPfoOutcomes--- Can't find slice CR worker instance. ";
194 
195  // Collect slices under both reconstruction hypotheses
196  for (unsigned int sliceIndex = 0; sliceIndex < slicePfos.size(); ++sliceIndex)
197  {
198  const pandora::PfoList *pNuPfoList(nullptr);
199  if (pandora::STATUS_CODE_SUCCESS == PandoraApi::GetPfoList(*pSliceNuWorker, "NeutrinoParticles3D" + std::to_string(sliceIndex), pNuPfoList))
200  collectedPfos.insert(collectedPfos.end(), pNuPfoList->begin(), pNuPfoList->end());
201 
202  const pandora::PfoList *pCRPfoList(nullptr);
203  if (pandora::STATUS_CODE_SUCCESS == PandoraApi::GetPfoList(*pSliceCRWorker, "MuonParticles3D" + std::to_string(sliceIndex), pCRPfoList))
204  collectedPfos.insert(collectedPfos.end(), pCRPfoList->begin(), pCRPfoList->end());
205  }
206 
207  // Get the list of the parent pfos from the primary pandora instance
208  const pandora::PfoList *pParentPfoList(nullptr);
209  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*pPrimaryPandora, pParentPfoList));
210 
211  // Collect clear cosmic-rays
212  for (const pandora::ParticleFlowObject *const pPfo : *pParentPfoList)
213  {
215  collectedPfos.push_back(pPfo);
216  }
217 
218  // Collect all pfos that are downstream of the parents we have collected
219  pandora::PfoVector pfoVector;
220  LArPandoraOutput::CollectPfos(collectedPfos, pfoVector);
221 
222  return pfoVector;
223 }
static void GetPandoraSlices(const pandora::Pandora *const pPrimaryPandora, pandora::PfoVector &slicePfos)
Get the slice pfos - one pfo per slice.
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 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.
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
pandora::ClusterList lar_pandora::LArPandoraOutput::CollectClusters ( const pandora::PfoVector &  pfoVector,
IdToIdVectorMap pfoToClustersMap 
)
staticprivate

Collect a sorted list of all 2D clusters contained in the input pfo list Order is guaranteed provided pfoVector is ordered.

Parameters
pfoVectorthe input list of pfos
pfoToClustersMapthe output mapping from pfo ID to cluster IDs
Returns
the list of clusters collected

Definition at line 324 of file LArPandoraOutput.cxx.

References lar_content::LArPfoHelper::GetTwoDClusterList(), and lar_content::LArClusterHelper::SortByNHits().

Referenced by ProduceArtOutput().

325 {
326  pandora::ClusterList clusterList;
327 
328  for (unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
329  {
330  const pandora::ParticleFlowObject *const pPfo(pfoVector.at(pfoId));
331 
332  // Get the sorted list of clusters from the pfo
333  pandora::ClusterList clusters;
336 
337  // Get incrementing id's for each cluster
338  IdVector clusterIds(clusters.size());
339  std::iota(clusterIds.begin(), clusterIds.end(), clusterList.size());
340 
341  clusterList.insert(clusterList.end(), clusters.begin(), clusters.end());
342 
343  if (!pfoToClustersMap.insert(IdToIdVectorMap::value_type(pfoId, clusterIds)).second)
344  throw cet::exception("LArPandora") << " LArPandoraOutput::CollectClusters --- repeated pfos in input list ";
345  }
346 
347  return clusterList;
348 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
Definition: LArPfoHelper.cc:97
std::vector< size_t > IdVector
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
pandora::PfoVector lar_pandora::LArPandoraOutput::CollectPfos ( const pandora::Pandora *const  pPrimaryPandora)
staticprivate

Collect the current pfos (including all downstream pfos) from the master pandora instance.

Parameters
pPrimaryPandoraaddress of master pandora instance
Returns
a sorted list of all pfos to convert to ART PFParticles

Definition at line 267 of file LArPandoraOutput.cxx.

Referenced by CollectAllPfoOutcomes(), and ProduceArtOutput().

268 {
269  const pandora::PfoList *pParentPfoList(nullptr);
270  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*pPrimaryPandora, pParentPfoList));
271 
272  pandora::PfoVector pfoVector;
273  LArPandoraOutput::CollectPfos(*pParentPfoList, pfoVector);
274 
275  return pfoVector;
276 }
static pandora::PfoVector CollectPfos(const pandora::Pandora *const pPrimaryPandora)
Collect the current pfos (including all downstream pfos) from the master pandora instance.
void lar_pandora::LArPandoraOutput::CollectPfos ( const pandora::PfoList &  parentPfoList,
pandora::PfoVector &  pfoVector 
)
staticprivate

Collect a sorted list of all downstream pfos of an input list of parent.

Parameters
parentPfoListthe input list of parent pfos
pfoVectorthe sorted output list of all downstream pfos

Definition at line 280 of file LArPandoraOutput.cxx.

References lar_content::LArPfoHelper::GetAllConnectedPfos(), and lar_content::LArPfoHelper::SortByNHits().

281 {
282  if (!pfoVector.empty())
283  throw cet::exception("LArPandora") << " LArPandoraOutput::CollectPfos--- trying to collect pfos into a non-empty list ";
284 
285  pandora::PfoList pfoList;
286  lar_content::LArPfoHelper::GetAllConnectedPfos(parentPfoList, pfoList);
287 
288  pfoVector.insert(pfoVector.end(), pfoList.begin(), pfoList.end());
289  std::sort(pfoVector.begin(), pfoVector.end(), lar_content::LArPfoHelper::SortByNHits);
290 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
static void GetAllConnectedPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively including all daughters and parents associated with those pf...
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
pandora::VertexVector lar_pandora::LArPandoraOutput::CollectVertices ( const pandora::PfoVector &  pfoVector,
IdToIdVectorMap pfoToVerticesMap 
)
staticprivate

Collect all vertices contained in the input pfo list Order is guaranteed provided pfoVector is ordered.

Parameters
pfoVectorthe input list of pfos
pfoToVerticesMapthe output mapping from pfo ID to vertex IDs (zero or one)
Returns
the list of vertices collected

Definition at line 294 of file LArPandoraOutput.cxx.

References lar_content::LArPfoHelper::GetVertex().

Referenced by ProduceArtOutput().

295 {
296  pandora::VertexVector vertexVector;
297 
298  for (unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
299  {
300  const pandora::ParticleFlowObject *const pPfo(pfoVector.at(pfoId));
301 
302  if (pPfo->GetVertexList().empty())
303  continue;
304 
305  const pandora::Vertex *const pVertex(lar_content::LArPfoHelper::GetVertex(pPfo));
306 
307  // Get the vertex ID and add it to the vertex list if required
308  const auto it(std::find(vertexVector.begin(), vertexVector.end(), pVertex));
309  const bool isInList(it != vertexVector.end());
310  const size_t vertexId(isInList ? std::distance(vertexVector.begin(), it) : vertexVector.size());
311 
312  if (!isInList)
313  vertexVector.push_back(pVertex);
314 
315  if (!pfoToVerticesMap.insert(IdToIdVectorMap::value_type(pfoId, {vertexId})).second)
316  throw cet::exception("LArPandora") << " LArPandoraOutput::CollectVertices --- repeated pfos in input list ";
317  }
318 
319  return vertexVector;
320 }
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
std::vector< art::Ptr< recob::Vertex > > VertexVector
void lar_pandora::LArPandoraOutput::CopyAllHitsToSingleSlice ( const Settings settings,
const art::Event event,
const art::EDProducer *const  pProducer,
const std::string &  instanceLabel,
const pandora::PfoVector &  pfoVector,
const IdToHitMap idToHitMap,
SliceCollection outputSlices,
PFParticleToSliceCollection outputParticlesToSlices,
SliceToHitCollection outputSlicesToHits 
)
staticprivate

Ouput a single slice containing all of the input hits.

Parameters
settingsthe settings
eventthe art event
pProducerthe address of the pandora producer
instanceLabelthe label for the collections to be produced
pfoVectorthe input vector of all pfos to be output
idToHitMapinput mapping from pandora hit ID to ART hit
outputSlicesthe output collection of slices to populate
outputParticlesToSlicesthe output association from particles to slices
outputSlicesToHitsthe output association from slices to hits

Definition at line 649 of file LArPandoraOutput.cxx.

References AddAssociation(), BuildDummySlice(), lar_pandora::LArPandoraHelper::CollectHits(), hits(), and lar_pandora::LArPandoraOutput::Settings::m_hitfinderModuleLabel.

Referenced by BuildSlices().

652 {
653  const unsigned int sliceIndex(LArPandoraOutput::BuildDummySlice(outputSlices));
654 
655  // Add all of the hits in the events to the slice
656  HitVector hits;
657  LArPandoraHelper::CollectHits(event, settings.m_hitfinderModuleLabel, hits);
658  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, sliceIndex, hits, outputSlicesToHits);
659 
660  mf::LogDebug("LArPandora") << "Finding hits with label: " << settings.m_hitfinderModuleLabel << std::endl;
661  mf::LogDebug("LArPandora") << " - Found " << hits.size() << std::endl;
662  mf::LogDebug("LArPandora") << " - Making associations " << outputSlicesToHits->size() << std::endl;
663 
664  // Add all of the PFOs to the slice
665  for (unsigned int pfoId = 0; pfoId < pfoVector.size(); ++pfoId)
666  LArPandoraOutput::AddAssociation(event, pProducer, instanceLabel, pfoId, sliceIndex, outputParticlesToSlices);
667 }
static unsigned int BuildDummySlice(SliceCollection &outputSlices)
Build a new slice object with dummy information.
static void AddAssociation(const art::Event &event, const art::EDProducer *const pProducer, 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.
void hits()
Definition: readHits.C:15
std::vector< art::Ptr< recob::Hit > > HitVector
static void CollectHits(const art::Event &evt, const std::string &label, HitVector &hitVector)
Collect the reconstructed Hits from the ART event record.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
art::Ptr< recob::Hit > lar_pandora::LArPandoraOutput::GetHit ( const IdToHitMap idToHitMap,
const pandora::CaloHit *const  pCaloHit 
)
staticprivate

Look up ART hit from an input Pandora hit.

Parameters
idToHitMapthe mapping between Pandora and ART hits
pCaloHitthe input Pandora hit (2D)

Definition at line 425 of file LArPandoraOutput.cxx.

Referenced by BuildSlice(), and GetPandoraToArtHitMap().

426 {
427  // TODO make this less evil
428 
429  // ATTN The CaloHit can come from the primary pandora instance (depth = 0) or one of its daughers (depth = 1).
430  // Here we keep trying to access the ART hit increasing the depth step-by-step
431  for (unsigned int depth = 0, maxDepth = 2; depth < maxDepth; ++depth)
432  {
433  // Navigate to the hit address in the pandora master instance (assuming the depth is correct)
434  const pandora::CaloHit *pParentCaloHit = pCaloHit;
435  for (unsigned int i = 0; i < depth; ++i)
436  pParentCaloHit = static_cast<const pandora::CaloHit *>(pCaloHit->GetParentAddress());
437 
438  // Attempt to find the mapping from the "parent" calo hit to the ART hit
439  const void *const pHitAddress(pParentCaloHit->GetParentAddress());
440  const intptr_t hitID_temp((intptr_t)(pHitAddress));
441  const int hitID((int)(hitID_temp));
442 
443  IdToHitMap::const_iterator artIter = idToHitMap.find(hitID);
444 
445  // If there is no such mapping from "parent" calo hit to the ART hit, then increase the depth and try again!
446  if (idToHitMap.end() == artIter)
447  continue;
448 
449  return artIter->second;
450  }
451 
452  throw cet::exception("LArPandora") << " LArPandoraOutput::GetHit --- found a Pandora hit without a parent ART hit ";
453 }
intermediate_table::const_iterator const_iterator
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraOutput::GetHitsInCluster ( const pandora::Cluster *const  pCluster,
pandora::CaloHitVector &  sortedHits 
)
staticprivate

Collect a sorted list of all 2D hits in a cluster.

Parameters
pClusterthe input cluster
sortedHitsthe output vector of sorted 2D hits

Definition at line 750 of file LArPandoraOutput.cxx.

References lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by BuildClusters(), and GetPandoraToArtHitMap().

751 {
752  if (!sortedHits.empty())
753  throw cet::exception("LArPandora") << " LArPandoraOutput::GetHitsInCluster --- vector to hold hits is not empty ";
754 
755  pandora::CaloHitList hitList;
756  pCluster->GetOrderedCaloHitList().FillCaloHitList(hitList);
757  hitList.insert(hitList.end(), pCluster->GetIsolatedCaloHitList().begin(), pCluster->GetIsolatedCaloHitList().end());
758 
759  sortedHits.insert(sortedHits.end(), hitList.begin(), hitList.end());
760  std::sort(sortedHits.begin(), sortedHits.end(), lar_content::LArClusterHelper::SortHitsByPosition);
761 }
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T >
size_t lar_pandora::LArPandoraOutput::GetId ( const T *const  pT,
const std::list< const T * > &  tList 
)
inlinestaticprivate

Find the index of an input object in an input list. Throw an exception if it doesn't exist.

Parameters
pTthe input object for which the ID should be found
tLista list of objects of type pT to query
Returns
the ID of the input object

Definition at line 533 of file LArPandoraOutput.h.

Referenced by BuildClusters(), BuildPFParticle(), and BuildT0().

534 {
535  typename std::list<const T*>::const_iterator it(std::find(tList.begin(), tList.end(), pT));
536 
537  if (it == tList.end())
538  throw cet::exception("LArPandora") << " LArPandoraOutput::GetId --- can't find the id of supplied object";
539 
540  return static_cast<size_t>(std::distance(tList.begin(), it));
541 }
intermediate_table::const_iterator const_iterator
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
template<typename T >
size_t lar_pandora::LArPandoraOutput::GetId ( const T *const  pT,
const std::vector< const T * > &  tVector 
)
inlinestaticprivate

Find the index of an input object in an input vector. Throw an exception if it doesn't exist.

Parameters
pTthe input object for which the ID should be found
tVectora list of objects of type pT to query
Returns
the ID of the input object

Definition at line 546 of file LArPandoraOutput.h.

547 {
548  typename std::vector<const T*>::const_iterator it(std::find(tVector.begin(), tVector.end(), pT));
549 
550  if (it == tVector.end())
551  throw cet::exception("LArPandora") << " LArPandoraOutput::GetId --- can't find the id of supplied object";
552 
553  return static_cast<size_t>(std::distance(tVector.begin(), it));
554 }
intermediate_table::const_iterator const_iterator
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool lar_pandora::LArPandoraOutput::GetPandoraInstance ( const pandora::Pandora *const  pPrimaryPandora,
const std::string &  name,
const pandora::Pandora *&  pPandoraInstance 
)
staticprivate

Get the address of a pandora instance with a given name.

Parameters
pPrimaryPandorathe primary pandora instance
namethe name of the instance to collect
pPandoraInstancethe output address of the pandora instance requested
Returns
if the pandora instance could be found

Definition at line 134 of file LArPandoraOutput.cxx.

References MultiPandoraApi::GetDaughterPandoraInstanceList().

Referenced by CollectAllPfoOutcomes(), and GetPandoraSlices().

136 {
137  if (!pPrimaryPandora)
138  throw cet::exception("LArPandora") << " LArPandoraOutput::GetPandoraInstance--- input primary pandora instance address is invalid ";
139 
140  if (pPandoraInstance)
141  throw cet::exception("LArPandora") << " LArPandoraOutput::GetPandoraInstance--- the input pandora instance address is non-null ";
142 
143  for (const pandora::Pandora *const pPandora : MultiPandoraApi::GetDaughterPandoraInstanceList(pPrimaryPandora))
144  {
145  if (pPandora->GetName() != name)
146  continue;
147 
148  if (pPandoraInstance)
149  throw cet::exception("LArPandora") << " LArPandoraOutput::GetPandoraInstance--- found multiple pandora instances with name: " << name;
150 
151  pPandoraInstance = pPandora;
152  }
153 
154  return static_cast<bool>(pPandoraInstance);
155 }
static const PandoraInstanceList & GetDaughterPandoraInstanceList(const pandora::Pandora *const pPrimaryPandora)
Get the list of daughter pandora instances associated with a given primary pandora instance...
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraOutput::GetPandoraSlices ( const pandora::Pandora *const  pPrimaryPandora,
pandora::PfoVector &  slicePfos 
)
staticprivate

Get the slice pfos - one pfo per slice.

Parameters
pPrimaryPandorathe primary pandora instance
slicePfosthe output vector of slice pfos

Definition at line 159 of file LArPandoraOutput.cxx.

References GetPandoraInstance().

Referenced by BuildSlices(), and CollectAllPfoOutcomes().

160 {
161  if (!slicePfos.empty())
162  throw cet::exception("LArPandora") << " LArPandoraOutput::GetPandoraSlices--- Input slicePfo vector is not empty ";
163 
164  // Get the pandora slicing worker - if it exists
165  const pandora::Pandora *pSlicingWorker(nullptr);
166  if (!LArPandoraOutput::GetPandoraInstance(pPrimaryPandora, "SlicingWorker", pSlicingWorker))
167  return;
168 
169  // Get the slice PFOs - one PFO per slice
170  const pandora::PfoList *pSlicePfoList(nullptr);
171  PANDORA_THROW_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(*pSlicingWorker, pSlicePfoList));
172 
173  slicePfos.insert(slicePfos.end(), pSlicePfoList->begin(), pSlicePfoList->end());
174 }
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.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraOutput::GetPandoraToArtHitMap ( const pandora::ClusterList &  clusterList,
const pandora::CaloHitList &  threeDHitList,
const IdToHitMap idToHitMap,
CaloHitToArtHitMap pandoraHitToArtHitMap 
)
staticprivate

Collect all 2D and 3D hits that were used / produced in the reconstruction and map them to their corresponding ART hit.

Parameters
clusterListinput list of all 2D clusters to be output
threeDHitListinput list of all 3D hits to be output (as spacepoints)
idToHitMapinput mapping from pandora hit ID to ART hit
pandoraHitToArtHitMapoutput mapping from pandora hit to ART hit

Definition at line 393 of file LArPandoraOutput.cxx.

References lar_content::LArClusterHelper::GetClusterHitType(), GetHit(), and GetHitsInCluster().

Referenced by ProduceArtOutput().

395 {
396  // Collect 2D hits from clusters
397  for (const pandora::Cluster *const pCluster : clusterList)
398  {
399  if (pandora::TPC_3D == lar_content::LArClusterHelper::GetClusterHitType(pCluster))
400  throw cet::exception("LArPandora") << " LArPandoraOutput::GetPandoraToArtHitMap --- found a 3D input cluster ";
401 
402  pandora::CaloHitVector sortedHits;
403  LArPandoraOutput::GetHitsInCluster(pCluster, sortedHits);
404 
405  for (const pandora::CaloHit *const pCaloHit : sortedHits)
406  {
407  if (!pandoraHitToArtHitMap.insert(CaloHitToArtHitMap::value_type(pCaloHit, LArPandoraOutput::GetHit(idToHitMap, pCaloHit))).second)
408  throw cet::exception("LArPandora") << " LArPandoraOutput::GetPandoraToArtHitMap --- found repeated input hits ";
409  }
410  }
411 
412  for (const pandora::CaloHit *const pCaloHit : threeDHitList)
413  {
414  if (pCaloHit->GetHitType() != pandora::TPC_3D)
415  throw cet::exception("LArPandora") << " LArPandoraOutput::GetPandoraToArtHitMap --- found a non-3D hit in the input list ";
416 
417  // ATTN get the 2D calo hit from the 3D calo hit then find the art hit!
418  if (!pandoraHitToArtHitMap.insert(CaloHitToArtHitMap::value_type(pCaloHit, LArPandoraOutput::GetHit(idToHitMap, static_cast<const pandora::CaloHit*>(pCaloHit->GetParentAddress())))).second)
419  throw cet::exception("LArPandora") << " LArPandoraOutput::GetPandoraToArtHitMap --- found repeated input hits ";
420  }
421 }
static void GetHitsInCluster(const pandora::Cluster *const pCluster, pandora::CaloHitVector &sortedHits)
Collect a sorted list of all 2D hits in a cluster.
static art::Ptr< recob::Hit > GetHit(const IdToHitMap &idToHitMap, const pandora::CaloHit *const pCaloHit)
Look up ART hit from an input Pandora hit.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
unsigned int lar_pandora::LArPandoraOutput::GetSliceIndex ( const pandora::ParticleFlowObject *const  pPfo)
staticprivate

Get the index of the slice from which this pfo was produced.

Parameters
pPfothe input pfo
Returns
the slice index

Definition at line 252 of file LArPandoraOutput.cxx.

References lar_content::LArPfoHelper::GetParentPfo().

Referenced by BuildSlices().

253 {
254  const pandora::ParticleFlowObject *const pParent(lar_content::LArPfoHelper::GetParentPfo(pPfo));
255 
256  const auto &properties(pParent->GetPropertiesMap());
257  const auto it(properties.find("SliceIndex"));
258 
259  if (it == properties.end())
260  throw cet::exception("LArPandora") << " LArPandoraOutput::GetSliceIndex--- Input PFO was not from a slice ";
261 
262  return static_cast<unsigned int>(std::round(it->second));
263 }
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool lar_pandora::LArPandoraOutput::IsClearCosmic ( const pandora::ParticleFlowObject *const  pPfo)
staticprivate

Check if the input pfo is an unambiguous cosmic ray.

Parameters
pPfothe input pfo
Returns
if the input pfo is a clear cosmic ray

Definition at line 227 of file LArPandoraOutput.cxx.

References lar_content::LArPfoHelper::GetParentPfo().

Referenced by CollectAllPfoOutcomes().

228 {
229  const pandora::ParticleFlowObject *const pParent(lar_content::LArPfoHelper::GetParentPfo(pPfo));
230 
231  const auto &properties(pParent->GetPropertiesMap());
232  const auto it(properties.find("IsClearCosmic"));
233 
234  if (it == properties.end())
235  return false;
236 
237  return static_cast<bool>(std::round(it->second));
238 }
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
bool lar_pandora::LArPandoraOutput::IsFromSlice ( const pandora::ParticleFlowObject *const  pPfo)
staticprivate

Check if the input pfo is from a slice.

Parameters
pPfothe input pfo
Returns
if the input pfo is from a slice

Definition at line 242 of file LArPandoraOutput.cxx.

References lar_content::LArPfoHelper::GetParentPfo().

Referenced by BuildSlices().

243 {
244  const pandora::ParticleFlowObject *const pParent(lar_content::LArPfoHelper::GetParentPfo(pPfo));
245 
246  const auto &properties(pParent->GetPropertiesMap());
247  return (properties.find("SliceIndex") != properties.end());
248 }
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
void lar_pandora::LArPandoraOutput::ProduceArtOutput ( const Settings settings,
const IdToHitMap idToHitMap,
art::Event evt 
)
static

Convert the Pandora PFOs into ART clusters and write into ART event.

Parameters
settingsthe settings
idToHitMapthe mapping from Pandora hit ID to ART hit
evtthe ART event

Definition at line 50 of file LArPandoraOutput.cxx.

References BuildClusters(), BuildParticleMetadata(), BuildPFParticles(), BuildSlices(), BuildSpacePoints(), BuildT0s(), BuildVertices(), Collect3DHits(), CollectAllPfoOutcomes(), CollectClusters(), CollectPfos(), CollectVertices(), GetPandoraToArtHitMap(), lar_pandora::LArPandoraOutput::Settings::m_allOutcomesInstanceLabel, lar_pandora::LArPandoraOutput::Settings::m_pPrimaryPandora, lar_pandora::LArPandoraOutput::Settings::m_pProducer, lar_pandora::LArPandoraOutput::Settings::m_shouldProduceAllOutcomes, lar_pandora::LArPandoraOutput::Settings::m_shouldRunStitching, art::Event::put(), and lar_pandora::LArPandoraOutput::Settings::Validate().

Referenced by lar_pandora::LArPandora::ProcessPandoraOutput().

51 {
52  settings.Validate();
53  const std::string instanceLabel(settings.m_shouldProduceAllOutcomes ? settings.m_allOutcomesInstanceLabel : "");
54 
55  // Set up the output collections
56  PFParticleCollection outputParticles( new std::vector<recob::PFParticle> );
57  VertexCollection outputVertices( new std::vector<recob::Vertex> );
58  ClusterCollection outputClusters( new std::vector<recob::Cluster> );
59  SpacePointCollection outputSpacePoints( new std::vector<recob::SpacePoint> );
60  T0Collection outputT0s( new std::vector<anab::T0> );
61  PFParticleMetadataCollection outputParticleMetadata( new std::vector<larpandoraobj::PFParticleMetadata> );
62  SliceCollection outputSlices( new std::vector<recob::Slice> );
63 
64  // Set up the output associations
74 
75  // Collect immutable lists of pandora collections that we should convert to ART format
76  const pandora::PfoVector pfoVector(settings.m_shouldProduceAllOutcomes ?
77  LArPandoraOutput::CollectAllPfoOutcomes(settings.m_pPrimaryPandora) :
78  LArPandoraOutput::CollectPfos(settings.m_pPrimaryPandora));
79 
80  IdToIdVectorMap pfoToVerticesMap;
81  const pandora::VertexVector vertexVector(LArPandoraOutput::CollectVertices(pfoVector, pfoToVerticesMap));
82 
83  IdToIdVectorMap pfoToClustersMap;
84  const pandora::ClusterList clusterList(LArPandoraOutput::CollectClusters(pfoVector, pfoToClustersMap));
85 
86  IdToIdVectorMap pfoToThreeDHitsMap;
87  const pandora::CaloHitList threeDHitList(LArPandoraOutput::Collect3DHits(pfoVector, pfoToThreeDHitsMap));
88 
89  // Get mapping from pandora hits to art hits
90  CaloHitToArtHitMap pandoraHitToArtHitMap;
91  LArPandoraOutput::GetPandoraToArtHitMap(clusterList, threeDHitList, idToHitMap, pandoraHitToArtHitMap);
92 
93  // Build the ART outputs from the pandora objects
94  LArPandoraOutput::BuildVertices(vertexVector, outputVertices);
95  LArPandoraOutput::BuildSpacePoints(evt, settings.m_pProducer, instanceLabel, threeDHitList, pandoraHitToArtHitMap, outputSpacePoints, outputSpacePointsToHits);
96 
97  IdToIdVectorMap pfoToArtClustersMap;
98  LArPandoraOutput::BuildClusters(evt, settings.m_pProducer, instanceLabel, clusterList, pandoraHitToArtHitMap, pfoToClustersMap, outputClusters, outputClustersToHits, pfoToArtClustersMap);
99 
100  LArPandoraOutput::BuildPFParticles(evt, settings.m_pProducer, instanceLabel, pfoVector, pfoToVerticesMap, pfoToThreeDHitsMap, pfoToArtClustersMap, outputParticles, outputParticlesToVertices, outputParticlesToSpacePoints, outputParticlesToClusters);
101 
102  LArPandoraOutput::BuildParticleMetadata(evt, settings.m_pProducer, instanceLabel, pfoVector, outputParticleMetadata, outputParticlesToMetadata);
103  LArPandoraOutput::BuildSlices(settings, settings.m_pPrimaryPandora, evt, settings.m_pProducer, instanceLabel, pfoVector, idToHitMap, outputSlices, outputParticlesToSlices, outputSlicesToHits);
104 
105  if (settings.m_shouldRunStitching)
106  LArPandoraOutput::BuildT0s(evt, settings.m_pProducer, instanceLabel, pfoVector, outputT0s, pandoraHitToArtHitMap, outputParticlesToT0s);
107 
108  // Add the outputs to the event
109  evt.put(std::move(outputParticles), instanceLabel);
110  evt.put(std::move(outputSpacePoints), instanceLabel);
111  evt.put(std::move(outputClusters), instanceLabel);
112  evt.put(std::move(outputVertices), instanceLabel);
113  evt.put(std::move(outputParticleMetadata), instanceLabel);
114  evt.put(std::move(outputSlices), instanceLabel);
115 
116  evt.put(std::move(outputParticlesToMetadata), instanceLabel);
117  evt.put(std::move(outputParticlesToSpacePoints), instanceLabel);
118  evt.put(std::move(outputParticlesToClusters), instanceLabel);
119  evt.put(std::move(outputParticlesToVertices), instanceLabel);
120  evt.put(std::move(outputParticlesToSlices), instanceLabel);
121  evt.put(std::move(outputSpacePointsToHits), instanceLabel);
122  evt.put(std::move(outputClustersToHits), instanceLabel);
123  evt.put(std::move(outputSlicesToHits), instanceLabel);
124 
125  if (settings.m_shouldRunStitching)
126  {
127  evt.put(std::move(outputT0s), instanceLabel);
128  evt.put(std::move(outputParticlesToT0s), instanceLabel);
129  }
130 }
static void BuildPFParticles(const art::Event &event, const art::EDProducer *const pProducer, 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 pandora::VertexVector CollectVertices(const pandora::PfoVector &pfoVector, IdToIdVectorMap &pfoToVerticesMap)
Collect all vertices contained in the input pfo list Order is guaranteed provided pfoVector is ordere...
std::unique_ptr< art::Assns< recob::PFParticle, anab::T0 > > PFParticleToT0Collection
std::unique_ptr< std::vector< recob::Cluster > > ClusterCollection
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 BuildParticleMetadata(const art::Event &event, const art::EDProducer *const pProducer, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, PFParticleMetadataCollection &outputParticleMetadata, PFParticleToMetadataCollection &outputParticlesToMetadata)
Build metadata objects from a list of input pfos.
std::map< size_t, IdVector > IdToIdVectorMap
std::map< const pandora::CaloHit *, art::Ptr< recob::Hit > > CaloHitToArtHitMap
std::unique_ptr< std::vector< recob::SpacePoint > > SpacePointCollection
std::unique_ptr< std::vector< recob::Slice > > SliceCollection
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
static void BuildClusters(const art::Event &event, const art::EDProducer *const pProducer, 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, recob::Slice > > PFParticleToSliceCollection
std::unique_ptr< std::vector< recob::Vertex > > VertexCollection
static void BuildVertices(const pandora::VertexVector &vertexVector, VertexCollection &outputVertices)
Convert pandora vertices to ART vertices and add them to the output vector.
std::unique_ptr< std::vector< larpandoraobj::PFParticleMetadata > > PFParticleMetadataCollection
static pandora::PfoVector CollectPfos(const pandora::Pandora *const pPrimaryPandora)
Collect the current pfos (including all downstream pfos) from the master pandora instance.
std::unique_ptr< std::vector< recob::PFParticle > > PFParticleCollection
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.
std::unique_ptr< art::Assns< recob::PFParticle, larpandoraobj::PFParticleMetadata > > PFParticleToMetadataCollection
std::unique_ptr< art::Assns< recob::PFParticle, recob::Vertex > > PFParticleToVertexCollection
std::unique_ptr< std::vector< anab::T0 > > T0Collection
std::unique_ptr< art::Assns< recob::PFParticle, recob::Cluster > > PFParticleToClusterCollection
static void BuildSlices(const Settings &settings, const pandora::Pandora *const pPrimaryPandora, const art::Event &event, const art::EDProducer *const pProducer, 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< art::Assns< recob::Slice, recob::Hit > > SliceToHitCollection
static void BuildT0s(const art::Event &event, const art::EDProducer *const pProducer, const std::string &instanceLabel, const pandora::PfoVector &pfoVector, T0Collection &outputT0s, const CaloHitToArtHitMap &pandoraHitToArtHitMap, 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::PFParticle, recob::SpacePoint > > PFParticleToSpacePointCollection
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 BuildSpacePoints(const art::Event &event, const art::EDProducer *const pProducer, 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< art::Assns< recob::Cluster, recob::Hit > > ClusterToHitCollection
std::vector< art::Ptr< recob::Vertex > > VertexVector

The documentation for this class was generated from the following files: