Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
EnergyKickVertexSelectionAlgorithm.cc
Go to the documentation of this file.
1
9
11
14
16
17using namespace pandora;
18
19namespace lar_content
20{
21
23 m_minClusterCaloHits(12),
24 m_slidingFitWindow(100),
25 m_epsilon(0.06),
26 m_asymmetryConstant(3.f)
27{
28}
29
30//------------------------------------------------------------------------------------------------------------------------------------------
31
33 HitKDTree2D & /*kdTreeU*/, HitKDTree2D & /*kdTreeV*/, HitKDTree2D & /*kdTreeW*/, VertexScoreList &vertexScoreList) const
34{
35 ClusterList clustersU, clustersV, clustersW;
36 this->GetClusterLists(m_inputClusterListNames, clustersU, clustersV, clustersW);
37
38 SlidingFitDataList slidingFitDataListU, slidingFitDataListV, slidingFitDataListW;
39 this->CalculateClusterSlidingFits(clustersU, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListU);
40 this->CalculateClusterSlidingFits(clustersV, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListV);
41 this->CalculateClusterSlidingFits(clustersW, m_minClusterCaloHits, m_slidingFitWindow, slidingFitDataListW);
42
43 // Create maps from hit types to objects for passing to feature tools
44 const SlidingFitDataListMap slidingFitDataListMap{
45 {TPC_VIEW_U, slidingFitDataListU}, {TPC_VIEW_V, slidingFitDataListV}, {TPC_VIEW_W, slidingFitDataListW}};
46
47 float bestFastScore(0.f); // not actually used - artefact of toolizing RPhi score and still using performance trick
48 for (const Vertex *const pVertex : vertexVector)
49 {
50 const float beamDeweightingScore(this->IsBeamModeOn() ? this->GetBeamDeweightingScore(beamConstants, pVertex) : 0.f);
51
52 const float energyKick(LArMvaHelper::CalculateFeaturesOfType<EnergyKickFeatureTool>(m_featureToolVector, this, pVertex,
53 slidingFitDataListMap, ClusterListMap(), KDTreeMap(), ShowerClusterListMap(), beamDeweightingScore, bestFastScore)
54 .at(0)
55 .Get());
56
57 const float energyAsymmetry(LArMvaHelper::CalculateFeaturesOfType<LocalAsymmetryFeatureTool>(m_featureToolVector, this, pVertex,
58 slidingFitDataListMap, ClusterListMap(), KDTreeMap(), ShowerClusterListMap(), beamDeweightingScore, bestFastScore)
59 .at(0)
60 .Get());
61
62 const float energyKickScore(-energyKick / m_epsilon);
63 const float energyAsymmetryScore(energyAsymmetry / m_asymmetryConstant);
64
65 vertexScoreList.push_back(VertexScore(pVertex, beamDeweightingScore + energyKickScore + energyAsymmetryScore));
66 }
67}
68
69//------------------------------------------------------------------------------------------------------------------------------------------
70//------------------------------------------------------------------------------------------------------------------------------------------
71
73{
74 AlgorithmToolVector algorithmToolVector;
75 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "FeatureTools", algorithmToolVector));
76
77 for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
79
80 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "InputClusterListNames", m_inputClusterListNames));
81
83 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterCaloHits", m_minClusterCaloHits));
84
86 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
87
88 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Epsilon", m_epsilon));
89
91 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "AsymmetryConstant", m_asymmetryConstant));
92
93 if ((m_epsilon < std::numeric_limits<float>::epsilon()) || (m_asymmetryConstant < std::numeric_limits<float>::epsilon()))
94 {
95 std::cout << "EnergyKickVertexSelection: Invalid parameter(s), Epsilon " << m_epsilon << ", AsymmetryConstant "
96 << m_asymmetryConstant << std::endl;
97 return STATUS_CODE_INVALID_PARAMETER;
98 }
99
101}
102
103} // namespace lar_content
Grouping of header files for many classes of use in particle flow algorithms.
Header file for the energy kick feature tool class.
Header file for the energy kick vertex selection algorithm class.
Header file for the local asymmetry feature tool class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:19
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
float m_epsilon
The epsilon parameter in the energy score.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
float m_asymmetryConstant
The asymmetry constant parameter in the energy score.
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool map.
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
void GetVertexScoreList(const pandora::VertexVector &vertexVector, const BeamConstants &beamConstants, HitKDTree2D &kdTreeU, HitKDTree2D &kdTreeV, HitKDTree2D &kdTreeW, VertexScoreList &vertexScoreList) const
Get the vertex score list for a provided list of candidate vertices.
static pandora::StatusCode AddFeatureToolToVector(pandora::AlgorithmTool *const pFeatureTool, MvaFeatureToolVector< Ts... > &featureToolVector)
Add a feature tool to a vector of feature tools.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
float GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
Get the beam deweighting score for a vertex.
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.
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
bool IsBeamModeOn() const
Whether algorithm is running in beam mode, assuming neutrinos travel in positive z-direction.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
AlgorithmTool class. Algorithm tools will tend to be tailored for specific parent algorithms,...
Vertex class.
Definition Vertex.h:26
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
Definition XmlHelper.h:229
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
static StatusCode ProcessAlgorithmToolList(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &listName, AlgorithmToolVector &algorithmToolVector)
Process a list of algorithms tools in an xml file.
Definition XmlHelper.cc:101
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< AlgorithmTool * > AlgorithmToolVector
StatusCode
The StatusCode enum.
std::vector< const Vertex * > VertexVector