LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
EnergyKickVertexSelectionAlgorithm.cc
Go to the documentation of this file.
1 
8 #include "Pandora/AlgorithmHeaders.h"
9 
11 
14 
16 
17 using namespace pandora;
18 
19 namespace lar_content
20 {
21 
22 EnergyKickVertexSelectionAlgorithm::EnergyKickVertexSelectionAlgorithm() :
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{{TPC_VIEW_U, slidingFitDataListU},
45  {TPC_VIEW_V, slidingFitDataListV},
46  {TPC_VIEW_W, slidingFitDataListW}};
47 
48  float bestFastScore(0.f); // not actually used - artefact of toolizing RPhi score and still using performance trick
49  for (const Vertex *const pVertex : vertexVector)
50  {
51  const float beamDeweightingScore(this->IsBeamModeOn() ? this->GetBeamDeweightingScore(beamConstants, pVertex) : 0.f);
52 
53  const float energyKick(LArMvaHelper::CalculateFeaturesOfType<EnergyKickFeatureTool>(m_featureToolVector, this, pVertex, slidingFitDataListMap,
54  ClusterListMap(), KDTreeMap(), ShowerClusterListMap(), beamDeweightingScore, bestFastScore).at(0).Get());
55 
56  const float energyAsymmetry(LArMvaHelper::CalculateFeaturesOfType<LocalAsymmetryFeatureTool>(m_featureToolVector, this, pVertex, slidingFitDataListMap,
57  ClusterListMap(), KDTreeMap(), ShowerClusterListMap(), beamDeweightingScore, bestFastScore).at(0).Get());
58 
59  const float energyKickScore(-energyKick / m_epsilon);
60  const float energyAsymmetryScore(energyAsymmetry / m_asymmetryConstant);
61 
62  vertexScoreList.push_back(VertexScore(pVertex, beamDeweightingScore + energyKickScore + energyAsymmetryScore));
63  }
64 }
65 
66 //------------------------------------------------------------------------------------------------------------------------------------------
67 //------------------------------------------------------------------------------------------------------------------------------------------
68 
69 StatusCode EnergyKickVertexSelectionAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
70 {
71  AlgorithmToolVector algorithmToolVector;
72  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "FeatureTools", algorithmToolVector));
73 
74  for (AlgorithmTool *const pAlgorithmTool : algorithmToolVector)
75  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, LArMvaHelper::AddFeatureToolToVector(pAlgorithmTool, m_featureToolVector));
76 
77  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadVectorOfValues(xmlHandle,
78  "InputClusterListNames", m_inputClusterListNames));
79 
80  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
81  "MinClusterCaloHits", m_minClusterCaloHits));
82 
83  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
84  "SlidingFitWindow", m_slidingFitWindow));
85 
86  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
87  "Epsilon", m_epsilon));
88 
89  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
90  "AsymmetryConstant", m_asymmetryConstant));
91 
92  if ((m_epsilon < std::numeric_limits<float>::epsilon()) || (m_asymmetryConstant < std::numeric_limits<float>::epsilon()))
93  {
94  std::cout << "EnergyKickVertexSelection: Invalid parameter(s), Epsilon " << m_epsilon << ", AsymmetryConstant " << m_asymmetryConstant << std::endl;
95  return STATUS_CODE_INVALID_PARAMETER;
96  }
97 
99 }
100 
101 } // namespace lar_content
pandora::StringVector m_inputClusterListNames
The list of cluster list names.
void GetClusterLists(const pandora::StringVector &inputClusterListNames, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW) const
Get the cluster lists.
Class that implements the KDTree partition of 2D space and a closest point search algorithm...
void CalculateClusterSlidingFits(const pandora::ClusterList &inputClusterList, const unsigned int minClusterCaloHits, const unsigned int slidingFitWindow, SlidingFitDataList &slidingFitDataList) const
Calculate the cluster sliding fits.
unsigned int m_minClusterCaloHits
The min number of hits parameter in the energy score.
bool IsBeamModeOn() const
Whether algorithm is running in beam mode, assuming neutrinos travel in positive z-direction.
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
TFile f
Definition: plotHisto.C:6
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
Header file for the energy kick vertex selection algorithm class.
float m_epsilon
The epsilon parameter in the energy score.
VertexFeatureTool::FeatureToolVector m_featureToolVector
The feature tool map.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
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
Header file for the local asymmetry feature tool class.
float m_asymmetryConstant
The asymmetry constant parameter in the energy score.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
float GetBeamDeweightingScore(const BeamConstants &beamConstants, const pandora::Vertex *const pVertex) const
Get the beam deweighting score for a vertex.
Header file for the energy kick feature tool class.
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 for a provided list of candidate vertices.
std::vector< art::Ptr< recob::Vertex > > VertexVector
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)