32 for (
const Cluster *
const pCluster : clusterList)
51 for (
const Cluster *
const pCluster : clusterList)
52 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
70 for (
const Cluster *
const pCluster : clusterList)
71 caloHitList.insert(caloHitList.end(), pCluster->GetIsolatedCaloHitList().begin(), pCluster->GetIsolatedCaloHitList().end());
103 clusterList.push_back(pCluster);
111 unsigned int totalHits(0);
115 for (
const Cluster *
const pCluster : clusterList)
116 totalHits += pCluster->GetNCaloHits();
130 clusterList.push_back(pCluster);
143 clusterList.push_back(pCluster);
159 if (outputPfoList.end() != std::find(outputPfoList.begin(), outputPfoList.end(), pPfo))
162 outputPfoList.push_back(pPfo);
179 if (outputPfoList.end() != std::find(outputPfoList.begin(), outputPfoList.end(), pPfo))
182 outputPfoList.push_back(pPfo);
193 outputTrackPfoList.emplace_back(pPfo);
196 if (std::find(outputTrackPfoList.begin(), outputTrackPfoList.end(), pChild) == outputTrackPfoList.end())
198 const int pdg{std::abs(pChild->GetParticleId())};
201 outputLeadingShowerPfoList.emplace_back(pChild);
205 outputTrackPfoList.emplace_back(pChild);
213 outputLeadingShowerPfoList.emplace_back(pPfo);
243 float lengthSquared(0.f);
253 return lengthSquared;
263 float lengthSquared(0.f);
273 return lengthSquared;
285 if (clusterList.empty())
288 float bestDistance(std::numeric_limits<float>::max());
290 for (
const Cluster *
const pPfoCluster : clusterList)
294 if (thisDistance < bestDistance)
295 bestDistance = thisDistance;
310 if (clusterList1.empty() || clusterList2.empty())
349 return ((MU_MINUS == std::abs(pdg)) || (PI_PLUS == std::abs(pdg)) || (PROTON == std::abs(pdg)) || (K_PLUS == std::abs(pdg)));
359 return ((E_MINUS == std::abs(pdg)) || (PHOTON == std::abs(pdg)));
401 const int absoluteParticleId(std::abs(pPfo->
GetParticleId()));
403 if ((NU_E == absoluteParticleId) || (NU_MU == absoluteParticleId) || (NU_TAU == absoluteParticleId))
421 const PropertiesMap::const_iterator iter(properties.find(
"IsTestBeam"));
423 if (iter != properties.end())
424 return ((iter->second > 0.f) ?
true :
false);
439 recoNeutrinos.push_back(pPfo);
476 const Vertex *pVertex(
nullptr);
509 return pInteractionVertex;
516 const Vertex *pTargetVertex(
nullptr);
518 for (
const Vertex *pCandidateVertex : vertexList)
520 if (pCandidateVertex->GetVertexLabel() == vertexLabel)
524 pTargetVertex = pCandidateVertex;
536 return pTargetVertex;
550 const unsigned int layerWindow,
const float layerPitch,
LArTrackStateVector &trackStateVector)
568 if (eigenValues.
GetX() < std::numeric_limits<float>::epsilon())
572 const float testProjection(eigenVecs.at(0).GetDotProduct(vertexPosition - centroid));
573 const float directionScaleFactor((testProjection > std::numeric_limits<float>::epsilon()) ? -1.f : 1.f);
575 const CartesianVector primaryAxis(eigenVecs.at(0) * directionScaleFactor);
576 const CartesianVector secondaryAxis(eigenVecs.at(1) * directionScaleFactor);
577 const CartesianVector tertiaryAxis(eigenVecs.at(2) * directionScaleFactor);
579 return LArShowerPCA(centroid, primaryAxis, secondaryAxis, tertiaryAxis, eigenValues);
595 if (lhs.first != rhs.first)
596 return (lhs.first < rhs.first);
602 const float dx(lhs.second.GetPosition().GetX() - rhs.second.GetPosition().GetX());
603 const float dy(lhs.second.GetPosition().GetY() - rhs.second.GetPosition().GetY());
604 const float dz(lhs.second.GetPosition().GetZ() - rhs.second.GetPosition().GetZ());
605 return (dx + dy + dz > 0.f);
612 unsigned int nTwoDHitsLhs(0), nThreeDHitsLhs(0);
613 float energyLhs(0.f);
614 for (ClusterList::const_iterator iter = pLhs->
GetClusterList().begin(), iterEnd = pLhs->
GetClusterList().end(); iter != iterEnd; ++iter)
616 const Cluster *
const pClusterLhs = *iter;
626 unsigned int nTwoDHitsRhs(0), nThreeDHitsRhs(0);
627 float energyRhs(0.f);
628 for (ClusterList::const_iterator iter = pRhs->
GetClusterList().begin(), iterEnd = pRhs->
GetClusterList().end(); iter != iterEnd; ++iter)
630 const Cluster *
const pClusterRhs = *iter;
640 if (nTwoDHitsLhs != nTwoDHitsRhs)
641 return (nTwoDHitsLhs > nTwoDHitsRhs);
643 if (nThreeDHitsLhs != nThreeDHitsRhs)
644 return (nThreeDHitsLhs > nThreeDHitsRhs);
647 return (energyLhs > energyRhs);
656 while (!parents.empty())
658 if (parents.size() > 1)
660 pRoot = parents.front();
661 parents = pRoot->GetParentPfoList();
664 pfoList.emplace_back(pRoot);
665 queue.emplace_back(pRoot);
667 while (!queue.empty())
669 const PfoList &daughters{queue.front()->GetDaughterPfoList()};
673 pfoList.emplace_back(pDaughter);
674 queue.emplace_back(pDaughter);
687 for (
const auto &nextPoint : *pT)
690 if (pointVector.empty())
698 pIndexVector->clear();
706 if ((maxPosition - minPosition).GetMagnitudeSquared() < std::numeric_limits<float>::epsilon())
709 const CartesianVector seedPosition((maxPosition + minPosition) * 0.5f);
710 const CartesianVector seedDirection((maxPosition - minPosition).GetUnitVector());
712 const float scaleFactor((seedDirection.
GetDotProduct(seedPosition - vertexPosition) > 0.f) ? +1.f : -1.f);
715 for (
const auto &nextPoint : *pT)
726 if (positionStatusCode != STATUS_CODE_SUCCESS)
732 if (directionStatusCode != STATUS_CODE_SUCCESS)
735 const float projection(seedDirection.
GetDotProduct(position - seedPosition));
742 indicesWithoutSpacePoints.push_back(index);
744 if (STATUS_CODE_FAILURE == statusCodeException1.
GetStatusCode())
745 throw statusCodeException1;
751 if (STATUS_CODE_FAILURE == statusCodeException2.
GetStatusCode())
752 throw statusCodeException2;
760 trackStateVector.push_back(larTrackTrajectoryPoint.second);
762 pIndexVector->push_back(larTrackTrajectoryPoint.GetIndex());
768 for (
const int index : indicesWithoutSpacePoints)
769 pIndexVector->push_back(index);
Header file for the cluster helper class.
Header file for the object helper class.
Header file for the principal curve analysis helper class.
Header file for the pfo helper class.
Header file for the lar three dimensional sliding fit result class.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static void GetCoordinateVector(const pandora::Cluster *const pCluster, pandora::CartesianPointVector &coordinateVector)
Get vector of hit coordinates from an input cluster.
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 float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static const pandora::CaloHit * GetCaloHit(const T &t)
Get the associated calo hit, or nullptr if none.
static pandora::CartesianVector GetPosition(const T &t)
Get the associated position.
std::vector< pandora::CartesianVector > EigenVectors
static void RunPca(const T &t, pandora::CartesianVector ¢roid, EigenValues &outputEigenValues, EigenVectors &outputEigenVectors)
Run principal component analysis using input calo hits (TPC_VIEW_U,V,W or TPC_3D; all treated as 3D p...
static void GetAllConnectedPfos(const pandora::PfoList &inputPfoList, pandora::PfoList &outputPfoList)
Get a flat list of all pfos, recursively including all daughters and parents associated with those pf...
static bool IsFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a primary parent particle.
static bool IsTestBeam(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a test beam particle.
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
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...
static const pandora::ParticleFlowObject * GetParentPfo(const pandora::ParticleFlowObject *const pPfo)
Get the primary parent pfo.
static float GetThreeDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 3D clusters.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
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.
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 ...
static float GetThreeDSeparation(const pandora::ParticleFlowObject *const pPfo1, const pandora::ParticleFlowObject *const pPfo2)
Get distance between two Pfos using 3D clusters.
static bool IsShower(const pandora::ParticleFlowObject *const pPfo)
Return shower flag based on Pfo Particle ID.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
static bool SortByHitProjection(const LArTrackTrajectoryPoint &lhs, const LArTrackTrajectoryPoint &rhs)
Sort pfos by number of constituent hits.
static unsigned int GetNumberOfTwoDHits(const pandora::ParticleFlowObject *const pPfo)
Get the number of 2D hits of a PFO.
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 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.
static const pandora::ParticleFlowObject * GetParentNeutrino(const pandora::ParticleFlowObject *const pPfo)
Get primary neutrino or antineutrino.
static bool IsTwoD(const pandora::ParticleFlowObject *const pPfo)
Does Pfo contain 2D clusters.
static bool IsThreeD(const pandora::ParticleFlowObject *const pPfo)
Does Pfo contain 3D clusters.
static void GetTwoDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 2D clusters from an input pfo.
static float GetClosestDistance(const pandora::ParticleFlowObject *const pPfo, const pandora::Cluster *const pCluster)
Get closest distance between Pfo and cluster.
static LArShowerPCA GetPrincipalComponents(const pandora::CartesianPointVector &pointVector, const pandora::CartesianVector &vertexPosition)
Perform PCA analysis on a set of 3D points and return results.
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.
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 bool IsNeutrinoFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
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 GetRecoNeutrinos(const pandora::PfoList *const pPfoList, pandora::PfoList &recoNeutrinos)
Get neutrino pfos from an input pfo list.
static const pandora::Vertex * GetTestBeamInteractionVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo test beam interaction vertex.
static int GetPrimaryNeutrino(const pandora::ParticleFlowObject *const pPfo)
Get primary neutrino or antineutrino.
static bool IsTestBeamFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a test beam particle interaction.
static float GetTwoDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 2D clusters.
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 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.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
static int GetHierarchyTier(const pandora::ParticleFlowObject *const pPfo)
Determine the position in the hierarchy for the MCParticle.
LArTrackTrajectoryPoint class.
ThreeDSlidingFitResult class.
pandora::StatusCode GetGlobalFitPosition(const float rL, pandora::CartesianVector &position) const
Get global fit position for a given longitudinal coordinate.
float GetLongitudinalDisplacement(const pandora::CartesianVector &position) const
Get longitudinal projection onto primary axis.
const pandora::CartesianVector & GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
pandora::StatusCode GetGlobalFitDirection(const float rL, pandora::CartesianVector &direction) const
Get global fit direction for a given longitudinal coordinate.
const pandora::CartesianVector & GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
float GetX() const
Get the cartesian x coordinate.
float GetDotProduct(const CartesianVector &rhs) const
Get the dot product of the cartesian vector with a second cartesian vector.
float GetHadronicEnergy() const
Get the sum of hadronic energy measures of all constituent calo hits, units GeV.
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
ParticleFlowObject class.
const PropertiesMap & GetPropertiesMap() const
Get the map from registered property name to floating point property value.
const PfoList & GetDaughterPfoList() const
Get the daughter pfo list.
const ClusterList & GetClusterList() const
Get the cluster list.
const PfoList & GetParentPfoList() const
Get the parent pfo list.
const VertexList & GetVertexList() const
Get the vertex list.
int GetParticleId() const
Get the particle flow object id (PDG code)
StatusCodeException class.
StatusCode GetStatusCode() const
Get status code.
VertexType GetVertexType() const
Get the vertex type.
const CartesianVector & GetPosition() const
Get the vertex position.
std::vector< LArTrackTrajectoryPoint > LArTrackTrajectory
std::vector< LArTrackState > LArTrackStateVector
VertexLabel
Vertex label enum.
HitType
Calorimeter hit type enum.
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< int > IntVector
std::vector< CartesianVector > CartesianPointVector
MANAGED_CONTAINER< const CaloHit * > CaloHitList
MANAGED_CONTAINER< const Vertex * > VertexList
std::map< std::string, float > PropertiesMap
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList