Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
BranchAssociatedPfosTool.cc
Go to the documentation of this file.
1
10
13
16
18
19using namespace pandora;
20
21namespace lar_content
22{
23
26
28 m_minNeutrinoVertexDistance(5.f),
29 m_trackBranchAdditionFraction(0.4f),
30 m_maxParentClusterDistance(3.5f)
31{
32}
33
34//------------------------------------------------------------------------------------------------------------------------------------------
35
36void BranchAssociatedPfosTool::Run(const NeutrinoHierarchyAlgorithm *const pAlgorithm, const Vertex *const pNeutrinoVertex, PfoInfoMap &pfoInfoMap)
37{
39 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
40
41 bool associationsMade(true);
42
43 while (associationsMade)
44 {
45 associationsMade = false;
46 PfoVector assignedPfos, unassignedPfos;
47 pAlgorithm->SeparatePfos(pfoInfoMap, assignedPfos, unassignedPfos);
48
49 if (unassignedPfos.empty())
50 break;
51
52 // ATTN May want to reconsider precise association mechanics for complex situations
53 PfoSet recentlyAssigned;
54
55 for (const ParticleFlowObject *const pParentPfo : assignedPfos)
56 {
57 PfoInfo *const pParentPfoInfo(pfoInfoMap.at(pParentPfo));
58 const Cluster *const pParentCluster3D(pParentPfoInfo->GetCluster3D());
59
60 const bool parentIsTrack(LArPfoHelper::IsTrack(pParentPfo));
61 const ThreeDSlidingFitResult &parentFitResult(*(pParentPfoInfo->GetSlidingFitResult3D()));
62
63 const float parentLength3D((parentFitResult.GetGlobalMinLayerPosition() - parentFitResult.GetGlobalMaxLayerPosition()).GetMagnitude());
64 const CartesianVector &parentVertexPosition(pParentPfoInfo->IsInnerLayerAssociated() ? parentFitResult.GetGlobalMinLayerPosition()
65 : parentFitResult.GetGlobalMaxLayerPosition());
66
67 for (const ParticleFlowObject *const pPfo : unassignedPfos)
68 {
69 if (recentlyAssigned.count(pPfo))
70 continue;
71
72 PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
73 const LArPointingCluster pointingCluster(*(pPfoInfo->GetSlidingFitResult3D()));
74
75 const float dNeutrinoVertex(std::min((pointingCluster.GetInnerVertex().GetPosition() - pNeutrinoVertex->GetPosition()).GetMagnitude(),
76 (pointingCluster.GetOuterVertex().GetPosition() - pNeutrinoVertex->GetPosition()).GetMagnitude()));
77
78 if (dNeutrinoVertex < m_minNeutrinoVertexDistance)
79 continue;
80
81 const float dParentVertex(std::min((pointingCluster.GetInnerVertex().GetPosition() - parentVertexPosition).GetMagnitude(),
82 (pointingCluster.GetOuterVertex().GetPosition() - parentVertexPosition).GetMagnitude()));
83
84 if (parentIsTrack && (dParentVertex < m_trackBranchAdditionFraction * parentLength3D))
85 continue;
86
87 const float dInnerVertex(LArClusterHelper::GetClosestDistance(pointingCluster.GetInnerVertex().GetPosition(), pParentCluster3D));
88 const float dOuterVertex(LArClusterHelper::GetClosestDistance(pointingCluster.GetOuterVertex().GetPosition(), pParentCluster3D));
89
90 if ((dInnerVertex < m_maxParentClusterDistance) || (dOuterVertex < m_maxParentClusterDistance))
91 {
92 associationsMade = true;
93 pParentPfoInfo->AddDaughterPfo(pPfoInfo->GetThisPfo());
94 pPfoInfo->SetParentPfo(pParentPfoInfo->GetThisPfo());
95 pPfoInfo->SetInnerLayerAssociation(dInnerVertex < dOuterVertex);
96 recentlyAssigned.insert(pPfoInfo->GetThisPfo());
97 }
98 }
99 }
100 }
101}
102
103//------------------------------------------------------------------------------------------------------------------------------------------
104
106{
107 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
108 XmlHelper::ReadValue(xmlHandle, "MinNeutrinoVertexDistance", m_minNeutrinoVertexDistance));
109
110 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
111 XmlHelper::ReadValue(xmlHandle, "TrackBranchAdditionFraction", m_trackBranchAdditionFraction));
112
113 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
114 XmlHelper::ReadValue(xmlHandle, "MaxParentClusterDistance", m_maxParentClusterDistance));
115
116 return STATUS_CODE_SUCCESS;
117}
118
119} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the branch associated pfos tool class.
Header file for the cluster helper class.
Header file for the pfo helper class.
Header file for the lar pointing cluster class.
Header file for the lar three dimensional sliding fit result class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
void Run(const NeutrinoHierarchyAlgorithm *const pAlgorithm, const pandora::Vertex *const pNeutrinoVertex, NeutrinoHierarchyAlgorithm::PfoInfoMap &pfoInfoMap)
Run the algorithm tool.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
float m_trackBranchAdditionFraction
Branch association: min fraction of length along parent track before association allowed.
float m_maxParentClusterDistance
Branch association: max distance from branch vertex to a hit in parent 3D cluster.
float m_minNeutrinoVertexDistance
Branch association: min distance from branch vertex to neutrino vertex.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
const pandora::CartesianVector & GetPosition() const
Get the vertex position.
LArPointingCluster class.
const Vertex & GetInnerVertex() const
Get the inner vertex.
const Vertex & GetOuterVertex() const
Get the outer vertex.
const pandora::ParticleFlowObject * GetThisPfo() const
Get the address of the pfo.
bool IsInnerLayerAssociated() const
If associated, whether association to parent (vtx or pfo) is at sliding fit inner layer.
const pandora::Cluster * GetCluster3D() const
Get the address of the three dimensional cluster.
void AddDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo)
Add a daughter pfo.
void SetParentPfo(const pandora::ParticleFlowObject *const pParentPfo)
Set the parent pfo.
void SetInnerLayerAssociation(const bool isInnerLayerAssociated)
Set the inner layer association flag.
const ThreeDSlidingFitResult * GetSlidingFitResult3D() const
Get the address of the three dimensional sliding fit result.
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...
std::unordered_map< const pandora::ParticleFlowObject *, PfoInfo * > PfoInfoMap
const pandora::CartesianVector & GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
const pandora::CartesianVector & GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
CartesianVector class.
Cluster class.
Definition Cluster.h:31
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const std::string & GetType() const
Get the type.
Definition Process.h:102
const std::string & GetInstanceName() const
Get the instance name.
Definition Process.h:109
Vertex class.
Definition Vertex.h:26
const CartesianVector & GetPosition() const
Get the vertex position.
Definition Vertex.h:103
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
NeutrinoHierarchyAlgorithm::PfoInfo PfoInfo
NeutrinoHierarchyAlgorithm::PfoInfoMap PfoInfoMap
std::unordered_set< const ParticleFlowObject * > PfoSet
std::vector< const ParticleFlowObject * > PfoVector
StatusCode
The StatusCode enum.