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

ConeChargeFeatureTool class for the calculation of charge distribution and conicalness. More...

#include "TrackShowerIdFeatureTool.h"

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

Public Types

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

Public Member Functions

 ConeChargeFeatureTool ()
 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

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void CalculateChargeDistribution (const pandora::CaloHitList &caloHitList, const pandora::CartesianVector &pfoStart, const pandora::CartesianVector &pfoDir, float &chargeCore, float &chargeHalo, float &chargeCon)
 Calculate charge distribution in relation to the Moeliere radius. More...
 
float CalculateConicalness (const pandora::CaloHitList &caloHitList, const pandora::CartesianVector &pfoStart, const pandora::CartesianVector &pfoDir, const float pfoLength)
 Calculate conicalness as a ratio of charge distribution at the end and start of pfo. More...
 

Private Attributes

unsigned int m_conMinHits
 Configurable parameters to calculate cone charge variables. More...
 
float m_minCharge
 
float m_conFracRange
 
float m_MoliereRadius
 
float m_MoliereRadiusFrac
 

Detailed Description

ConeChargeFeatureTool class for the calculation of charge distribution and conicalness.

Definition at line 210 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::ConeChargeFeatureTool::ConeChargeFeatureTool ( )

Default constructor.

Definition at line 402 of file TrackShowerIdFeatureTool.cc.

402  :
403  m_conMinHits(3),
404  m_minCharge(0.1f),
405  m_conFracRange(0.2f),
406  m_MoliereRadius(10.1f),
408 {
409 }
unsigned int m_conMinHits
Configurable parameters to calculate cone charge variables.
TFile f
Definition: plotHisto.C:6

Member Function Documentation

void lar_content::ConeChargeFeatureTool::CalculateChargeDistribution ( const pandora::CaloHitList &  caloHitList,
const pandora::CartesianVector &  pfoStart,
const pandora::CartesianVector &  pfoDir,
float &  chargeCore,
float &  chargeHalo,
float &  chargeCon 
)
private

Calculate charge distribution in relation to the Moeliere radius.

Parameters
caloHitListthe calo hit list of plane w
pfoStartstart position of the pfo
pfoDirdirection of pfo from the principle vector of pca
chargeCoreto receive sum of charge within Moeliete radius * fraction
chargeHaloto receive sum of charge outside of Moeliere radius * fraction
chargeConto receive weighted sum of total charge

Definition at line 477 of file TrackShowerIdFeatureTool.cc.

References E, f, m_MoliereRadius, and m_MoliereRadiusFrac.

Referenced by Run().

479 {
480  for (const CaloHit *const pCaloHit : caloHitList)
481  {
482  const float distFromTrackFit(((pCaloHit->GetPositionVector() - pfoStart).GetCrossProduct(pfoDir)).GetMagnitude());
483 
484  if (distFromTrackFit < m_MoliereRadiusFrac * m_MoliereRadius)
485  chargeCore += pCaloHit->GetInputEnergy();
486  else
487  chargeHalo += pCaloHit->GetInputEnergy();
488 
489  chargeCon += pCaloHit->GetInputEnergy() / std::max(1.E-2f, distFromTrackFit); /* Set 1.E-2f to prevent division by 0 and to set max histogram bin as 100 */
490  }
491 }
TFile f
Definition: plotHisto.C:6
Float_t E
Definition: plot.C:20
float lar_content::ConeChargeFeatureTool::CalculateConicalness ( const pandora::CaloHitList &  caloHitList,
const pandora::CartesianVector &  pfoStart,
const pandora::CartesianVector &  pfoDir,
const float  pfoLength 
)
private

Calculate conicalness as a ratio of charge distribution at the end and start of pfo.

Parameters
caloHitListthe calo hit list of plane w
pfoStartstart position of the pfo
pfoDirdirection of pfo from the principle vector of pca
pfoLengthlength of the whole pfo return conicalness

Definition at line 495 of file TrackShowerIdFeatureTool.cc.

