Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ThreeViewDeltaRayMatchingAlgorithm.cc
Go to the documentation of this file.
1
10
12
13using namespace pandora;
14
15namespace lar_content
16{
17
18ThreeViewDeltaRayMatchingAlgorithm::ThreeViewDeltaRayMatchingAlgorithm() : m_minClusterCaloHits(5), m_nMaxTensorToolRepeats(10)
19{
20}
21
22//------------------------------------------------------------------------------------------------------------------------------------------
23
25{
26 return (pCluster->GetNCaloHits() >= m_minClusterCaloHits);
27}
28
29//------------------------------------------------------------------------------------------------------------------------------------------
30
31void ThreeViewDeltaRayMatchingAlgorithm::CalculateOverlapResult(const Cluster *const pClusterU, const Cluster *const pClusterV, const Cluster *const pClusterW)
32{
33 DeltaRayOverlapResult overlapResult;
35 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, this->CalculateOverlapResult(pClusterU, pClusterV, pClusterW, overlapResult));
36
37 if (overlapResult.IsInitialized())
38 this->GetMatchingControl().GetOverlapTensor().SetOverlapResult(pClusterU, pClusterV, pClusterW, overlapResult);
39}
40
41//------------------------------------------------------------------------------------------------------------------------------------------
42
44 const Cluster *const pClusterW, DeltaRayOverlapResult &overlapResult) const
45{
46 float chiSquaredSum(0.f);
47 unsigned int nSamplingPoints(0), nMatchedSamplingPoints(0);
48 XOverlap xOverlapObject(0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f);
49
50 StatusCode statusCode(
51 this->PerformThreeViewMatching(pClusterU, pClusterV, pClusterW, chiSquaredSum, nSamplingPoints, nMatchedSamplingPoints, xOverlapObject));
52
53 if (statusCode != STATUS_CODE_SUCCESS)
54 return statusCode;
55
56 PfoList commonMuonPfoList;
57 this->FindCommonMuonParents(pClusterU, pClusterV, pClusterW, commonMuonPfoList);
58
59 if (commonMuonPfoList.empty())
60 return STATUS_CODE_NOT_FOUND;
61
62 overlapResult = DeltaRayOverlapResult(nMatchedSamplingPoints, nSamplingPoints, chiSquaredSum, xOverlapObject, commonMuonPfoList);
63
64 return STATUS_CODE_SUCCESS;
65}
66
67//------------------------------------------------------------------------------------------------------------------------------------------
68
70 const Cluster *const pClusterU, const Cluster *const pClusterV, const Cluster *const pClusterW, PfoList &commonMuonPfoList) const
71{
72 ClusterList consideredClustersU, consideredClustersV, consideredClustersW;
73 PfoList nearbyMuonPfosU, nearbyMuonPfosV, nearbyMuonPfosW;
74
75 this->GetNearbyMuonPfos(pClusterU, consideredClustersU, nearbyMuonPfosU);
76
77 if (nearbyMuonPfosU.empty())
78 return;
79
80 this->GetNearbyMuonPfos(pClusterV, consideredClustersV, nearbyMuonPfosV);
81
82 if (nearbyMuonPfosV.empty())
83 return;
84
85 this->GetNearbyMuonPfos(pClusterW, consideredClustersW, nearbyMuonPfosW);
86
87 if (nearbyMuonPfosW.empty())
88 return;
89
90 for (const ParticleFlowObject *const pNearbyMuonU : nearbyMuonPfosU)
91 {
92 for (const ParticleFlowObject *const pNearbyMuonV : nearbyMuonPfosV)
93 {
94 if (pNearbyMuonV != pNearbyMuonU)
95 continue;
96
97 for (const ParticleFlowObject *const pNearbyMuonW : nearbyMuonPfosW)
98 {
99 if (pNearbyMuonW == pNearbyMuonV)
100 commonMuonPfoList.emplace_back(pNearbyMuonU);
101 }
102 }
103 }
104}
105
106//------------------------------------------------------------------------------------------------------------------------------------------
107
109{
110 // Apply tools sequentially restarting if a change is made and ending if the tools finish or the restart limit is reached
111 unsigned int repeatCounter(0);
112
113 for (auto toolIter = m_algorithmToolVector.begin(); toolIter != m_algorithmToolVector.end();)
114 {
115 DeltaRayTensorTool *const pTool(*toolIter);
116 const bool repeatTools(pTool->Run(this, this->GetMatchingControl().GetOverlapTensor()));
117
118 toolIter = repeatTools ? m_algorithmToolVector.begin() : toolIter + 1;
119 repeatCounter = repeatTools ? repeatCounter + 1 : repeatCounter;
120
121 if (repeatCounter > m_nMaxTensorToolRepeats)
122 break;
123 }
124}
125
126//------------------------------------------------------------------------------------------------------------------------------------------
127
129{
130 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MuonPfoListName", m_muonPfoListName));
131
132 AlgorithmToolVector algorithmToolVector;
133 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "DeltaRayTools", algorithmToolVector));
134
135 for (auto algorithmTool : algorithmToolVector)
136 {
137 DeltaRayTensorTool *const pDeltaRayTensorTool(dynamic_cast<DeltaRayTensorTool *>(algorithmTool));
138
139 if (!pDeltaRayTensorTool)
140 return STATUS_CODE_INVALID_PARAMETER;
141
142 m_algorithmToolVector.push_back(pDeltaRayTensorTool);
143 }
144
145 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithm(*this, xmlHandle, "ClusterRebuilding", m_reclusteringAlgorithmName));
146
148 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterCaloHits", m_minClusterCaloHits));
149
151 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NMaxTensorToolRepeats", m_nMaxTensorToolRepeats));
152
153 return BaseAlgorithm::ReadSettings(xmlHandle);
154}
155
156} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:55
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
virtual bool Run(ThreeViewDeltaRayMatchingAlgorithm *const pAlgorithm, TensorType &overlapTensor)=0
Run the algorithm tool.
void GetNearbyMuonPfos(const pandora::Cluster *const pCluster, pandora::ClusterList &consideredClusters, pandora::PfoList &nearbyMuonPfos) const
Use the cluster proximity map to travel along paths of nearby clusters finding the cosmic ray cluster...
pandora::StatusCode PerformThreeViewMatching(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3, float &reducedChiSquared) const
To determine how well three clusters (one in each view) map onto one another expressing this in terms...
MatchingType & GetMatchingControl()
Get the matching control.
unsigned int m_minClusterCaloHits
The threshold number of hits for a cluster to be considered.
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
std::string m_reclusteringAlgorithmName
The name of the clustering algorithm to be used to recluster created delta ray remnants.
TensorToolVector m_algorithmToolVector
The algorithm tool vector.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in container.
void FindCommonMuonParents(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, pandora::PfoList &commonMuonPfoList) const
Find the cosmic ray pfos that, in each view, lie close to the clusters of the tensor element.
virtual bool DoesClusterPassTensorThreshold(const pandora::Cluster *const pCluster) const
To check whether a given cluster meets the requirements to be added into the matching container (tens...
void ExamineOverlapContainer()
Examine contents of overlap container, collect together best-matching 2D particles and modify cluster...
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
bool IsInitialized() const
Whether the track overlap result has been initialized.
XOverlap class.
Definition LArXOverlap.h:18
Cluster class.
Definition Cluster.h:31
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
Definition Cluster.h:484
ParticleFlowObject class.
static StatusCode ProcessAlgorithm(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &description, std::string &algorithmName)
Process an algorithm described in an xml element with a matching "description = .....
Definition XmlHelper.cc:16
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
static StatusCode ProcessAlgorithmToolList(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &listName, AlgorithmToolVector &algorithmToolVector)
Process a list of algorithms tools in an xml file.
Definition XmlHelper.cc:101
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< AlgorithmTool * > AlgorithmToolVector
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList