LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
DLPrimaryHierarchyTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 #include "Pandora/StatusCodes.h"
11 
14 
17 
19 
20 #include <torch/script.h>
21 #include <torch/torch.h>
22 
23 using namespace pandora;
24 using namespace lar_content;
25 
26 namespace lar_dl_content
27 {
28 
29 //------------------------------------------------------------------------------------------------------------------------------------------
30 
31 void DLPrimaryHierarchyTool::DLPrimaryNetworkParams::AddCommonParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const
32 {
33  modelInput[0][insertIndex] = m_nSpacepoints;
34  ++insertIndex;
35 }
36 
37 //------------------------------------------------------------------------------------------------------------------------------------------
38 
39 void DLPrimaryHierarchyTool::DLPrimaryNetworkParams::AddOrientationParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const
40 {
41  for (const float param : {m_nuSeparation, m_vertexRegionNHits, m_vertexRegionNParticles, m_dca, m_connectionExtrapDistance,
42  m_isPOIClosestToNu, m_parentConnectionDistance, m_childConnectionDistance})
43  {
44  modelInput[0][insertIndex] = param;
45  ++insertIndex;
46  }
47 }
48 
49 //------------------------------------------------------------------------------------------------------------------------------------------
50 //------------------------------------------------------------------------------------------------------------------------------------------
51 
52 DLPrimaryHierarchyTool::DLPrimaryHierarchyTool() :
54  m_trainingMode(false),
55  m_extrapolationStepSize(1.f),
56  m_normalise(true)
57 {
58 }
59 
60 //------------------------------------------------------------------------------------------------------------------------------------------
61 
62 StatusCode DLPrimaryHierarchyTool::Run(const Algorithm *const pAlgorithm, const ParticleFlowObject *const pNeutrinoPfo,
63  const HierarchyPfoVector &trackPfos, const HierarchyPfo &hierarchyPfo, std::vector<DLPrimaryNetworkParams> &networkParamVector, float &primaryScore)
64 {
65  networkParamVector.clear();
66  primaryScore = std::numeric_limits<float>::lowest();
67 
68  this->SetDetectorBoundaries();
69 
70  const bool isTrack(hierarchyPfo.GetPfo()->GetParticleId() == 13);
71  std::vector<bool> orientationVector(isTrack ? std::vector<bool>({true, false}) : std::vector<bool>({true}));
72 
73  for (const bool useUpstream : orientationVector)
74  {
75  // Set network params
76  DLPrimaryNetworkParams primaryNetworkParams;
77 
78  const StatusCode statusCode(this->CalculateNetworkVariables(pAlgorithm, hierarchyPfo, pNeutrinoPfo, trackPfos, useUpstream, primaryNetworkParams));
79 
80  if (statusCode != STATUS_CODE_SUCCESS)
81  return statusCode;
82 
83  networkParamVector.emplace_back(primaryNetworkParams);
84  }
85 
86  // Now run the model!
87  if (!m_trainingMode)
88  {
89  if (isTrack)
90  primaryScore = this->ClassifyTrack(networkParamVector.at(0), networkParamVector.at(1));
91  else
92  primaryScore = this->ClassifyShower(networkParamVector.at(0));
93  }
94 
95  return STATUS_CODE_SUCCESS;
96 }
97 
98 //------------------------------------------------------------------------------------------------------------------------------------------
99 
100 StatusCode DLPrimaryHierarchyTool::CalculateNetworkVariables(const Algorithm *const pAlgorithm, const HierarchyPfo &hierarchyPfo,
101  const ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const bool useUpstream,
102  DLPrimaryNetworkParams &primaryNetworkParams) const
103 {
104  // Pick out neutrino vertex
105  if (pNeutrinoPfo->GetVertexList().empty())
106  return STATUS_CODE_NOT_INITIALIZED;
107 
108  const Vertex *const pNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
109  const CartesianVector nuVertex(
110  pNeutrinoVertex->GetPosition().GetX(), pNeutrinoVertex->GetPosition().GetY(), pNeutrinoVertex->GetPosition().GetZ());
111 
112  // Pick out the correct extremal point
113  const ExtremalPoint &particlePoint(useUpstream ? hierarchyPfo.GetUpstreamPoint() : hierarchyPfo.GetDownstreamPoint());
114 
115  // Check that we could actually calculate pfo vertex/direction, return if not
116  if (!particlePoint.IsSet())
117  {
118  return STATUS_CODE_NOT_INITIALIZED;
119  }
120 
121  // Set primaryNetworkParams
122  primaryNetworkParams.m_isPOIClosestToNu = useUpstream ? 1.f : 0.f;
123  primaryNetworkParams.m_nSpacepoints = LArPfoHelper::GetNumberOfThreeDHits(hierarchyPfo.GetPfo());
124  primaryNetworkParams.m_nuSeparation = (particlePoint.GetPosition() - nuVertex).GetMagnitude();
125  this->SetVertexRegionParams(pAlgorithm, hierarchyPfo.GetPfo(), particlePoint.GetPosition(), primaryNetworkParams);
126  this->SetConnectionParams(particlePoint, nuVertex, primaryNetworkParams);
127  this->SetContextParams(hierarchyPfo.GetPfo(), particlePoint, nuVertex, trackPfos, primaryNetworkParams);
128 
129  // Normalise
130  if (m_normalise)
131  this->NormaliseNetworkParams(primaryNetworkParams);
132 
133  return STATUS_CODE_SUCCESS;
134 }
135 
136 //------------------------------------------------------------------------------------------------------------------------------------------
137 
138 void DLPrimaryHierarchyTool::SetVertexRegionParams(const Algorithm *const pAlgorithm, const ParticleFlowObject *const pPfo,
139  const CartesianVector &particleVertex, DLPrimaryNetworkParams &primaryNetworkParams) const
140 {
141  std::pair<float, float> vertexRegionParams(this->GetParticleInfoAboutPfoPosition(pAlgorithm, pPfo, particleVertex));
142 
143  primaryNetworkParams.m_vertexRegionNHits = vertexRegionParams.first;
144  primaryNetworkParams.m_vertexRegionNParticles = vertexRegionParams.second;
145 }
146 
147 //------------------------------------------------------------------------------------------------------------------------------------------
148 
150  const ExtremalPoint &particlePoint, const CartesianVector &nuVertex, DLPrimaryNetworkParams &primaryNetworkParams) const
151 {
152  // Extrapolate particle to nuVertex
153  const float extrapDistance((nuVertex - particlePoint.GetPosition()).GetDotProduct(particlePoint.GetDirection()));
154  const CartesianVector extrapolationPoint(particlePoint.GetPosition() + (particlePoint.GetDirection() * extrapDistance));
155 
156  primaryNetworkParams.m_dca = (nuVertex - extrapolationPoint).GetMagnitude();
157  primaryNetworkParams.m_connectionExtrapDistance = (extrapDistance * (-1.f)); // backwards extrap. should be +ve
158 }
159 
160 //------------------------------------------------------------------------------------------------------------------------------------------
161 
162 void DLPrimaryHierarchyTool::SetContextParams(const ParticleFlowObject *const pPfo, const ExtremalPoint &particlePoint,
163  const CartesianVector &nuVertex, const HierarchyPfoVector &trackPfos, DLPrimaryNetworkParams &primaryNetworkParams) const
164 {
165  // What is our nuVertex separation
166  const float nuVertexSepSq((particlePoint.GetPosition() - nuVertex).GetMagnitudeSquared());
167 
168  bool found(false);
169  float parentConnectionDistance(std::numeric_limits<float>::max());
170  float childConnectionDistance(std::numeric_limits<float>::max());
171 
172  // Look at potential parents
173  for (const HierarchyPfo &hierarchyTrackPfo : trackPfos)
174  {
175  if (hierarchyTrackPfo == pPfo)
176  continue;
177 
178  // Upstream position should be closer to nu vertex
179  const float thisNuVertexSepSq((hierarchyTrackPfo.GetDownstreamPoint().GetPosition() - nuVertex).GetMagnitudeSquared());
180 
181  if (thisNuVertexSepSq > nuVertexSepSq)
182  continue;
183 
184  float thisParentConnectionDistance(std::numeric_limits<float>::lowest());
185  float thisChildConnectionDistance(std::numeric_limits<float>::lowest());
186 
187  this->CalculateConnectionDistances(hierarchyTrackPfo.GetDownstreamPoint(), particlePoint, thisParentConnectionDistance, thisChildConnectionDistance);
188 
189  if ((thisChildConnectionDistance > 0.f) && (std::fabs(thisParentConnectionDistance) < std::fabs(parentConnectionDistance)))
190  {
191  found = true;
192  parentConnectionDistance = thisParentConnectionDistance;
193  childConnectionDistance = thisChildConnectionDistance;
194  }
195  }
196 
197  if (found)
198  {
199  primaryNetworkParams.m_parentConnectionDistance = parentConnectionDistance;
200  primaryNetworkParams.m_childConnectionDistance = childConnectionDistance;
201  }
202 }
203 
204 //------------------------------------------------------------------------------------------------------------------------------------------
205 
207  const ExtremalPoint &parentPoint, const ExtremalPoint &childPoint, float &parentConnectionDistance, float &childConnectionDistance) const
208 {
209  // Loop things
210  float smallestT(std::numeric_limits<float>::max());
211  bool isGettingCloser(true);
212  bool found(false);
213  CartesianVector connectionPoint(std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest(), std::numeric_limits<float>::lowest());
214 
215  // start the seed
216  CartesianVector extrapolatedPoint(childPoint.GetPosition());
217 
218  while (isGettingCloser)
219  {
220  isGettingCloser = false;
221  extrapolatedPoint = extrapolatedPoint + (childPoint.GetDirection() * ((-1.f) * m_extrapolationStepSize));
222 
223  if (!LArGeometryHelper::IsInDetector(m_detectorBoundaries, extrapolatedPoint))
224  break;
225 
226  const float parentT(
227  (parentPoint.GetDirection() * (-1.f)).GetCrossProduct((extrapolatedPoint - parentPoint.GetPosition())).GetMagnitudeSquared());
228 
229  if (parentT < smallestT)
230  {
231  smallestT = parentT;
232  connectionPoint = extrapolatedPoint;
233  isGettingCloser = true;
234  found = true;
235  }
236  }
237 
238  // Distance from parent end to connection point - need to turn parent direction around
239  parentConnectionDistance = found ? (parentPoint.GetDirection() * (-1.f)).GetDotProduct(connectionPoint - parentPoint.GetPosition())
240  : std::numeric_limits<float>::lowest();
241  // Distance from child start to connection point
242  childConnectionDistance = found ? (childPoint.GetPosition() - connectionPoint).GetMagnitude() : std::numeric_limits<float>::lowest();
243 }
244 
245 //------------------------------------------------------------------------------------------------------------------------------------------
246 
248 {
252  this->NormaliseNetworkParam(
256  primaryNetworkParams.m_connectionExtrapDistance);
258  primaryNetworkParams.m_parentConnectionDistance);
260  primaryNetworkParams.m_childConnectionDistance);
261 }
262 
263 //------------------------------------------------------------------------------------------------------------------------------------------
264 
266 {
267  // Invoke branch model for each edge
268  const FloatVector outputUp(this->ClassifyTrackEdge(edgeParamsUp, edgeParamsDown));
269  const FloatVector outputDown(this->ClassifyTrackEdge(edgeParamsDown, edgeParamsUp));
270 
271  // Invoke classifier model for final output
273  LArDLHelper::InitialiseInput({1, 6}, input);
274 
275  int insertIndex(0);
276 
277  for (const FloatVector &edgeOutput : {outputUp, outputDown})
278  {
279  for (int i = 0; i < 3; ++i)
280  {
281  input[0][insertIndex] = edgeOutput.at(i);
282  ++insertIndex;
283  }
284  }
285 
288  torch::TensorAccessor<float, 2> outputAccessor = output.accessor<float, 2>();
289 
290  return outputAccessor[0][0];
291 }
292 
293 //------------------------------------------------------------------------------------------------------------------------------------------
294 
296 {
298  LArDLHelper::InitialiseInput({1, 17}, input);
299 
300  // Fill our torch vector
301  int insertIndex(0);
302  edgeParams.AddCommonParamsToInput(insertIndex, input);
303  edgeParams.AddOrientationParamsToInput(insertIndex, input);
304  otherEdgeParams.AddOrientationParamsToInput(insertIndex, input);
305 
308 
309  torch::TensorAccessor<float, 2> outputAccessor(output.accessor<float, 2>());
310 
311  return {outputAccessor[0][0], outputAccessor[0][1], outputAccessor[0][2]};
312 }
313 
314 //------------------------------------------------------------------------------------------------------------------------------------------
315 
317 {
319  LArDLHelper::InitialiseInput({1, 9}, input);
320 
321  // Fill our torch vector
322  int insertIndex(0);
323  primaryNetworkParams.AddCommonParamsToInput(insertIndex, input);
324  primaryNetworkParams.AddOrientationParamsToInput(insertIndex, input);
325 
328  auto outputAccessor = output.accessor<float, 2>();
329 
330  return outputAccessor[0][0];
331 }
332 
333 //------------------------------------------------------------------------------------------------------------------------------------------
334 
335 StatusCode DLPrimaryHierarchyTool::ReadSettings(const TiXmlHandle xmlHandle)
336 {
337  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrainingMode", m_trainingMode));
338  PANDORA_RETURN_RESULT_IF_AND_IF(
339  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "PfoListNames", m_pfoListNames));
340  PANDORA_RETURN_RESULT_IF_AND_IF(
341  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ExtrapolationStepSize", m_extrapolationStepSize));
342  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Normalise", m_normalise));
343  PANDORA_RETURN_RESULT_IF_AND_IF(
344  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NSpacepointsMin", m_normLimits.m_nSpacepointsMin));
345  PANDORA_RETURN_RESULT_IF_AND_IF(
346  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NSpacepointsMax", m_normLimits.m_nSpacepointsMax));
347  PANDORA_RETURN_RESULT_IF_AND_IF(
348  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NuSeparationMin", m_normLimits.m_nuSeparationMin));
349  PANDORA_RETURN_RESULT_IF_AND_IF(
350  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NuSeparationMax", m_normLimits.m_nuSeparationMax));
351  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
352  XmlHelper::ReadValue(xmlHandle, "VertexRegionNHitsMin", m_normLimits.m_vertexRegionNHitsMin));
353  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
354  XmlHelper::ReadValue(xmlHandle, "VertexRegionNHitsMax", m_normLimits.m_vertexRegionNHitsMax));
355  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
356  XmlHelper::ReadValue(xmlHandle, "VertexRegionNParticlesMin", m_normLimits.m_vertexRegionNParticlesMin));
357  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
358  XmlHelper::ReadValue(xmlHandle, "VertexRegionNParticlesMax", m_normLimits.m_vertexRegionNParticlesMax));
359  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DCAMin", m_normLimits.m_dcaMin));
360  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DCAMax", m_normLimits.m_dcaMax));
361  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
362  XmlHelper::ReadValue(xmlHandle, "ConnectionExtrapDistanceMin", m_normLimits.m_connectionExtrapDistanceMin));
363  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
364  XmlHelper::ReadValue(xmlHandle, "ConnectionExtrapDistanceMax", m_normLimits.m_connectionExtrapDistanceMax));
365  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
366  XmlHelper::ReadValue(xmlHandle, "ParentConnectionDistanceMin", m_normLimits.m_parentConnectionDistanceMin));
367  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
368  XmlHelper::ReadValue(xmlHandle, "ParentConnectionDistanceMax", m_normLimits.m_parentConnectionDistanceMax));
369  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
370  XmlHelper::ReadValue(xmlHandle, "ChildConnectionDistanceMin", m_normLimits.m_childConnectionDistanceMin));
371  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
372  XmlHelper::ReadValue(xmlHandle, "ChildConnectionDistanceMax", m_normLimits.m_childConnectionDistanceMax));
373 
374  if (!m_trainingMode)
375  {
376  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "PrimaryTrackBranchModelName", m_primaryTrackBranchModelName));
377  m_primaryTrackBranchModelName = LArFileHelper::FindFileInPath(m_primaryTrackBranchModelName, "FW_SEARCH_PATH");
378  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArDLHelper::LoadModel(m_primaryTrackBranchModelName, m_primaryTrackBranchModel));
379 
380  PANDORA_RETURN_RESULT_IF(
381  STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "PrimaryTrackClassifierModelName", m_primaryTrackClassifierModelName));
382  m_primaryTrackClassifierModelName = LArFileHelper::FindFileInPath(m_primaryTrackClassifierModelName, "FW_SEARCH_PATH");
383  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArDLHelper::LoadModel(m_primaryTrackClassifierModelName, m_primaryTrackClassifierModel));
384 
385  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=,
386  XmlHelper::ReadValue(xmlHandle, "PrimaryShowerClassifierModelName", m_primaryShowerClassifierModelName));
387  m_primaryShowerClassifierModelName = LArFileHelper::FindFileInPath(m_primaryShowerClassifierModelName, "FW_SEARCH_PATH");
388  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArDLHelper::LoadModel(m_primaryShowerClassifierModelName, m_primaryShowerClassifierModel));
389  }
390 
391  return DLBaseHierarchyTool::ReadSettings(xmlHandle);
392 }
393 
394 } // namespace lar_dl_content
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
HierarchyPfo class.
Header file for the pfo helper class.
NormalisationLimits m_normLimits
struct of the normalisation limits
std::string m_primaryTrackBranchModelName
the name of the primary track edge model file
pandora::FloatVector ClassifyTrackEdge(const DLPrimaryNetworkParams &edgeParams, const DLPrimaryNetworkParams &otherEdgeParams)
Apply the primary track orientation edge network - determine whether an edge is signal (with correct ...
const pandora::ParticleFlowObject * GetPfo() const
Get the pfo.
float m_vertexRegionNParticlesMax
the m_vertexRegionNParticles maximum range boundary
std::string m_primaryShowerClassifierModelName
the name of the primary shower classification model file
float m_parentConnectionDistanceMax
the m_parentConnectionDistance maximum range boundary
float m_extrapolationStepSize
the step size used to trace back a child particle&#39;s path
float m_childConnectionDistanceMin
the m_childConnectionDistance minimum range boundary
float ClassifyTrack(const DLPrimaryNetworkParams &edgeParamsUp, const DLPrimaryNetworkParams &edgeParamsDown)
Apply the primary track classification network.
float m_connectionExtrapDistanceMin
the m_connectionExtrapDistance minimum range boundary
float m_parentConnectionDistanceMin
the m_parentConnectionDistance minimum range boundary
Header file for the HierarchyPfo class.
float m_vertexRegionNHitsMax
the m_vertexRegionNHits maximum range boundary
Header file for the DL primary hierarchy tool.
std::string m_primaryTrackClassifierModelName
the name of the primary track classification model file
std::vector< HierarchyPfo > HierarchyPfoVector
bool m_trainingMode
whether to run the tool in training mode
DLBaseHierarchyTool to calculate variables related to the initial shower region.
float m_vertexRegionNParticlesMin
the m_vertexRegionNParticles minimum range boundary
float m_childConnectionDistanceMax
the m_childConnectionDistance maximum range boundary
void NormaliseNetworkParams(DLPrimaryNetworkParams &primaryNetworkParams) const
Shift and normalise the primary network parameters.
float m_vertexRegionNHitsMin
the m_vertexRegionNHits minimum range boundary
float m_nSpacepointsMin
the m_nSpacepoints minimum range boundary
float m_vertexRegionNHits
the number of 3D hits &#39;close to&#39; the POI
TFile f
Definition: plotHisto.C:6
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...
float m_dca
the distance of closest approach from the POI to the nu vertex
void NormaliseNetworkParam(const float minLimit, const float maxLimit, float &networkParam) const
Shift and normalise a network parameter with respect to an input range.
void SetConnectionParams(const ExtremalPoint &particlePoint, const pandora::CartesianVector &nuVertex, DLPrimaryNetworkParams &primaryNetworkParams) const
Set the connection region DLPrimaryNetworkParams params (m_dca, m_connectionExtrapDistance) ...
const ExtremalPoint & GetUpstreamPoint() const
Get the upstream extremal point.
ExtremalPoint class.
const ExtremalPoint & GetDownstreamPoint() const
Get the downstream extremal point.
Header file for the lar deep learning helper helper class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
const pandora::CartesianVector & GetPosition() const
Get the position.
Header file for the file helper class.
pandora::StatusCode Run(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfo &hierarchyPfo, std::vector< DLPrimaryNetworkParams > &networkParamVector, float &primaryScore)
static void Forward(TorchModel &model, const TorchInputVector &input, TorchOutput &output)
Run a deep learning model.
Definition: LArDLHelper.cc:41
pandora::StringVector m_pfoListNames
the input pfo list name vector
void SetContextParams(const pandora::ParticleFlowObject *const pPfo, const ExtremalPoint &particlePoint, const pandora::CartesianVector &nuVertex, const HierarchyPfoVector &trackPfos, DLPrimaryNetworkParams &primaryNetworkParams) const
Set the event context DLPrimaryNetworkParams params (m_parentConnectionDistance, m_childConnectionDis...
float m_nSpacepointsMax
the m_nSpacepoints maximum range boundary
float m_nuSeparation
the sep. between the POI and the nu vertex
void AddCommonParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const
Add the orientation independent primary network parameters to the model input tensor.
float ClassifyShower(const DLPrimaryNetworkParams &primaryNetworkParams)
Apply the primary shower classification network.
float m_isPOIClosestToNu
whether the POI is that closest to the nu vertex
static pandora::StatusCode LoadModel(const std::string &filename, TorchModel &model)
Loads a deep learning model.
Definition: LArDLHelper.cc:16
float m_connectionExtrapDistance
the sep. between the POI and the DCA point
float m_nuSeparationMin
the m_nuSeparation minimum range boundary
void CalculateConnectionDistances(const ExtremalPoint &parentPoint, const ExtremalPoint &childPoint, float &parentConnectionDistance, float &childConnectionDistance) const
Calculate the variables describing the extension of a child particle to a given parent (m_parentConne...
float m_childConnectionDistance
the sep. between the POI and the extension point for m_parentConnectionDistance
void SetVertexRegionParams(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pPfo, const pandora::CartesianVector &particleVertex, DLPrimaryNetworkParams &primaryNetworkParams) const
Set the vertex region DLPrimaryNetworkParams params (m_vertexRegionNHits, m_vertexRegionNParticles) ...
bool m_normalise
whether to normalise the network parameters
LArDLHelper::TorchModel m_primaryShowerClassifierModel
the primary shower classification model
const pandora::CartesianVector & GetDirection() const
Get the direction at the extremal point.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
float m_vertexRegionNParticles
the number of different particles &#39;close to&#39; the POI
LArGeometryHelper::DetectorBoundaries m_detectorBoundaries
the detector boundaries
static void InitialiseInput(const at::IntArrayRef dimensions, TorchInput &tensor)
Create a torch input tensor.
Definition: LArDLHelper.cc:34
LArDLHelper::TorchModel m_primaryTrackClassifierModel
the primary track classification model
float m_nuSeparationMax
the m_nuSeparation maximum range boundary
float m_parentConnectionDistance
the DCA to the most likely parent pfo endpoint
LArDLHelper::TorchModel m_primaryTrackBranchModel
the primary track edge model
void AddOrientationParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const
Add the orientation dependent primary network parameters to the model input tensor.
pandora::StatusCode CalculateNetworkVariables(const pandora::Algorithm *const pAlgorithm, const HierarchyPfo &hierarchyPfo, const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const bool useUpstream, DLPrimaryNetworkParams &primaryNetworkParams) const
Function to calculate the DLPrimaryNetworkParams.
void SetDetectorBoundaries()
Set the detector boundaries.
float m_connectionExtrapDistanceMax
the m_connectionExtrapDistance maximum range boundary