8 #ifndef LAR_TRAINED_VERTEX_SELECTION_ALGORITHM_H 9 #define LAR_TRAINED_VERTEX_SELECTION_ALGORITHM_H 1 11 #include "Api/PandoraContentApi.h" 26 template <
typename,
unsigned int>
27 class KDTreeLinkerAlgo;
28 template <
typename,
unsigned int>
29 class KDTreeNodeInfoT;
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);
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);
165 const pandora::ClusterList &clusterList, pandora::ClusterList &showerLikeClusters, ClusterEndPointsMap &clusterEndPointsMap)
const;
171 typedef std::unordered_map<const pandora::CaloHit *, const pandora::Cluster *>
HitToClusterMap;
180 void PopulateKdTree(
const pandora::ClusterList &clusterList, HitKDTree2D &kdTree, HitToClusterMap &hitToClusterMap)
const;
192 bool AddClusterToShower(
const ClusterEndPointsMap &clusterEndPointsMap, pandora::ClusterList &availableShowerLikeClusters,
193 const pandora::Cluster *
const pCluster, pandora::ClusterList &showerCluster)
const;
206 bool AddClusterToShower(HitKDTree2D &kdTree,
const HitToClusterMap &hitToClusterMap, pandora::ClusterList &availableShowerLikeClusters,
207 const pandora::Cluster *
const pCluster, pandora::ClusterList &showerCluster)
const;
230 void IncrementShoweryParameters(
const pandora::ClusterList &clusterList,
unsigned int &nShoweryHits,
unsigned int &nHits,
float &eventEnergy)
const;
266 void Get2DSpan(
const pandora::ClusterList &clusterList,
float &xSpan,
float &zSpan)
const;
277 const float minPositionCoord,
const float maxPositionCoord, pandora::InputFloat &minCoord, pandora::InputFloat &maxCoord)
const;
287 float GetCoordinateSpan(
const pandora::InputFloat &minCoord,
const pandora::InputFloat &maxCoord)
const;
310 const pandora::Vertex *
const pVertex, VertexFeatureInfoMap &vertexFeatureInfoMap)
const;
374 std::bernoulli_distribution &coinFlip, std::mt19937 &generator,
const std::string &interactionType,
const std::string &trainingOutputFile,
396 float &separation,
float &axisHits)
const;
406 void IncrementSharedAxisValues(
const pandora::CartesianVector pos1,
const pandora::CartesianVector pos2, HitKDTree2D &kdTree,
float &axisHits)
const;
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;
450 pandora::StatusCode
ReadSettings(
const pandora::TiXmlHandle xmlHandle);
488 const float localAsymmetry,
const float globalAsymmetry,
const float showerAsymmetry,
const float dEdxAsymmetry,
const float vertexEnergy) :
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),
509 m_nClusters(nClusters),
510 m_nCandidates(nCandidates)
517 m_separation(separation),
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.
unsigned int m_nHits
The number of hits in the event.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
float m_vertexEnergy
The vertex energy feature.
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
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
std::vector< ShowerCluster > ShowerClusterList
float m_dEdxAsymmetry
The dE/dx asymmetry feature.
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.
float m_beamDeweighting
The beam deweighting feature.
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.
Vertex feature info class.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
float m_regionRadius
The radius for a vertex region.
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...
unsigned int m_nClusters
The number of clusters in the event.
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.
float m_longitudinality
The longitudinality of the event.
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.
float m_eventArea
The area of the event.
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.
TrainedVertexSelectionAlgorithm()
Default constructor.
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.
float m_eventEnergy
The event energy.
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_localAsymmetry
The local asymmetry feature.
float m_maxTrueVertexRadius
The maximum distance at which a vertex candidate can be considered the 'true' 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.
float m_energyKick
The energy kick feature.
Header file for the vertex selection base algorithm class.
VertexSelectionBaseAlgorithm class.
TrainedVertexSelectionAlgorithm class.
float m_showerAsymmetryConstant
The shower asymmetry constant for the initial region score list.
std::vector< LArMvaHelper::MvaFeatureVector > FeatureListVector
std::vector< VertexScore > VertexScoreList
void PopulateKdTree(const pandora::ClusterList &clusterList, HitKDTree2D &kdTree, HitToClusterMap &hitToClusterMap) const
Populate kd tree with information about hits in a provided list of clusters.
std::vector< HitKDNode2D > HitKDNode2DList
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_trainingSetMode
Whether to train.
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.
float m_separation
The distance between the two vertices.
bool m_testBeamMode
Test beam mode.
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.
float m_showerAsymmetry
The shower asymmetry feature.
std::vector< MvaFeatureTool< Ts... > * > FeatureToolVector
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.
std::vector< art::Ptr< recob::Vertex > > VertexVector
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.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
Shared vertex feature info class.
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_rPhiFeature
The r/phi feature.
float m_showerClusteringDistance
The shower clustering distance.
float m_axisHits
The hit density along the axis between the two vertices.
float m_eventShoweryness
The event showeryness feature.
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
std::map< const pandora::Vertex *const, VertexFeatureInfo > VertexFeatureInfoMap
float m_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.
Event feature info class.
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.
float m_globalAsymmetry
The global asymmetry feature.