27 m_minVertexLongitudinalDistance(-2.5f),
28 m_maxVertexTransverseDistance(1.5f),
29 m_minVertexAssociatedHitTypes(2),
30 m_coneAngleCentile(0.8f),
31 m_maxConeCosHalfAngle(0.95f),
32 m_maxConeLengthMultiplier(3.f),
33 m_directionTanAngle(1.732f),
34 m_directionApexShift(0.333f),
35 m_meanBoundedFractionCut(0.6f),
36 m_maxBoundedFractionCut(0.7f),
37 m_minBoundedFractionCut(0.3f),
38 m_minConsistentDirections(2),
39 m_minConsistentDirectionsTrack(3)
50 const Vertex *
const pSelectedVertex(
51 (pVertexList && (pVertexList->size() == 1) && (
VERTEX_3D == (*(pVertexList->begin()))->GetVertexType())) ? *(pVertexList->begin()) :
nullptr);
56 std::cout <<
"VertexBasedPfoMopUp: unable to find vertex in current list " << std::endl;
58 return STATUS_CODE_SUCCESS;
63 PfoList vertexPfos, nonVertexPfos;
64 this->
GetInputPfos(pSelectedVertex, vertexPfos, nonVertexPfos);
67 this->
GetPfoAssociations(pSelectedVertex, vertexPfos, nonVertexPfos, pfoAssociationList);
69 std::sort(pfoAssociationList.begin(), pfoAssociationList.end());
76 return STATUS_CODE_SUCCESS;
107 for (
const std::string &listName : listNames)
109 const PfoList *pPfoList(
nullptr);
114 for (
const Pfo *
const pPfo : *pPfoList)
117 pfoTargetList.push_back(pPfo);
145 hitTypeSet.insert(hitType);
152 const unsigned int nVertexAssociatedHitTypes(hitTypeSet.size());
161 for (
const Pfo *
const pVertexPfo : vertexPfos)
163 for (
const Pfo *
const pDaughterPfo : nonVertexPfos)
168 pfoAssociationList.push_back(pfoAssociation);
180 const Vertex *
const pVertex,
const Pfo *
const pVertexPfo,
const Pfo *
const pDaughterPfo)
const
195 if (vertexHitType != daughterHitType)
199 hitTypeToAssociationMap[vertexHitType] = clusterAssociation;
203 return this->
GetPfoAssociation(pVertexPfo, pDaughterPfo, hitTypeToAssociationMap);
209 const Vertex *
const pVertex,
const Cluster *
const pVertexCluster,
const Cluster *
const pDaughterCluster)
const
221 const bool isConsistentDirection(vertexClusterDirection == daughterClusterDirection);
223 return ClusterAssociation(pVertexCluster, pDaughterCluster, boundedFraction, isConsistentDirection);
230 const PfoList *pTrackPfoList(
nullptr);
244 if ((pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pfoAssociation.GetVertexPfo())) &&
245 (pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pfoAssociation.GetDaughterPfo())))
250 if (((pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pfoAssociation.GetVertexPfo())) ||
251 (pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pfoAssociation.GetDaughterPfo()))) &&
269 const PfoList *pTrackPfoList(
nullptr), *pShowerPfoList(
nullptr);
273 if (!pTrackPfoList && !pShowerPfoList)
277 const bool isvertexTrack(pTrackPfoList && (pTrackPfoList->end() != std::find(pTrackPfoList->begin(), pTrackPfoList->end(), pVertexPfo)));
279 const bool isDaughterShower(pShowerPfoList && (pShowerPfoList->end() != std::find(pShowerPfoList->begin(), pShowerPfoList->end(), pDaughterPfo)));
283 if (isvertexTrack && isDaughterShower)
285 const PfoList vertexPfoList(1, pVertexPfo);
287 PandoraContentApi::ParticleFlowObject::Metadata metadata;
288 metadata.m_particleId = E_MINUS;
299 m_pVertexCluster(nullptr),
300 m_pDaughterCluster(nullptr),
301 m_boundedFraction(0.f),
302 m_isConsistentDirection(false)
309 const Cluster *
const pDaughterCluster,
const float boundedFraction,
const bool isConsistentDirection) :
310 m_pVertexCluster(pVertexCluster),
311 m_pDaughterCluster(pDaughterCluster),
312 m_boundedFraction(boundedFraction),
313 m_isConsistentDirection(isConsistentDirection)
322 m_pVertexPfo(pVertexPfo),
323 m_pDaughterPfo(pDaughterPfo),
324 m_clusterAssociationU(clusterAssociationU),
325 m_clusterAssociationV(clusterAssociationV),
326 m_clusterAssociationW(clusterAssociationW)
334 return ((this->GetClusterAssociationU().GetBoundedFraction() + this->GetClusterAssociationV().GetBoundedFraction() +
335 this->GetClusterAssociationW().GetBoundedFraction()) /
343 return std::max(this->GetClusterAssociationU().GetBoundedFraction(),
344 std::max(this->GetClusterAssociationV().GetBoundedFraction(), this->GetClusterAssociationW().GetBoundedFraction()));
351 return std::min(this->GetClusterAssociationU().GetBoundedFraction(),
352 std::min(this->GetClusterAssociationV().GetBoundedFraction(), this->GetClusterAssociationW().GetBoundedFraction()));
359 unsigned int nConsistentDirections(0);
361 if (this->GetClusterAssociationU().IsConsistentDirection())
362 ++nConsistentDirections;
364 if (this->GetClusterAssociationV().IsConsistentDirection())
365 ++nConsistentDirections;
367 if (this->GetClusterAssociationW().IsConsistentDirection())
368 ++nConsistentDirections;
370 return nConsistentDirections;
377 if (std::fabs(this->GetMeanBoundedFraction() - rhs.
GetMeanBoundedFraction()) > std::numeric_limits<float>::epsilon())
390 const Cluster *
const pCluster,
const CartesianVector &vertexPosition2D,
const float coneAngleCentile,
const float maxCosHalfAngle) :
391 m_pCluster(pCluster),
392 m_apex(vertexPosition2D),
393 m_direction(0.f, 0.f, 0.f),
395 m_coneCosHalfAngle(0.f)
401 if (
m_coneLength < std::numeric_limits<float>::epsilon())
414 unsigned int nMatchedHits(0);
419 for (CaloHitList::const_iterator hIter = iter->second->begin(), hIterEnd = iter->second->end(); hIter != hIterEnd; ++hIter)
423 if (m_direction.GetCosOpeningAngle(positionVector - m_apex) < m_coneCosHalfAngle)
426 if (m_direction.GetDotProduct(positionVector - m_apex) > coneLengthMultiplier * m_coneLength)
436 return (
static_cast<float>(nMatchedHits) /
static_cast<float>(pDaughterCluster->
GetNCaloHits()));
444 float sumDxDz(0.f), sumDxDx(0.f);
448 for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
450 const CartesianVector apexDisplacement((*hitIter)->GetPositionVector() - m_apex);
451 sumDxDz += apexDisplacement.
GetX() * apexDisplacement.
GetZ();
452 sumDxDx += apexDisplacement.
GetX() * apexDisplacement.
GetX();
456 if (sumDxDx < std::numeric_limits<float>::epsilon())
466 float maxProjectedLength(0.f);
471 for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
473 const float projectedLength(m_direction.GetDotProduct((*hitIter)->GetPositionVector() - m_apex));
475 if (std::fabs(projectedLength) > std::fabs(maxProjectedLength))
476 maxProjectedLength = projectedLength;
480 return maxProjectedLength;
492 for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
493 halfAngleValues.push_back(m_direction.GetOpeningAngle((*hitIter)->GetPositionVector() - m_apex));
496 std::sort(halfAngleValues.begin(), halfAngleValues.end());
498 if (halfAngleValues.empty())
501 const unsigned int halfAngleBin(coneAngleCentile * halfAngleValues.size());
502 return std::cos(halfAngleValues.at(halfAngleBin));
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the pfo helper class.
Header file for the lar pointing cluster class.
Header file for the vertex helper class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Header file for the vertex based pfo mop up algorithm class.
static pandora::StatusCode SaveList(const pandora::Algorithm &algorithm, const T &t, const std::string &newListName)
Save a provided input object list under a new name.
static pandora::StatusCode GetCurrentList(const pandora::Algorithm &algorithm, const T *&pT)
Get the current list.
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
static bool IsNode(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex, const float minLongitudinalDistance, const float maxTransverseDistance)
Whether pointing vertex is adjacent to a given position.
LArPointingCluster class.
const Vertex & GetInnerVertex() const
Get the inner vertex.
const Vertex & GetOuterVertex() const
Get the outer vertex.
static ClusterDirection GetClusterDirectionInZ(const pandora::Pandora &pandora, const pandora::Vertex *const pVertex, const pandora::Cluster *const pCluster, const float tanAngle, const float apexShift)
Get the direction of the cluster in z, using a projection of the provided vertex.
pandora::StringVector m_daughterListNames
The list of potential daughter object list names.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
virtual void MergeAndDeletePfos(const pandora::ParticleFlowObject *const pPfoToEnlarge, const pandora::ParticleFlowObject *const pPfoToDelete) const
Merge and delete a pair of pfos, with a specific set of conventions for cluster merging,...
ClusterAssociation class.
ClusterAssociation()
Default constructor.
float GetBoundedFraction(const pandora::Cluster *const pDaughterCluster, const float coneLengthMultiplier) const
Get the fraction of hits in a candidate daughter cluster bounded by the cone.
ConeParameters(const pandora::Cluster *const pCluster, const pandora::CartesianVector &vertexPosition2D, const float coneAngleCentile, const float maxConeCosHalfAngle)
Constructor.
float GetSignedConeLength() const
Get the cone length (signed, by projections of hits onto initial direction estimate)
float GetCosHalfAngleEstimate(const float coneAngleCentile) const
Get the cone cos half angle estimate.
float m_coneLength
The cone length.
pandora::CartesianVector m_direction
The cone direction.
pandora::CartesianVector GetDirectionEstimate() const
Get the cone direction estimate, with apex fixed at the 2d vertex position.
float m_coneCosHalfAngle
The cone cos half angle.
const pandora::Pfo * m_pVertexPfo
The address of the vertex-associated pfo.
const pandora::Pfo * GetVertexPfo() const
Get the address of the vertex-associated pfo.
PfoAssociation(const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo, const ClusterAssociation &clusterAssociationU, const ClusterAssociation &clusterAssociationV, const ClusterAssociation &clusterAssociationW)
Constructor.
unsigned int GetNConsistentDirections() const
Get the number of views for which the vertex and daughter cluster directions are consistent.
const pandora::Pfo * GetDaughterPfo() const
Get the address of the non-vertex-associated candidate daughter pfo.
float GetMeanBoundedFraction() const
Get the mean bounded fraction, averaging over the u, v and w views.
bool operator<(const PfoAssociation &rhs) const
operator<
float GetMinBoundedFraction() const
Get the minimum bounded fraction from the u, v and w views.
const pandora::Pfo * m_pDaughterPfo
The address of the non-vertex-associated candidate daughter pfo.
float GetMaxBoundedFraction() const
Get the maximum bounded fraction from the u, v and w views.
void GetPfoAssociations(const pandora::Vertex *const pVertex, const pandora::PfoList &vertexPfos, const pandora::PfoList &nonVertexPfos, PfoAssociationList &pfoAssociationList) const
Get the list of associations between vertex-associated pfos and non-vertex-associated pfos.
std::map< pandora::HitType, ClusterAssociation > HitTypeToAssociationMap
std::set< pandora::HitType > HitTypeSet
ClusterAssociation GetClusterAssociation(const pandora::Vertex *const pVertex, const pandora::Cluster *const pVertexCluster, const pandora::Cluster *const pDaughterCluster) const
Get cluster association details between a vertex-associated cluster and a non-vertex associated daugh...
float m_maxBoundedFractionCut
Cut on association info (max bounded fraction) for determining pfo merges.
float m_directionApexShift
Direction determination, look for vertex inside triangle with apex shifted along the cluster length.
virtual bool IsVertexAssociated(const pandora::CartesianVector &vertex2D, const LArPointingCluster &pointingCluster) const
Whether a specified pfo is associated with a specified vertex.
virtual PfoAssociation GetPfoAssociation(const pandora::Pfo *const pVertexPfo, const pandora::Pfo *const pDaughterPfo, HitTypeToAssociationMap &hitTypeToAssociationMap) const
Get pfo association details between a vertex-associated pfo and a non-vertex associated daughter cand...
float m_maxConeCosHalfAngle
Maximum value for cosine of cone half angle.
unsigned int m_minVertexAssociatedHitTypes
The min number of vertex associated hit types for a vertex associated pfo.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
unsigned int m_minConsistentDirectionsTrack
The minimum number of consistent cluster directions to allow a merge involving a track pfo.
std::vector< PfoAssociation > PfoAssociationList
void GetInputPfos(const pandora::Vertex *const pVertex, pandora::PfoList &vertexPfos, pandora::PfoList &nonVertexPfos) const
Get the list of input pfos and divide them into vertex-associated and non-vertex-associated lists.
bool ProcessPfoAssociations(const PfoAssociationList &pfoAssociationList) const
Process the list of pfo associations, merging the best-matching pfo.
float m_directionTanAngle
Direction determination, look for vertex inside triangle with apex shifted along the cluster length.
unsigned int m_minConsistentDirections
The minimum number of consistent cluster directions to allow a pfo merge.
float m_maxConeLengthMultiplier
Consider hits as bound if inside cone, with projected distance less than N times cone length.
pandora::StatusCode Run()
Run the algorithm.
float m_coneAngleCentile
Cluster cone angle is defined using specified centile of distribution of hit half angles.
std::string m_showerPfoListName
The input shower pfo list name.
void MergePfos(const PfoAssociation &pfoAssociation) const
Merge the vertex and daughter pfos (deleting daughter pfo, merging clusters, etc.) described in the s...
float m_minBoundedFractionCut
Cut on association info (min bounded fraction) for determining pfo merges.
float m_meanBoundedFractionCut
Cut on association info (mean bounded fraction) for determining pfo merges.
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
std::string m_trackPfoListName
The input track pfo list name.
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
VertexBasedPfoMopUpAlgorithm()
Default constructor.
float GetX() const
Get the cartesian x coordinate.
CartesianVector GetUnitVector() const
Get a unit vector in the direction of the cartesian vector.
float GetZ() const
Get the cartesian z coordinate.
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
const OrderedCaloHitList & GetOrderedCaloHitList() const
Get the ordered calo hit list.
Calo hit lists arranged by pseudo layer.
const_iterator end() const
Returns a const iterator referring to the past-the-end element in the ordered calo hit list.
const_iterator begin() const
Returns a const iterator referring to the first element in the ordered calo hit list.
TheList::const_iterator const_iterator
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const ClusterList & GetClusterList() const
Get the cluster list.
StatusCode AlterMetadata(const object_creation::ParticleFlowObject::Metadata &metadata)
Alter particle flow object metadata parameters.
const Pandora & GetPandora() const
Get the associated pandora instance.
StatusCodeException class.
VertexType GetVertexType() const
Get the vertex type.
const CartesianVector & GetPosition() const
Get the vertex position.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
HitType
Calorimeter hit type enum.
std::vector< std::string > StringVector
std::vector< float > FloatVector
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList