9 #include "Pandora/AlgorithmHeaders.h" 38 m_filePathEnvironmentVariable(
"FW_SEARCH_PATH")
48 ClusterList clustersU, clustersV, clustersW;
62 const ClusterListMap clusterListMap{{TPC_VIEW_U, clustersU}, {TPC_VIEW_V, clustersV}, {TPC_VIEW_W, clustersW}};
65 {TPC_VIEW_U, slidingFitDataListU}, {TPC_VIEW_V, slidingFitDataListV}, {TPC_VIEW_W, slidingFitDataListW}};
67 const ShowerClusterListMap showerClusterListMap{{TPC_VIEW_U, showerClusterListU}, {TPC_VIEW_V, showerClusterListV}, {TPC_VIEW_W, showerClusterListW}};
69 const KDTreeMap kdTreeMap{{TPC_VIEW_U, kdTreeU}, {TPC_VIEW_V, kdTreeV}, {TPC_VIEW_W, kdTreeW}};
78 for (
const Vertex *
const pVertex : vertexVector)
81 beamConstants, clusterListMap, slidingFitDataListMap, showerClusterListMap, kdTreeMap, pVertex, vertexFeatureInfoMap);
86 for (
const Vertex *
const pVertex : vertexVector)
93 this->
ProduceTrainingSets(vertexVector, bestRegionVertices, vertexFeatureInfoMap, eventFeatureList, kdTreeMap);
98 const Vertex *
const pBestRegionVertex(
103 for (
const Vertex *
const pVertex : vertexVector)
105 if (pVertex == pBestRegionVertex)
108 if ((pBestRegionVertex->GetPosition() - pVertex->GetPosition()).GetMagnitude() <
m_regionRadius)
109 regionalVertices.push_back(pVertex);
114 if (!regionalVertices.empty())
117 const Vertex *
const pBestVertex(
126 template <
typename T>
130 const Vertex *pBestVertex(vertexVector.front());
136 for (
const Vertex *
const pVertex : vertexVector)
138 if (pVertex == pBestVertex)
148 float separation(0.
f), axisHits(0.
f);
155 pBestVertex = pVertex;
156 chosenFeatureList = featureList;
163 pBestVertex = pVertex;
164 chosenFeatureList = featureList;
174 template <
typename T>
177 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
180 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MvaFileName",
m_mvaFileName));
182 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"RegionMvaName",
m_regionMvaName));
184 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"VertexMvaName",
m_vertexMvaName));
193 std::cout <<
"MvaVertexSelectionAlgorithm: MvaFileName, RegionMvaName and VertexMvaName must be set if training set mode is" 194 <<
"off or we allow classification during training" <<
std::endl;
195 return STATUS_CODE_INVALID_PARAMETER;
203 return STATUS_CODE_SUCCESS;
void AddEventFeaturesToVector(const EventFeatureInfo &eventFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector) const
Add the event features to a vector in the correct order.
bool m_useRPhiFeatureForRegion
Whether to use the r/phi feature for the region vertex.
Header file for the kd tree linker algo template class.
void GetBestRegionVertices(VertexScoreList &initialScoreList, pandora::VertexVector &bestRegionVertices) const
Get the list of top-N separated vertices.
MvaTypes::MvaFeatureVector MvaFeatureVector
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
std::vector< ShowerCluster > ShowerClusterList
Header file for the interaction type helper class.
T m_mvaVertex
The vertex mva.
void PopulateInitialScoreList(VertexFeatureInfoMap &vertexFeatureInfoMap, const pandora::Vertex *const pVertex, VertexScoreList &initialScoreList) const
Populate the initial vertex score list for a given vertex.
std::string m_filePathEnvironmentVariable
The environment variable providing a list of paths to mva files.
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 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...
std::string m_mvaFileName
The mva file name.
static bool Classify(const MvaInterface &classifier, TLISTS &&...featureLists)
Use the trained classifier to predict the boolean class of an example.
Vertex feature info class.
Header file for the mva vertex selection algorithm class.
float m_regionRadius
The radius for a vertex region.
void AddVertexFeaturesToVector(const VertexFeatureInfo &vertexFeatureInfo, LArMvaHelper::MvaFeatureVector &featureVector, const bool useRPhi) const
Add the vertex features to a vector in the correct order.
const pandora::Vertex * CompareVertices(const pandora::VertexVector &vertexVector, const VertexFeatureInfoMap &vertexFeatureInfoMap, const LArMvaHelper::MvaFeatureVector &eventFeatureList, const KDTreeMap &kdTreeMap, const T &t, const bool useRPhi) const
Used a binary classifier to compare a set of vertices and pick the best one.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
void CalculateRPhiScores(pandora::VertexVector &vertexVector, VertexFeatureInfoMap &vertexFeatureInfoMap, const KDTreeMap &kdTreeMap) const
Calculate the r/phi scores for the vertices in a vector, possibly erasing those that fail the fast sc...
void GetVertexScoreList(const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const
Get the vertex score list.
std::vector< SlidingFitData > SlidingFitDataList
Header file for the geometry helper class.
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.
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
void PopulateVertexFeatureInfoMap(const BeamConstants &beamConstants, const ClusterListMap &clusterListMap, const SlidingFitDataListMap &slidingFitDataListMap, const ShowerClusterListMap &showerClusterListMap, const KDTreeMap &kdTreeMap, const pandora::Vertex *const pVertex, VertexFeatureInfoMap &vertexFeatureInfoMap) const
Populate the vertex feature info map for a given vertex.
Header file for the lar monte carlo particle helper helper class.
Header file for the cluster helper class.
EventFeatureInfo CalculateEventFeatures(const pandora::ClusterList &clusterListU, const pandora::ClusterList &clusterListV, const pandora::ClusterList &clusterListW, const pandora::VertexVector &vertexVector) const
Calculate the event parameters.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
std::string m_regionMvaName
The name of the region mva to find.
TrainedVertexSelectionAlgorithm class.
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...
Header file for the file helper class.
std::vector< VertexScore > VertexScoreList
std::string m_vertexMvaName
The name of the vertex mva to find.
bool m_trainingSetMode
Whether to train.
bool m_allowClassifyDuringTraining
Whether classification is allowed during training.
void CalculateShowerClusterList(const pandora::ClusterList &inputClusterList, ShowerClusterList &showerClusterList) const
Calculate the shower cluster map for a cluster list.
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.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
bool m_legacyVariables
Whether to only use the old variables.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
T m_mvaRegion
The region mva.
std::vector< art::Ptr< recob::Vertex > > VertexVector
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
Shared vertex feature info class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
MvaVertexSelectionAlgorithm class.
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
std::map< const pandora::Vertex *const, VertexFeatureInfo > VertexFeatureInfoMap
Event feature info class.
QTextStream & endl(QTextStream &s)