LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::EnergyKickFeatureTool Class Referenceabstract

EnergyKickFeatureTool class. More...

#include "EnergyKickFeatureTool.h"

Inheritance diagram for lar_content::EnergyKickFeatureTool:
lar_content::MvaFeatureTool< Ts >

Public Types

typedef std::vector< MvaFeatureTool< Ts... > * > FeatureToolVector
 
typedef std::map< std::string, MvaFeatureTool< Ts... > * > FeatureToolMap
 

Public Member Functions

 EnergyKickFeatureTool ()
 Default constructor. More...
 
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. More...
 
virtual void Run (MvaTypes::MvaFeatureVector &featureVector, Ts...args)=0
 Run the algorithm tool. More...
 
virtual void Run (MvaTypes::MvaFeatureMap &featureMap, pandora::StringVector &featureOrder, const std::string &featureToolName, Ts...)
 

Private Member Functions

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. More...
 
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. More...
 

Private Attributes

float m_rOffset
 The r offset parameter in the energy score. More...
 
float m_xOffset
 The x offset parameter in the energy score. More...
 

Detailed Description

EnergyKickFeatureTool class.

Definition at line 19 of file EnergyKickFeatureTool.h.

Member Typedef Documentation

template<typename... Ts>
typedef std::map<std::string, MvaFeatureTool<Ts...> *> lar_content::MvaFeatureTool< Ts >::FeatureToolMap
inherited

Definition at line 37 of file LArMvaHelper.h.

template<typename... Ts>
typedef std::vector<MvaFeatureTool<Ts...> *> lar_content::MvaFeatureTool< Ts >::FeatureToolVector
inherited

Definition at line 36 of file LArMvaHelper.h.

Constructor & Destructor Documentation

lar_content::EnergyKickFeatureTool::EnergyKickFeatureTool ( )

Default constructor.

Definition at line 20 of file EnergyKickFeatureTool.cc.

20  :
21  m_rOffset(10.f),
22  m_xOffset(0.06f)
23 {
24 }
float m_xOffset
The x offset parameter in the energy score.
float m_rOffset
The r offset parameter in the energy score.
TFile f
Definition: plotHisto.C:6

Member Function Documentation

float lar_content::EnergyKickFeatureTool::GetEnergyKickForView ( const pandora::CartesianVector &  vertexPosition2D,
const VertexSelectionBaseAlgorithm::SlidingFitDataList slidingFitDataList 
) const
private

Get the energy kick feature for a given view.

Parameters
vertexPosition2Dthe projection of the vertex position in this view
slidingFitDataListthe list of sliding fit data objects in this view
Returns
the energy kick feature

Definition at line 52 of file EnergyKickFeatureTool.cc.

References f, and IncrementEnergyKickParameters().

Referenced by Run().

54 {
55  unsigned int totHits(0);
56  bool useEnergy(true);
57  float totEnergy(0.f), totEnergyKick(0.f), totHitKick(0.f);
58 
59  for (const VertexSelectionBaseAlgorithm::SlidingFitData &slidingFitData : slidingFitDataList)
60  {
61  const Cluster *const pCluster(slidingFitData.GetCluster());
62 
63  if (pCluster->GetElectromagneticEnergy() < std::numeric_limits<float>::epsilon())
64  useEnergy = false;
65 
66  const CartesianVector vertexToMinLayer(slidingFitData.GetMinLayerPosition() - vertexPosition2D);
67  const CartesianVector vertexToMaxLayer(slidingFitData.GetMaxLayerPosition() - vertexPosition2D);
68 
69  const bool minLayerClosest(vertexToMinLayer.GetMagnitudeSquared() < vertexToMaxLayer.GetMagnitudeSquared());
70  const CartesianVector &clusterDisplacement((minLayerClosest) ? vertexToMinLayer : vertexToMaxLayer);
71  const CartesianVector &clusterDirection((minLayerClosest) ? slidingFitData.GetMinLayerDirection() : slidingFitData.GetMaxLayerDirection());
72 
73  this->IncrementEnergyKickParameters(pCluster, clusterDisplacement, clusterDirection, totEnergyKick, totEnergy, totHitKick, totHits);
74  }
75 
76  float energyKick(0.f);
77  if (useEnergy && totEnergy > std::numeric_limits<float>::epsilon())
78  energyKick = totEnergyKick / totEnergy;
79 
80  else if (!useEnergy && totHits > 0)
81  energyKick = totHitKick / static_cast<float>(totHits);
82 
83  return energyKick;
84 }
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.
TFile f
Definition: plotHisto.C:6
void lar_content::EnergyKickFeatureTool::IncrementEnergyKickParameters ( const pandora::Cluster *const  pCluster,
const pandora::CartesianVector &  clusterDisplacement,
const pandora::CartesianVector &  clusterDirection,
float &  totEnergyKick,
float &  totEnergy,
float &  totHitKick,
unsigned int &  totHits 
) const
private

