All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar_content::ThreeDChargeFeatureTool Class Reference

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 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)
 
- Public Member Functions inherited from lar_content::MvaFeatureTool< Ts >
 MvaFeatureTool ()=default
 Default constructor. 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...args)
 

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

Additional Inherited Members

- Public Types inherited from lar_content::MvaFeatureTool< Ts >
typedef std::vector
< MvaFeatureTool< Ts...> * > 
FeatureToolVector
 
typedef std::map< std::string,
MvaFeatureTool< Ts...> * > 
FeatureToolMap
 

Detailed Description

ThreeDChargeFeatureTool class for the calculation of charge-related features.

Definition at line 338 of file TrackShowerIdFeatureTool.h.

Constructor & Destructor Documentation

lar_content::ThreeDChargeFeatureTool::ThreeDChargeFeatureTool ( )

Default constructor.

Definition at line 1057 of file TrackShowerIdFeatureTool.cc.

1057  : m_endChargeFraction(0.1f)
1058 {
1059 }
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 1112 of file TrackShowerIdFeatureTool.cc.

1114 {
1115  totalCharge = 0.f;
1116  chargeSigma = 0.f;
1117  chargeMean = 0.f;
1118  endCharge = 0.f;
1119 
1120  CaloHitList orderedCaloHitList;
1121  this->OrderCaloHitsByDistanceToVertex(pAlgorithm, pCluster, orderedCaloHitList);
1122 
1123  FloatVector chargeVector;
1124  unsigned int hitCounter(0);
1125  const unsigned int nTotalHits(orderedCaloHitList.size());
1126 
1127  for (const CaloHit *const pCaloHit : orderedCaloHitList)
1128  {
1129  ++hitCounter;
1130  const float pCaloHitCharge(pCaloHit->GetInputEnergy());
1131 
1132  if (pCaloHitCharge >= 0.f)
1133  {
1134  totalCharge += pCaloHitCharge;
1135  chargeVector.push_back(pCaloHitCharge);
1136 
1137  if (hitCounter >= std::floor(static_cast<float>(nTotalHits) * (1.f - m_endChargeFraction)))
1138  endCharge += pCaloHitCharge;
1139  }
1140  }
1141 
1142  if (!chargeVector.empty())
1143  {
1144  chargeMean = totalCharge / static_cast<float>(chargeVector.size());
1145 
1146  for (const float charge : chargeVector)
1147  chargeSigma += (charge - chargeMean) * (charge - chargeMean);
1148 
1149  chargeSigma = std::sqrt(chargeSigma / static_cast<float>(chargeVector.size()));
1150  }
1151 }
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.
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 1155 of file TrackShowerIdFeatureTool.cc.

1157 {
1158  const VertexList *pVertexList(nullptr);
1159  (void)PandoraContentApi::GetCurrentList(*pAlgorithm, pVertexList);
1160 
1161  if (!pVertexList || pVertexList->empty())
1162  return;
1163 
1164  unsigned int nInteractionVertices(0);
1165  const Vertex *pInteractionVertex(nullptr);
1166 
1167  for (const Vertex *pVertex : *pVertexList)
1168  {
1169  if ((pVertex->GetVertexLabel() == VERTEX_INTERACTION) && (pVertex->GetVertexType() == VERTEX_3D))
1170  {
1171  ++nInteractionVertices;
1172  pInteractionVertex = pVertex;
1173  }
1174  }
1175 
1176  if (pInteractionVertex && (1 == nInteractionVertices))
1177  {
1178  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
1179  const CartesianVector vertexPosition2D(LArGeometryHelper::ProjectPosition(pAlgorithm->GetPandora(), pInteractionVertex->GetPosition(), hitType));
1180 
1181  CaloHitList clusterCaloHitList;
1182  pCluster->GetOrderedCaloHitList().FillCaloHitList(clusterCaloHitList);
1183 
1184  clusterCaloHitList.sort(ThreeDChargeFeatureTool::VertexComparator(vertexPosition2D));
1185  caloHitList.insert(caloHitList.end(), clusterCaloHitList.begin(), clusterCaloHitList.end());
1186  }
1187 }
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.
j template void())
Definition: json.hpp:3108
std::list< Vertex > VertexList
Definition: DCEL.h:182
StatusCode lar_content::ThreeDChargeFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 1191 of file TrackShowerIdFeatureTool.cc.

1192 {
1193  PANDORA_RETURN_RESULT_IF_AND_IF(
1194  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "EndChargeFraction", m_endChargeFraction));
1195 
1196  return STATUS_CODE_SUCCESS;
1197 }
float m_endChargeFraction
Fraction of hits that will be considered to calculate end charge (default 10%)
void lar_content::ThreeDChargeFeatureTool::Run ( LArMvaHelper::MvaFeatureVector featureVector,
const pandora::Algorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pInputPfo 
)

Definition at line 1063 of file TrackShowerIdFeatureTool.cc.

1065 {
1066  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
1067  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
1068 
1069  float totalCharge(-1.f), chargeSigma(-1.f), chargeMean(-1.f), endCharge(-1.f);
1070  LArMvaHelper::MvaFeature charge1, charge2;
1071 
1072  ClusterList clusterListW;
1073  LArPfoHelper::GetClusters(pInputPfo, TPC_VIEW_W, clusterListW);
1074 
1075  if (!clusterListW.empty())
1076  this->CalculateChargeVariables(pAlgorithm, clusterListW.front(), totalCharge, chargeSigma, chargeMean, endCharge);
1077 
1078  if (chargeMean > std::numeric_limits<float>::epsilon())
1079  charge1 = chargeSigma / chargeMean;
1080 
1081  if (totalCharge > std::numeric_limits<float>::epsilon())
1082  charge2 = endCharge / totalCharge;
1083 
1084  featureVector.push_back(charge1);
1085  featureVector.push_back(charge2);
1086 }
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:71
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.
BEGIN_PROLOG could also be cout
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.


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