8#ifndef LAR_TRAINED_VERTEX_SELECTION_ALGORITHM_H
9#define LAR_TRAINED_VERTEX_SELECTION_ALGORITHM_H 1
26template <
typename,
unsigned int>
27class KDTreeLinkerAlgo;
28template <
typename,
unsigned int>
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);
171 typedef std::unordered_map<const pandora::CaloHit *, const pandora::Cluster *>
HitToClusterMap;
374 std::bernoulli_distribution &coinFlip, std::mt19937 &generator,
const std::string &interactionType,
const std::string &trainingOutputFile,
396 float &separation,
float &axisHits)
const;
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)
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),
Header file for the lar adaptive boosted decision tree class.
Header file for the lar monte carlo particle helper helper class.
Header file for the lar support vector machine class.
Header file for the lar two dimensional sliding fit result class.
Header file for the pandora content api class.
Header file for the vertex selection base algorithm class.
Data stored in each KDTree node. The dim1/dim2 fields are usually the duplication of some PFRecHit va...
MvaTypes::MvaFeatureVector MvaFeatureVector
std::vector< MvaFeatureTool< Ts... > * > FeatureToolVector
Event feature info class.
float m_eventShoweryness
The event showeryness feature.
float m_eventArea
The area of the event.
unsigned int m_nCandidates
The total number of vertex candidates.
float m_eventEnergy
The event energy.
unsigned int m_nHits
The number of hits in the event.
unsigned int m_nClusters
The number of clusters in the event.
float m_longitudinality
The longitudinality of the event.
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.
Vertex feature info class.
float m_globalAsymmetry
The global asymmetry feature.
float m_beamDeweighting
The beam deweighting feature.
float m_showerAsymmetry
The shower asymmetry feature.
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_dEdxAsymmetry
The dE/dx asymmetry feature.
float m_rPhiFeature
The r/phi feature.
float m_vertexEnergy
The vertex energy feature.
float m_energyKick
The energy kick feature.
float m_localAsymmetry
The local asymmetry feature.
Shared vertex feature info class.
float m_axisHits
The hit density along the axis between the two vertices.
float m_separation
The distance between the two vertices.
VertexSharedFeatureInfo(const float separation, const float axisHits)
Constructor.
TrainedVertexSelectionAlgorithm class.
float m_showerAsymmetryConstant
The shower 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.
bool m_legacyVariables
Whether to only use the old variables.
void AddEventFeaturesToVector(const EventFeatureInfo &eventFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the event features to a vector in the correct order.
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_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.
float m_showerClusteringDistance
The shower clustering distance.
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.
float m_regionRadius
The radius for a vertex region.
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
std::vector< pandora::VertexVector > VectorOfVertexVectors
std::vector< HitKDNode2D > HitKDNode2DList
void IncrementShoweryParameters(const pandora::ClusterList &clusterList, unsigned int &nShoweryHits, unsigned int &nHits, float &eventEnergy) const
Increment the showery hit parameters for a cluster list.
bool IsClusterShowerLike(const pandora::Cluster *const pCluster) const
Find whether a cluster is shower-like.
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
void IncrementSharedAxisValues(const pandora::CartesianVector pos1, const pandora::CartesianVector pos2, HitKDTree2D &kdTree, float &axisHits) const
Increments the axis hits information for one view.
float GetCoordinateSpan(const pandora::InputFloat &minCoord, const pandora::InputFloat &maxCoord) const
Get the coordinate span.
bool m_legacyEventShapes
Whether to use the old event shapes calculation.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
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.
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.
void GetBestRegionVertices(VertexScoreList &initialScoreList, pandora::VertexVector &bestRegionVertices) const
Get the list of top-N separated vertices.
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::string m_mcParticleListName
The MC particle list for creating training examples.
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 AddVertexFeaturesToVector(const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
Add the vertex features to a vector in the correct order.
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool vector.
void UpdateSpanCoordinate(const float minPositionCoord, const float maxPositionCoord, pandora::InputFloat &minCoord, pandora::InputFloat &maxCoord) const
Update the min/max coordinate spans.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
std::string GetInteractionType() const
Get the interaction type string.
bool m_trainingSetMode
Whether to train.
bool m_useShowerClusteringApproximation
Whether to use the shower clustering distance approximation.
std::vector< LArMvaHelper::MvaFeatureVector > FeatureListVector
void GetLegacyEventShapeFeatures(const pandora::ClusterList &clusterList, float &eventVolume, float &longitudinality) const
Get the event shape features.
std::pair< pandora::CartesianVector, pandora::CartesianVector > ClusterEndPoints
float m_globalAsymmetryConstant
The global asymmetry constant for the initial region score list.
TrainedVertexSelectionAlgorithm()
Default constructor.
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.
void GetShowerLikeClusterEndPoints(const pandora::ClusterList &clusterList, pandora::ClusterList &showerLikeClusters, ClusterEndPointsMap &clusterEndPointsMap) const
Add the endpoints of any shower-like clusters to the map.
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
std::map< const pandora::Vertex *const, VertexFeatureInfo > VertexFeatureInfoMap
std::string m_trainingOutputFileRegion
The training output file for the region mva.
void AddSharedFeaturesToVector(const VertexSharedFeatureInfo &vertexSharedFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the shared features to a vector in the correct order.
void CalculateShowerClusterList(const pandora::ClusterList &inputClusterList, ShowerClusterList &showerClusterList) const
Calculate the shower cluster map for a cluster list.
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.
std::map< const pandora::Cluster *const, ClusterEndPoints > ClusterEndPointsMap
float m_mcVertexXCorrection
The correction to the x-coordinate of the MC vertex position.
float m_maxTrueVertexRadius
The maximum distance at which a vertex candidate can be considered the 'true' vertex.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region 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.
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::string m_trainingOutputFileVertex
The training output file for the vertex mva.
float m_minShowerSpineLength
The minimum length at which all are considered to be tracks.
std::string m_caloHitListName
The 2D CaloHit list name.
KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
float m_localAsymmetryConstant
The local asymmetry constant for the initial region score list.
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
bool m_dropFailedRPhiFastScoreCandidates
Whether to drop candidates that fail the r/phi fast score test.
void PopulateInitialScoreList(VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pVertex, VertexScoreList &initialScoreList) const
Populate the initial vertex score list for a given vertex.
float m_energyKickConstant
The energy kick constant for the initial region score list.
unsigned int m_minShowerClusterHits
The minimum number of shower cluster hits.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
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.
bool m_testBeamMode
Test beam mode.
float m_beamDeweightingConstant
The beam deweighting constant for the initial region score list.
void GetEventShapeFeatures(const ClusterListMap &clusterListMap, float &eventArea, float &longitudinality) const
Get the event shape features.
void Get2DSpan(const pandora::ClusterList &clusterList, float &xSpan, float &zSpan) const
Get the coordinate span in one view.
VertexSelectionBaseAlgorithm class.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
std::vector< VertexScore > VertexScoreList
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
std::vector< ShowerCluster > ShowerClusterList
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< std::string > StringVector
StatusCode
The StatusCode enum.
std::vector< const Vertex * > VertexVector