Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
lar_content::TrainedVertexSelectionAlgorithm Class Referenceabstract

TrainedVertexSelectionAlgorithm class. More...

#include <TrainedVertexSelectionAlgorithm.h>

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

Classes

class  EventFeatureInfo
 Event feature info class. More...
 
class  VertexFeatureInfo
 Vertex feature info class. More...
 
class  VertexSharedFeatureInfo
 Shared vertex feature info class. More...
 

Public Types

typedef std::map< const pandora::Vertex *const, VertexFeatureInfoVertexFeatureInfoMap
 
- Public Types inherited from lar_content::VertexSelectionBaseAlgorithm
typedef std::vector< VertexScoreVertexScoreList
 
typedef std::vector< SlidingFitDataSlidingFitDataList
 
typedef std::vector< ShowerClusterShowerClusterList
 
typedef KDTreeNodeInfoT< const pandora::CaloHit *, 2 > HitKDNode2D
 
typedef std::vector< HitKDNode2DHitKDNode2DList
 
typedef KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
 
typedef std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
 Map array of cluster lists for passing to tools. More...
 
typedef std::map< pandora::HitType, const 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

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

Protected 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
 

Protected Member Functions

virtual void GetVertexScoreList (const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const =0
 Get the vertex score list. 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 GetLegacyEventShapeFeatures (const pandora::ClusterList &clusterList, float &eventVolume, float &longitudinality) const
 Get the event shape features. More...
 
void GetEventShapeFeatures (const ClusterListMap &clusterListMap, float &eventArea, float &longitudinality) const
 Get the event shape features. More...
 
void Get2DSpan (const pandora::ClusterList &clusterList, float &xSpan, float &zSpan) const
 Get the coordinate span in one view. More...
 
void UpdateSpanCoordinate (const float minPositionCoord, const float maxPositionCoord, pandora::InputFloat &minCoord, pandora::InputFloat &maxCoord) const
 Update the min/max coordinate spans. More...
 
float GetCoordinateSpan (const pandora::InputFloat &minCoord, const pandora::InputFloat &maxCoord) const
 Get the coordinate span. More...
 
void AddEventFeaturesToVector (const EventFeatureInfo &eventFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
 Add the event features to a vector in the correct order. More...
 
void PopulateVertexFeatureInfoMap (const BeamConstants &beamConstants, const ClusterListMap &clusterListMap, const SlidingFitDataListMap &slidingFitDataListMap, const ShowerClusterListMap &showerClusterListMap, const KDTreeMap &kdTreeMap, const pandora::Vertex *const pVertex, VertexFeatureInfoMap &vertexFeatureInfoMap) const
 Populate the vertex feature info map for a given vertex. More...
 
void PopulateInitialScoreList (VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pVertex, VertexScoreList &initialScoreList) const
 Populate the initial vertex score list for a given vertex. More...
 
void GetBestRegionVertices (VertexScoreList &initialScoreList, pandora::VertexVector &bestRegionVertices) const
 Get the list of top-N separated vertices. More...
 
void ProduceTrainingSets (const pandora::VertexVector &vertexVector, const pandora::VertexVector &bestRegionVertices, VertexFeatureInfoMap &vertexFeatureInfoMap, const LArMvaHelper::MvaFeatureVector &eventFeatureList, const KDTreeMap &kdTreeMap) const
 Produce the region and vertex training sets. More...
 
void CalculateRPhiScores (pandora::VertexVector &vertexVector, VertexFeatureInfoMap &vertexFeatureInfoMap, const KDTreeMap &kdTreeMap) const
 Calculate the r/phi scores for the vertices in a vector, possibly erasing those that fail the fast score test. More...
 
std::string GetInteractionType () const
 Get the interaction type string. More...
 
const pandora::Vertex * ProduceTrainingExamples (const pandora::VertexVector &vertexVector, const VertexFeatureInfoMap &vertexFeatureInfoMap, std::bernoulli_distribution &coinFlip, std::mt19937 &generator, const std::string &interactionType, const std::string &trainingOutputFile, const LArMvaHelper::MvaFeatureVector &eventFeatureList, const KDTreeMap &kdTreeMap, const float maxRadius, const bool useRPhi) const
 Produce a set of training examples for a binary classifier. More...
 
void GetBestVertex (const pandora::VertexVector &vertexVector, const pandora::Vertex *&pBestVertex, float &bestVertexDr) const
 Use the MC information to get the best vertex from a list. More...
 
void GetSharedFeatures (const pandora::Vertex *const pVertex1, const pandora::Vertex *const pVertex2, const KDTreeMap &kdTreeMap, float &separation, float &axisHits) const
 Calculates the shared features of a pair of vertex candidates. More...
 
void IncrementSharedAxisValues (const pandora::CartesianVector pos1, const pandora::CartesianVector pos2, HitKDTree2D &kdTree, float &axisHits) const
 Increments the axis hits information for one view. More...
 
bool IsHitInBox (const pandora::CartesianVector &hitPos, const pandora::CartesianVector &point1, const pandora::CartesianVector &point2, const pandora::CartesianVector &point3, const pandora::CartesianVector &point4) const
 Determines whether a hit lies within the box defined by four other positions. More...
 
void AddVertexFeaturesToVector (const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
 Add the vertex features to a vector in the correct order. More...
 
void AddSharedFeaturesToVector (const VertexSharedFeatureInfo &vertexSharedFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
 Add the shared features to a vector in the correct order. More...
 
void PopulateFinalVertexScoreList (const VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pFavouriteVertex, const pandora::VertexVector &vertexVector, VertexScoreList &finalVertexScoreList) const
 Populate the final vertex score list using the r/phi score to find the best vertex in the vicinity. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
- Protected Member Functions inherited from lar_content::VertexSelectionBaseAlgorithm
virtual void FilterVertexList (const pandora::VertexList *const pInputVertexList, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, pandora::VertexVector &filteredVertices) const
 Filter the input list of vertices to obtain a reduced number of vertex candidates. More...
 
virtual void GetBeamConstants (const pandora::VertexVector &vertexVector, BeamConstants &beamConstants) const
 Get the beam score constants for a provided list of candidate vertices. More...
 
void GetClusterLists (const pandora::StringVector &inputClusterListNames, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
 Get the cluster lists. More...
 
void CalculateClusterSlidingFits (const pandora::ClusterList &inputClusterList, const unsigned int minClusterCaloHits, const unsigned int slidingFitWindow, SlidingFitDataList &slidingFitDataList) const
 Calculate the cluster sliding fits. More...
 
float GetBeamDeweightingScore (const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
 Get the beam deweighting score for a vertex. More...
 
bool IsBeamModeOn () const
 Whether algorithm is running in beam mode, assuming neutrinos travel in positive z-direction. More...
 
float GetVertexEnergy (const pandora::Vertex *const pVertex, const KDTreeMap &kdTreeMap) const
 Calculate the energy of a vertex candidate by summing values from all three planes. More...
 
float VertexHitEnergy (const pandora::Vertex *const pVertex, const pandora::HitType hitType, HitKDTree2D &kdTree) const
 Finds the energy of the nearest hit to the vertex candidate in this view. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Protected Attributes

VertexFeatureTool::FeatureToolVector m_featureToolVector
 The feature tool vector. More...
 
bool m_trainingSetMode
 Whether to train. More...
 
bool m_allowClassifyDuringTraining
 Whether classification is allowed during training. More...
 
float m_mcVertexXCorrection
 The correction to the x-coordinate of the MC vertex position. More...
 
std::string m_trainingOutputFileRegion
 The training output file for the region mva. More...
 
std::string m_trainingOutputFileVertex
 The training output file for the vertex mva. More...
 
std::string m_mcParticleListName
 The MC particle list for creating training examples. More...
 
std::string m_caloHitListName
 The 2D CaloHit list name. More...
 
pandora::StringVector m_inputClusterListNames
 The list of cluster list names. More...
 
unsigned int m_minClusterCaloHits
 The min number of hits parameter in the energy score. More...
 
unsigned int m_slidingFitWindow
 The layer window for the sliding linear fits. More...
 
float m_minShowerSpineLength
 The minimum length at which all are considered to be tracks. More...
 
float m_beamDeweightingConstant
 The beam deweighting constant for the initial region score list. More...
 
float m_localAsymmetryConstant
 The local asymmetry constant for the initial region score list. More...
 
float m_globalAsymmetryConstant
 The global asymmetry constant for the initial region score list. More...
 
float m_showerAsymmetryConstant
 The shower asymmetry constant for the initial region score list. More...
 
float m_energyKickConstant
 The energy kick constant for the initial region score list. More...
 
float m_showerClusteringDistance
 The shower clustering distance. More...
 
unsigned int m_minShowerClusterHits
 The minimum number of shower cluster hits. More...
 
bool m_useShowerClusteringApproximation
 Whether to use the shower clustering distance approximation. More...
 
float m_regionRadius
 The radius for a vertex region. More...
 
float m_rPhiFineTuningRadius
 The maximum distance the r/phi tune can move a vertex. More...
 
float m_maxTrueVertexRadius
 The maximum distance at which a vertex candidate can be considered the 'true' vertex. More...
 
bool m_useRPhiFeatureForRegion
 Whether to use the r/phi feature for the region vertex. More...
 
bool m_dropFailedRPhiFastScoreCandidates
 Whether to drop candidates that fail the r/phi fast score test. More...
 
bool m_testBeamMode
 Test beam mode. More...
 
bool m_legacyEventShapes
 Whether to use the old event shapes calculation. More...
 
bool m_legacyVariables
 Whether to only use the old variables. More...
 

Detailed Description

TrainedVertexSelectionAlgorithm class.

Definition at line 36 of file TrainedVertexSelectionAlgorithm.h.

Member Typedef Documentation

typedef std::pair<pandora::CartesianVector, pandora::CartesianVector> lar_content::TrainedVertexSelectionAlgorithm::ClusterEndPoints
protected

Definition at line 131 of file TrainedVertexSelectionAlgorithm.h.

typedef std::map<const pandora::Cluster *const, ClusterEndPoints> lar_content::TrainedVertexSelectionAlgorithm::ClusterEndPointsMap
protected

Definition at line 132 of file TrainedVertexSelectionAlgorithm.h.

Definition at line 133 of file TrainedVertexSelectionAlgorithm.h.

typedef KDTreeNodeInfoT<const pandora::CaloHit *, 2> lar_content::TrainedVertexSelectionAlgorithm::HitKDNode2D
protected

Definition at line 168 of file TrainedVertexSelectionAlgorithm.h.

Definition at line 169 of file TrainedVertexSelectionAlgorithm.h.

typedef KDTreeLinkerAlgo<const pandora::CaloHit *, 2> lar_content::TrainedVertexSelectionAlgorithm::HitKDTree2D
protected

Definition at line 167 of file TrainedVertexSelectionAlgorithm.h.

typedef std::unordered_map<const pandora::CaloHit *, const pandora::Cluster *> lar_content::TrainedVertexSelectionAlgorithm::HitToClusterMap
protected

Definition at line 171 of file TrainedVertexSelectionAlgorithm.h.

Definition at line 134 of file TrainedVertexSelectionAlgorithm.h.

Definition at line 70 of file TrainedVertexSelectionAlgorithm.h.

Constructor & Destructor Documentation

lar_content::TrainedVertexSelectionAlgorithm::TrainedVertexSelectionAlgorithm ( )

Default constructor.

Definition at line 36 of file TrainedVertexSelectionAlgorithm.cc.

36  :
38  m_trainingSetMode(false),
42  m_slidingFitWindow(100),
52  m_regionRadius(10.f),
57  m_testBeamMode(false),
58  m_legacyEventShapes(true),
59  m_legacyVariables(true)
60 {
61 }
bool m_useShowerClusteringApproximation
Whether to use the shower clustering distance approximation.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
bool m_legacyEventShapes
Whether to use the old event shapes calculation.
float m_localAsymmetryConstant
The local asymmetry constant for the initial region score list.
unsigned int m_minShowerClusterHits
The minimum number of shower cluster hits.
float m_globalAsymmetryConstant
The global asymmetry constant for the initial region score list.
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.
float m_beamDeweightingConstant
The beam deweighting constant for the initial region score list.
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
bool m_dropFailedRPhiFastScoreCandidates
Whether to drop candidates that fail the r/phi fast score test.
float m_energyKickConstant
The energy kick constant for the initial region score list.
float m_mcVertexXCorrection
The correction to the x-coordinate of the MC vertex position.
bool m_legacyVariables
Whether to only use the old variables.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
float m_minShowerSpineLength
The minimum length at which all are considered to be tracks.
float m_showerClusteringDistance
The shower clustering distance.
float m_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.

Member Function Documentation

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

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
bool lar_content::TrainedVertexSelectionAlgorithm::AddClusterToShower ( HitKDTree2D kdTree,
const HitToClusterMap hitToClusterMap,
pandora::ClusterList &  availableShowerLikeClusters,
const pandora::Cluster *const  pCluster,
pandora::ClusterList &  showerCluster 
) const
protected

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::TrainedVertexSelectionAlgorithm::AddEventFeaturesToVector ( const EventFeatureInfo eventFeatureInfo,
LArMvaHelper::MvaFeatureVector featureVector 
) const
protected

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 412 of file TrainedVertexSelectionAlgorithm.cc.

413 {
414  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_eventShoweryness));
415  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_eventEnergy));
416  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_eventArea));
417  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_longitudinality));
418  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_nHits));
419  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_nClusters));
420  featureVector.push_back(static_cast<double>(eventFeatureInfo.m_nCandidates));
421 }
void lar_content::TrainedVertexSelectionAlgorithm::AddSharedFeaturesToVector ( const VertexSharedFeatureInfo vertexSharedFeatureInfo,
LArMvaHelper::MvaFeatureVector featureVector 
) const
protected

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

Parameters
vertexSharedFeatureInfothe shared vertex feature info
featureVectorthe vector of floats to append

Definition at line 820 of file TrainedVertexSelectionAlgorithm.cc.

822 {
823  featureVector.push_back(static_cast<double>(vertexSharedFeatureInfo.m_separation));
824  featureVector.push_back(static_cast<double>(vertexSharedFeatureInfo.m_axisHits));
825 }
void lar_content::TrainedVertexSelectionAlgorithm::AddVertexFeaturesToVector ( const VertexFeatureInfo vertexFeatureInfo,
LArMvaHelper::MvaFeatureVector featureVector,
const bool  useRPhi 
) const
protected

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 799 of file TrainedVertexSelectionAlgorithm.cc.

801 {
802  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_beamDeweighting));
803  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_energyKick));
804  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_globalAsymmetry));
805  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_localAsymmetry));
806  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_showerAsymmetry));
807 
808  if (!m_legacyVariables)
809  {
810  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_dEdxAsymmetry));
811  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_vertexEnergy));
812  }
813 
814  if (useRPhi)
815  featureVector.push_back(static_cast<double>(vertexFeatureInfo.m_rPhiFeature));
816 }
bool m_legacyVariables
Whether to only use the old variables.
TrainedVertexSelectionAlgorithm::EventFeatureInfo lar_content::TrainedVertexSelectionAlgorithm::CalculateEventFeatures ( const pandora::ClusterList &  clusterListU,
const pandora::ClusterList &  clusterListV,
const pandora::ClusterList &  clusterListW,
const pandora::VertexVector &  vertexVector 
) const
protected

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 240 of file TrainedVertexSelectionAlgorithm.cc.

242 {
243  float eventEnergy(0.f);
244  unsigned int nShoweryHits(0), nHits(0);
245 
246  this->IncrementShoweryParameters(clusterListU, nShoweryHits, nHits, eventEnergy);
247  this->IncrementShoweryParameters(clusterListV, nShoweryHits, nHits, eventEnergy);
248  this->IncrementShoweryParameters(clusterListW, nShoweryHits, nHits, eventEnergy);
249 
250  const unsigned int nClusters(clusterListU.size() + clusterListV.size() + clusterListW.size());
251  const float eventShoweryness((nHits > 0) ? static_cast<float>(nShoweryHits) / static_cast<float>(nHits) : 0.f);
252 
253  ClusterList allClusters(clusterListU);
254  allClusters.insert(allClusters.end(), clusterListV.begin(), clusterListV.end());
255  allClusters.insert(allClusters.end(), clusterListW.begin(), clusterListW.end());
256 
257  const ClusterListMap clusterListMap{{TPC_VIEW_U, clusterListU}, {TPC_VIEW_V, clusterListV}, {TPC_VIEW_W, clusterListW}};
258 
259  float eventArea(0.f), longitudinality(0.f);
261  this->GetLegacyEventShapeFeatures(allClusters, eventArea, longitudinality);
262  else
263  this->GetEventShapeFeatures(clusterListMap, eventArea, longitudinality);
264 
265  return EventFeatureInfo(eventShoweryness, eventEnergy, eventArea, longitudinality, nHits, nClusters, vertexVector.size());
266 }
void GetLegacyEventShapeFeatures(const pandora::ClusterList &clusterList, float &eventVolume, float &longitudinality) const
Get the event shape features.
bool m_legacyEventShapes
Whether to use the old event shapes calculation.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
void IncrementShoweryParameters(const pandora::ClusterList &clusterList, unsigned int &nShoweryHits, unsigned int &nHits, float &eventEnergy) const
Increment the showery hit parameters for a cluster list.
void GetEventShapeFeatures(const ClusterListMap &clusterListMap, float &eventArea, float &longitudinality) const
Get the event shape features.
void lar_content::TrainedVertexSelectionAlgorithm::CalculateRPhiScores ( pandora::VertexVector &  vertexVector,
VertexFeatureInfoMap vertexFeatureInfoMap,
const KDTreeMap kdTreeMap 
) const
protected

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 563 of file TrainedVertexSelectionAlgorithm.cc.

565 {
566  float bestFastScore(-std::numeric_limits<float>::max());
567 
568  for (auto iter = vertexVector.begin(); iter != vertexVector.end(); /* no increment */)
569  {
570  VertexFeatureInfo &vertexFeatureInfo = vertexFeatureInfoMap.at(*iter);
571  vertexFeatureInfo.m_rPhiFeature = static_cast<float>(LArMvaHelper::CalculateFeaturesOfType<RPhiFeatureTool>(m_featureToolVector, this,
572  *iter, SlidingFitDataListMap(), ClusterListMap(), kdTreeMap, ShowerClusterListMap(), vertexFeatureInfo.m_beamDeweighting, bestFastScore)
573  .at(0)
574  .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 }
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool vector.
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.
static int max(int a, int b)
bool m_dropFailedRPhiFastScoreCandidates
Whether to drop candidates that fail the r/phi fast score test.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
void lar_content::TrainedVertexSelectionAlgorithm::CalculateShowerClusterList ( const pandora::ClusterList &  inputClusterList,
ShowerClusterList showerClusterList 
) const
protected

Calculate the shower cluster map for a cluster list.

Parameters
inputClusterListthe input cluster list
showerClusterListthe shower cluster list to populate

Definition at line 65 of file TrainedVertexSelectionAlgorithm.cc.

66 {
67  ClusterEndPointsMap clusterEndPointsMap;
68  ClusterList showerLikeClusters;
69  this->GetShowerLikeClusterEndPoints(inputClusterList, showerLikeClusters, clusterEndPointsMap);
70 
71  const float slidingFitPitch(LArGeometryHelper::GetWireZPitch(this->GetPandora()));
72  ClusterList availableShowerLikeClusters(showerLikeClusters.begin(), showerLikeClusters.end());
73 
74  HitKDTree2D kdTree;
75  HitToClusterMap hitToClusterMap;
76 
78  this->PopulateKdTree(availableShowerLikeClusters, kdTree, hitToClusterMap);
79 
80  while (!availableShowerLikeClusters.empty())
81  {
82  ClusterList showerCluster;
83  showerCluster.push_back(availableShowerLikeClusters.back());
84  availableShowerLikeClusters.pop_back();
85 
86  bool addedCluster(true);
87  while (addedCluster && !availableShowerLikeClusters.empty())
88  {
89  addedCluster = false;
90  for (const Cluster *const pCluster : showerCluster)
91  {
93  {
94  addedCluster = this->AddClusterToShower(kdTree, hitToClusterMap, availableShowerLikeClusters, pCluster, showerCluster);
95  }
96  else
97  {
98  addedCluster = this->AddClusterToShower(clusterEndPointsMap, availableShowerLikeClusters, pCluster, showerCluster);
99  }
100 
101  if (addedCluster)
102  break;
103  }
104  }
105 
106  unsigned int totHits(0);
107  for (const Cluster *const pCluster : showerCluster)
108  totHits += pCluster->GetNCaloHits();
109 
110  if (totHits < m_minClusterCaloHits)
111  continue;
112 
113  showerClusterList.emplace_back(showerCluster, slidingFitPitch, m_slidingFitWindow);
114  }
115 }
bool m_useShowerClusteringApproximation
Whether to use the shower clustering distance approximation.
std::unordered_map< const pandora::CaloHit *, const pandora::Cluster * > HitToClusterMap
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
KDTreeLinkerAlgo< const pandora::CaloHit *, 2 > HitKDTree2D
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
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_slidingFitWindow
The layer window for the sliding linear fits.
std::map< const pandora::Cluster *const, ClusterEndPoints > ClusterEndPointsMap
bool AddClusterToShower(const ClusterEndPointsMap &clusterEndPointsMap, pandora::ClusterList &availableShowerLikeClusters, const pandora::Cluster *const pCluster, pandora::ClusterList &showerCluster) const
Try to add an available cluster to a given shower cluster, using shower clustering approximation...
void GetShowerLikeClusterEndPoints(const pandora::ClusterList &clusterList, pandora::ClusterList &showerLikeClusters, ClusterEndPointsMap &clusterEndPointsMap) const
Add the endpoints of any shower-like clusters to the map.
void lar_content::TrainedVertexSelectionAlgorithm::Get2DSpan ( const pandora::ClusterList &  clusterList,
float &  xSpan,
float &  zSpan 
) const
protected

Get the coordinate span in one view.

Parameters
clusterListthe cluster list in one view
xSpanthe coordinate span in the drift direction
zSpanthe coordinate span in the wire direction

Definition at line 352 of file TrainedVertexSelectionAlgorithm.cc.

353 {
354  FloatVector xPositions, zPositions;
355 
356  for (const Cluster *const pCluster : clusterList)
357  {
358  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
359 
360  for (OrderedCaloHitList::const_iterator iter = orderedCaloHitList.begin(), iterEnd = orderedCaloHitList.end(); iter != iterEnd; ++iter)
361  {
362  for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
363  {
364  xPositions.push_back((*hitIter)->GetPositionVector().GetX());
365  zPositions.push_back((*hitIter)->GetPositionVector().GetZ());
366  }
367  }
368  }
369 
370  std::sort(xPositions.begin(), xPositions.end());
371  std::sort(zPositions.begin(), zPositions.end());
372 
373  if (xPositions.empty())
374  {
375  xSpan = 0;
376  zSpan = 0;
377  }
378  else
379  {
380  const int low = std::round(0.05 * xPositions.size());
381  const int high = std::round(0.95 * xPositions.size()) - 1;
382 
383  xSpan = xPositions[high] - xPositions[low];
384  zSpan = zPositions[high] - zPositions[low];
385  }
386 }
intermediate_table::const_iterator const_iterator
Dft::FloatVector FloatVector
void lar_content::TrainedVertexSelectionAlgorithm::GetBestRegionVertices ( VertexScoreList initialScoreList,
pandora::VertexVector &  bestRegionVertices 
) const
protected

Get the list of top-N separated vertices.

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

Definition at line 490 of file TrainedVertexSelectionAlgorithm.cc.

491 {
492  std::sort(initialScoreList.begin(), initialScoreList.end());
493 
494  for (const VertexScore &vertexScore : initialScoreList)
495  {
496  const Vertex *const pVertex(vertexScore.GetVertex());
497  bool farEnoughAway(true);
498 
499  for (const Vertex *const pRegionVertex : bestRegionVertices)
500  {
501  if (pRegionVertex == pVertex)
502  {
503  farEnoughAway = false;
504  break;
505  }
506 
507  const float distance = (pRegionVertex->GetPosition() - pVertex->GetPosition()).GetMagnitude();
508 
509  if (distance <= m_regionRadius)
510  {
511  farEnoughAway = false;
512  break;
513  }
514  }
515 
516  if (farEnoughAway)
517  bestRegionVertices.push_back(pVertex);
518  }
519 }
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
void lar_content::TrainedVertexSelectionAlgorithm::GetBestVertex ( const pandora::VertexVector &  vertexVector,
const pandora::Vertex *&  pBestVertex,
float &  bestVertexDr 
) const
protected

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 756 of file TrainedVertexSelectionAlgorithm.cc.

757 {
758  // Extract input collections
759  const MCParticleList *pMCParticleList(nullptr);
760  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_mcParticleListName, pMCParticleList));
761 
762  // Obtain vector: true targets
763  MCParticleVector mcTargetVector;
764 
765  if (m_testBeamMode)
766  {
767  LArMCParticleHelper::GetTrueTestBeamParticles(pMCParticleList, mcTargetVector);
768  }
769  else
770  {
771  LArMCParticleHelper::GetTrueNeutrinos(pMCParticleList, mcTargetVector);
772  }
773 
774  for (const Vertex *const pVertex : vertexVector)
775  {
776  float mcVertexDr(std::numeric_limits<float>::max());
777  for (const MCParticle *const pMCTarget : mcTargetVector)
778  {
779  const CartesianVector &mcTargetPosition(
780  (m_testBeamMode && std::fabs(pMCTarget->GetParticleId()) == 11) ? pMCTarget->GetVertex() : pMCTarget->GetEndpoint());
781  const CartesianVector mcTargetCorrectedPosition(
782  mcTargetPosition.GetX() + m_mcVertexXCorrection, mcTargetPosition.GetY(), mcTargetPosition.GetZ());
783  const float dr = (mcTargetCorrectedPosition - pVertex->GetPosition()).GetMagnitude();
784 
785  if (dr < mcVertexDr)
786  mcVertexDr = dr;
787  }
788 
789  if (mcVertexDr < bestVertexDr)
790  {
791  bestVertexDr = mcVertexDr;
792  pBestVertex = pVertex;
793  }
794  }
795 }
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
std::string m_mcParticleListName
The MC particle list for creating training examples.
static int max(int a, int b)
static void GetTrueNeutrinos(const pandora::MCParticleList *const pMCParticleList, pandora::MCParticleVector &trueNeutrinos)
Get neutrino MC particles from an input MC particle list.
float m_mcVertexXCorrection
The correction to the x-coordinate of the MC vertex position.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
static void GetTrueTestBeamParticles(const pandora::MCParticleList *const pMCParticleList, pandora::MCParticleVector &trueTestBeamParticles)
Get triggered test beam MC particles from an input MC particle list.
float lar_content::TrainedVertexSelectionAlgorithm::GetCoordinateSpan ( const pandora::InputFloat &  minCoord,
const pandora::InputFloat &  maxCoord 
) const
inlineprotected

Get the coordinate span.

Parameters
minCoordthe min coordinate
maxCoordthe max coordinate
Returns
the coordinate span

Definition at line 402 of file TrainedVertexSelectionAlgorithm.cc.

403 {
404  if (minCoord.IsInitialized() && maxCoord.IsInitialized())
405  return std::fabs(maxCoord.Get() - minCoord.Get());
406 
407  return 0.f;
408 }
void lar_content::TrainedVertexSelectionAlgorithm::GetEventShapeFeatures ( const ClusterListMap clusterListMap,
float &  eventArea,
float &  longitudinality 
) const
protected

Get the event shape features.

Parameters
clusterListthe map of cluster lists for each view
eventAreathe event area
longitudinalitythe event longitudinality

Definition at line 332 of file TrainedVertexSelectionAlgorithm.cc.

333 {
334  float xSpanU(0.f), zSpanU(0.f), xSpanV(0.f), zSpanV(0.f), xSpanW(0.f), zSpanW(0.f);
335 
336  this->Get2DSpan(clusterListMap.at(TPC_VIEW_U), xSpanU, zSpanU);
337  this->Get2DSpan(clusterListMap.at(TPC_VIEW_V), xSpanV, zSpanV);
338  this->Get2DSpan(clusterListMap.at(TPC_VIEW_W), xSpanW, zSpanW);
339 
340  const float xSpan = (xSpanU + xSpanV + xSpanW) / 3.f;
341  const float zSpan = (zSpanU + zSpanV + zSpanW) / 3.f;
342 
343  if ((xSpan > std::numeric_limits<float>::epsilon()) && (zSpan > std::numeric_limits<float>::epsilon()))
344  {
345  eventArea = xSpan * zSpan;
346  longitudinality = zSpan / (xSpan + zSpan);
347  }
348 }
void Get2DSpan(const pandora::ClusterList &clusterList, float &xSpan, float &zSpan) const
Get the coordinate span in one view.
std::string lar_content::TrainedVertexSelectionAlgorithm::GetInteractionType ( ) const
protected

Get the interaction type string.

Returns
the interaction type string

Definition at line 586 of file TrainedVertexSelectionAlgorithm.cc.

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  LArMCParticleHelper::MCContributionMap targetMCParticlesToGoodHitsMap;
596 
597  if (m_testBeamMode)
598  {
599  LArMCParticleHelper::SelectReconstructableMCParticles(pMCParticleList, pCaloHitList, LArMCParticleHelper::PrimaryParameters(),
600  LArMCParticleHelper::IsTriggeredBeamParticle, targetMCParticlesToGoodHitsMap);
601  }
602  else
603  {
604  // ATTN Assumes single neutrino is parent of all neutrino-induced mc particles
605  LArMCParticleHelper::SelectReconstructableMCParticles(pMCParticleList, pCaloHitList, LArMCParticleHelper::PrimaryParameters(),
606  LArMCParticleHelper::IsBeamNeutrinoFinalState, targetMCParticlesToGoodHitsMap);
607  }
608 
609  MCParticleList mcPrimaryList;
610  for (const auto &mapEntry : targetMCParticlesToGoodHitsMap)
611  mcPrimaryList.push_back(mapEntry.first);
612  mcPrimaryList.sort(LArMCParticleHelper::SortByMomentum);
613 
615  return LArInteractionTypeHelper::ToString(interactionType);
616 }
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
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 target, reconstructable mc particles that match given criteria.
std::string m_mcParticleListName
The MC particle list for creating training examples.
static std::string ToString(const InteractionType interactionType)
Get a string representation of an interaction type.
static bool IsTriggeredBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary triggered beam MCParticle.
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::TrainedVertexSelectionAlgorithm::GetLegacyEventShapeFeatures ( const pandora::ClusterList &  clusterList,
float &  eventVolume,
float &  longitudinality 
) const
protected

Get the event shape features.

Parameters
clusterListthe cluster list
eventVolumethe event volume
longitudinalitythe event longitudinality

Definition at line 292 of file TrainedVertexSelectionAlgorithm.cc.

293 {
294  InputFloat xMin, yMin, zMin, xMax, yMax, zMax;
295 
296  for (const Cluster *const pCluster : clusterList)
297  {
298  CartesianVector minPosition(0.f, 0.f, 0.f), maxPosition(0.f, 0.f, 0.f);
299  LArClusterHelper::GetClusterBoundingBox(pCluster, minPosition, maxPosition);
300 
301  this->UpdateSpanCoordinate(minPosition.GetX(), maxPosition.GetX(), xMin, xMax);
302  this->UpdateSpanCoordinate(minPosition.GetY(), maxPosition.GetY(), yMin, yMax);
303  this->UpdateSpanCoordinate(minPosition.GetZ(), maxPosition.GetZ(), zMin, zMax);
304  }
305 
306  const float xSpan(this->GetCoordinateSpan(xMax, xMin));
307  const float ySpan(this->GetCoordinateSpan(yMax, zMin));
308  const float zSpan(this->GetCoordinateSpan(yMax, zMin));
309 
310  // Calculate the volume and longitudinality of the event (ySpan often 0 - to be investigated).
311  if ((xSpan > std::numeric_limits<float>::epsilon()) && (ySpan > std::numeric_limits<float>::epsilon()))
312  {
313  eventVolume = xSpan * ySpan * zSpan;
314  longitudinality = zSpan / (xSpan + ySpan);
315  }
316 
317  else if (ySpan > std::numeric_limits<float>::epsilon())
318  {
319  eventVolume = ySpan * ySpan * zSpan;
320  longitudinality = zSpan / (ySpan + ySpan);
321  }
322 
323  else if (xSpan > std::numeric_limits<float>::epsilon())
324  {
325  eventVolume = xSpan * xSpan * zSpan;
326  longitudinality = zSpan / (xSpan + xSpan);
327  }
328 }
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.
float GetCoordinateSpan(const pandora::InputFloat &minCoord, const pandora::InputFloat &maxCoord) const
Get the coordinate span.
void lar_content::TrainedVertexSelectionAlgorithm::GetSharedFeatures ( const pandora::Vertex *const  pVertex1,
const pandora::Vertex *const  pVertex2,
const KDTreeMap kdTreeMap,
float &  separation,
float &  axisHits 
) const
protected

Calculates the shared features of a pair of vertex candidates.

Parameters
pVertex1the address of the first vertex
pVertex2the address of the second vertex
kdTreeMapthe map of 2D hit kd trees
separationthe 3D distance between the two vertex candidates
axisHitsthe number of hits between the two candidates normalised to the distance between them

Definition at line 680 of file TrainedVertexSelectionAlgorithm.cc.

682 {
683  separation = (pVertex1->GetPosition() - pVertex2->GetPosition()).GetMagnitude();
684 
685  this->IncrementSharedAxisValues(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex1->GetPosition(), TPC_VIEW_U),
686  LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex2->GetPosition(), TPC_VIEW_U), kdTreeMap.at(TPC_VIEW_U), axisHits);
687 
688  this->IncrementSharedAxisValues(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex1->GetPosition(), TPC_VIEW_V),
689  LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex2->GetPosition(), TPC_VIEW_V), kdTreeMap.at(TPC_VIEW_V), axisHits);
690 
691  this->IncrementSharedAxisValues(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex1->GetPosition(), TPC_VIEW_W),
692  LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex2->GetPosition(), TPC_VIEW_W), kdTreeMap.at(TPC_VIEW_W), axisHits);
693 
694  axisHits = separation > std::numeric_limits<float>::epsilon() ? axisHits / separation : 0.f;
695 }
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
void IncrementSharedAxisValues(const pandora::CartesianVector pos1, const pandora::CartesianVector pos2, HitKDTree2D &kdTree, float &axisHits) const
Increments the axis hits information for one view.
void lar_content::TrainedVertexSelectionAlgorithm::GetShowerLikeClusterEndPoints ( const pandora::ClusterList &  clusterList,
pandora::ClusterList &  showerLikeClusters,
ClusterEndPointsMap clusterEndPointsMap 
) const
protected

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 119 of file TrainedVertexSelectionAlgorithm.cc.

121 {
122  for (const Cluster *const pCluster : clusterList)
123  {
124  if (pCluster->GetNCaloHits() < m_minShowerClusterHits)
125  continue;
126 
127  if (this->IsClusterShowerLike(pCluster))
128  showerLikeClusters.push_back(pCluster);
129 
130  CaloHitList clusterCaloHitList;
131  pCluster->GetOrderedCaloHitList().FillCaloHitList(clusterCaloHitList);
132 
133  CaloHitVector clusterCaloHitVector(clusterCaloHitList.begin(), clusterCaloHitList.end());
134  std::sort(clusterCaloHitVector.begin(), clusterCaloHitVector.end(), LArClusterHelper::SortHitsByPosition);
135 
136  if (clusterCaloHitVector.empty())
137  continue;
138 
139  ClusterEndPoints clusterEndPoints(clusterCaloHitVector.front()->GetPositionVector(), clusterCaloHitVector.back()->GetPositionVector());
140  clusterEndPointsMap.emplace(pCluster, clusterEndPoints);
141  }
142 }
bool IsClusterShowerLike(const pandora::Cluster *const pCluster) const
Find whether a cluster is shower-like.
unsigned int m_minShowerClusterHits
The minimum number of shower cluster hits.
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)
virtual void lar_content::TrainedVertexSelectionAlgorithm::GetVertexScoreList ( const pandora::VertexVector &  vertexVector,
const BeamConstants beamConstants,
HitKDTree2D kdTreeU,
HitKDTree2D kdTreeV,
HitKDTree2D kdTreeW,
VertexScoreList vertexScoreList 
) const
protectedpure virtual

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.

Implemented in lar_content::MvaVertexSelectionAlgorithm< T >, and lar_content::CheatingVertexSelectionAlgorithm.

void lar_content::TrainedVertexSelectionAlgorithm::IncrementSharedAxisValues ( const pandora::CartesianVector  pos1,
const pandora::CartesianVector  pos2,
HitKDTree2D kdTree,
float &  axisHits 
) const
protected

Increments the axis hits information for one view.

Parameters
pos12D projected position of the first vertex
pos22D projected position of the second vertex
kdTreethe kd tree of 2D hits
axisHitsthe number of hits between the two candidates

Definition at line 699 of file TrainedVertexSelectionAlgorithm.cc.

701 {
702  if (pos1 == pos2)
703  return;
704 
705  // Define the axis and perpendicular directions
706  const CartesianVector unitAxis = (pos1 - pos2).GetUnitVector();
707  const CartesianVector unitPerp(unitAxis.GetZ(), 0, -unitAxis.GetX());
708 
709  // Define the corners of the search box
710  const CartesianVector point1 = pos1 + unitPerp;
711  const CartesianVector point2 = pos1 - unitPerp;
712  const CartesianVector point3 = pos2 + unitPerp;
713  const CartesianVector point4 = pos2 - unitPerp;
714 
715  // Find the total coordinate span these points cover
716  const float xMin{std::min({point1.GetX(), point2.GetX(), point3.GetX(), point4.GetX()})};
717  const float xMax{std::max({point1.GetX(), point2.GetX(), point3.GetX(), point4.GetX()})};
718  const float zMin{std::min({point1.GetZ(), point2.GetZ(), point3.GetZ(), point4.GetZ()})};
719  const float zMax{std::max({point1.GetZ(), point2.GetZ(), point3.GetZ(), point4.GetZ()})};
720 
721  // Use a kd search to find the hits in the 'wide' area
722  KDTreeBox searchBox(xMin, zMin, xMax, zMax);
724  kdTree.search(searchBox, found);
725 
726  // Use IsHitInBox method to check the 'wide' area hits for those in the search box
727  for (auto f : found)
728  {
729  const CartesianVector &hitPos = f.data->GetPositionVector();
730  bool inBox = this->IsHitInBox(hitPos, point1, point2, point3, point4);
731 
732  if (inBox)
733  ++axisHits;
734  }
735 }
bool IsHitInBox(const pandora::CartesianVector &hitPos, const pandora::CartesianVector &point1, const pandora::CartesianVector &point2, const pandora::CartesianVector &point3, const pandora::CartesianVector &point4) const
Determines whether a hit lies within the box defined by four other positions.
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
KDTreeBoxT< 2 > KDTreeBox
void lar_content::TrainedVertexSelectionAlgorithm::IncrementShoweryParameters ( const pandora::ClusterList &  clusterList,
unsigned int &  nShoweryHits,
unsigned int &  nHits,
float &  eventEnergy 
) const
protected

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 270 of file TrainedVertexSelectionAlgorithm.cc.

272 {
273  for (const Cluster *const pCluster : clusterList)
274  {
275  if (this->IsClusterShowerLike(pCluster))
276  nShoweryHits += pCluster->GetNCaloHits();
277 
278  eventEnergy += pCluster->GetElectromagneticEnergy();
279  nHits += pCluster->GetNCaloHits();
280  }
281 }
bool IsClusterShowerLike(const pandora::Cluster *const pCluster) const
Find whether a cluster is shower-like.
bool lar_content::TrainedVertexSelectionAlgorithm::IsClusterShowerLike ( const pandora::Cluster *const  pCluster) const
inlineprotected

Find whether a cluster is shower-like.

Parameters
pClusterthe cluster
Returns
boolean

Definition at line 285 of file TrainedVertexSelectionAlgorithm.cc.

286 {
287  return (pCluster->GetParticleId() == E_MINUS && LArClusterHelper::GetLength(pCluster) < m_minShowerSpineLength);
288 }
static float GetLength(const pandora::Cluster *const pCluster)
Get length of cluster.
float m_minShowerSpineLength
The minimum length at which all are considered to be tracks.
bool lar_content::TrainedVertexSelectionAlgorithm::IsHitInBox ( const pandora::CartesianVector &  hitPos,
const pandora::CartesianVector &  point1,
const pandora::CartesianVector &  point2,
const pandora::CartesianVector &  point3,
const pandora::CartesianVector &  point4 
) const
protected

Determines whether a hit lies within the box defined by four other positions.

Parameters
hitPosthe hit position
point1the first corner of the box
point2the second corner of the box
point3the third corner of the box
point4the fourth corner of the box
Returns
boolean

Definition at line 739 of file TrainedVertexSelectionAlgorithm.cc.

741 {
742  bool b1 = std::signbit(((point2 - point1).GetCrossProduct(point2 - hitPos)).GetY());
743  bool b2 = std::signbit(((point4 - point3).GetCrossProduct(point4 - hitPos)).GetY());
744 
745  if (!(b1 xor b2))
746  return false;
747 
748  bool b3 = std::signbit(((point3 - point1).GetCrossProduct(point3 - hitPos)).GetY());
749  bool b4 = std::signbit(((point4 - point2).GetCrossProduct(point4 - hitPos)).GetY());
750 
751  return (b3 xor b4);
752 }
void lar_content::TrainedVertexSelectionAlgorithm::PopulateFinalVertexScoreList ( const VertexFeatureInfoMap vertexFeatureInfoMap,
const pandora::Vertex *const  pFavouriteVertex,
const pandora::VertexVector &  vertexVector,
VertexScoreList finalVertexScoreList 
) const
protected

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 829 of file TrainedVertexSelectionAlgorithm.cc.

831 {
832  if (pFavouriteVertex)
833  {
834  const CartesianVector vertexPosition(pFavouriteVertex->GetPosition());
835 
836  for (const Vertex *const pVertex : vertexVector)
837  {
838  if ((pVertex->GetPosition() - vertexPosition).GetMagnitude() < m_rPhiFineTuningRadius)
839  {
840  const float rPhiScore(vertexFeatureInfoMap.at(pVertex).m_rPhiFeature);
841  finalVertexScoreList.emplace_back(pVertex, rPhiScore);
842  }
843  }
844  }
845 }
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
float m_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.
void lar_content::TrainedVertexSelectionAlgorithm::PopulateInitialScoreList ( VertexFeatureInfoMap vertexFeatureInfoMap,
const pandora::Vertex *const  pVertex,
VertexScoreList initialScoreList 
) const
protected

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 474 of file TrainedVertexSelectionAlgorithm.cc.

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

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 146 of file TrainedVertexSelectionAlgorithm.cc.

147 {
148  CaloHitList allCaloHits;
149 
150  for (const Cluster *const pCluster : clusterList)
151  {
152  CaloHitList daughterHits;
153  pCluster->GetOrderedCaloHitList().FillCaloHitList(daughterHits);
154  allCaloHits.insert(allCaloHits.end(), daughterHits.begin(), daughterHits.end());
155 
156  for (const CaloHit *const pCaloHit : daughterHits)
157  (void)hitToClusterMap.insert(HitToClusterMap::value_type(pCaloHit, pCluster));
158  }
159 
160  HitKDNode2DList hitKDNode2DList;
161  KDTreeBox hitsBoundingRegion2D(fill_and_bound_2d_kd_tree(allCaloHits, hitKDNode2DList));
162  kdTree.build(hitKDNode2DList, hitsBoundingRegion2D);
163 }
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::TrainedVertexSelectionAlgorithm::PopulateVertexFeatureInfoMap ( const BeamConstants beamConstants,
const ClusterListMap clusterListMap,
const SlidingFitDataListMap slidingFitDataListMap,
const ShowerClusterListMap showerClusterListMap,
const KDTreeMap kdTreeMap,
const pandora::Vertex *const  pVertex,
VertexFeatureInfoMap vertexFeatureInfoMap 
) const
protected

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 425 of file TrainedVertexSelectionAlgorithm.cc.

428 {
429  float bestFastScore(-std::numeric_limits<float>::max()); // not actually used - artefact of toolizing RPhi score and still using performance trick
430 
431  const double beamDeweighting(this->GetBeamDeweightingScore(beamConstants, pVertex));
432 
433  const double energyKick(LArMvaHelper::CalculateFeaturesOfType<EnergyKickFeatureTool>(m_featureToolVector, this, pVertex,
434  slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore)
435  .at(0)
436  .Get());
437 
438  const double localAsymmetry(LArMvaHelper::CalculateFeaturesOfType<LocalAsymmetryFeatureTool>(m_featureToolVector, this, pVertex,
439  slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore)
440  .at(0)
441  .Get());
442 
443  const double globalAsymmetry(LArMvaHelper::CalculateFeaturesOfType<GlobalAsymmetryFeatureTool>(m_featureToolVector, this, pVertex,
444  slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore)
445  .at(0)
446  .Get());
447 
448  const double showerAsymmetry(LArMvaHelper::CalculateFeaturesOfType<ShowerAsymmetryFeatureTool>(m_featureToolVector, this, pVertex,
449  slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore)
450  .at(0)
451  .Get());
452 
453  //const double rPhiFeature(LArMvaHelper::CalculateFeaturesOfType<RPhiFeatureTool>(m_featureToolVector, this, pVertex,
454  // slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore).at(0).Get());
455 
456  double dEdxAsymmetry(0.f), vertexEnergy(0.f);
457 
458  if (!m_legacyVariables)
459  {
460  dEdxAsymmetry = LArMvaHelper::CalculateFeaturesOfType<EnergyDepositionAsymmetryFeatureTool>(m_featureToolVector, this, pVertex,
461  slidingFitDataListMap, clusterListMap, kdTreeMap, showerClusterListMap, beamDeweighting, bestFastScore)
462  .at(0)
463  .Get();
464 
465  vertexEnergy = this->GetVertexEnergy(pVertex, kdTreeMap);
466  }
467 
468  VertexFeatureInfo vertexFeatureInfo(beamDeweighting, 0.f, energyKick, localAsymmetry, globalAsymmetry, showerAsymmetry, dEdxAsymmetry, vertexEnergy);
469  vertexFeatureInfoMap.emplace(pVertex, vertexFeatureInfo);
470 }
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool vector.
static int max(int a, int b)
float GetVertexEnergy(const pandora::Vertex *const pVertex, const KDTreeMap &kdTreeMap) const
Calculate the energy of a vertex candidate by summing values from all three planes.
bool m_legacyVariables
Whether to only use the old variables.
float GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
Get the beam deweighting score for a vertex.
const pandora::Vertex * lar_content::TrainedVertexSelectionAlgorithm::ProduceTrainingExamples ( const pandora::VertexVector &  vertexVector,
const VertexFeatureInfoMap vertexFeatureInfoMap,
std::bernoulli_distribution &  coinFlip,
std::mt19937 &  generator,
const std::string interactionType,
const std::string trainingOutputFile,
const LArMvaHelper::MvaFeatureVector eventFeatureList,
const KDTreeMap kdTreeMap,
const float  maxRadius,
const bool  useRPhi 
) const
protected

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
kdTreeMapthe map of 2D hit kd trees
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 620 of file TrainedVertexSelectionAlgorithm.cc.

624 {
625  const Vertex *pBestVertex(nullptr);
626  float bestVertexDr(std::numeric_limits<float>::max());
627 
628  LArMvaHelper::MvaFeatureVector bestVertexFeatureList;
629  this->GetBestVertex(vertexVector, pBestVertex, bestVertexDr);
630 
631  VertexFeatureInfo bestVertexFeatureInfo(vertexFeatureInfoMap.at(pBestVertex));
632  this->AddVertexFeaturesToVector(bestVertexFeatureInfo, bestVertexFeatureList, useRPhi);
633 
634  for (const Vertex *const pVertex : vertexVector)
635  {
636  if (pVertex == pBestVertex)
637  continue;
638 
639  LArMvaHelper::MvaFeatureVector featureList;
640  VertexFeatureInfo vertexFeatureInfo(vertexFeatureInfoMap.at(pVertex));
641  this->AddVertexFeaturesToVector(vertexFeatureInfo, featureList, useRPhi);
642 
643  if (!m_legacyVariables)
644  {
645  LArMvaHelper::MvaFeatureVector sharedFeatureList;
646  float separation(0.f), axisHits(0.f);
647  this->GetSharedFeatures(pVertex, pBestVertex, kdTreeMap, separation, axisHits);
648  VertexSharedFeatureInfo sharedFeatureInfo(separation, axisHits);
649  this->AddSharedFeaturesToVector(sharedFeatureInfo, sharedFeatureList);
650 
651  if (pBestVertex && (bestVertexDr < maxRadius))
652  {
653  if (coinFlip(generator))
654  LArMvaHelper::ProduceTrainingExample(trainingOutputFile + "_" + interactionType + ".txt", true, eventFeatureList,
655  bestVertexFeatureList, featureList, sharedFeatureList);
656  else
657  LArMvaHelper::ProduceTrainingExample(trainingOutputFile + "_" + interactionType + ".txt", false, eventFeatureList,
658  featureList, bestVertexFeatureList, sharedFeatureList);
659  }
660  }
661  else
662  {
663  if (pBestVertex && (bestVertexDr < maxRadius))
664  {
665  if (coinFlip(generator))
667  trainingOutputFile + "_" + interactionType + ".txt", true, eventFeatureList, bestVertexFeatureList, featureList);
668  else
670  trainingOutputFile + "_" + interactionType + ".txt", false, eventFeatureList, featureList, bestVertexFeatureList);
671  }
672  }
673  }
674 
675  return pBestVertex;
676 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:58
void AddVertexFeaturesToVector(const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
Add the vertex features to a vector in the correct order.
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
static int max(int a, int b)
generator
Definition: train.py:468
void AddSharedFeaturesToVector(const VertexSharedFeatureInfo &vertexSharedFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the shared features to a vector in the correct order.
void GetSharedFeatures(const pandora::Vertex *const pVertex1, const pandora::Vertex *const pVertex2, const KDTreeMap &kdTreeMap, float &separation, float &axisHits) const
Calculates the shared features of a pair of vertex candidates.
bool m_legacyVariables
Whether to only use the old variables.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
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::TrainedVertexSelectionAlgorithm::ProduceTrainingSets ( const pandora::VertexVector &  vertexVector,
const pandora::VertexVector &  bestRegionVertices,
VertexFeatureInfoMap vertexFeatureInfoMap,
const LArMvaHelper::MvaFeatureVector eventFeatureList,
const KDTreeMap kdTreeMap 
) const
protected

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 523 of file TrainedVertexSelectionAlgorithm.cc.

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

Definition at line 850 of file TrainedVertexSelectionAlgorithm.cc.

851 {
852  AlgorithmToolVector algorithmToolVector;
853  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "FeatureTools", algorithmToolVector));
854 
855  for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
856  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArMvaHelper::AddFeatureToolToVector(pAlgorithmTool, m_featureToolVector));
857 
858  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrainingSetMode", m_trainingSetMode));
859 
860  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
861  XmlHelper::ReadValue(xmlHandle, "AllowClassifyDuringTraining", m_allowClassifyDuringTraining));
862 
863  PANDORA_RETURN_RESULT_IF_AND_IF(
864  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MCVertexXCorrection", m_mcVertexXCorrection));
865 
866  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
867  XmlHelper::ReadValue(xmlHandle, "TrainingOutputFileRegion", m_trainingOutputFileRegion));
868 
869  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
870  XmlHelper::ReadValue(xmlHandle, "TrainingOutputFileVertex", m_trainingOutputFileVertex));
871 
873  {
874  std::cout << "TrainedVertexSelectionAlgorithm: TrainingOutputFileRegion and TrainingOutputFileVertex are required for training set "
875  << "mode" << std::endl;
876  return STATUS_CODE_INVALID_PARAMETER;
877  }
878 
879  PANDORA_RETURN_RESULT_IF_AND_IF(
880  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MCParticleListName", m_mcParticleListName));
881 
882  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "CaloHitListName", m_caloHitListName));
883 
884  if (m_trainingSetMode && (m_mcParticleListName.empty() || m_caloHitListName.empty()))
885  {
886  std::cout << "TrainedVertexSelectionAlgorithm: MCParticleListName and CaloHitListName are required for training set mode" << std::endl;
887  return STATUS_CODE_INVALID_PARAMETER;
888  }
889 
890  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "InputClusterListNames", m_inputClusterListNames));
891 
892  PANDORA_RETURN_RESULT_IF_AND_IF(
893  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterCaloHits", m_minClusterCaloHits));
894 
895  PANDORA_RETURN_RESULT_IF_AND_IF(
896  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
897 
898  PANDORA_RETURN_RESULT_IF_AND_IF(
899  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinShowerSpineLength", m_minShowerSpineLength));
900 
901  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
902  XmlHelper::ReadValue(xmlHandle, "BeamDeweightingConstant", m_beamDeweightingConstant));
903 
904  PANDORA_RETURN_RESULT_IF_AND_IF(
905  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "LocalAsymmetryConstant", m_localAsymmetryConstant));
906 
907  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
908  XmlHelper::ReadValue(xmlHandle, "GlobalAsymmetryConstant", m_globalAsymmetryConstant));
909 
910  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
911  XmlHelper::ReadValue(xmlHandle, "ShowerAsymmetryConstant", m_showerAsymmetryConstant));
912 
913  PANDORA_RETURN_RESULT_IF_AND_IF(
914  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "EnergyKickConstant", m_energyKickConstant));
915 
916  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
917  XmlHelper::ReadValue(xmlHandle, "ShowerClusteringDistance", m_showerClusteringDistance));
918 
919  PANDORA_RETURN_RESULT_IF_AND_IF(
920  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinShowerClusterHits", m_minShowerClusterHits));
921 
922  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
923  XmlHelper::ReadValue(xmlHandle, "UseShowerClusteringApproximation", m_useShowerClusteringApproximation));
924 
925  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "RegionRadius", m_regionRadius));
926 
927  PANDORA_RETURN_RESULT_IF_AND_IF(
928  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "RPhiFineTuningRadius", m_rPhiFineTuningRadius));
929 
930  PANDORA_RETURN_RESULT_IF_AND_IF(
931  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxTrueVertexRadius", m_maxTrueVertexRadius));
932 
933  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
934  XmlHelper::ReadValue(xmlHandle, "UseRPhiFeatureForRegion", m_useRPhiFeatureForRegion));
935 
936  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
937  XmlHelper::ReadValue(xmlHandle, "DropFailedRPhiFastScoreCandidates", m_dropFailedRPhiFastScoreCandidates));
938 
939  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TestBeamMode", m_testBeamMode));
940 
941  PANDORA_RETURN_RESULT_IF_AND_IF(
942  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "LegacyEventShapes", m_legacyEventShapes));
943 
944  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "LegacyVariables", m_legacyVariables));
945 
947  std::cout << "TrainedVertexSelectionAlgorithm: WARNING -- Producing training sample using incorrect legacy event shapes, consider turning LegacyEventShapes off"
948  << std::endl;
949 
951 }
std::string m_trainingOutputFileVertex
The training output file for the vertex mva.
bool m_useShowerClusteringApproximation
Whether to use the shower clustering distance approximation.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool vector.
bool m_legacyEventShapes
Whether to use the old event shapes calculation.
float m_localAsymmetryConstant
The local asymmetry constant for the initial region score list.
unsigned int m_minShowerClusterHits
The minimum number of shower cluster hits.
std::string m_mcParticleListName
The MC particle list for creating training examples.
float m_globalAsymmetryConstant
The global asymmetry constant for the initial region score list.
float m_maxTrueVertexRadius
The maximum distance at which a vertex candidate can be considered the &#39;true&#39; vertex.
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
float m_showerAsymmetryConstant
The shower asymmetry constant for the initial region score list.
float m_beamDeweightingConstant
The beam deweighting constant for the initial region score list.
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
std::string m_trainingOutputFileRegion
The training output file for the region mva.
bool m_dropFailedRPhiFastScoreCandidates
Whether to drop candidates that fail the r/phi fast score test.
float m_energyKickConstant
The energy kick constant for the initial region score list.
float m_mcVertexXCorrection
The correction to the x-coordinate of the MC vertex position.
bool m_legacyVariables
Whether to only use the old variables.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
std::string m_caloHitListName
The 2D CaloHit list name.
float m_minShowerSpineLength
The minimum length at which all are considered to be tracks.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_showerClusteringDistance
The shower clustering distance.
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
float m_rPhiFineTuningRadius
The maximum distance the r/phi tune can move a vertex.
QTextStream & endl(QTextStream &s)
void lar_content::TrainedVertexSelectionAlgorithm::UpdateSpanCoordinate ( const float  minPositionCoord,
const float  maxPositionCoord,
pandora::InputFloat &  minCoord,
pandora::InputFloat &  maxCoord 
) const
inlineprotected

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 390 of file TrainedVertexSelectionAlgorithm.cc.

392 {
393  if (!minCoord.IsInitialized() || minPositionCoord < minCoord.Get())
394  minCoord = minPositionCoord;
395 
396  if (!maxCoord.IsInitialized() || maxPositionCoord > maxCoord.Get())
397  maxCoord = maxPositionCoord;
398 }

Member Data Documentation

bool lar_content::TrainedVertexSelectionAlgorithm::m_allowClassifyDuringTraining
protected

Whether classification is allowed during training.

Definition at line 454 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_beamDeweightingConstant
protected

The beam deweighting constant for the initial region score list.

Definition at line 466 of file TrainedVertexSelectionAlgorithm.h.

std::string lar_content::TrainedVertexSelectionAlgorithm::m_caloHitListName
protected

The 2D CaloHit list name.

Definition at line 459 of file TrainedVertexSelectionAlgorithm.h.

bool lar_content::TrainedVertexSelectionAlgorithm::m_dropFailedRPhiFastScoreCandidates
protected

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

Definition at line 479 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_energyKickConstant
protected

The energy kick constant for the initial region score list.

Definition at line 470 of file TrainedVertexSelectionAlgorithm.h.

VertexFeatureTool::FeatureToolVector lar_content::TrainedVertexSelectionAlgorithm::m_featureToolVector
protected

The feature tool vector.

Definition at line 452 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_globalAsymmetryConstant
protected

The global asymmetry constant for the initial region score list.

Definition at line 468 of file TrainedVertexSelectionAlgorithm.h.

pandora::StringVector lar_content::TrainedVertexSelectionAlgorithm::m_inputClusterListNames
protected

The list of cluster list names.

Definition at line 461 of file TrainedVertexSelectionAlgorithm.h.

bool lar_content::TrainedVertexSelectionAlgorithm::m_legacyEventShapes
protected

Whether to use the old event shapes calculation.

Definition at line 481 of file TrainedVertexSelectionAlgorithm.h.

bool lar_content::TrainedVertexSelectionAlgorithm::m_legacyVariables
protected

Whether to only use the old variables.

Definition at line 482 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_localAsymmetryConstant
protected

The local asymmetry constant for the initial region score list.

Definition at line 467 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_maxTrueVertexRadius
protected

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

Definition at line 477 of file TrainedVertexSelectionAlgorithm.h.

std::string lar_content::TrainedVertexSelectionAlgorithm::m_mcParticleListName
protected

The MC particle list for creating training examples.

Definition at line 458 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_mcVertexXCorrection
protected

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

Definition at line 455 of file TrainedVertexSelectionAlgorithm.h.

unsigned int lar_content::TrainedVertexSelectionAlgorithm::m_minClusterCaloHits
protected

The min number of hits parameter in the energy score.

Definition at line 462 of file TrainedVertexSelectionAlgorithm.h.

unsigned int lar_content::TrainedVertexSelectionAlgorithm::m_minShowerClusterHits
protected

The minimum number of shower cluster hits.

Definition at line 473 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_minShowerSpineLength
protected

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

Definition at line 464 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_regionRadius
protected

The radius for a vertex region.

Definition at line 475 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_rPhiFineTuningRadius
protected

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

Definition at line 476 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_showerAsymmetryConstant
protected

The shower asymmetry constant for the initial region score list.

Definition at line 469 of file TrainedVertexSelectionAlgorithm.h.

float lar_content::TrainedVertexSelectionAlgorithm::m_showerClusteringDistance
protected

The shower clustering distance.

Definition at line 472 of file TrainedVertexSelectionAlgorithm.h.

unsigned int lar_content::TrainedVertexSelectionAlgorithm::m_slidingFitWindow
protected

The layer window for the sliding linear fits.

Definition at line 463 of file TrainedVertexSelectionAlgorithm.h.

bool lar_content::TrainedVertexSelectionAlgorithm::m_testBeamMode
protected

Test beam mode.

Definition at line 480 of file TrainedVertexSelectionAlgorithm.h.

std::string lar_content::TrainedVertexSelectionAlgorithm::m_trainingOutputFileRegion
protected

The training output file for the region mva.

Definition at line 456 of file TrainedVertexSelectionAlgorithm.h.

std::string lar_content::TrainedVertexSelectionAlgorithm::m_trainingOutputFileVertex
protected

The training output file for the vertex mva.

Definition at line 457 of file TrainedVertexSelectionAlgorithm.h.

bool lar_content::TrainedVertexSelectionAlgorithm::m_trainingSetMode
protected

Whether to train.

Definition at line 453 of file TrainedVertexSelectionAlgorithm.h.

bool lar_content::TrainedVertexSelectionAlgorithm::m_useRPhiFeatureForRegion
protected

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

Definition at line 478 of file TrainedVertexSelectionAlgorithm.h.

bool lar_content::TrainedVertexSelectionAlgorithm::m_useShowerClusteringApproximation
protected

Whether to use the shower clustering distance approximation.

Definition at line 474 of file TrainedVertexSelectionAlgorithm.h.


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