References f, m_conFracRange, m_conMinHits, and m_minCharge.

Referenced by Run().

497 {
498  float totalChargeStart(0.f), totalChargeEnd(0.f);
499  float chargeConStart(0.f), chargeConEnd(0.f);
500  unsigned int nHitsConStart(0), nHitsConEnd(0);
501 
502  for (const CaloHit *const pCaloHit : caloHitList)
503  {
504  const float distFromTrackFit(((pCaloHit->GetPositionVector() - pfoStart).GetCrossProduct(pfoDir)).GetMagnitude());
505  const float hitLength(std::fabs((pCaloHit->GetPositionVector() - pfoStart).GetDotProduct(pfoDir)));
506 
507  if (hitLength / pfoLength < m_conFracRange)
508  {
509  chargeConStart += distFromTrackFit * distFromTrackFit * pCaloHit->GetInputEnergy();
510  ++nHitsConStart;
511  totalChargeStart += pCaloHit->GetInputEnergy();
512  }
513  else if (1.f - hitLength / pfoLength < m_conFracRange)
514  {
515  chargeConEnd += distFromTrackFit * distFromTrackFit * pCaloHit->GetInputEnergy();
516  ++nHitsConEnd;
517  totalChargeEnd += pCaloHit->GetInputEnergy();
518  }
519  }
520 
521  float conicalness(1.f);
522 
523  if (nHitsConStart >= m_conMinHits && nHitsConEnd >= m_conMinHits && totalChargeEnd > m_minCharge &&
524  std::sqrt(chargeConStart) > m_minCharge && totalChargeStart > m_minCharge)
525  conicalness = (std::sqrt(chargeConEnd / chargeConStart)) / (totalChargeEnd / totalChargeStart);
526 
527  return conicalness;
528 }
unsigned int m_conMinHits
Configurable parameters to calculate cone charge variables.
TFile f
Definition: plotHisto.C:6
StatusCode lar_content::ConeChargeFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 532 of file TrackShowerIdFeatureTool.cc.

References m_conFracRange, m_conMinHits, m_minCharge, m_MoliereRadius, and m_MoliereRadiusFrac.

533 {
534  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ConMinHits", m_conMinHits));
535  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCharge", m_minCharge));
536  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ConFracRange", m_conFracRange));
537  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MoliereRadius", m_MoliereRadius));
538  PANDORA_RETURN_RESULT_IF_AND_IF(
539  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MoliereRadiusFrac", m_MoliereRadiusFrac));
540 
541  return STATUS_CODE_SUCCESS;
542 }
unsigned int m_conMinHits
Configurable parameters to calculate cone charge variables.
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::ConeChargeFeatureTool::Run ( LArMvaHelper::MvaFeatureVector featureVector,
const pandora::Algorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pInputPfo 
)

Definition at line 413 of file TrackShowerIdFeatureTool.cc.

References CalculateChargeDistribution(), CalculateConicalness(), f, lar_content::LArPfoHelper::GetClusters(), lar_content::LArPfoHelper::GetThreeDLengthSquared(), and lar_content::LArPcaHelper::RunPca().

415 {
416  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
417  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
418 
419  ClusterList clusterListW;
420  LArPfoHelper::GetClusters(pInputPfo, TPC_VIEW_W, clusterListW);
421 
422  LArMvaHelper::MvaFeature haloTotalRatio, concentration, conicalness;
423 
424  if (!clusterListW.empty())
425  {
426  CaloHitList clusterCaloHitList;
427  clusterListW.front()->GetOrderedCaloHitList().FillCaloHitList(clusterCaloHitList);
428 
429  const CartesianVector &pfoStart(clusterCaloHitList.front()->GetPositionVector());
430  CartesianVector centroid(0.f, 0.f, 0.f);
431  LArPcaHelper::EigenVectors eigenVecs;
432  LArPcaHelper::EigenValues eigenValues(0.f, 0.f, 0.f);
433  LArPcaHelper::RunPca(clusterCaloHitList, centroid, eigenValues, eigenVecs);
434 
435  float chargeCore(0.f), chargeHalo(0.f), chargeCon(0.f);
436  this->CalculateChargeDistribution(clusterCaloHitList, pfoStart, eigenVecs[0], chargeCore, chargeHalo, chargeCon);
437  haloTotalRatio = (chargeCore + chargeHalo > std::numeric_limits<float>::epsilon()) ? chargeHalo / (chargeCore + chargeHalo) : -1.f;
438  concentration = (chargeCore + chargeHalo > std::numeric_limits<float>::epsilon()) ? chargeCon / (chargeCore + chargeHalo) : -1.f;
439  const float pfoLength(std::sqrt(LArPfoHelper::GetThreeDLengthSquared(pInputPfo)));
440  conicalness = (pfoLength > std::numeric_limits<float>::epsilon())
441  ? this->CalculateConicalness(clusterCaloHitList, pfoStart, eigenVecs[0], pfoLength)
442  : 1.f;
443  }
444 
445  featureVector.push_back(haloTotalRatio);
446  featureVector.push_back(concentration);
447  featureVector.push_back(conicalness);
448 }
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.
pandora::CartesianVector EigenValues
Definition: LArPcaHelper.h:24
static float GetThreeDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 3D clusters.
MvaTypes::MvaFeature MvaFeature
Definition: LArMvaHelper.h:74
TFile f
Definition: plotHisto.C:6
static void RunPca(const T &t, pandora::CartesianVector &centroid, EigenValues &outputEigenValues, EigenVectors &outputEigenVectors)
Run principal component analysis using input calo hits (TPC_VIEW_U,V,W or TPC_3D; all treated as 3D p...
std::vector< pandora::CartesianVector > EigenVectors
Definition: LArPcaHelper.h:25
float CalculateConicalness(const pandora::CaloHitList &caloHitList, const pandora::CartesianVector &pfoStart, const pandora::CartesianVector &pfoDir, const float pfoLength)
Calculate conicalness as a ratio of charge distribution at the end and start of pfo.
void CalculateChargeDistribution(const pandora::CaloHitList &caloHitList, const pandora::CartesianVector &pfoStart, const pandora::CartesianVector &pfoDir, float &chargeCore, float &chargeHalo, float &chargeCon)
Calculate charge distribution in relation to the Moeliere radius.
void lar_content::ConeChargeFeatureTool::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::ConeChargeFeatureTool::m_conFracRange
private

Definition at line 236 of file TrackShowerIdFeatureTool.h.

Referenced by CalculateConicalness(), and ReadSettings().

unsigned int lar_content::ConeChargeFeatureTool::m_conMinHits
private

Configurable parameters to calculate cone charge variables.

Parameters
conMinHitsminimum hit requirement at start and end of pfo to calculate conicalness
minChargeminimum charge requirement at start and end of pfo to calculate conicalness
conFracRangeconincal fractional range to determine start/end of pfo
MoliereRadius10.1 cm to determine halo/core of pfo
MoliereRadiusFracfraction of Moliere radius, default = 0.2

Definition at line 234 of file TrackShowerIdFeatureTool.h.

Referenced by CalculateConicalness(), and ReadSettings().

float lar_content::ConeChargeFeatureTool::m_minCharge
private

Definition at line 235 of file TrackShowerIdFeatureTool.h.

Referenced by CalculateConicalness(), and ReadSettings().

float lar_content::ConeChargeFeatureTool::m_MoliereRadius
private

Definition at line 237 of file TrackShowerIdFeatureTool.h.

Referenced by CalculateChargeDistribution(), and ReadSettings().

float lar_content::ConeChargeFeatureTool::m_MoliereRadiusFrac
private

Definition at line 238 of file TrackShowerIdFeatureTool.h.

Referenced by CalculateChargeDistribution(), and ReadSettings().


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