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

ChargeFeatureTool class for the calculation of concentration. 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
 

Public Member Functions

 ThreeDChargeFeatureTool ()
 Default constructor. More...
 
void Run (LArMvaHelper::MvaFeatureVector &featureVector, const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pInputPfo)
 
virtual void Run (MvaTypes::MvaFeatureVector &featureVector, Ts...args)=0
 Run the algorithm tool. More...
 

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

ChargeFeatureTool class for the calculation of concentration.

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

Default constructor.

Definition at line 619 of file TrackShowerIdFeatureTool.cc.

619  :
621 {
622 }
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 655 of file TrackShowerIdFeatureTool.cc.

References f, m_endChargeFraction, and OrderCaloHitsByDistanceToVertex().

Referenced by Run().

657 {
658 
659  CaloHitList orderedCaloHitList;
660  this->OrderCaloHitsByDistanceToVertex(pAlgorithm, pCluster, orderedCaloHitList);
661 
662  const int totalHits(pCluster->GetNCaloHits());
663  FloatVector chargeVector;
664  int hitCounter(0);
665  totalCharge = 0.f;
666  endCharge = 0.f;
667 
668  for (const CaloHit *const pCaloHit : orderedCaloHitList)
669  {
670  hitCounter++;
671  const float pCaloHitCharge(pCaloHit->GetInputEnergy());
672 
673  if (pCaloHitCharge < 0)
674  {
675  std::cout << "Found a hit with negative charge! " << std::endl;
676  }
677  else
678  {
679  totalCharge += pCaloHitCharge;
680  chargeVector.push_back(pCaloHitCharge);
681 
682  if (hitCounter >= std::floor(totalHits*(1.f-m_endChargeFraction)))
683  {
684  endCharge += pCaloHitCharge;
685  }
686  }
687  }
688 
689  if (!chargeVector.empty())
690  {
691  chargeMean = 0.f;
692  chargeSigma = 0.f;
693 
694  for (const float charge : chargeVector)
695  chargeMean += charge;
696 
697  chargeMean /= static_cast<float>(chargeVector.size());
698 
699  for (const float charge : chargeVector)
700  chargeSigma += (charge - chargeMean) * (charge - chargeMean);
701 
702  chargeSigma = std::sqrt(chargeSigma / static_cast<float>(chargeVector.size()));
703  }
704 }
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 708 of file TrackShowerIdFeatureTool.cc.

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

Referenced by CalculateChargeVariables().

709 {
710  //find the neutrino vertex and sort hits by distance to vertex
711  const VertexList *pVertexList = nullptr;
712  (void) PandoraContentApi::GetCurrentList(*pAlgorithm, pVertexList);
713 
714  if ((!pVertexList->empty()) && (pVertexList->size() == 1) && (VERTEX_3D == pVertexList->front()->GetVertexType()))
715  {
716  const Vertex *const pVertex(pVertexList->front());
717  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
718 
719  const CartesianVector vertexPosition2D(LArGeometryHelper::ProjectPosition(pAlgorithm->GetPandora(), pVertex->GetPosition(), hitType));
720 
721  CaloHitList clusterCaloHitList;
722  pCluster->GetOrderedCaloHitList().FillCaloHitList(clusterCaloHitList);
723  CaloHitVector clusterCaloHitVector(clusterCaloHitList.begin(), clusterCaloHitList.end());
724 
725  //TODO: might give problems if vertex in the middle of the cluster ?
726  std::sort(clusterCaloHitVector.begin(), clusterCaloHitVector.end(), VertexComparator(vertexPosition2D));
727  caloHitList.insert(caloHitList.end(), clusterCaloHitVector.begin(), clusterCaloHitVector.end());
728  }
729 }
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.
std::list< Vertex > VertexList
Definition: DCEL.h:178
StatusCode lar_content::ThreeDChargeFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 733 of file TrackShowerIdFeatureTool.cc.

References m_endChargeFraction.

734 {
735 
736  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
737  "EndChargeFraction", m_endChargeFraction));
738 
739  return STATUS_CODE_SUCCESS;
740 }
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
void lar_content::ThreeDChargeFeatureTool::Run ( LArMvaHelper::MvaFeatureVector featureVector,
const pandora::Algorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pInputPfo 
)

Definition at line 626 of file TrackShowerIdFeatureTool.cc.

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

628 {
629  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
630  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
631 
632  float totalCharge(-1.f), chargeSigma(-1.f), chargeMean(-1.f), endCharge(-1.f);
633  LArMvaHelper::MvaFeature charge1, charge2;
634 
635  ClusterList pClusterList;
636  LArPfoHelper::GetClusters(pInputPfo, TPC_VIEW_W, pClusterList);
637  if ((!pClusterList.empty()) && (pClusterList.size() == 1))
638  {
639  const Cluster *const pCluster(pClusterList.front());
640  this->CalculateChargeVariables(pAlgorithm, pCluster, totalCharge, chargeSigma, chargeMean, endCharge);
641  }
642 
643  if (chargeMean > std::numeric_limits<float>::epsilon())
644  charge1 = chargeSigma / chargeMean;
645 
646  if (totalCharge > std::numeric_limits<float>::epsilon())
647  charge2 = endCharge / totalCharge;
648 
649  featureVector.push_back(charge1);
650  featureVector.push_back(charge2);
651 }
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:57
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.

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 286 of file TrackShowerIdFeatureTool.h.

Referenced by CalculateChargeVariables(), and ReadSettings().


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