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

ThreeDChargeFeatureTool class for the calculation of charge-related features. More...

#include "TrackShowerIdFeatureTool.h"

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

Classes

class  VertexComparator
 VertexComparator class for comparison of two points wrt neutrino vertex position. More...
 

Public Types

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

Public Member Functions

 ThreeDChargeFeatureTool ()
 Default constructor. More...
 
void Run (LArMvaHelper::MvaFeatureVector &featureVector, const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pInputPfo)
 
void Run (LArMvaHelper::MvaFeatureMap &featureMap, pandora::StringVector &featureOrder, const std::string &featureToolName, const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pInputPfo)
 
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

void CalculateChargeVariables (const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster, float &totalCharge, float &chargeSigma, float &chargeMean, float &endCharge)
 Calculation of the charge variables. More...
 
void OrderCaloHitsByDistanceToVertex (const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster, pandora::CaloHitList &caloHitList)
 Function to order the calo hit list by distance to neutrino vertex. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

float m_endChargeFraction
 Fraction of hits that will be considered to calculate end charge (default 10%) More...
 

Detailed Description

ThreeDChargeFeatureTool class for the calculation of charge-related features.

Definition at line 338 of file TrackShowerIdFeatureTool.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::ThreeDChargeFeatureTool::ThreeDChargeFeatureTool ( )

Default constructor.

Definition at line 1066 of file TrackShowerIdFeatureTool.cc.

1066  :
1068 {
1069 }
TFile f
Definition: plotHisto.C:6
float m_endChargeFraction
Fraction of hits that will be considered to calculate end charge (default 10%)

Member Function Documentation

void lar_content::ThreeDChargeFeatureTool::CalculateChargeVariables ( const pandora::Algorithm *const  pAlgorithm,
const pandora::Cluster *const  pCluster,
float &  totalCharge,
float &  chargeSigma,
float &  chargeMean,
float &  endCharge 
)
private

Calculation of the charge variables.

Parameters
pAlgorithm,thealgorithm
pClusterthe cluster we are characterizing
totalCharge,toreceive the total charge
chargeSigma,toreceive the charge sigma
chargeMean,toreceive the charge mean
startCharge,toreceive the charge in the initial 10% hits
endCharge,toreceive the charge in the last 10% hits

Definition at line 1122 of file TrackShowerIdFeatureTool.cc.

References f, m_endChargeFraction, and OrderCaloHitsByDistanceToVertex().

Referenced by Run().

1124 {
1125  totalCharge = 0.f;
1126  chargeSigma = 0.f;
1127  chargeMean = 0.f;
1128  endCharge = 0.f;
1129 
1130  CaloHitList orderedCaloHitList;
1131  this->OrderCaloHitsByDistanceToVertex(pAlgorithm, pCluster, orderedCaloHitList);
1132 
1133  FloatVector chargeVector;
1134  unsigned int hitCounter(0);
1135  const unsigned int nTotalHits(orderedCaloHitList.size());
1136 
1137  for (const CaloHit *const pCaloHit : orderedCaloHitList)
1138  {
1139  ++hitCounter;
1140  const float pCaloHitCharge(pCaloHit->GetInputEnergy());
1141 
1142  if (pCaloHitCharge >= 0.f)
1143  {
1144  totalCharge += pCaloHitCharge;
1145  chargeVector.push_back(pCaloHitCharge);
1146 
1147  if (hitCounter >= std::floor(static_cast<float>(nTotalHits) * (1.f - m_endChargeFraction)))
1148  endCharge += pCaloHitCharge;
1149  }
1150  }
1151 
1152  if (!chargeVector.empty())
1153  {
1154  chargeMean = totalCharge / static_cast<float>(chargeVector.size());
1155 
1156  for (const float charge : chargeVector)
1157  chargeSigma += (charge - chargeMean) * (charge - chargeMean);
1158 
1159  chargeSigma = std::sqrt(chargeSigma / static_cast<float>(chargeVector.size()));
1160  }
1161 }
void OrderCaloHitsByDistanceToVertex(const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster, pandora::CaloHitList &caloHitList)
Function to order the calo hit list by distance to neutrino vertex.
TFile f
Definition: plotHisto.C:6
float m_endChargeFraction
Fraction of hits that will be considered to calculate end charge (default 10%)
void lar_content::ThreeDChargeFeatureTool::OrderCaloHitsByDistanceToVertex ( const pandora::Algorithm *const  pAlgorithm,
const pandora::Cluster *const  pCluster,
pandora::CaloHitList &  caloHitList 
)
private

Function to order the calo hit list by distance to neutrino vertex.

Parameters
pAlgorithm,thealgorithm
pClusterthe cluster we are characterizing
caloHitListto receive the ordered calo hit list

Definition at line 1165 of file TrackShowerIdFeatureTool.cc.

References lar_content::LArClusterHelper::GetClusterHitType(), and lar_content::LArGeometryHelper::ProjectPosition().

Referenced by CalculateChargeVariables().

1167 {
1168  const VertexList *pVertexList(nullptr);
1169  (void)PandoraContentApi::GetCurrentList(*pAlgorithm, pVertexList);
1170 
1171  if (!pVertexList || pVertexList->empty())
1172  return;
1173 
1174  unsigned int nInteractionVertices(0);
1175  const Vertex *pInteractionVertex(nullptr);
1176 
1177  for (const Vertex *pVertex : *pVertexList)
1178  {
1179  if ((pVertex->GetVertexLabel() == VERTEX_INTERACTION) && (pVertex->GetVertexType() == VERTEX_3D))
1180  {
1181  ++nInteractionVertices;
1182  pInteractionVertex = pVertex;
1183  }
1184  }
1185 
1186  if (pInteractionVertex && (1 == nInteractionVertices))
1187  {
1188  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
1189  const CartesianVector vertexPosition2D(LArGeometryHelper::ProjectPosition(pAlgorithm->GetPandora(), pInteractionVertex->GetPosition(), hitType));
1190 
1191  CaloHitList clusterCaloHitList;
1192  pCluster->GetOrderedCaloHitList().FillCaloHitList(clusterCaloHitList);
1193 
1194  clusterCaloHitList.sort(ThreeDChargeFeatureTool::VertexComparator(vertexPosition2D));
1195  caloHitList.insert(caloHitList.end(), clusterCaloHitList.begin(), clusterCaloHitList.end());
1196  }
1197 }
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
HitType
Definition: HitType.h:12
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::list< Vertex > VertexList
Definition: DCEL.h:169
StatusCode lar_content::ThreeDChargeFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 1201 of file TrackShowerIdFeatureTool.cc.

References m_endChargeFraction.

1202 {
1203  PANDORA_RETURN_RESULT_IF_AND_IF(
1204  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "EndChargeFraction", m_endChargeFraction));
1205 
1206  return STATUS_CODE_SUCCESS;
1207 }
float m_endChargeFraction
Fraction of hits that will be considered to calculate end charge (default 10%)
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  };
void lar_content::ThreeDChargeFeatureTool::Run ( LArMvaHelper::MvaFeatureVector featureVector,
const pandora::Algorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pInputPfo 
)

Definition at line 1073 of file TrackShowerIdFeatureTool.cc.

References CalculateChargeVariables(), f, and lar_content::LArPfoHelper::GetClusters().

1075 {
1076  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
1077  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
1078 
1079  float totalCharge(-1.f), chargeSigma(-1.f), chargeMean(-1.f), endCharge(-1.f);
1080  LArMvaHelper::MvaFeature charge1, charge2;
1081 
1082  ClusterList clusterListW;
1083  LArPfoHelper::GetClusters(pInputPfo, TPC_VIEW_W, clusterListW);
1084 
1085  if (!clusterListW.empty())
1086  this->CalculateChargeVariables(pAlgorithm, clusterListW.front(), totalCharge, chargeSigma, chargeMean, endCharge);
1087 
1088  if (chargeMean > std::numeric_limits<float>::epsilon())
1089  charge1 = chargeSigma / chargeMean;
1090 
1091  if (totalCharge > std::numeric_limits<float>::epsilon())
1092  charge2 = endCharge / totalCharge;
1093 
1094  featureVector.push_back(charge1);
1095  featureVector.push_back(charge2);
1096 }
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
MvaTypes::MvaFeature MvaFeature
Definition: LArMvaHelper.h:74
TFile f
Definition: plotHisto.C:6
void CalculateChargeVariables(const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster, float &totalCharge, float &chargeSigma, float &chargeMean, float &endCharge)
Calculation of the charge variables.
void lar_content::ThreeDChargeFeatureTool::Run ( LArMvaHelper::MvaFeatureMap featureMap,
pandora::StringVector &  featureOrder,
const std::string &  featureToolName,
const pandora::Algorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pInputPfo 
)

Member Data Documentation

float lar_content::ThreeDChargeFeatureTool::m_endChargeFraction
private

Fraction of hits that will be considered to calculate end charge (default 10%)

Definition at line 401 of file TrackShowerIdFeatureTool.h.

Referenced by CalculateChargeVariables(), and ReadSettings().


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