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

Slice features class. More...

Public Member Functions

 SliceFeatures (const pandora::PfoList &nuPfos, const pandora::PfoList &crPfos, const SliceFeatureParameters &sliceFeatureParameters)
 Constructor. More...
 
 SliceFeatures (const SliceFeatures &)=default
 Copy constructor. More...
 
 ~SliceFeatures ()=default
 Destructor. More...
 
bool IsFeatureVectorAvailable () const
 Check if all features were calculable. More...
 
void FillFeatureVector (LArMvaHelper::MvaFeatureVector &featureVector) const
 Get the feature vector for the SVM. More...
 
float GetAdaBoostDecisionTreeScore (const AdaBoostDecisionTree &adaBoostDecisionTree) const
 Get the probability that this slice contains a beam particle. More...
 

Private Member Functions

void GetLeadingCaloHits (const pandora::CaloHitList &inputCaloHitList, pandora::CaloHitList &outputCaloHitList, double &closestHitToFaceDistance) const
 Select a given fraction of a slice's calo hits that are closest to the beam spot. More...
 
void GetLArTPCIntercepts (const pandora::CartesianVector &a0, const pandora::CartesianVector &majorAxis, pandora::CartesianVector &interceptOne, pandora::CartesianVector &interceptTwo) const
 Find the intercepts of a line with the protoDUNE detector. More...
 
bool IsContained (const pandora::CartesianVector &spacePoint, const float limit) const
 Check if a given 3D spacepoint is inside the global LArTPC volume. More...
 

Private Attributes

bool m_isAvailable
 Is the feature vector available. More...
 
const SliceFeatureParameters m_sliceFeatureParameters
 Geometry information block. More...
 
LArMvaHelper::MvaFeatureVector m_featureVector
 The MVA feature vector. More...
 

Detailed Description

Slice features class.

Definition at line 221 of file BdtBeamParticleIdTool.h.

Constructor & Destructor Documentation

lar_content::BdtBeamParticleIdTool::SliceFeatures::SliceFeatures ( const pandora::PfoList &  nuPfos,
const pandora::PfoList &  crPfos,
const SliceFeatureParameters sliceFeatureParameters 
)

Constructor.

Parameters
nuPfosinput list of Pfos reconstructed under the neutrino hypothesis
crPfosinput list of Pfos reconstructed under the cosmic ray hypothesis
geometryInfogeometry information block
lar_content::BdtBeamParticleIdTool::SliceFeatures::SliceFeatures ( const SliceFeatures )
default

Copy constructor.

Parameters
TheSliceFeatures to copy
lar_content::BdtBeamParticleIdTool::SliceFeatures::~SliceFeatures ( )
default

Destructor.

Member Function Documentation

void lar_content::BdtBeamParticleIdTool::SliceFeatures::FillFeatureVector ( LArMvaHelper::MvaFeatureVector featureVector) const

Get the feature vector for the SVM.

Parameters
featuresVectorempty feature vector to populate

Definition at line 651 of file BdtBeamParticleIdTool.cc.

652 {
653  if (!m_isAvailable)
654  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
655 
656  if (!featureVector.empty())
657  {
658  std::cout << "BdtBeamParticleIdTool::SliceFeatures::FillFeatureVector - feature vector already populated" << std::endl;
659  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
660  }
661 
662  featureVector.insert(featureVector.end(), m_featureVector.begin(), m_featureVector.end());
663 }
bool m_isAvailable
Is the feature vector available.
LArMvaHelper::MvaFeatureVector m_featureVector
The MVA feature vector.
BEGIN_PROLOG could also be cout
float lar_content::BdtBeamParticleIdTool::SliceFeatures::GetAdaBoostDecisionTreeScore ( const AdaBoostDecisionTree adaBoostDecisionTree) const

Get the probability that this slice contains a beam particle.

Parameters
adaBoostDecisionTreethe adaptive boost decision tree used to calculate the probability
Returns
the probability that the slice contains a beam particle

Definition at line 667 of file BdtBeamParticleIdTool.cc.

668 {
669  // ATTN if one or more of the features can not be calculated, then default to calling the slice a cosmic ray. -1.f is the minimum score
670  // possible for a weighted bdt.
671  if (!this->IsFeatureVectorAvailable())
672  return -1.f;
673 
674  LArMvaHelper::MvaFeatureVector featureVector;
675 
676  try
677  {
678  this->FillFeatureVector(featureVector);
679  }
680  catch (const StatusCodeException &statusCodeException)
681  {
682  std::cout << "BdtBeamParticleIdTool::SliceFeatures::GetAdaBoostDecisionTreeScore - unable to fill feature vector" << std::endl;
683  return -1.f;
684  }
685 
686  return LArMvaHelper::CalculateClassificationScore(adaBoostDecisionTree, featureVector);
687 }
MvaTypes::MvaFeatureVector MvaFeatureVector
Definition: LArMvaHelper.h:72
void FillFeatureVector(LArMvaHelper::MvaFeatureVector &featureVector) const
Get the feature vector for the SVM.
bool IsFeatureVectorAvailable() const
Check if all features were calculable.
static double CalculateClassificationScore(const MvaInterface &classifier, TCONTAINER &&featureContainer)
Use the trained classifer to calculate the classification score of an example (&gt;0 means boolean class...
Definition: LArMvaHelper.h:358
BEGIN_PROLOG could also be cout
void lar_content::BdtBeamParticleIdTool::SliceFeatures::GetLArTPCIntercepts ( const pandora::CartesianVector &  a0,
const pandora::CartesianVector &  majorAxis,
pandora::CartesianVector &  interceptOne,
pandora::CartesianVector &  interceptTwo 
) const
private

Find the intercepts of a line with the protoDUNE detector.

Parameters
a0a point on the line in question
majorAxisthe direction of the line in question
interceptOneto receive the first intersection between line and protoDUNE detector
interceptTwoto receive the second intersection between line and protoDUNE detector

Definition at line 570 of file BdtBeamParticleIdTool.cc.

572 {
573  CartesianPointVector intercepts;
574  CartesianVector lineUnitVector(0.f, 0.f, 0.f);
575 
576  try
577  {
578  lineUnitVector = lineDirection.GetUnitVector();
579  }
580  catch (const StatusCodeException &statusCodeException)
581  {
582  std::cout << "BdtBeamParticleIdTool::SliceFeatures::GetLArTPCIntercepts - normal vector to plane has a magnitude of zero" << std::endl;
583  throw statusCodeException;
584  }
585 
586  for (const Plane &plane : m_sliceFeatureParameters.GetPlanes())
587  {
588  const CartesianVector intercept(plane.GetLineIntersection(a0, lineUnitVector));
589 
591  intercepts.push_back(intercept);
592  }
593 
594  if (intercepts.size() > 1)
595  {
596  float maximumSeparationSquared(0.f);
597  bool interceptsSet(false);
598 
599  for (unsigned int i = 0; i < intercepts.size(); i++)
600  {
601  for (unsigned int j = i + 1; j < intercepts.size(); j++)
602  {
603  const CartesianVector &candidateInterceptOne(intercepts.at(i));
604  const CartesianVector &candidateInterceptTwo(intercepts.at(j));
605  const float separationSquared((candidateInterceptOne - candidateInterceptTwo).GetMagnitudeSquared());
606 
607  if (separationSquared > maximumSeparationSquared)
608  {
609  maximumSeparationSquared = separationSquared;
610  interceptOne = candidateInterceptOne;
611  interceptTwo = candidateInterceptTwo;
612  interceptsSet = true;
613  }
614  }
615  }
616 
617  if (!interceptsSet)
618  {
619  std::cout << "BdtBeamParticleIdTool::SliceFeatures::GetLArTPCIntercepts - unable to set the intercepts between a line and the LArTPC"
620  << std::endl;
621  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
622  }
623  }
624  else
625  {
626  std::cout << "BdtBeamParticleIdTool::SliceFeatures::GetLArTPCIntercepts - inconsistent number of intercepts between a line and the LArTPC"
627  << std::endl;
628  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
629  }
630 }
BEGIN_PROLOG true icarus_rawdigitfilter FilterTools FilterPlane1 Plane
const SliceFeatureParameters m_sliceFeatureParameters
Geometry information block.
#define a0
bool IsContained(const pandora::CartesianVector &spacePoint, const float limit) const
Check if a given 3D spacepoint is inside the global LArTPC volume.
const PlaneVector & GetPlanes() const
Get vector of planes.
BEGIN_PROLOG could also be cout
void lar_content::BdtBeamParticleIdTool::SliceFeatures::GetLeadingCaloHits ( const pandora::CaloHitList &  inputCaloHitList,
pandora::CaloHitList &  outputCaloHitList,
double &  closestHitToFaceDistance 
) const
private

Select a given fraction of a slice's calo hits that are closest to the beam spot.

Parameters
inputCaloHitListall calo hits in slice
outputCaloHitListto receive the list of selected calo hits
closestHitToFaceDistanceto receive the distance of closest hit to beam spot

Definition at line 525 of file BdtBeamParticleIdTool.cc.

527 {
528  if (inputCaloHitList.empty())
529  {
530  std::cout << "BdtBeamParticleIdTool::SliceFeatures::GetLeadingCaloHits - empty calo hit list" << std::endl;
531  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
532  }
533 
534  typedef std::pair<const CaloHit *, float> HitDistancePair;
535  typedef std::vector<HitDistancePair> HitDistanceVector;
536  HitDistanceVector hitDistanceVector;
537 
538  for (const CaloHit *const pCaloHit : inputCaloHitList)
539  hitDistanceVector.emplace_back(
540  pCaloHit, (pCaloHit->GetPositionVector() - m_sliceFeatureParameters.GetBeamLArTPCIntersection()).GetMagnitudeSquared());
541 
542  std::sort(hitDistanceVector.begin(), hitDistanceVector.end(),
543  [](const HitDistancePair &lhs, const HitDistancePair &rhs) -> bool { return (lhs.second < rhs.second); });
544 
545  if (hitDistanceVector.front().second < 0.f)
546  {
547  std::cout << "BdtBeamParticleIdTool::SliceFeatures::GetLeadingCaloHits - unphysical magnitude of a vector" << std::endl;
548  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
549  }
550 
551  closestHitToFaceDistance = std::sqrt(hitDistanceVector.front().second);
552 
553  const unsigned int nInputHits(inputCaloHitList.size());
554  const unsigned int nSelectedCaloHits(
556  ? nInputHits
557  : static_cast<unsigned int>(std::ceil(static_cast<float>(nInputHits) * m_sliceFeatureParameters.GetSelectedFraction() / 100.f)));
558 
559  for (const HitDistancePair &hitDistancePair : hitDistanceVector)
560  {
561  outputCaloHitList.push_back(hitDistancePair.first);
562 
563  if (outputCaloHitList.size() >= nSelectedCaloHits)
564  break;
565  }
566 }
const SliceFeatureParameters m_sliceFeatureParameters
Geometry information block.
unsigned int GetNSelectedHits() const
Get m_nSelectedHits.
const pandora::CartesianVector & GetBeamLArTPCIntersection() const
Get the beam LArTPC intersection.
BEGIN_PROLOG could also be cout
bool lar_content::BdtBeamParticleIdTool::SliceFeatures::IsContained ( const pandora::CartesianVector &  spacePoint,
const float  limit 
) const
private

Check if a given 3D spacepoint is inside the global LArTPC volume.

Parameters
spacePoint

Definition at line 634 of file BdtBeamParticleIdTool.cc.

635 {
636  if ((m_sliceFeatureParameters.GetLArTPCMinX() - spacePoint.GetX() > limit) ||
637  (spacePoint.GetX() - m_sliceFeatureParameters.GetLArTPCMaxX() > limit) ||
638  (m_sliceFeatureParameters.GetLArTPCMinY() - spacePoint.GetY() > limit) ||
639  (spacePoint.GetY() - m_sliceFeatureParameters.GetLArTPCMaxY() > limit) ||
640  (m_sliceFeatureParameters.GetLArTPCMinZ() - spacePoint.GetZ() > limit) ||
641  (spacePoint.GetZ() - m_sliceFeatureParameters.GetLArTPCMaxZ() > limit))
642  {
643  return false;
644  }
645 
646  return true;
647 }
const SliceFeatureParameters m_sliceFeatureParameters
Geometry information block.
bool lar_content::BdtBeamParticleIdTool::SliceFeatures::IsFeatureVectorAvailable ( ) const
inline

Check if all features were calculable.

Returns
true if the feature vector is available

Definition at line 524 of file BdtBeamParticleIdTool.h.

525 {
526  return m_isAvailable;
527 }
bool m_isAvailable
Is the feature vector available.

Member Data Documentation

LArMvaHelper::MvaFeatureVector lar_content::BdtBeamParticleIdTool::SliceFeatures::m_featureVector
private

The MVA feature vector.

Definition at line 299 of file BdtBeamParticleIdTool.h.

bool lar_content::BdtBeamParticleIdTool::SliceFeatures::m_isAvailable
private

Is the feature vector available.

Definition at line 297 of file BdtBeamParticleIdTool.h.

const SliceFeatureParameters lar_content::BdtBeamParticleIdTool::SliceFeatures::m_sliceFeatureParameters
private

Geometry information block.

Definition at line 298 of file BdtBeamParticleIdTool.h.


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