Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
NeutrinoHierarchyAlgorithm.cc
Go to the documentation of this file.
1
10
14
16
17using namespace pandora;
18
19namespace lar_content
20{
21
22NeutrinoHierarchyAlgorithm::NeutrinoHierarchyAlgorithm() : m_halfWindowLayers(20), m_displayPfoInfoMap(false)
23{
24}
25
26//------------------------------------------------------------------------------------------------------------------------------------------
27
28void NeutrinoHierarchyAlgorithm::SeparatePfos(const PfoInfoMap &pfoInfoMap, PfoVector &assignedPfos, PfoVector &unassignedPfos) const
29{
30 PfoVector sortedPfos;
31 for (const auto &mapEntry : pfoInfoMap)
32 sortedPfos.push_back(mapEntry.first);
33 std::sort(sortedPfos.begin(), sortedPfos.end(), LArPfoHelper::SortByNHits);
34
35 for (const Pfo *const pPfo : sortedPfos)
36 {
37 const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
38
39 if (pPfoInfo->IsNeutrinoVertexAssociated() || pPfoInfo->GetParentPfo())
40 {
41 assignedPfos.push_back(pPfoInfo->GetThisPfo());
42 }
43 else
44 {
45 unassignedPfos.push_back(pPfoInfo->GetThisPfo());
46 }
47 }
48}
49
50//------------------------------------------------------------------------------------------------------------------------------------------
51
53{
54 const ParticleFlowObject *pNeutrinoPfo(nullptr);
55 PfoList candidateDaughterPfoList;
56
57 try
58 {
59 this->GetNeutrinoPfo(pNeutrinoPfo);
60 this->GetCandidateDaughterPfoList(candidateDaughterPfoList);
61 }
62 catch (StatusCodeException &statusCodeException)
63 {
65 std::cout << "NeutrinoHierarchyAlgorithm: required input pfos unavailable." << std::endl;
66
67 if (STATUS_CODE_NOT_FOUND != statusCodeException.GetStatusCode())
68 throw statusCodeException;
69
70 return STATUS_CODE_SUCCESS;
71 }
72
73 PfoInfoMap pfoInfoMap;
74
75 try
76 {
77 if (!pNeutrinoPfo->GetVertexList().empty())
78 {
79 const Vertex *const pNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
80 this->GetInitialPfoInfoMap(candidateDaughterPfoList, pfoInfoMap);
81
82 for (PfoRelationTool *const pPfoRelationTool : m_algorithmToolVector)
83 pPfoRelationTool->Run(this, pNeutrinoVertex, pfoInfoMap);
84 }
85
86 this->ProcessPfoInfoMap(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap);
87 }
88 catch (StatusCodeException &statusCodeException)
89 {
90 std::cout << "NeutrinoHierarchyAlgorithm: unable to process input neutrino pfo, " << statusCodeException.ToString() << std::endl;
91 }
92
94 this->DisplayPfoInfoMap(pNeutrinoPfo, pfoInfoMap);
95
96 for (auto &mapIter : pfoInfoMap)
97 delete mapIter.second;
98
99 return STATUS_CODE_SUCCESS;
100}
101
102//------------------------------------------------------------------------------------------------------------------------------------------
103
105{
106 const PfoList *pPfoList = nullptr;
108 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_neutrinoPfoListName, pPfoList));
109
110 if (!pPfoList || pPfoList->empty())
111 {
113 std::cout << "NeutrinoHierarchyAlgorithm: unable to find pfo list " << m_neutrinoPfoListName << std::endl;
114
115 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
116 }
117
118 // ATTN Enforces that only one pfo, of neutrino-type, be in the specified input list
119 pNeutrinoPfo = ((1 == pPfoList->size()) ? *(pPfoList->begin()) : nullptr);
120
121 if (!pNeutrinoPfo || !LArPfoHelper::IsNeutrino(pNeutrinoPfo))
122 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
123}
124
125//------------------------------------------------------------------------------------------------------------------------------------------
126
128{
129 for (const std::string &daughterPfoListName : m_daughterPfoListNames)
130 {
131 const PfoList *pCandidatePfoList(nullptr);
132
133 if (STATUS_CODE_SUCCESS == PandoraContentApi::GetList(*this, daughterPfoListName, pCandidatePfoList))
134 {
135 candidateDaughterPfoList.insert(candidateDaughterPfoList.end(), pCandidatePfoList->begin(), pCandidatePfoList->end());
136 }
138 {
139 std::cout << "NeutrinoHierarchyAlgorithm: unable to find pfo list " << daughterPfoListName << std::endl;
140 }
141 }
142
143 if (candidateDaughterPfoList.empty())
144 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
145}
146
147//------------------------------------------------------------------------------------------------------------------------------------------
148
150{
151 const float layerPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
152
153 for (const ParticleFlowObject *const pPfo : pfoList)
154 {
155 PfoInfo *pPfoInfo(nullptr);
156
157 try
158 {
159 pPfoInfo = new PfoInfo(pPfo, m_halfWindowLayers, layerPitch);
160 (void)pfoInfoMap.insert(PfoInfoMap::value_type(pPfo, pPfoInfo));
161 }
162 catch (StatusCodeException &)
163 {
165 std::cout << "NeutrinoHierarchyAlgorithm: Unable to calculate pfo information " << std::endl;
166
167 delete pPfoInfo;
168 }
169 }
170}
171
172//------------------------------------------------------------------------------------------------------------------------------------------
173
174void NeutrinoHierarchyAlgorithm::ProcessPfoInfoMap(const ParticleFlowObject *const pNeutrinoPfo, const PfoList &candidateDaughterPfoList,
175 PfoInfoMap &pfoInfoMap, const unsigned int callDepth) const
176{
177 PfoVector candidateDaughterPfoVector(candidateDaughterPfoList.begin(), candidateDaughterPfoList.end());
178 std::sort(candidateDaughterPfoVector.begin(), candidateDaughterPfoVector.end(), LArPfoHelper::SortByNHits);
179
180 // Add neutrino->primary pfo links
181 for (const ParticleFlowObject *const pDaughterPfo : candidateDaughterPfoVector)
182 {
183 PfoInfoMap::const_iterator iter = pfoInfoMap.find(pDaughterPfo);
184
185 if ((pfoInfoMap.end() != iter) && (iter->second->IsNeutrinoVertexAssociated()))
186 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pNeutrinoPfo, pDaughterPfo));
187 }
188
189 // Handle exceptional case where vertex selected far from any other particle passing creation thresholds
190 if ((0 == callDepth) && (0 == pNeutrinoPfo->GetNDaughterPfos()))
191 {
192 this->AdjustVertexAndPfoInfo(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap);
193 return this->ProcessPfoInfoMap(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap, callDepth + 1);
194 }
195
196 // Add primary pfo->daughter pfo links
197 PfoVector sortedPfos;
198 for (const auto &mapEntry : pfoInfoMap)
199 sortedPfos.push_back(mapEntry.first);
200 std::sort(sortedPfos.begin(), sortedPfos.end(), LArPfoHelper::SortByNHits);
201
202 for (const Pfo *const pPfo : sortedPfos)
203 {
204 const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
205
206 PfoVector daughterPfos(pPfoInfo->GetDaughterPfoList().begin(), pPfoInfo->GetDaughterPfoList().end());
207 std::sort(daughterPfos.begin(), daughterPfos.end(), LArPfoHelper::SortByNHits);
208
209 for (const ParticleFlowObject *const pDaughterPfo : daughterPfos)
211 STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pPfoInfo->GetThisPfo(), pDaughterPfo));
212 }
213
214 // Deal with any remaining parent-less pfos
215 for (const ParticleFlowObject *const pRemainingPfo : candidateDaughterPfoVector)
216 {
217 if (!pRemainingPfo->GetParentPfoList().empty())
218 continue;
219
220 // TODO Most appropriate decision - add as daughter of either i) nearest pfo, or ii) the neutrino (current approach)
221 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pNeutrinoPfo, pRemainingPfo));
222 }
223}
224
225//------------------------------------------------------------------------------------------------------------------------------------------
226
228 const ParticleFlowObject *const pNeutrinoPfo, const PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap) const
229{
230 PfoVector candidateDaughterPfoVector(candidateDaughterPfoList.begin(), candidateDaughterPfoList.end());
231 std::sort(candidateDaughterPfoVector.begin(), candidateDaughterPfoVector.end(), LArPfoHelper::SortByNHits);
232
233 // TODO Consider deleting the neutrino pfo if there are no daughter pfo candidates
234 if (candidateDaughterPfoVector.empty())
235 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
236
237 ClusterList daughterClusterList3D;
238 LArPfoHelper::GetThreeDClusterList(candidateDaughterPfoVector.front(), daughterClusterList3D);
239 daughterClusterList3D.sort(LArClusterHelper::SortByNHits);
240
241 // If no 3D hits, must leave vertex where it was
242 if (daughterClusterList3D.empty())
243 return;
244
245 const Vertex *pOldNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
246 const CartesianVector newVertexPosition(LArClusterHelper::GetClosestPosition(pOldNeutrinoVertex->GetPosition(), daughterClusterList3D.front()));
247
248 PandoraContentApi::Vertex::Parameters parameters;
249 parameters.m_position = newVertexPosition;
250 parameters.m_vertexLabel = pOldNeutrinoVertex->GetVertexLabel();
251 parameters.m_vertexType = pOldNeutrinoVertex->GetVertexType();
252 parameters.m_x0 = pOldNeutrinoVertex->GetX0();
253
254 std::string neutrinoVertexListName(m_neutrinoVertexListName);
255 if (neutrinoVertexListName.empty())
256 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentListName<Vertex>(*this, neutrinoVertexListName));
257
258 std::string temporaryVertexListName;
259 const VertexList *pTemporaryVertexList(nullptr);
260 const Vertex *pNewNeutrinoVertex(nullptr);
262 STATUS_CODE_SUCCESS, !=, PandoraContentApi::CreateTemporaryListAndSetCurrent(*this, pTemporaryVertexList, temporaryVertexListName));
263 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*this, parameters, pNewNeutrinoVertex));
264 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SaveList<Vertex>(*this, neutrinoVertexListName));
265
266 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::RemoveFromPfo(*this, pNeutrinoPfo, pOldNeutrinoVertex));
267 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToPfo(*this, pNeutrinoPfo, pNewNeutrinoVertex));
268 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Vertex>(*this, pOldNeutrinoVertex, neutrinoVertexListName));
269
270 for (auto &mapIter : pfoInfoMap)
271 delete mapIter.second;
272
273 pfoInfoMap.clear();
274
275 for (PfoRelationTool *const pPfoRelationTool : m_algorithmToolVector)
276 pPfoRelationTool->Run(this, pNewNeutrinoVertex, pfoInfoMap);
277}
278
279//------------------------------------------------------------------------------------------------------------------------------------------
280
281void NeutrinoHierarchyAlgorithm::DisplayPfoInfoMap(const ParticleFlowObject *const pNeutrinoPfo, const PfoInfoMap &pfoInfoMap) const
282{
283 bool display(false);
284 PANDORA_MONITORING_API(SetEveDisplayParameters(this->GetPandora(), false, DETECTOR_VIEW_XZ, -1.f, -1.f, 1.f));
285 std::cout << "-Neutrino Pfo, nDaughters " << pNeutrinoPfo->GetDaughterPfoList().size() << ", nVertices "
286 << pNeutrinoPfo->GetVertexList().size() << std::endl;
287
288 PfoVector sortedPfos;
289 for (const auto &mapEntry : pfoInfoMap)
290 sortedPfos.push_back(mapEntry.first);
291 std::sort(sortedPfos.begin(), sortedPfos.end(), LArPfoHelper::SortByNHits);
292
293 for (const Pfo *const pPfo : sortedPfos)
294 {
295 const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
296
297 std::cout << "Pfo " << pPfoInfo->GetThisPfo() << ", vtxAssoc " << pPfoInfo->IsNeutrinoVertexAssociated() << ", parent "
298 << pPfoInfo->GetParentPfo() << ", nDaughters " << pPfoInfo->GetDaughterPfoList().size() << " (";
299
300 for (const ParticleFlowObject *const pDaughterPfo : pPfoInfo->GetDaughterPfoList())
301 std::cout << pDaughterPfo << " ";
302 std::cout << ") " << std::endl;
303
304 if (pPfoInfo->IsNeutrinoVertexAssociated())
305 {
306 display = true;
307 const PfoList tempPfoList(1, pPfoInfo->GetThisPfo());
308 PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &tempPfoList, "VertexPfo", RED, true, false));
309 }
310 }
311
312 if (display)
313 {
314 PANDORA_MONITORING_API(VisualizeVertices(this->GetPandora(), &(pNeutrinoPfo->GetVertexList()), "NeutrinoVertex", ORANGE));
315 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
316 display = false;
317 }
318
319 for (const Pfo *const pPfo : sortedPfos)
320 {
321 const PfoInfo *const pPfoInfo(pfoInfoMap.at(pPfo));
322
323 if (!pPfoInfo->GetDaughterPfoList().empty())
324 {
325 display = true;
326 const PfoList tempPfoList(1, pPfoInfo->GetThisPfo());
327 PANDORA_MONITORING_API(VisualizeParticleFlowObjects(this->GetPandora(), &tempPfoList, "ParentPfo", RED, true, false));
329 VisualizeParticleFlowObjects(this->GetPandora(), &(pPfoInfo->GetDaughterPfoList()), "DaughterPfos", BLUE, true, false));
330 PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
331 }
332 }
333}
334
335//------------------------------------------------------------------------------------------------------------------------------------------
336//------------------------------------------------------------------------------------------------------------------------------------------
337
338NeutrinoHierarchyAlgorithm::PfoInfo::PfoInfo(const pandora::ParticleFlowObject *const pPfo, const unsigned int halfWindowLayers, const float layerPitch) :
339 m_pThisPfo(pPfo),
340 m_pCluster3D(nullptr),
341 m_pVertex3D(nullptr),
342 m_pSlidingFitResult3D(nullptr),
343 m_isNeutrinoVertexAssociated(false),
344 m_isInnerLayerAssociated(false),
345 m_pParentPfo(nullptr)
346{
347 ClusterList clusterList3D;
348 LArPfoHelper::GetThreeDClusterList(pPfo, clusterList3D);
349
350 if (1 != clusterList3D.size())
351 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
352
353 m_pCluster3D = *(clusterList3D.begin());
354 m_pSlidingFitResult3D = new ThreeDSlidingFitResult(m_pCluster3D, halfWindowLayers, layerPitch);
355
357 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
358}
359
360//------------------------------------------------------------------------------------------------------------------------------------------
361
363 m_pThisPfo(rhs.m_pThisPfo),
364 m_pCluster3D(rhs.m_pCluster3D),
365 m_pVertex3D(rhs.m_pVertex3D),
366 m_pSlidingFitResult3D(nullptr),
367 m_isNeutrinoVertexAssociated(rhs.m_isNeutrinoVertexAssociated),
368 m_isInnerLayerAssociated(rhs.m_isInnerLayerAssociated),
369 m_pParentPfo(rhs.m_pParentPfo),
370 m_daughterPfoList(rhs.m_daughterPfoList)
371{
372 if (!rhs.m_pSlidingFitResult3D)
373 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
374
377}
378
379//------------------------------------------------------------------------------------------------------------------------------------------
380
382{
383 if (this != &rhs)
384 {
385 if (!rhs.m_pSlidingFitResult3D)
386 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
387
388 m_pThisPfo = rhs.m_pThisPfo;
389 m_pCluster3D = rhs.m_pCluster3D;
390 m_pVertex3D = rhs.m_pVertex3D;
391 m_isNeutrinoVertexAssociated = rhs.m_isNeutrinoVertexAssociated;
392 m_isInnerLayerAssociated = rhs.m_isInnerLayerAssociated;
393 m_pParentPfo = rhs.m_pParentPfo;
394 m_daughterPfoList = rhs.m_daughterPfoList;
395
396 delete m_pSlidingFitResult3D;
397 m_pSlidingFitResult3D = new ThreeDSlidingFitResult(m_pCluster3D, rhs.m_pSlidingFitResult3D->GetFirstFitResult().GetLayerFitHalfWindow(),
399 }
400
401 return *this;
402}
403
404//------------------------------------------------------------------------------------------------------------------------------------------
405
407{
408 delete m_pSlidingFitResult3D;
409}
410
411//------------------------------------------------------------------------------------------------------------------------------------------
412
414{
415 m_isNeutrinoVertexAssociated = isNeutrinoVertexAssociated;
416}
417
418//------------------------------------------------------------------------------------------------------------------------------------------
419
421{
422 m_isInnerLayerAssociated = isInnerLayerAssociated;
423}
424
425//------------------------------------------------------------------------------------------------------------------------------------------
426
428{
429 if (m_pParentPfo)
430 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
431
432 m_pParentPfo = pParentPfo;
433}
434
435//------------------------------------------------------------------------------------------------------------------------------------------
436
438{
439 m_pParentPfo = nullptr;
440}
441
442//------------------------------------------------------------------------------------------------------------------------------------------
443
445{
446 if (m_daughterPfoList.end() != std::find(m_daughterPfoList.begin(), m_daughterPfoList.end(), pDaughterPfo))
447 throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
448
449 m_daughterPfoList.push_back(pDaughterPfo);
450}
451
452//------------------------------------------------------------------------------------------------------------------------------------------
453
455{
456 PfoList::iterator eraseIter = std::find(m_daughterPfoList.begin(), m_daughterPfoList.end(), pDaughterPfo);
457
458 if (m_daughterPfoList.end() == eraseIter)
459 throw StatusCodeException(STATUS_CODE_NOT_FOUND);
460
461 m_daughterPfoList.erase(eraseIter);
462}
463
464//------------------------------------------------------------------------------------------------------------------------------------------
465//------------------------------------------------------------------------------------------------------------------------------------------
466
468{
469 AlgorithmToolVector algorithmToolVector;
470 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "PfoRelationTools", algorithmToolVector));
471
472 for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
473 {
474 PfoRelationTool *const pPfoRelationTool(dynamic_cast<PfoRelationTool *>(*iter));
475
476 if (!pPfoRelationTool)
477 return STATUS_CODE_INVALID_PARAMETER;
478
479 m_algorithmToolVector.push_back(pPfoRelationTool);
480 }
481
482 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoPfoListName", m_neutrinoPfoListName));
483
484 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "DaughterPfoListNames", m_daughterPfoListNames));
485
487 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoVertexListName", m_neutrinoVertexListName));
488
490 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitHalfWindow", m_halfWindowLayers));
491
493 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DisplayPfoInfoMap", m_displayPfoInfoMap));
494
495 return STATUS_CODE_SUCCESS;
496}
497
498} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
#define PANDORA_MONITORING_API(command)
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 neutrino hierarchy algorithm class.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:55
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:43
#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
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode AddToPfo(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pPfo, const T *const pT)
Add a cluster to a particle flow object.
static pandora::StatusCode CreateTemporaryListAndSetCurrent(const pandora::Algorithm &algorithm, const T *&pT, std::string &temporaryListName)
Create a temporary list and set it to be the current list, enabling object creation.
static pandora::StatusCode SetPfoParentDaughterRelationship(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pParentPfo, const pandora::ParticleFlowObject *const pDaughterPfo)
Set parent-daughter particle flow object relationship.
static pandora::StatusCode RemoveFromPfo(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pPfo, const T *const pT)
Remove a cluster from a particle flow object. Note this function will not remove the final object (tr...
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::CartesianVector GetClosestPosition(const pandora::CartesianVector &position, const pandora::ClusterList &clusterList)
Get closest position in a list of clusters to a specified input position vector.
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position,...
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
bool IsNeutrinoVertexAssociated() const
Whether the pfo is associated with the neutrino vertex.
const pandora::ParticleFlowObject * m_pThisPfo
The address of the pfo.
const pandora::Vertex * m_pVertex3D
The address of the three dimensional vertex.
void SetNeutrinoVertexAssociation(const bool isNeutrinoVertexAssociated)
Set the neutrino vertex association flag.
pandora::PfoList m_daughterPfoList
The daughter pfo list.
ThreeDSlidingFitResult * m_pSlidingFitResult3D
The three dimensional sliding fit result.
const pandora::ParticleFlowObject * GetThisPfo() const
Get the address of the pfo.
const pandora::PfoList & GetDaughterPfoList() const
Get the daughter pfo list.
const pandora::ParticleFlowObject * m_pParentPfo
The address of the parent pfo.
const pandora::Cluster * m_pCluster3D
The address of the three dimensional cluster.
void RemoveDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo)
Remove a daughter pfo.
PfoInfo & operator=(const PfoInfo &rhs)
Assignment operator.
bool m_isNeutrinoVertexAssociated
Whether the pfo is associated with the neutrino vertex.
const pandora::ParticleFlowObject * GetParentPfo() const
Get the address of the parent pfo.
void AddDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo)
Add a daughter pfo.
PfoInfo(const pandora::ParticleFlowObject *const pPfo, const unsigned int halfWindowLayers, const float layerPitch)
Constructor.
bool m_isInnerLayerAssociated
If associated, whether association to parent (vtx or pfo) is at sliding fit inner layer.
void SetParentPfo(const pandora::ParticleFlowObject *const pParentPfo)
Set the parent pfo.
void SetInnerLayerAssociation(const bool isInnerLayerAssociated)
Set the inner layer association flag.
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...
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
void GetCandidateDaughterPfoList(pandora::PfoList &candidateDaughterPfoList) const
Get the list of candidate daughter pfos.
void GetInitialPfoInfoMap(const pandora::PfoList &pfoList, PfoInfoMap &pfoInfoMap) const
Process a provided pfo list and populate an initial pfo info map.
std::string m_neutrinoVertexListName
The neutrino vertex list name - if not specified will assume current list.
std::unordered_map< const pandora::ParticleFlowObject *, PfoInfo * > PfoInfoMap
void AdjustVertexAndPfoInfo(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap) const
Adjust neutrino vertex to ensure agreement with at least one pfo (first in sorted input list)
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::string m_neutrinoPfoListName
The neutrino pfo list name.
void ProcessPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap, const unsigned int callDepth=0) const
Process the information in a pfo info map, creating pfo parent/daughter links.
void GetNeutrinoPfo(const pandora::ParticleFlowObject *&pNeutrinoPfo) const
Get the address of the input neutrino pfo - enforces only one pfo present in input list; can return N...
pandora::StringVector m_daughterPfoListNames
The list of daughter pfo list names.
void DisplayPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const PfoInfoMap &pfoInfoMap) const
Display the information in a pfo info map, visualising pfo parent/daughter links.
pandora::StatusCode Run()
Run the algorithm.
bool m_displayPfoInfoMap
Whether to display the pfo info map (if monitoring is enabled)
PfoRelationToolVector m_algorithmToolVector
The algorithm tool vector.
int GetMinLayer() const
Get the minimum occupied layer in the sliding fit.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
const TwoDSlidingFitResult & GetFirstFitResult() const
Get the first sliding fit result for this cluster.
float GetLayerPitch() const
Get the layer pitch, units cm.
unsigned int GetLayerFitHalfWindow() const
Get the layer fit half window.
CartesianVector class.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const PfoList & GetDaughterPfoList() const
Get the daughter pfo list.
const VertexList & GetVertexList() const
Get the vertex list.
unsigned int GetNDaughterPfos() const
Get the number of daughter pfos.
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
StatusCodeException class.
std::string ToString() const
Get status code as a string.
StatusCode GetStatusCode() const
Get status code.
Vertex class.
Definition Vertex.h:26
VertexType GetVertexType() const
Get the vertex type.
Definition Vertex.h:124
const CartesianVector & GetPosition() const
Get the vertex position.
Definition Vertex.h:103
VertexLabel GetVertexLabel() const
Get the vertex label.
Definition Vertex.h:117
float GetX0() const
For LArTPC usage, the x-coordinate shift associated with a drift time t0 shift, units mm.
Definition Vertex.h:110
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
Definition XmlHelper.h:229
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< const ParticleFlowObject * > PfoVector
std::vector< AlgorithmTool * > AlgorithmToolVector
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList