LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::SvmVertexSelectionAlgorithm Class Reference

SvmVertexSelectionAlgorithm class. More...

#include "SvmVertexSelectionAlgorithm.h"

Inheritance diagram for lar_content::SvmVertexSelectionAlgorithm:
lar_content::VertexSelectionBaseAlgorithm

Classes

class  EventFeatureInfo
 Event feature info class. More...
 
class  VertexFeatureInfo
 Vertex feature info class. More...
 

Public Types

typedef std::map< const pandora::Vertex *const, VertexFeatureInfoVertexFeatureInfoMap
 
typedef std::vector< VertexScoreVertexScoreList
 
typedef std::vector< SlidingFitDataSlidingFitDataList
 
typedef std::vector< ShowerClusterShowerClusterList
 
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 SlidingFitDataListSlidingFitDataListMap
 Map of sliding fit data lists for passing to tools. More...
 
typedef std::map< pandora::HitType, const ShowerClusterListShowerClusterListMap
 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...
 

Public Member Functions

 SvmVertexSelectionAlgorithm ()
 Default constructor. More...
 

Protected Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
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...
 

Private Types

typedef std::pair< pandora::CartesianVector, pandora::CartesianVector > ClusterEndPoints
 
typedef std::map< const pandora::Cluster *const, ClusterEndPointsClusterEndPointsMap
 
typedef std::vector< LArMvaHelper::MvaFeatureVectorFeatureListVector
 
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
 

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...
 
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 GetEventShapeFeatures (const pandora::ClusterList &clusterList, float &eventVolume, float &longitudinality) const
 Get the event shape features. 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 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 AddVertexFeaturesToVector (const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
 Add the vertex features to a vector in the correct order. More...
 
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. 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...
 

Private Attributes

VertexFeatureTool::FeatureToolVector m_featureToolVector
 The feature tool vector. More...
 
std::string m_filePathEnvironmentVariable
 The environment variable providing a list of paths to svm files. More...
 
std::string m_svmFileName
 The Svm file name. More...
 
std::string m_regionSvmName
 The name of the region Svm to find. More...
 
std::string m_vertexSvmName
 The name of the vertex Svm to find. More...
 
SupportVectorMachine m_svMachineRegion
 The region support vector machine. More...
 
SupportVectorMachine m_svMachineVertex
 The vertex support vector machine. 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 Svm. More...
 
std::string m_trainingOutputFileVertex
 The training output file for the vertex Svm. 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...
 

Detailed Description

Member Typedef Documentation

typedef std::pair<pandora::CartesianVector, pandora::CartesianVector> lar_content::SvmVertexSelectionAlgorithm::ClusterEndPoints
private

Definition at line 107 of file SvmVertexSelectionAlgorithm.h.

typedef std::map<const pandora::Cluster *const, ClusterEndPoints> lar_content::SvmVertexSelectionAlgorithm::ClusterEndPointsMap
private

Definition at line 108 of file SvmVertexSelectionAlgorithm.h.

typedef std::map<pandora::HitType, const pandora::ClusterList &> lar_content::VertexSelectionBaseAlgorithm::ClusterListMap
inherited

Map array of cluster lists for passing to tools.

Definition at line 224 of file VertexSelectionBaseAlgorithm.h.

typedef KDTreeNodeInfoT<const pandora::CaloHit*, 2> lar_content::SvmVertexSelectionAlgorithm::HitKDNode2D
private

Definition at line 144 of file SvmVertexSelectionAlgorithm.h.

typedef KDTreeLinkerAlgo<const pandora::CaloHit*, 2> lar_content::SvmVertexSelectionAlgorithm::HitKDTree2D
private

Definition at line 143 of file SvmVertexSelectionAlgorithm.h.

typedef std::unordered_map<const pandora::CaloHit*, const pandora::Cluster*> lar_content::SvmVertexSelectionAlgorithm::HitToClusterMap
private

Definition at line 147 of file SvmVertexSelectionAlgorithm.h.

typedef std::map<pandora::HitType, const std::reference_wrapper<HitKDTree2D> > lar_content::VertexSelectionBaseAlgorithm::KDTreeMap
inherited

Map array of hit kd trees for passing to tools.

Definition at line 227 of file VertexSelectionBaseAlgorithm.h.

typedef std::map<pandora::HitType, const ShowerClusterList> lar_content::VertexSelectionBaseAlgorithm::ShowerClusterListMap
inherited

Map of shower cluster lists for passing to tools.

Definition at line 226 of file VertexSelectionBaseAlgorithm.h.

typedef std::map<pandora::HitType, const SlidingFitDataList> lar_content::VertexSelectionBaseAlgorithm::SlidingFitDataListMap
inherited

Map of sliding fit data lists for passing to tools.

Definition at line 225 of file VertexSelectionBaseAlgorithm.h.

typedef std::vector<pandora::VertexVector> lar_content::SvmVertexSelectionAlgorithm::VectorOfVertexVectors
private

Definition at line 110 of file SvmVertexSelectionAlgorithm.h.

Definition at line 63 of file SvmVertexSelectionAlgorithm.h.

typedef MvaFeatureTool<const VertexSelectionBaseAlgorithm *const, const pandora::Vertex * const, const SlidingFitDataListMap &, const ClusterListMap &, const KDTreeMap &, const ShowerClusterListMap &, const float, float &> lar_content::VertexSelectionBaseAlgorithm::VertexFeatureTool
inherited

The base type for the vertex feature tools.

Definition at line 230 of file VertexSelectionBaseAlgorithm.h.

Constructor & Destructor Documentation

lar_content::SvmVertexSelectionAlgorithm::SvmVertexSelectionAlgorithm ( )

Default constructor.

Definition at line 34 of file SvmVertexSelectionAlgorithm.cc.

34  :
36  m_filePathEnvironmentVariable("FW_SEARCH_PATH"),
37  m_trainingSetMode(false),
41  m_slidingFitWindow(100),
51  m_regionRadius(10.f),
56 {
57 }
unsigned int m_minShowerClusterHits
The minimum number of shower cluster hits.
float m_globalAsymmetryConstant
The global asymmetry constant for the initial region score list.
bool m_dropFailedRPhiFastScoreCandidates
Whether to drop candidates that fail the r/phi fast score test.
float m_maxTrueVertexRadius
The maximum distance at which a vertex candidate can be considered the &#39;true&#39; vertex.
float m_showerAsymmetryConstant
The shower asymmetry constant for the initial region score list.
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
TFile f
Definition: plotHisto.C:6
float m_localAsymmetryConstant
The local asymmetry constant for the initial region score list.
float m_regionRadius
The radius for a vertex region.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
float m_minShowerSpineLength
The minimum length at which all are considered to be tracks.
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.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to svm files.
float m_showerClusteringDistance
The shower clustering distance.
bool m_useShowerClusteringApproximation
Whether to use the shower clustering distance approximation.
float m_beamDeweightingConstant
The beam deweighting constant for the initial region score list.
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
float m_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.

Member Function Documentation

bool lar_content::SvmVertexSelectionAlgorithm::AddClusterToShower ( const ClusterEndPointsMap clusterEndPointsMap,
pandora::ClusterList &  availableShowerLikeClusters,
const pandora::Cluster *const  pCluster,
pandora::ClusterList &  showerCluster 
) const
private

Try to add an available cluster to a given shower cluster, using shower clustering approximation.

Parameters
clusterEndPointsMapthe map of shower-like cluster endpoints
availableShowerLikeClustersthe list of shower-like clusters still available
pClusterthe cluster in the shower cluster from which to consider distances
showerClusterthe shower cluster
Returns
boolean

Referenced by CalculateShowerClusterList(), and PopulateKdTree().

bool lar_content::SvmVertexSelectionAlgorithm::AddClusterToShower ( HitKDTree2D kdTree,
const HitToClusterMap hitToClusterMap,
pandora::ClusterList &  availableShowerLikeClusters,
const pandora::Cluster *const  pCluster,
pandora::ClusterList &  showerCluster 
) const
private

Try to add an available cluster to a given shower cluster, using cluster hit positions cached in kd tree.

Parameters
kdTreethe kd tree, used purely for efficiency in events with large hit multiplicity
hitToClusterMapthe hit to cluster map, used to interpret kd tree findings
availableShowerLikeClustersthe list of shower-like clusters still available
pClusterthe cluster in the shower cluster from which to consider distances
showerClusterthe shower cluster
Returns
boolean
void lar_content::SvmVertexSelectionAlgorithm::AddEventFeaturesToVector ( const EventFeatureInfo eventFeatureInfo,
LArMvaHelper::MvaFeatureVector featureVector 
) const
private

Add the event features to a vector in the correct order.

Parameters
eventFeatureInfothe event feature info
featureVectorthe vector of doubles to append

Definition at line 432 of file SvmVertexSelectionAlgorithm.cc.

References lar_content::SvmVertexSelectionAlgorithm::EventFeatureInfo::m_eventEnergy, lar_content::SvmVertexSelectionAlgorithm::EventFeatureInfo::m_eventShoweryness, lar_content::SvmVertexSelectionAlgorithm::EventFeatureInfo::m_eventVolume, lar_content::SvmVertexSelectionAlgorithm::EventFeatureInfo::m_longitudinality, lar_content::SvmVertexSelectionAlgorithm::EventFeatureInfo::m_nCandidates, lar_content::SvmVertexSelectionAlgorithm::EventFeatureInfo::m_nClusters, and lar_content::SvmVertexSelectionAlgorithm::EventFeatureInfo::m_nHits.

Referenced by GetVertexScoreList().

434 {
435  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_eventShoweryness));
436  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_eventEnergy));
437  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_eventVolume));
438  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_longitudinality));
439  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_nHits));
440  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_nClusters));
441  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_nCandidates));
442 }
void lar_content::SvmVertexSelectionAlgorithm::AddVertexFeaturesToVector ( const VertexFeatureInfo vertexFeatureInfo,
LArMvaHelper::MvaFeatureVector featureVector,
const bool  useRPhi 
) const
private

Add the vertex features to a vector in the correct order.

Parameters
vertexFeatureInfothe vertex feature info
featureVectorthe vector of floats to append
useRPhiwhether to include the r/phi feature

Definition at line 687 of file SvmVertexSelectionAlgorithm.cc.

References lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_beamDeweighting, lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_energyKick, lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_globalAsymmetry, lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_localAsymmetry, lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_rPhiFeature, and lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_showerAsymmetry.

Referenced by CompareVertices(), and ProduceTrainingExamples().

689 {
690  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_beamDeweighting));
691  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_energyKick));
692  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_globalAsymmetry));
693  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_localAsymmetry));
694  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_showerAsymmetry));
695 
696  if (useRPhi)
697  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_rPhiFeature));
698 }
void lar_content::VertexSelectionBaseAlgorithm::CalculateClusterSlidingFits ( const pandora::ClusterList &  inputClusterList,
const unsigned int  minClusterCaloHits,
const unsigned int  slidingFitWindow,
SlidingFitDataList slidingFitDataList 
) const
protectedinherited

Calculate the cluster sliding fits.

Parameters
inputClusterListthe input cluster list
minClusterCaloHitsthe minimum number of cluster calo hits
slidingFitWindowthe sliding fit window
slidingFitDataListthe list of sliding fits to fill

Definition at line 119 of file VertexSelectionBaseAlgorithm.cc.

References lar_content::LArGeometryHelper::GetWireZPitch(), min, and lar_content::LArClusterHelper::SortByNHits().

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::GetVertexScoreList(), and GetVertexScoreList().

121 {
122  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
123 
124  ClusterVector sortedClusters(inputClusterList.begin(), inputClusterList.end());
125  std::sort(sortedClusters.begin(), sortedClusters.end(), LArClusterHelper::SortByNHits);
126 
127  for (const Cluster * const pCluster : sortedClusters)
128  {
129  if (pCluster->GetNCaloHits() < minClusterCaloHits)
130  continue;
131 
132  // Make sure the window size is such that there are not more layers than hits (following TwoDSlidingLinearFit calculation).
133  const unsigned int newSlidingFitWindow(std::min(static_cast<int>(pCluster->GetNCaloHits()), static_cast<int>(slidingFitPitch * slidingFitWindow)));
134  slidingFitDataList.emplace_back(pCluster, newSlidingFitWindow, slidingFitPitch);
135  }
136 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
Int_t min
Definition: plot.C:26
SvmVertexSelectionAlgorithm::EventFeatureInfo lar_content::SvmVertexSelectionAlgorithm::CalculateEventFeatures ( const pandora::ClusterList &  clusterListU,
const pandora::ClusterList &  clusterListV,
const pandora::ClusterList &  clusterListW,
const pandora::VertexVector &  vertexVector 
) const
private

Calculate the event parameters.

Parameters
clusterListUthe U-view cluster list
clusterListVthe V-view cluster list
clusterListWthe W-view cluster list
vertexVectorthe vector of vertex candidates
Returns
the EventFeatureInfo object

Definition at line 323 of file SvmVertexSelectionAlgorithm.cc.

References f, GetEventShapeFeatures(), and IncrementShoweryParameters().

Referenced by GetVertexScoreList().

325 {
326  float eventEnergy(0.f);
327  unsigned int nShoweryHits(0), nHits(0);
328 
329  this->IncrementShoweryParameters(clusterListU, nShoweryHits, nHits, eventEnergy);
330  this->IncrementShoweryParameters(clusterListV, nShoweryHits, nHits, eventEnergy);
331  this->IncrementShoweryParameters(clusterListW, nShoweryHits, nHits, eventEnergy);
332 
333  const unsigned int nClusters(clusterListU.size() + clusterListV.size() + clusterListW.size());
334  const float eventShoweryness((nHits > 0) ? static_cast<float>(nShoweryHits) / static_cast<float>(nHits) : 0.f);
335 
336  ClusterList allClusters(clusterListU);
337  allClusters.insert(allClusters.end(), clusterListV.begin(), clusterListV.end());
338  allClusters.insert(allClusters.end(), clusterListW.begin(), clusterListW.end());
339 
340  float eventVolume(0.f), longitudinality(0.f);
341  this->GetEventShapeFeatures(allClusters, eventVolume, longitudinality);
342 
343  return EventFeatureInfo(eventShoweryness, eventEnergy, eventVolume, longitudinality, nHits, nClusters, vertexVector.size());
344 }
void IncrementShoweryParameters(const pandora::ClusterList &clusterList, unsigned int &nShoweryHits, unsigned int &nHits, float &eventEnergy) const
Increment the showery hit parameters for a cluster list.
TFile f
Definition: plotHisto.C:6
void GetEventShapeFeatures(const pandora::ClusterList &clusterList, float &eventVolume, float &longitudinality) const
Get the event shape features.
void lar_content::SvmVertexSelectionAlgorithm::CalculateRPhiScores ( pandora::VertexVector &  vertexVector,
VertexFeatureInfoMap vertexFeatureInfoMap,
const KDTreeMap kdTreeMap 
) const
private

Calculate the r/phi scores for the vertices in a vector, possibly erasing those that fail the fast score test.

Parameters
vertexVectorthe vector of vertices
vertexFeatureInfoMapthe vertex feature info map
kdTreeMapthe kd tree map

Definition at line 564 of file SvmVertexSelectionAlgorithm.cc.

References lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_beamDeweighting, m_dropFailedRPhiFastScoreCandidates, m_featureToolVector, lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_rPhiFeature, and max.

Referenced by GetVertexScoreList(), and ProduceTrainingSets().

566 {
567  float bestFastScore(-std::numeric_limits<float>::max());
568 
569  for (auto iter = vertexVector.begin(); iter != vertexVector.end(); /* no increment */)
570  {
571  VertexFeatureInfo &vertexFeatureInfo = vertexFeatureInfoMap.at(*iter);
572  vertexFeatureInfo.m_rPhiFeature = static_cast<float>(LArMvaHelper::CalculateFeaturesOfType<RPhiFeatureTool>(m_featureToolVector, this, *iter,
573  SlidingFitDataListMap(), ClusterListMap(), kdTreeMap, ShowerClusterListMap(), vertexFeatureInfo.m_beamDeweighting,
574  bestFastScore).at(0).Get());
575 
576  if (m_dropFailedRPhiFastScoreCandidates && (vertexFeatureInfo.m_rPhiFeature <= std::numeric_limits<float>::epsilon()))
577  iter = vertexVector.erase(iter);
578 
579  else
580  ++iter;
581  }
582 }
bool m_dropFailedRPhiFastScoreCandidates
Whether to drop candidates that fail the r/phi fast score test.
Int_t max
Definition: plot.C:27
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool vector.
void lar_content::SvmVertexSelectionAlgorithm::CalculateShowerClusterList ( const pandora::ClusterList &  inputClusterList,
ShowerClusterList showerClusterList 
) const
private

Calculate the shower cluster map for a cluster list.

Parameters
inputClusterListthe input cluster list
showerClusterListthe shower cluster list to populate

Definition at line 148 of file SvmVertexSelectionAlgorithm.cc.

References AddClusterToShower(), GetShowerLikeClusterEndPoints(), lar_content::LArGeometryHelper::GetWireZPitch(), m_minClusterCaloHits, m_slidingFitWindow, m_useShowerClusteringApproximation, and PopulateKdTree().

Referenced by GetVertexScoreList().

149 {
150  ClusterEndPointsMap clusterEndPointsMap;
151  ClusterList showerLikeClusters;
152  this->GetShowerLikeClusterEndPoints(inputClusterList, showerLikeClusters, clusterEndPointsMap);
153 
154  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
155  ClusterList availableShowerLikeClusters(showerLikeClusters.begin(), showerLikeClusters.end());
156 
157  HitKDTree2D kdTree;
158  HitToClusterMap hitToClusterMap;
159 
161  this->PopulateKdTree(availableShowerLikeClusters, kdTree, hitToClusterMap);
162 
163  while (!availableShowerLikeClusters.empty())
164  {
165  ClusterList showerCluster;
166  showerCluster.push_back(availableShowerLikeClusters.back());
167  availableShowerLikeClusters.pop_back();
168 
169  bool addedCluster(true);
170  while (addedCluster && !availableShowerLikeClusters.empty())
171  {
172  addedCluster = false;
173  for (const Cluster *const pCluster : showerCluster)
174  {
176  {
177  addedCluster = this->AddClusterToShower(kdTree, hitToClusterMap, availableShowerLikeClusters, pCluster, showerCluster);
178  }
179  else
180  {
181  addedCluster = this->AddClusterToShower(clusterEndPointsMap, availableShowerLikeClusters, pCluster, showerCluster);
182  }
183 
184  if (addedCluster)
185  break;
186  }
187  }
188 
189  unsigned int totHits(0);
190  for (const Cluster *const pCluster : showerCluster)
191  totHits += pCluster->GetNCaloHits();
192 
193  if (totHits < m_minClusterCaloHits)
194  continue;
195 
196  showerClusterList.emplace_back(showerCluster, slidingFitPitch, m_slidingFitWindow);
197  }
198 }
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
std::map< const pandora::Cluster *const, ClusterEndPoints > ClusterEndPointsMap
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
bool m_useShowerClusteringApproximation
Whether to use the shower clustering distance approximation.
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 PopulateKdTree(const pandora::ClusterList &clusterList, HitKDTree2D &kdTree, HitToClusterMap &hitToClusterMap) const
Populate kd tree with information about hits in a provided list of clusters.
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
void GetShowerLikeClusterEndPoints(const pandora::ClusterList &clusterList, pandora::ClusterList &showerLikeClusters, ClusterEndPointsMap &clusterEndPointsMap) const
Add the endpoints of any shower-like clusters to the map.
const pandora::Vertex * lar_content::SvmVertexSelectionAlgorithm::CompareVertices ( const pandora::VertexVector &  vertexVector,
const VertexFeatureInfoMap vertexFeatureInfoMap,
const LArMvaHelper::MvaFeatureVector eventFeatureList,
const SupportVectorMachine supportVectorMachine,
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
supportVectorMachinethe support vector machine classifier
useRPhiwhether to include the r/phi feature
Returns
address of the best vertex

Definition at line 702 of file SvmVertexSelectionAlgorithm.cc.

References AddVertexFeaturesToVector(), and lar_content::LArMvaHelper::Classify().

Referenced by GetVertexScoreList().

704 {
705  const Vertex *pBestVertex(vertexVector.front());
706  LArMvaHelper::MvaFeatureVector chosenFeatureList;
707 
708  VertexFeatureInfo chosenVertexFeatureInfo(vertexFeatureInfoMap.at(pBestVertex));
709  this->AddVertexFeaturesToVector(chosenVertexFeatureInfo, chosenFeatureList, useRPhi);
710 
711  for (const Vertex *const pVertex : vertexVector)
712  {
713  if (pVertex == pBestVertex)
714  continue;
715 
716  LArMvaHelper::MvaFeatureVector featureList;
717  VertexFeatureInfo vertexFeatureInfo(vertexFeatureInfoMap.at(pVertex));
718  this->AddVertexFeaturesToVector(vertexFeatureInfo, featureList, useRPhi);
719 
720  if (LArMvaHelper::Classify(supportVectorMachine, eventFeatureList, featureList, chosenFeatureList))
721  {
722  pBestVertex = pVertex;
723  chosenFeatureList = featureList;
724  }
725  }
726 
727  return pBestVertex;
728 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:58
static bool Classify(const MvaInterface &classifier, TLISTS &&...featureLists)
Use the trained classifier to predict the boolean class of an example.
Definition: LArMvaHelper.h:220
void AddVertexFeaturesToVector(const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
Add the vertex features to a vector in the correct order.
void lar_content::VertexSelectionBaseAlgorithm::FilterVertexList ( const pandora::VertexList *const  pInputVertexList,
HitKDTree2D kdTreeU,
HitKDTree2D kdTreeV,
HitKDTree2D kdTreeW,
pandora::VertexVector &  filteredVertices 
) const
protectedvirtualinherited

Filter the input list of vertices to obtain a reduced number of vertex candidates.

Parameters
pInputVertexListthe address of the input vertex list
kdTreeUthe kd tree for u hits
kdTreeVthe kd tree for v hits
kdTreeWthe kd tree for w hits
filteredVerticesto receive the filtered vertex list

Definition at line 40 of file VertexSelectionBaseAlgorithm.cc.

References lar_content::KDTreeLinkerAlgo< DATA, DIM >::empty(), lar_content::VertexSelectionBaseAlgorithm::IsVertexInGap(), lar_content::VertexSelectionBaseAlgorithm::IsVertexOnHit(), lar_content::VertexSelectionBaseAlgorithm::m_isEmptyViewAcceptable, lar_content::VertexSelectionBaseAlgorithm::m_minVertexAcceptableViews, and lar_content::VertexSelectionBaseAlgorithm::SortByVertexZPosition().

Referenced by lar_content::VertexSelectionBaseAlgorithm::Run().

42 {
43  for (const Vertex *const pVertex : *pInputVertexList)
44  {
45  unsigned int nAcceptableViews(0);
46 
47  if ((m_isEmptyViewAcceptable && kdTreeU.empty()) || this->IsVertexOnHit(pVertex, TPC_VIEW_U, kdTreeU) || this->IsVertexInGap(pVertex, TPC_VIEW_U))
48  ++nAcceptableViews;
49 
50  if ((m_isEmptyViewAcceptable && kdTreeV.empty()) || this->IsVertexOnHit(pVertex, TPC_VIEW_V, kdTreeV) || this->IsVertexInGap(pVertex, TPC_VIEW_V))
51  ++nAcceptableViews;
52 
53  if ((m_isEmptyViewAcceptable && kdTreeW.empty()) || this->IsVertexOnHit(pVertex, TPC_VIEW_W, kdTreeW) || this->IsVertexInGap(pVertex, TPC_VIEW_W))
54  ++nAcceptableViews;
55 
56  if (nAcceptableViews >= m_minVertexAcceptableViews)
57  filteredVertices.push_back(pVertex);
58  }
59 
60  std::sort(filteredVertices.begin(), filteredVertices.end(), SortByVertexZPosition);
61 }
bool IsVertexOnHit(const pandora::Vertex *const pVertex, const pandora::HitType hitType, HitKDTree2D &kdTree) const
Whether the vertex lies on a hit in the specified view.
bool IsVertexInGap(const pandora::Vertex *const pVertex, const pandora::HitType hitType) const
Whether the vertex lies in a registered gap.
static bool SortByVertexZPosition(const pandora::Vertex *const pLhs, const pandora::Vertex *const pRhs)
Sort vertices by increasing z position.
bool m_isEmptyViewAcceptable
Whether views entirely empty of hits are classed as &#39;acceptable&#39; for candidate filtration.
unsigned int m_minVertexAcceptableViews
The minimum number of views in which a candidate must sit on/near a hit or in a gap (or view can be e...
void lar_content::VertexSelectionBaseAlgorithm::GetBeamConstants ( const pandora::VertexVector &  vertexVector,
BeamConstants beamConstants 
) const
protectedvirtualinherited

Get the beam score constants for a provided list of candidate vertices.

Parameters
vertexVectorthe vertex vector
beamConstantsto receive the beam constants

Definition at line 65 of file VertexSelectionBaseAlgorithm.cc.

References f, lar_content::VertexSelectionBaseAlgorithm::m_beamMode, lar_content::VertexSelectionBaseAlgorithm::m_nDecayLengthsInZSpan, max, and lar_content::VertexSelectionBaseAlgorithm::BeamConstants::SetConstants().

Referenced by lar_content::VertexSelectionBaseAlgorithm::Run().

66 {
67  if (!m_beamMode)
68  return;
69 
70  if (vertexVector.empty())
71  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
72 
73  float minZCoordinate(std::numeric_limits<float>::max()), maxZCoordinate(-std::numeric_limits<float>::max());
74 
75  for (const Vertex *const pVertex : vertexVector)
76  {
77  if (pVertex->GetPosition().GetZ() < minZCoordinate)
78  minZCoordinate = pVertex->GetPosition().GetZ();
79 
80  if (pVertex->GetPosition().GetZ() > maxZCoordinate)
81  maxZCoordinate = pVertex->GetPosition().GetZ();
82  }
83 
84  const float zSpan(maxZCoordinate - minZCoordinate);
85  const float decayConstant((zSpan < std::numeric_limits<float>::epsilon()) ? 0.f : (m_nDecayLengthsInZSpan / zSpan));
86  beamConstants.SetConstants(minZCoordinate, decayConstant);
87 }
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
bool m_beamMode
Whether to run in beam mode, assuming neutrinos travel in positive z-direction.
float m_nDecayLengthsInZSpan
The number of score decay lengths to use over the course of the vertex z-span.
float lar_content::VertexSelectionBaseAlgorithm::GetBeamDeweightingScore ( const BeamConstants beamConstants,
const pandora::Vertex *const  pVertex 
) const
inlineprotectedinherited

Get the beam deweighting score for a vertex.

Parameters
beamConstantsthe beam constants
pVertexaddress of the vertex
Returns
the score

Definition at line 394 of file VertexSelectionBaseAlgorithm.h.

References lar_content::VertexSelectionBaseAlgorithm::BeamConstants::GetDecayConstant(), lar_content::VertexSelectionBaseAlgorithm::BeamConstants::GetMinZCoordinate(), and max.

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::GetVertexScoreList(), and PopulateVertexFeatureInfoMap().

395 {
396  const float vertexMinZ(std::max(pVertex->GetPosition().GetZ(), beamConstants.GetMinZCoordinate()));
397  return (beamConstants.GetMinZCoordinate() - vertexMinZ) * beamConstants.GetDecayConstant();
398 }
Int_t max
Definition: plot.C:27
void lar_content::SvmVertexSelectionAlgorithm::GetBestRegionVertices ( VertexScoreList initialScoreList,
pandora::VertexVector &  bestRegionVertices 
) const
private

Get the list of top-N separated vertices.

Parameters
initialScoreListthe initial score list
bestRegionVerticesthe list of best region vertices populate

Definition at line 491 of file SvmVertexSelectionAlgorithm.cc.

References m_regionRadius.

Referenced by GetVertexScoreList().

492 {
493  std::sort(initialScoreList.begin(), initialScoreList.end());
494 
495  for (const VertexScore &vertexScore : initialScoreList)
496  {
497  const Vertex *const pVertex(vertexScore.GetVertex());
498  bool farEnoughAway(true);
499 
500  for (const Vertex *const pRegionVertex: bestRegionVertices)
501  {
502  if (pRegionVertex == pVertex)
503  {
504  farEnoughAway = false;
505  break;
506  }
507 
508  const float distance = (pRegionVertex->GetPosition() - pVertex->GetPosition()).GetMagnitude();
509 
510  if (distance <= m_regionRadius)
511  {
512  farEnoughAway = false;
513  break;
514  }
515  }
516 
517  if (farEnoughAway)
518  bestRegionVertices.push_back(pVertex);
519  }
520 }
float m_regionRadius
The radius for a vertex region.
void lar_content::SvmVertexSelectionAlgorithm::GetBestVertex ( const pandora::VertexVector &  vertexVector,
const pandora::Vertex *&  pBestVertex,
float &  bestVertexDr 
) const
private

Use the MC information to get the best vertex from a list.

Parameters
vertexVectorthe vector of vertices
pBestVertexaddress of the best vertex
bestVertexDrdR of the best vertex

Definition at line 654 of file SvmVertexSelectionAlgorithm.cc.

References lar_content::LArMCParticleHelper::GetTrueNeutrinos(), m_mcParticleListName, m_mcVertexXCorrection, and max.

Referenced by ProduceTrainingExamples().

655 {
656  // Extract input collections
657  const MCParticleList *pMCParticleList(nullptr);
658  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
659 
660  // Obtain vector: true neutrinos
661  MCParticleVector mcNeutrinoVector;
662  LArMCParticleHelper::GetTrueNeutrinos(pMCParticleList, mcNeutrinoVector);
663 
664  for (const Vertex *const pVertex : vertexVector)
665  {
666  float mcVertexDr(std::numeric_limits<float>::max());
667  for (const MCParticle *const pMCNeutrino : mcNeutrinoVector)
668  {
669  const CartesianVector mcNeutrinoPosition(pMCNeutrino->GetEndpoint().GetX() + m_mcVertexXCorrection, pMCNeutrino->GetEndpoint().GetY(),
670  pMCNeutrino->GetEndpoint().GetZ());
671 
672  const float dr = (mcNeutrinoPosition - pVertex->GetPosition()).GetMagnitude();
673  if (dr < mcVertexDr)
674  mcVertexDr = dr;
675  }
676 
677  if (mcVertexDr < bestVertexDr)
678  {
679  bestVertexDr = mcVertexDr;
680  pBestVertex = pVertex;
681  }
682  }
683 }
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
Int_t max
Definition: plot.C:27
std::string m_mcParticleListName
The MC particle list for creating training examples.
float m_mcVertexXCorrection
The correction to the x-coordinate of the MC vertex position.
static void GetTrueNeutrinos(const pandora::MCParticleList *const pMCParticleList, pandora::MCParticleVector &trueNeutrinos)
Get neutrino MC particles from an input MC particle list.
void lar_content::VertexSelectionBaseAlgorithm::GetClusterLists ( const pandora::StringVector &  inputClusterListNames,
pandora::ClusterList &  clusterListU,
pandora::ClusterList &  clusterListV,
pandora::ClusterList &  clusterListW 
) const
protectedinherited

Get the cluster lists.

Parameters
inputClusterListNamesthe input cluster list names
clusterListUthe U-view cluster list to populate
clusterListVthe V-view cluster list to populate
clusterListWthe W-view cluster list to populate

Definition at line 91 of file VertexSelectionBaseAlgorithm.cc.

References lar_content::LArClusterHelper::GetClusterHitType().

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::GetVertexScoreList(), and GetVertexScoreList().

93 {
94  for (const std::string &clusterListName : inputClusterListNames)
95  {
96  const ClusterList *pClusterList(NULL);
97  PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, clusterListName, pClusterList));
98 
99  if (!pClusterList || pClusterList->empty())
100  {
101  if (PandoraContentApi::GetSettings(*this)->ShouldDisplayAlgorithmInfo())
102  std::cout << "EnergyKickVertexSelectionAlgorithm: unable to find cluster list " << clusterListName << std::endl;
103 
104  continue;
105  }
106 
107  const HitType hitType(LArClusterHelper::GetClusterHitType(*(pClusterList->begin())));
108 
109  if ((TPC_VIEW_U != hitType) && (TPC_VIEW_V != hitType) && (TPC_VIEW_W != hitType))
110  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
111 
112  ClusterList &clusterList((TPC_VIEW_U == hitType) ? clusterListU : (TPC_VIEW_V == hitType) ? clusterListV : clusterListW);
113  clusterList.insert(clusterList.end(), pClusterList->begin(), pClusterList->end());
114  }
115 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
float lar_content::SvmVertexSelectionAlgorithm::GetCoordinateSpan ( const pandora::InputFloat &  minCoord,
const pandora::InputFloat &  maxCoord 
) const
inlineprivate

Get the coordinate span.

Parameters
minCoordthe min coordinate
maxCoordthe max coordinate
Returns
the coordinate span

Definition at line 422 of file SvmVertexSelectionAlgorithm.cc.

Referenced by GetEventShapeFeatures().

423 {
424  if (minCoord.IsInitialized() && maxCoord.IsInitialized())
425  return std::fabs(maxCoord.Get() - minCoord.Get());
426 
427  return 0.f;
428 }
void lar_content::SvmVertexSelectionAlgorithm::GetEventShapeFeatures ( const pandora::ClusterList &  clusterList,
float &  eventVolume,
float &  longitudinality 
) const
private

Get the event shape features.

Parameters
clusterListthe cluster list
eventVolumethe event volume
longitudinalitythe event longitudinality

Definition at line 370 of file SvmVertexSelectionAlgorithm.cc.

References f, lar_content::LArClusterHelper::GetClusterBoundingBox(), GetCoordinateSpan(), and UpdateSpanCoordinate().

Referenced by CalculateEventFeatures().

371 {
372  InputFloat xMin, yMin, zMin, xMax, yMax, zMax;
373 
374  for (const Cluster *const pCluster : clusterList)
375  {
376  CartesianVector minPosition(0.f, 0.f, 0.f), maxPosition(0.f, 0.f, 0.f);
377  LArClusterHelper::GetClusterBoundingBox(pCluster, minPosition, maxPosition);
378 
379  this->UpdateSpanCoordinate(minPosition.GetX(), maxPosition.GetX(), xMin, xMax);
380  this->UpdateSpanCoordinate(minPosition.GetY(), maxPosition.GetY(), yMin, yMax);
381  this->UpdateSpanCoordinate(minPosition.GetZ(), maxPosition.GetZ(), zMin, zMax);
382  }
383 
384  const float xSpan(this->GetCoordinateSpan(xMax, xMin));
385  const float ySpan(this->GetCoordinateSpan(yMax, zMin));
386  const float zSpan(this->GetCoordinateSpan(yMax, zMin));
387 
388  // Calculate the volume and longitudinality of the event (ySpan often 0 - to be investigated).
389  if ((xSpan > std::numeric_limits<float>::epsilon()) && (ySpan > std::numeric_limits<float>::epsilon()))
390  {
391  eventVolume = xSpan * ySpan * zSpan;
392  longitudinality = zSpan / (xSpan + ySpan);
393  }
394 
395  else if (ySpan > std::numeric_limits<float>::epsilon())
396  {
397  eventVolume = ySpan * ySpan * zSpan;
398  longitudinality = zSpan / (ySpan + ySpan);
399  }
400 
401  else if (xSpan > std::numeric_limits<float>::epsilon())
402  {
403  eventVolume = xSpan * xSpan * zSpan;
404  longitudinality = zSpan / (xSpan + xSpan);
405  }
406 }
float GetCoordinateSpan(const pandora::InputFloat &minCoord, const pandora::InputFloat &maxCoord) const
Get the coordinate span.
TFile f
Definition: plotHisto.C:6
static void GetClusterBoundingBox(const pandora::Cluster *const pCluster, pandora::CartesianVector &minimumCoordinate, pandora::CartesianVector &maximumCoordinate)
Get minimum and maximum X, Y and Z positions of the calo hits in a cluster.
void UpdateSpanCoordinate(const float minPositionCoord, const float maxPositionCoord, pandora::InputFloat &minCoord, pandora::InputFloat &maxCoord) const
Update the min/max coordinate spans.
std::string lar_content::SvmVertexSelectionAlgorithm::GetInteractionType ( ) const
private

Get the interaction type string.

Returns
the interaction type string

Definition at line 586 of file SvmVertexSelectionAlgorithm.cc.

References lar_content::LArInteractionTypeHelper::GetInteractionType(), lar_content::LArMCParticleHelper::IsBeamNeutrinoFinalState(), m_caloHitListName, m_mcParticleListName, lar_content::LArMCParticleHelper::SelectReconstructableMCParticles(), lar_content::LArMCParticleHelper::SortByMomentum(), and lar_content::LArInteractionTypeHelper::ToString().

Referenced by ProduceTrainingSets().

587 {
588  // Extract input collections
589  const MCParticleList *pMCParticleList(nullptr);
590  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
591 
592  const CaloHitList *pCaloHitList(nullptr);
593  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_caloHitListName, pCaloHitList));
594 
595  // ATTN Assumes single neutrino is parent of all neutrino-induced mc particles
596  LArMCParticleHelper::MCContributionMap nuMCParticlesToGoodHitsMap;
597  LArMCParticleHelper::SelectReconstructableMCParticles(pMCParticleList, pCaloHitList, LArMCParticleHelper::PrimaryParameters(),
598  LArMCParticleHelper::IsBeamNeutrinoFinalState, nuMCParticlesToGoodHitsMap);
599 
600  MCParticleList mcPrimaryList;
601  for (const auto &mapEntry : nuMCParticlesToGoodHitsMap) mcPrimaryList.push_back(mapEntry.first);
602  mcPrimaryList.sort(LArMCParticleHelper::SortByMomentum);
603 
605  return LArInteractionTypeHelper::ToString(interactionType);
606 }
static InteractionType GetInteractionType(const pandora::MCParticleList &mcPrimaryList)
Get the interaction type of an event.
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
static void SelectReconstructableMCParticles(const pandora::MCParticleList *pMCParticleList, const pandora::CaloHitList *pCaloHitList, const PrimaryParameters &parameters, std::function< bool(const pandora::MCParticle *const)> fCriteria, MCContributionMap &selectedMCParticlesToHitsMap)
Select primary, reconstructable mc particles that match given criteria.
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
static std::string ToString(const InteractionType interactionType)
Get a string representation of an interaction type.
std::string m_mcParticleListName
The MC particle list for creating training examples.
std::string m_caloHitListName
The 2D CaloHit list name.
static bool IsBeamNeutrinoFinalState(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary neutrino final state MCParticle.
void lar_content::SvmVertexSelectionAlgorithm::GetShowerLikeClusterEndPoints ( const pandora::ClusterList &  clusterList,
pandora::ClusterList &  showerLikeClusters,
ClusterEndPointsMap clusterEndPointsMap 
) const
private

Add the endpoints of any shower-like clusters to the map.

Parameters
clusterListthe list of clusters
showerLikeClustersthe list of shower-like clusters to populate
clusterEndPointsMapthe map of shower-like cluster endpoints to populate

Definition at line 202 of file SvmVertexSelectionAlgorithm.cc.

References IsClusterShowerLike(), m_minShowerClusterHits, and lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by CalculateShowerClusterList().

204 {
205  for (const Cluster *const pCluster : clusterList)
206  {
207  if (pCluster->GetNCaloHits() < m_minShowerClusterHits)
208  continue;
209 
210  if (this->IsClusterShowerLike(pCluster))
211  showerLikeClusters.push_back(pCluster);
212 
213  CaloHitList clusterCaloHitList;
214  pCluster->GetOrderedCaloHitList().FillCaloHitList(clusterCaloHitList);
215 
216  CaloHitVector clusterCaloHitVector(clusterCaloHitList.begin(), clusterCaloHitList.end());
217  std::sort(clusterCaloHitVector.begin(), clusterCaloHitVector.end(), LArClusterHelper::SortHitsByPosition);
218 
219  if (clusterCaloHitVector.empty())
220  continue;
221 
222  ClusterEndPoints clusterEndPoints(clusterCaloHitVector.front()->GetPositionVector(), clusterCaloHitVector.back()->GetPositionVector());
223  clusterEndPointsMap.emplace(pCluster, clusterEndPoints);
224  }
225 }
unsigned int m_minShowerClusterHits
The minimum number of shower cluster hits.
bool IsClusterShowerLike(const pandora::Cluster *const pCluster) const
Find whether a cluster is shower-like.
std::pair< pandora::CartesianVector, pandora::CartesianVector > ClusterEndPoints
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
void lar_content::SvmVertexSelectionAlgorithm::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::VertexSelectionBaseAlgorithm.

Definition at line 61 of file SvmVertexSelectionAlgorithm.cc.

References AddEventFeaturesToVector(), lar_content::VertexSelectionBaseAlgorithm::CalculateClusterSlidingFits(), CalculateEventFeatures(), CalculateRPhiScores(), CalculateShowerClusterList(), CompareVertices(), GetBestRegionVertices(), lar_content::VertexSelectionBaseAlgorithm::GetClusterLists(), m_allowClassifyDuringTraining, m_inputClusterListNames, m_minClusterCaloHits, m_regionRadius, m_slidingFitWindow, m_svMachineRegion, m_svMachineVertex, m_trainingSetMode, m_useRPhiFeatureForRegion, PopulateFinalVertexScoreList(), PopulateInitialScoreList(), PopulateVertexFeatureInfoMap(), and ProduceTrainingSets().

63 {
64  ClusterList clustersU, clustersV, clustersW;
65  this->GetClusterLists(m_inputClusterListNames, clustersU, clustersV, clustersW);
66 
67  SlidingFitDataList slidingFitDataListU, slidingFitDataListV, slidingFitDataListW;
68  this->CalculateClusterSlidingFits(clustersU, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListU);
69  this->CalculateClusterSlidingFits(clustersV, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListV);
70  this->CalculateClusterSlidingFits(clustersW, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListW);
71 
72  ShowerClusterList showerClusterListU, showerClusterListV, showerClusterListW;
73  this->CalculateShowerClusterList(clustersU, showerClusterListU);
74  this->CalculateShowerClusterList(clustersV, showerClusterListV);
75  this->CalculateShowerClusterList(clustersW, showerClusterListW);
76 
77  // Create maps from hit types to objects for passing to feature tools.
78  const ClusterListMap clusterListMap{{TPC_VIEW_U, clustersU},
79  {TPC_VIEW_V, clustersV},
80  {TPC_VIEW_W, clustersV}};
81 
82  const SlidingFitDataListMap slidingFitDataListMap{{TPC_VIEW_U, slidingFitDataListU},
83  {TPC_VIEW_V, slidingFitDataListV},
84  {TPC_VIEW_W, slidingFitDataListW}};
85 
86  const ShowerClusterListMap showerClusterListMap{{TPC_VIEW_U, showerClusterListU},
87  {TPC_VIEW_V, showerClusterListV},
88  {TPC_VIEW_W, showerClusterListW}};
89 
90  const KDTreeMap kdTreeMap{{TPC_VIEW_U, kdTreeU},
91  {TPC_VIEW_V, kdTreeV},
92  {TPC_VIEW_W, kdTreeW}};
93 
94  // Calculate the event feature list and the vertex feature map.
95  EventFeatureInfo eventFeatureInfo(this->CalculateEventFeatures(clustersU, clustersV, clustersW, vertexVector));
96 
97  LArMvaHelper::MvaFeatureVector eventFeatureList;
98  this->AddEventFeaturesToVector(eventFeatureInfo, eventFeatureList);
99 
100  VertexFeatureInfoMap vertexFeatureInfoMap;
101  for (const Vertex *const pVertex : vertexVector)
102  {
103  this->PopulateVertexFeatureInfoMap(beamConstants, clusterListMap, slidingFitDataListMap, showerClusterListMap, kdTreeMap, pVertex,
104  vertexFeatureInfoMap);
105  }
106 
107  // Use a simple score to get the list of vertices representing good regions.
108  VertexScoreList initialScoreList;
109  for (const Vertex *const pVertex : vertexVector)
110  PopulateInitialScoreList(vertexFeatureInfoMap, pVertex, initialScoreList);
111 
112  VertexVector bestRegionVertices;
113  this->GetBestRegionVertices(initialScoreList, bestRegionVertices);
114 
115  if (m_trainingSetMode)
116  this->ProduceTrainingSets(vertexVector, bestRegionVertices, vertexFeatureInfoMap, eventFeatureList, kdTreeMap);
117 
118  if ((!m_trainingSetMode || m_allowClassifyDuringTraining) && !bestRegionVertices.empty())
119  {
120  // Use svm to choose the region.
121  const Vertex *const pBestRegionVertex(this->CompareVertices(bestRegionVertices, vertexFeatureInfoMap, eventFeatureList, m_svMachineRegion,
123 
124  // Get all the vertices in the best region.
125  VertexVector regionalVertices{pBestRegionVertex};
126  for (const Vertex *const pVertex : vertexVector)
127  {
128  if (pVertex == pBestRegionVertex)
129  continue;
130 
131  if ((pBestRegionVertex->GetPosition() - pVertex->GetPosition()).GetMagnitude() < m_regionRadius)
132  regionalVertices.push_back(pVertex);
133  }
134 
135  this->CalculateRPhiScores(regionalVertices, vertexFeatureInfoMap, kdTreeMap);
136 
137  if (!regionalVertices.empty())
138  {
139  // Use svm to choose the vertex and then fine-tune using the RPhi score.
140  const Vertex *const pBestVertex(this->CompareVertices(regionalVertices, vertexFeatureInfoMap, eventFeatureList, m_svMachineVertex, true));
141  this->PopulateFinalVertexScoreList(vertexFeatureInfoMap, pBestVertex, vertexVector, vertexScoreList);
142  }
143  }
144 }
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...
void GetBestRegionVertices(VertexScoreList &initialScoreList, pandora::VertexVector &bestRegionVertices) const
Get the list of top-N separated vertices.
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:58
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 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...
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
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.
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.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
SupportVectorMachine m_svMachineVertex
The vertex support vector machine.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
SupportVectorMachine m_svMachineRegion
The region support vector machine.
void PopulateInitialScoreList(VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pVertex, VertexScoreList &initialScoreList) const
Populate the initial vertex score list for a given vertex.
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 AddEventFeaturesToVector(const EventFeatureInfo &eventFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the event features to a vector in the correct order.
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.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data 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.
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.
std::vector< art::Ptr< recob::Vertex > > VertexVector
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
void lar_content::SvmVertexSelectionAlgorithm::IncrementShoweryParameters ( const pandora::ClusterList &  clusterList,
unsigned int &  nShoweryHits,
unsigned int &  nHits,
float &  eventEnergy 
) const
private

Increment the showery hit parameters for a cluster list.

Parameters
clusterListthe cluster list
nShoweryHitsthe number of showery hits
nHitsthe number of hits
eventEnergythe event energy

Definition at line 348 of file SvmVertexSelectionAlgorithm.cc.

References IsClusterShowerLike().

Referenced by CalculateEventFeatures().

350 {
351  for (const Cluster *const pCluster : clusterList)
352  {
353  if (this->IsClusterShowerLike(pCluster))
354  nShoweryHits += pCluster->GetNCaloHits();
355 
356  eventEnergy += pCluster->GetElectromagneticEnergy();
357  nHits += pCluster->GetNCaloHits();
358  }
359 }
bool IsClusterShowerLike(const pandora::Cluster *const pCluster) const
Find whether a cluster is shower-like.
bool lar_content::VertexSelectionBaseAlgorithm::IsBeamModeOn ( ) const
inlineprotectedinherited

Whether algorithm is running in beam mode, assuming neutrinos travel in positive z-direction.

Returns
boolean

Definition at line 402 of file VertexSelectionBaseAlgorithm.h.

References lar_content::VertexSelectionBaseAlgorithm::m_beamMode.

Referenced by lar_content::EnergyKickVertexSelectionAlgorithm::GetVertexScoreList().

403 {
404  return m_beamMode;
405 }
bool m_beamMode
Whether to run in beam mode, assuming neutrinos travel in positive z-direction.
bool lar_content::SvmVertexSelectionAlgorithm::IsClusterShowerLike ( const pandora::Cluster *const  pCluster) const
inlineprivate

Find whether a cluster is shower-like.

Parameters
pClusterthe cluster
Returns
boolean

Definition at line 363 of file SvmVertexSelectionAlgorithm.cc.

References lar_content::LArClusterHelper::GetLength(), and m_minShowerSpineLength.

Referenced by GetShowerLikeClusterEndPoints(), and IncrementShoweryParameters().

364 {
365  return (pCluster->GetParticleId() == E_MINUS && LArClusterHelper::GetLength(pCluster) < m_minShowerSpineLength);
366 }
float m_minShowerSpineLength
The minimum length at which all are considered to be tracks.
static float GetLength(const pandora::Cluster *const pCluster)
Get length of cluster.
void lar_content::SvmVertexSelectionAlgorithm::PopulateFinalVertexScoreList ( const VertexFeatureInfoMap vertexFeatureInfoMap,
const pandora::Vertex *const  pFavouriteVertex,
const pandora::VertexVector &  vertexVector,
VertexScoreList finalVertexScoreList 
) const
private

Populate the final vertex score list using the r/phi score to find the best vertex in the vicinity.

Parameters
vertexFeatureInfoMapthe vertex feature info map
pFavouriteVertexaddress of the favourite vertex
vertexVectorthe vector of all vertex candidates
finalVertexScoreListthe final vertex score list to populate

Definition at line 732 of file SvmVertexSelectionAlgorithm.cc.

References m_rPhiFineTuningRadius.

Referenced by GetVertexScoreList().

734 {
735  if (pFavouriteVertex)
736  {
737  const CartesianVector vertexPosition(pFavouriteVertex->GetPosition());
738 
739  for (const Vertex *const pVertex : vertexVector)
740  {
741  if ((pVertex->GetPosition() - vertexPosition).GetMagnitude() < m_rPhiFineTuningRadius)
742  {
743  const float rPhiScore(vertexFeatureInfoMap.at(pVertex).m_rPhiFeature);
744  finalVertexScoreList.emplace_back(pVertex, rPhiScore);
745  }
746  }
747  }
748 }
float m_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.
void lar_content::SvmVertexSelectionAlgorithm::PopulateInitialScoreList ( VertexFeatureInfoMap vertexFeatureInfoMap,
const pandora::Vertex *const  pVertex,
VertexScoreList initialScoreList 
) const
private

Populate the initial vertex score list for a given vertex.

Parameters
vertexFeatureInfoMapthe vertex feature info map
pVertexthe vertex
initialScoreListthe score list to populate

Definition at line 475 of file SvmVertexSelectionAlgorithm.cc.

References lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_beamDeweighting, m_beamDeweightingConstant, lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_energyKick, m_energyKickConstant, lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_globalAsymmetry, m_globalAsymmetryConstant, lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_localAsymmetry, m_localAsymmetryConstant, lar_content::SvmVertexSelectionAlgorithm::VertexFeatureInfo::m_showerAsymmetry, and m_showerAsymmetryConstant.

Referenced by GetVertexScoreList().

477 {
478  VertexFeatureInfo vertexFeatureInfo = vertexFeatureInfoMap.at(pVertex);
479 
480  const float beamDeweightingScore(vertexFeatureInfo.m_beamDeweighting / m_beamDeweightingConstant);
481  const float energyKickScore(-vertexFeatureInfo.m_energyKick / m_energyKickConstant);
482  const float localAsymmetryScore(vertexFeatureInfo.m_localAsymmetry / m_localAsymmetryConstant);
483  const float globalAsymmetryScore(vertexFeatureInfo.m_globalAsymmetry / m_globalAsymmetryConstant);
484  const float showerAsymmetryScore(vertexFeatureInfo.m_showerAsymmetry / m_showerAsymmetryConstant);
485 
486  initialScoreList.emplace_back(pVertex, beamDeweightingScore + energyKickScore + localAsymmetryScore + globalAsymmetryScore + showerAsymmetryScore);
487 }
float m_globalAsymmetryConstant
The global asymmetry constant for the initial region score list.
float m_showerAsymmetryConstant
The shower asymmetry constant for the initial region score list.
float m_localAsymmetryConstant
The local asymmetry constant for the initial region score list.
float m_energyKickConstant
The energy kick constant for the initial region score list.
float m_beamDeweightingConstant
The beam deweighting constant for the initial region score list.
void lar_content::SvmVertexSelectionAlgorithm::PopulateKdTree ( const pandora::ClusterList &  clusterList,
HitKDTree2D kdTree,
HitToClusterMap hitToClusterMap 
) const
private

Populate kd tree with information about hits in a provided list of clusters.

Parameters
clusterListthe list of clusters
kdTreeto receive the populated kd tree
hitToClusterMapto receive the populated hit to cluster map

Definition at line 229 of file SvmVertexSelectionAlgorithm.cc.

References AddClusterToShower(), lar_content::KDTreeLinkerAlgo< DATA, DIM >::build(), lar_content::build_2d_kd_search_region(), lar_content::fill_and_bound_2d_kd_tree(), m_showerClusteringDistance, min, and lar_content::KDTreeLinkerAlgo< DATA, DIM >::search().

Referenced by CalculateShowerClusterList().

230 {
231  CaloHitList allCaloHits;
232 
233  for (const Cluster *const pCluster : clusterList)
234  {
235  CaloHitList daughterHits;
236  pCluster->GetOrderedCaloHitList().FillCaloHitList(daughterHits);
237  allCaloHits.insert(allCaloHits.end(), daughterHits.begin(), daughterHits.end());
238 
239  for (const CaloHit *const pCaloHit : daughterHits)
240  (void) hitToClusterMap.insert(HitToClusterMap::value_type(pCaloHit, pCluster));
241  }
242 
243  HitKDNode2DList hitKDNode2DList;
244  KDTreeBox hitsBoundingRegion2D(fill_and_bound_2d_kd_tree(allCaloHits, hitKDNode2DList));
245  kdTree.build(hitKDNode2DList, hitsBoundingRegion2D);
246 }
KDTreeBox fill_and_bound_2d_kd_tree(const MANAGED_CONTAINER< const T * > &points, std::vector< KDTreeNodeInfoT< const T *, 2 > > &nodes)
fill_and_bound_2d_kd_tree
KDTreeBoxT< 2 > KDTreeBox
void lar_content::SvmVertexSelectionAlgorithm::PopulateVertexFeatureInfoMap ( const BeamConstants beamConstants,
const ClusterListMap clusterListMap,
const SlidingFitDataListMap slidingFitDataListMap,
const ShowerClusterListMap showerClusterListMap,
const KDTreeMap kdTreeMap,
const pandora::Vertex *const  pVertex,
VertexFeatureInfoMap vertexFeatureInfoMap 
) const
private

Populate the vertex feature info map for a given vertex.

Parameters
beamConstantsthe beam constants
clusterListMapthe cluster list map
slidingFitDataListMapthe sliding fit data list map
showerClusterListMapthe shower cluster list map
kdTreeMapthe kd tree map
pVertexthe vertex
vertexFeatureInfoMapthe map to populate

Definition at line 446 of file SvmVertexSelectionAlgorithm.cc.

References f, Get, lar_content::VertexSelectionBaseAlgorithm::GetBeamDeweightingScore(), m_featureToolVector, and max.

Referenced by GetVertexScoreList().

449 {
450  float bestFastScore(-std::numeric_limits<float>::max()); // not actually used - artefact of toolizing RPhi score and still using performance trick
451 
452  const double beamDeweighting(this->GetBeamDeweightingScore(beamConstants, pVertex));
453 
454  const double energyKick(LArMvaHelper::CalculateFeaturesOfType<EnergyKickFeatureTool>(m_featureToolVector, this, pVertex,
455  slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore).at(0).Get());
456 
457  const double localAsymmetry(LArMvaHelper::CalculateFeaturesOfType<LocalAsymmetryFeatureTool>(m_featureToolVector, this, pVertex,
458  slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore).at(0).Get());
459 
460  const double globalAsymmetry(LArMvaHelper::CalculateFeaturesOfType<GlobalAsymmetryFeatureTool>(m_featureToolVector, this, pVertex,
461  slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore).at(0).Get());
462 
463  const double showerAsymmetry(LArMvaHelper::CalculateFeaturesOfType<ShowerAsymmetryFeatureTool>(m_featureToolVector, this, pVertex,
464  slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore).at(0).Get());
465 
466  //const double rPhiFeature(LArMvaHelper::CalculateFeaturesOfType<RPhiFeatureTool>(m_featureToolVector, this, pVertex,
467  // slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore).at(0).Get());
468 
469  VertexFeatureInfo vertexFeatureInfo(beamDeweighting, 0.f, energyKick, localAsymmetry, globalAsymmetry, showerAsymmetry);
470  vertexFeatureInfoMap.emplace(pVertex, vertexFeatureInfo);
471 }
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool vector.
float GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
Get the beam deweighting score for a vertex.
const pandora::Vertex * lar_content::SvmVertexSelectionAlgorithm::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
private

Produce a set of training examples for a binary classifier.

Parameters
vertexVectorthe vector of vertices to use
vertexFeatureInfoMapthe vertex feature info map
coinFlipa distribution for producing coin flips
generatorthe random number generator
interactionTypethe interaction type string
trainingOutputFilethe training set output file
eventFeatureListthe event feature list
maxRadiusthe maximum allowed radius for the 'best' vertex
useRPhiwhether to include the r/phi feature
Returns
address of the vertex used as the 'best' vertex in the classifier

Definition at line 610 of file SvmVertexSelectionAlgorithm.cc.

References AddVertexFeaturesToVector(), GetBestVertex(), max, and lar_content::LArMvaHelper::ProduceTrainingExample().

Referenced by ProduceTrainingSets().

614 {
615  const Vertex *pBestVertex(nullptr);
616  float bestVertexDr(std::numeric_limits<float>::max());
617 
618  LArMvaHelper::MvaFeatureVector bestVertexFeatureList;
619  this->GetBestVertex(vertexVector, pBestVertex, bestVertexDr);
620 
621  VertexFeatureInfo bestVertexFeatureInfo(vertexFeatureInfoMap.at(pBestVertex));
622  this->AddVertexFeaturesToVector(bestVertexFeatureInfo, bestVertexFeatureList, useRPhi);
623 
624  for (const Vertex *const pVertex : vertexVector)
625  {
626  if (pVertex == pBestVertex)
627  continue;
628 
629  LArMvaHelper::MvaFeatureVector featureList;
630  VertexFeatureInfo vertexFeatureInfo(vertexFeatureInfoMap.at(pVertex));
631  this->AddVertexFeaturesToVector(vertexFeatureInfo, featureList, useRPhi);
632 
633  if (pBestVertex && (bestVertexDr < maxRadius))
634  {
635  if (coinFlip(generator))
636  {
637  LArMvaHelper::ProduceTrainingExample(trainingOutputFile + "_" + interactionType + ".txt", true, eventFeatureList,
638  bestVertexFeatureList, featureList);
639  }
640 
641  else
642  {
643  LArMvaHelper::ProduceTrainingExample(trainingOutputFile + "_" + interactionType + ".txt", false, eventFeatureList, featureList,
644  bestVertexFeatureList);
645  }
646  }
647  }
648 
649  return pBestVertex;
650 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:58
Int_t max
Definition: plot.C:27
static pandora::StatusCode ProduceTrainingExample(const std::string &trainingOutputFile, const bool result, TLISTS &&...featureLists)
Produce a training example with the given features and result.
Definition: LArMvaHelper.h:197
void AddVertexFeaturesToVector(const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
Add the vertex features to a vector in the correct order.
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 lar_content::SvmVertexSelectionAlgorithm::ProduceTrainingSets ( const pandora::VertexVector &  vertexVector,
const pandora::VertexVector &  bestRegionVertices,
VertexFeatureInfoMap vertexFeatureInfoMap,
const LArMvaHelper::MvaFeatureVector eventFeatureList,
const KDTreeMap kdTreeMap 
) const
private

Produce the region and vertex training sets.

Parameters
vertexVectorthe vector of all vertices
bestRegionVerticesthe best region vertices
vertexFeatureInfoMapthe vertex feature info map
eventFeatureListthe list of event features
kdTreeMap

Definition at line 524 of file SvmVertexSelectionAlgorithm.cc.

References CalculateRPhiScores(), GetInteractionType(), m_maxTrueVertexRadius, m_regionRadius, m_trainingOutputFileRegion, m_trainingOutputFileVertex, m_useRPhiFeatureForRegion, and ProduceTrainingExamples().

Referenced by GetVertexScoreList().

526 {
527  if (vertexVector.empty())
528  return;
529 
530  // Create a distribution for random coin flips.
531  std::random_device device;
532  std::mt19937 generator(device());
533  std::bernoulli_distribution coinFlip(0.5);
534 
535  const std::string interactionType(this->GetInteractionType());
536 
537  // Produce training examples for the vertices representing regions.
538  const Vertex *const pBestRegionVertex(this->ProduceTrainingExamples(bestRegionVertices, vertexFeatureInfoMap, coinFlip, generator,
539  interactionType, m_trainingOutputFileRegion, eventFeatureList, m_regionRadius, m_useRPhiFeatureForRegion));
540 
541  // Get all the vertices in the best region.
542  VertexVector regionalVertices{pBestRegionVertex};
543  for (const Vertex *const pVertex : vertexVector)
544  {
545  if (pVertex == pBestRegionVertex)
546  continue;
547 
548  if ((pBestRegionVertex->GetPosition() - pVertex->GetPosition()).GetMagnitude() < m_regionRadius)
549  regionalVertices.push_back(pVertex);
550  }
551 
552  this->CalculateRPhiScores(regionalVertices, vertexFeatureInfoMap, kdTreeMap);
553 
554  // Produce training examples for the final vertices within the best region.
555  if (!regionalVertices.empty())
556  {
557  this->ProduceTrainingExamples(regionalVertices, vertexFeatureInfoMap, coinFlip, generator, interactionType, m_trainingOutputFileVertex,
558  eventFeatureList, m_maxTrueVertexRadius, true);
559  }
560 }
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...
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.
float m_maxTrueVertexRadius
The maximum distance at which a vertex candidate can be considered the &#39;true&#39; vertex.
float m_regionRadius
The radius for a vertex region.
std::string GetInteractionType() const
Get the interaction type string.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
std::string m_trainingOutputFileVertex
The training output file for the vertex Svm.
std::string m_trainingOutputFileRegion
The training output file for the region Svm.
std::vector< art::Ptr< recob::Vertex > > VertexVector
StatusCode lar_content::SvmVertexSelectionAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protected

Definition at line 753 of file SvmVertexSelectionAlgorithm.cc.

References lar_content::LArMvaHelper::AddFeatureToolToVector(), lar_content::LArFileHelper::FindFileInPath(), lar_content::SupportVectorMachine::Initialize(), m_allowClassifyDuringTraining, m_beamDeweightingConstant, m_caloHitListName, m_dropFailedRPhiFastScoreCandidates, m_energyKickConstant, m_featureToolVector, m_filePathEnvironmentVariable, m_globalAsymmetryConstant, m_inputClusterListNames, m_localAsymmetryConstant, m_maxTrueVertexRadius, m_mcParticleListName, m_mcVertexXCorrection, m_minClusterCaloHits, m_minShowerClusterHits, m_minShowerSpineLength, m_regionRadius, m_regionSvmName, m_rPhiFineTuningRadius, m_showerAsymmetryConstant, m_showerClusteringDistance, m_slidingFitWindow, m_svMachineRegion, m_svMachineVertex, m_svmFileName, m_trainingOutputFileRegion, m_trainingOutputFileVertex, m_trainingSetMode, m_useRPhiFeatureForRegion, m_useShowerClusteringApproximation, m_vertexSvmName, and lar_content::VertexSelectionBaseAlgorithm::ReadSettings().

754 {
755  AlgorithmToolVector algorithmToolVector;
756  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "FeatureTools", algorithmToolVector));
757 
758  for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
759  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArMvaHelper::AddFeatureToolToVector(pAlgorithmTool, m_featureToolVector));
760 
761  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
762  "FilePathEnvironmentVariable", m_filePathEnvironmentVariable));
763 
764  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
765  "SvmFileName", m_svmFileName));
766 
767  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
768  "RegionSvmName", m_regionSvmName));
769 
770  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
771  "VertexSvmName", m_vertexSvmName));
772 
773  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
774  "TrainingSetMode", m_trainingSetMode));
775 
776  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
777  "AllowClassifyDuringTraining", m_allowClassifyDuringTraining));
778 
780  {
781  if (m_svmFileName.empty() || m_regionSvmName.empty() || m_vertexSvmName.empty())
782  {
783  std::cout << "SvmVertexSelectionAlgorithm: SvmFileName, RegionSvmName and VertexSvmName must be set if training set mode is" <<
784  "off or we allow classification during training" << std::endl;
785  return STATUS_CODE_INVALID_PARAMETER;
786  }
787 
789  m_svMachineRegion.Initialize(fullSvmFileName, m_regionSvmName);
790  m_svMachineVertex.Initialize(fullSvmFileName, m_vertexSvmName);
791  }
792 
793 
794  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
795  "MCVertexXCorrection", m_mcVertexXCorrection));
796 
797  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
798  "TrainingOutputFileRegion", m_trainingOutputFileRegion));
799 
800  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
801  "TrainingOutputFileVertex", m_trainingOutputFileVertex));
802 
804  {
805  std::cout << "SvmVertexSelectionAlgorithm: TrainingOutputFileRegion and TrainingOutputFileVertex are required for training set " <<
806  "mode" << std::endl;
807  return STATUS_CODE_INVALID_PARAMETER;
808  }
809 
810  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
811  "MCParticleListName", m_mcParticleListName));
812 
813  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
814  "CaloHitListName", m_caloHitListName));
815 
816  if (m_trainingSetMode && (m_mcParticleListName.empty() || m_caloHitListName.empty()))
817  {
818  std::cout << "SvmVertexSelectionAlgorithm: MCParticleListName and CaloHitListName are required for training set mode" << std::endl;
819  return STATUS_CODE_INVALID_PARAMETER;
820  }
821 
822  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
823  "InputClusterListNames", m_inputClusterListNames));
824 
825  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
826  "MinClusterCaloHits", m_minClusterCaloHits));
827 
828  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
829  "SlidingFitWindow", m_slidingFitWindow));
830 
831  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
832  "MinShowerSpineLength", m_minShowerSpineLength));
833 
834  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
835  "BeamDeweightingConstant", m_beamDeweightingConstant));
836 
837  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
838  "LocalAsymmetryConstant", m_localAsymmetryConstant));
839 
840  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
841  "GlobalAsymmetryConstant", m_globalAsymmetryConstant));
842 
843  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
844  "ShowerAsymmetryConstant", m_showerAsymmetryConstant));
845 
846  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
847  "EnergyKickConstant", m_energyKickConstant));
848 
849  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
850  "ShowerClusteringDistance", m_showerClusteringDistance));
851 
852  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
853  "MinShowerClusterHits", m_minShowerClusterHits));
854 
855  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
856  "UseShowerClusteringApproximation", m_useShowerClusteringApproximation));
857 
858  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
859  "RegionRadius", m_regionRadius));
860 
861  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
862  "RPhiFineTuningRadius", m_rPhiFineTuningRadius));
863 
864  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
865  "MaxTrueVertexRadius", m_maxTrueVertexRadius));
866 
867  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
868  "UseRPhiFeatureForRegion", m_useRPhiFeatureForRegion));
869 
870  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
871  "DropFailedRPhiFastScoreCandidates", m_dropFailedRPhiFastScoreCandidates));
872 
874 }
std::string m_vertexSvmName
The name of the vertex Svm to find.
unsigned int m_minShowerClusterHits
The minimum number of shower cluster hits.
float m_globalAsymmetryConstant
The global asymmetry constant for the initial region score list.
bool m_dropFailedRPhiFastScoreCandidates
Whether to drop candidates that fail the r/phi fast score test.
float m_maxTrueVertexRadius
The maximum distance at which a vertex candidate can be considered the &#39;true&#39; vertex.
float m_showerAsymmetryConstant
The shower asymmetry constant for the initial region score list.
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
float m_localAsymmetryConstant
The local asymmetry constant for the initial region score list.
float m_regionRadius
The radius for a vertex region.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
SupportVectorMachine m_svMachineVertex
The vertex support vector machine.
SupportVectorMachine m_svMachineRegion
The region support vector machine.
float m_minShowerSpineLength
The minimum length at which all are considered to be tracks.
std::string m_mcParticleListName
The MC particle list for creating training examples.
static pandora::StatusCode AddFeatureToolToVector(pandora::AlgorithmTool *const pFeatureTool, MvaFeatureToolVector< Ts... > &featureToolVector)
Add a feature tool to a vector of feature tools.
Definition: LArMvaHelper.h:274
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...
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.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to svm files.
std::string m_caloHitListName
The 2D CaloHit list name.
float m_showerClusteringDistance
The shower clustering distance.
std::string m_trainingOutputFileVertex
The training output file for the vertex Svm.
pandora::StatusCode Initialize(const std::string &parameterLocation, const std::string &svmName)
Initialize the svm using a serialized model.
bool m_useShowerClusteringApproximation
Whether to use the shower clustering distance approximation.
float m_beamDeweightingConstant
The beam deweighting constant for the initial region score list.
std::string m_trainingOutputFileRegion
The training output file for the region Svm.
std::string m_regionSvmName
The name of the region Svm to find.
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool vector.
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
void lar_content::SvmVertexSelectionAlgorithm::UpdateSpanCoordinate ( const float  minPositionCoord,
const float  maxPositionCoord,
pandora::InputFloat &  minCoord,
pandora::InputFloat &  maxCoord 
) const
inlineprivate

Update the min/max coordinate spans.

Parameters
minPositionCoordthe min position coordinate
maxPositionCoordthe max position coordinate
minCoordthe current min coordinate
maxCoordthe current max coordinate

Definition at line 410 of file SvmVertexSelectionAlgorithm.cc.

Referenced by GetEventShapeFeatures().

412 {
413  if (!minCoord.IsInitialized() || minPositionCoord < minCoord.Get())
414  minCoord = minPositionCoord;
415 
416  if (!maxCoord.IsInitialized() || maxPositionCoord > maxCoord.Get())
417  maxCoord = maxPositionCoord;
418 }

Member Data Documentation

bool lar_content::SvmVertexSelectionAlgorithm::m_allowClassifyDuringTraining
private

Whether classification is allowed during training.

Definition at line 388 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetVertexScoreList(), and ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_beamDeweightingConstant
private

The beam deweighting constant for the initial region score list.

Definition at line 400 of file SvmVertexSelectionAlgorithm.h.

Referenced by PopulateInitialScoreList(), and ReadSettings().

std::string lar_content::SvmVertexSelectionAlgorithm::m_caloHitListName
private

The 2D CaloHit list name.

Definition at line 393 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetInteractionType(), and ReadSettings().

bool lar_content::SvmVertexSelectionAlgorithm::m_dropFailedRPhiFastScoreCandidates
private

Whether to drop candidates that fail the r/phi fast score test.

Definition at line 413 of file SvmVertexSelectionAlgorithm.h.

Referenced by CalculateRPhiScores(), and ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_energyKickConstant
private

The energy kick constant for the initial region score list.

Definition at line 404 of file SvmVertexSelectionAlgorithm.h.

Referenced by PopulateInitialScoreList(), and ReadSettings().

VertexFeatureTool::FeatureToolVector lar_content::SvmVertexSelectionAlgorithm::m_featureToolVector
private

The feature tool vector.

Definition at line 379 of file SvmVertexSelectionAlgorithm.h.

Referenced by CalculateRPhiScores(), PopulateVertexFeatureInfoMap(), and ReadSettings().

std::string lar_content::SvmVertexSelectionAlgorithm::m_filePathEnvironmentVariable
private

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

Definition at line 380 of file SvmVertexSelectionAlgorithm.h.

Referenced by ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_globalAsymmetryConstant
private

The global asymmetry constant for the initial region score list.

Definition at line 402 of file SvmVertexSelectionAlgorithm.h.

Referenced by PopulateInitialScoreList(), and ReadSettings().

pandora::StringVector lar_content::SvmVertexSelectionAlgorithm::m_inputClusterListNames
private

The list of cluster list names.

Definition at line 395 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetVertexScoreList(), and ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_localAsymmetryConstant
private

The local asymmetry constant for the initial region score list.

Definition at line 401 of file SvmVertexSelectionAlgorithm.h.

Referenced by PopulateInitialScoreList(), and ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_maxTrueVertexRadius
private

The maximum distance at which a vertex candidate can be considered the 'true' vertex.

Definition at line 411 of file SvmVertexSelectionAlgorithm.h.

Referenced by ProduceTrainingSets(), and ReadSettings().

std::string lar_content::SvmVertexSelectionAlgorithm::m_mcParticleListName
private

The MC particle list for creating training examples.

Definition at line 392 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetBestVertex(), GetInteractionType(), and ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_mcVertexXCorrection
private

The correction to the x-coordinate of the MC vertex position.

Definition at line 389 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetBestVertex(), and ReadSettings().

unsigned int lar_content::SvmVertexSelectionAlgorithm::m_minClusterCaloHits
private

The min number of hits parameter in the energy score.

Definition at line 396 of file SvmVertexSelectionAlgorithm.h.

Referenced by CalculateShowerClusterList(), GetVertexScoreList(), and ReadSettings().

unsigned int lar_content::SvmVertexSelectionAlgorithm::m_minShowerClusterHits
private

The minimum number of shower cluster hits.

Definition at line 407 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetShowerLikeClusterEndPoints(), and ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_minShowerSpineLength
private

The minimum length at which all are considered to be tracks.

Definition at line 398 of file SvmVertexSelectionAlgorithm.h.

Referenced by IsClusterShowerLike(), and ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_regionRadius
private

The radius for a vertex region.

Definition at line 409 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetBestRegionVertices(), GetVertexScoreList(), ProduceTrainingSets(), and ReadSettings().

std::string lar_content::SvmVertexSelectionAlgorithm::m_regionSvmName
private

The name of the region Svm to find.

Definition at line 382 of file SvmVertexSelectionAlgorithm.h.

Referenced by ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_rPhiFineTuningRadius
private

The maximum distance the r/phi tune can move a vertex.

Definition at line 410 of file SvmVertexSelectionAlgorithm.h.

Referenced by PopulateFinalVertexScoreList(), and ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_showerAsymmetryConstant
private

The shower asymmetry constant for the initial region score list.

Definition at line 403 of file SvmVertexSelectionAlgorithm.h.

Referenced by PopulateInitialScoreList(), and ReadSettings().

float lar_content::SvmVertexSelectionAlgorithm::m_showerClusteringDistance
private

The shower clustering distance.

Definition at line 406 of file SvmVertexSelectionAlgorithm.h.

Referenced by PopulateKdTree(), and ReadSettings().

unsigned int lar_content::SvmVertexSelectionAlgorithm::m_slidingFitWindow
private

The layer window for the sliding linear fits.

Definition at line 397 of file SvmVertexSelectionAlgorithm.h.

Referenced by CalculateShowerClusterList(), GetVertexScoreList(), and ReadSettings().

SupportVectorMachine lar_content::SvmVertexSelectionAlgorithm::m_svMachineRegion
private

The region support vector machine.

Definition at line 384 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetVertexScoreList(), and ReadSettings().

SupportVectorMachine lar_content::SvmVertexSelectionAlgorithm::m_svMachineVertex
private

The vertex support vector machine.

Definition at line 385 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetVertexScoreList(), and ReadSettings().

std::string lar_content::SvmVertexSelectionAlgorithm::m_svmFileName
private

The Svm file name.

Definition at line 381 of file SvmVertexSelectionAlgorithm.h.

Referenced by ReadSettings().

std::string lar_content::SvmVertexSelectionAlgorithm::m_trainingOutputFileRegion
private

The training output file for the region Svm.

Definition at line 390 of file SvmVertexSelectionAlgorithm.h.

Referenced by ProduceTrainingSets(), and ReadSettings().

std::string lar_content::SvmVertexSelectionAlgorithm::m_trainingOutputFileVertex
private

The training output file for the vertex Svm.

Definition at line 391 of file SvmVertexSelectionAlgorithm.h.

Referenced by ProduceTrainingSets(), and ReadSettings().

bool lar_content::SvmVertexSelectionAlgorithm::m_trainingSetMode
private

Whether to train.

Definition at line 387 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetVertexScoreList(), and ReadSettings().

bool lar_content::SvmVertexSelectionAlgorithm::m_useRPhiFeatureForRegion
private

Whether to use the r/phi feature for the region vertex.

Definition at line 412 of file SvmVertexSelectionAlgorithm.h.

Referenced by GetVertexScoreList(), ProduceTrainingSets(), and ReadSettings().

bool lar_content::SvmVertexSelectionAlgorithm::m_useShowerClusteringApproximation
private

Whether to use the shower clustering distance approximation.

Definition at line 408 of file SvmVertexSelectionAlgorithm.h.

Referenced by CalculateShowerClusterList(), and ReadSettings().

std::string lar_content::SvmVertexSelectionAlgorithm::m_vertexSvmName
private

The name of the vertex Svm to find.

Definition at line 383 of file SvmVertexSelectionAlgorithm.h.

Referenced by ReadSettings().


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