LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 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 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 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 GetTwoDSeparation (const pandora::ParticleFlowObject *const pPfo1, const pandora::ParticleFlowObject *const pPfo2)
 Get distance between two Pfos using 2D clusters. 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 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 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 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

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::PfoList &  inputPfoList,
pandora::PfoList &  outputPfoList 
)
static
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
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 202 of file LArPfoHelper.cc.

References max.

203 {
204  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
205 
206  ClusterList clusterList;
207  LArPfoHelper::GetClusters(pPfo, hitType, clusterList);
208 
209  if (clusterList.empty())
210  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
211 
212  float bestDistance(std::numeric_limits<float>::max());
213 
214  for (const Cluster *const pPfoCluster : clusterList)
215  {
216  const float thisDistance(LArClusterHelper::GetClosestDistance(pCluster, pPfoCluster));
217 
218  if (thisDistance < bestDistance)
219  bestDistance = thisDistance;
220  }
221 
222  return bestDistance;
223 }
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.
Int_t max
Definition: plot.C:27
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::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.
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(), and lar_content::LArMCParticleHelper::CollectReconstructable2DHits().

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
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 418 of file LArPfoHelper.cc.

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

419 {
420  const ParticleFlowObject *const pParentPfo = LArPfoHelper::GetParentPfo(pPfo);
421 
422  if(!LArPfoHelper::IsNeutrino(pParentPfo))
423  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
424 
425  return pParentPfo;
426 }
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 404 of file LArPfoHelper.cc.

Referenced by lar_pandora::LArPandoraOutput::BuildSlices(), lar_pandora::LArPandoraOutput::GetSliceIndex(), lar_pandora::LArPandoraOutput::IsClearCosmic(), and lar_pandora::LArPandoraOutput::IsFromSlice().

405 {
406  const ParticleFlowObject *pParentPfo = pPfo;
407 
408  while (pParentPfo->GetParentPfoList().empty() == false)
409  {
410  pParentPfo = *(pParentPfo->GetParentPfoList().begin());
411  }
412 
413  return pParentPfo;
414 }
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 330 of file LArPfoHelper.cc.

331 {
332  try
333  {
334  const ParticleFlowObject *const pParentPfo = LArPfoHelper::GetParentNeutrino(pPfo);
335  return pParentPfo->GetParticleId();
336  }
337  catch (const StatusCodeException &)
338  {
339  return 0;
340  }
341 }
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 390 of file LArPfoHelper.cc.

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

391 {
392  if (!pPfoList)
393  return;
394 
395  for (const ParticleFlowObject *const pPfo : *pPfoList)
396  {
397  if (LArPfoHelper::IsNeutrino(pPfo))
398  recoNeutrinos.push_back(pPfo);
399  }
400 }
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 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
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 110 of file LArPfoHelper.cc.

Referenced by lar_content::ThreeDHitCreationAlgorithm::AddThreeDHitsToPfo(), lar_content::StitchingCosmicRayMergingTool::BuildPointingClusterMaps(), lar_content::CosmicRayTaggingTool::CRCandidate::CRCandidate(), lar_content::NeutrinoIdTool::SliceFeatures::GetSpacePoints(), lar_content::EventSlicingTool::GetThreeDClusters(), lar_content::SlidingConePfoMopUpAlgorithm::GetThreeDClusters(), lar_content::SlidingConeClusterMopUpAlgorithm::GetThreeDClusters(), lar_content::CosmicRayTaggingTool::GetValid3DCluster(), lar_content::NeutrinoHierarchyAlgorithm::PfoInfo::PfoInfo(), lar_content::MasterAlgorithm::Reset(), lar_content::ThreeDOpeningAngleFeatureTool::Run(), and lar_content::ThreeDPCAFeatureTool::Run().

111 {
112  for (const Cluster *const pCluster : pPfo->GetClusterList())
113  {
114  if (TPC_3D != LArClusterHelper::GetClusterHitType(pCluster))
115  continue;
116 
117  clusterList.push_back(pCluster);
118  }
119 }
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 182 of file LArPfoHelper.cc.

References f.

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

183 {
184  if (!LArPfoHelper::IsThreeD(pPfo))
185  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
186 
187  float lengthSquared(0.f);
188 
189  for (const Cluster *const pCluster : pPfo->GetClusterList())
190  {
191  if (TPC_3D != LArClusterHelper::GetClusterHitType(pCluster))
192  continue;
193 
194  lengthSquared += LArClusterHelper::GetLengthSquared(pCluster);
195  }
196 
197  return lengthSquared;
198 }
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 269 of file LArPfoHelper.cc.

270 {
271  ClusterList clusterList1, clusterList2;
272 
273  LArPfoHelper::GetClusters(pPfo1, TPC_3D, clusterList1);
274  LArPfoHelper::GetClusters(pPfo2, TPC_3D, clusterList2);
275 
276  if (clusterList1.empty() || clusterList2.empty())
277  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
278 
279  return LArClusterHelper::GetClosestDistance(clusterList1, clusterList2);
280 }
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 97 of file LArPfoHelper.cc.

Referenced by 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().

98 {
99  for (const Cluster *const pCluster : pPfo->GetClusterList())
100  {
101  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
102  continue;
103 
104  clusterList.push_back(pCluster);
105  }
106 }
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 162 of file LArPfoHelper.cc.

References f.

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

163 {
164  if (!LArPfoHelper::IsTwoD(pPfo))
165  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
166 
167  float lengthSquared(0.f);
168 
169  for (const Cluster *const pCluster : pPfo->GetClusterList())
170  {
171  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
172  continue;
173 
174  lengthSquared += LArClusterHelper::GetLengthSquared(pCluster);
175  }
176 
177  return lengthSquared;
178 }
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.
float lar_content::LArPfoHelper::GetTwoDSeparation ( const pandora::ParticleFlowObject *const  pPfo1,
const pandora::ParticleFlowObject *const  pPfo2 
)
static

Get distance between two Pfos using 2D clusters.

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

Definition at line 227 of file LArPfoHelper.cc.

References f.

228 {
229  ClusterList clusterListU1, clusterListV1, clusterListW1;
230  ClusterList clusterListU2, clusterListV2, clusterListW2;
231 
232  LArPfoHelper::GetClusters(pPfo1, TPC_VIEW_U, clusterListU1);
233  LArPfoHelper::GetClusters(pPfo1, TPC_VIEW_V, clusterListV1);
234  LArPfoHelper::GetClusters(pPfo1, TPC_VIEW_W, clusterListW1);
235 
236  LArPfoHelper::GetClusters(pPfo2, TPC_VIEW_U, clusterListU2);
237  LArPfoHelper::GetClusters(pPfo2, TPC_VIEW_V, clusterListV2);
238  LArPfoHelper::GetClusters(pPfo2, TPC_VIEW_W, clusterListW2);
239 
240  float numViews(0.f);
241  float distanceSquared(0.f);
242 
243  if (!clusterListU1.empty() && !clusterListU2.empty())
244  {
245  distanceSquared += LArClusterHelper::GetClosestDistance(clusterListU1, clusterListU2);
246  numViews += 1.f;
247  }
248 
249  if (!clusterListV1.empty() && !clusterListV2.empty())
250  {
251  distanceSquared += LArClusterHelper::GetClosestDistance(clusterListV1, clusterListV2);
252  numViews += 1.f;
253  }
254 
255  if (!clusterListW1.empty() && !clusterListW2.empty())
256  {
257  distanceSquared += LArClusterHelper::GetClosestDistance(clusterListW1, clusterListW2);
258  numViews += 1.f;
259  }
260 
261  if (numViews < std::numeric_limits<float>::epsilon())
262  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
263 
264  return std::sqrt(distanceSquared / numViews);
265 }
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.
TFile f
Definition: plotHisto.C:6
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
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 430 of file LArPfoHelper.cc.

References f.

Referenced by lar_content::CosmicRayTaggingTool::CheckIfInTime(), lar_pandora::LArPandoraOutput::CollectVertices(), lar_content::TrackParticleBuildingAlgorithm::CreatePfo(), lar_content::PcaShowerParticleBuildingAlgorithm::CreatePfo(), lar_content::EventValidationAlgorithm::ProcessOutput(), lar_content::ThreeDVertexDistanceFeatureTool::Run(), lar_content::NeutrinoHierarchyAlgorithm::Run(), lar_content::TestBeamParticleCreationAlgorithm::SetupTestBeamVertex(), and lar_content::NeutrinoIdTool::SliceFeatures::SliceFeatures().

431 {
432  if (pPfo->GetVertexList().empty())
433  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
434 
435  if (pPfo->GetVertexList().size() != 1)
436  throw StatusCodeException(STATUS_CODE_FAILURE);
437 
438  const Vertex *const pVertex = *(pPfo->GetVertexList().begin());
439 
440  if (VERTEX_3D != pVertex->GetVertexType())
441  throw StatusCodeException(STATUS_CODE_FAILURE);
442 
443  return pVertex;
444 }
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 345 of file LArPfoHelper.cc.

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

346 {
347  if (pPfo->GetParentPfoList().empty() && !LArPfoHelper::IsNeutrino(pPfo))
348  return true;
349 
351  return true;
352 
353  return false;
354 }
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 365 of file LArPfoHelper.cc.

Referenced by 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::NeutrinoPropertiesAlgorithm::Run(), lar_content::TestBeamParticleCreationAlgorithm::Run(), and lar_content::CheatingBeamParticleIdTool::SelectOutputPfos().

366 {
367  const int absoluteParticleId(std::abs(pPfo->GetParticleId()));
368 
369  if ((NU_E == absoluteParticleId) || (NU_MU == absoluteParticleId) || (NU_TAU == absoluteParticleId))
370  return true;
371 
372  return false;
373 }
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 358 of file LArPfoHelper.cc.

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

359 {
360  return ((pPfo->GetParentPfoList().size() == 1) && (LArPfoHelper::IsNeutrino(*(pPfo->GetParentPfoList().begin()))));
361 }
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 320 of file LArPfoHelper.cc.

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

321 {
322  const int pdg(pPfo->GetParticleId());
323 
324  // electron, photon
325  return ((E_MINUS == std::abs(pdg)) || (PHOTON == std::abs(pdg)));
326 }
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 377 of file LArPfoHelper.cc.

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

378 {
379  const PropertiesMap &properties(pPfo->GetPropertiesMap());
380  const PropertiesMap::const_iterator iter(properties.find("IsTestBeam"));
381 
382  if (iter != properties.end())
383  return ((iter->second > 0.f) ? true : false);
384 
385  return false;
386 }
intermediate_table::const_iterator const_iterator
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 297 of file LArPfoHelper.cc.

Referenced by lar_content::SvmPfoCharacterisationAlgorithm::IsClearTrack().

298 {
299  for (const Cluster *const pCluster : pPfo->GetClusterList())
300  {
301  if (TPC_3D == LArClusterHelper::GetClusterHitType(pCluster))
302  return true;
303  }
304 
305  return false;
306 }
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 284 of file LArPfoHelper.cc.

285 {
286  for (const Cluster *const pCluster : pPfo->GetClusterList())
287  {
288  if (TPC_3D != LArClusterHelper::GetClusterHitType(pCluster))
289  return true;
290  }
291 
292  return false;
293 }
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 558 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().

