LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DlVertexingAlgorithm.h
Go to the documentation of this file.
1 
8 #ifndef LAR_DL_VERTEXING_ALGORITHM_H
9 #define LAR_DL_VERTEXING_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 DlVertexingAlgorithm : public pandora::Algorithm
28 {
29 public:
30  typedef std::map<std::pair<int, int>, std::vector<const pandora::CaloHit *>> PixelToCaloHitsMap;
31 
36 
37  virtual ~DlVertexingAlgorithm();
38 
39 private:
41  {
42  public:
43  VertexTuple(const pandora::Pandora &pandora, const pandora::CartesianVector &vertexU, const pandora::CartesianVector &vertexV,
44  const pandora::CartesianVector &vertexW);
45 
46  VertexTuple(const pandora::Pandora &pandora, const pandora::CartesianVector &vertex1, const pandora::CartesianVector &vertex2,
47  const pandora::HitType view1, const pandora::HitType view2);
48 
49  const pandora::CartesianVector &GetPosition() const;
50  float GetChi2() const;
51  std::string ToString() const;
52 
53  private:
54  pandora::CartesianVector m_pos;
55  float m_chi2;
56  };
57 
58  typedef std::pair<int, int> Pixel; // A Pixel is a row, column pair
59  typedef std::vector<Pixel> PixelVector;
60 
61  pandora::StatusCode Run();
62  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
63  pandora::StatusCode PrepareTrainingSample();
64  pandora::StatusCode Infer();
65 
66  /*
67  * @brief Create input for the network from a calo hit list
68  *
69  * @param caloHits The CaloHitList from which the input should be made
70  * @param view The wire plane view
71  * @param xMin The minimum x coordinate for the hits
72  * @param xMax The maximum x coordinate for the hits
73  * @param zMin The minimum x coordinate for the hits
74  * @param zMax The maximum x coordinate for the hits
75  * @param networkInput The TorchInput object to populate
76  * @param pixelVector The output vector of populated pixels
77  *
78  * @return The StatusCode resulting from the function
79  **/
80  pandora::StatusCode MakeNetworkInputFromHits(const pandora::CaloHitList &caloHits, const pandora::HitType view, const float xMin,
81  const float xMax, const float zMin, const float zMax, LArDLHelper::TorchInput &networkInput, PixelVector &pixelVector) const;
82 
83  /*
84  * @brief Create a list of wire plane-space coordinates from a canvas
85  *
86  * @param canvas The input canvas
87  * @param canvasWidth The width of the canvas
88  * @param canvasHeight The height of the canvas
89  * @param columnOffset The column offset used when populating the canvas
90  * @param rowOffset The row offset used when populating the canvas
91  * @param xMin The minimum x coordinate for the hits
92  * @param xMax The maximum x coordinate for the hits
93  * @param zMin The minimum x coordinate for the hits
94  * @param zMax The maximum x coordinate for the hits
95  * @param positionVector The output vector of wire plane positions
96  *
97  * @return The StatusCode resulting from the function
98  **/
99  pandora::StatusCode MakeWirePlaneCoordinatesFromCanvas(float **canvas, const int canvasWidth, const int canvasHeight,
100  const int columnOffset, const int rowOffset, const pandora::HitType view, const float xMin, const float xMax, const float zMin,
101  const float zMax, pandora::CartesianPointVector &positionVector) const;
102 
116  void GetCanvasParameters(const LArDLHelper::TorchOutput &networkOutput, const PixelVector &pixelVector, int &columnOffset,
117  int &rowOffset, int &width, int &height) const;
118 
139  void DrawRing(float **canvas, const int row, const int col, const int inner, const int outer, const float weight) const;
140 
152  void Update(const int radius, int &col, int &row) const;
153 
154  /*
155  * @brief Retrieve the map from MC to calo hits for reconstructable particles
156  *
157  * @param mcToHitsMap The map to populate
158  *
159  * @return The StatusCode resulting from the function
160  **/
161  pandora::StatusCode GetMCToHitsMap(LArMCParticleHelper::MCContributionMap &mcToHitsMap) const;
162 
163  /*
164  * @brief Construct a list of the MC particles from the MC to calo hits map, completing the interaction hierarchy with the invisible
165  * upstream particles.
166  *
167  * @param mcToHitsMap The map of reconstructible MC particles to calo hits
168  * @param mcHierarchy The output list of MC particles representing the interaction
169  *
170  * @return The StatusCode resulting from the function
171  **/
172  pandora::StatusCode CompleteMCHierarchy(const LArMCParticleHelper::MCContributionMap &mcToHitsMap, pandora::MCParticleList &mcHierarchy) const;
173 
174  /*
175  * @brief Determine the physical bounds associated with a CaloHitList.
176  *
177  * @param caloHitList The CaloHitList for which bounds should be determined
178  * @param xMin The output minimum x value
179  * @param xMax The output maximum x value
180  * @param zMin The output minimum z value
181  * @param zMax The output maximum z value
182  *
183  * @return The StatusCode resulting from the function
184  */
185  void GetHitRegion(const pandora::CaloHitList &caloHitList, float &xMin, float &xMax, float &zMin, float &zMax) const;
186 
194  pandora::StatusCode MakeCandidateVertexList(const pandora::CartesianPointVector &positions);
195 
199  void GetTrueVertexPosition(float &x, float &y, float &z) const;
200 
204  void GetTrueVertexPosition(float &x, float &u, float &v, float &w) const;
205 
209  const pandora::CartesianVector &GetTrueVertex() const;
210 
211 #ifdef MONITORING
212 
215  void PopulateRootTree(const std::vector<VertexTuple> &vertexTuples, const pandora::CartesianPointVector &vertexCandidatesU,
216  const pandora::CartesianPointVector &vertexCandidatesV, const pandora::CartesianPointVector &vertexCandidatesW) const;
217 #endif
218 
220  std::string m_trainingOutputFile;
221  std::string m_inputVertexListName;
223  pandora::StringVector m_caloHitListNames;
227  int m_event;
228  int m_pass;
230  int m_height;
231  int m_width;
232  float m_driftStep;
233  bool m_visualise;
234  bool m_writeTree;
235  std::string m_rootTreeName;
236  std::string m_rootFileName;
237  std::mt19937 m_rng;
238  std::vector<double> m_thresholds;
239  std::string m_volumeType;
240 };
241 
242 } // namespace lar_dl_content
243 
244 #endif // LAR_DL_VERTEXING_ALGORITHM_H
Float_t x
Definition: compare.C:6
pandora::CartesianVector m_pos
Calculated 3D position.
LArDLHelper::TorchModel m_modelU
The model for the U view.
std::vector< double > m_thresholds
Distance class thresholds.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
bool m_visualise
Whether or not to visualise the candidate vertices.
int m_event
The current event number.
pandora::StringVector m_caloHitListNames
Names of input calo hit lists.
torch::jit::script::Module TorchModel
Definition: LArDLHelper.h:25
LArDLHelper::TorchModel m_modelV
The model for the V view.
bool Update(detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, PFPStruct &pfp)
Definition: PFPUtils.cxx:1055
std::string m_outputVertexListName
Output vertex list name.
std::mt19937 m_rng
The random number generator.
int m_nClasses
The number of distance classes.
std::string m_rootTreeName
The ROOT tree name.
Header file for the lar monte carlo particle helper helper class.
DeepLearningTrackShowerIdAlgorithm class.
Float_t radius
Definition: plot.C:23
Int_t col[ntarg]
Definition: Style.C:29
bool m_writeTree
Whether or not to write validation details to a ROOT tree.
Header file for the lar deep learning helper helper class.
int m_height
The height of the images.
int m_pass
The pass of the train/infer step.
std::map< std::pair< int, int >, std::vector< const pandora::CaloHit * > > PixelToCaloHitsMap
std::string m_inputVertexListName
Input vertex list name if 2nd pass.
double weight
Definition: plottest35.C:25
LArDLHelper::TorchModel m_modelW
The model for the W view.
std::string m_trainingOutputFile
Output file name for training examples.
std::string m_rootFileName
The ROOT file name.
HitType
Definition: HitType.h:12
float m_driftStep
The size of a pixel in the drift direction in cm (most relevant in pass 2)
int m_width
The width of the images.
Float_t w
Definition: plot.C:20
float m_chi2
Chi squared of calculated position.
std::string m_volumeType
The name of the fiducial volume type for the monitoring output.