LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
DLBaseHierarchyTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 #include "Pandora/StatusCodes.h"
11 
14 
17 
18 #include <torch/script.h>
19 #include <torch/torch.h>
20 
21 using namespace pandora;
22 using namespace lar_content;
23 
24 namespace lar_dl_content
25 {
26 
27 DLBaseHierarchyTool::DLBaseHierarchyTool() :
28  m_vertexRegionRadiusSq(25.f),
29  m_pfoListNames({"TrackParticles3D", "ShowerParticles3D"}),
30  m_areBoundariesSet(false)
31 {
32 }
33 
34 //------------------------------------------------------------------------------------------------------------------------------------------
35 
37 {
39  return;
40 
41  m_detectorBoundaries = LArGeometryHelper::GetDetectorBoundaries(this->GetPandora());
42  m_areBoundariesSet = true;
43 }
44 
45 //------------------------------------------------------------------------------------------------------------------------------------------
46 
48  const Algorithm *const pAlgorithm, const ParticleFlowObject *const pPfo, const CartesianVector &pointOfInterest) const
49 {
50  int hitCount(0);
51  int particleCount(0);
52 
53  for (const std::string &pfoListName : m_pfoListNames)
54  {
55  const PfoList *pPfoList(nullptr);
56  if (PandoraContentApi::GetList(*pAlgorithm, pfoListName, pPfoList) != STATUS_CODE_SUCCESS)
57  continue;
58 
59  for (const ParticleFlowObject *const pOtherPfo : *pPfoList)
60  {
61  if (pPfo == pOtherPfo)
62  continue;
63 
64  bool isClose(false);
65 
66  CartesianPointVector otherPfoPositions3D;
67  LArPfoHelper::GetCoordinateVector(pOtherPfo, TPC_3D, otherPfoPositions3D);
68 
69  for (const CartesianVector &otherPfoPosition : otherPfoPositions3D)
70  {
71  const double sepSq((otherPfoPosition - pointOfInterest).GetMagnitudeSquared());
72 
73  if (sepSq < m_vertexRegionRadiusSq)
74  {
75  isClose = true;
76  ++hitCount;
77  }
78  }
79 
80  if (isClose)
81  ++particleCount;
82  }
83  }
84 
85  return std::pair<float, float>({hitCount, particleCount});
86 }
87 
88 //------------------------------------------------------------------------------------------------------------------------------------------
89 
90 void DLBaseHierarchyTool::NormaliseNetworkParam(const float minLimit, const float maxLimit, float &networkParam) const
91 {
92  const float interval(std::fabs(maxLimit - minLimit));
93 
94  if (interval < std::numeric_limits<float>::epsilon())
95  {
96  networkParam = minLimit;
97  return;
98  }
99 
100  if (networkParam < minLimit)
101  networkParam = minLimit;
102 
103  if (networkParam > maxLimit)
104  networkParam = maxLimit;
105 
106  networkParam /= interval;
107 }
108 
109 //------------------------------------------------------------------------------------------------------------------------------------------
110 
111 StatusCode DLBaseHierarchyTool::ReadSettings(const TiXmlHandle xmlHandle)
112 {
113  StatusCode statCode(XmlHelper::ReadValue(xmlHandle, "VertexRegionRadius", m_vertexRegionRadiusSq));
114 
115  if (statCode == STATUS_CODE_SUCCESS)
116  {
118  }
119  else if (statCode != STATUS_CODE_NOT_FOUND)
120  {
121  return statCode;
122  }
123 
124  PANDORA_RETURN_RESULT_IF_AND_IF(
125  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "PfoListNames", m_pfoListNames));
126 
127  return STATUS_CODE_SUCCESS;
128 }
129 
130 //------------------------------------------------------------------------------------------------------------------------------------------
131 
132 } // namespace lar_dl_content
Header file for the pfo helper class.
Header file for the DL base hierarchy tool.
TFile f
Definition: plotHisto.C:6
float m_vertexRegionRadiusSq
the radius (squared) in which to search for particle hits
Header file for the geometry helper class.
std::pair< float, float > GetParticleInfoAboutPfoPosition(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pPfo, const pandora::CartesianVector &pointOfInterest) const
Return the number of 3D hits and the number of corresponding pfos of a given pfo about a point...
void NormaliseNetworkParam(const float minLimit, const float maxLimit, float &networkParam) const
Shift and normalise a network parameter with respect to an input range.
Header file for the lar deep learning helper helper class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::StringVector m_pfoListNames
the input pfo list name vector
bool m_areBoundariesSet
whether the detector boundaries have been set
LArGeometryHelper::DetectorBoundaries m_detectorBoundaries
the detector boundaries
void SetDetectorBoundaries()
Set the detector boundaries.