560 {
561  CartesianPointVector pointVector;
562 
563  for (const auto &nextPoint : *pT)
564  pointVector.push_back(LArObjectHelper::TypeAdaptor::GetPosition(nextPoint));
565 
566  if (pointVector.empty())
567  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
568 
569  std::sort(pointVector.begin(), pointVector.end(), LArClusterHelper::SortCoordinatesByPosition);
570 
571  LArTrackTrajectory trackTrajectory;
572  IntVector indicesWithoutSpacePoints;
573  if (pIndexVector) pIndexVector->clear();
574 
575  try
576  {
577  const ThreeDSlidingFitResult slidingFitResult(&pointVector, layerWindow, layerPitch);
578  const CartesianVector minPosition(slidingFitResult.GetGlobalMinLayerPosition());
579  const CartesianVector maxPosition(slidingFitResult.GetGlobalMaxLayerPosition());
580 
581  if ((maxPosition - minPosition).GetMagnitudeSquared() < std::numeric_limits<float>::epsilon())
582  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
583 
584  const CartesianVector seedPosition((maxPosition + minPosition) * 0.5f);
585  const CartesianVector seedDirection((maxPosition - minPosition).GetUnitVector());
586 
587  const float scaleFactor((seedDirection.GetDotProduct(seedPosition - vertexPosition) > 0.f) ? +1.f : -1.f);
588 
589  int index(-1);
590  for (const auto &nextPoint : *pT)
591  {
592  ++index;
593 
594  try
595  {
596  const float rL(slidingFitResult.GetLongitudinalDisplacement(LArObjectHelper::TypeAdaptor::GetPosition(nextPoint)));
597 
598  CartesianVector position(0.f, 0.f, 0.f);
599  const StatusCode positionStatusCode(slidingFitResult.GetGlobalFitPosition(rL, position));
600 
601  if (positionStatusCode != STATUS_CODE_SUCCESS)
602  throw StatusCodeException(positionStatusCode);
603 
604  CartesianVector direction(0.f, 0.f, 0.f);
605  const StatusCode directionStatusCode(slidingFitResult.GetGlobalFitDirection(rL, direction));
606 
607  if (directionStatusCode != STATUS_CODE_SUCCESS)
608  throw StatusCodeException(directionStatusCode);
609 
610  const float projection(seedDirection.GetDotProduct(position - seedPosition));
611 
612  trackTrajectory.push_back(LArTrackTrajectoryPoint(projection * scaleFactor,
613  LArTrackState(position, direction * scaleFactor, LArObjectHelper::TypeAdaptor::GetCaloHit(nextPoint)), index));
614  }
615  catch (const StatusCodeException &statusCodeException1)
616  {
617  indicesWithoutSpacePoints.push_back(index);
618 
619  if (STATUS_CODE_FAILURE == statusCodeException1.GetStatusCode())
620  throw statusCodeException1;
621  }
622  }
623  }
624  catch (const StatusCodeException &statusCodeException2)
625  {
626  if (STATUS_CODE_FAILURE == statusCodeException2.GetStatusCode())
627  throw statusCodeException2;
628  }
629 
630  // Sort trajectory points by distance along track
631  std::sort(trackTrajectory.begin(), trackTrajectory.end(), LArPfoHelper::SortByHitProjection);
632 
633  for (const LArTrackTrajectoryPoint &larTrackTrajectoryPoint : trackTrajectory)
634  {
635  trackStateVector.push_back(larTrackTrajectoryPoint.second);
636  if (pIndexVector) pIndexVector->push_back(larTrackTrajectoryPoint.GetIndex());
637  }
638 
639  // Store indices of spacepoints with no associated trajectory point at the end of pIndexVector
640  if (pIndexVector)
641  {
642  for (const int index : indicesWithoutSpacePoints)
643  pIndexVector->push_back(index);
644  }
645 }
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 500 of file LArPfoHelper.cc.

References f.

