LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_content::ThreeDOpeningAngleFeatureTool Class Referenceabstract

VertexDistanceFeatureTool class for the calculation of distance to neutrino vertex. More...

#include "TrackShowerIdFeatureTool.h"

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

Public Types

typedef std::vector< MvaFeatureTool< Ts... > * > FeatureToolVector
 

Public Member Functions

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

pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void Divide3DCaloHitList (const pandora::Algorithm *const pAlgorithm, pandora::CaloHitList &threeDCaloHitList, pandora::CartesianPointVector &pointVectorStart, pandora::CartesianPointVector &pointVectorEnd)
 
float OpeningAngle (const pandora::CartesianVector &principal, const pandora::CartesianVector &secondary, const pandora::CartesianVector &eigenValues) const
 

Detailed Description

VertexDistanceFeatureTool class for the calculation of distance to neutrino vertex.

Definition at line 181 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::ThreeDOpeningAngleFeatureTool::ThreeDOpeningAngleFeatureTool ( )

Default constructor.

Definition at line 441 of file TrackShowerIdFeatureTool.cc.

442 {
443 }

Member Function Documentation

void lar_content::ThreeDOpeningAngleFeatureTool::Divide3DCaloHitList ( const pandora::Algorithm *const  pAlgorithm,
pandora::CaloHitList &  threeDCaloHitList,
pandora::CartesianPointVector &  pointVectorStart,
pandora::CartesianPointVector &  pointVectorEnd 
)
private

Definition at line 492 of file TrackShowerIdFeatureTool.cc.

493 {
494  const VertexList *pVertexList = nullptr;
495  (void) PandoraContentApi::GetCurrentList(*pAlgorithm, pVertexList);
496 
497  if ((!pVertexList->empty()) && (pVertexList->size() == 1) && (VERTEX_3D == pVertexList->front()->GetVertexType()))
498  {
499  const CartesianVector nuVertex(pVertexList->front()->GetPosition());
500  CaloHitVector threeDCaloHitVector(threeDCaloHitList.begin(), threeDCaloHitList.end());
501 
502  //order by distance to vertex, so first ones are closer to nuvertex
503  std::sort(threeDCaloHitVector.begin(), threeDCaloHitVector.end(), ThreeDChargeFeatureTool::VertexComparator(nuVertex));
504  CaloHitList orderedCaloHitList(threeDCaloHitVector.begin(),threeDCaloHitVector.end());
505  const unsigned int nhits(orderedCaloHitList.size());
506 
507  for (const CaloHit *const pCaloHit : orderedCaloHitList)
508  {
509  CartesianPointVector &targetVector((pointVectorStart.size() < (nhits / 2)) ? pointVectorStart : pointVectorEnd);
510  targetVector.push_back(pCaloHit->GetPositionVector());
511  }
512  }
513 }
std::list< Vertex > VertexList
Definition: DCEL.h:178
float lar_content::ThreeDOpeningAngleFeatureTool::OpeningAngle ( const pandora::CartesianVector &  principal,
const pandora::CartesianVector &  secondary,
const pandora::CartesianVector &  eigenValues 
) const
private

Definition at line 517 of file TrackShowerIdFeatureTool.cc.

References f.

519 {
520  const float principalMagnitude(principal.GetMagnitude());
521  const float secondaryMagnitude(secondary.GetMagnitude());
522 
523  if (std::fabs(principalMagnitude) < std::numeric_limits<float>::epsilon())
524  {
525  std::cout << "PcaShowerParticleBuildingAlgorithm::OpeningAngle - The principal eigenvector is 0." << std::endl;
526  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
527  }
528  else if (std::fabs(secondaryMagnitude) < std::numeric_limits<float>::epsilon())
529  {
530  return 0.f;
531  }
532 
533  const float cosTheta(principal.GetDotProduct(secondary) / (principalMagnitude * secondaryMagnitude));
534 
535  if (cosTheta > 1.f)
536  {
537  std::cout << "PcaShowerParticleBuildingAlgorithm::OpeningAngle - cos(theta) reportedly greater than 1." << std::endl;
538  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
539  }
540 
541  const float sinTheta(std::sqrt(1.f - cosTheta * cosTheta));
542 
543  if (std::fabs(eigenValues.GetX()) < std::numeric_limits<float>::epsilon())
544  {
545  std::cout << "PcaShowerParticleBuildingAlgorithm::OpeningAngle - principal eigenvalue less than or equal to 0." << std::endl;
546  throw StatusCodeException( STATUS_CODE_INVALID_PARAMETER );
547  }
548  else if (std::fabs(eigenValues.GetY()) < std::numeric_limits<float>::epsilon())
549  {
550  return 0.f;
551  }
552 
553  return std::atan(std::sqrt(eigenValues.GetY()) * sinTheta / std::sqrt(eigenValues.GetX()));
554 }
TFile f
Definition: plotHisto.C:6
StatusCode lar_content::ThreeDOpeningAngleFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 557 of file TrackShowerIdFeatureTool.cc.

558 {
559  return STATUS_CODE_SUCCESS;
560 }
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::ThreeDOpeningAngleFeatureTool::Run ( LArMvaHelper::MvaFeatureVector featureVector,
const pandora::Algorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pInputPfo 
)

Definition at line 447 of file TrackShowerIdFeatureTool.cc.

References f, lar_content::LArPfoHelper::GetCaloHits(), lar_content::LArPfoHelper::GetThreeDClusterList(), and lar_content::LArPcaHelper::RunPca().

449 {
450  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
451  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
452 
453  // Need the 3D clusters and hits to calculate PCA components
454  ClusterList threeDClusterList;
455  LArPfoHelper::GetThreeDClusterList(pInputPfo, threeDClusterList);
456 
457  CaloHitList threeDCaloHitList;
458  LArPfoHelper::GetCaloHits(pInputPfo, TPC_3D, threeDCaloHitList);
459 
460  LArMvaHelper::MvaFeature diffAngle;
461  if (!threeDCaloHitList.empty())
462  {
463  CartesianPointVector pointVectorStart, pointVectorEnd;
464  this->Divide3DCaloHitList(pAlgorithm, threeDCaloHitList, pointVectorStart, pointVectorEnd);
465 
466  //able to calculate angles only if > 1 point provided
467  if ((pointVectorStart.size() > 1) && (pointVectorEnd.size() > 1))
468  {
469  try
470  {
471  // Run the PCA analysis twice
472  CartesianVector centroidStart(0.f, 0.f, 0.f), centroidEnd(0.f, 0.f, 0.f);
473  LArPcaHelper::EigenVectors eigenVecsStart, eigenVecsEnd;
474  LArPcaHelper::EigenValues eigenValuesStart(0.f, 0.f, 0.f), eigenValuesEnd(0.f, 0.f, 0.f);
475 
476  LArPcaHelper::RunPca(pointVectorStart, centroidStart, eigenValuesStart, eigenVecsStart);
477  LArPcaHelper::RunPca(pointVectorEnd, centroidEnd, eigenValuesEnd, eigenVecsEnd);
478 
479  const float openingAngle(this->OpeningAngle(eigenVecsStart.at(0), eigenVecsStart.at(1), eigenValuesStart));
480  const float closingAngle(this->OpeningAngle(eigenVecsEnd.at(0), eigenVecsEnd.at(1), eigenValuesEnd));
481  diffAngle = std::fabs(openingAngle-closingAngle);
482  }
483  catch (const StatusCodeException &){}
484  }
485  }
486 
487  featureVector.push_back(diffAngle);
488 }
pandora::CartesianVector EigenValues
Definition: LArPcaHelper.h:21
MvaTypes::MvaFeature MvaFeature
Definition: LArMvaHelper.h:57
TFile f
Definition: plotHisto.C:6
float OpeningAngle(const pandora::CartesianVector &principal, const pandora::CartesianVector &secondary, const pandora::CartesianVector &eigenValues) const
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
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:22
void Divide3DCaloHitList(const pandora::Algorithm *const pAlgorithm, pandora::CaloHitList &threeDCaloHitList, pandora::CartesianPointVector &pointVectorStart, pandora::CartesianPointVector &pointVectorEnd)
static void GetCaloHits(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::CaloHitList &caloHitList)
Get a list of calo hits of a particular hit type from a list of pfos.

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