LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::ShowerAsymmetryFeatureTool Class Referenceabstract

ShowerAsymmetryFeatureTool class. More...

#include "ShowerAsymmetryFeatureTool.h"

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

Public Types

typedef std::vector< MvaFeatureTool< Ts... > * > FeatureToolVector
 

Public Member Functions

 ShowerAsymmetryFeatureTool ()
 Default constructor. More...
 
void Run (LArMvaHelper::MvaFeatureVector &featureVector, const VertexSelectionBaseAlgorithm *const pAlgorithm, const pandora::Vertex *const pVertex, const VertexSelectionBaseAlgorithm::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...
 

Private Member Functions

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
float GetShowerAsymmetryForView (const pandora::CartesianVector &vertexPosition2D, const VertexSelectionBaseAlgorithm::ShowerClusterList &showerClusterList) const
 Get the shower asymmetry feature for a given view. More...
 
bool ShouldUseShowerCluster (const pandora::CartesianVector &vertexPosition, const VertexSelectionBaseAlgorithm::ShowerCluster &showerCluster) const
 Get whether we should use a given shower cluster for asymmetry calculation. More...
 
void CalculateAsymmetryParameters (const VertexSelectionBaseAlgorithm::ShowerCluster &showerCluster, const float projectedVtxPosition, const pandora::CartesianVector &showerDirection, float &beforeVtxEnergy, float &afterVtxEnergy) const
 Calculate the parameters for the asymmetry calculation. More...
 

Private Attributes

float m_vertexClusterDistance
 The distance around the vertex to look for shower clusters. More...
 

Detailed Description

ShowerAsymmetryFeatureTool class.

Definition at line 21 of file ShowerAsymmetryFeatureTool.h.

Member Typedef Documentation

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

Definition at line 30 of file LArMvaHelper.h.

Constructor & Destructor Documentation

lar_content::ShowerAsymmetryFeatureTool::ShowerAsymmetryFeatureTool ( )

Default constructor.

Definition at line 19 of file ShowerAsymmetryFeatureTool.cc.

19  :
21 {
22 }
TFile f
Definition: plotHisto.C:6
float m_vertexClusterDistance
The distance around the vertex to look for shower clusters.

Member Function Documentation

void lar_content::ShowerAsymmetryFeatureTool::CalculateAsymmetryParameters ( const VertexSelectionBaseAlgorithm::ShowerCluster showerCluster,
const float  projectedVtxPosition,
const pandora::CartesianVector &  showerDirection,
float &  beforeVtxEnergy,
float &  afterVtxEnergy 
) const
private

Calculate the parameters for the asymmetry calculation.

Parameters
showerClusterthe shower cluster
projectedVtxPositionthe projected vertex position
showerDirectionthe direction of the shower axis
beforeVtxEnergythe shower energy before the vertex position
afterVtxEnergythe shower energy after the vertex position

Definition at line 97 of file ShowerAsymmetryFeatureTool.cc.

References lar_content::VertexSelectionBaseAlgorithm::ShowerCluster::GetClusters(), and lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by GetShowerAsymmetryForView().

99 {
100  beforeVtxEnergy = 0.f;
101  afterVtxEnergy = 0.f;
102 
103  for (const Cluster * const pCluster : showerCluster.GetClusters())
104  {
105  CaloHitList caloHitList;
106  pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
107 
108  CaloHitVector caloHitVector(caloHitList.begin(), caloHitList.end());
109  std::sort(caloHitVector.begin(), caloHitVector.end(), LArClusterHelper::SortHitsByPosition);
110 
111  for (const CaloHit *const pCaloHit : caloHitVector)
112  {
113  if (pCaloHit->GetPositionVector().GetDotProduct(showerDirection) < projectedVtxPosition)
114  beforeVtxEnergy += pCaloHit->GetElectromagneticEnergy();
115 
116  else if (pCaloHit->GetPositionVector().GetDotProduct(showerDirection) > projectedVtxPosition)
117  afterVtxEnergy += pCaloHit->GetElectromagneticEnergy();
118  }
119  }
120 }
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)
float lar_content::ShowerAsymmetryFeatureTool::GetShowerAsymmetryForView ( const pandora::CartesianVector &  vertexPosition2D,
const VertexSelectionBaseAlgorithm::ShowerClusterList showerClusterList 
) const
private

Get the shower asymmetry feature for a given view.

Parameters
vertexPosition2Dthe projected vertex position
showerClusterListthe list of shower clusters in this view
Returns
the shower asymmetry feature

Definition at line 49 of file ShowerAsymmetryFeatureTool.cc.

References CalculateAsymmetryParameters(), f, lar_content::TwoDSlidingFitResult::GetGlobalFitDirection(), lar_content::TwoDSlidingFitResult::GetLocalPosition(), and ShouldUseShowerCluster().

Referenced by Run().

