All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
lar_content::MvaVertexSelectionAlgorithm< T > Class Template Reference

MvaVertexSelectionAlgorithm class. More...

#include <MvaVertexSelectionAlgorithm.h>

Inheritance diagram for lar_content::MvaVertexSelectionAlgorithm< T >:
lar_content::TrainedVertexSelectionAlgorithm lar_content::VertexSelectionBaseAlgorithm

Public Member Functions

 MvaVertexSelectionAlgorithm ()
 Default constructor. More...
 
- Public Member Functions inherited from lar_content::TrainedVertexSelectionAlgorithm
 TrainedVertexSelectionAlgorithm ()
 Default constructor. More...
 
- Public Member Functions inherited from lar_content::VertexSelectionBaseAlgorithm
 VertexSelectionBaseAlgorithm ()
 Default constructor. More...
 

Protected Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
- Protected Member Functions inherited from lar_content::TrainedVertexSelectionAlgorithm
void CalculateShowerClusterList (const pandora::ClusterList &inputClusterList, ShowerClusterList &showerClusterList) const
 Calculate the shower cluster map for a cluster list. More...
 
void GetShowerLikeClusterEndPoints (const pandora::ClusterList &clusterList, pandora::ClusterList &showerLikeClusters, ClusterEndPointsMap &clusterEndPointsMap) const
 Add the endpoints of any shower-like clusters to the map. More...
 
void PopulateKdTree (const pandora::ClusterList &clusterList, HitKDTree2D &kdTree, HitToClusterMap &hitToClusterMap) const
 Populate kd tree with information about hits in a provided list of clusters. More...
 
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. More...
 
bool AddClusterToShower (HitKDTree2D &kdTree, const HitToClusterMap &hitToClusterMap, pandora::ClusterList &availableShowerLikeClusters, const pandora::Cluster *const pCluster, pandora::ClusterList &showerCluster) const
 Try to add an available cluster to a given shower cluster, using cluster hit positions cached in kd tree. More...
 
EventFeatureInfo CalculateEventFeatures (const pandora::ClusterList &clusterListU, const pandora::ClusterList &clusterListV, const pandora::ClusterList &clusterListW, const pandora::VertexVector &vertexVector) const
 Calculate the event parameters. More...
 
void IncrementShoweryParameters (const pandora::ClusterList &clusterList, unsigned int &nShoweryHits, unsigned int &nHits, float &eventEnergy) const
 Increment the showery hit parameters for a cluster list. More...
 
bool IsClusterShowerLike (const pandora::Cluster *const pCluster) const
 Find whether a cluster is shower-like. More...
 
void GetLegacyEventShapeFeatures (const pandora::ClusterList &clusterList, float &eventVolume, float &longitudinality) const
 Get the event shape features. More...
 
void GetEventShapeFeatures (const ClusterListMap &clusterListMap, float &eventArea, float &longitudinality) const
 Get the event shape features. More...
 
void Get2DSpan (const pandora::ClusterList &clusterList, float &xSpan, float &zSpan) const
 Get the coordinate span in one view. More...
 
void UpdateSpanCoordinate (const float minPositionCoord, const float maxPositionCoord, pandora::InputFloat &minCoord, pandora::InputFloat &maxCoord) const
 Update the min/max coordinate spans. More...
 
float GetCoordinateSpan (const pandora::InputFloat &minCoord, const pandora::InputFloat &maxCoord) const
 Get the coordinate span. More...
 
void AddEventFeaturesToVector (const EventFeatureInfo &eventFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
 Add the event features to a vector in the correct order. More...
 
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. More...
 
void PopulateInitialScoreList (VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pVertex, VertexScoreList &initialScoreList) const
 Populate the initial vertex score list for a given vertex. More...
 
void GetBestRegionVertices (VertexScoreList &initialScoreList, pandora::VertexVector &bestRegionVertices) const
 Get the list of top-N separated vertices. More...
 
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. More...
 
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 score test. More...
 
std::string GetInteractionType () const
 Get the interaction type string. More...
 
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. More...
 
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. More...
 
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. More...
 
void IncrementSharedAxisValues (const pandora::CartesianVector pos1, const pandora::CartesianVector pos2, HitKDTree2D &kdTree, float &axisHits) const
 Increments the axis hits information for one view. More...
 
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. More...
 
void AddVertexFeaturesToVector (const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
 Add the vertex features to a vector in the correct order. More...
 
void AddSharedFeaturesToVector (const VertexSharedFeatureInfo &vertexSharedFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
 Add the shared features to a vector in the correct order. More...
 
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. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
- Protected Member Functions inherited from lar_content::VertexSelectionBaseAlgorithm
virtual void FilterVertexList (const pandora::VertexList *const pInputVertexList, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, pandora::VertexVector &filteredVertices) const
 Filter the input list of vertices to obtain a reduced number of vertex candidates. More...
 
virtual void GetBeamConstants (const pandora::VertexVector &vertexVector, BeamConstants &beamConstants) const
 Get the beam score constants for a provided list of candidate vertices. More...
 
void GetClusterLists (const pandora::StringVector &inputClusterListNames, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
 Get the cluster lists. More...
 
void CalculateClusterSlidingFits (const pandora::ClusterList &inputClusterList, const unsigned int minClusterCaloHits, const unsigned int slidingFitWindow, SlidingFitDataList &slidingFitDataList) const
 Calculate the cluster sliding fits. More...
 
float GetBeamDeweightingScore (const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
 Get the beam deweighting score for a vertex. More...
 
bool IsBeamModeOn () const
 Whether algorithm is running in beam mode, assuming neutrinos travel in positive z-direction. More...
 
float GetVertexEnergy (const pandora::Vertex *const pVertex, const KDTreeMap &kdTreeMap) const
 Calculate the energy of a vertex candidate by summing values from all three planes. More...
 
float VertexHitEnergy (const pandora::Vertex *const pVertex, const pandora::HitType hitType, HitKDTree2D &kdTree) const
 Finds the energy of the nearest hit to the vertex candidate in this view. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Member Functions

void GetVertexScoreList (const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const
 Get the vertex score list. More...
 
const pandora::Vertex * CompareVertices (const pandora::VertexVector &vertexVector, const VertexFeatureInfoMap &vertexFeatureInfoMap, const LArMvaHelper::MvaFeatureVector &eventFeatureList, const KDTreeMap &kdTreeMap, const T &t, const bool useRPhi) const
 Used a binary classifier to compare a set of vertices and pick the best one. More...
 

Private Attributes

std::string m_filePathEnvironmentVariable
 The environment variable providing a list of paths to mva files. More...
 
std::string m_mvaFileName
 The mva file name. More...
 
std::string m_regionMvaName
 The name of the region mva to find. More...
 
std::string m_vertexMvaName
 The name of the vertex mva to find. More...
 
m_mvaRegion
 The region mva. More...
 
m_mvaVertex
 The vertex mva. More...
 

Additional Inherited Members

- Public Types inherited from lar_content::TrainedVertexSelectionAlgorithm
typedef std::map< const
pandora::Vertex *const,
VertexFeatureInfo
VertexFeatureInfoMap
 
- Public Types inherited from lar_content::VertexSelectionBaseAlgorithm
typedef std::vector< VertexScoreVertexScoreList
 
typedef std::vector
< SlidingFitData
SlidingFitDataList
 
typedef std::vector
< ShowerCluster
ShowerClusterList
 
typedef KDTreeNodeInfoT< const
pandora::CaloHit *, 2 > 
HitKDNode2D
 
typedef std::vector< HitKDNode2DHitKDNode2DList
 
typedef KDTreeLinkerAlgo
< const pandora::CaloHit *, 2 > 
HitKDTree2D
 
typedef std::map
< pandora::HitType, const
pandora::ClusterList & > 
ClusterListMap
 Map array of cluster lists for passing to tools. More...
 
typedef std::map
< pandora::HitType, const
SlidingFitDataList
SlidingFitDataListMap
 Map of sliding fit data lists for passing to tools. More...
 
typedef std::map
< pandora::HitType, const
ShowerClusterList
ShowerClusterListMap
 Map of shower cluster lists for passing to tools. More...
 
typedef std::map
< pandora::HitType, const
std::reference_wrapper
< HitKDTree2D > > 
KDTreeMap
 Map array of hit kd trees for passing to tools. More...
 
typedef MvaFeatureTool< const
VertexSelectionBaseAlgorithm
*const, const pandora::Vertex
*const, const
SlidingFitDataListMap &, const
ClusterListMap &, const
KDTreeMap &, const
ShowerClusterListMap &, const
float, float & > 
VertexFeatureTool
 The base type for the vertex feature tools. More...
 
- Protected Types inherited from lar_content::TrainedVertexSelectionAlgorithm
typedef std::pair
< pandora::CartesianVector,
pandora::CartesianVector > 
ClusterEndPoints
 
typedef std::map< const
pandora::Cluster *const,
ClusterEndPoints
ClusterEndPointsMap
 
typedef std::vector
< LArMvaHelper::MvaFeatureVector
FeatureListVector
 
typedef std::vector
< pandora::VertexVector
VectorOfVertexVectors
 
typedef KDTreeLinkerAlgo
< const pandora::CaloHit *, 2 > 
HitKDTree2D
 
typedef KDTreeNodeInfoT< const
pandora::CaloHit *, 2 > 
HitKDNode2D
 
typedef std::vector< HitKDNode2DHitKDNode2DList
 
typedef std::unordered_map
< const pandora::CaloHit
*, const pandora::Cluster * > 
HitToClusterMap
 
- Protected Attributes inherited from lar_content::TrainedVertexSelectionAlgorithm
VertexFeatureTool::FeatureToolVector m_featureToolVector
 The feature tool vector. More...
 
bool m_trainingSetMode
 Whether to train. More...
 
bool m_allowClassifyDuringTraining
 Whether classification is allowed during training. More...
 
float m_mcVertexXCorrection
 The correction to the x-coordinate of the MC vertex position. More...
 
std::string m_trainingOutputFileRegion
 The training output file for the region mva. More...
 
std::string m_trainingOutputFileVertex
 The training output file for the vertex mva. More...
 
std::string m_mcParticleListName
 The MC particle list for creating training examples. More...
 
std::string m_caloHitListName
 The 2D CaloHit list name. More...
 
pandora::StringVector m_inputClusterListNames
 The list of cluster list names. More...
 
unsigned int m_minClusterCaloHits
 The min number of hits parameter in the energy score. More...
 
unsigned int m_slidingFitWindow
 The layer window for the sliding linear fits. More...
 
float m_minShowerSpineLength
 The minimum length at which all are considered to be tracks. More...
 
float m_beamDeweightingConstant
 The beam deweighting constant for the initial region score list. More...
 
float m_localAsymmetryConstant
 The local asymmetry constant for the initial region score list. More...
 
float m_globalAsymmetryConstant
 The global asymmetry constant for the initial region score list. More...
 
float m_showerAsymmetryConstant
 The shower asymmetry constant for the initial region score list. More...
 
float m_energyKickConstant
 The energy kick constant for the initial region score list. More...
 
float m_showerClusteringDistance
 The shower clustering distance. More...
 
unsigned int m_minShowerClusterHits
 The minimum number of shower cluster hits. More...
 
bool m_useShowerClusteringApproximation
 Whether to use the shower clustering distance approximation. More...
 
float m_regionRadius
 The radius for a vertex region. More...
 
float m_rPhiFineTuningRadius
 The maximum distance the r/phi tune can move a vertex. More...
 
float m_maxTrueVertexRadius
 The maximum distance at which a vertex candidate can be considered the 'true' vertex. More...
 
bool m_useRPhiFeatureForRegion
 Whether to use the r/phi feature for the region vertex. More...
 
bool m_dropFailedRPhiFastScoreCandidates
 Whether to drop candidates that fail the r/phi fast score test. More...
 
bool m_testBeamMode
 Test beam mode. More...
 
bool m_legacyEventShapes
 Whether to use the old event shapes calculation. More...
 
bool m_legacyVariables
 Whether to only use the old variables. More...
 

Detailed Description

template<typename T>
class lar_content::MvaVertexSelectionAlgorithm< T >

MvaVertexSelectionAlgorithm class.

Definition at line 37 of file MvaVertexSelectionAlgorithm.h.

Constructor & Destructor Documentation

Default constructor.

Definition at line 36 of file MvaVertexSelectionAlgorithm.cc.

36  :
38  m_filePathEnvironmentVariable("FW_SEARCH_PATH")
39 {
40 }
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to mva files.

Member Function Documentation

template<typename T >
const pandora::Vertex * lar_content::MvaVertexSelectionAlgorithm< T >::CompareVertices ( const pandora::VertexVector vertexVector,
const VertexFeatureInfoMap vertexFeatureInfoMap,
const LArMvaHelper::MvaFeatureVector eventFeatureList,
const KDTreeMap kdTreeMap,
const T &  t,
const bool  useRPhi 
) const
private

Used a binary classifier to compare a set of vertices and pick the best one.

Parameters
vertexVectorthe vector of vertices
vertexFeatureInfoMapthe vertex feature info map
eventFeatureListthe event feature list
kdTreeMapthe map of 2D hit kd trees
tthe mva
useRPhiwhether to include the r/phi feature
Returns
address of the best vertex

Definition at line 127 of file MvaVertexSelectionAlgorithm.cc.

129 {
130  const Vertex *pBestVertex(vertexVector.front());
131  LArMvaHelper::MvaFeatureVector chosenFeatureList;
132 
133  VertexFeatureInfo chosenVertexFeatureInfo(vertexFeatureInfoMap.at(pBestVertex));
134  this->AddVertexFeaturesToVector(chosenVertexFeatureInfo, chosenFeatureList, useRPhi);
135 
136  for (const Vertex *const pVertex : vertexVector)
137  {
138  if (pVertex == pBestVertex)
139  continue;
140 
141  LArMvaHelper::MvaFeatureVector featureList;
142  VertexFeatureInfo vertexFeatureInfo(vertexFeatureInfoMap.at(pVertex));
143  this->AddVertexFeaturesToVector(vertexFeatureInfo, featureList, useRPhi);
144 
145  if (!m_legacyVariables)
146  {
147  LArMvaHelper::MvaFeatureVector sharedFeatureList;
148  float separation(0.f), axisHits(0.f);
149  this->GetSharedFeatures(pVertex, pBestVertex, kdTreeMap, separation, axisHits);
150  VertexSharedFeatureInfo sharedFeatureInfo(separation, axisHits);
151  this->AddSharedFeaturesToVector(sharedFeatureInfo, sharedFeatureList);
152 
153  if (LArMvaHelper::Classify(t, LArMvaHelper::ConcatenateFeatureLists(eventFeatureList, featureList, chosenFeatureList, sharedFeatureList)))
154  {
155  pBestVertex = pVertex;
156  chosenFeatureList = featureList;
157  }
158  }
159  else
160  {
161  if (LArMvaHelper::Classify(t, LArMvaHelper::ConcatenateFeatureLists(eventFeatureList, featureList, chosenFeatureList)))
162  {
163  pBestVertex = pVertex;
164  chosenFeatureList = featureList;
165  }
166  }
167  }
168 
169  return pBestVertex;
170 }
static bool Classify(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained classifier to predict the boolean class of an example.
Definition: LArMvaHelper.h:328
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:72
void AddVertexFeaturesToVector(const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
Add the vertex features to a vector in the correct order.
void AddSharedFeaturesToVector(const VertexSharedFeatureInfo &vertexSharedFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the shared features to a vector in the correct order.
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.
bool m_legacyVariables
Whether to only use the old variables.
static MvaFeatureVector ConcatenateFeatureLists()
Recursively concatenate vectors of features (terminating method)
Definition: LArMvaHelper.h:538
template<typename T >
void lar_content::MvaVertexSelectionAlgorithm< T >::GetVertexScoreList ( const pandora::VertexVector vertexVector,
const BeamConstants beamConstants,
HitKDTree2D kdTreeU,
HitKDTree2D kdTreeV,
HitKDTree2D kdTreeW,
VertexScoreList vertexScoreList 
) const
privatevirtual

Get the vertex score list.

Parameters
vertexVectorthe vector of vertices
beamConstantsthe beam constants
kdTreeUthe hit kd tree for the U view
kdTreeVthe hit kd tree for the V view
kdTreeWthe hit kd tree for the W view
vertexScoreListthe vertex score list to fill

Implements lar_content::TrainedVertexSelectionAlgorithm.

Definition at line 45 of file MvaVertexSelectionAlgorithm.cc.

47 {
48  ClusterList clustersU, clustersV, clustersW;
49  this->GetClusterLists(m_inputClusterListNames, clustersU, clustersV, clustersW);
50 
51  SlidingFitDataList slidingFitDataListU, slidingFitDataListV, slidingFitDataListW;
52  this->CalculateClusterSlidingFits(clustersU, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListU);
53  this->CalculateClusterSlidingFits(clustersV, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListV);
54  this->CalculateClusterSlidingFits(clustersW, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListW);
55 
56  ShowerClusterList showerClusterListU, showerClusterListV, showerClusterListW;
57  this->CalculateShowerClusterList(clustersU, showerClusterListU);
58  this->CalculateShowerClusterList(clustersV, showerClusterListV);
59  this->CalculateShowerClusterList(clustersW, showerClusterListW);
60 
61  // Create maps from hit types to objects for passing to feature tools.
62  const ClusterListMap clusterListMap{{TPC_VIEW_U, clustersU}, {TPC_VIEW_V, clustersV}, {TPC_VIEW_W, clustersW}};
63 
64  const SlidingFitDataListMap slidingFitDataListMap{
65  {TPC_VIEW_U, slidingFitDataListU}, {TPC_VIEW_V, slidingFitDataListV}, {TPC_VIEW_W, slidingFitDataListW}};
66 
67  const ShowerClusterListMap showerClusterListMap{{TPC_VIEW_U, showerClusterListU}, {TPC_VIEW_V, showerClusterListV}, {TPC_VIEW_W, showerClusterListW}};
68 
69  const KDTreeMap kdTreeMap{{TPC_VIEW_U, kdTreeU}, {TPC_VIEW_V, kdTreeV}, {TPC_VIEW_W, kdTreeW}};
70 
71  // Calculate the event feature list and the vertex feature map.
72  EventFeatureInfo eventFeatureInfo(this->CalculateEventFeatures(clustersU, clustersV, clustersW, vertexVector));
73 
74  LArMvaHelper::MvaFeatureVector eventFeatureList;
75  this->AddEventFeaturesToVector(eventFeatureInfo, eventFeatureList);
76 
77  VertexFeatureInfoMap vertexFeatureInfoMap;
78  for (const Vertex *const pVertex : vertexVector)
79  {
81  beamConstants, clusterListMap, slidingFitDataListMap, showerClusterListMap, kdTreeMap, pVertex, vertexFeatureInfoMap);
82  }
83 
84  // Use a simple score to get the list of vertices representing good regions.
85  VertexScoreList initialScoreList;
86  for (const Vertex *const pVertex : vertexVector)
87  PopulateInitialScoreList(vertexFeatureInfoMap, pVertex, initialScoreList);
88 
89  VertexVector bestRegionVertices;
90  this->GetBestRegionVertices(initialScoreList, bestRegionVertices);
91 
93  this->ProduceTrainingSets(vertexVector, bestRegionVertices, vertexFeatureInfoMap, eventFeatureList, kdTreeMap);
94 
95  if ((!m_trainingSetMode || m_allowClassifyDuringTraining) && !bestRegionVertices.empty())
96  {
97  // Use mva to choose the region.
98  const Vertex *const pBestRegionVertex(
99  this->CompareVertices(bestRegionVertices, vertexFeatureInfoMap, eventFeatureList, kdTreeMap, m_mvaRegion, m_useRPhiFeatureForRegion));
100 
101  // Get all the vertices in the best region.
102  VertexVector regionalVertices{pBestRegionVertex};
103  for (const Vertex *const pVertex : vertexVector)
104  {
105  if (pVertex == pBestRegionVertex)
106  continue;
107 
108  if ((pBestRegionVertex->GetPosition() - pVertex->GetPosition()).GetMagnitude() < m_regionRadius)
109  regionalVertices.push_back(pVertex);
110  }
111 
112  this->CalculateRPhiScores(regionalVertices, vertexFeatureInfoMap, kdTreeMap);
113 
114  if (!regionalVertices.empty())
115  {
116  // Use mva to choose the vertex and then fine-tune using the RPhi score.
117  const Vertex *const pBestVertex(
118  this->CompareVertices(regionalVertices, vertexFeatureInfoMap, eventFeatureList, kdTreeMap, m_mvaVertex, true));
119  this->PopulateFinalVertexScoreList(vertexFeatureInfoMap, pBestVertex, vertexVector, vertexScoreList);
120  }
121  }
122 }
void AddEventFeaturesToVector(const EventFeatureInfo &eventFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the event features to a vector in the correct order.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
void GetBestRegionVertices(VertexScoreList &initialScoreList, pandora::VertexVector &bestRegionVertices) const
Get the list of top-N separated vertices.
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.
void GetClusterLists(const pandora::StringVector &inputClusterListNames, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
Get the cluster lists.
void CalculateClusterSlidingFits(const pandora::ClusterList &inputClusterList, const unsigned int minClusterCaloHits, const unsigned int slidingFitWindow, SlidingFitDataList &slidingFitDataList) const
Calculate the cluster sliding fits.
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...
const pandora::Vertex * CompareVertices(const pandora::VertexVector &vertexVector, const VertexFeatureInfoMap &vertexFeatureInfoMap, const LArMvaHelper::MvaFeatureVector &eventFeatureList, const KDTreeMap &kdTreeMap, const T &t, const bool useRPhi) const
Used a binary classifier to compare a set of vertices and pick the best one.
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 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.
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.
EventFeatureInfo CalculateEventFeatures(const pandora::ClusterList &clusterListU, const pandora::ClusterList &clusterListV, const pandora::ClusterList &clusterListW, const pandora::VertexVector &vertexVector) const
Calculate the event parameters.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
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::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
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
template<typename T >
StatusCode lar_content::MvaVertexSelectionAlgorithm< T >::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protected

Definition at line 175 of file MvaVertexSelectionAlgorithm.cc.

176 {
177  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
178  XmlHelper::ReadValue(xmlHandle, "FilePathEnvironmentVariable", m_filePathEnvironmentVariable));
179 
180  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MvaFileName", m_mvaFileName));
181 
182  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "RegionMvaName", m_regionMvaName));
183 
184  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "VertexMvaName", m_vertexMvaName));
185 
186  // ATTN : Need access to base class member variables at this point, so call read settings prior to end of this function
187  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, TrainedVertexSelectionAlgorithm::ReadSettings(xmlHandle));
188 
190  {
191  if (m_mvaFileName.empty() || m_regionMvaName.empty() || m_vertexMvaName.empty())
192  {
193  std::cout << "MvaVertexSelectionAlgorithm: MvaFileName, RegionMvaName and VertexMvaName must be set if training set mode is"
194  << "off or we allow classification during training" << std::endl;
195  return STATUS_CODE_INVALID_PARAMETER;
196  }
197 
199  m_mvaRegion.Initialize(fullMvaFileName, m_regionMvaName);
200  m_mvaVertex.Initialize(fullMvaFileName, m_vertexMvaName);
201  }
202 
203  return STATUS_CODE_SUCCESS;
204 }
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to mva files.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::string m_regionMvaName
The name of the region mva to find.
static std::string FindFileInPath(const std::string &unqualifiedFileName, const std::string &environmentVariable, const std::string &delimiter=":")
Find the fully-qualified file name by searching through a list of delimiter-separated paths in a name...
std::string m_vertexMvaName
The name of the vertex mva to find.
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
BEGIN_PROLOG could also be cout

Member Data Documentation

template<typename T >
std::string lar_content::MvaVertexSelectionAlgorithm< T >::m_filePathEnvironmentVariable
private

The environment variable providing a list of paths to mva files.

Definition at line 77 of file MvaVertexSelectionAlgorithm.h.

template<typename T >
std::string lar_content::MvaVertexSelectionAlgorithm< T >::m_mvaFileName
private

The mva file name.

Definition at line 78 of file MvaVertexSelectionAlgorithm.h.

template<typename T >
T lar_content::MvaVertexSelectionAlgorithm< T >::m_mvaRegion
private

The region mva.

Definition at line 81 of file MvaVertexSelectionAlgorithm.h.

template<typename T >
T lar_content::MvaVertexSelectionAlgorithm< T >::m_mvaVertex
private

The vertex mva.

Definition at line 82 of file MvaVertexSelectionAlgorithm.h.

template<typename T >
std::string lar_content::MvaVertexSelectionAlgorithm< T >::m_regionMvaName
private

The name of the region mva to find.

Definition at line 79 of file MvaVertexSelectionAlgorithm.h.

template<typename T >
std::string lar_content::MvaVertexSelectionAlgorithm< T >::m_vertexMvaName
private

The name of the vertex mva to find.

Definition at line 80 of file MvaVertexSelectionAlgorithm.h.


The documentation for this class was generated from the following files: