9 #include "Pandora/AlgorithmHeaders.h" 26 EndAssociatedPfosTool::EndAssociatedPfosTool() :
27 m_minNeutrinoVertexDistance(5.
f),
28 m_minVertexLongitudinalDistance(-2.5
f),
29 m_maxVertexLongitudinalDistance(20.
f),
30 m_maxVertexTransverseDistance(3.5
f),
31 m_vertexAngularAllowance(3.
f),
32 m_maxParentEndpointDistance(2.5
f)
40 if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
41 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() << std::endl;
43 bool associationsMade(
true);
45 while (associationsMade)
47 associationsMade =
false;
48 PfoVector assignedPfos, unassignedPfos;
49 pAlgorithm->
SeparatePfos(pfoInfoMap, assignedPfos, unassignedPfos);
51 if (unassignedPfos.empty())
55 PfoSet recentlyAssigned;
57 for (
const ParticleFlowObject *
const pParentPfo : assignedPfos)
59 PfoInfo *
const pParentPfoInfo(pfoInfoMap.at(pParentPfo));
60 const LArPointingCluster parentPointingCluster(*(pParentPfoInfo->GetSlidingFitResult3D()));
63 pParentPfoInfo->IsInnerLayerAssociated() ? parentPointingCluster.GetOuterVertex() : parentPointingCluster.GetInnerVertex());
64 const float neutrinoVertexDistance((parentEndpoint.GetPosition() - pNeutrinoVertex->GetPosition()).GetMagnitude());
69 for (
const ParticleFlowObject *
const pPfo : unassignedPfos)
71 if (recentlyAssigned.count(pPfo))
74 PfoInfo *
const pPfoInfo(pfoInfoMap.at(pPfo));
77 const bool useInner((pointingCluster.GetInnerVertex().GetPosition() - parentEndpoint.GetPosition()).GetMagnitudeSquared() <
78 (pointingCluster.GetOuterVertex().GetPosition() - parentEndpoint.GetPosition()).GetMagnitudeSquared());
80 const LArPointingCluster::Vertex &daughterVertex(useInner ? pointingCluster.GetInnerVertex() : pointingCluster.GetOuterVertex());
88 this->
IsCloseToParentEndpoint(parentEndpoint.GetPosition(), pParentPfoInfo->GetCluster3D(), pPfoInfo->GetCluster3D()))
90 associationsMade =
true;
91 pParentPfoInfo->AddDaughterPfo(pPfoInfo->GetThisPfo());
92 pPfoInfo->SetParentPfo(pParentPfoInfo->GetThisPfo());
93 pPfoInfo->SetInnerLayerAssociation(useInner);
94 recentlyAssigned.insert(pPfoInfo->GetThisPfo());
104 const CartesianVector &parentEndpoint,
const Cluster *
const pParentCluster3D,
const Cluster *
const pDaughterCluster3D)
const 108 CartesianVector parentPosition3D(0.
f, 0.
f, 0.
f), daughterPosition3D(0.
f, 0.
f, 0.
f);
115 catch (
const StatusCodeException &)
126 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
129 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
132 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
135 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
138 PANDORA_RETURN_RESULT_IF_AND_IF(
139 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"VertexAngularAllowance",
m_vertexAngularAllowance));
141 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
144 return STATUS_CODE_SUCCESS;
void Run(const NeutrinoHierarchyAlgorithm *const pAlgorithm, const pandora::Vertex *const pNeutrinoVertex, NeutrinoHierarchyAlgorithm::PfoInfoMap &pfoInfoMap)
Run the algorithm tool.
Header file for the lar pointing cluster class.
NeutrinoHierarchyAlgorithm::PfoInfoMap PfoInfoMap
static bool IsEmission(const pandora::CartesianVector &parentVertex, const LArPointingCluster::Vertex &daughterVertex, const float minLongitudinalDistance, const float maxLongitudinalDistance, const float maxTransverseDistance, const float angularAllowance)
Whether pointing vertex is emitted from a given position.
float m_minNeutrinoVertexDistance
Min distance between candidate parent endpoint and neutrino vertex.
void SeparatePfos(const NeutrinoHierarchyAlgorithm::PfoInfoMap &pfoInfoMap, pandora::PfoVector &assignedPfos, pandora::PfoVector &unassignedPfos) const
Query the pfo info map and separate/extract pfos currently either acting as parents or associated wit...
LArPointingCluster class.
static void GetClosestPositions(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::CartesianVector &position1, pandora::CartesianVector &position2)
Get pair of closest positions for a pair of clusters.
float m_vertexAngularAllowance
Vertex association check: pointing angular allowance in degrees.
NeutrinoHierarchyAlgorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_maxVertexLongitudinalDistance
Vertex association check: max longitudinal distance cut.
Header file for the lar three dimensional sliding fit result class.
float m_maxParentEndpointDistance
Max distance between candidate parent endpoint and candidate daughter.
bool IsCloseToParentEndpoint(const pandora::CartesianVector &parentEndpoint, const pandora::Cluster *const pParentCluster3D, const pandora::Cluster *const pDaughterCluster3D) const
Whether a daughter 3D cluster is in close proximity to the endpoint of a parent 3D cluster...
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
float m_maxVertexTransverseDistance
Vertex association check: max transverse distance cut.
NeutrinoHierarchyAlgorithm::PfoInfo PfoInfo
float m_minVertexLongitudinalDistance
Vertex association check: min longitudinal distance cut.
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.