LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DlSNSignalAlgorithm.h
Go to the documentation of this file.
1 
8 #ifndef LAR_DL_SIGNAL_ALGORITHM_H
9 #define LAR_DL_SIGNAL_ALGORITHM_H 1
10 
11 #include "Pandora/Algorithm.h"
12 #include "Pandora/AlgorithmHeaders.h"
13 
15 
17 
18 #include <random>
19 
20 using namespace lar_content;
21 
22 namespace lar_dl_content
23 {
27 class DlSNSignalAlgorithm : public pandora::Algorithm
28 {
29 public:
30  typedef std::map<std::pair<int, int>, std::vector<const pandora::CaloHit *>> PixelToCaloHitsMap;
31 
36 
37  virtual ~DlSNSignalAlgorithm();
38 
39 private:
40  typedef std::pair<int, int> Pixel; // A Pixel is a row, column pair
41  typedef std::map<const pandora::CaloHit *, Pixel> PixelMap; //A mapping between a CaloHit and a Pixel in the canvas
42 
43  pandora::StatusCode Run();
44  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
45  pandora::StatusCode PrepareTrainingSample();
46  pandora::StatusCode Infer();
47  pandora::StatusCode CheatedSeparation();
48 
49  /*
50  * @brief Create input for the network from a calo hit list
51  *
52  * @param caloHits The CaloHitList from which the input should be made
53  * @param view The wire plane view
54  * @param xMin The minimum x coordinate for the hits
55  * @param xMax The maximum x coordinate for the hits
56  * @param zMin The minimum x coordinate for the hits
57  * @param zMax The maximum x coordinate for the hits
58  * @param networkInput The TorchInput object to populate
59  * @param pixelVector The output vector of populated pixels
60  *
61  * @return The StatusCode resulting from the function
62  **/
63  pandora::StatusCode MakeNetworkInputFromHits(const pandora::CaloHitList &caloHits, const pandora::HitType view, const float xMin,
64  const float xMax, const float zMin, const float zMax, LArDLHelper::TorchInput &networkInput, PixelMap &pixelMap) const;
65 
66  /*
67  * @brief Retrieve the map from MC to calo hits for reconstructable particles
68  *
69  * @param mcToHitsMap The map to populate
70  *
71  * @return The StatusCode resulting from the function
72  **/
73  pandora::StatusCode GetMCToHitsMap(LArMCParticleHelper::MCContributionMap &mcToHitsMap) const;
74 
75  /*
76  * @brief Construct a list of the MC particles from the MC to calo hits map, completing the interaction hierarchy with the invisible
77  * upstream particles.
78  *
79  * @param mcToHitsMap The map of reconstructible MC particles to calo hits
80  * @param mcHierarchy The output list of MC particles representing the interaction
81  *
82  * @return The StatusCode resulting from the function
83  **/
84  pandora::StatusCode CompleteMCHierarchy(const LArMCParticleHelper::MCContributionMap &mcToHitsMap, pandora::MCParticleList &mcHierarchy) const;
85 
86  /*
87  * @brief Determine the physical bounds associated with a CaloHitList.
88  *
89  * @param caloHitList The CaloHitList for which bounds should be determined
90  * @param xMin The output minimum x value
91  * @param xMax The output maximum x value
92  * @param zMin The output minimum z value
93  * @param zMax The output maximum z value
94  *
95  * @return The StatusCode resulting from the function
96  */
97  void GetHitRegion(const pandora::CaloHitList &caloHitList, float &xMin, float &xMax, float &zMin, float &zMax) const;
98 
100  std::string m_trainingOutputFile;
101  std::string m_inputSignalListName;
102  pandora::StringVector m_caloHitListNames;
106  int m_event;
107  int m_pass;
108  int m_height;
109  int m_width;
110  float m_driftStep;
111  bool m_visualise;
112  bool m_writeTree;
113  std::string m_rootTreeName;
114  std::string m_rootFileName;
115  std::mt19937 m_rng;
116  bool m_printOut;
117  std::string m_signalListNameU;
118  std::string m_signalListNameV;
119  std::string m_signalListNameW;
120  std::string m_signalListName2D;
121  std::string m_caloHitListName2D;
122  pandora::StringVector m_inputCaloHitListNames;
123  std::string m_backgroundListName;
126  long unsigned int m_passOneTrustThreshold;
127  const int PHOTON_CLASS{2};
128  const int ELECTRON_CLASS{3};
129  const int SIGNAL_CLASS{2};
130 };
131 
132 } // namespace lar_dl_content
133 
134 #endif // LAR_DL_SIGNAL_ALGORITHM_H
std::string m_signalListNameV
Output signal CaloHitListV name.
std::string m_rootFileName
The ROOT file name.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
int m_width
The width of the images.
std::string m_caloHitListName2D
Input CaloHitList2D name.
int m_height
The height of the images.
pandora::StringVector m_caloHitListNames
Names of input calo hit lists.
std::string m_signalListNameW
Output signal CaloHitListW name.
torch::jit::script::Module TorchModel
Definition: LArDLHelper.h:25
std::map< std::pair< int, int >, std::vector< const pandora::CaloHit * > > PixelToCaloHitsMap
int m_pass
The pass of the train/infer step.
LArDLHelper::TorchModel m_modelU
The model for the U view.
LArDLHelper::TorchModel m_modelW
The model for the W view.
std::string m_trainingOutputFile
Output file name for training examples.
bool m_visualise
Whether or not to visualise the candidate vertices.
std::string m_rootTreeName
The ROOT tree name.
std::string m_inputSignalListName
Input vertex list name if 2nd pass.
Header file for the lar monte carlo particle helper helper class.
Header file for the lar deep learning helper helper class.
std::string m_backgroundListName
Input Background CaloHitList name.
long unsigned int m_passOneTrustThreshold
Number of pixels in pass one required to trust the wire finding ability, below this threshold...
std::mt19937 m_rng
The random number generator.
pandora::StringVector m_inputCaloHitListNames
Names of input calo hit lists, passed from Pass 1 of DLSignalAlg.
int m_event
The current event number.
std::string m_signalListName2D
Output signal CaloHitList2D name.
bool m_applyCheatedSeparation
Whether cheating to separate background and signal hits.
LArDLHelper::TorchModel m_modelV
The model for the V view.
HitType
Definition: HitType.h:12
float m_driftStep
The size of a pixel in the drift direction in cm (most relevant in pass 2)
bool m_printOut
Whether or not to print out network outputs of CaloHitList names and sizes.
DeepLearningSignalIdAlgorithm class.
bool m_simpleZoom
Decide whethere to run a simple loop to find highest adc hit or run network.
std::map< const pandora::CaloHit *, Pixel > PixelMap
bool m_writeTree
Whether or not to write validation details to a ROOT tree.
std::string m_signalListNameU
Output signal CaloHitListU name.