All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrainedVertexSelectionAlgorithm.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArVertex/TrainedVertexSelectionAlgorithm.h
3  *
4  * @brief Header file for the trained vertex selection algorithm class.
5  *
6  * $Log: $
7  */
8 #ifndef LAR_TRAINED_VERTEX_SELECTION_ALGORITHM_H
9 #define LAR_TRAINED_VERTEX_SELECTION_ALGORITHM_H 1
10 
11 #include "Api/PandoraContentApi.h"
12 
16 
18 
20 
21 #include <random>
22 
23 namespace lar_content
24 {
25 
26 template <typename, unsigned int>
27 class KDTreeLinkerAlgo;
28 template <typename, unsigned int>
29 class KDTreeNodeInfoT;
30 
31 //------------------------------------------------------------------------------------------------------------------------------------------
32 
33 /**
34  * @brief TrainedVertexSelectionAlgorithm class
35  */
37 {
38 public:
39  /**
40  * @brief Vertex feature info class
41  */
43  {
44  public:
45  /**
46  * @brief Constructor
47  *
48  * @param beamDeweighting the beam deweighting feature
49  * @param rPhiFeature the r/phi feature
50  * @param energyKick the energy kick feature
51  * @param localAsymmetry the local asymmetry feature
52  * @param globalAsymmetry the global asymmetry feature
53  * @param showerAsymmetry the shower asymmetry feature
54  * @param dEdxAsymmetry the dE/dx asymmetry feature
55  * @param vertexEnergy the vertex energy feature
56  */
57  VertexFeatureInfo(const float beamDeweighting, const float rPhiFeature, const float energyKick, const float localAsymmetry,
58  const float globalAsymmetry, const float showerAsymmetry, const float dEdxAsymmetry, const float vertexEnergy);
59 
60  float m_beamDeweighting; ///< The beam deweighting feature
61  float m_rPhiFeature; ///< The r/phi feature
62  float m_energyKick; ///< The energy kick feature
63  float m_localAsymmetry; ///< The local asymmetry feature
64  float m_globalAsymmetry; ///< The global asymmetry feature
65  float m_showerAsymmetry; ///< The shower asymmetry feature
66  float m_dEdxAsymmetry; ///< The dE/dx asymmetry feature
67  float m_vertexEnergy; ///< The vertex energy feature
68  };
69 
70  typedef std::map<const pandora::Vertex *const, VertexFeatureInfo> VertexFeatureInfoMap;
71 
72  //--------------------------------------------------------------------------------------------------------------------------------------
73 
74  /**
75  * @brief Shared vertex feature info class
76  */
78  {
79  public:
80  /**
81  * @brief Constructor
82  *
83  * @param m_separation the distance between the two vertices
84  * @param m_axisHits the hit density along the axis between the two vertices
85  */
86  VertexSharedFeatureInfo(const float separation, const float axisHits);
87 
88  float m_separation; ///< The distance between the two vertices
89  float m_axisHits; ///< The hit density along the axis between the two vertices
90  };
91 
92  //--------------------------------------------------------------------------------------------------------------------------------------
93 
94  /**
95  * @brief Event feature info class
96  */
98  {
99  public:
100  /**
101  * @brief Constructor
102  *
103  * @param eventShoweryness the event showeryness feature
104  * @param eventEnergy the energy of the event
105  * @param eventArea the area of the event
106  * @param longitudinality the longitudinality of the event
107  * @param nHits the number of hits in the event
108  * @param nClusters the number of clusters in the event
109  * @param nCandidates the total number of vertex candidates
110  */
111  EventFeatureInfo(const float eventShoweryness, const float eventEnergy, const float eventArea, const float longitudinality,
112  const unsigned int nHits, const unsigned int nClusters, const unsigned int nCandidates);
113 
114  float m_eventShoweryness; ///< The event showeryness feature
115  float m_eventEnergy; ///< The event energy
116  float m_eventArea; ///< The area of the event
117  float m_longitudinality; ///< The longitudinality of the event
118  unsigned int m_nHits; ///< The number of hits in the event
119  unsigned int m_nClusters; ///< The number of clusters in the event
120  unsigned int m_nCandidates; ///< The total number of vertex candidates
121  };
122 
123  //--------------------------------------------------------------------------------------------------------------------------------------
124 
125  /**
126  * @brief Default constructor
127  */
129 
130 protected:
131  typedef std::pair<pandora::CartesianVector, pandora::CartesianVector> ClusterEndPoints;
132  typedef std::map<const pandora::Cluster *const, ClusterEndPoints> ClusterEndPointsMap;
133  typedef std::vector<LArMvaHelper::MvaFeatureVector> FeatureListVector;
134  typedef std::vector<pandora::VertexVector> VectorOfVertexVectors;
135 
136  /**
137  * @brief Get the vertex score list
138  *
139  * @param vertexVector the vector of vertices
140  * @param beamConstants the beam constants
141  * @param kdTreeU the hit kd tree for the U view
142  * @param kdTreeV the hit kd tree for the V view
143  * @param kdTreeW the hit kd tree for the W view
144  * @param vertexScoreList the vertex score list to fill
145  */
146  virtual void GetVertexScoreList(const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU,
147  HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const = 0;
148 
149  /**
150  * @brief Calculate the shower cluster map for a cluster list
151  *
152  * @param inputClusterList the input cluster list
153  * @param showerClusterList the shower cluster list to populate
154  */
155  void CalculateShowerClusterList(const pandora::ClusterList &inputClusterList, ShowerClusterList &showerClusterList) const;
156 
157  /**
158  * @brief Add the endpoints of any shower-like clusters to the map
159  *
160  * @param clusterList the list of clusters
161  * @param showerLikeClusters the list of shower-like clusters to populate
162  * @param clusterEndPointsMap the map of shower-like cluster endpoints to populate
163  */
165  const pandora::ClusterList &clusterList, pandora::ClusterList &showerLikeClusters, ClusterEndPointsMap &clusterEndPointsMap) const;
166 
169  typedef std::vector<HitKDNode2D> HitKDNode2DList;
170 
171  typedef std::unordered_map<const pandora::CaloHit *, const pandora::Cluster *> HitToClusterMap;
172 
173  /**
174  * @brief Populate kd tree with information about hits in a provided list of clusters
175  *
176  * @param clusterList the list of clusters
177  * @param kdTree to receive the populated kd tree
178  * @param hitToClusterMap to receive the populated hit to cluster map
179  */
180  void PopulateKdTree(const pandora::ClusterList &clusterList, HitKDTree2D &kdTree, HitToClusterMap &hitToClusterMap) const;
181 
182  /**
183  * @brief Try to add an available cluster to a given shower cluster, using shower clustering approximation
184  *
185  * @param clusterEndPointsMap the map of shower-like cluster endpoints
186  * @param availableShowerLikeClusters the list of shower-like clusters still available
187  * @param pCluster the cluster in the shower cluster from which to consider distances
188  * @param showerCluster the shower cluster
189  *
190  * @return boolean
191  */
192  bool AddClusterToShower(const ClusterEndPointsMap &clusterEndPointsMap, pandora::ClusterList &availableShowerLikeClusters,
193  const pandora::Cluster *const pCluster, pandora::ClusterList &showerCluster) const;
194 
195  /**
196  * @brief Try to add an available cluster to a given shower cluster, using cluster hit positions cached in kd tree
197  *
198  * @param kdTree the kd tree, used purely for efficiency in events with large hit multiplicity
199  * @param hitToClusterMap the hit to cluster map, used to interpret kd tree findings
200  * @param availableShowerLikeClusters the list of shower-like clusters still available
201  * @param pCluster the cluster in the shower cluster from which to consider distances
202  * @param showerCluster the shower cluster
203  *
204  * @return boolean
205  */
206  bool AddClusterToShower(HitKDTree2D &kdTree, const HitToClusterMap &hitToClusterMap, pandora::ClusterList &availableShowerLikeClusters,
207  const pandora::Cluster *const pCluster, pandora::ClusterList &showerCluster) const;
208 
209  /**
210  * @brief Calculate the event parameters
211  *
212  * @param clusterListU the U-view cluster list
213  * @param clusterListV the V-view cluster list
214  * @param clusterListW the W-view cluster list
215  * @param vertexVector the vector of vertex candidates
216  *
217  * @return the EventFeatureInfo object
218  */
219  EventFeatureInfo CalculateEventFeatures(const pandora::ClusterList &clusterListU, const pandora::ClusterList &clusterListV,
220  const pandora::ClusterList &clusterListW, const pandora::VertexVector &vertexVector) const;
221 
222  /**
223  * @brief Increment the showery hit parameters for a cluster list
224  *
225  * @param clusterList the cluster list
226  * @param nShoweryHits the number of showery hits
227  * @param nHits the number of hits
228  * @param eventEnergy the event energy
229  */
230  void IncrementShoweryParameters(const pandora::ClusterList &clusterList, unsigned int &nShoweryHits, unsigned int &nHits, float &eventEnergy) const;
231 
232  /**
233  * @brief Find whether a cluster is shower-like
234  *
235  * @param pCluster the cluster
236  *
237  * @return boolean
238  */
239  bool IsClusterShowerLike(const pandora::Cluster *const pCluster) const;
240 
241  /**
242  * @brief Get the event shape features
243  *
244  * @param clusterList the cluster list
245  * @param eventVolume the event volume
246  * @param longitudinality the event longitudinality
247  */
248  void GetLegacyEventShapeFeatures(const pandora::ClusterList &clusterList, float &eventVolume, float &longitudinality) const;
249 
250  /**
251  * @brief Get the event shape features
252  *
253  * @param clusterList the map of cluster lists for each view
254  * @param eventArea the event area
255  * @param longitudinality the event longitudinality
256  */
257  void GetEventShapeFeatures(const ClusterListMap &clusterListMap, float &eventArea, float &longitudinality) const;
258 
259  /**
260  * @brief Get the coordinate span in one view
261  *
262  * @param clusterList the cluster list in one view
263  * @param xSpan the coordinate span in the drift direction
264  * @param zSpan the coordinate span in the wire direction
265  */
266  void Get2DSpan(const pandora::ClusterList &clusterList, float &xSpan, float &zSpan) const;
267 
268  /**
269  * @brief Update the min/max coordinate spans
270  *
271  * @param minPositionCoord the min position coordinate
272  * @param maxPositionCoord the max position coordinate
273  * @param minCoord the current min coordinate
274  * @param maxCoord the current max coordinate
275  */
277  const float minPositionCoord, const float maxPositionCoord, pandora::InputFloat &minCoord, pandora::InputFloat &maxCoord) const;
278 
279  /**
280  * @brief Get the coordinate span
281  *
282  * @param minCoord the min coordinate
283  * @param maxCoord the max coordinate
284  *
285  * @return the coordinate span
286  */
287  float GetCoordinateSpan(const pandora::InputFloat &minCoord, const pandora::InputFloat &maxCoord) const;
288 
289  /**
290  * @brief Add the event features to a vector in the correct order
291  *
292  * @param eventFeatureInfo the event feature info
293  * @param featureVector the vector of doubles to append
294  */
295  void AddEventFeaturesToVector(const EventFeatureInfo &eventFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const;
296 
297  /**
298  * @brief Populate the vertex feature info map for a given vertex
299  *
300  * @param beamConstants the beam constants
301  * @param clusterListMap the cluster list map
302  * @param slidingFitDataListMap the sliding fit data list map
303  * @param showerClusterListMap the shower cluster list map
304  * @param kdTreeMap the kd tree map
305  * @param pVertex the vertex
306  * @param vertexFeatureInfoMap the map to populate
307  */
308  void PopulateVertexFeatureInfoMap(const BeamConstants &beamConstants, const ClusterListMap &clusterListMap,
309  const SlidingFitDataListMap &slidingFitDataListMap, const ShowerClusterListMap &showerClusterListMap, const KDTreeMap &kdTreeMap,
310  const pandora::Vertex *const pVertex, VertexFeatureInfoMap &vertexFeatureInfoMap) const;
311 
312  /**
313  * @brief Populate the initial vertex score list for a given vertex
314  *
315  * @param vertexFeatureInfoMap the vertex feature info map
316  * @param pVertex the vertex
317  * @param initialScoreList the score list to populate
318  */
319  void PopulateInitialScoreList(VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pVertex, VertexScoreList &initialScoreList) const;
320 
321  /**
322  * @brief Get the list of top-N separated vertices
323  *
324  * @param initialScoreList the initial score list
325  * @param bestRegionVertices the list of best region vertices populate
326  */
327  void GetBestRegionVertices(VertexScoreList &initialScoreList, pandora::VertexVector &bestRegionVertices) const;
328 
329  /**
330  * @brief Produce the region and vertex training sets
331  *
332  * @param vertexVector the vector of all vertices
333  * @param bestRegionVertices the best region vertices
334  * @param vertexFeatureInfoMap the vertex feature info map
335  * @param eventFeatureList the list of event features
336  * @param kdTreeMap
337  */
338  void ProduceTrainingSets(const pandora::VertexVector &vertexVector, const pandora::VertexVector &bestRegionVertices,
339  VertexFeatureInfoMap &vertexFeatureInfoMap, const LArMvaHelper::MvaFeatureVector &eventFeatureList, const KDTreeMap &kdTreeMap) const;
340 
341  /**
342  * @brief Calculate the r/phi scores for the vertices in a vector, possibly erasing those that fail the fast score test
343  *
344  * @param vertexVector the vector of vertices
345  * @param vertexFeatureInfoMap the vertex feature info map
346  * @param kdTreeMap the kd tree map
347  */
348  void CalculateRPhiScores(pandora::VertexVector &vertexVector, VertexFeatureInfoMap &vertexFeatureInfoMap, const KDTreeMap &kdTreeMap) const;
349 
350  /**
351  * @brief Get the interaction type string
352  *
353  * @return the interaction type string
354  */
355  std::string GetInteractionType() const;
356 
357  /**
358  * @brief Produce a set of training examples for a binary classifier
359  *
360  * @param vertexVector the vector of vertices to use
361  * @param vertexFeatureInfoMap the vertex feature info map
362  * @param coinFlip a distribution for producing coin flips
363  * @param generator the random number generator
364  * @param interactionType the interaction type string
365  * @param trainingOutputFile the training set output file
366  * @param eventFeatureList the event feature list
367  * @param kdTreeMap the map of 2D hit kd trees
368  * @param maxRadius the maximum allowed radius for the 'best' vertex
369  * @param useRPhi whether to include the r/phi feature
370  *
371  * @return address of the vertex used as the 'best' vertex in the classifier
372  */
373  const pandora::Vertex *ProduceTrainingExamples(const pandora::VertexVector &vertexVector, const VertexFeatureInfoMap &vertexFeatureInfoMap,
374  std::bernoulli_distribution &coinFlip, std::mt19937 &generator, const std::string &interactionType, const std::string &trainingOutputFile,
375  const LArMvaHelper::MvaFeatureVector &eventFeatureList, const KDTreeMap &kdTreeMap, const float maxRadius, const bool useRPhi) const;
376 
377  /**
378  * @brief Use the MC information to get the best vertex from a list
379  *
380  * @param vertexVector the vector of vertices
381  * @param pBestVertex address of the best vertex
382  * @param bestVertexDr dR of the best vertex
383  */
384  void GetBestVertex(const pandora::VertexVector &vertexVector, const pandora::Vertex *&pBestVertex, float &bestVertexDr) const;
385 
386  /**
387  * @brief Calculates the shared features of a pair of vertex candidates
388  *
389  * @param pVertex1 the address of the first vertex
390  * @param pVertex2 the address of the second vertex
391  * @param kdTreeMap the map of 2D hit kd trees
392  * @param separation the 3D distance between the two vertex candidates
393  * @param axisHits the number of hits between the two candidates normalised to the distance between them
394  */
395  void GetSharedFeatures(const pandora::Vertex *const pVertex1, const pandora::Vertex *const pVertex2, const KDTreeMap &kdTreeMap,
396  float &separation, float &axisHits) const;
397 
398  /**
399  * @brief Increments the axis hits information for one view
400  *
401  * @param pos1 2D projected position of the first vertex
402  * @param pos2 2D projected position of the second vertex
403  * @param kdTree the kd tree of 2D hits
404  * @param axisHits the number of hits between the two candidates
405  */
406  void IncrementSharedAxisValues(const pandora::CartesianVector pos1, const pandora::CartesianVector pos2, HitKDTree2D &kdTree, float &axisHits) const;
407 
408  /**
409  * @brief Determines whether a hit lies within the box defined by four other positions
410  *
411  * @param hitPos the hit position
412  * @param point1 the first corner of the box
413  * @param point2 the second corner of the box
414  * @param point3 the third corner of the box
415  * @param point4 the fourth corner of the box
416  *
417  * @return boolean
418  */
419  bool IsHitInBox(const pandora::CartesianVector &hitPos, const pandora::CartesianVector &point1, const pandora::CartesianVector &point2,
420  const pandora::CartesianVector &point3, const pandora::CartesianVector &point4) const;
421 
422  /**
423  * @brief Add the vertex features to a vector in the correct order
424  *
425  * @param vertexFeatureInfo the vertex feature info
426  * @param featureVector the vector of floats to append
427  * @param useRPhi whether to include the r/phi feature
428  */
429  void AddVertexFeaturesToVector(const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const;
430 
431  /**
432  * @brief Add the shared features to a vector in the correct order
433  *
434  * @param vertexSharedFeatureInfo the shared vertex feature info
435  * @param featureVector the vector of floats to append
436  */
437  void AddSharedFeaturesToVector(const VertexSharedFeatureInfo &vertexSharedFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const;
438 
439  /**
440  * @brief Populate the final vertex score list using the r/phi score to find the best vertex in the vicinity
441  *
442  * @param vertexFeatureInfoMap the vertex feature info map
443  * @param pFavouriteVertex address of the favourite vertex
444  * @param vertexVector the vector of all vertex candidates
445  * @param finalVertexScoreList the final vertex score list to populate
446  */
447  void PopulateFinalVertexScoreList(const VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pFavouriteVertex,
448  const pandora::VertexVector &vertexVector, VertexScoreList &finalVertexScoreList) const;
449 
450  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
451 
453  bool m_trainingSetMode; ///< Whether to train
454  bool m_allowClassifyDuringTraining; ///< Whether classification is allowed during training
455  float m_mcVertexXCorrection; ///< The correction to the x-coordinate of the MC vertex position
456  std::string m_trainingOutputFileRegion; ///< The training output file for the region mva
457  std::string m_trainingOutputFileVertex; ///< The training output file for the vertex mva
458  std::string m_mcParticleListName; ///< The MC particle list for creating training examples
459  std::string m_caloHitListName; ///< The 2D CaloHit list name
460 
461  pandora::StringVector m_inputClusterListNames; ///< The list of cluster list names
462  unsigned int m_minClusterCaloHits; ///< The min number of hits parameter in the energy score
463  unsigned int m_slidingFitWindow; ///< The layer window for the sliding linear fits
464  float m_minShowerSpineLength; ///< The minimum length at which all are considered to be tracks
465 
466  float m_beamDeweightingConstant; ///< The beam deweighting constant for the initial region score list
467  float m_localAsymmetryConstant; ///< The local asymmetry constant for the initial region score list
468  float m_globalAsymmetryConstant; ///< The global asymmetry constant for the initial region score list
469  float m_showerAsymmetryConstant; ///< The shower asymmetry constant for the initial region score list
470  float m_energyKickConstant; ///< The energy kick constant for the initial region score list
471 
472  float m_showerClusteringDistance; ///< The shower clustering distance
473  unsigned int m_minShowerClusterHits; ///< The minimum number of shower cluster hits
474  bool m_useShowerClusteringApproximation; ///< Whether to use the shower clustering distance approximation
475  float m_regionRadius; ///< The radius for a vertex region
476  float m_rPhiFineTuningRadius; ///< The maximum distance the r/phi tune can move a vertex
477  float m_maxTrueVertexRadius; ///< The maximum distance at which a vertex candidate can be considered the 'true' vertex
478  bool m_useRPhiFeatureForRegion; ///< Whether to use the r/phi feature for the region vertex
479  bool m_dropFailedRPhiFastScoreCandidates; ///< Whether to drop candidates that fail the r/phi fast score test
480  bool m_testBeamMode; ///< Test beam mode
481  bool m_legacyEventShapes; ///< Whether to use the old event shapes calculation
482  bool m_legacyVariables; ///< Whether to only use the old variables
483 };
484 
485 //------------------------------------------------------------------------------------------------------------------------------------------
486 
487 inline TrainedVertexSelectionAlgorithm::VertexFeatureInfo::VertexFeatureInfo(const float beamDeweighting, const float rPhiFeature, const float energyKick,
488  const float localAsymmetry, const float globalAsymmetry, const float showerAsymmetry, const float dEdxAsymmetry, const float vertexEnergy) :
489  m_beamDeweighting(beamDeweighting),
490  m_rPhiFeature(rPhiFeature),
491  m_energyKick(energyKick),
492  m_localAsymmetry(localAsymmetry),
493  m_globalAsymmetry(globalAsymmetry),
494  m_showerAsymmetry(showerAsymmetry),
495  m_dEdxAsymmetry(dEdxAsymmetry),
496  m_vertexEnergy(vertexEnergy)
497 {
498 }
499 
500 //------------------------------------------------------------------------------------------------------------------------------------------
501 
502 inline TrainedVertexSelectionAlgorithm::EventFeatureInfo::EventFeatureInfo(const float eventShoweryness, const float eventEnergy,
503  const float eventArea, const float longitudinality, const unsigned int nHits, const unsigned int nClusters, const unsigned int nCandidates) :
504  m_eventShoweryness(eventShoweryness),
505  m_eventEnergy(eventEnergy),
506  m_eventArea(eventArea),
507  m_longitudinality(longitudinality),
508  m_nHits(nHits),
509  m_nClusters(nClusters),
510  m_nCandidates(nCandidates)
511 {
512 }
513 
514 //------------------------------------------------------------------------------------------------------------------------------------------
515 
516 inline TrainedVertexSelectionAlgorithm::VertexSharedFeatureInfo::VertexSharedFeatureInfo(const float separation, const float axisHits) :
517  m_separation(separation),
518  m_axisHits(axisHits)
519 {
520 }
521 
522 } // namespace lar_content
523 
524 #endif // #ifndef LAR_TRAINED_VERTEX_SELECTION_ALGORITHM_H
void AddEventFeaturesToVector(const EventFeatureInfo &eventFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the event features to a vector in the correct order.
void GetLegacyEventShapeFeatures(const pandora::ClusterList &clusterList, float &eventVolume, float &longitudinality) const
Get the event shape features.
std::string m_trainingOutputFileVertex
The training output file for the vertex mva.
unsigned int m_nCandidates
The total number of vertex candidates.
bool m_useShowerClusteringApproximation
Whether to use the shower clustering distance approximation.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
std::vector< pandora::VertexVector > VectorOfVertexVectors
void GetBestRegionVertices(VertexScoreList &initialScoreList, pandora::VertexVector &bestRegionVertices) const
Get the list of top-N separated vertices.
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:72
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
void PopulateInitialScoreList(VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pVertex, VertexScoreList &initialScoreList) const
Populate the initial vertex score list for a given vertex.
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool vector.
void PopulateFinalVertexScoreList(const VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pFavouriteVertex, const pandora::VertexVector &vertexVector, VertexScoreList &finalVertexScoreList) const
Populate the final vertex score list using the r/phi score to find the best vertex in the vicinity...
bool m_legacyEventShapes
Whether to use the old event shapes calculation.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
void AddVertexFeaturesToVector(const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
Add the vertex features to a vector in the correct order.
void IncrementSharedAxisValues(const pandora::CartesianVector pos1, const pandora::CartesianVector pos2, HitKDTree2D &kdTree, float &axisHits) const
Increments the axis hits information for one view.
const pandora::Vertex * ProduceTrainingExamples(const pandora::VertexVector &vertexVector, const VertexFeatureInfoMap &vertexFeatureInfoMap, std::bernoulli_distribution &coinFlip, std::mt19937 &generator, const std::string &interactionType, const std::string &trainingOutputFile, const LArMvaHelper::MvaFeatureVector &eventFeatureList, const KDTreeMap &kdTreeMap, const float maxRadius, const bool useRPhi) const
Produce a set of training examples for a binary classifier.
bool IsClusterShowerLike(const pandora::Cluster *const pCluster) const
Find whether a cluster is shower-like.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void CalculateRPhiScores(pandora::VertexVector &vertexVector, VertexFeatureInfoMap &vertexFeatureInfoMap, const KDTreeMap &kdTreeMap) const
Calculate the r/phi scores for the vertices in a vector, possibly erasing those that fail the fast sc...
void Get2DSpan(const pandora::ClusterList &clusterList, float &xSpan, float &zSpan) const
Get the coordinate span in one view.
float m_localAsymmetryConstant
The local asymmetry constant for the initial region score list.
bool IsHitInBox(const pandora::CartesianVector &hitPos, const pandora::CartesianVector &point1, const pandora::CartesianVector &point2, const pandora::CartesianVector &point3, const pandora::CartesianVector &point4) const
Determines whether a hit lies within the box defined by four other positions.
unsigned int m_minShowerClusterHits
The minimum number of shower cluster hits.
Data stored in each KDTree node. The dim1/dim2 fields are usually the duplication of some PFRecHit va...
VertexSharedFeatureInfo(const float separation, const float axisHits)
Constructor.
void ProduceTrainingSets(const pandora::VertexVector &vertexVector, const pandora::VertexVector &bestRegionVertices, VertexFeatureInfoMap &vertexFeatureInfoMap, const LArMvaHelper::MvaFeatureVector &eventFeatureList, const KDTreeMap &kdTreeMap) const
Produce the region and vertex training sets.
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
std::string m_mcParticleListName
The MC particle list for creating training examples.
void PopulateVertexFeatureInfoMap(const BeamConstants &beamConstants, const ClusterListMap &clusterListMap, const SlidingFitDataListMap &slidingFitDataListMap, const ShowerClusterListMap &showerClusterListMap, const KDTreeMap &kdTreeMap, const pandora::Vertex *const pVertex, VertexFeatureInfoMap &vertexFeatureInfoMap) const
Populate the vertex feature info map for a given vertex.
Header file for the lar adaptive boosted decision tree class.
float m_globalAsymmetryConstant
The global asymmetry constant for the initial region score list.
Header file for the lar monte carlo particle helper helper class.
std::pair< pandora::CartesianVector, pandora::CartesianVector > ClusterEndPoints
Header file for the lar support vector machine class.
EventFeatureInfo CalculateEventFeatures(const pandora::ClusterList &clusterListU, const pandora::ClusterList &clusterListV, const pandora::ClusterList &clusterListW, const pandora::VertexVector &vertexVector) const
Calculate the event parameters.
float m_maxTrueVertexRadius
The maximum distance at which a vertex candidate can be considered the &#39;true&#39; vertex.
Header file for the lar two dimensional sliding fit result class.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
Header file for the vertex selection base algorithm class.
float m_showerAsymmetryConstant
The shower asymmetry constant for the initial region score list.
std::vector< LArMvaHelper::MvaFeatureVector > FeatureListVector
void PopulateKdTree(const pandora::ClusterList &clusterList, HitKDTree2D &kdTree, HitToClusterMap &hitToClusterMap) const
Populate kd tree with information about hits in a provided list of clusters.
float m_beamDeweightingConstant
The beam deweighting constant for the initial region score list.
virtual void GetVertexScoreList(const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const =0
Get the vertex score list.
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
void CalculateShowerClusterList(const pandora::ClusterList &inputClusterList, ShowerClusterList &showerClusterList) const
Calculate the shower cluster map for a cluster list.
std::string m_trainingOutputFileRegion
The training output file for the region mva.
bool m_dropFailedRPhiFastScoreCandidates
Whether to drop candidates that fail the r/phi fast score test.
void AddSharedFeaturesToVector(const VertexSharedFeatureInfo &vertexSharedFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the shared features to a vector in the correct order.
float m_energyKickConstant
The energy kick constant for the initial region score list.
void GetSharedFeatures(const pandora::Vertex *const pVertex1, const pandora::Vertex *const pVertex2, const KDTreeMap &kdTreeMap, float &separation, float &axisHits) const
Calculates the shared features of a pair of vertex candidates.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
void UpdateSpanCoordinate(const float minPositionCoord, const float maxPositionCoord, pandora::InputFloat &minCoord, pandora::InputFloat &maxCoord) const
Update the min/max coordinate spans.
float m_mcVertexXCorrection
The correction to the x-coordinate of the MC vertex position.
std::vector< MvaFeatureTool< Ts...> * > FeatureToolVector
Definition: LArMvaHelper.h:36
void IncrementShoweryParameters(const pandora::ClusterList &clusterList, unsigned int &nShoweryHits, unsigned int &nHits, float &eventEnergy) const
Increment the showery hit parameters for a cluster list.
float GetCoordinateSpan(const pandora::InputFloat &minCoord, const pandora::InputFloat &maxCoord) const
Get the coordinate span.
bool m_legacyVariables
Whether to only use the old variables.
KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
std::map< const pandora::Cluster *const, ClusterEndPoints > ClusterEndPointsMap
void GetEventShapeFeatures(const ClusterListMap &clusterListMap, float &eventArea, float &longitudinality) const
Get the event shape features.
std::string m_caloHitListName
The 2D CaloHit list name.
bool AddClusterToShower(const ClusterEndPointsMap &clusterEndPointsMap, pandora::ClusterList &availableShowerLikeClusters, const pandora::Cluster *const pCluster, pandora::ClusterList &showerCluster) const
Try to add an available cluster to a given shower cluster, using shower clustering approximation...
float m_minShowerSpineLength
The minimum length at which all are considered to be tracks.
void GetShowerLikeClusterEndPoints(const pandora::ClusterList &clusterList, pandora::ClusterList &showerLikeClusters, ClusterEndPointsMap &clusterEndPointsMap) const
Add the endpoints of any shower-like clusters to the map.
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
EventFeatureInfo(const float eventShoweryness, const float eventEnergy, const float eventArea, const float longitudinality, const unsigned int nHits, const unsigned int nClusters, const unsigned int nCandidates)
Constructor.
VertexFeatureInfo(const float beamDeweighting, const float rPhiFeature, const float energyKick, const float localAsymmetry, const float globalAsymmetry, const float showerAsymmetry, const float dEdxAsymmetry, const float vertexEnergy)
Constructor.
float m_showerClusteringDistance
The shower clustering distance.
float m_axisHits
The hit density along the axis between the two vertices.
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
std::array< float, 2 > VertexVector(const recob::Vertex &vert, const geo::PlaneID &plane, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
std::map< const pandora::Vertex *const, VertexFeatureInfo > VertexFeatureInfoMap
float m_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.
void GetBestVertex(const pandora::VertexVector &vertexVector, const pandora::Vertex *&pBestVertex, float &bestVertexDr) const
Use the MC information to get the best vertex from a list.
std::string GetInteractionType() const
Get the interaction type string.