Increment the energy kick parameters for a given cluster.

Parameters
pClusteraddress of the cluster
clusterDisplacementthe cluster displacement
clusterDirectionthe cluster direction
totEnergyKickthe total energy kick
totEnergythe total energy
totHitKickthe total hit kick
totHitsthe total number of hits

Definition at line 88 of file EnergyKickFeatureTool.cc.

References m_rOffset, and m_xOffset.

Referenced by GetEnergyKickForView().

90 {
91  const float impactParameter(clusterDisplacement.GetCrossProduct(clusterDirection).GetMagnitude());
92  const float displacement(clusterDisplacement.GetMagnitude());
93 
94  totEnergyKick += pCluster->GetElectromagneticEnergy() * (impactParameter + m_xOffset) / (displacement + m_rOffset);
95  totEnergy += pCluster->GetElectromagneticEnergy();
96 
97  totHitKick += static_cast<float>(pCluster->GetNCaloHits()) * (impactParameter + m_xOffset) / (displacement + m_rOffset);
98  totHits += pCluster->GetNCaloHits();
99 }
float m_xOffset
The x offset parameter in the energy score.
float m_rOffset
The r offset parameter in the energy score.
StatusCode lar_content::EnergyKickFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 103 of file EnergyKickFeatureTool.cc.

References m_rOffset, and m_xOffset.

104 {
105  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ROffset", m_rOffset));
106 
107  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "XOffset", m_xOffset));
108 
109  return STATUS_CODE_SUCCESS;
110 }
float m_xOffset
The x offset parameter in the energy score.
float m_rOffset
The r offset parameter in the energy score.
void lar_content::EnergyKickFeatureTool::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.

Parameters
pAlgorithmaddress of the calling algorithm
pVertexaddress of the vertex
slidingFitDataListMapmap of the sliding fit data lists
Returns
the energy kick feature

Definition at line 28 of file EnergyKickFeatureTool.cc.

References f, GetEnergyKickForView(), and lar_content::LArGeometryHelper::ProjectPosition().

32 {
33  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
34  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
35 
36  float energyKick(0.f);
37 
38  energyKick += this->GetEnergyKickForView(
39  LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_U), slidingFitDataListMap.at(TPC_VIEW_U));
40 
41  energyKick += this->GetEnergyKickForView(
42  LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_V), slidingFitDataListMap.at(TPC_VIEW_V));
43 
44  energyKick += this->GetEnergyKickForView(
45  LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_W), slidingFitDataListMap.at(TPC_VIEW_W));
46 
47  featureVector.push_back(energyKick);
48 }
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
TFile f
Definition: plotHisto.C:6
float GetEnergyKickForView(const pandora::CartesianVector &vertexPosition2D, const VertexSelectionBaseAlgorithm::SlidingFitDataList &slidingFitDataList) const
Get the energy kick feature for a given view.
template<typename... Ts>
virtual void lar_content::MvaFeatureTool< Ts >::Run ( MvaTypes::MvaFeatureVector featureVector,
Ts...  args 
)
pure virtualinherited

Run the algorithm tool.

Parameters
featureVectorthe vector of features to append
argsarguments to pass to the tool
template<typename... Ts>
virtual void lar_content::MvaFeatureTool< Ts >::Run ( MvaTypes::MvaFeatureMap featureMap,
pandora::StringVector &  featureOrder,
const std::string &  featureToolName,
Ts...   
)
inlinevirtualinherited

Definition at line 51 of file LArMvaHelper.h.

52  {
53  (void)featureMap;
54  (void)featureOrder;
55  (void)featureToolName;
56  return;
57  };

Member Data Documentation

float lar_content::EnergyKickFeatureTool::m_rOffset
private

The r offset parameter in the energy score.

Definition at line 68 of file EnergyKickFeatureTool.h.

Referenced by IncrementEnergyKickParameters(), and ReadSettings().

float lar_content::EnergyKickFeatureTool::m_xOffset
private

The x offset parameter in the energy score.

Definition at line 69 of file EnergyKickFeatureTool.h.

Referenced by IncrementEnergyKickParameters(), and ReadSettings().


The documentation for this class was generated from the following files: