8 #ifndef LAR_SVM_VERTEX_SELECTION_ALGORITHM_H 9 #define LAR_SVM_VERTEX_SELECTION_ALGORITHM_H 1 11 #include "Api/PandoraContentApi.h" 25 template<
typename,
unsigned int>
class KDTreeLinkerAlgo;
26 template<
typename,
unsigned int>
class KDTreeNodeInfoT;
52 VertexFeatureInfo(
const float beamDeweighting,
const float rPhiFeature,
const float energyKick,
const float localAsymmetry,
53 const float globalAsymmetry,
const float showerAsymmetry);
84 EventFeatureInfo(
const float eventShoweryness,
const float eventEnergy,
const float eventVolume,
const float longitudinality,
85 const unsigned int nHits,
const unsigned int nClusters,
const unsigned int nCandidates);
104 pandora::StatusCode
ReadSettings(
const pandora::TiXmlHandle xmlHandle);
141 ClusterEndPointsMap &clusterEndPointsMap)
const;
147 typedef std::unordered_map<const pandora::CaloHit*, const pandora::Cluster*>
HitToClusterMap;
156 void PopulateKdTree(
const pandora::ClusterList &clusterList, HitKDTree2D &kdTree, HitToClusterMap &hitToClusterMap)
const;
168 bool AddClusterToShower(
const ClusterEndPointsMap &clusterEndPointsMap, pandora::ClusterList &availableShowerLikeClusters,
169 const pandora::Cluster *
const pCluster, pandora::ClusterList &showerCluster)
const;
182 bool AddClusterToShower(HitKDTree2D &kdTree,
const HitToClusterMap &hitToClusterMap, pandora::ClusterList &availableShowerLikeClusters,
183 const pandora::Cluster *
const pCluster, pandora::ClusterList &showerCluster)
const;
207 float &eventEnergy)
const;
225 void GetEventShapeFeatures(
const pandora::ClusterList &clusterList,
float &eventVolume,
float &longitudinality)
const;
235 void UpdateSpanCoordinate(
const float minPositionCoord,
const float maxPositionCoord, pandora::InputFloat &minCoord,
236 pandora::InputFloat &maxCoord)
const;
246 float GetCoordinateSpan(
const pandora::InputFloat &minCoord,
const pandora::InputFloat &maxCoord)
const;
269 const pandora::Vertex *
const pVertex, VertexFeatureInfoMap &vertexFeatureInfoMap)
const;
333 std::bernoulli_distribution &coinFlip, std::mt19937 &generator,
const std::string &interactionType,
const std::string &trainingOutputFile,
419 const float localAsymmetry,
const float globalAsymmetry,
const float showerAsymmetry) :
432 const float eventVolume,
const float longitudinality,
const unsigned int nHits,
const unsigned int nClusters,
const unsigned int nCandidates) :
433 m_eventShoweryness(eventShoweryness),
434 m_eventEnergy(eventEnergy),
435 m_eventVolume(eventVolume),
436 m_longitudinality(longitudinality),
438 m_nClusters(nClusters),
439 m_nCandidates(nCandidates)
445 #endif // #ifndef LAR_SVM_VERTEX_SELECTION_ALGORITHM_H std::string m_vertexSvmName
The name of the vertex Svm to find.
std::map< const pandora::Vertex *const, VertexFeatureInfo > VertexFeatureInfoMap
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...
SupportVectorMachine class.
void GetBestRegionVertices(VertexScoreList &initialScoreList, pandora::VertexVector &bestRegionVertices) const
Get the list of top-N separated vertices.
MvaTypes::MvaFeatureVector MvaFeatureVector
unsigned int m_nCandidates
The total number of vertex candidates.
void IncrementShoweryParameters(const pandora::ClusterList &clusterList, unsigned int &nShoweryHits, unsigned int &nHits, float &eventEnergy) const
Increment the showery hit parameters for a cluster list.
std::vector< ShowerCluster > ShowerClusterList
float m_beamDeweighting
The beam deweighting feature.
unsigned int m_minShowerClusterHits
The minimum number of shower cluster hits.
std::vector< LArMvaHelper::MvaFeatureVector > FeatureListVector
float m_globalAsymmetryConstant
The global asymmetry constant for the initial region score list.
Class that implements the KDTree partition of 2D space and a closest point search algorithm...
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...
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
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 float maxRadius, const bool useRPhi) const
Produce a set of training examples for a binary classifier.
void GetVertexScoreList(const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const
Get the vertex score list.
bool m_dropFailedRPhiFastScoreCandidates
Whether to drop candidates that fail the r/phi fast score test.
std::vector< HitKDNode2D > HitKDNode2DList
float m_energyKick
The energy kick feature.
Vertex feature info class.
float GetCoordinateSpan(const pandora::InputFloat &minCoord, const pandora::InputFloat &maxCoord) const
Get the coordinate span.
float m_maxTrueVertexRadius
The maximum distance at which a vertex candidate can be considered the 'true' vertex.
float m_showerAsymmetryConstant
The shower asymmetry constant for the initial region score list.
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
VertexFeatureInfo(const float beamDeweighting, const float rPhiFeature, const float energyKick, const float localAsymmetry, const float globalAsymmetry, const float showerAsymmetry)
Constructor.
KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
bool IsClusterShowerLike(const pandora::Cluster *const pCluster) const
Find whether a cluster is shower-like.
Data stored in each KDTree node. The dim1/dim2 fields are usually the duplication of some PFRecHit va...
SvmVertexSelectionAlgorithm class.
float m_localAsymmetryConstant
The local asymmetry constant for the initial region score list.
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.
float m_regionRadius
The radius for a vertex region.
float m_eventEnergy
The event energy.
std::map< const pandora::Cluster *const, ClusterEndPoints > ClusterEndPointsMap
std::string GetInteractionType() const
Get the interaction type string.
std::pair< pandora::CartesianVector, pandora::CartesianVector > ClusterEndPoints
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
void GetEventShapeFeatures(const pandora::ClusterList &clusterList, float &eventVolume, float &longitudinality) const
Get the event shape features.
Header file for the lar monte carlo particle helper helper class.
float m_eventShoweryness
The event showeryness feature.
Header file for the lar support vector machine class.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
SupportVectorMachine m_svMachineVertex
The vertex support vector machine.
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.
EventFeatureInfo(const float eventShoweryness, const float eventEnergy, const float eventVolume, const float longitudinality, const unsigned int nHits, const unsigned int nClusters, const unsigned int nCandidates)
Constructor.
SupportVectorMachine m_svMachineRegion
The region support vector machine.
float m_minShowerSpineLength
The minimum length at which all are considered to be tracks.
Header file for the vertex selection base algorithm class.
std::string m_mcParticleListName
The MC particle list for creating training examples.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
VertexSelectionBaseAlgorithm class.
float m_globalAsymmetry
The global asymmetry feature.
float m_mcVertexXCorrection
The correction to the x-coordinate of the MC vertex position.
float m_energyKickConstant
The energy kick constant for the initial region score list.
void PopulateInitialScoreList(VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pVertex, VertexScoreList &initialScoreList) const
Populate the initial vertex score list for a given vertex.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to svm files.
std::vector< VertexScore > VertexScoreList
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.
float m_localAsymmetry
The local asymmetry feature.
void AddEventFeaturesToVector(const EventFeatureInfo &eventFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the event features to a vector in the correct order.
float m_eventVolume
The volume of the event.
std::string m_caloHitListName
The 2D CaloHit list name.
float m_showerClusteringDistance
The shower clustering distance.
void AddVertexFeaturesToVector(const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
Add the vertex features to a vector in the correct order.
std::string m_trainingOutputFileVertex
The training output file for the vertex Svm.
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.
bool m_useShowerClusteringApproximation
Whether to use the shower clustering distance approximation.
float m_beamDeweightingConstant
The beam deweighting constant for the initial region score list.
const pandora::Vertex * CompareVertices(const pandora::VertexVector &vertexVector, const VertexFeatureInfoMap &vertexFeatureInfoMap, const LArMvaHelper::MvaFeatureVector &eventFeatureList, const SupportVectorMachine &supportVectorMachine, const bool useRPhi) const
Used a binary classifier to compare a set of vertices and pick the best one.
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...
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
std::vector< MvaFeatureTool< Ts... > * > FeatureToolVector
unsigned int m_nHits
The number of hits in the event.
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_longitudinality
The longitudinality of the event.
std::string m_svmFileName
The Svm file name.
std::string m_trainingOutputFileRegion
The training output file for the region Svm.
bool m_trainingSetMode
Whether to train.
void UpdateSpanCoordinate(const float minPositionCoord, const float maxPositionCoord, pandora::InputFloat &minCoord, pandora::InputFloat &maxCoord) const
Update the min/max coordinate spans.
std::string m_regionSvmName
The name of the region Svm to find.
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool vector.
float m_showerAsymmetry
The shower asymmetry feature.
void CalculateShowerClusterList(const pandora::ClusterList &inputClusterList, ShowerClusterList &showerClusterList) const
Calculate the shower cluster map for a cluster list.
EventFeatureInfo CalculateEventFeatures(const pandora::ClusterList &clusterListU, const pandora::ClusterList &clusterListV, const pandora::ClusterList &clusterListW, const pandora::VertexVector &vertexVector) const
Calculate the event parameters.
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
SvmVertexSelectionAlgorithm()
Default constructor.
void GetShowerLikeClusterEndPoints(const pandora::ClusterList &clusterList, pandora::ClusterList &showerLikeClusters, ClusterEndPointsMap &clusterEndPointsMap) const
Add the endpoints of any shower-like clusters to the map.
unsigned int m_nClusters
The number of clusters in the event.
float m_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.
Event feature info class.
std::vector< pandora::VertexVector > VectorOfVertexVectors
std::vector< art::Ptr< recob::Vertex > > VertexVector
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
float m_rPhiFeature
The r/phi feature.