501 {
502  if (lhs.first != rhs.first)
503  return (lhs.first < rhs.first);
504 
505  // ATTN Removed to support use with CartesianVector only (no CaloHit) input
506  // if (lhs.second.GetCaloHit() && rhs.second.GetCaloHit())
507  // return (lhs.second.GetCaloHit()->GetInputEnergy() > rhs.second.GetCaloHit()->GetInputEnergy());
508 
509  const float dx(lhs.second.GetPosition().GetX() - rhs.second.GetPosition().GetX());
510  const float dy(lhs.second.GetPosition().GetY() - rhs.second.GetPosition().GetY());
511  const float dz(lhs.second.GetPosition().GetZ() - rhs.second.GetPosition().GetZ());
512  return (dx + dy + dz > 0.f);
513 }
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 517 of file LArPfoHelper.cc.

References f.

Referenced by lar_content::DeltaRayIdentificationAlgorithm::BuildParentDaughterLinks(), lar_pandora::LArPandoraOutput::BuildSlice(), lar_content::CosmicRayTaggingMonitoringTool::CalculatePfoMetrics(), lar_pandora::LArPandoraOutput::CollectPfos(), lar_content::NeutrinoHierarchyAlgorithm::DisplayPfoInfoMap(), lar_content::DeltaRayMatchingAlgorithm::GetAllPfos(), lar_content::LArMCParticleHelper::GetPfoMCParticleHitSharingMaps(), lar_content::DeltaRayGrowingAlgorithm::GetPfos(), lar_content::DeltaRayIdentificationAlgorithm::GetPfos(), lar_content::EventValidationAlgorithm::InterpretMatching(), lar_content::VertexBasedPfoMopUpAlgorithm::PfoAssociation::operator<(), lar_content::StitchingCosmicRayMergingTool::OrderPfoMerges(), lar_content::NeutrinoHierarchyAlgorithm::ProcessPfoInfoMap(), lar_content::VertexAssociatedPfosTool::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().

518 {
519  unsigned int nTwoDHitsLhs(0), nThreeDHitsLhs(0); float energyLhs(0.f);
520  for (ClusterList::const_iterator iter = pLhs->GetClusterList().begin(), iterEnd = pLhs->GetClusterList().end(); iter != iterEnd; ++iter)
521  {
522  const Cluster *const pClusterLhs = *iter;
523 
524  if (TPC_3D != LArClusterHelper::GetClusterHitType(pClusterLhs))
525  nTwoDHitsLhs += pClusterLhs->GetNCaloHits();
526  else
527  nThreeDHitsLhs += pClusterLhs->GetNCaloHits();
528 
529  energyLhs += pClusterLhs->GetHadronicEnergy();
530  }
531 
532  unsigned int nTwoDHitsRhs(0), nThreeDHitsRhs(0); float energyRhs(0.f);
533  for (ClusterList::const_iterator iter = pRhs->GetClusterList().begin(), iterEnd = pRhs->GetClusterList().end(); iter != iterEnd; ++iter)
534  {
535  const Cluster *const pClusterRhs = *iter;
536 
537  if (TPC_3D != LArClusterHelper::GetClusterHitType(pClusterRhs))
538  nTwoDHitsRhs += pClusterRhs->GetNCaloHits();
539  else
540  nThreeDHitsRhs += pClusterRhs->GetNCaloHits();
541 
542  energyRhs += pClusterRhs->GetHadronicEnergy();
543  }
544 
545  if (nTwoDHitsLhs != nTwoDHitsRhs)
546  return (nTwoDHitsLhs > nTwoDHitsRhs);
547 
548  if (nThreeDHitsLhs != nThreeDHitsRhs)
549  return (nThreeDHitsLhs > nThreeDHitsRhs);
550 
551  // ATTN Need an efficient (balance with well-motivated) tie-breaker here. Pfo length, for instance, is extremely slow.
552  return (energyLhs > energyRhs);
553 }
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
intermediate_table::const_iterator const_iterator

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