LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::LArPfoHelper Class Reference

LArPfoHelper class. More...

#include "LArPfoHelper.h"

Public Member Functions

template<typename T >
void SlidingFitTrajectoryImpl (const T *const pT, const CartesianVector &vertexPosition, const unsigned int layerWindow, const float layerPitch, LArTrackStateVector &trackStateVector, IntVector *const pIndexVector)
 

Static Public Member Functions

static void GetCoordinateVector (const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::CartesianPointVector &coordinateVector)
 Get a list of coordinates of a particular hit type from an input pfos. More...
 
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. More...
 
static void GetCaloHits (const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
 Get a list of calo hits of a particular hit type from a given pfo. More...
 
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. More...
 
static void GetIsolatedCaloHits (const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
 Get a list of isolated calo hits of a particular hit type from a given pfo. More...
 
static void GetAllCaloHits (const pandora::ParticleFlowObject *pPfo, pandora::CaloHitList &caloHitList)
 Get a list of all calo hits (including isolated) of all types from a given pfo. More...
 
static void GetClusters (const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
 Get a list of clusters of a particular hit type from a list of pfos. More...
 
static void GetClusters (const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
 Get a list of clusters of a particular hit type from a given pfo. More...
 
static unsigned int GetNumberOfTwoDHits (const pandora::ParticleFlowObject *const pPfo)
 Get the number of 2D hits of a PFO. More...
 
static void GetTwoDClusterList (const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
 Get the list of 2D clusters from an input pfo. More...
 
static void GetThreeDClusterList (const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
 Get the list of 3D clusters from an input pfo. More...
 
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 pfos in an input list. More...
 
static void GetAllConnectedPfos (const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &outputPfoList)
 Get a flat list of all pfos, recursively including all daughters and parents associated with an input pfo. More...
 
static void GetAllDownstreamPfos (const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
 Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input list. More...
 
static void GetAllDownstreamPfos (const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &outputPfoList)
 Get a flat list of all pfos, recursively, of all daughters and parents associated with an input pfo. More...
 
static void GetAllDownstreamPfos (const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &outputTrackPfoList, pandora::PfoList &outputLeadingShowerPfoList)
 Get flat lists of all downstream track pfos and also shower-like pfos. This method collects together all track-like particles downstream of the root particle, stopping at a leading shower and then storing that leading shower in a separate list. More...
 
static int GetHierarchyTier (const pandora::ParticleFlowObject *const pPfo)
 Determine the position in the hierarchy for the MCParticle. More...
 
static float GetTwoDLengthSquared (const pandora::ParticleFlowObject *const pPfo)
 Calculate length of Pfo using 2D clusters. More...
 
static float GetThreeDLengthSquared (const pandora::ParticleFlowObject *const pPfo)
 Calculate length of Pfo using 3D clusters. More...
 
static float GetClosestDistance (const pandora::ParticleFlowObject *const pPfo, const pandora::Cluster *const pCluster)
 Get closest distance between Pfo and cluster. More...
 
static float GetThreeDSeparation (const pandora::ParticleFlowObject *const pPfo1, const pandora::ParticleFlowObject *const pPfo2)
 Get distance between two Pfos using 3D clusters. More...
 
static bool IsTwoD (const pandora::ParticleFlowObject *const pPfo)
 Does Pfo contain 2D clusters. More...
 
static bool IsThreeD (const pandora::ParticleFlowObject *const pPfo)
 Does Pfo contain 3D clusters. More...
 
static bool IsTrack (const pandora::ParticleFlowObject *const pPfo)
 Return track flag based on Pfo Particle ID. More...
 
static bool IsShower (const pandora::ParticleFlowObject *const pPfo)
 Return shower flag based on Pfo Particle ID. More...
 
static int GetPrimaryNeutrino (const pandora::ParticleFlowObject *const pPfo)
 Get primary neutrino or antineutrino. More...
 
static bool IsFinalState (const pandora::ParticleFlowObject *const pPfo)
 Whether a pfo is a primary parent particle. More...
 
static bool IsNeutrinoFinalState (const pandora::ParticleFlowObject *const pPfo)
 Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction. More...
 
static bool IsNeutrino (const pandora::ParticleFlowObject *const pPfo)
 Whether a pfo is a neutrino or (antineutrino) More...
 
static bool IsTestBeamFinalState (const pandora::ParticleFlowObject *const pPfo)
 Whether a pfo is a final-state particle from a test beam particle interaction. More...
 
static bool IsTestBeam (const pandora::ParticleFlowObject *const pPfo)
 Whether a pfo is a test beam particle. More...
 
static void GetRecoNeutrinos (const pandora::PfoList *const pPfoList, pandora::PfoList &recoNeutrinos)
 Get neutrino pfos from an input pfo list. More...
 
static const pandora::ParticleFlowObject * GetParentPfo (const pandora::ParticleFlowObject *const pPfo)
 Get the primary parent pfo. More...
 
static const pandora::ParticleFlowObject * GetParentNeutrino (const pandora::ParticleFlowObject *const pPfo)
 Get primary neutrino or antineutrino. More...
 
static const pandora::Vertex * GetVertex (const pandora::ParticleFlowObject *const pPfo)
 Get the pfo vertex. More...
 
static const pandora::Vertex * GetTestBeamInteractionVertex (const pandora::ParticleFlowObject *const pPfo)
 Get the pfo test beam interaction vertex. More...
 
static const pandora::Vertex * GetVertexWithLabel (const pandora::VertexList &vertexList, const pandora::VertexLabel vertexLabel)
 Get the vertex with a specific vertex label in a given vertex list. More...
 
static void GetSlidingFitTrajectory (const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition, const unsigned int layerWindow, const float layerPitch, LArTrackStateVector &trackStateVector, pandora::IntVector *const pIndexVector=nullptr)
 Apply 3D sliding fit to a set of 3D points and return track trajectory. More...
 
static void GetSlidingFitTrajectory (const pandora::ParticleFlowObject *const pPfo, const pandora::Vertex *const pVertex, const unsigned int slidingFitHalfWindow, const float layerPitch, LArTrackStateVector &trackStateVector)
 Apply 3D sliding fit to Pfo and return track trajectory. More...
 
static LArShowerPCA GetPrincipalComponents (const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition)
 Perform PCA analysis on a set of 3D points and return results. More...
 
static LArShowerPCA GetPrincipalComponents (const pandora::ParticleFlowObject *const pPfo, const pandora::Vertex *const pVertex)
 Perform PCA analysis on Pfo and return results. More...
 
static bool SortByHitProjection (const LArTrackTrajectoryPoint &lhs, const LArTrackTrajectoryPoint &rhs)
 Sort pfos by number of constituent hits. More...
 
static bool SortByNHits (const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
 Sort pfos by number of constituent hits. More...
 
static void GetBreadthFirstHierarchyRepresentation (const pandora::ParticleFlowObject *const pPfo, pandora::PfoList &pfoList)
 Retrieve a linearised representation of the PFO hierarchy in breadth first order. This iterates over the PFO hierarchy in a manor that sees primaries at the front of the list, with progressively deeper tiers later in the list. This is useful for some visualisation cases. More...
 

Static Private Member Functions

template<typename T >
static void SlidingFitTrajectoryImpl (const T *const pT, const pandora::CartesianVector &vertexPosition, const unsigned int layerWindow, const float layerPitch, LArTrackStateVector &trackStateVector, pandora::IntVector *const pIndexVector=nullptr)
 Implementation of sliding fit trajectory extraction. More...
 

Detailed Description

LArPfoHelper class.

Definition at line 23 of file LArPfoHelper.h.

Member Function Documentation

void lar_content::LArPfoHelper::GetAllCaloHits ( const pandora::ParticleFlowObject *  pPfo,
pandora::CaloHitList &  caloHitList 
)
static

Get a list of all calo hits (including isolated) of all types from a given pfo.

Parameters
pPfothe input Pfo
caloHitListthe output list of calo hits

Definition at line 76 of file LArPfoHelper.cc.

Referenced by lar_content::LArHierarchyHelper::RecoHierarchy::Node::FillFlat(), lar_content::LArHierarchyHelper::RecoHierarchy::Node::FillHierarchy(), and lar_content::LArHierarchyHelper::RecoHierarchy::FillHierarchy().

77 {
78  LArPfoHelper::GetCaloHits(pPfo, TPC_VIEW_U, caloHitList);
79  LArPfoHelper::GetCaloHits(pPfo, TPC_VIEW_V, caloHitList);
80  LArPfoHelper::GetCaloHits(pPfo, TPC_VIEW_W, caloHitList);
81  LArPfoHelper::GetIsolatedCaloHits(pPfo, TPC_VIEW_U, caloHitList);
82  LArPfoHelper::GetIsolatedCaloHits(pPfo, TPC_VIEW_V, caloHitList);
83  LArPfoHelper::GetIsolatedCaloHits(pPfo, TPC_VIEW_W, caloHitList);
84 }
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 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.
static void lar_content::LArPfoHelper::GetAllConnectedPfos ( const pandora::PfoList &  inputPfoList,
pandora::PfoList &  outputPfoList 
)
static
static void lar_content::LArPfoHelper::GetAllConnectedPfos ( const pandora::ParticleFlowObject *const  pPfo,
pandora::PfoList &  outputPfoList 
)
static

Get a flat list of all pfos, recursively including all daughters and parents associated with an input pfo.

Parameters
pPfothe input Pfo
outputPfoListto receive the output pfo list
static void lar_content::LArPfoHelper::GetAllDownstreamPfos ( const pandora::ParticleFlowObject *const  pPfo,
pandora::PfoList &  outputPfoList 
)
static

Get a flat list of all pfos, recursively, of all daughters and parents associated with an input pfo.

Parameters
pPfothe input Pfo
outputPfoListto receive the output pfo list
void lar_content::LArPfoHelper::GetAllDownstreamPfos ( const pandora::ParticleFlowObject *const  pPfo,
pandora::PfoList &  outputTrackPfoList,
pandora::PfoList &  outputLeadingShowerPfoList 
)
static

Get flat lists of all downstream track pfos and also shower-like pfos. This method collects together all track-like particles downstream of the root particle, stopping at a leading shower and then storing that leading shower in a separate list.

Parameters
pPfothe input pfo
outputTrackPfoListthe output list of descendent track-like particles
outputLeadingShowerParticlesthe output list of leading shower particles

Definition at line 188 of file LArPfoHelper.cc.

References util::abs().

190 {
191  if (LArPfoHelper::IsTrack(pPfo))
192  {
193  outputTrackPfoList.emplace_back(pPfo);
194  for (const ParticleFlowObject *pChild : pPfo->GetDaughterPfoList())
195  {
196  if (std::find(outputTrackPfoList.begin(), outputTrackPfoList.end(), pChild) == outputTrackPfoList.end())
197  {
198  const int pdg{std::abs(pChild->GetParticleId())};
199  if (pdg == E_MINUS)
200  {
201  outputLeadingShowerPfoList.emplace_back(pChild);
202  }
203  else
204  {
205  outputTrackPfoList.emplace_back(pChild);
206  LArPfoHelper::GetAllDownstreamPfos(pChild, outputTrackPfoList, outputLeadingShowerPfoList);
207  }
208  }
209  }
210  }
211  else
212  {
213  outputLeadingShowerPfoList.emplace_back(pPfo);
214  }
215 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static void GetAllDownstreamPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively, of all daughters associated with those pfos in an input lis...
void lar_content::LArPfoHelper::GetBreadthFirstHierarchyRepresentation ( const pandora::ParticleFlowObject *const  pPfo,
pandora::PfoList &  pfoList 
)
static

Retrieve a linearised representation of the PFO hierarchy in breadth first order. This iterates over the PFO hierarchy in a manor that sees primaries at the front of the list, with progressively deeper tiers later in the list. This is useful for some visualisation cases.

Parameters
pPfoa PFO in the hierarchy - can be any PFO
pfoListthe output PFO list

Definition at line 652 of file LArPfoHelper.cc.

Referenced by lar_content::VisualParticleMonitoringAlgorithm::Run().

653 {
654  const ParticleFlowObject *pRoot{pPfo};
655  PfoList parents{pRoot->GetParentPfoList()};
656  while (!parents.empty())
657  {
658  if (parents.size() > 1)
659  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
660  pRoot = parents.front();
661  parents = pRoot->GetParentPfoList();
662  }
663  PfoList queue;
664  pfoList.emplace_back(pRoot);
665  queue.emplace_back(pRoot);
666 
667  while (!queue.empty())
668  {
669  const PfoList &daughters{queue.front()->GetDaughterPfoList()};
670  queue.pop_front();
671  for (const ParticleFlowObject *pDaughter : daughters)
672  {
673  pfoList.emplace_back(pDaughter);
674  queue.emplace_back(pDaughter);
675  }
676  }
677 }
static void lar_content::LArPfoHelper::GetCaloHits ( const pandora::PfoList &  pfoList,
const pandora::HitType &  hitType,
pandora::CaloHitList &  caloHitList 
)
static

Get a list of calo hits of a particular hit type from a list of pfos.

Parameters
pfoListthe input list of Pfos
hitTypethe cluster hit type
caloHitListthe output list of calo hits

Referenced by lar_content::ShowerStartFinderTool::BuildShowerRegion(), lar_pandora::LArPandoraOutput::BuildSlice(), lar_content::ElectronInitialRegionRefinementAlgorithm::BuildViewPathways(), lar_content::ElectronInitialRegionRefinementAlgorithm::BuildViewProtoShowers(), lar_content::ShowerRegionFeatureTool::BuildViewShower(), lar_content::CosmicRayTaggingTool::CheckIfInTime(), lar_content::NeutrinoIdTool< T >::Collect2DHits(), lar_content::BdtBeamParticleIdTool::Collect2DHits(), lar_pandora::LArPandoraOutput::Collect3DHits(), lar_content::LArMCParticleHelper::CollectReconstructableTestBeamHierarchy2DHits(), lar_content::StitchingCosmicRayMergingTool::CreatePfoMatches(), lar_content::ShowerRegionFeatureTool::GetShowerHitVariables(), lar_content::ShowerRegionFeatureTool::GetViewShowerRegionVariables(), lar_content::BdtBeamParticleIdTool::SliceFeatureParameters::Initialize(), lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), lar_content::ElectronInitialRegionRefinementAlgorithm::IsElectron(), lar_content::ElectronInitialRegionRefinementAlgorithm::IsSpineCoincident(), lar_content::CosmicRayTaggingMonitoringTool::PrintPfoTable(), lar_content::ElectronInitialRegionRefinementAlgorithm::RefineShowerVertex(), lar_content::PeakDirectionFinderTool::Run(), lar_content::VisualParticleMonitoringAlgorithm::Run(), lar_content::ElectronInitialRegionRefinementAlgorithm::Run(), lar_content::PfoHierarchyFeatureTool::Run(), lar_content::ThreeDVertexDistanceFeatureTool::Run(), lar_content::ThreeDOpeningAngleFeatureTool::Run(), lar_content::ThreeDPCAFeatureTool::Run(), lar_content::MasterAlgorithm::RunCosmicRayHitRemoval(), lar_content::MasterAlgorithm::RunSlicing(), and lar_content::BeamParticleIdTool::SelectOutputPfos().

static void lar_content::LArPfoHelper::GetCaloHits ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::HitType &  hitType,
pandora::CaloHitList &  caloHitList 
)
static

Get a list of calo hits of a particular hit type from a given pfo.

Parameters
pPfothe input Pfo
hitTypethe cluster hit type
caloHitListthe output list of calo hits
float lar_content::LArPfoHelper::GetClosestDistance ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::Cluster *const  pCluster 
)
static

Get closest distance between Pfo and cluster.

Parameters
pPfothe address of the input Pfo
pClusterthe address of the input cluster

Definition at line 278 of file LArPfoHelper.cc.

279 {
280  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
281 
282  ClusterList clusterList;
283  LArPfoHelper::GetClusters(pPfo, hitType, clusterList);
284 
285  if (clusterList.empty())
286  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
287 
288  float bestDistance(std::numeric_limits<float>::max());
289 
290  for (const Cluster *const pPfoCluster : clusterList)
291  {
292  const float thisDistance(LArClusterHelper::GetClosestDistance(pCluster, pPfoCluster));
293 
294  if (thisDistance < bestDistance)
295  bestDistance = thisDistance;
296  }
297 
298  return bestDistance;
299 }
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
HitType
Definition: HitType.h:12
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static void lar_content::LArPfoHelper::GetClusters ( const pandora::PfoList &  pfoList,
const pandora::HitType &  hitType,
pandora::ClusterList &  clusterList 
)
static

Get a list of clusters of a particular hit type from a list of pfos.

Parameters
pfoListthe input list of Pfos
hitTypethe cluster hit type
clusterListthe output list of clusters

Referenced by lar_content::DeltaRayMatchingContainers::AddClustersToPfoMaps(), lar_content::DeltaRayMatchingAlgorithm::AddToDaughterPfo(), lar_content::CosmicRayVertexBuildingAlgorithm::BuildCosmicRayDaughter(), lar_content::CosmicRayVertexBuildingAlgorithm::BuildCosmicRayParent(), lar_content::NeutrinoDaughterVerticesAlgorithm::BuildDaughterShower(), lar_content::NeutrinoDaughterVerticesAlgorithm::BuildDaughterTrack(), lar_content::CosmicRayVertexBuildingAlgorithm::BuildPointingClusterMap(), lar_content::NeutrinoDaughterVerticesAlgorithm::BuildPointingClusterMap(), lar_content::DeltaRayMergeTool::FindVertices(), lar_content::TwoViewDeltaRayMatchingAlgorithm::FormThirdViewCluster(), lar_content::TwoViewDeltaRayMatchingAlgorithm::GetBestMatchedCluster(), lar_content::OneViewDeltaRayMatchingAlgorithm::GetBestProjectedCluster(), lar_content::CosmicRayVertexBuildingAlgorithm::GetCosmicPfos(), lar_content::NeutrinoDaughterVerticesAlgorithm::GetDaughterPfos(), lar_content::DeltaRayMatchingAlgorithm::GetDistanceSquaredToPfo(), lar_content::DeltaRayGrowingAlgorithm::GetListOfSeedClusters(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetMuonCluster(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetProjectedPositions(), lar_content::ElectronInitialRegionRefinementAlgorithm::GetShowerVertex(), lar_content::DeltaRayParentAlgorithm::GetTwoDSeparation(), lar_content::DeltaRayIdentificationAlgorithm::GetTwoDSeparation(), lar_content::DeltaRayIdentificationAlgorithm::GetTwoDVertices(), lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack(), lar_content::UnambiguousDeltaRayTool::IsConnected(), lar_content::DeltaRayMergeTool::IsConnected(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::ProjectMuonPositions(), lar_content::ConeChargeFeatureTool::Run(), and lar_content::ThreeDChargeFeatureTool::Run().

static void lar_content::LArPfoHelper::GetClusters ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::HitType &  hitType,
pandora::ClusterList &  clusterList 
)
static

Get a list of clusters of a particular hit type from a given pfo.

Parameters
pPfothe input Pfo
hitTypethe cluster hit type
clusterListthe output list of clusters
void lar_content::LArPfoHelper::GetCoordinateVector ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::HitType &  hitType,
pandora::CartesianPointVector &  coordinateVector 
)
static

Get a list of coordinates of a particular hit type from an input pfos.

Parameters
pPfothe address of the input Pfo
hitTypethe cluster hit type
coordinateVectorthe output list of coordinates

Definition at line 27 of file LArPfoHelper.cc.

28 {
29  ClusterList clusterList;
30  LArPfoHelper::GetClusters(pPfo, hitType, clusterList);
31 
32  for (const Cluster *const pCluster : clusterList)
33  LArClusterHelper::GetCoordinateVector(pCluster, coordinateVector);
34 }
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
static void GetCoordinateVector(const pandora::Cluster *const pCluster, pandora::CartesianPointVector &coordinateVector)
Get vector of hit coordinates from an input cluster.
int lar_content::LArPfoHelper::GetHierarchyTier ( const pandora::ParticleFlowObject *const  pPfo)
static

Determine the position in the hierarchy for the MCParticle.

Parameters
pPfothe input Pfo
Returns
integer

Definition at line 219 of file LArPfoHelper.cc.

Referenced by lar_content::LArHierarchyHelper::RecoHierarchy::Node::FillHierarchy().

220 {
221  const ParticleFlowObject *pParentPfo = pPfo;
222  int tier(0);
223 
224  while (pParentPfo->GetParentPfoList().empty() == false)
225  {
226  if (1 != pParentPfo->GetParentPfoList().size())
227  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
228 
229  pParentPfo = *(pParentPfo->GetParentPfoList().begin());
230  ++tier;
231  }
232 
233  return tier;
234 }
static void lar_content::LArPfoHelper::GetIsolatedCaloHits ( const pandora::PfoList &  pfoList,
const pandora::HitType &  hitType,
pandora::CaloHitList &  caloHitList 
)
static

Get a list of isolated calo hits of a particular hit type from a list of pfos.

Parameters
pfoListthe input list of Pfos
hitTypethe cluster hit type
caloHitListthe output list of calo hits

Referenced by lar_pandora::LArPandoraOutput::BuildSlice(), lar_content::LArMCParticleHelper::CollectReconstructableTestBeamHierarchy2DHits(), lar_content::VisualParticleMonitoringAlgorithm::Run(), and lar_content::MasterAlgorithm::RunCosmicRayHitRemoval().

static void lar_content::LArPfoHelper::GetIsolatedCaloHits ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::HitType &  hitType,
pandora::CaloHitList &  caloHitList 
)
static

Get a list of isolated calo hits of a particular hit type from a given pfo.

Parameters
pPfothe input Pfo
hitTypethe cluster hit type
caloHitListthe output list of isolated calo hits
unsigned int lar_content::LArPfoHelper::GetNumberOfTwoDHits ( const pandora::ParticleFlowObject *const  pPfo)
static

Get the number of 2D hits of a PFO.

Parameters
pPfothe pfo to check
Returns
int of number of 2D hits

Definition at line 109 of file LArPfoHelper.cc.

110 {
111  unsigned int totalHits(0);
112 
113  ClusterList clusterList;
114  LArPfoHelper::GetTwoDClusterList(pPfo, clusterList);
115  for (const Cluster *const pCluster : clusterList)
116  totalHits += pCluster->GetNCaloHits();
117 
118  return totalHits;
119 }
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
const ParticleFlowObject * lar_content::LArPfoHelper::GetParentNeutrino ( const pandora::ParticleFlowObject *const  pPfo)
static

Get primary neutrino or antineutrino.

Parameters
pPfothe address of the Pfo
Returns
address of primary neutrino pfo

Definition at line 459 of file LArPfoHelper.cc.

Referenced by lar_content::NeutrinoEventValidationAlgorithm::ProcessOutput().

460 {
461  const ParticleFlowObject *const pParentPfo = LArPfoHelper::GetParentPfo(pPfo);
462 
463  if (!LArPfoHelper::IsNeutrino(pParentPfo))
464  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
465 
466  return pParentPfo;
467 }
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
const ParticleFlowObject * lar_content::LArPfoHelper::GetParentPfo ( const pandora::ParticleFlowObject *const  pPfo)
static

Get the primary parent pfo.

Parameters
pPfothe address of the Pfo
Returns
address of the primary parent pfo

Definition at line 445 of file LArPfoHelper.cc.

Referenced by lar_pandora::LArPandoraOutput::BuildSlices(), lar_pandora::LArPandoraOutput::BuildT0(), lar_pandora::LArPandoraOutput::GetSliceIndex(), lar_pandora::LArPandoraOutput::IsClearCosmic(), lar_pandora::LArPandoraOutput::IsFromSlice(), and lar_content::MuonLeadingEventValidationAlgorithm::ProcessOutput().

446 {
447  const ParticleFlowObject *pParentPfo = pPfo;
448 
449  while (pParentPfo->GetParentPfoList().empty() == false)
450  {
451  pParentPfo = *(pParentPfo->GetParentPfoList().begin());
452  }
453 
454  return pParentPfo;
455 }
int lar_content::LArPfoHelper::GetPrimaryNeutrino ( const pandora::ParticleFlowObject *const  pPfo)
static

Get primary neutrino or antineutrino.

Parameters
pPfothe address of the Pfo
Returns
pdg code of neutrino (or zero, otherwise)

Definition at line 364 of file LArPfoHelper.cc.

365 {
366  try
367  {
368  const ParticleFlowObject *const pParentPfo = LArPfoHelper::GetParentNeutrino(pPfo);
369  return pParentPfo->GetParticleId();
370  }
371  catch (const StatusCodeException &)
372  {
373  return 0;
374  }
375 }
static const pandora::ParticleFlowObject * GetParentNeutrino(const pandora::ParticleFlowObject *const pPfo)
Get primary neutrino or antineutrino.
static LArShowerPCA lar_content::LArPfoHelper::GetPrincipalComponents ( const pandora::CartesianPointVector &  pointVector,
const pandora::CartesianVector &  vertexPosition 
)
static

Perform PCA analysis on a set of 3D points and return results.

Parameters
pointVectorthe input list of 3D positions
vertexPositionthe input vertex position

Referenced by lar_content::PcaShowerParticleBuildingAlgorithm::CreatePfo(), and lar_pandora::LArPandoraShowerCreation::produce().

static LArShowerPCA lar_content::LArPfoHelper::GetPrincipalComponents ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::Vertex *const  pVertex 
)
static

Perform PCA analysis on Pfo and return results.

Parameters
pPfothe address of the input Pfo
pVertexthe address of the input vertex
void lar_content::LArPfoHelper::GetRecoNeutrinos ( const pandora::PfoList *const  pPfoList,
pandora::PfoList &  recoNeutrinos 
)
static

Get neutrino pfos from an input pfo list.

Parameters
pPfoListthe input pfo list
recoNeutrinosto receive the list of neutrino pfos

Definition at line 431 of file LArPfoHelper.cc.

Referenced by lar_content::CheatingNeutrinoDaughterVerticesAlgorithm::Run().

432 {
433  if (!pPfoList)
434  return;
435 
436  for (const ParticleFlowObject *const pPfo : *pPfoList)
437  {
438  if (LArPfoHelper::IsNeutrino(pPfo))
439  recoNeutrinos.push_back(pPfo);
440  }
441 }
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
static void lar_content::LArPfoHelper::GetSlidingFitTrajectory ( const pandora::CartesianPointVector &  pointVector,
const pandora::CartesianVector &  vertexPosition,
const unsigned int  layerWindow,
const float  layerPitch,
LArTrackStateVector trackStateVector,
pandora::IntVector *const  pIndexVector = nullptr 
)
static

Apply 3D sliding fit to a set of 3D points and return track trajectory.

Parameters
pointVectorthe input list of 3D positions
vertexPositionthe input vertex position
slidingFitHalfWindowsize of half window for sliding linear fit
layerPitchsize of pitch for sliding linear fit
trackStateVectorthe output track trajectory
pIndexVectorlookup vector of spacepoint indices to store trajectory point sorting

Referenced by ShowerRecoTools::ShowerPandoraSlidingFitTrackFinder::CalculateElement(), lar_content::TrackParticleBuildingAlgorithm::CreatePfo(), and lar_pandora::LArPandoraTrackCreation::produce().

static void lar_content::LArPfoHelper::GetSlidingFitTrajectory ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::Vertex *const  pVertex,
const unsigned int  slidingFitHalfWindow,
const float  layerPitch,
LArTrackStateVector trackStateVector 
)
static

Apply 3D sliding fit to Pfo and return track trajectory.

Parameters
pPfothe address of the input Pfo
pVertexthe address of the input vertex
slidingFitHalfWindowsize of half window for sliding linear fit
layerPitchsize of pitch for sliding linear fit
trackStateVectorthe output track trajectory
const Vertex * lar_content::LArPfoHelper::GetTestBeamInteractionVertex ( const pandora::ParticleFlowObject *const  pPfo)
static

Get the pfo test beam interaction vertex.

Parameters
pPfothe address of the Pfo
Returns
address of pfo vertex

Definition at line 499 of file LArPfoHelper.cc.

Referenced by lar_pandora::LArPandoraOutput::ProduceArtOutput().

500 {
501  if (pPfo->GetVertexList().empty() || !pPfo->GetParentPfoList().empty() || !LArPfoHelper::IsTestBeam(pPfo))
502  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
503 
504  const Vertex *pInteractionVertex(LArPfoHelper::GetVertexWithLabel(pPfo->GetVertexList(), VERTEX_INTERACTION));
505 
506  if (VERTEX_3D != pInteractionVertex->GetVertexType())
507  throw StatusCodeException(STATUS_CODE_FAILURE);
508 
509  return pInteractionVertex;
510 }
static const pandora::Vertex * GetVertexWithLabel(const pandora::VertexList &vertexList, const pandora::VertexLabel vertexLabel)
Get the vertex with a specific vertex label in a given vertex list.
static bool IsTestBeam(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a test beam particle.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
void lar_content::LArPfoHelper::GetThreeDClusterList ( const pandora::ParticleFlowObject *const  pPfo,
pandora::ClusterList &  clusterList 
)
static

Get the list of 3D clusters from an input pfo.

Parameters
pPfothe input Pfo
clusterListthe output list of clusters

Definition at line 136 of file LArPfoHelper.cc.

Referenced by lar_content::ThreeDHitCreationAlgorithm::AddThreeDHitsToPfo(), lar_content::NeutrinoHierarchyAlgorithm::AdjustVertexAndPfoInfo(), lar_content::StitchingCosmicRayMergingTool::BuildPointingClusterMaps(), lar_content::CosmicRayTaggingTool::CRCandidate::CRCandidate(), lar_content::NeutrinoIdTool< T >::SliceFeatures::GetSpacePoints(), lar_content::EventSlicingTool::GetThreeDClusters(), lar_content::SlidingConeClusterMopUpAlgorithm::GetThreeDClusters(), lar_content::SlidingConePfoMopUpAlgorithm::GetThreeDClusters(), lar_content::CosmicRayTaggingTool::GetValid3DCluster(), lar_content::NeutrinoHierarchyAlgorithm::PfoInfo::PfoInfo(), and lar_content::MasterAlgorithm::Reset().

137 {
138  for (const Cluster *const pCluster : pPfo->GetClusterList())
139  {
140  if (TPC_3D != LArClusterHelper::GetClusterHitType(pCluster))
141  continue;
142 
143  clusterList.push_back(pCluster);
144  }
145 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
float lar_content::LArPfoHelper::GetThreeDLengthSquared ( const pandora::ParticleFlowObject *const  pPfo)
static

Calculate length of Pfo using 3D clusters.

Parameters
pPfothe input Pfo
Returns
length variable

Definition at line 258 of file LArPfoHelper.cc.

References f.

Referenced by lar_content::ThreeDLinearFitFeatureTool::Run(), and lar_content::ConeChargeFeatureTool::Run().

259 {
260  if (!LArPfoHelper::IsThreeD(pPfo))
261  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
262 
263  float lengthSquared(0.f);
264 
265  for (const Cluster *const pCluster : pPfo->GetClusterList())
266  {
267  if (TPC_3D != LArClusterHelper::GetClusterHitType(pCluster))
268  continue;
269 
270  lengthSquared += LArClusterHelper::GetLengthSquared(pCluster);
271  }
272 
273  return lengthSquared;
274 }
static bool IsThreeD(const pandora::ParticleFlowObject *const pPfo)
Does Pfo contain 3D clusters.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
TFile f
Definition: plotHisto.C:6
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
float lar_content::LArPfoHelper::GetThreeDSeparation ( const pandora::ParticleFlowObject *const  pPfo1,
const pandora::ParticleFlowObject *const  pPfo2 
)
static

Get distance between two Pfos using 3D clusters.

Parameters
pPfothe address of the first Pfo
pPfothe address of the second Pfo

Definition at line 303 of file LArPfoHelper.cc.

304 {
305  ClusterList clusterList1, clusterList2;
306 
307  LArPfoHelper::GetClusters(pPfo1, TPC_3D, clusterList1);
308  LArPfoHelper::GetClusters(pPfo2, TPC_3D, clusterList2);
309 
310  if (clusterList1.empty() || clusterList2.empty())
311  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
312 
313  return LArClusterHelper::GetClosestDistance(clusterList1, clusterList2);
314 }
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
void lar_content::LArPfoHelper::GetTwoDClusterList ( const pandora::ParticleFlowObject *const  pPfo,
pandora::ClusterList &  clusterList 
)
static

Get the list of 2D clusters from an input pfo.

Parameters
pPfothe input Pfo
clusterListthe output list of clusters

Definition at line 123 of file LArPfoHelper.cc.

Referenced by lar_content::DeltaRayParentAlgorithm::AssignToParentPfo(), lar_pandora::LArPandoraOutput::CollectClusters(), lar_content::EventSlicingTool::CopyPfoHitsToSlices(), lar_content::LArMCParticleHelper::GetMainMCParticle(), lar_content::PfoCharacterisationBaseAlgorithm::IsClearTrack3x2D(), lar_content::LArParticleIdPlugins::LArMuonId::IsMatch(), lar_content::MasterAlgorithm::Reset(), lar_content::PfoCharacterisationBaseAlgorithm::Run(), lar_content::ThreeDLinearFitFeatureTool::Run(), and lar_content::ThreeDHitCreationAlgorithm::SeparateTwoDHits().

124 {
125  for (const Cluster *const pCluster : pPfo->GetClusterList())
126  {
127  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
128  continue;
129 
130  clusterList.push_back(pCluster);
131  }
132 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
float lar_content::LArPfoHelper::GetTwoDLengthSquared ( const pandora::ParticleFlowObject *const  pPfo)
static

Calculate length of Pfo using 2D clusters.

Parameters
pPfothe input Pfo
Returns
length variable

Definition at line 238 of file LArPfoHelper.cc.

References f.

Referenced by lar_content::DeltaRayMatchingAlgorithm::GetLengthFromCache(), lar_content::DeltaRayParentAlgorithm::InitialisePfoLengthMap(), lar_content::DeltaRayIdentificationAlgorithm::IsAssociated(), and lar_content::DeltaRayParentAlgorithm::UpdatePfoLengthMap().

239 {
240  if (!LArPfoHelper::IsTwoD(pPfo))
241  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
242 
243  float lengthSquared(0.f);
244 
245  for (const Cluster *const pCluster : pPfo->GetClusterList())
246  {
247  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
248  continue;
249 
250  lengthSquared += LArClusterHelper::GetLengthSquared(pCluster);
251  }
252 
253  return lengthSquared;
254 }
static bool IsTwoD(const pandora::ParticleFlowObject *const pPfo)
Does Pfo contain 2D clusters.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
TFile f
Definition: plotHisto.C:6
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
const Vertex * lar_content::LArPfoHelper::GetVertex ( const pandora::ParticleFlowObject *const  pPfo)
static

Get the pfo vertex.

Parameters
pPfothe address of the Pfo
Returns
address of pfo vertex

Definition at line 471 of file LArPfoHelper.cc.

Referenced by lar_content::NeutrinoHierarchyAlgorithm::AdjustVertexAndPfoInfo(), lar_content::VertexMonitoringAlgorithm::AssessVertices(), lar_content::CosmicRayTaggingTool::CheckIfInTime(), lar_content::TrackParticleBuildingAlgorithm::CreatePfo(), lar_content::PcaShowerParticleBuildingAlgorithm::CreatePfo(), lar_content::NeutrinoEventValidationAlgorithm::ProcessOutput(), lar_pandora::LArPandoraOutput::ProduceArtOutput(), lar_content::HierarchyValidationAlgorithm::Run(), lar_content::NeutrinoHierarchyAlgorithm::Run(), lar_content::ThreeDVertexDistanceFeatureTool::Run(), and lar_content::NeutrinoIdTool< T >::SliceFeatures::SliceFeatures().

472 {
473  if (pPfo->GetVertexList().empty())
474  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
475 
476  const Vertex *pVertex(nullptr);
477 
478  // ATTN : Test beam parent pfos contain an interaction and start vertex
479  if (LArPfoHelper::IsTestBeam(pPfo) && pPfo->GetParentPfoList().empty())
480  {
481  pVertex = LArPfoHelper::GetVertexWithLabel(pPfo->GetVertexList(), VERTEX_START);
482  }
483  else
484  {
485  if (pPfo->GetVertexList().size() != 1)
486  throw StatusCodeException(STATUS_CODE_FAILURE);
487 
488  pVertex = *(pPfo->GetVertexList().begin());
489  }
490 
491  if (VERTEX_3D != pVertex->GetVertexType())
492  throw StatusCodeException(STATUS_CODE_FAILURE);
493 
494  return pVertex;
495 }
static const pandora::Vertex * GetVertexWithLabel(const pandora::VertexList &vertexList, const pandora::VertexLabel vertexLabel)
Get the vertex with a specific vertex label in a given vertex list.
static bool IsTestBeam(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a test beam particle.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
const Vertex * lar_content::LArPfoHelper::GetVertexWithLabel ( const pandora::VertexList &  vertexList,
const pandora::VertexLabel  vertexLabel 
)
static

Get the vertex with a specific vertex label in a given vertex list.

Parameters
vertexListvertex list
vertexLabeltarget vertex label type
Returns
address of the desired vertex

Definition at line 514 of file LArPfoHelper.cc.

References f.

515 {
516  const Vertex *pTargetVertex(nullptr);
517 
518  for (const Vertex *pCandidateVertex : vertexList)
519  {
520  if (pCandidateVertex->GetVertexLabel() == vertexLabel)
521  {
522  if (!pTargetVertex)
523  {
524  pTargetVertex = pCandidateVertex;
525  }
526  else
527  {
528  throw StatusCodeException(STATUS_CODE_FAILURE);
529  }
530  }
531  }
532 
533  if (!pTargetVertex)
534  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
535 
536  return pTargetVertex;
537 }
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
bool lar_content::LArPfoHelper::IsFinalState ( const pandora::ParticleFlowObject *const  pPfo)
static

Whether a pfo is a primary parent particle.

Parameters
pPfothe address of the Pfo
Returns
boolean

Definition at line 379 of file LArPfoHelper.cc.

Referenced by lar_content::CosmicRayVertexBuildingAlgorithm::BuildCosmicRayParticles(), lar_content::TrackParticleBuildingAlgorithm::CreatePfo(), lar_content::PcaShowerParticleBuildingAlgorithm::CreatePfo(), lar_content::NeutrinoEventValidationAlgorithm::FillValidationInfo(), lar_content::CosmicRayVertexBuildingAlgorithm::GetCosmicPfos(), lar_content::CosmicRayTaggingTool::GetCRCandidates(), lar_content::PfoValidationAlgorithm::Run(), and lar_content::StitchingCosmicRayMergingTool::SelectPrimaryPfos().

380 {
381  if (pPfo->GetParentPfoList().empty() && !LArPfoHelper::IsNeutrino(pPfo))
382  return true;
383 
385  return true;
386 
387  return false;
388 }
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
static bool IsNeutrinoFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction.
bool lar_content::LArPfoHelper::IsNeutrino ( const pandora::ParticleFlowObject *const  pPfo)
static

Whether a pfo is a neutrino or (antineutrino)

Parameters
pPfothe address of the Pfo
Returns
boolean

Definition at line 399 of file LArPfoHelper.cc.

References util::abs().

Referenced by lar_content::VertexMonitoringAlgorithm::AssessVertices(), lar_content::NeutrinoDaughterVerticesAlgorithm::BuildDaughterShower(), lar_content::NeutrinoDaughterVerticesAlgorithm::BuildDaughterTrack(), lar_content::TrackParticleBuildingAlgorithm::CreatePfo(), lar_content::PcaShowerParticleBuildingAlgorithm::CreatePfo(), lar_content::NeutrinoDaughterVerticesAlgorithm::GetDaughterPfos(), lar_content::NeutrinoHierarchyAlgorithm::GetNeutrinoPfo(), lar_content::LArHierarchyHelper::GetRecoPrimaries(), and lar_content::NeutrinoPropertiesAlgorithm::Run().

400 {
401  const int absoluteParticleId(std::abs(pPfo->GetParticleId()));
402 
403  if ((NU_E == absoluteParticleId) || (NU_MU == absoluteParticleId) || (NU_TAU == absoluteParticleId))
404  return true;
405 
406  return false;
407 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
bool lar_content::LArPfoHelper::IsNeutrinoFinalState ( const pandora::ParticleFlowObject *const  pPfo)
static

Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction.

Parameters
pPfothe address of the Pfo
Returns
boolean

Definition at line 392 of file LArPfoHelper.cc.

Referenced by lar_content::TrackParticleBuildingAlgorithm::CreatePfo(), lar_content::PcaShowerParticleBuildingAlgorithm::CreatePfo(), and lar_content::NeutrinoEventValidationAlgorithm::ProcessOutput().

393 {
394  return ((pPfo->GetParentPfoList().size() == 1) && (LArPfoHelper::IsNeutrino(*(pPfo->GetParentPfoList().begin()))));
395 }
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
bool lar_content::LArPfoHelper::IsShower ( const pandora::ParticleFlowObject *const  pPfo)
static

Return shower flag based on Pfo Particle ID.

Parameters
pPfothe address of the Pfo

Definition at line 354 of file LArPfoHelper.cc.

References util::abs().

Referenced by lar_content::PcaShowerParticleBuildingAlgorithm::CreatePfo(), lar_content::SlidingConePfoMopUpAlgorithm::GetClusterMergeMap(), lar_content::SlidingConeClusterMopUpAlgorithm::GetThreeDClusters(), lar_content::ShowerHitsBaseTool::Run(), and lar_content::ThreeDHitCreationAlgorithm::Run().

355 {
356  const int pdg(pPfo->GetParticleId());
357 
358  // electron, photon
359  return ((E_MINUS == std::abs(pdg)) || (PHOTON == std::abs(pdg)));
360 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
bool lar_content::LArPfoHelper::IsTestBeam ( const pandora::ParticleFlowObject *const  pPfo)
static

Whether a pfo is a test beam particle.

Parameters
pPfothe address of the Pfo
Returns
boolean

Definition at line 418 of file LArPfoHelper.cc.

Referenced by lar_content::LArMCParticleHelper::CollectReconstructableTestBeamHierarchy2DHits(), and lar_content::CheatingBeamParticleIdTool::SelectOutputPfos().

419 {
420  const PropertiesMap &properties(pPfo->GetPropertiesMap());
421  const PropertiesMap::const_iterator iter(properties.find("IsTestBeam"));
422 
423  if (iter != properties.end())
424  return ((iter->second > 0.f) ? true : false);
425 
426  return false;
427 }
intermediate_table::const_iterator const_iterator
bool lar_content::LArPfoHelper::IsTestBeamFinalState ( const pandora::ParticleFlowObject *const  pPfo)
static

Whether a pfo is a final-state particle from a test beam particle interaction.

Parameters
pPfothe address of the Pfo
Returns
boolean

Definition at line 411 of file LArPfoHelper.cc.

412 {
414 }
static bool IsTestBeam(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a test beam particle.
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
bool lar_content::LArPfoHelper::IsThreeD ( const pandora::ParticleFlowObject *const  pPfo)
static

Does Pfo contain 3D clusters.

Parameters
pPfothe address of the Pfo

Definition at line 331 of file LArPfoHelper.cc.

Referenced by lar_content::MvaPfoCharacterisationAlgorithm< T >::IsClearTrack().

332 {
333  for (const Cluster *const pCluster : pPfo->GetClusterList())
334  {
335  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
336  return true;
337  }
338 
339  return false;
340 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
bool lar_content::LArPfoHelper::IsTwoD ( const pandora::ParticleFlowObject *const  pPfo)
static

Does Pfo contain 2D clusters.

Parameters
pPfothe address of the Pfo

Definition at line 318 of file LArPfoHelper.cc.

319 {
320  for (const Cluster *const pCluster : pPfo->GetClusterList())
321  {
322  if (TPC_3D != LArClusterHelper::GetClusterHitType(pCluster))
323  return true;
324  }
325 
326  return false;
327 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
template<typename T >
static void lar_content::LArPfoHelper::SlidingFitTrajectoryImpl ( const T *const  pT,
const pandora::CartesianVector &  vertexPosition,
const unsigned int  layerWindow,
const float  layerPitch,
LArTrackStateVector trackStateVector,
pandora::IntVector *const  pIndexVector = nullptr 
)
staticprivate

Implementation of sliding fit trajectory extraction.

Parameters
tthe input information
pVertexthe address of the input vertex
slidingFitHalfWindowsize of half window for sliding linear fit
layerPitchsize of pitch for sliding linear fit
trackStateVectorthe output track trajectory
pIndexVectorlookup vector of spacepoint indices to store trajectory point sorting
template<typename T >
void lar_content::LArPfoHelper::SlidingFitTrajectoryImpl ( const T *const  pT,
const CartesianVector &  vertexPosition,
const unsigned int  layerWindow,
const float  layerPitch,
LArTrackStateVector trackStateVector,
IntVector *const  pIndexVector 
)

Definition at line 682 of file LArPfoHelper.cc.

References f, lar_content::ThreeDSlidingFitResult::GetGlobalFitDirection(), lar_content::ThreeDSlidingFitResult::GetGlobalFitPosition(), lar_content::ThreeDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::ThreeDSlidingFitResult::GetGlobalMinLayerPosition(), and lar_content::ThreeDSlidingFitResult::GetLongitudinalDisplacement().

684 {
685  CartesianPointVector pointVector;
686 
687  for (const auto &nextPoint : *pT)
688  pointVector.push_back(LArObjectHelper::TypeAdaptor::GetPosition(nextPoint));
689 
690  if (pointVector.empty())
691  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
692 
693  std::sort(pointVector.begin(), pointVector.end(), LArClusterHelper::SortCoordinatesByPosition);
694 
695  LArTrackTrajectory trackTrajectory;
696  IntVector indicesWithoutSpacePoints;
697  if (pIndexVector)
698  pIndexVector->clear();
699 
700  try
701  {
702  const ThreeDSlidingFitResult slidingFitResult(&pointVector, layerWindow, layerPitch);
703  const CartesianVector minPosition(slidingFitResult.GetGlobalMinLayerPosition());
704  const CartesianVector maxPosition(slidingFitResult.GetGlobalMaxLayerPosition());
705 
706  if ((maxPosition - minPosition).GetMagnitudeSquared() < std::numeric_limits<float>::epsilon())
707  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
708 
709  const CartesianVector seedPosition((maxPosition + minPosition) * 0.5f);
710  const CartesianVector seedDirection((maxPosition - minPosition).GetUnitVector());
711 
712  const float scaleFactor((seedDirection.GetDotProduct(seedPosition - vertexPosition) > 0.f) ? +1.f : -1.f);
713 
714  int index(-1);
715  for (const auto &nextPoint : *pT)
716  {
717  ++index;
718 
719  try
720  {
721  const float rL(slidingFitResult.GetLongitudinalDisplacement(LArObjectHelper::TypeAdaptor::GetPosition(nextPoint)));
722 
723  CartesianVector position(0.f, 0.f, 0.f);
724  const StatusCode positionStatusCode(slidingFitResult.GetGlobalFitPosition(rL, position));
725 
726  if (positionStatusCode != STATUS_CODE_SUCCESS)
727  throw StatusCodeException(positionStatusCode);
728 
729  CartesianVector direction(0.f, 0.f, 0.f);
730  const StatusCode directionStatusCode(slidingFitResult.GetGlobalFitDirection(rL, direction));
731 
732  if (directionStatusCode != STATUS_CODE_SUCCESS)
733  throw StatusCodeException(directionStatusCode);
734 
735  const float projection(seedDirection.GetDotProduct(position - seedPosition));
736 
737  trackTrajectory.push_back(LArTrackTrajectoryPoint(projection * scaleFactor,
738  LArTrackState(position, direction * scaleFactor, LArObjectHelper::TypeAdaptor::GetCaloHit(nextPoint)), index));
739  }
740  catch (const StatusCodeException &statusCodeException1)
741  {
742  indicesWithoutSpacePoints.push_back(index);
743 
744  if (STATUS_CODE_FAILURE == statusCodeException1.GetStatusCode())
745  throw statusCodeException1;
746  }
747  }
748  }
749  catch (const StatusCodeException &statusCodeException2)
750  {
751  if (STATUS_CODE_FAILURE == statusCodeException2.GetStatusCode())
752  throw statusCodeException2;
753  }
754 
755  // Sort trajectory points by distance along track
756  std::sort(trackTrajectory.begin(), trackTrajectory.end(), LArPfoHelper::SortByHitProjection);
757 
758  for (const LArTrackTrajectoryPoint &larTrackTrajectoryPoint : trackTrajectory)
759  {
760  trackStateVector.push_back(larTrackTrajectoryPoint.second);
761  if (pIndexVector)
762  pIndexVector->push_back(larTrackTrajectoryPoint.GetIndex());
763  }
764 
765  // Store indices of spacepoints with no associated trajectory point at the end of pIndexVector
766  if (pIndexVector)
767  {
768  for (const int index : indicesWithoutSpacePoints)
769  pIndexVector->push_back(index);
770  }
771 }
static const pandora::CaloHit * GetCaloHit(const T &t)
Get the associated calo hit, or nullptr if none.
std::vector< int > IntVector
static pandora::CartesianVector GetPosition(const T &t)
Get the associated position.
std::vector< LArTrackTrajectoryPoint > LArTrackTrajectory
TFile f
Definition: plotHisto.C:6
static bool SortCoordinatesByPosition(const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs)
Sort cartesian vectors by their position (use Z, followed by X, followed by Y)
static bool SortByHitProjection(const LArTrackTrajectoryPoint &lhs, const LArTrackTrajectoryPoint &rhs)
Sort pfos by number of constituent hits.
bool lar_content::LArPfoHelper::SortByHitProjection ( const LArTrackTrajectoryPoint lhs,
const LArTrackTrajectoryPoint rhs 
)
static

Sort pfos by number of constituent hits.

Parameters
pLhsaddress of first pfo
pRhsaddress of second pfo

Definition at line 593 of file LArPfoHelper.cc.

References f.

594 {
595  if (lhs.first != rhs.first)
596  return (lhs.first < rhs.first);
597 
598  // ATTN Removed to support use with CartesianVector only (no CaloHit) input
599  // if (lhs.second.GetCaloHit() && rhs.second.GetCaloHit())
600  // return (lhs.second.GetCaloHit()->GetInputEnergy() > rhs.second.GetCaloHit()->GetInputEnergy());
601 
602  const float dx(lhs.second.GetPosition().GetX() - rhs.second.GetPosition().GetX());
603  const float dy(lhs.second.GetPosition().GetY() - rhs.second.GetPosition().GetY());
604  const float dz(lhs.second.GetPosition().GetZ() - rhs.second.GetPosition().GetZ());
605  return (dx + dy + dz > 0.f);
606 }
TFile f
Definition: plotHisto.C:6
bool lar_content::LArPfoHelper::SortByNHits ( const pandora::ParticleFlowObject *const  pLhs,
const pandora::ParticleFlowObject *const  pRhs 
)
static

Sort pfos by number of constituent hits.

Parameters
pLhsaddress of first pfo
pRhsaddress of second pfo

Definition at line 610 of file LArPfoHelper.cc.

References f.

Referenced by lar_content::NeutrinoHierarchyAlgorithm::AdjustVertexAndPfoInfo(), lar_content::DeltaRayIdentificationAlgorithm::BuildParentDaughterLinks(), lar_pandora::LArPandoraOutput::BuildSlice(), lar_content::CosmicRayTaggingMonitoringTool::CalculatePfoMetrics(), lar_pandora::LArPandoraOutput::CollectPfos(), lar_content::NeutrinoHierarchyAlgorithm::DisplayPfoInfoMap(), lar_content::LArHierarchyHelper::RecoHierarchy::FillHierarchy(), lar_content::ElectronInitialRegionRefinementAlgorithm::FillShowerPfoVector(), lar_content::DeltaRayMatchingAlgorithm::GetAllPfos(), lar_content::LArMCParticleHelper::GetPfoMCParticleHitSharingMaps(), lar_content::DeltaRayGrowingAlgorithm::GetPfos(), lar_content::DeltaRayIdentificationAlgorithm::GetPfos(), lar_content::EventValidationBaseAlgorithm::InterpretMatching(), lar_content::LArHierarchyHelper::RecoHierarchy::Node::Node(), lar_content::VertexBasedPfoMopUpAlgorithm::PfoAssociation::operator<(), lar_content::StitchingCosmicRayMergingTool::OrderPfoMerges(), lar_content::NeutrinoHierarchyAlgorithm::ProcessPfoInfoMap(), lar_content::VertexAssociatedPfosTool::Run(), lar_content::DeltaRayParentAlgorithm::Run(), lar_content::ThreeDHitCreationAlgorithm::Run(), lar_content::StitchingCosmicRayMergingTool::SelectPfoMatches(), lar_content::StitchingCosmicRayMergingTool::SelectPfoMerges(), lar_content::StitchingCosmicRayMergingTool::SelectPrimaryPfos(), lar_content::NeutrinoHierarchyAlgorithm::SeparatePfos(), lar_content::NeutrinoPropertiesAlgorithm::SetNeutrinoId(), and lar_content::StitchingCosmicRayMergingTool::StitchPfos().

611 {
612  unsigned int nTwoDHitsLhs(0), nThreeDHitsLhs(0);
613  float energyLhs(0.f);
614  for (ClusterList::const_iterator iter = pLhs->GetClusterList().begin(), iterEnd = pLhs->GetClusterList().end(); iter != iterEnd; ++iter)
615  {
616  const Cluster *const pClusterLhs = *iter;
617 
618  if (TPC_3D != LArClusterHelper::GetClusterHitType(pClusterLhs))
619  nTwoDHitsLhs += pClusterLhs->GetNCaloHits();
620  else
621  nThreeDHitsLhs += pClusterLhs->GetNCaloHits();
622 
623  energyLhs += pClusterLhs->GetHadronicEnergy();
624  }
625 
626  unsigned int nTwoDHitsRhs(0), nThreeDHitsRhs(0);
627  float energyRhs(0.f);
628  for (ClusterList::const_iterator iter = pRhs->GetClusterList().begin(), iterEnd = pRhs->GetClusterList().end(); iter != iterEnd; ++iter)
629  {
630  const Cluster *const pClusterRhs = *iter;
631 
632  if (TPC_3D != LArClusterHelper::GetClusterHitType(pClusterRhs))
633  nTwoDHitsRhs += pClusterRhs->GetNCaloHits();
634  else
635  nThreeDHitsRhs += pClusterRhs->GetNCaloHits();
636 
637  energyRhs += pClusterRhs->GetHadronicEnergy();
638  }
639 
640  if (nTwoDHitsLhs != nTwoDHitsRhs)
641  return (nTwoDHitsLhs > nTwoDHitsRhs);
642 
643  if (nThreeDHitsLhs != nThreeDHitsRhs)
644  return (nThreeDHitsLhs > nThreeDHitsRhs);
645 
646  // ATTN Need an efficient (balance with well-motivated) tie-breaker here. Pfo length, for instance, is extremely slow.
647  return (energyLhs > energyRhs);
648 }
intermediate_table::const_iterator const_iterator
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
TFile f
Definition: plotHisto.C:6

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