9 #include "Pandora/AlgorithmHeaders.h" 20 EnergyKickFeatureTool::EnergyKickFeatureTool() :
33 if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
34 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() << std::endl;
36 float energyKick(0.
f);
47 featureVector.push_back(energyKick);
55 unsigned int totHits(0);
57 float totEnergy(0.
f), totEnergyKick(0.
f), totHitKick(0.
f);
61 const Cluster *
const pCluster(slidingFitData.GetCluster());
63 if (pCluster->GetElectromagneticEnergy() < std::numeric_limits<float>::epsilon())
66 const CartesianVector vertexToMinLayer(slidingFitData.GetMinLayerPosition() - vertexPosition2D);
67 const CartesianVector vertexToMaxLayer(slidingFitData.GetMaxLayerPosition() - vertexPosition2D);
69 const bool minLayerClosest(vertexToMinLayer.GetMagnitudeSquared() < vertexToMaxLayer.GetMagnitudeSquared());
70 const CartesianVector &clusterDisplacement((minLayerClosest) ? vertexToMinLayer : vertexToMaxLayer);
71 const CartesianVector &clusterDirection((minLayerClosest) ? slidingFitData.GetMinLayerDirection() : slidingFitData.GetMaxLayerDirection());
76 float energyKick(0.
f);
77 if (useEnergy && totEnergy > std::numeric_limits<float>::epsilon())
78 energyKick = totEnergyKick / totEnergy;
80 else if (!useEnergy && totHits > 0)
81 energyKick = totHitKick /
static_cast<float>(totHits);
89 const CartesianVector &clusterDirection,
float &totEnergyKick,
float &totEnergy,
float &totHitKick,
unsigned int &totHits)
const 91 const float impactParameter(clusterDisplacement.GetCrossProduct(clusterDirection).GetMagnitude());
92 const float displacement(clusterDisplacement.GetMagnitude());
94 totEnergyKick += pCluster->GetElectromagneticEnergy() * (impactParameter +
m_xOffset) / (displacement +
m_rOffset);
95 totEnergy += pCluster->GetElectromagneticEnergy();
97 totHitKick +=
static_cast<float>(pCluster->GetNCaloHits()) * (impactParameter +
m_xOffset) / (displacement +
m_rOffset);
98 totHits += pCluster->GetNCaloHits();
105 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"ROffset",
m_rOffset));
107 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"XOffset",
m_xOffset));
109 return STATUS_CODE_SUCCESS;
MvaTypes::MvaFeatureVector MvaFeatureVector
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.
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.
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
float m_xOffset
The x offset parameter in the energy score.
float m_rOffset
The r offset parameter in the energy score.
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.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
VertexSelectionBaseAlgorithm class.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float GetEnergyKickForView(const pandora::CartesianVector &vertexPosition2D, const VertexSelectionBaseAlgorithm::SlidingFitDataList &slidingFitDataList) const
Get the energy kick feature for a given view.
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.