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

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
 

Detailed Description

ThreeDChargeFeatureTool class for the calculation of charge-related features.

Definition at line 259 of file TrackShowerIdFeatureTool.h.

Constructor & Destructor Documentation

lar_content::ThreeDChargeFeatureTool::ThreeDChargeFeatureTool ( )

Default constructor.

Definition at line 728 of file TrackShowerIdFeatureTool.cc.

728  : m_endChargeFraction(0.1f)
729 {
730 }
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 761 of file TrackShowerIdFeatureTool.cc.

763 {
764  totalCharge = 0.f;
765  chargeSigma = 0.f;
766  chargeMean = 0.f;
767  endCharge = 0.f;
768 
769  CaloHitList orderedCaloHitList;
770  this->OrderCaloHitsByDistanceToVertex(pAlgorithm, pCluster, orderedCaloHitList);
771 
772  FloatVector chargeVector;
773  unsigned int hitCounter(0);
774  const unsigned int nTotalHits(orderedCaloHitList.size());
775 
776  for (const CaloHit *const pCaloHit : orderedCaloHitList)
777  {
778  ++hitCounter;
779  const float pCaloHitCharge(pCaloHit->GetInputEnergy());
780 
781  if (pCaloHitCharge >= 0.f)
782  {
783  totalCharge += pCaloHitCharge;
784  chargeVector.push_back(pCaloHitCharge);
785 
786  if (hitCounter >= std::floor(static_cast<float>(nTotalHits) * (1.f - m_endChargeFraction)))
787  endCharge += pCaloHitCharge;
788  }
789  }
790 
791  if (!chargeVector.empty())
792  {
793  chargeMean = totalCharge / static_cast<float>(chargeVector.size());
794 
795  for (const float charge : chargeVector)
796  chargeSigma += (charge - chargeMean) * (charge - chargeMean);
797 
798  chargeSigma = std::sqrt(chargeSigma / static_cast<float>(chargeVector.size()));
799  }
800 }
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.
Dft::FloatVector FloatVector
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 804 of file TrackShowerIdFeatureTool.cc.

806 {
807  const VertexList *pVertexList(nullptr);
808  (void)PandoraContentApi::GetCurrentList(*pAlgorithm, pVertexList);
809 
810  if (!pVertexList || pVertexList->empty())
811  return;
812 
813  unsigned int nInteractionVertices(0);
814  const Vertex *pInteractionVertex(nullptr);
815 
816  for (const Vertex *pVertex : *pVertexList)
817  {
818  if ((pVertex->GetVertexLabel() == VERTEX_INTERACTION) && (pVertex->GetVertexType() == VERTEX_3D))
819  {
820  ++nInteractionVertices;
821  pInteractionVertex = pVertex;
822  }
823  }
824 
825  if (pInteractionVertex && (1 == nInteractionVertices))
826  {
827  const HitType hitType(LArClusterHelper::GetClusterHitType(pCluster));
828  const CartesianVector vertexPosition2D(LArGeometryHelper::ProjectPosition(pAlgorithm->GetPandora(), pInteractionVertex->GetPosition(), hitType));
829 
830  CaloHitList clusterCaloHitList;
831  pCluster->GetOrderedCaloHitList().FillCaloHitList(clusterCaloHitList);
832 
833  clusterCaloHitList.sort(ThreeDChargeFeatureTool::VertexComparator(vertexPosition2D));
834  caloHitList.insert(caloHitList.end(), clusterCaloHitList.begin(), clusterCaloHitList.end());
835  }
836 }
enum cvn::HType HitType
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.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
std::list< Vertex > VertexList
Definition: DCEL.h:182
StatusCode lar_content::ThreeDChargeFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 840 of file TrackShowerIdFeatureTool.cc.

841 {
842  PANDORA_RETURN_RESULT_IF_AND_IF(
843  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "EndChargeFraction", m_endChargeFraction));
844 
845  return STATUS_CODE_SUCCESS;
846 }
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 734 of file TrackShowerIdFeatureTool.cc.

736 {
737  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
738  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
739 
740  float totalCharge(-1.f), chargeSigma(-1.f), chargeMean(-1.f), endCharge(-1.f);
741  LArMvaHelper::MvaFeature charge1, charge2;
742 
743  ClusterList clusterListW;
744  LArPfoHelper::GetClusters(pInputPfo, TPC_VIEW_W, clusterListW);
745 
746  if (!clusterListW.empty())
747  this->CalculateChargeVariables(pAlgorithm, clusterListW.front(), totalCharge, chargeSigma, chargeMean, endCharge);
748 
749  if (chargeMean > std::numeric_limits<float>::epsilon())
750  charge1 = chargeSigma / chargeMean;
751 
752  if (totalCharge > std::numeric_limits<float>::epsilon())
753  charge2 = endCharge / totalCharge;
754 
755  featureVector.push_back(charge1);
756  featureVector.push_back(charge2);
757 }
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
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.
QTextStream & endl(QTextStream &s)

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


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