51 {
52  float showerAsymmetry(1.f);
53 
54  for (const VertexSelectionBaseAlgorithm::ShowerCluster &showerCluster : showerClusterList)
55  {
56  if (this->ShouldUseShowerCluster(vertexPosition2D, showerCluster))
57  {
58  const TwoDSlidingFitResult &showerFit = showerCluster.GetFit();
59 
60  float rL(0.f), rT(0.f);
61  showerFit.GetLocalPosition(vertexPosition2D, rL, rT);
62 
63  CartesianVector showerDirection(0.f, 0.f, 0.f);
64  showerFit.GetGlobalFitDirection(rL, showerDirection);
65 
66  const float projectedVtxPosition = vertexPosition2D.GetDotProduct(showerDirection);
67 
68  float beforeVtxEnergy(0.f), afterVtxEnergy(0.f);
69  this->CalculateAsymmetryParameters(showerCluster, projectedVtxPosition, showerDirection, beforeVtxEnergy, afterVtxEnergy);
70 
71  if (beforeVtxEnergy + afterVtxEnergy > 0.f)
72  showerAsymmetry = std::fabs(afterVtxEnergy - beforeVtxEnergy) / (afterVtxEnergy + beforeVtxEnergy);
73 
74  break;
75  }
76  }
77 
78  return showerAsymmetry;
79 }
TFile f
Definition: plotHisto.C:6
void CalculateAsymmetryParameters(const VertexSelectionBaseAlgorithm::ShowerCluster &showerCluster, const float projectedVtxPosition, const pandora::CartesianVector &showerDirection, float &beforeVtxEnergy, float &afterVtxEnergy) const
Calculate the parameters for the asymmetry calculation.
bool ShouldUseShowerCluster(const pandora::CartesianVector &vertexPosition, const VertexSelectionBaseAlgorithm::ShowerCluster &showerCluster) const
Get whether we should use a given shower cluster for asymmetry calculation.
StatusCode lar_content::ShowerAsymmetryFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 125 of file ShowerAsymmetryFeatureTool.cc.

References m_vertexClusterDistance.

126 {
127  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
128  "VertexClusterDistance", m_vertexClusterDistance));
129 
130  return STATUS_CODE_SUCCESS;
131 }
float m_vertexClusterDistance
The distance around the vertex to look for shower clusters.
void lar_content::ShowerAsymmetryFeatureTool::Run ( LArMvaHelper::MvaFeatureVector featureVector,
const VertexSelectionBaseAlgorithm *const  pAlgorithm,
const pandora::Vertex *const  pVertex,
const VertexSelectionBaseAlgorithm::SlidingFitDataListMap ,
const VertexSelectionBaseAlgorithm::ClusterListMap ,
const VertexSelectionBaseAlgorithm::KDTreeMap ,
const VertexSelectionBaseAlgorithm::ShowerClusterListMap showerClusterListMap,
const float  ,
float &   
)

Run the tool.

Parameters
pAlgorithmaddress of the calling algorithm
pVertexaddress of the vertex
showerClusterListMapmap of the shower cluster lists
Returns
the shower asymmetry feature

Definition at line 26 of file ShowerAsymmetryFeatureTool.cc.

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

29 {
30  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
31  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
32 
33  float showerAsymmetry(0.f);
34 
35  showerAsymmetry += this->GetShowerAsymmetryForView(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_U),
36  showerClusterListMap.at(TPC_VIEW_U));
37 
38  showerAsymmetry += this->GetShowerAsymmetryForView(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_V),
39  showerClusterListMap.at(TPC_VIEW_V));
40 
41  showerAsymmetry += this->GetShowerAsymmetryForView(LArGeometryHelper::ProjectPosition(this->GetPandora(), pVertex->GetPosition(), TPC_VIEW_W),
42  showerClusterListMap.at(TPC_VIEW_W));
43 
44  featureVector.push_back(showerAsymmetry);
45 }
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 GetShowerAsymmetryForView(const pandora::CartesianVector &vertexPosition2D, const VertexSelectionBaseAlgorithm::ShowerClusterList &showerClusterList) const
Get the shower asymmetry 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
bool lar_content::ShowerAsymmetryFeatureTool::ShouldUseShowerCluster ( const pandora::CartesianVector &  vertexPosition,
const VertexSelectionBaseAlgorithm::ShowerCluster showerCluster 
) const
private

Get whether we should use a given shower cluster for asymmetry calculation.

Parameters
vertexPositionthe projected vertex position
showerClusterthe shower cluster
Returns
whether the shower cluster should be considered

Definition at line 83 of file ShowerAsymmetryFeatureTool.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), lar_content::VertexSelectionBaseAlgorithm::ShowerCluster::GetClusters(), and m_vertexClusterDistance.

Referenced by GetShowerAsymmetryForView().

85 {
86  for (const Cluster * const pCluster : showerCluster.GetClusters())
87  {
88  if (LArClusterHelper::GetClosestDistance(vertexPosition, pCluster) < m_vertexClusterDistance)
89  return true;
90  }
91 
92  return false;
93 }
float m_vertexClusterDistance
The distance around the vertex to look for shower clusters.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.

Member Data Documentation

float lar_content::ShowerAsymmetryFeatureTool::m_vertexClusterDistance
private

The distance around the vertex to look for shower clusters.

Definition at line 78 of file ShowerAsymmetryFeatureTool.h.

Referenced by ReadSettings(), and ShouldUseShowerCluster().


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