LArSoft  v10_06_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 unsigned int GetNumberOfThreeDHits (const pandora::ParticleFlowObject *const pPfo)
 Get the number of 3D hits owned by 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 float GetTrackScore (const pandora::ParticleFlowObject *const pPfo)
 Get the track/shower score of the pfo. 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 203 of file LArPfoHelper.cc.

References util::abs().

205 {
206  if (LArPfoHelper::IsTrack(pPfo))
207  {
208  outputTrackPfoList.emplace_back(pPfo);
209  for (const ParticleFlowObject *pChild : pPfo->GetDaughterPfoList())
210  {
211  if (std::find(outputTrackPfoList.begin(), outputTrackPfoList.end(), pChild) == outputTrackPfoList.end())
212  {
213  const int pdg{std::abs(pChild->GetParticleId())};
214  if (pdg == E_MINUS)
215  {
216  outputLeadingShowerPfoList.emplace_back(pChild);
217  }
218  else
219  {
220  outputTrackPfoList.emplace_back(pChild);
221  LArPfoHelper::GetAllDownstreamPfos(pChild, outputTrackPfoList, outputLeadingShowerPfoList);
222  }
223  }
224  }
225  }
226  else
227  {
228  outputLeadingShowerPfoList.emplace_back(pPfo);
229  }
230 }
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 681 of file LArPfoHelper.cc.

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

682 {
683  const ParticleFlowObject *pRoot{pPfo};
684  PfoList parents{pRoot->GetParentPfoList()};
685  while (!parents.empty())
686  {
687  if (parents.size() > 1)
688  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
689  pRoot = parents.front();
690  parents = pRoot->GetParentPfoList();
691  }
692  PfoList queue;
693  pfoList.emplace_back(pRoot);
694  queue.emplace_back(pRoot);
695 
696  while (!queue.empty())
697  {
698  const PfoList &daughters{queue.front()->GetDaughterPfoList()};
699  queue.pop_front();
700  for (const ParticleFlowObject *pDaughter : daughters)
701  {
702  pfoList.emplace_back(pDaughter);
703  queue.emplace_back(pDaughter);
704  }
705  }
706 }
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::TestBeamCosmicRayTaggingTool::CheckIfInVetoedTPC(), lar_content::TestBeamCosmicRayTaggingTool::CheckIfOutOfTime(), 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 293 of file LArPfoHelper.cc.

