LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
DLLaterTierHierarchyTool.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 #include "Pandora/StatusCodes.h"
11 
17 
19 
21 
22 #include <torch/script.h>
23 #include <torch/torch.h>
24 
25 using namespace pandora;
26 using namespace lar_content;
27 
28 namespace lar_dl_content
29 {
30 
31 //------------------------------------------------------------------------------------------------------------------------------------------
32 
33 void DLLaterTierHierarchyTool::DLLaterTierNetworkParams::AddCommonParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const
34 {
35  for (const float param : {m_parentTrackScore, m_childTrackScore, m_parentNSpacepoints, m_childNSpacepoints, m_separation3D})
36  {
37  modelInput[0][insertIndex] = param;
38  ++insertIndex;
39  }
40 }
41 
42 //------------------------------------------------------------------------------------------------------------------------------------------
43 
44 void DLLaterTierHierarchyTool::DLLaterTierNetworkParams::AddOrientationParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const
45 {
46  for (const float param : {m_parentNuVertexSep, m_childNuVertexSep, m_parentEndRegionNHits, m_parentEndRegionNParticles,
47  m_parentEndRegionRToWall, m_vertexSeparation, m_doesChildConnect, m_overshootStartDCA, m_overshootStartL, m_overshootEndDCA,
48  m_overshootEndL, m_childCPDCA, m_childCPExtrapDistance, m_childCPLRatio, m_parentCPNUpstreamHits, m_parentCPNDownstreamHits,
49  m_parentCPNHitRatio, m_parentCPEigenvalueRatio, m_parentCPOpeningAngle, m_parentIsPOIClosestToNu, m_childIsPOIClosestToNu})
50  {
51  modelInput[0][insertIndex] = param;
52  ++insertIndex;
53  }
54 }
55 
56 //------------------------------------------------------------------------------------------------------------------------------------------
57 //------------------------------------------------------------------------------------------------------------------------------------------
58 
59 DLLaterTierHierarchyTool::DLLaterTierHierarchyTool() :
61  m_trainingMode(false),
62  m_trajectoryStepSize(1.f),
63  m_connectionBuffer(50.f),
64  m_searchRegion(10.f),
65  m_normalise(true)
66 {
67 }
68 
69 //------------------------------------------------------------------------------------------------------------------------------------------
70 
71 StatusCode DLLaterTierHierarchyTool::Run(const Algorithm *const pAlgorithm, const ParticleFlowObject *const pNeutrinoPfo,
72  const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo,
73  std::vector<DLLaterTierNetworkParams> &networkParamVector, float &laterTierScore)
74 {
75  networkParamVector.clear();
76  laterTierScore = std::numeric_limits<float>::lowest();
77 
78  this->SetDetectorBoundaries();
79 
80  // Get the common params i.e. independent of postulated orientation
81  const std::pair<float, float> trackScoreParams(
82  {LArPfoHelper::GetTrackScore(parentHierarchyPfo.GetPfo()), LArPfoHelper::GetTrackScore(childHierarchyPfo.GetPfo())});
83  const std::pair<float, float> nSpacepointsParams(
84  {LArPfoHelper::GetNumberOfThreeDHits(parentHierarchyPfo.GetPfo()), LArPfoHelper::GetNumberOfThreeDHits(childHierarchyPfo.GetPfo())});
85  const float separation3D(LArPfoHelper::GetThreeDSeparation(parentHierarchyPfo.GetPfo(), childHierarchyPfo.GetPfo()));
86 
87  const bool isChildTrack(childHierarchyPfo.GetPfo()->GetParticleId() == 13);
88  std::vector<bool> childOrientationVector(
89  isChildTrack ? std::vector<bool>({true, false}) : std::vector<bool>({this->IsShowerVertexUpstream(parentHierarchyPfo, childHierarchyPfo)}));
90 
91  // Set network params
92  for (const bool &useUpstreamForParent : {true, false})
93  {
94  for (const bool &useUpstreamForChild : childOrientationVector)
95  {
96  DLLaterTierNetworkParams edgeParams;
97 
98  // Set common params
99  this->SetCommonParams(trackScoreParams, nSpacepointsParams, separation3D, edgeParams);
100 
101  // Get orientation dependent params
102  const StatusCode statusCode(this->CalculateNetworkVariables(
103  pAlgorithm, parentHierarchyPfo, childHierarchyPfo, pNeutrinoPfo, useUpstreamForParent, useUpstreamForChild, edgeParams));
104 
105  if (statusCode != STATUS_CODE_SUCCESS)
106  return statusCode;
107 
108  // Add these to our output vector
109  networkParamVector.emplace_back(edgeParams);
110  }
111  }
112 
113  // Now run the model!
114  if (!m_trainingMode)
115  {
116  if (isChildTrack)
117  laterTierScore =
118  this->ClassifyTrackTrack(networkParamVector.at(0), networkParamVector.at(1), networkParamVector.at(2), networkParamVector.at(3));
119  else
120  laterTierScore = this->ClassifyTrackShower(networkParamVector.at(0), networkParamVector.at(1));
121  }
122 
123  return STATUS_CODE_SUCCESS;
124 }
125 
126 //------------------------------------------------------------------------------------------------------------------------------------------
127 
128 bool DLLaterTierHierarchyTool::IsShowerVertexUpstream(const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo) const
129 {
130  const bool isUpstreamSet(childHierarchyPfo.GetUpstreamPoint().IsSet());
131  const bool isDownstreamSet(childHierarchyPfo.GetDownstreamPoint().IsSet());
132 
133  if (isUpstreamSet && !isDownstreamSet)
134  return true;
135 
136  if (!isUpstreamSet && isDownstreamSet)
137  return false;
138 
139  // By design, showers should have at least one set
140  if (!isUpstreamSet && !isDownstreamSet)
141  throw StatusCodeException(STATUS_CODE_FAILURE);
142 
143  CartesianPointVector parentPositions3D;
144  LArPfoHelper::GetCoordinateVector(parentHierarchyPfo.GetPfo(), TPC_3D, parentPositions3D);
145 
146  float upstreamSepSq(std::numeric_limits<float>::max());
147  float downstreamSepSq(std::numeric_limits<float>::max());
148 
149  for (const CartesianVector &parentPosition3D : parentPositions3D)
150  {
151  const float thisUpstreamSepSq((parentPosition3D - childHierarchyPfo.GetUpstreamPoint().GetPosition()).GetMagnitudeSquared());
152  const float thisDownstreamSepSq((parentPosition3D - childHierarchyPfo.GetDownstreamPoint().GetPosition()).GetMagnitudeSquared());
153 
154  upstreamSepSq = std::min(upstreamSepSq, thisUpstreamSepSq);
155  downstreamSepSq = std::min(downstreamSepSq, thisDownstreamSepSq);
156  }
157 
158  return (upstreamSepSq < downstreamSepSq);
159 }
160 
161 //------------------------------------------------------------------------------------------------------------------------------------------
162 
163 void DLLaterTierHierarchyTool::SetCommonParams(const std::pair<float, float> &trackScoreParams,
164  const std::pair<float, float> &nSpacepointsParams, const float separation3D, DLLaterTierNetworkParams &laterTierNetworkParams) const
165 {
166  laterTierNetworkParams.m_parentTrackScore = trackScoreParams.first;
167  laterTierNetworkParams.m_childTrackScore = trackScoreParams.second;
168  laterTierNetworkParams.m_parentNSpacepoints = nSpacepointsParams.first;
169  laterTierNetworkParams.m_childNSpacepoints = nSpacepointsParams.second;
170  laterTierNetworkParams.m_separation3D = separation3D;
171 }
172 
173 //------------------------------------------------------------------------------------------------------------------------------------------
174 
175 StatusCode DLLaterTierHierarchyTool::CalculateNetworkVariables(const Algorithm *const pAlgorithm, const HierarchyPfo &parentHierarchyPfo,
176  const HierarchyPfo &childHierarchyPfo, const ParticleFlowObject *const pNeutrinoPfo, const bool useUpstreamForParent,
177  const bool useUpstreamForChild, DLLaterTierNetworkParams &laterTierNetworkParams) const
178 {
179  // Pick out neutrino vertex
180  if (pNeutrinoPfo->GetVertexList().empty())
181  return STATUS_CODE_NOT_INITIALIZED;
182 
183  const Vertex *const pNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
184  const CartesianVector nuVertex(
185  pNeutrinoVertex->GetPosition().GetX(), pNeutrinoVertex->GetPosition().GetY(), pNeutrinoVertex->GetPosition().GetZ());
186 
187  // Pick out the correct pfo vertex/direction
188  // Parent POI is a postulate endpoint
189  // Child POI is a postulate startpoint
190  const ExtremalPoint &parentStart(useUpstreamForParent ? parentHierarchyPfo.GetDownstreamPoint() : parentHierarchyPfo.GetUpstreamPoint());
191  const ExtremalPoint &parentEnd(useUpstreamForParent ? parentHierarchyPfo.GetUpstreamPoint() : parentHierarchyPfo.GetDownstreamPoint());
192  const ExtremalPoint &childStart(useUpstreamForChild ? childHierarchyPfo.GetUpstreamPoint() : childHierarchyPfo.GetDownstreamPoint());
193 
194  // Check that we could actually calculate pfo vertex/direction, return if not
195  if (!parentStart.IsSet())
196  {
197  return STATUS_CODE_NOT_INITIALIZED;
198  }
199  if (!parentEnd.IsSet())
200  {
201  return STATUS_CODE_NOT_INITIALIZED;
202  }
203  if (!childStart.IsSet())
204  {
205  return STATUS_CODE_NOT_INITIALIZED;
206  }
207 
208  // Set laterTierNetworkParams
209  laterTierNetworkParams.m_parentIsPOIClosestToNu = useUpstreamForParent ? 1.f : 0.f;
210  laterTierNetworkParams.m_childIsPOIClosestToNu = useUpstreamForChild ? 1.f : 0.f;
211  this->SetVertexParams(nuVertex, parentStart.GetPosition(), parentEnd.GetPosition(), childStart.GetPosition(), laterTierNetworkParams);
212  this->SetEndRegionParams(pAlgorithm, parentHierarchyPfo.GetPfo(), parentEnd.GetPosition(), laterTierNetworkParams);
213  this->SetConnectionParams(parentHierarchyPfo, parentStart.GetPosition(), childStart, laterTierNetworkParams);
214  this->SetOvershootParams(parentStart, parentEnd, childStart, laterTierNetworkParams);
215  this->SetParentConnectionPointVars(parentHierarchyPfo, laterTierNetworkParams);
216 
217  // Normalise
218  if (m_normalise)
219  this->NormaliseNetworkParams(laterTierNetworkParams);
220 
221  return STATUS_CODE_SUCCESS;
222 }
223 
224 //------------------------------------------------------------------------------------------------------------------------------------------
225 
226 void DLLaterTierHierarchyTool::SetVertexParams(const CartesianVector &nuVertex, const CartesianVector &parentStartPos,
227  const CartesianVector &parentEndPos, const CartesianVector &childStartPos, DLLaterTierNetworkParams &laterTierNetworkParams) const
228 {
229  laterTierNetworkParams.m_parentNuVertexSep = (parentStartPos - nuVertex).GetMagnitude();
230  laterTierNetworkParams.m_childNuVertexSep = (childStartPos - nuVertex).GetMagnitude();
231  laterTierNetworkParams.m_vertexSeparation = (parentEndPos - childStartPos).GetMagnitude();
232 }
233 
234 //------------------------------------------------------------------------------------------------------------------------------------------
235 
236 void DLLaterTierHierarchyTool::SetEndRegionParams(const Algorithm *const pAlgorithm, const ParticleFlowObject *const pParentPfo,
237  const CartesianVector &parentEndPos, DLLaterTierNetworkParams &laterTierNetworkParams) const
238 {
239  std::pair<float, float> endRegionParams(this->GetParticleInfoAboutPfoPosition(pAlgorithm, pParentPfo, parentEndPos));
240 
241  laterTierNetworkParams.m_parentEndRegionNHits = endRegionParams.first;
242  laterTierNetworkParams.m_parentEndRegionNParticles = endRegionParams.second;
243 
244  this->SetEndRegionRToWall(parentEndPos, laterTierNetworkParams);
245 }
246 
247 //------------------------------------------------------------------------------------------------------------------------------------------
248 
249 void DLLaterTierHierarchyTool::SetEndRegionRToWall(const CartesianVector &parentEndPos, DLLaterTierNetworkParams &laterTierNetworkParams) const
250 {
251  float closestDistance(std::numeric_limits<float>::max());
252 
253  for (int iAxis : {0, 1, 2})
254  {
255  const float parentCoord(iAxis == 0 ? parentEndPos.GetX() : iAxis == 1 ? parentEndPos.GetY() : parentEndPos.GetZ());
256  const std::pair<float, float> &boundary(iAxis == 0 ? m_detectorBoundaries.m_xBoundaries
257  : iAxis == 1 ? m_detectorBoundaries.m_yBoundaries
259  const float dimensionMin(std::min((parentCoord - boundary.first), (boundary.second - parentCoord)));
260 
261  closestDistance = std::min(closestDistance, dimensionMin);
262  }
263 
264  laterTierNetworkParams.m_parentEndRegionRToWall = closestDistance;
265 }
266 
267 //------------------------------------------------------------------------------------------------------------------------------------------
268 
269 void DLLaterTierHierarchyTool::SetConnectionParams(const HierarchyPfo &parentHierarchyPfo, const CartesianVector &parentStartPos,
270  const ExtremalPoint &childStart, DLLaterTierNetworkParams &laterTierNetworkParams) const
271 {
272  // Get fit of parent
273  const ThreeDSlidingFitResult &slidingFitResult(parentHierarchyPfo.GetSlidingFitResult());
274 
275  // Now walk along track, starting from parentStartPos
276  // I want this to be interpreted as l = 0 so have to alter pandora def
277  const bool startFromMin((parentStartPos - slidingFitResult.GetGlobalMinLayerPosition()).GetMagnitudeSquared() <
278  (parentStartPos - slidingFitResult.GetGlobalMaxLayerPosition()).GetMagnitudeSquared());
279  const float minL(slidingFitResult.GetLongitudinalDisplacement(slidingFitResult.GetGlobalMinLayerPosition()));
280  const float maxL(slidingFitResult.GetLongitudinalDisplacement(slidingFitResult.GetGlobalMaxLayerPosition()));
281 
282  if (std::fabs(minL - maxL) < std::numeric_limits<float>::epsilon())
283  return;
284 
285  const int nSteps(std::floor(std::fabs(maxL - minL) / m_trajectoryStepSize));
286 
287  // Keep track of these in loop
288  float slidingL(startFromMin ? minL : 0.f);
289  float trackLength(0.f);
290  float minDCA(std::numeric_limits<float>::max());
291  float lengthAtConnection(0.f);
292 
293  laterTierNetworkParams.m_doesChildConnect = 0.f;
294 
295  for (int i = 0; i < nSteps; i++)
296  {
297  float firstL(slidingL), secondL(slidingL + m_trajectoryStepSize);
298  float firstEvalL(startFromMin ? firstL : (maxL - firstL));
299  float secondEvalL(startFromMin ? secondL : (maxL - secondL));
300  CartesianVector firstPosition(0.f, 0.f, 0.f);
301  CartesianVector secondPosition(0.f, 0.f, 0.f);
302 
303  if ((slidingFitResult.GetGlobalFitPosition(firstEvalL, firstPosition) != STATUS_CODE_SUCCESS) ||
304  (slidingFitResult.GetGlobalFitPosition(secondEvalL, secondPosition) != STATUS_CODE_SUCCESS))
305  {
306  slidingL += m_trajectoryStepSize;
307  continue;
308  }
309 
310  // Get trajectory position
311  const CartesianVector midPoint((secondPosition + firstPosition) * 0.5f);
312 
313  // Extrap child vertex to parent position
314  const std::pair<CartesianVector, bool> extrap(this->ExtrapolateChildToParent(midPoint, childStart));
315  const float thisDCA((midPoint - extrap.first).GetMagnitude());
316 
317  if (thisDCA < minDCA)
318  {
319  if (this->DoesConnect(firstPosition, secondPosition, extrap.first))
320  {
321  minDCA = thisDCA;
322  laterTierNetworkParams.m_doesChildConnect = 1.f;
323  laterTierNetworkParams.m_connectionPoint = midPoint;
324  laterTierNetworkParams.m_connectionDirection = (secondPosition - firstPosition).GetUnitVector();
325  laterTierNetworkParams.m_childCPDCA = thisDCA;
326  laterTierNetworkParams.m_childCPExtrapDistance =
327  (extrap.first - childStart.GetPosition()).GetMagnitude() * (extrap.second ? 1.f : (-1.f));
328  lengthAtConnection = trackLength + (midPoint - firstPosition).GetMagnitude();
329  }
330  }
331 
332  slidingL += m_trajectoryStepSize;
333  trackLength += (secondPosition - firstPosition).GetMagnitude();
334  }
335 
336  if (std::fabs(laterTierNetworkParams.m_doesChildConnect - 1.f) < std::numeric_limits<float>::epsilon())
337  laterTierNetworkParams.m_childCPLRatio = lengthAtConnection / trackLength;
338 }
339 
340 //------------------------------------------------------------------------------------------------------------------------------------------
341 
342 std::pair<CartesianVector, bool> DLLaterTierHierarchyTool::ExtrapolateChildToParent(const CartesianVector &parentPos, const ExtremalPoint &childStart) const
343 {
344  const double extrapDistance((parentPos - childStart.GetPosition()).GetDotProduct(childStart.GetDirection()));
345  const bool backwardsExtrap(extrapDistance < 0.f);
346  const CartesianVector extrapPoint(childStart.GetPosition() + (childStart.GetDirection() * extrapDistance));
347 
348  return std::pair<CartesianVector, bool>({extrapPoint, backwardsExtrap});
349 }
350 
351 //------------------------------------------------------------------------------------------------------------------------------------------
352 
353 bool DLLaterTierHierarchyTool::DoesConnect(const CartesianVector &boundary1, const CartesianVector &boundary2, const CartesianVector &testPoint) const
354 {
355  const CartesianVector displacement(boundary2 - boundary1);
356  const double segmentLength(displacement.GetMagnitude());
357  const CartesianVector unitVector(displacement * (1.f / segmentLength));
358  const double l(unitVector.GetDotProduct(testPoint - boundary1));
359 
360  if ((l < 0.f) || (l > segmentLength))
361  return false;
362 
363  const double t(unitVector.GetCrossProduct(testPoint - boundary1).GetMagnitudeSquared());
364 
366  return false;
367 
368  return true;
369 }
370 
371 //------------------------------------------------------------------------------------------------------------------------------------------
372 
374  const ExtremalPoint &childStart, DLLaterTierNetworkParams &laterTierNetworkParams) const
375 {
376  if (std::fabs(laterTierNetworkParams.m_doesChildConnect - 1.f) < std::numeric_limits<float>::epsilon())
377  return;
378 
379  // Let's start at the very beginning, a very good place to start
380  const std::pair<CartesianVector, bool> extrapStart(this->ExtrapolateChildToParent(parentStart.GetPosition(), childStart));
381  laterTierNetworkParams.m_overshootStartDCA =
382  (extrapStart.first - parentStart.GetPosition()).GetMagnitude() * (extrapStart.second ? 1.f : (-1.f));
383  laterTierNetworkParams.m_overshootStartL =
384  std::fabs((childStart.GetPosition() - parentStart.GetPosition()).GetDotProduct(parentStart.GetDirection()));
385 
386  // Now end
387  const std::pair<CartesianVector, bool> extrapEnd(this->ExtrapolateChildToParent(parentEnd.GetPosition(), childStart));
388  laterTierNetworkParams.m_overshootEndDCA = (extrapEnd.first - parentEnd.GetPosition()).GetMagnitude() * (extrapEnd.second ? 1.f : (-1.f));
389  laterTierNetworkParams.m_overshootEndL =
390  std::fabs((childStart.GetPosition() - parentEnd.GetPosition()).GetDotProduct(parentEnd.GetDirection()));
391 }
392 
393 //------------------------------------------------------------------------------------------------------------------------------------------
394 
395 void DLLaterTierHierarchyTool::SetParentConnectionPointVars(const HierarchyPfo &parentHierarchyPfo, DLLaterTierNetworkParams &laterTierNetworkParams) const
396 {
397  if (std::fabs(laterTierNetworkParams.m_doesChildConnect - 1.f) > std::numeric_limits<float>::epsilon())
398  return;
399 
400  // Use direction to current direction to split spacepoints into two groups
401  CartesianPointVector parentPositions3D;
402  LArPfoHelper::GetCoordinateVector(parentHierarchyPfo.GetPfo(), TPC_3D, parentPositions3D);
403 
404  CartesianPointVector upstreamGroup, downstreamGroup;
405 
406  for (const CartesianVector &parentPosition : parentPositions3D)
407  {
408  const CartesianVector displacement(parentPosition - laterTierNetworkParams.m_connectionPoint);
409 
410  // Do box as quicker than circle with mag.
411  if ((std::fabs(displacement.GetX()) > m_searchRegion) || (std::fabs(displacement.GetY()) > m_searchRegion) ||
412  (std::fabs(displacement.GetZ()) > m_searchRegion))
413  {
414  continue;
415  }
416 
417  // Assign to group
418  const float thisL(laterTierNetworkParams.m_connectionDirection.GetDotProduct(displacement));
419  CartesianPointVector &group(thisL > 0.f ? downstreamGroup : upstreamGroup);
420  group.emplace_back(parentPosition);
421  }
422 
423  laterTierNetworkParams.m_parentCPNUpstreamHits = upstreamGroup.size();
424  laterTierNetworkParams.m_parentCPNDownstreamHits = downstreamGroup.size();
425 
426  if (upstreamGroup.empty() || downstreamGroup.empty())
427  return;
428 
429  laterTierNetworkParams.m_parentCPNHitRatio = laterTierNetworkParams.m_parentCPNDownstreamHits / laterTierNetworkParams.m_parentCPNUpstreamHits;
430 
431  // Now PCA magic
432  try
433  {
434  CartesianVector centroidUp(0.f, 0.f, 0.f);
435  CartesianVector centroidDown(0.f, 0.f, 0.f);
436  LArPcaHelper::EigenVectors eigenVecsUp, eigenVecsDown;
437  LArPcaHelper::EigenValues eigenValuesUp(0.f, 0.f, 0.f);
438  LArPcaHelper::EigenValues eigenValuesDown(0.f, 0.f, 0.f);
439 
440  LArPcaHelper::RunPca(upstreamGroup, centroidUp, eigenValuesUp, eigenVecsUp);
441  LArPcaHelper::RunPca(downstreamGroup, centroidDown, eigenValuesDown, eigenVecsDown);
442 
443  // Get opening angle from first eigenvectors (this is the longitudinal one) - straight would be around 180
444  laterTierNetworkParams.m_parentCPOpeningAngle = eigenVecsUp.at(0).GetOpeningAngle(eigenVecsDown.at(0)) * (180.f / 3.14);
445 
446  // Get average transverse eigenvalues, get ratio
447  const float avTransEVaUp((eigenValuesUp.GetY() + eigenValuesUp.GetZ()) * 0.5f);
448  const float avTransEVaDown((eigenValuesDown.GetY() + eigenValuesDown.GetZ()) * 0.5f);
449 
450  laterTierNetworkParams.m_parentCPEigenvalueRatio = avTransEVaUp < std::numeric_limits<double>::epsilon() ? 0.f : avTransEVaDown / avTransEVaUp;
451  }
452  catch (...)
453  {
454  return;
455  }
456 }
457 
458 //------------------------------------------------------------------------------------------------------------------------------------------
459 
461 {
471  laterTierNetworkParams.m_parentEndRegionNParticles);
472  this->NormaliseNetworkParam(
481  this->NormaliseNetworkParam(
488  laterTierNetworkParams.m_parentCPEigenvalueRatio);
490 }
491 
492 //------------------------------------------------------------------------------------------------------------------------------------------
493 
495  const DLLaterTierNetworkParams &edgeParamsDownUp, const DLLaterTierNetworkParams &edgeParamsDownDown)
496 {
497  // Invoke branch model for each edge
498  const FloatVector outputUpUp(this->ClassifyTrackTrackEdge(edgeParamsUpUp, edgeParamsUpDown, edgeParamsDownUp, edgeParamsDownDown));
499  const FloatVector outputUpDown(this->ClassifyTrackTrackEdge(edgeParamsUpDown, edgeParamsDownUp, edgeParamsDownDown, edgeParamsUpUp));
500  const FloatVector outputDownUp(this->ClassifyTrackTrackEdge(edgeParamsDownUp, edgeParamsDownDown, edgeParamsUpUp, edgeParamsUpDown));
501  const FloatVector outputDownDown(this->ClassifyTrackTrackEdge(edgeParamsDownDown, edgeParamsUpUp, edgeParamsUpDown, edgeParamsDownUp));
502 
503  // Invoke classifier model for final output
505  LArDLHelper::InitialiseInput({1, 12}, input);
506 
507  int insertIndex(0);
508 
509  for (const FloatVector &edgeOutput : {outputUpUp, outputUpDown, outputDownUp, outputDownDown})
510  {
511  for (int i = 0; i < 3; ++i)
512  {
513  input[0][insertIndex] = edgeOutput.at(i);
514  ++insertIndex;
515  }
516  }
517 
520  const torch::TensorAccessor<float, 2> outputAccessor = output.accessor<float, 2>();
521 
522  return outputAccessor[0][0];
523 }
524 
525 //------------------------------------------------------------------------------------------------------------------------------------------
526 
528  const DLLaterTierNetworkParams &otherEdgeParams1, const DLLaterTierNetworkParams &otherEdgeParams2, const DLLaterTierNetworkParams &otherEdgeParams3)
529 {
531  LArDLHelper::InitialiseInput({1, 89}, input);
532 
533  int insertIndex(0);
534  edgeParams.AddCommonParamsToInput(insertIndex, input);
535  edgeParams.AddOrientationParamsToInput(insertIndex, input);
536  otherEdgeParams1.AddOrientationParamsToInput(insertIndex, input);
537  otherEdgeParams2.AddOrientationParamsToInput(insertIndex, input);
538  otherEdgeParams3.AddOrientationParamsToInput(insertIndex, input);
539 
542 
543  const torch::TensorAccessor<float, 2> outputAccessor(output.accessor<float, 2>());
544 
545  return {outputAccessor[0][0], outputAccessor[0][1], outputAccessor[0][2]};
546 }
547 
548 //------------------------------------------------------------------------------------------------------------------------------------------
549 
551 {
552  // Invoke branch model for each edge
553  const FloatVector outputUp(this->ClassifyTrackShowerEdge(edgeParamsUp, edgeParamsDown));
554  const FloatVector outputDown(this->ClassifyTrackShowerEdge(edgeParamsDown, edgeParamsUp));
555 
556  // Invoke classifier model for final output
558  LArDLHelper::InitialiseInput({1, 6}, input);
559 
560  int insertIndex(0);
561 
562  for (const FloatVector &edgeOutput : {outputUp, outputDown})
563  {
564  for (int i = 0; i < 3; ++i)
565  {
566  input[0][insertIndex] = edgeOutput.at(i);
567  ++insertIndex;
568  }
569  }
570 
573  const torch::TensorAccessor<float, 2> outputAccessor = output.accessor<float, 2>();
574 
575  return outputAccessor[0][0];
576 }
577 
578 //------------------------------------------------------------------------------------------------------------------------------------------
579 
581 {
583  LArDLHelper::InitialiseInput({1, 47}, input);
584 
585  int insertIndex(0);
586  edgeParams.AddCommonParamsToInput(insertIndex, input);
587  edgeParams.AddOrientationParamsToInput(insertIndex, input);
588  otherEdgeParams.AddOrientationParamsToInput(insertIndex, input);
589 
592 
593  const torch::TensorAccessor<float, 2> outputAccessor(output.accessor<float, 2>());
594 
595  return {outputAccessor[0][0], outputAccessor[0][1], outputAccessor[0][2]};
596 }
597 
598 //------------------------------------------------------------------------------------------------------------------------------------------
599 
600 StatusCode DLLaterTierHierarchyTool::ReadSettings(const TiXmlHandle xmlHandle)
601 {
602  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrainingMode", m_trainingMode));
603  PANDORA_RETURN_RESULT_IF_AND_IF(
604  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrajectoryStepSize", m_trajectoryStepSize));
605  PANDORA_RETURN_RESULT_IF_AND_IF(
606  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ConnectionBuffer", m_connectionBuffer));
607  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SearchRegion", m_searchRegion));
608  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Normalise", m_normalise));
609 
610  PANDORA_RETURN_RESULT_IF_AND_IF(
611  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrackScoreMin", m_normLimits.m_trackScoreMin));
612  PANDORA_RETURN_RESULT_IF_AND_IF(
613  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrackScoreMax", m_normLimits.m_trackScoreMax));
614  PANDORA_RETURN_RESULT_IF_AND_IF(
615  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NSpacepointsMin", m_normLimits.m_nSpacepointsMin));
616  PANDORA_RETURN_RESULT_IF_AND_IF(
617  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NSpacepointsMax", m_normLimits.m_nSpacepointsMax));
618  PANDORA_RETURN_RESULT_IF_AND_IF(
619  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Separation3DMin", m_normLimits.m_separation3DMin));
620  PANDORA_RETURN_RESULT_IF_AND_IF(
621  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Separation3DMax", m_normLimits.m_separation3DMax));
622  PANDORA_RETURN_RESULT_IF_AND_IF(
623  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NuVertexSepMin", m_normLimits.m_nuVertexSepMin));
624  PANDORA_RETURN_RESULT_IF_AND_IF(
625  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NuVertexSepMax", m_normLimits.m_nuVertexSepMax));
626  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
627  XmlHelper::ReadValue(xmlHandle, "ParentEndRegionNHitsMin", m_normLimits.m_parentEndRegionNHitsMin));
628  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
629  XmlHelper::ReadValue(xmlHandle, "ParentEndRegionNHitsMax", m_normLimits.m_parentEndRegionNHitsMax));
630  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
631  XmlHelper::ReadValue(xmlHandle, "ParentEndRegionNParticlesMin", m_normLimits.m_parentEndRegionNParticlesMin));
632  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
633  XmlHelper::ReadValue(xmlHandle, "ParentEndRegionNParticlesMax", m_normLimits.m_parentEndRegionNParticlesMax));
634  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
635  XmlHelper::ReadValue(xmlHandle, "ParentEndRegionRToWallMin", m_normLimits.m_parentEndRegionRToWallMin));
636  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
637  XmlHelper::ReadValue(xmlHandle, "ParentEndRegionRToWallMax", m_normLimits.m_parentEndRegionRToWallMax));
638  PANDORA_RETURN_RESULT_IF_AND_IF(
639  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "VertexSepMin", m_normLimits.m_vertexSepMin));
640  PANDORA_RETURN_RESULT_IF_AND_IF(
641  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "VertexSepMax", m_normLimits.m_vertexSepMax));
642  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
643  XmlHelper::ReadValue(xmlHandle, "DoesChildConnectMin", m_normLimits.m_doesChildConnectMin));
644  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
645  XmlHelper::ReadValue(xmlHandle, "DoesChildConnectMax", m_normLimits.m_doesChildConnectMax));
646  PANDORA_RETURN_RESULT_IF_AND_IF(
647  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "OvershootDCAMin", m_normLimits.m_overshootDCAMin));
648  PANDORA_RETURN_RESULT_IF_AND_IF(
649  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "OvershootDCAMax", m_normLimits.m_overshootDCAMax));
650  PANDORA_RETURN_RESULT_IF_AND_IF(
651  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "OvershootLMin", m_normLimits.m_overshootLMin));
652  PANDORA_RETURN_RESULT_IF_AND_IF(
653  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "OvershootLMax", m_normLimits.m_overshootLMax));
654  PANDORA_RETURN_RESULT_IF_AND_IF(
655  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ChildCPDCAMin", m_normLimits.m_childCPDCAMin));
656  PANDORA_RETURN_RESULT_IF_AND_IF(
657  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ChildCPDCAMax", m_normLimits.m_childCPDCAMax));
658  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
659  XmlHelper::ReadValue(xmlHandle, "ChildCPExtrapDistanceMin", m_normLimits.m_childCPExtrapDistanceMin));
660  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
661  XmlHelper::ReadValue(xmlHandle, "ChildCPExtrapDistanceMax", m_normLimits.m_childCPExtrapDistanceMax));
662  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
663  XmlHelper::ReadValue(xmlHandle, "ChildCPLRatioMin", m_normLimits.m_childCPLRatioMin));
664  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
665  XmlHelper::ReadValue(xmlHandle, "ChildCPLRatioMax", m_normLimits.m_childCPLRatioMax));
666  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
667  XmlHelper::ReadValue(xmlHandle, "ParentCPNHitsMin", m_normLimits.m_parentCPNHitsMin));
668  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
669  XmlHelper::ReadValue(xmlHandle, "ParentCPNHitsMax", m_normLimits.m_parentCPNHitsMax));
670  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
671  XmlHelper::ReadValue(xmlHandle, "ParentCPNHitRatioMin", m_normLimits.m_parentCPNHitRatioMin));
672  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
673  XmlHelper::ReadValue(xmlHandle, "ParentCPNHitRatioMax", m_normLimits.m_parentCPNHitRatioMax));
674  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
675  XmlHelper::ReadValue(xmlHandle, "ParentCPEigenvalueRatioMin", m_normLimits.m_parentCPEigenvalueRatioMin));
676  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
677  XmlHelper::ReadValue(xmlHandle, "ParentCPEigenvalueRatioMax", m_normLimits.m_parentCPEigenvalueRatioMax));
678  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
679  XmlHelper::ReadValue(xmlHandle, "ParentCPOpeningAngleMin", m_normLimits.m_parentCPOpeningAngleMin));
680  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
681  XmlHelper::ReadValue(xmlHandle, "ParentCPOpeningAngleMax", m_normLimits.m_parentCPOpeningAngleMax));
682 
683  if (!m_trainingMode)
684  {
685  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "TrackTrackBranchModelName", m_trackTrackBranchModelName));
686  m_trackTrackBranchModelName = LArFileHelper::FindFileInPath(m_trackTrackBranchModelName, "FW_SEARCH_PATH");
687  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArDLHelper::LoadModel(m_trackTrackBranchModelName, m_trackTrackBranchModel));
688 
689  PANDORA_RETURN_RESULT_IF(
690  STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "TrackTrackClassifierModelName", m_trackTrackClassifierModelName));
691  m_trackTrackClassifierModelName = LArFileHelper::FindFileInPath(m_trackTrackClassifierModelName, "FW_SEARCH_PATH");
692  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArDLHelper::LoadModel(m_trackTrackClassifierModelName, m_trackTrackClassifierModel));
693 
694  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "TrackShowerBranchModelName", m_trackShowerBranchModelName));
695  m_trackShowerBranchModelName = LArFileHelper::FindFileInPath(m_trackShowerBranchModelName, "FW_SEARCH_PATH");
696  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArDLHelper::LoadModel(m_trackShowerBranchModelName, m_trackShowerBranchModel));
697 
698  PANDORA_RETURN_RESULT_IF(
699  STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "TrackShowerClassifierModelName", m_trackShowerClassifierModelName));
700  m_trackShowerClassifierModelName = LArFileHelper::FindFileInPath(m_trackShowerClassifierModelName, "FW_SEARCH_PATH");
701  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArDLHelper::LoadModel(m_trackShowerClassifierModelName, m_trackShowerClassifierModel));
702  }
703 
704  return DLBaseHierarchyTool::ReadSettings(xmlHandle);
705 }
706 
707 } // namespace lar_dl_content
float m_parentNuVertexSep
the separation between the neutrino vertex and assumed parent start point
float m_doesChildConnectMin
the m_doesChildConnect minimum range boundary
float m_childCPExtrapDistanceMax
the m_childCPExtrapDistance maximum range boundary
HierarchyPfo class.
float m_childCPLRatioMin
the m_childCPLRatio minimum range boundary
float m_parentCPEigenvalueRatio
the ratio of the second eigenvalues of the downstream and upstream 3D hit groups (set if the child co...
Header file for the pfo helper class.
float m_trackScoreMin
the m_parent(child)TrackScore minimum range boundary
pandora::StatusCode CalculateNetworkVariables(const pandora::Algorithm *const pAlgorithm, const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo, const pandora::ParticleFlowObject *const pNeutrinoPfo, const bool useUpstreamForParent, const bool useUpstreamForChild, DLLaterTierNetworkParams &laterTierNetworkParams) const
Function to calculate the DLLaterTierNetworkParams.
void SetConnectionParams(const HierarchyPfo &parentHierarchyPfo, const pandora::CartesianVector &parentStartPos, const ExtremalPoint &childStart, DLLaterTierNetworkParams &laterTierNetworkParams) const
Set the child connection DLLaterTierNetworkParams (m_doesChildConnect, m_connectionPoint, m_connectionDirection, m_childCPDCA, m_childCPExtrapDistance, m_childCPLRatio)
float m_overshootEndL
the extension distance of the child to the DCA point (set if the child doesn&#39;t connect) ...
const pandora::ParticleFlowObject * GetPfo() const
Get the pfo.
float m_parentCPNHitRatioMax
the m_parentCPNHitRatio maximum range boundary
pandora::FloatVector ClassifyTrackShowerEdge(const DLLaterTierNetworkParams &edgeParams, const DLLaterTierNetworkParams &otherEdgeParams)
Apply the track-shower orientation edge network - determine whether an edge is signal (with correct o...
void SetParentConnectionPointVars(const HierarchyPfo &parentHierarchyPfo, DLLaterTierNetworkParams &laterTierNetworkParams) const
Set the parent connection point DLLaterTierNetworkParams (m_parentCPNUpstreamHits, m_parentCPNDownstreamHits, m_parentCPNHitRatio, m_parentCPEigenvalueRatio, m_parentCPOpeningAngle)
float m_overshootStartL
the extension distance of the child to the DCA point (set if the child doesn&#39;t connect) ...
pandora::CartesianVector EigenValues
Definition: LArPcaHelper.h:24
float m_childCPExtrapDistanceMin
the m_childCPExtrapDistance minimum range boundary
float m_childCPDCA
the DCA of the child to the connection point (set if the child connects)
float m_separation3DMin
the m_separation3D minimum range boundary
float m_parentEndRegionNHits
the number of 3D hits &#39;close to&#39; the parent POI
float m_parentEndRegionNParticles
the number of different particles &#39;close to&#39; the parent POI
pandora::StatusCode Run(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo, std::vector< DLLaterTierNetworkParams > &networkParamVector, float &laterTierScore)
float m_parentCPEigenvalueRatioMin
the m_parentCPEigenvalueRatio minimum range boundary
float m_parentCPNHitRatio
the ratio of the number of downstream hits and upstream 3D hits (set if the child connects) ...
float m_overshootStartDCA
the DCA of the child to the parent startpoint (set if the child doesn&#39;t connect)
float m_separation3D
the smallest 3D distance between the parent and child 3D hits
Header file for the principal curve analysis helper class.
float m_vertexSeparation
the separation between the parent and child POIs
LArDLHelper::TorchModel m_trackShowerBranchModel
the track-shower edge model
float m_parentCPOpeningAngleMax
the m_parentCPOpeningAngle maximum range boundary
std::string m_trackShowerBranchModelName
the name of the track-shower edge model file
DLBaseHierarchyTool to calculate variables related to the initial shower region.
float m_overshootEndDCA
the DCA of the child to the parent endpoint (set if the child doesn&#39;t connect)
pandora::CartesianVector m_connectionPoint
the connection point of the child on the parent
float m_nuVertexSepMax
the m_parent(child)NuVertexSep maximum range boundary
float m_parentCPNHitsMax
the m_parentCPNUp(Down)streamHits maximum range boundary
bool m_normalise
whether to normalise the network parameters
bool IsShowerVertexUpstream(const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo) const
Whether the shower POI is the endpoint closest to the neutrino vertex.
float m_parentCPOpeningAngleMin
the m_parentCPOpeningAngle minimum range boundary
float m_childCPDCAMin
the m_childCPDCA minimum range boundary
float m_parentCPNUpstreamHits
the number of 3D parent hits upstream of the connection point (set if the child connects) ...
float m_connectionBuffer
the &#39;is child connected?&#39; threshold
float m_parentCPEigenvalueRatioMax
the m_parentCPEigenvalueRatio maximum range boundary
TFile f
Definition: plotHisto.C:6
NormalisationLimits m_normLimits
struct of the normalisation limits
void AddOrientationParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const
Add the orientation dependent later tier network parameters to the model input tensor.
std::pair< float, float > m_yBoundaries
{low, high} y boundaries of the detector
float m_overshootDCAMin
the m_overshootStart(End)DCA minimum range boundary
Header file for the geometry helper class.
void AddCommonParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const
Add the orientation independent later tier network parameters to the model input tensor.
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 NormaliseNetworkParams(DLLaterTierNetworkParams &laterTierNetworkParams) const
Shift and normalise the later tier network parameters.
bool IsSet() const
Whether extremal point object has been set.
float m_parentCPOpeningAngle
the opening angle between the first eigenvectors of the downstream and upstream 3D hit groups (set if...
LArDLHelper::TorchModel m_trackShowerClassifierModel
the track-shower classification model
std::string m_trackTrackBranchModelName
the name of the track-track edge model file
float m_overshootLMin
the m_overshootStart(End)L minimum range boundary
void NormaliseNetworkParam(const float minLimit, const float maxLimit, float &networkParam) const
Shift and normalise a network parameter with respect to an input range.
float m_doesChildConnectMax
the m_doesChildConnect maximum range boundary
std::pair< float, float > m_xBoundaries
{low, high} x boundaries of the detector
float m_overshootLMax
the m_overshootStart(End)L maximum range boundary
const ExtremalPoint & GetUpstreamPoint() const
Get the upstream extremal point.
void SetEndRegionParams(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pParentPfo, const pandora::CartesianVector &parentEndPos, DLLaterTierNetworkParams &laterTierNetworkParams) const
Set the parent endpoint region DLLaterTierNetworkParams (m_parentEndRegionNHits, m_parentEndRegionNPa...
float m_trackScoreMax
the m_parent(child)TrackScore maximum range boundary
ExtremalPoint class.
float m_searchRegion
the dimensions of the box used to obtain the up/downstream 3D hit groups
float m_nSpacepointsMin
the m_parent(child)NSpacepoints minimum range boundary
const ExtremalPoint & GetDownstreamPoint() const
Get the downstream extremal point.
std::pair< float, float > m_zBoundaries
{low, high} z boundaries of the detector
float m_vertexSepMax
the m_vertexSeparation maximum range boundary
Header file for the lar deep learning helper helper class.
float m_parentCPNHitRatioMin
the m_parentCPNHitRatio minimum range boundary
float m_parentCPNDownstreamHits
the number of 3D parent hits downstream of the connection point (set if the child connects) ...
void SetOvershootParams(const ExtremalPoint &parentStart, const ExtremalPoint &parentEnd, const ExtremalPoint &childStart, DLLaterTierNetworkParams &laterTierNetworkParams) const
Set the overshoot DLLaterTierNetworkParams (m_overshootStartDCA, m_overshootStartL, m_overshootEndDCA, m_overshootEndL)
float m_nSpacepointsMax
the m_parent(child)NSpacepoints maximum range boundary
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float ClassifyTrackTrack(const DLLaterTierNetworkParams &edgeParamsUpUp, const DLLaterTierNetworkParams &edgeParamsUpDown, const DLLaterTierNetworkParams &edgeParamsDownUp, const DLLaterTierNetworkParams &edgeParamsDownDown)
Apply the track-track parent-child classification network.
const pandora::CartesianVector & GetPosition() const
Get the position.
Header file for the file helper class.
float m_parentEndRegionRToWall
the smallest parent POI to detector boundary separation
static void Forward(TorchModel &model, const TorchInputVector &input, TorchOutput &output)
Run a deep learning model.
Definition: LArDLHelper.cc:41
float m_parentEndRegionNHitsMin
the m_parentEndRegionNHits minimum range boundary
pandora::FloatVector ClassifyTrackTrackEdge(const DLLaterTierNetworkParams &edgeParams, const DLLaterTierNetworkParams &otherEdgeParams1, const DLLaterTierNetworkParams &otherEdgeParams2, const DLLaterTierNetworkParams &otherEdgeParams3)
Apply the track-track orientation edge network - determine whether an edge is signal (with correct or...
float m_parentTrackScore
the track/shower score of the parent pfo
Header file for the lar three dimensional sliding fit result class.
float m_separation3DMax
the m_separation3D maximum range boundary
const ThreeDSlidingFitResult & GetSlidingFitResult() const
Get the pfo&#39;s 3D sliding fit result.
float m_parentCPNHitsMin
the m_parentCPNUp(Down)streamHits minimum range boundary
void SetVertexParams(const pandora::CartesianVector &nuVertex, const pandora::CartesianVector &parentStartPos, const pandora::CartesianVector &parentEndPos, const pandora::CartesianVector &childStartPos, DLLaterTierNetworkParams &laterTierNetworkParams) const
Set the vertex related DLLaterTierNetworkParams (m_parentNuVertexSep, m_childNuVertexSep, m_vertexSeparation)
float m_parentEndRegionRToWallMax
the m_parentEndRegionRToWall maximum range boundary
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void SetCommonParams(const std::pair< float, float > &trackScoreParams, const std::pair< float, float > &nSpacepointsParams, const float separation3D, DLLaterTierNetworkParams &laterTierNetworkParams) const
Set the orientation independent DLLaterTierNetworkParams (m_parentTrackScore, m_childTrackScore, m_parentNSpacepoints, m_childNSpacepoints, m_separation3D)
float m_doesChildConnect
whether the backwards trace of the child&#39;s path connects to the parent
std::vector< pandora::CartesianVector > EigenVectors
Definition: LArPcaHelper.h:25
static pandora::StatusCode LoadModel(const std::string &filename, TorchModel &model)
Loads a deep learning model.
Definition: LArDLHelper.cc:16
float m_trajectoryStepSize
the size of the steps taken to trace the parent trajectory
std::pair< pandora::CartesianVector, bool > ExtrapolateChildToParent(const pandora::CartesianVector &parentPosition, const ExtremalPoint &childStart) const
Project the (parentPos - childStartPos) vector onto the child direction axis to obtain an extrapolati...
float m_parentEndRegionNParticlesMin
the m_parentEndRegionNParticles minimum range boundary
float m_parentEndRegionNHitsMax
the m_parentEndRegionNHits maximum range boundary
bool m_trainingMode
whether to run the tool in training mode
LArDLHelper::TorchModel m_trackTrackClassifierModel
the track-track classification model
bool DoesConnect(const pandora::CartesianVector &boundary1, const pandora::CartesianVector &boundary2, const pandora::CartesianVector &testPoint) const
Return whether an input position connects to a line defined by two endpoints.
void SetEndRegionRToWall(const pandora::CartesianVector &parentEndPos, DLLaterTierNetworkParams &laterTierNetworkParams) const
Set the m_parentEndRegionRToWall DLLaterTierNetworkParam.
float m_childCPLRatio
the ratio of the parent length at the connection point and the full parent length (set if the child c...
const pandora::CartesianVector & GetDirection() const
Get the direction at the extremal point.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::string m_trackShowerClassifierModelName
the name of the track-shower classification model file
LArDLHelper::TorchModel m_trackTrackBranchModel
the track-track edge model
float m_parentEndRegionNParticlesMax
the m_parentEndRegionNParticles maximum range boundary
LArGeometryHelper::DetectorBoundaries m_detectorBoundaries
the detector boundaries
float m_childCPLRatioMax
the m_childCPLRatio maximum range boundary
float m_childCPExtrapDistance
the extension distance of the child to the DCA point (set if the child connects)
float m_childCPDCAMax
the m_childCPDCA maximum range boundary
float m_parentIsPOIClosestToNu
whether the parent POI is that closest to the neutrino vertex
static void InitialiseInput(const at::IntArrayRef dimensions, TorchInput &tensor)
Create a torch input tensor.
Definition: LArDLHelper.cc:34
Header file for the DL later hierarchy tool.
pandora::CartesianVector m_connectionDirection
the parent&#39;s direction at the connection point
float m_overshootDCAMax
the m_overshootStart(End)DCA maximum range boundary
std::string m_trackTrackClassifierModelName
the name of the track-track classification model file
float ClassifyTrackShower(const DLLaterTierNetworkParams &edgeParamsUp, const DLLaterTierNetworkParams &edgeParamsDown)
Apply the track-shower parent-child classification network.
float m_parentNSpacepoints
the number of 3D hits in the parent pfo
float m_nuVertexSepMin
the m_parent(child)NuVertexSep minimum range boundary
float m_childIsPOIClosestToNu
whether the child POI is that closest to the neutrino vertex
float m_childNuVertexSep
the separation between the neutrino vertex and assumed child start point
float m_parentEndRegionRToWallMin
the m_parentEndRegionRToWall minimum range boundary
float m_vertexSepMin
the m_vertexSeparation minimum range boundary
void SetDetectorBoundaries()
Set the detector boundaries.