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

EnergyDepositionAsymmetryFeatureTool class. More...

#include "EnergyDepositionAsymmetryFeatureTool.h"

Inheritance diagram for lar_content::EnergyDepositionAsymmetryFeatureTool:
lar_content::GlobalAsymmetryFeatureTool lar_content::AsymmetryFeatureBaseTool lar_content::MvaFeatureTool< Ts >

Public Types

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

Public Member Functions

 EnergyDepositionAsymmetryFeatureTool ()
 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 &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...)
 

Protected Member Functions

void IncrementAsymmetryParameters (const float weight, const pandora::CartesianVector &clusterDirection, pandora::CartesianVector &localWeightedDirectionSum) const
 Increment the asymmetry parameters. More...
 

Protected Attributes

float m_maxAsymmetryDistance
 The max distance between cluster (any hit) and vertex to calculate asymmetry score. More...
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle) override
 
float CalculateAsymmetry (const bool useEnergyMetrics, const pandora::CartesianVector &vertexPosition2D, const pandora::ClusterVector &clusterVector, const pandora::CartesianVector &localWeightedDirectionSum) const override
 Calculate the energy deposition asymmetry feature. More...
 

Detailed Description

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::EnergyDepositionAsymmetryFeatureTool::EnergyDepositionAsymmetryFeatureTool ( )

Default constructor.

Definition at line 19 of file EnergyDepositionAsymmetryFeatureTool.cc.

19  :
21 {
22 }

Member Function Documentation

float lar_content::EnergyDepositionAsymmetryFeatureTool::CalculateAsymmetry ( const bool  useEnergyMetrics,
const pandora::CartesianVector &  vertexPosition2D,
const pandora::ClusterVector &  clusterVector,
const pandora::CartesianVector &  localWeightedDirectionSum 
) const
overrideprivatevirtual

Calculate the energy deposition asymmetry feature.

Parameters
useEnergyMetricswhether to use energy-based metrics instead of hit-counting-based metrics
vertexPosition2Dthe vertex position in this view
slidingFitDataListthe list of sliding fit data objects
localWeightedDirectionSumthe local event axis
Returns
the energy deposition asymmetry feature

Reimplemented from lar_content::AsymmetryFeatureBaseTool.

Definition at line 26 of file EnergyDepositionAsymmetryFeatureTool.cc.

References f, and lar_content::LArClusterHelper::SortHitsByPosition().

28 {
29  // Project every hit onto local event axis direction and record side of the projected vtx position on which it falls
30  float beforeVtxEnergy(0.f), afterVtxEnergy(0.f);
31  unsigned int beforeVtxHits(0), afterVtxHits(0);
32 
33  const CartesianVector localWeightedDirection(localWeightedDirectionSum.GetUnitVector());
34  const float evtProjectedVtxPos(vertexPosition2D.GetDotProduct(localWeightedDirection));
35 
36  float minBeforeProjectedPos(std::numeric_limits<float>::max());
37  float maxBeforeProjectedPos(-std::numeric_limits<float>::max());
38 
39  float minAfterProjectedPos(std::numeric_limits<float>::max());
40  float maxAfterProjectedPos(-std::numeric_limits<float>::max());
41 
42  for (const Cluster *const pCluster : clusterVector)
43  {
44  CaloHitList caloHitList;
45  pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
46 
47  CaloHitVector caloHitVector(caloHitList.begin(), caloHitList.end());
48  std::sort(caloHitVector.begin(), caloHitVector.end(), LArClusterHelper::SortHitsByPosition);
49 
50  for (const CaloHit *const pCaloHit : caloHitVector)
51  {
52  if (pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection) < evtProjectedVtxPos)
53  {
54  minBeforeProjectedPos = std::min(minBeforeProjectedPos, pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection));
55  maxBeforeProjectedPos = std::max(maxBeforeProjectedPos, pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection));
56 
57  beforeVtxEnergy += pCaloHit->GetElectromagneticEnergy();
58  ++beforeVtxHits;
59  }
60 
61  else
62  {
63  minAfterProjectedPos = std::min(minAfterProjectedPos, pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection));
64  maxAfterProjectedPos = std::max(maxAfterProjectedPos, pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection));
65 
66  afterVtxEnergy += pCaloHit->GetElectromagneticEnergy();
67  ++afterVtxHits;
68  }
69  }
70  }
71 
72  // Use energy metrics if possible, otherwise fall back on hit counting.
73  const unsigned int totalHits(beforeVtxHits + afterVtxHits);
74 
75  const float beforeLength(std::fabs(maxBeforeProjectedPos - minBeforeProjectedPos));
76  const float afterLength(std::fabs(maxAfterProjectedPos - minAfterProjectedPos));
77 
78  const float beforeVtxEnergyDeposition(beforeLength < std::numeric_limits<float>::epsilon() ? 0 : beforeVtxEnergy / beforeLength);
79 
80  const float afterVtxEnergyDeposition(afterLength < std::numeric_limits<float>::epsilon() ? 0 : afterVtxEnergy / afterLength);
81 
82  const float totalEnergyDeposition(beforeVtxEnergyDeposition + afterVtxEnergyDeposition);
83 
84  if (useEnergyMetrics && totalEnergyDeposition > std::numeric_limits<float>::epsilon())
85  return std::fabs((afterVtxEnergyDeposition - beforeVtxEnergyDeposition)) / totalEnergyDeposition;
86 
87  if (0 == totalHits)
88  throw StatusCodeException(STATUS_CODE_FAILURE);
89 
90  const float beforeVtxHitDeposition(beforeLength < std::numeric_limits<float>::epsilon() ? 0 : beforeVtxHits / beforeLength);
91 
92  const float afterVtxHitDeposition(afterLength < std::numeric_limits<float>::epsilon() ? 0 : afterVtxHits / afterLength);
93 
94  const float totalHitDeposition(beforeVtxHitDeposition + afterVtxHitDeposition);
95 
96  if (totalHitDeposition > std::numeric_limits<float>::epsilon())
97  return std::fabs((afterVtxHitDeposition - beforeVtxHitDeposition)) / totalHitDeposition;
98 
99  return 0.f;
100 }
TFile f
Definition: plotHisto.C:6
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
void lar_content::AsymmetryFeatureBaseTool::IncrementAsymmetryParameters ( const float  weight,
const pandora::CartesianVector &  clusterDirection,
pandora::CartesianVector &  localWeightedDirectionSum 
) const
protectedinherited

Increment the asymmetry parameters.

Parameters
weightthe weight to assign to this vector
clusterDirectionthe direction of the cluster
localWeightedDirectionSumthe current energy-weighted local cluster direction vector

Definition at line 53 of file AsymmetryFeatureBaseTool.cc.

References f, and weight.

Referenced by lar_content::LocalAsymmetryFeatureTool::GetAsymmetryForView(), and lar_content::GlobalAsymmetryFeatureTool::GetAsymmetryForView().

55 {
56  // If the new axis direction is at an angle of greater than 90 deg to the current axis direction, flip it 180 degs.
57  CartesianVector newDirection(clusterDirection);
58 
59  if (localWeightedDirectionSum.GetMagnitudeSquared() > std::numeric_limits<float>::epsilon())
60  {
61  if (localWeightedDirectionSum.GetCosOpeningAngle(clusterDirection) < 0.f)
62  newDirection *= -1.f;
63  }
64 
65  localWeightedDirectionSum += newDirection * weight;
66 }
TFile f
Definition: plotHisto.C:6
double weight
Definition: plottest35.C:25
StatusCode lar_content::EnergyDepositionAsymmetryFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
overrideprivate

Definition at line 104 of file EnergyDepositionAsymmetryFeatureTool.cc.

References lar_content::GlobalAsymmetryFeatureTool::ReadSettings().

105 {
107 }
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle) override
void lar_content::AsymmetryFeatureBaseTool::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 showerClusterListMap,
const float  ,
float &   
)
inherited

Run the tool.

Parameters
pAlgorithmaddress of the calling algorithm
pVertexaddress of the vertex
slidingFitDataListMapmap of the sliding fit data lists
showerClusterListMapmap of the shower cluster lists
Returns
the asymmetry feature

Definition at line 26 of file AsymmetryFeatureBaseTool.cc.

References f, lar_content::AsymmetryFeatureBaseTool::GetAsymmetryForView(), and lar_content::LArGeometryHelper::ProjectPosition().

30 {
31  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
32  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
33 
34  float asymmetry(0.f);
35 
36  asymmetry += this->GetAsymmetryForView(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_U),
37  slidingFitDataListMap.at(TPC_VIEW_U),
38  showerClusterListMap.empty() ? VertexSelectionBaseAlgorithm::ShowerClusterList() : showerClusterListMap.at(TPC_VIEW_U));
39 
40  asymmetry += this->GetAsymmetryForView(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_V),
41  slidingFitDataListMap.at(TPC_VIEW_V),
42  showerClusterListMap.empty() ? VertexSelectionBaseAlgorithm::ShowerClusterList() : showerClusterListMap.at(TPC_VIEW_V));
43 
44  asymmetry += this->GetAsymmetryForView(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_W),
45  slidingFitDataListMap.at(TPC_VIEW_W),
46  showerClusterListMap.empty() ? VertexSelectionBaseAlgorithm::ShowerClusterList() : showerClusterListMap.at(TPC_VIEW_W));
47 
48  featureVector.push_back(asymmetry);
49 }
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
virtual float GetAsymmetryForView(const pandora::CartesianVector &vertexPosition2D, const VertexSelectionBaseAlgorithm::SlidingFitDataList &slidingFitDataList, const VertexSelectionBaseAlgorithm::ShowerClusterList &showerClusterList) const =0
Get the asymmetry feature for a given view.
TFile f
Definition: plotHisto.C:6
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::AsymmetryFeatureBaseTool::m_maxAsymmetryDistance
protectedinherited

The max distance between cluster (any hit) and vertex to calculate asymmetry score.

Definition at line 81 of file AsymmetryFeatureBaseTool.h.

Referenced by lar_content::LocalAsymmetryFeatureTool::GetAsymmetryForView(), lar_content::GlobalAsymmetryFeatureTool::GetAsymmetryForView(), and lar_content::AsymmetryFeatureBaseTool::ReadSettings().


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