LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
DLLaterTierHierarchyTool.h
Go to the documentation of this file.
1 
8 #ifndef LAR_DL_LATER_TIER_HIERARCHY_TOOL_H
9 #define LAR_DL_LATER_TIER_HIERARCHY_TOOL_H 1
10 
11 #include "Pandora/PandoraInternal.h"
12 
16 
17 namespace lar_dl_content
18 {
19 
24 {
25 public:
26  struct DLLaterTierNetworkParams // all floats because they'll be normalised
27  {
28  float m_parentTrackScore = -999.f;
29  float m_childTrackScore = -999.f;
30  float m_parentNSpacepoints = -999.f;
31  float m_childNSpacepoints = -999.f;
32  float m_separation3D = -999.f;
33  float m_parentNuVertexSep = -999.f;
34  float m_childNuVertexSep = -999.f;
35  float m_parentEndRegionNHits = -999.f;
36  float m_parentEndRegionNParticles = -999.f;
37  float m_parentEndRegionRToWall = -999.f;
38  float m_vertexSeparation = -999.f;
39  float m_doesChildConnect = -999.f;
40  pandora::CartesianVector m_connectionPoint = pandora::CartesianVector(-999.f, -999.f, -999.f);
41  pandora::CartesianVector m_connectionDirection = pandora::CartesianVector(-999.f, -999.f, -999.f);
42  float m_overshootStartDCA = -999.f;
43  float m_overshootStartL = -999.f;
44  float m_overshootEndDCA = -999.f;
45  float m_overshootEndL = -999.f;
46  float m_childCPDCA = -999.f;
47  float m_childCPExtrapDistance = -999.f;
48  float m_childCPLRatio = -999.f;
49  float m_parentCPNUpstreamHits = -999.f;
50  float m_parentCPNDownstreamHits = -999.f;
51  float m_parentCPNHitRatio = -999.f;
52  float m_parentCPEigenvalueRatio = -999.f;
53  float m_parentCPOpeningAngle = -999.f;
54  float m_parentIsPOIClosestToNu = -999.f;
55  float m_childIsPOIClosestToNu = -999.f;
56 
64  void AddCommonParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const;
65 
73  void AddOrientationParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const;
74  };
75 
76  pandora::StatusCode Run(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pNeutrinoPfo,
77  const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo,
78  std::vector<DLLaterTierNetworkParams> &networkParamVector, float &laterTierScore);
79 
84 
85 private:
87  {
88  float m_trackScoreMin = -1.f;
89  float m_trackScoreMax = 1.f;
90  float m_nSpacepointsMin = 0.f;
91  float m_nSpacepointsMax = 2000.f;
92  float m_separation3DMin = -50.f;
93  float m_separation3DMax = 700.f;
94  float m_nuVertexSepMin = -100.f;
95  float m_nuVertexSepMax = 750.f;
96  float m_parentEndRegionNHitsMin = -10.f;
97  float m_parentEndRegionNHitsMax = 80.f;
98  float m_parentEndRegionNParticlesMin = -1.f;
99  float m_parentEndRegionNParticlesMax = 5.f;
100  float m_parentEndRegionRToWallMin = -10.f;
101  float m_parentEndRegionRToWallMax = 400.f;
102  float m_vertexSepMin = -50.f;
103  float m_vertexSepMax = 700.f;
104  float m_doesChildConnectMin = -1.f;
105  float m_doesChildConnectMax = 1.f;
106  float m_overshootDCAMin = -700.f;
107  float m_overshootDCAMax = 700.f;
108  float m_overshootLMin = -100.f;
109  float m_overshootLMax = 700.f;
110  float m_childCPDCAMin = -5.f;
111  float m_childCPDCAMax = 50.f;
112  float m_childCPExtrapDistanceMin = -500.f;
113  float m_childCPExtrapDistanceMax = 500.f;
114  float m_childCPLRatioMin = -1.f;
115  float m_childCPLRatioMax = 1.f;
116  float m_parentCPNHitsMin = -10.f;
117  float m_parentCPNHitsMax = 100.f;
118  float m_parentCPNHitRatioMin = -5.f;
119  float m_parentCPNHitRatioMax = 30.f;
120  float m_parentCPEigenvalueRatioMin = -5.f;
121  float m_parentCPEigenvalueRatioMax = 50.f;
122  float m_parentCPOpeningAngleMin = -10.f;
123  float m_parentCPOpeningAngleMax = 180.f;
124  };
125 
126  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
127 
136  bool IsShowerVertexUpstream(const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo) const;
137 
151  pandora::StatusCode CalculateNetworkVariables(const pandora::Algorithm *const pAlgorithm, const HierarchyPfo &parentHierarchyPfo,
152  const HierarchyPfo &childHierarchyPfo, const pandora::ParticleFlowObject *const pNeutrinoPfo, const bool useUpstreamForParent,
153  const bool useUpstreamForChild, DLLaterTierNetworkParams &laterTierNetworkParams) const;
154 
164  void SetCommonParams(const std::pair<float, float> &trackScoreParams, const std::pair<float, float> &nSpacepointsParams,
165  const float separation3D, DLLaterTierNetworkParams &laterTierNetworkParams) const;
166 
177  void SetVertexParams(const pandora::CartesianVector &nuVertex, const pandora::CartesianVector &parentStartPos,
178  const pandora::CartesianVector &parentEndPos, const pandora::CartesianVector &childStartPos,
179  DLLaterTierNetworkParams &laterTierNetworkParams) const;
180 
190  void SetEndRegionParams(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pParentPfo,
191  const pandora::CartesianVector &parentEndPos, DLLaterTierNetworkParams &laterTierNetworkParams) const;
192 
199  void SetEndRegionRToWall(const pandora::CartesianVector &parentEndPos, DLLaterTierNetworkParams &laterTierNetworkParams) const;
200 
211  void SetConnectionParams(const HierarchyPfo &parentHierarchyPfo, const pandora::CartesianVector &parentStartPos,
212  const ExtremalPoint &childStart, DLLaterTierNetworkParams &laterTierNetworkParams) const;
213 
223  std::pair<pandora::CartesianVector, bool> ExtrapolateChildToParent(
224  const pandora::CartesianVector &parentPosition, const ExtremalPoint &childStart) const;
225 
235  bool DoesConnect(const pandora::CartesianVector &boundary1, const pandora::CartesianVector &boundary2, const pandora::CartesianVector &testPoint) const;
236 
246  void SetOvershootParams(const ExtremalPoint &parentStart, const ExtremalPoint &parentEnd, const ExtremalPoint &childStart,
247  DLLaterTierNetworkParams &laterTierNetworkParams) const;
248 
257  void SetParentConnectionPointVars(const HierarchyPfo &parentHierarchyPfo, DLLaterTierNetworkParams &laterTierNetworkParams) const;
258 
264  void NormaliseNetworkParams(DLLaterTierNetworkParams &laterTierNetworkParams) const;
265 
276  float ClassifyTrackTrack(const DLLaterTierNetworkParams &edgeParamsUpUp, const DLLaterTierNetworkParams &edgeParamsUpDown,
277  const DLLaterTierNetworkParams &edgeParamsDownUp, const DLLaterTierNetworkParams &edgeParamsDownDown);
278 
290  pandora::FloatVector ClassifyTrackTrackEdge(const DLLaterTierNetworkParams &edgeParams, const DLLaterTierNetworkParams &otherEdgeParams1,
291  const DLLaterTierNetworkParams &otherEdgeParams2, const DLLaterTierNetworkParams &otherEdgeParams3);
292 
301  float ClassifyTrackShower(const DLLaterTierNetworkParams &edgeParamsUp, const DLLaterTierNetworkParams &edgeParamsDown);
302 
312  pandora::FloatVector ClassifyTrackShowerEdge(const DLLaterTierNetworkParams &edgeParams, const DLLaterTierNetworkParams &otherEdgeParams);
313 
314  // For model
323  // For tool
328  // For normalisation
329  bool m_normalise;
331 };
332 
333 } // namespace lar_dl_content
334 
335 #endif // #ifndef LAR_DL_LATER_TIER_HIERARCHY_TOOL_H
float m_parentNuVertexSep
the separation between the neutrino vertex and assumed parent start point
HierarchyPfo class.
float m_parentCPEigenvalueRatio
the ratio of the second eigenvalues of the downstream and upstream 3D hit groups (set if the child co...
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) ...
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) ...
float m_childCPDCA
the DCA of the child to the connection point (set if the child connects)
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)
Header file for the HierarchyPfo class.
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
float m_vertexSeparation
the separation between the parent and child POIs
LArDLHelper::TorchModel m_trackShowerBranchModel
the track-shower edge model
torch::jit::script::Module TorchModel
Definition: LArDLHelper.h:25
std::string m_trackShowerBranchModelName
the name of the track-shower edge model file
Header file for the DL base hierarchy tool.
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
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_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
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.
void AddCommonParamsToInput(int &insertIndex, LArDLHelper::TorchInput &modelInput) const
Add the orientation independent later tier network parameters to the model input tensor.
void NormaliseNetworkParams(DLLaterTierNetworkParams &laterTierNetworkParams) const
Shift and normalise the later tier network parameters.
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
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...
ExtremalPoint class.
float m_searchRegion
the dimensions of the box used to obtain the up/downstream 3D hit groups
Header file for the lar deep learning helper helper class.
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)
DLLaterTierHierarchyTool to apply the later-tier hierarchy DL networks.
float ClassifyTrackTrack(const DLLaterTierNetworkParams &edgeParamsUpUp, const DLLaterTierNetworkParams &edgeParamsUpDown, const DLLaterTierNetworkParams &edgeParamsDownUp, const DLLaterTierNetworkParams &edgeParamsDownDown)
Apply the track-track parent-child classification network.
float m_parentEndRegionRToWall
the smallest parent POI to detector boundary separation
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
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)
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
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...
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...
std::string m_trackShowerClassifierModelName
the name of the track-shower classification model file
LArDLHelper::TorchModel m_trackTrackBranchModel
the track-track edge model
float m_childCPExtrapDistance
the extension distance of the child to the DCA point (set if the child connects)
float m_parentIsPOIClosestToNu
whether the parent POI is that closest to the neutrino vertex
pandora::CartesianVector m_connectionDirection
the parent&#39;s direction at the connection point
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_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