LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
DLNeutrinoHierarchyAlgorithm.h
Go to the documentation of this file.
1 
8 #ifndef LAR_DL_NEUTRINO_HIERARCHY_ALGORITHM_H
9 #define LAR_DL_NEUTRINO_HIERARCHY_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 
15 
20 
21 using namespace lar_content;
22 
23 namespace lar_dl_content
24 {
25 
26 //------------------------------------------------------------------------------------------------------------------------------------------
27 
31 class DLNeutrinoHierarchyAlgorithm : public pandora::Algorithm
32 {
33 public:
38 
43 
44 private:
45  typedef std::map<const pandora::ParticleFlowObject *, const pandora::MCParticle *> PfoToMCParticleMap;
46  typedef std::map<const pandora::ParticleFlowObject *, std::pair<const pandora::ParticleFlowObject *, int>> ChildToParentPfoMap;
47  typedef std::vector<pandora::PfoVector> Hierarchy;
48 
49  pandora::StatusCode Run();
50 
58  bool GetNeutrinoPfo(const pandora::ParticleFlowObject *&pNeutrinoPfo) const;
59 
67  void FillTrackShowerVectors(const pandora::ParticleFlowObject *const pNeutrinoPfo, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos) const;
68 
81  bool GetExtremalVerticesAndDirections(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::ParticleFlowObject *const pPfo,
82  const ThreeDSlidingFitResult &slidingFitResult, ExtremalPoint &upstreamPoint, ExtremalPoint &downstreamPoint) const;
83 
94  bool GetShowerDirection(
95  const pandora::ParticleFlowObject *const pPfo, const pandora::CartesianVector &vertex, pandora::CartesianVector &direction) const;
96 
104  void SetPrimaryScores(const pandora::ParticleFlowObject *const pNeutrinoPfo, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos) const;
105 
115  float GetPrimaryScore(
116  const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfo &hierarchyPfo) const;
117 
131  void UpdateHierarchy(const pandora::ParticleFlowObject *const pNeutrinoPfo, const bool buildPrimaryTier, const bool usePrimaryScore,
132  const float trackThreshold, const float showerThreshold, const bool isLowerThreshold, HierarchyPfoVector &trackPfos,
133  HierarchyPfoVector &showerPfos, Hierarchy &hierarchy) const;
134 
143  void SetLaterTierScores(const pandora::ParticleFlowObject *const pNeutrinoPfo, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos) const;
144 
155  float GetLaterTierScore(const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfo &parentPfo, const HierarchyPfo &childPfo) const;
156 
164  void BuildPandoraHierarchy(const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos,
165  const HierarchyPfoVector &showerPfos) const;
166 
167  //------------------------------------------------------------------------------------------------------------------------------------------
168  // Training functions
169  //------------------------------------------------------------------------------------------------------------------------------------------
170 
178  bool ShouldTrainOnEvent(const pandora::ParticleFlowObject *const pNeutrinoPfo) const;
179 
187  void GetParticleIDMap(const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos,
188  std::map<const pandora::ParticleFlowObject *, int> &particleIDMap) const;
189 
201  std::pair<float, float> GetTrainingCuts(const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo,
202  const bool trueParentOrientation, const bool trueChildOrientation) const;
203 
214  void FillEventTree(const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos, const int nPrimaryTrackLinks,
215  const int nPrimaryShowerLinks, const int nLaterTierTrackTrackLinks, const int nLaterTierTrackShowerLinks) const;
216 
229  void FillPrimaryTrees(const PfoToMCParticleMap &matchingMap, const ChildToParentPfoMap &childToParentPfoMap,
230  const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos,
231  const std::map<const pandora::ParticleFlowObject *, int> &particleIDMap, int &nPrimaryTrackLinks, int &nPrimaryShowerLinks) const;
232 
246  void FillPrimaryTree(const std::string &treeName, const bool isTrainingLink, const bool isTrueLink, const bool isOrientationCorrect,
247  const int trueVisibleGen, const int truePDG, const int trueParentID, const int particleID,
248  const DLPrimaryHierarchyTool::DLPrimaryNetworkParams &primaryNetworkParams) const;
249 
262  void FillLaterTierTrees(const PfoToMCParticleMap &matchingMap, const ChildToParentPfoMap &childToParentPfoMap,
263  const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos,
264  const std::map<const pandora::ParticleFlowObject *, int> &particleIDMap, int &nTrackLinks, int &nShowerLinks) const;
265 
279  void FillLaterTierTree(const std::string &treeName, const bool isTrainingLink, const bool isTrueLink, const bool isOrientationCorrect,
280  const int childTrueGen, const std::pair<float, float> &trainingCuts, const int parentID, const int childID,
281  const DLLaterTierHierarchyTool::DLLaterTierNetworkParams &networkParams) const;
282 
283  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
284 
285  int m_eventID;
287  std::string m_trainingFileName;
288  std::string m_eventTreeName;
293  std::string m_mcParticleListName;
295  std::string m_neutrinoPfoListName;
296  pandora::StringVector m_pfoListNames;
297  unsigned int m_minClusterSize;
313 };
314 
315 } // namespace lar_dl_content
316 
317 #endif // #ifndef LAR_DL_NEUTRINO_HIERARCHY_ALGORITHM_H
float m_primaryThresholdTrackPass2
The threshold applied to tracks in pass 2 primary tier building.
HierarchyPfo class.
float m_primaryThresholdShowerPass2
The threshold applied to showers in pass 2 primary tier building.
Header file for the pfo helper class.
float m_laterTierThresholdTrackPass2
The threshold applied to track-track links in pass 2 later tier building.
std::string m_primaryTrackTreeName
the name of the output primary track link tree
pandora::StringVector m_pfoListNames
the name of the pfo lists
std::string m_primaryShowerTreeName
the name of the output primary shower link tree
float m_primaryThresholdTrackPass1
The threshold applied to tracks in pass 1 primary tier building.
std::string m_mcParticleListName
the name of the MCParticle list
Header file for the HierarchyPfo class.
Header file for the DL primary hierarchy tool.
std::string m_laterTierTrackTrackTreeName
the name of the output track-track later tier link tree
std::map< const pandora::ParticleFlowObject *, std::pair< const pandora::ParticleFlowObject *, int > > ChildToParentPfoMap
std::vector< HierarchyPfo > HierarchyPfoVector
DLCheatHierarchyTool to calculate variables related to the initial shower region. ...
Header file for the cheat hierarchy tool.
ExtremalPoint class.
std::string m_neutrinoPfoListName
the name of the neutrino pfo list
std::string m_laterTierTrackShowerTreeName
the name of the output track-shower later tier link tree
std::string m_trainingFileName
the name of the output training file
DLLaterTierHierarchyTool to apply the later-tier hierarchy DL networks.
bool m_trainingMode
whether to run in training mode
Header file for the lar three dimensional sliding fit result class.
float m_primaryRegion
the radius of the nu vertex region where particles are assumed to be primaries
float m_primaryThresholdShowerPass1
The threshold applied to showers in pass 1 primary tier building.
int m_slidingFitWindow
the sliding fit window to use in pfo sliding linear fits
DLLaterTierHierarchyTool * m_laterTierHierarchyTool
The tool used to build the later tiers.
float m_regionForDirFit
the radius of the region used in shower direction fits
float m_laterTierThresholdTrackPass1
The threshold applied to track-track links in pass 1 later tier building.
DLPrimaryHierarchyTool * m_primaryHierarchyTool
The tool used to build the primary tiers.
std::string m_eventTreeName
the name of the output event tree
unsigned int m_minClusterSize
the minimum threshold of 3D hits of a considered pfo
DLPrimaryHierarchyTool to apply the primary hierarchy DL networks.
float m_laterTierThresholdShowerPass2
The threshold applied to track-shower links in pass 2 later tier building.
DLCheatHierarchyTool * m_cheatHierarchyTool
The tool used to obtain the true hierarchy.
int m_nAngularBins
the number of angle bins used by the shower direction fitter
Header file for the DL later hierarchy tool.
std::map< const pandora::ParticleFlowObject *, const pandora::MCParticle * > PfoToMCParticleMap
float m_trainingVertexAccuracy
the maximum true-reco nu vertex displacement allowed for training
float m_laterTierThresholdShowerPass1
The threshold applied to track-shower links in pass 1 later tier building.
vertex reconstruction