LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
DLPrimaryHierarchyTool.h
Go to the documentation of this file.
1 
8 #ifndef LAR_DL_PRIMARY_HIERARCHY_TOOL_H
9 #define LAR_DL_PRIMARY_HIERARCHY_TOOL_H 1
10 
11 #include "Pandora/PandoraInternal.h"
12 
16 
17 namespace lar_dl_content
18 {
23 {
24 public:
25  struct DLPrimaryNetworkParams // all floats because they'll be normalised
26  {
27  float m_nSpacepoints = -999.f;
28  float m_nuSeparation = -999.f;
29  float m_vertexRegionNHits = -999.f;
30  float m_vertexRegionNParticles = -999.f;
31  float m_dca = -999.f;
32  float m_connectionExtrapDistance = -999.f;
33  float m_isPOIClosestToNu = -999.f;
34  float m_parentConnectionDistance = -999.f;
35  float m_childConnectionDistance = -999.f;
36 
44  void AddCommonParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const;
45 
53  void AddOrientationParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const;
54  };
55 
57  {
58  float m_nSpacepointsMin = 0.f;
59  float m_nSpacepointsMax = 2000.f;
60  float m_nuSeparationMin = -50.f;
61  float m_nuSeparationMax = 500.f;
62  float m_vertexRegionNHitsMin = -10.f;
63  float m_vertexRegionNHitsMax = 100.f;
64  float m_vertexRegionNParticlesMin = -1.f;
65  float m_vertexRegionNParticlesMax = 8.f;
66  float m_dcaMin = -60.f;
67  float m_dcaMax = 600.f;
68  float m_connectionExtrapDistanceMin = -700.f;
69  float m_connectionExtrapDistanceMax = 500.f;
70  float m_parentConnectionDistanceMin = -150.f;
71  float m_parentConnectionDistanceMax = 150.f;
72  float m_childConnectionDistanceMin = -30.f;
73  float m_childConnectionDistanceMax = 300.f;
74  };
75 
76  pandora::StatusCode Run(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pNeutrinoPfo,
77  const HierarchyPfoVector &trackPfos, const HierarchyPfo &hierarchyPfo, std::vector<DLPrimaryNetworkParams> &networkParamVector,
78  float &primaryScore);
79 
84 
94  void CalculateConnectionDistances(const ExtremalPoint &parentPoint, const ExtremalPoint &childPoint, float &parentConnectionDistance,
95  float &childConnectionDistance) const;
96 
97 private:
98  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
99 
112  pandora::StatusCode CalculateNetworkVariables(const pandora::Algorithm *const pAlgorithm, const HierarchyPfo &hierarchyPfo,
113  const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const bool useUpstream,
114  DLPrimaryNetworkParams &primaryNetworkParams) const;
115 
125  void SetVertexRegionParams(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pPfo,
126  const pandora::CartesianVector &particleVertex, DLPrimaryNetworkParams &primaryNetworkParams) const;
127 
136  void SetConnectionParams(
137  const ExtremalPoint &particlePoint, const pandora::CartesianVector &nuVertex, DLPrimaryNetworkParams &primaryNetworkParams) const;
138 
149  void SetContextParams(const pandora::ParticleFlowObject *const pPfo, const ExtremalPoint &particlePoint,
150  const pandora::CartesianVector &nuVertex, const HierarchyPfoVector &trackPfos, DLPrimaryNetworkParams &primaryNetworkParams) const;
151 
157  void NormaliseNetworkParams(DLPrimaryNetworkParams &primaryNetworkParams) const;
158 
167  float ClassifyTrack(const DLPrimaryNetworkParams &edgeParamsUp, const DLPrimaryNetworkParams &edgeParamsDown);
168 
178  pandora::FloatVector ClassifyTrackEdge(const DLPrimaryNetworkParams &edgeParams, const DLPrimaryNetworkParams &otherEdgeParams);
179 
187  float ClassifyShower(const DLPrimaryNetworkParams &primaryNetworkParams);
188 
189  // For model
197  // For tool
199  // For normalisation
200  bool m_normalise;
202 };
203 
204 //------------------------------------------------------------------------------------------------------------------------------------------
205 
206 } // namespace lar_dl_content
207 
208 #endif // #ifndef LAR_DL_PRIMARY_HIERARCHY_TOOL_H
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
HierarchyPfo 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 ...
std::string m_primaryShowerClassifierModelName
the name of the primary shower classification model file
float m_extrapolationStepSize
the step size used to trace back a child particle&#39;s path
float ClassifyTrack(const DLPrimaryNetworkParams &edgeParamsUp, const DLPrimaryNetworkParams &edgeParamsDown)
Apply the primary track classification network.
Header file for the HierarchyPfo class.
std::string m_primaryTrackClassifierModelName
the name of the primary track classification model file
std::vector< HierarchyPfo > HierarchyPfoVector
torch::jit::script::Module TorchModel
Definition: LArDLHelper.h:25
Header file for the DL base hierarchy tool.
bool m_trainingMode
whether to run the tool in training mode
DLBaseHierarchyTool to calculate variables related to the initial shower region.
void NormaliseNetworkParams(DLPrimaryNetworkParams &primaryNetworkParams) const
Shift and normalise the primary network parameters.
float m_vertexRegionNHits
the number of 3D hits &#39;close to&#39; the POI
float m_dca
the distance of closest approach from the POI to the nu vertex
void SetConnectionParams(const ExtremalPoint &particlePoint, const pandora::CartesianVector &nuVertex, DLPrimaryNetworkParams &primaryNetworkParams) const
Set the connection region DLPrimaryNetworkParams params (m_dca, m_connectionExtrapDistance) ...
ExtremalPoint class.
Header file for the lar deep learning helper 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)
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_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
float m_connectionExtrapDistance
the sep. between the POI and the DCA point
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
float m_vertexRegionNParticles
the number of different particles &#39;close to&#39; the POI
DLPrimaryHierarchyTool to apply the primary hierarchy DL networks.
LArDLHelper::TorchModel m_primaryTrackClassifierModel
the primary track classification model
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.