294 {
295  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
296 
297  ClusterList clusterList;
298  LArPfoHelper::GetClusters(pPfo, hitType, clusterList);
299 
300  if (clusterList.empty())
301  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
302 
303  float bestDistance(std::numeric_limits<float>::max());
304 
305  for (const Cluster *const pPfoCluster : clusterList)
306  {
307  const float thisDistance(LArClusterHelper::GetClosestDistance(pCluster, pPfoCluster));
308 
309  if (thisDistance < bestDistance)
310  bestDistance = thisDistance;
311  }
312 
313  return bestDistance;
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 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::ThreeDMultiReclusteringAlgorithm::FreeClustersFromPfos(), 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 234 of file LArPfoHelper.cc.

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

235 {
236  const ParticleFlowObject *pParentPfo = pPfo;
237  int tier(0);
238 
239  while (pParentPfo->GetParentPfoList().empty() == false)
240  {
241  if (1 != pParentPfo->GetParentPfoList().size())
242  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
243 
244  pParentPfo = *(pParentPfo->GetParentPfoList().begin());
245  ++tier;
246  }
247 
248  return tier;
249 }
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::GetNumberOfThreeDHits ( const pandora::ParticleFlowObject *const  pPfo)
static

Get the number of 3D hits owned by a pfo.

Parameters
pPfoa pointer to the pfo
Returns
The number of 3D hits

Definition at line 123 of file LArPfoHelper.cc.

124 {
125  ClusterList clusterList3D;
126  LArPfoHelper::GetThreeDClusterList(pPfo, clusterList3D);
127 
128  int total3DHits(0);
129 
130  for (const Cluster *const pCluster3D : clusterList3D)
131  total3DHits += pCluster3D->GetNCaloHits();
132 
133  return total3DHits;
134 }
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
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 488 of file LArPfoHelper.cc.

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

489 {
490  const ParticleFlowObject *const pParentPfo = LArPfoHelper::GetParentPfo(pPfo);
491 
492  if (!LArPfoHelper::IsNeutrino(pParentPfo))
493  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
494 
495  return pParentPfo;
496 }
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 474 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().

475 {
476  const ParticleFlowObject *pParentPfo = pPfo;
477 
478  while (pParentPfo->GetParentPfoList().empty() == false)
479  {
480  pParentPfo = *(pParentPfo->GetParentPfoList().begin());
481  }
482 
483  return pParentPfo;
484 }
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 393 of file LArPfoHelper.cc.

394 {
395  try
396  {
397  const ParticleFlowObject *const pParentPfo = LArPfoHelper::GetParentNeutrino(pPfo);
398  return pParentPfo->GetParticleId();
399  }
400  catch (const StatusCodeException &)
401  {
402  return 0;
403  }
404 }
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 460 of file LArPfoHelper.cc.

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

461 {
462  if (!pPfoList)
463  return;
464 
465  for (const ParticleFlowObject *const pPfo : *pPfoList)
466  {
467  if (LArPfoHelper::IsNeutrino(pPfo))
468  recoNeutrinos.push_back(pPfo);
469  }
470 }
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 528 of file LArPfoHelper.cc.

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

529 {
530  if (pPfo->GetVertexList().empty() || !pPfo->GetParentPfoList().empty() || !LArPfoHelper::IsTestBeam(pPfo))
531  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
532 
533  const Vertex *pInteractionVertex(LArPfoHelper::GetVertexWithLabel(pPfo->GetVertexList(), VERTEX_INTERACTION));
534 
535  if (VERTEX_3D != pInteractionVertex->GetVertexType())
536  throw StatusCodeException(STATUS_CODE_FAILURE);
537 
538  return pInteractionVertex;
539 }
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 151 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::TestBeamCosmicRayTaggingTool::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::TestBeamCosmicRayTaggingTool::GetValid3DCluster(), lar_content::ThreeDReclusteringAlgorithm::PassesCutsForReclustering(), lar_content::NeutrinoHierarchyAlgorithm::PfoInfo::PfoInfo(), lar_content::MasterAlgorithm::Reset(), and lar_content::ThreeDReclusteringAlgorithm::Run().

152 {
153  for (const Cluster *const pCluster : pPfo->GetClusterList())
154  {
155  if (TPC_3D != LArClusterHelper::GetClusterHitType(pCluster))
156  continue;
157 
158  clusterList.push_back(pCluster);
159  }
160 }
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 273 of file LArPfoHelper.cc.

References f.

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

274 {
275  if (!LArPfoHelper::IsThreeD(pPfo))
276  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
277 
278  float lengthSquared(0.f);
279 
280  for (const Cluster *const pCluster : pPfo->GetClusterList())
281  {
282  if (TPC_3D != LArClusterHelper::GetClusterHitType(pCluster))
283  continue;
284 
285  lengthSquared += LArClusterHelper::GetLengthSquared(pCluster);
286  }
287 
288  return lengthSquared;
289 }
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 318 of file LArPfoHelper.cc.

319 {
320  ClusterList clusterList1, clusterList2;
321 
322  LArPfoHelper::GetClusters(pPfo1, TPC_3D, clusterList1);
323  LArPfoHelper::GetClusters(pPfo2, TPC_3D, clusterList2);
324 
325  if (clusterList1.empty() || clusterList2.empty())
326  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
327 
328  return LArClusterHelper::GetClosestDistance(clusterList1, clusterList2);
329 }
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.
float lar_content::LArPfoHelper::GetTrackScore ( const pandora::ParticleFlowObject *const  pPfo)
static

Get the track/shower score of the pfo.

Parameters
pPfothe address pf the pfo
Returns
the track score

Definition at line 379 of file LArPfoHelper.cc.

References f.

380 {
381  float trackScore(-999.f);
382 
383  const PropertiesMap &metadata(pPfo->GetPropertiesMap());
384 
385  if (metadata.find("TrackScore") != metadata.end())
386  trackScore = metadata.at("TrackScore");
387 
388  return trackScore;
389 }
TFile f
Definition: plotHisto.C:6
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 138 of file LArPfoHelper.cc.

Referenced by lar_content::DeltaRayParentAlgorithm::AssignToParentPfo(), lar_content::ThreeDReclusteringAlgorithm::BuildNewTwoDClusters(), 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().

139 {
140  for (const Cluster *const pCluster : pPfo->GetClusterList())
141  {
142  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
143  continue;
144 
145  clusterList.push_back(pCluster);
146  }
147 }
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 253 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().

254 {
255  if (!LArPfoHelper::IsTwoD(pPfo))
256  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
257 
258  float lengthSquared(0.f);
259 
260  for (const Cluster *const pCluster : pPfo->GetClusterList())
261  {
262  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
263  continue;
264 
265  lengthSquared += LArClusterHelper::GetLengthSquared(pCluster);
266  }
267 
268  return lengthSquared;
269 }
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 500 of file LArPfoHelper.cc.

Referenced by lar_content::NeutrinoHierarchyAlgorithm::AdjustVertexAndPfoInfo(), lar_content::VertexMonitoringAlgorithm::AssessVertices(), lar_content::CosmicRayTaggingTool::CheckIfInTime(), lar_content::TestBeamCosmicRayTaggingTool::CheckIfOutOfTime(), 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().

501 {
502  if (pPfo->GetVertexList().empty())
503  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
504 
505  const Vertex *pVertex(nullptr);
506 
507  // ATTN : Test beam parent pfos contain an interaction and start vertex
508  if (LArPfoHelper::IsTestBeam(pPfo) && pPfo->GetParentPfoList().empty())
509  {
510  pVertex = LArPfoHelper::GetVertexWithLabel(pPfo->GetVertexList(), VERTEX_START);
511  }
512  else
513  {
514  if (pPfo->GetVertexList().size() != 1)
515  throw StatusCodeException(STATUS_CODE_FAILURE);
516 
517  pVertex = *(pPfo->GetVertexList().begin());
518  }
519 
520  if (VERTEX_3D != pVertex->GetVertexType())
521  throw StatusCodeException(STATUS_CODE_FAILURE);
522 
523  return pVertex;
524 }
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 543 of file LArPfoHelper.cc.

References f.

544 {
545  const Vertex *pTargetVertex(nullptr);
546 
547  for (const Vertex *pCandidateVertex : vertexList)
548  {
549  if (pCandidateVertex->GetVertexLabel() == vertexLabel)
550  {
551  if (!pTargetVertex)
552  {
553  pTargetVertex = pCandidateVertex;
554  }
555  else
556  {
557  throw StatusCodeException(STATUS_CODE_FAILURE);
558  }
559  }
560  }
561 
562  if (!pTargetVertex)
563  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
564 
565  return pTargetVertex;
566 }
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 408 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::TestBeamCosmicRayTaggingTool::GetCRCandidates(), lar_content::PfoValidationAlgorithm::Run(), and lar_content::StitchingCosmicRayMergingTool::SelectPrimaryPfos().

409 {
410  if (pPfo->GetParentPfoList().empty() && !LArPfoHelper::IsNeutrino(pPfo))
411  return true;
412 
414  return true;
415 
416  return false;
417 }
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 428 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().

429 {
430  const int absoluteParticleId(std::abs(pPfo->GetParticleId()));
431 
432  if ((NU_E == absoluteParticleId) || (NU_MU == absoluteParticleId) || (NU_TAU == absoluteParticleId))
433  return true;
434 
435  return false;
436 }
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 421 of file LArPfoHelper.cc.

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

422 {
423  return ((pPfo->GetParentPfoList().size() == 1) && (LArPfoHelper::IsNeutrino(*(pPfo->GetParentPfoList().begin()))));
424 }
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 369 of file LArPfoHelper.cc.

References util::abs().

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

370 {
371  const int pdg(pPfo->GetParticleId());
372 
373  // electron, photon
374  return ((E_MINUS == std::abs(pdg)) || (PHOTON == std::abs(pdg)));
375 }
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 447 of file LArPfoHelper.cc.

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

448 {
449  const PropertiesMap &properties(pPfo->GetPropertiesMap());
450  const PropertiesMap::const_iterator iter(properties.find("IsTestBeam"));
451 
452  if (iter != properties.end())
453  return ((iter->second > 0.f) ? true : false);
454 
455  return false;
456 }
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 440 of file LArPfoHelper.cc.

441 {
443 }
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 346 of file LArPfoHelper.cc.

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

347 {
348  for (const Cluster *const pCluster : pPfo->GetClusterList())
349  {
350  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
351  return true;
352  }
353 
354  return false;
355 }
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 333 of file LArPfoHelper.cc.

334 {
335  for (const Cluster *const pCluster : pPfo->GetClusterList())
336  {
337  if (TPC_3D != LArClusterHelper::GetClusterHitType(pCluster))
338  return true;
339  }
340 
341  return false;
342 }
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 711 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().

713 {
714  CartesianPointVector pointVector;
715 
716  for (const auto &nextPoint : *pT)
717  pointVector.push_back(LArObjectHelper::TypeAdaptor::GetPosition(nextPoint));
718 
719  if (pointVector.empty())
720  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
721 
722  std::sort(pointVector.begin(), pointVector.end(), LArClusterHelper::SortCoordinatesByPosition);
723 
724  LArTrackTrajectory trackTrajectory;
725  IntVector indicesWithoutSpacePoints;
726  if (pIndexVector)
727  pIndexVector->clear();
728 
729  try
730  {
731  const ThreeDSlidingFitResult slidingFitResult(&pointVector, layerWindow, layerPitch);
732  const CartesianVector minPosition(slidingFitResult.GetGlobalMinLayerPosition());
733  const CartesianVector maxPosition(slidingFitResult.GetGlobalMaxLayerPosition());
734 
735  if ((maxPosition - minPosition).GetMagnitudeSquared() < std::numeric_limits<float>::epsilon())
736  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
737 
738  const CartesianVector seedPosition((maxPosition + minPosition) * 0.5f);
739  const CartesianVector seedDirection((maxPosition - minPosition).GetUnitVector());
740 
741  const float scaleFactor((seedDirection.GetDotProduct(seedPosition - vertexPosition) > 0.f) ? +1.f : -1.f);
742 
743  int index(-1);
744  for (const auto &nextPoint : *pT)
745  {
746  ++index;
747 
748  try
749  {
750  const float rL(slidingFitResult.GetLongitudinalDisplacement(LArObjectHelper::TypeAdaptor::GetPosition(nextPoint)));
751 
752  CartesianVector position(0.f, 0.f, 0.f);
753  const StatusCode positionStatusCode(slidingFitResult.GetGlobalFitPosition(rL, position));
754 
755  if (positionStatusCode != STATUS_CODE_SUCCESS)
756  throw StatusCodeException(positionStatusCode);
757 
758  CartesianVector direction(0.f, 0.f, 0.f);
759  const StatusCode directionStatusCode(slidingFitResult.GetGlobalFitDirection(rL, direction));
760 
761  if (directionStatusCode != STATUS_CODE_SUCCESS)
762  throw StatusCodeException(directionStatusCode);
763 
764  const float projection(seedDirection.GetDotProduct(position - seedPosition));
765 
766  trackTrajectory.push_back(LArTrackTrajectoryPoint(projection * scaleFactor,
767  LArTrackState(position, direction * scaleFactor, LArObjectHelper::TypeAdaptor::GetCaloHit(nextPoint)), index));
768  }
769  catch (const StatusCodeException &statusCodeException1)
770  {
771  indicesWithoutSpacePoints.push_back(index);
772 
773  if (STATUS_CODE_FAILURE == statusCodeException1.GetStatusCode())
774  throw statusCodeException1;
775  }
776  }
777  }
778  catch (const StatusCodeException &statusCodeException2)
779  {
780  if (STATUS_CODE_FAILURE == statusCodeException2.GetStatusCode())
781  throw statusCodeException2;
782  }
783 
784  // Sort trajectory points by distance along track
785  std::sort(trackTrajectory.begin(), trackTrajectory.end(), LArPfoHelper::SortByHitProjection);
786 
787  for (const LArTrackTrajectoryPoint &larTrackTrajectoryPoint : trackTrajectory)
788  {
789  trackStateVector.push_back(larTrackTrajectoryPoint.second);
790  if (pIndexVector)
791  pIndexVector->push_back(larTrackTrajectoryPoint.GetIndex());
792  }
793 
794  // Store indices of spacepoints with no associated trajectory point at the end of pIndexVector
795  if (pIndexVector)
796  {
797  for (const int index : indicesWithoutSpacePoints)
798  pIndexVector->push_back(index);
799  }
800 }
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 622 of file LArPfoHelper.cc.

References f.

623 {
624  if (lhs.first != rhs.first)
625  return (lhs.first < rhs.first);
626 
627  // ATTN Removed to support use with CartesianVector only (no CaloHit) input
628  // if (lhs.second.GetCaloHit() && rhs.second.GetCaloHit())
629  // return (lhs.second.GetCaloHit()->GetInputEnergy() > rhs.second.GetCaloHit()->GetInputEnergy());
630 
631  const float dx(lhs.second.GetPosition().GetX() - rhs.second.GetPosition().GetX());
632  const float dy(lhs.second.GetPosition().GetY() - rhs.second.GetPosition().GetY());
633  const float dz(lhs.second.GetPosition().GetZ() - rhs.second.GetPosition().GetZ());
634  return (dx + dy + dz > 0.f);
635 }
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 639 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().

640 {
641  unsigned int nTwoDHitsLhs(0), nThreeDHitsLhs(0);
642  float energyLhs(0.f);
643  for (ClusterList::const_iterator iter = pLhs->GetClusterList().begin(), iterEnd = pLhs->GetClusterList().end(); iter != iterEnd; ++iter)
644  {
645  const Cluster *const pClusterLhs = *iter;
646 
647  if (TPC_3D != LArClusterHelper::GetClusterHitType(pClusterLhs))
648  nTwoDHitsLhs += pClusterLhs->GetNCaloHits();
649  else
650  nThreeDHitsLhs += pClusterLhs->GetNCaloHits();
651 
652  energyLhs += pClusterLhs->GetHadronicEnergy();
653  }
654 
655  unsigned int nTwoDHitsRhs(0), nThreeDHitsRhs(0);
656  float energyRhs(0.f);
657  for (ClusterList::const_iterator iter = pRhs->GetClusterList().begin(), iterEnd = pRhs->GetClusterList().end(); iter != iterEnd; ++iter)
658  {
659  const Cluster *const pClusterRhs = *iter;
660 
661  if (TPC_3D != LArClusterHelper::GetClusterHitType(pClusterRhs))
662  nTwoDHitsRhs += pClusterRhs->GetNCaloHits();
663  else
664  nThreeDHitsRhs += pClusterRhs->GetNCaloHits();
665 
666  energyRhs += pClusterRhs->GetHadronicEnergy();
667  }
668 
669  if (nTwoDHitsLhs != nTwoDHitsRhs)
670  return (nTwoDHitsLhs > nTwoDHitsRhs);
671 
672  if (nThreeDHitsLhs != nThreeDHitsRhs)
673  return (nThreeDHitsLhs > nThreeDHitsRhs);
674 
675  // ATTN Need an efficient (balance with well-motivated) tie-breaker here. Pfo length, for instance, is extremely slow.
676  return (energyLhs > energyRhs);
677 }
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: