9 #include "Pandora/AlgorithmHeaders.h"
38 m_filePathEnvironmentVariable(
"FW_SEARCH_PATH")
48 ClusterList clustersU, clustersV, clustersW;
49 this->GetClusterLists(m_inputClusterListNames, clustersU, clustersV, clustersW);
52 this->CalculateClusterSlidingFits(clustersU, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListU);
53 this->CalculateClusterSlidingFits(clustersV, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListV);
54 this->CalculateClusterSlidingFits(clustersW, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListW);
57 this->CalculateShowerClusterList(clustersU, showerClusterListU);
58 this->CalculateShowerClusterList(clustersV, showerClusterListV);
59 this->CalculateShowerClusterList(clustersW, showerClusterListW);
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}};
72 EventFeatureInfo eventFeatureInfo(this->CalculateEventFeatures(clustersU, clustersV, clustersW, vertexVector));
75 this->AddEventFeaturesToVector(eventFeatureInfo, eventFeatureList);
78 for (
const Vertex *
const pVertex : vertexVector)
80 this->PopulateVertexFeatureInfoMap(
81 beamConstants, clusterListMap, slidingFitDataListMap, showerClusterListMap, kdTreeMap, pVertex, vertexFeatureInfoMap);
86 for (
const Vertex *
const pVertex : vertexVector)
87 PopulateInitialScoreList(vertexFeatureInfoMap, pVertex, initialScoreList);
90 this->GetBestRegionVertices(initialScoreList, bestRegionVertices);
92 if (m_trainingSetMode)
93 this->ProduceTrainingSets(vertexVector, bestRegionVertices, vertexFeatureInfoMap, eventFeatureList, kdTreeMap);
95 if ((!m_trainingSetMode || m_allowClassifyDuringTraining) && !bestRegionVertices.empty())
98 const Vertex *
const pBestRegionVertex(
99 this->CompareVertices(bestRegionVertices, vertexFeatureInfoMap, eventFeatureList, kdTreeMap, m_mvaRegion, m_useRPhiFeatureForRegion));
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);
112 this->CalculateRPhiScores(regionalVertices, vertexFeatureInfoMap, kdTreeMap);
114 if (!regionalVertices.empty())
117 const Vertex *
const pBestVertex(
118 this->CompareVertices(regionalVertices, vertexFeatureInfoMap, eventFeatureList, kdTreeMap, m_mvaVertex,
true));
119 this->PopulateFinalVertexScoreList(vertexFeatureInfoMap, pBestVertex, vertexVector, vertexScoreList);
126 template <
typename T>
130 const Vertex *pBestVertex(vertexVector.front());
134 this->AddVertexFeaturesToVector(chosenVertexFeatureInfo, chosenFeatureList, useRPhi);
136 for (
const Vertex *
const pVertex : vertexVector)
138 if (pVertex == pBestVertex)
143 this->AddVertexFeaturesToVector(vertexFeatureInfo, featureList, useRPhi);
145 if (!m_legacyVariables)
148 float separation(0.f), axisHits(0.f);
149 this->GetSharedFeatures(pVertex, pBestVertex, kdTreeMap, separation, axisHits);
151 this->AddSharedFeaturesToVector(sharedFeatureInfo, sharedFeatureList);
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, !=,
178 XmlHelper::ReadValue(xmlHandle,
"FilePathEnvironmentVariable", m_filePathEnvironmentVariable));
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));
189 if ((!m_trainingSetMode || m_allowClassifyDuringTraining))
191 if (m_mvaFileName.empty() || m_regionMvaName.empty() || m_vertexMvaName.empty())
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;
199 m_mvaRegion.Initialize(fullMvaFileName, m_regionMvaName);
200 m_mvaVertex.Initialize(fullMvaFileName, m_vertexMvaName);
203 return STATUS_CODE_SUCCESS;
static bool Classify(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained classifier to predict the boolean class of an example.
Header file for the kd tree linker algo template class.
MvaTypes::MvaFeatureVector MvaFeatureVector
std::vector< ShowerCluster > ShowerClusterList
Header file for the interaction type helper class.
Vertex feature info class.
Header file for the mva vertex selection algorithm class.
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 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.
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
Header file for the lar monte carlo particle helper helper class.
Header file for the cluster helper class.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
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
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
static MvaFeatureVector ConcatenateFeatureLists()
Recursively concatenate vectors of features (terminating method)
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.
std::array< float, 2 > VertexVector(const recob::Vertex &vert, const geo::PlaneID &plane, const geo::GeometryCore *geo, const detinfo::DetectorPropertiesData &dprop)
BEGIN_PROLOG could also be cout
std::map< const pandora::Vertex *const, VertexFeatureInfo > VertexFeatureInfoMap
Event feature info class.