Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
EnergyKickFeatureTool.cc
Go to the documentation of this file.
1
10
12
14
15using namespace pandora;
16
17namespace lar_content
18{
19
20EnergyKickFeatureTool::EnergyKickFeatureTool() : m_rOffset(10.f), m_xOffset(0.06f)
21{
22}
23
24//------------------------------------------------------------------------------------------------------------------------------------------
25
27 const Vertex *const pVertex, const VertexSelectionBaseAlgorithm::SlidingFitDataListMap &slidingFitDataListMap,
29 const VertexSelectionBaseAlgorithm::ShowerClusterListMap &, const float, float &)
30{
32 std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
33
34 float energyKick(0.f);
35
36 energyKick += this->GetEnergyKickForView(
37 LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_U), slidingFitDataListMap.at(TPC_VIEW_U));
38
39 energyKick += this->GetEnergyKickForView(
40 LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_V), slidingFitDataListMap.at(TPC_VIEW_V));
41
42 energyKick += this->GetEnergyKickForView(
43 LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_W), slidingFitDataListMap.at(TPC_VIEW_W));
44
45 featureVector.push_back(energyKick);
46}
47
48//------------------------------------------------------------------------------------------------------------------------------------------
49
51 const CartesianVector &vertexPosition2D, const VertexSelectionBaseAlgorithm::SlidingFitDataList &slidingFitDataList) const
52{
53 unsigned int totHits(0);
54 bool useEnergy(true);
55 float totEnergy(0.f), totEnergyKick(0.f), totHitKick(0.f);
56
57 for (const VertexSelectionBaseAlgorithm::SlidingFitData &slidingFitData : slidingFitDataList)
58 {
59 const Cluster *const pCluster(slidingFitData.GetCluster());
60
61 if (pCluster->GetElectromagneticEnergy() < std::numeric_limits<float>::epsilon())
62 useEnergy = false;
63
64 const CartesianVector vertexToMinLayer(slidingFitData.GetMinLayerPosition() - vertexPosition2D);
65 const CartesianVector vertexToMaxLayer(slidingFitData.GetMaxLayerPosition() - vertexPosition2D);
66
67 const bool minLayerClosest(vertexToMinLayer.GetMagnitudeSquared() < vertexToMaxLayer.GetMagnitudeSquared());
68 const CartesianVector &clusterDisplacement((minLayerClosest) ? vertexToMinLayer : vertexToMaxLayer);
69 const CartesianVector &clusterDirection((minLayerClosest) ? slidingFitData.GetMinLayerDirection() : slidingFitData.GetMaxLayerDirection());
70
71 this->IncrementEnergyKickParameters(pCluster, clusterDisplacement, clusterDirection, totEnergyKick, totEnergy, totHitKick, totHits);
72 }
73
74 float energyKick(0.f);
75 if (useEnergy && totEnergy > std::numeric_limits<float>::epsilon())
76 energyKick = totEnergyKick / totEnergy;
77
78 else if (!useEnergy && totHits > 0)
79 energyKick = totHitKick / static_cast<float>(totHits);
80
81 return energyKick;
82}
83
84//------------------------------------------------------------------------------------------------------------------------------------------
85
86void EnergyKickFeatureTool::IncrementEnergyKickParameters(const Cluster *const pCluster, const CartesianVector &clusterDisplacement,
87 const CartesianVector &clusterDirection, float &totEnergyKick, float &totEnergy, float &totHitKick, unsigned int &totHits) const
88{
89 const float impactParameter(clusterDisplacement.GetCrossProduct(clusterDirection).GetMagnitude());
90 const float displacement(clusterDisplacement.GetMagnitude());
91
92 totEnergyKick += pCluster->GetElectromagneticEnergy() * (impactParameter + m_xOffset) / (displacement + m_rOffset);
93 totEnergy += pCluster->GetElectromagneticEnergy();
94
95 totHitKick += static_cast<float>(pCluster->GetNCaloHits()) * (impactParameter + m_xOffset) / (displacement + m_rOffset);
96 totHits += pCluster->GetNCaloHits();
97}
98
99//------------------------------------------------------------------------------------------------------------------------------------------
100
102{
103 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ROffset", m_rOffset));
104
105 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "XOffset", m_xOffset));
106
107 return STATUS_CODE_SUCCESS;
108}
109
110} // 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 geometry helper class.
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
Definition StatusCodes.h:31
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
float m_xOffset
The x offset parameter in the energy score.
float GetEnergyKickForView(const pandora::CartesianVector &vertexPosition2D, const VertexSelectionBaseAlgorithm::SlidingFitDataList &slidingFitDataList) const
Get the energy kick feature for a given view.
void Run(LArMvaHelper::MvaFeatureVector &featureVector, const VertexSelectionBaseAlgorithm *const pAlgorithm, const pandora::Vertex *const pVertex, const VertexSelectionBaseAlgorithm::SlidingFitDataListMap &slidingFitDataListMap, const VertexSelectionBaseAlgorithm::ClusterListMap &, const VertexSelectionBaseAlgorithm::KDTreeMap &, const VertexSelectionBaseAlgorithm::ShowerClusterListMap &, const float, float &)
Run the tool.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
void IncrementEnergyKickParameters(const pandora::Cluster *const pCluster, const pandora::CartesianVector &clusterDisplacement, const pandora::CartesianVector &clusterDirection, float &totEnergyKick, float &totEnergy, float &totHitKick, unsigned int &totHits) const
Increment the energy kick parameters for a given cluster.
float m_rOffset
The r offset parameter in the energy score.
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
MvaTypes::MvaFeatureVector MvaFeatureVector
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.
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
CartesianVector class.
float GetMagnitudeSquared() const
Get the magnitude squared.
float GetMagnitude() const
Get the magnitude.
CartesianVector GetCrossProduct(const CartesianVector &rhs) const
Get the cross product of the cartesian vector with a second cartesian vector.
Cluster class.
Definition Cluster.h:31
unsigned int GetNCaloHits() const
Get the number of calo hits in the cluster.
Definition Cluster.h:484
float GetElectromagneticEnergy() const
Get the sum of electromagnetic energy measures of all constituent calo hits, units GeV.
Definition Cluster.h:519
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
const std::string & GetType() const
Get the type.
Definition Process.h:102
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
const std::string & GetInstanceName() const
Get the instance name.
Definition Process.h:109
Vertex class.
Definition Vertex.h:26
const CartesianVector & GetPosition() const
Get the vertex position.
Definition Vertex.h:103
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
Definition XmlHelper.h:136
StatusCode
The StatusCode enum.