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

ShowerRegionFeatureTool to calculate variables related to the shower region. More...

#include "ConnectionPathwayFeatureTool.h"

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

Public Types

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

Public Member Functions

 ShowerRegionFeatureTool ()
 Default constructor. More...
 
void Run (LArMvaHelper::MvaFeatureVector &featureVector, const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pShowerPfo, const pandora::CartesianVector &nuVertex3D, const ProtoShowerMatch &protoShowerMatch, const pandora::CartesianPointVector &showerStarts3D)
 
void Run (LArMvaHelper::MvaFeatureMap &featureMap, pandora::StringVector &featureOrder, const std::string &featureToolName, const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pShowerPfo, const pandora::CartesianVector &nuVertex3D, const ProtoShowerMatch &protoShowerMatch, const pandora::CartesianPointVector &showerStarts3D)
 
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 GetViewShowerRegionVariables (const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pShowerPfo, const pandora::CartesianVector &nuVertex3D, const ProtoShowerMatch &protoShowerMatch, const pandora::HitType hitType, const pandora::CartesianVector &showerStart3D, float &nHits, float &foundHitRatio, float &scatterAngle, float &openingAngle, float &nuVertexEnergyAsymmetry, float &nuVertexEnergyWeightedMeanRadialDistance, float &showerStartEnergyAsymmetry, float &showerStartMoliereRadius)
 Calculate the shower region variables for the input view. More...
 
void BuildViewShower (const pandora::ParticleFlowObject *const pShowerPfo, const TwoDSlidingFitResult &spineFit, const pandora::HitType hitType, const pandora::CartesianVector &showerStart2D, const pandora::CartesianVector &nuVertex2D, pandora::CaloHitList &postShowerHitList, pandora::CartesianPointVector &postShowerPositions)
 Collect the shower region hits in a given view. More...
 
void GetShowerHitVariables (const pandora::CaloHitList &spineHitList, const pandora::CaloHitList &postShowerHitList, const pandora::ParticleFlowObject *const pShowerPfo, const pandora::HitType hitType, float &nHits, float &foundHitRatio)
 Evaluate the variables associated with the shower region hit multiplicity. More...
 
void CalculateViewScatterAngle (const pandora::CartesianVector &nuVertex2D, const TwoDSlidingFitResult &spineFitResult, const pandora::CartesianVector &showerStart2D, const TwoDSlidingFitResult &showerFitResult, float &scatterAngle)
 Calculate the connection pathway-shower region scatter angle. More...
 
void CalculateViewOpeningAngle (const TwoDSlidingFitResult &showerFitResult, const pandora::CaloHitList &postShowerHitList, const pandora::CartesianVector &showerStart2D, float &openingAngle)
 Calculate the opening angle of the shower region. More...
 
void CalculateViewNuVertexConsistencyVariables (const TwoDSlidingFitResult &spineFitResult, const pandora::CaloHitList &postShowerHitList, const bool isDownstream, const pandora::CartesianVector &nuVertex2D, float &nuVertexEnergyAsymmetry, float &nuVertexEnergyWeightedMeanRadialDistance)
 Evaluate the neutrino vertex consistency variables. More...
 
void CalculateViewShowerStartConsistencyVariables (const TwoDSlidingFitResult &showerFitResult, const pandora::CaloHitList &postShowerHitList, const bool isShowerDownstream, float &showerStartEnergyAsymmetry, float &showerStartMoliereRadius)
 Evaluate the shower start consistency variables. More...
 

Private Attributes

float m_defaultFloat
 Default float value. More...
 
float m_defaultRatio
 Default float value for ratios. More...
 
unsigned int m_spineFitWindow
 The spine fit window. More...
 
float m_showerRadius
 The max. separation distance between a shower region hit and the shower core. More...
 
unsigned int m_showerFitWindow
 The shower fit window. More...
 
float m_edgeStep
 The binning of the shower boundaries. More...
 
float m_moliereFraction
 The energy fraction which corresponds to minShowerStartMoliereRadius. More...
 
float m_maxNHitsLimit
 maxNHits max. limit More...
 
float m_maxFoundHitRatioLimit
 maxFoundHitRatio max. limit More...
 
float m_maxScatterAngleLimit
 maxScatterAngle max. limit More...
 
float m_maxOpeningAngleLimit
 maxOpeningAngle max. limit More...
 
float m_maxNuVertexEnergyWeightedMeanRadialDistanceLimit
 maxNuVertexEnergyWeightedMeanRadialDistance max. limit More...
 
float m_minShowerStartMoliereRadiusLimit
 minShowerStartMoliereRadius max. limit More...
 

Detailed Description

ShowerRegionFeatureTool to calculate variables related to the shower region.

Definition at line 128 of file ConnectionPathwayFeatureTool.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::ShowerRegionFeatureTool::ShowerRegionFeatureTool ( )

Default constructor.

Definition at line 335 of file ConnectionPathwayFeatureTool.cc.

References lar_content::LArConnectionPathwayHelper::GetMinMiddleMax(), GetViewShowerRegionVariables(), m_defaultFloat, m_defaultRatio, m_maxFoundHitRatioLimit, m_maxNHitsLimit, m_maxNuVertexEnergyWeightedMeanRadialDistanceLimit, m_maxOpeningAngleLimit, m_maxScatterAngleLimit, m_minShowerStartMoliereRadiusLimit, and Run().

335  :
336  m_defaultFloat(-10.f),
337  m_defaultRatio(-0.5f),
338  m_spineFitWindow(20),
339  m_showerRadius(14.f),
340  m_showerFitWindow(1000),
341  m_edgeStep(2.f),
342  m_moliereFraction(0.9f),
343  m_maxNHitsLimit(2000.f),
349 {
350 }
float m_edgeStep
The binning of the shower boundaries.
float m_maxFoundHitRatioLimit
maxFoundHitRatio max. limit
float m_maxNuVertexEnergyWeightedMeanRadialDistanceLimit
maxNuVertexEnergyWeightedMeanRadialDistance max. limit
float m_maxOpeningAngleLimit
maxOpeningAngle max. limit
float m_maxScatterAngleLimit
maxScatterAngle max. limit
unsigned int m_showerFitWindow
The shower fit window.
unsigned int m_spineFitWindow
The spine fit window.
TFile f
Definition: plotHisto.C:6
float m_defaultRatio
Default float value for ratios.
float m_showerRadius
The max. separation distance between a shower region hit and the shower core.
float m_moliereFraction
The energy fraction which corresponds to minShowerStartMoliereRadius.
float m_minShowerStartMoliereRadiusLimit
minShowerStartMoliereRadius max. limit

Member Function Documentation

void lar_content::ShowerRegionFeatureTool::BuildViewShower ( const pandora::ParticleFlowObject *const  pShowerPfo,
const TwoDSlidingFitResult spineFit,
const pandora::HitType  hitType,
const pandora::CartesianVector &  showerStart2D,
const pandora::CartesianVector &  nuVertex2D,
pandora::CaloHitList &  postShowerHitList,
pandora::CartesianPointVector &  postShowerPositions 
)
private

Collect the shower region hits in a given view.

Parameters
pShowerPfothe shower pfo
spineFitthe shower spine fit
hitTypethe 2D view
showerStart2Dthe 2D shower start position
nuVertex2Dthe 2D neutrino vertex position
postShowerHitListthe collected shower region hit list
postShowerPositionsthe collected shower region hit position vector

Definition at line 579 of file ConnectionPathwayFeatureTool.cc.

References f, lar_content::LArPfoHelper::GetCaloHits(), lar_content::TwoDSlidingFitResult::GetGlobalDirection(), lar_content::TwoDSlidingFitResult::GetLayer(), lar_content::TwoDSlidingFitResult::GetLayerFitResultMap(), lar_content::TwoDSlidingFitResult::GetLocalPosition(), and m_showerRadius.

Referenced by GetViewShowerRegionVariables().

581 {
582  // Find initial shower direction from spine fit
583  float lShowerStart(0.f), tShowerStart(0.f);
584  spineFit.GetLocalPosition(showerStart2D, lShowerStart, tShowerStart);
585 
586  const LayerFitResultMap &layerFitResultMap(spineFit.GetLayerFitResultMap());
587  const int showerStartLayer(spineFit.GetLayer(lShowerStart));
588  int closestLayer(std::numeric_limits<int>::max());
589 
590  for (const auto &entry : layerFitResultMap)
591  {
592  if (std::fabs(entry.first - showerStartLayer) < std::fabs(entry.first - closestLayer))
593  closestLayer = entry.first;
594  }
595 
596  const float gradient(layerFitResultMap.at(closestLayer).GetGradient());
597  CartesianVector showerDirection(0.f, 0.f, 0.f);
598 
599  spineFit.GetGlobalDirection(gradient, showerDirection);
600 
601  // Now find the shower
602  const bool isDownstream(showerStart2D.GetZ() > nuVertex2D.GetZ());
603  CaloHitList caloHitList;
604 
605  LArPfoHelper::GetCaloHits(pShowerPfo, hitType, caloHitList);
606 
607  for (const CaloHit *const pCaloHit : caloHitList)
608  {
609  const CartesianVector &hitPosition(pCaloHit->GetPositionVector());
610  const CartesianVector displacement(hitPosition - showerStart2D);
611  const float l(showerDirection.GetDotProduct(displacement));
612  const float t(showerDirection.GetCrossProduct(displacement).GetMagnitude());
613 
614  if (((isDownstream && (l > 0.f)) || (!isDownstream && (l < 0.f))) && (t < m_showerRadius))
615  {
616  postShowerHitList.push_back(pCaloHit);
617  postShowerPositions.push_back(pCaloHit->GetPositionVector());
618  }
619  }
620 }
TFile f
Definition: plotHisto.C:6
float m_showerRadius
The max. separation distance between a shower region hit and the shower core.
std::map< int, LayerFitResult > LayerFitResultMap
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.
void lar_content::ShowerRegionFeatureTool::CalculateViewNuVertexConsistencyVariables ( const TwoDSlidingFitResult spineFitResult,
const pandora::CaloHitList &  postShowerHitList,
const bool  isDownstream,
const pandora::CartesianVector &  nuVertex2D,
float &  nuVertexEnergyAsymmetry,
float &  nuVertexEnergyWeightedMeanRadialDistance 
)
private

Evaluate the neutrino vertex consistency variables.

Parameters
spineHitListthe shower spine hit list
postShowerHitListthe collected shower region hit list
isDownstreamwhether the shower direction is downstream (in Z) of the neutrino vertex
nuVertex2Dthe 2D neutrino vertex
nuVertexEnergyAsymmetrythe output neutrino vertex energy asymmetry
nuVertexEnergyWeightedMeanRadialDistancethe output neutrino vertex energy weighted mean radial distance

Definition at line 725 of file ConnectionPathwayFeatureTool.cc.

References f, lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerDirection(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerDirection(), m_defaultFloat, and m_defaultRatio.

Referenced by GetViewShowerRegionVariables().

727 {
728  const CartesianVector &directionAxis(isDownstream ? spineFitResult.GetGlobalMinLayerDirection() : spineFitResult.GetGlobalMaxLayerDirection());
729  const CartesianVector orthoAxis = directionAxis.GetCrossProduct(CartesianVector(0.f, 1.f, 0.f));
730 
731  float totalEnergy(0.f);
732 
733  // nuVertexEnergyAsymmetry
734  nuVertexEnergyAsymmetry = 0.f;
735 
736  for (const CaloHit *const pCaloHit : postShowerHitList)
737  {
738  const float hitEnergy(std::fabs(pCaloHit->GetElectromagneticEnergy()));
739 
740  totalEnergy += hitEnergy;
741 
742  const CartesianVector position(pCaloHit->GetPositionVector() - nuVertex2D);
743  const float thisL(orthoAxis.GetDotProduct(position));
744 
745  nuVertexEnergyAsymmetry += (thisL < 0.f) ? (-1.f * hitEnergy) : hitEnergy;
746  }
747 
748  nuVertexEnergyAsymmetry = (totalEnergy < std::numeric_limits<float>::epsilon()) ? m_defaultRatio : (nuVertexEnergyAsymmetry / totalEnergy);
749  nuVertexEnergyAsymmetry = std::fabs(nuVertexEnergyAsymmetry);
750 
751  // nuVertexEnergyWeightedMeanRadialDistance
752  nuVertexEnergyWeightedMeanRadialDistance = 0.f;
753 
754  for (const CaloHit *const pCaloHit : postShowerHitList)
755  {
756  const CartesianVector position(pCaloHit->GetPositionVector() - nuVertex2D);
757  const float hitEnergy(std::fabs(pCaloHit->GetElectromagneticEnergy()));
758 
759  nuVertexEnergyWeightedMeanRadialDistance += (directionAxis.GetCrossProduct(position).GetMagnitude() * hitEnergy);
760  }
761 
762  nuVertexEnergyWeightedMeanRadialDistance =
763  (totalEnergy < std::numeric_limits<float>::epsilon()) ? m_defaultFloat : nuVertexEnergyWeightedMeanRadialDistance / totalEnergy;
764 }
TFile f
Definition: plotHisto.C:6
float m_defaultRatio
Default float value for ratios.
void lar_content::ShowerRegionFeatureTool::CalculateViewOpeningAngle ( const TwoDSlidingFitResult showerFitResult,
const pandora::CaloHitList &  postShowerHitList,
const pandora::CartesianVector &  showerStart2D,
float &  openingAngle 
)
private

Calculate the opening angle of the shower region.

Parameters
showerFitResultthe shower region fit
postShowerHitListthe collected shower region hit list
showerStart2Dthe 2D shower start position
openingAnglethe output opening angle

Definition at line 661 of file ConnectionPathwayFeatureTool.cc.

References f, lar_content::TwoDSlidingFitResult::GetGlobalMinLayerDirection(), lar_content::TwoDSlidingFitResult::GetLayerPitch(), m_edgeStep, and m_showerFitWindow.

Referenced by GetViewShowerRegionVariables().

663 {
664  try
665  {
666  const CartesianVector directionAxis = showerFitResult.GetGlobalMinLayerDirection();
667  const CartesianVector orthoAxis = directionAxis.GetCrossProduct(CartesianVector(0.f, 1.f, 0.f));
668 
669  std::map<int, float> positiveEdges, negativeEdges;
670 
671  for (const CaloHit *const pCaloHit : postShowerHitList)
672  {
673  const CartesianVector position(pCaloHit->GetPositionVector() - showerStart2D);
674  const float thisT(directionAxis.GetCrossProduct(position).GetMagnitude());
675  const float thisL(directionAxis.GetDotProduct(position));
676  const float orthoL(orthoAxis.GetDotProduct(position));
677 
678  std::map<int, float> &edgeMap(orthoL > 0.f ? positiveEdges : negativeEdges);
679 
680  const int lIndex(std::floor(thisL / m_edgeStep));
681 
682  edgeMap[lIndex] = (edgeMap.find(lIndex) == edgeMap.end() ? thisT : std::max(edgeMap[lIndex], thisT));
683  }
684 
685  CartesianPointVector positiveEdgePositions, negativeEdgePositions;
686 
687  for (auto &entry : positiveEdges)
688  positiveEdgePositions.push_back(CartesianVector(entry.second, 0.f, entry.first));
689 
690  for (auto &entry : negativeEdges)
691  negativeEdgePositions.push_back(CartesianVector(entry.second, 0.f, entry.first));
692 
693  const TwoDSlidingFitResult positiveEdgeFit(&positiveEdgePositions, m_showerFitWindow, showerFitResult.GetLayerPitch());
694  const TwoDSlidingFitResult negativeEdgeFit(&negativeEdgePositions, m_showerFitWindow, showerFitResult.GetLayerPitch());
695 
696  const CartesianVector positiveMinLayer(positiveEdgeFit.GetGlobalMinLayerPosition());
697  const CartesianVector positiveMaxLayer(positiveEdgeFit.GetGlobalMaxLayerPosition());
698  const CartesianVector negativeMinLayer(negativeEdgeFit.GetGlobalMinLayerPosition());
699  const CartesianVector negativeMaxLayer(negativeEdgeFit.GetGlobalMaxLayerPosition());
700 
701  const CartesianVector globalPositiveMinLayer(
702  showerStart2D + (directionAxis * positiveMinLayer.GetZ()) + (orthoAxis * positiveMinLayer.GetX()));
703  const CartesianVector globalPositiveMaxLayer(
704  showerStart2D + (directionAxis * positiveMaxLayer.GetZ()) + (orthoAxis * positiveMaxLayer.GetX()));
705  const CartesianVector globalNegativeMinLayer(
706  showerStart2D + (directionAxis * negativeMinLayer.GetZ()) - (orthoAxis * negativeMinLayer.GetX()));
707  const CartesianVector globalNegativeMaxLayer(
708  showerStart2D + (directionAxis * negativeMaxLayer.GetZ()) - (orthoAxis * negativeMaxLayer.GetX()));
709 
710  const CartesianVector positiveEdgeVector((globalPositiveMaxLayer - globalPositiveMinLayer).GetUnitVector());
711  const CartesianVector negativeEdgeVector((globalNegativeMaxLayer - globalNegativeMinLayer).GetUnitVector());
712 
713  const float positiveOpeningAngle = directionAxis.GetOpeningAngle(positiveEdgeVector) * 180.f / M_PI;
714  const float negativeOpeningAngle = directionAxis.GetOpeningAngle(negativeEdgeVector) * 180.f / M_PI;
715 
716  openingAngle = std::max(positiveOpeningAngle, negativeOpeningAngle);
717  }
718  catch (...)
719  {
720  }
721 }
float m_edgeStep
The binning of the shower boundaries.
unsigned int m_showerFitWindow
The shower fit window.
TFile f
Definition: plotHisto.C:6
void lar_content::ShowerRegionFeatureTool::CalculateViewScatterAngle ( const pandora::CartesianVector &  nuVertex2D,
const TwoDSlidingFitResult spineFitResult,
const pandora::CartesianVector &  showerStart2D,
const TwoDSlidingFitResult showerFitResult,
float &  scatterAngle 
)
private

Calculate the connection pathway-shower region scatter angle.

Parameters
nuVertex2Dthe 2D neutrino vertex
spineFitResultthe shower spine fit
showerStart2Dthe 2D shower start position
showerFitResultthe shower region fit
scatterAnglethe output scatter angle

Definition at line 644 of file ConnectionPathwayFeatureTool.cc.

References lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerDirection(), lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerDirection(), and lar_content::TwoDSlidingFitResult::GetGlobalMinLayerPosition().

Referenced by GetViewShowerRegionVariables().

646 {
647  const bool isDownstream(showerStart2D.GetZ() > nuVertex2D.GetZ());
648  const CartesianVector streamCorrectedConnectionPathwayDirection(
649  isDownstream ? spineFitResult.GetGlobalMinLayerDirection() : spineFitResult.GetGlobalMaxLayerDirection() * (-1.f));
650 
651  const bool isShowerDownstream((showerStart2D - showerFitResult.GetGlobalMinLayerPosition()).GetMagnitude() <
652  (showerStart2D - showerFitResult.GetGlobalMaxLayerPosition()).GetMagnitude());
653  const CartesianVector streamCorrectedShowerDirection(
654  isShowerDownstream ? showerFitResult.GetGlobalMinLayerDirection() : showerFitResult.GetGlobalMaxLayerDirection() * (-1.f));
655 
656  scatterAngle = streamCorrectedConnectionPathwayDirection.GetOpeningAngle(streamCorrectedShowerDirection) * 180.f / M_PI;
657 }
void lar_content::ShowerRegionFeatureTool::CalculateViewShowerStartConsistencyVariables ( const TwoDSlidingFitResult showerFitResult,
const pandora::CaloHitList &  postShowerHitList,
const bool  isShowerDownstream,
float &  showerStartEnergyAsymmetry,
float &  showerStartMoliereRadius 
)
private

Evaluate the shower start consistency variables.

Parameters
showerFitResultthe shower fit result
postShowerHitListthe collected shower region hit list
isShowerDownstreamwhether the shower direction is downstream (in Z) of the neutrino vertex
showerStartEnergyAsymmetrythe output shower start energy asymmetry
showerStartMoliereRadiusthe output shower start moliere radius

Definition at line 768 of file ConnectionPathwayFeatureTool.cc.

References f, lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerDirection(), lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerDirection(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerPosition(), m_defaultFloat, m_defaultRatio, and m_moliereFraction.

Referenced by GetViewShowerRegionVariables().

770 {
771  const CartesianVector fitShowerStart(isShowerDownstream ? showerFitResult.GetGlobalMinLayerPosition() : showerFitResult.GetGlobalMaxLayerPosition());
772  const CartesianVector directionAxis(
773  isShowerDownstream ? showerFitResult.GetGlobalMinLayerDirection() : showerFitResult.GetGlobalMaxLayerDirection());
774  const CartesianVector orthoAxis = directionAxis.GetCrossProduct(CartesianVector(0.f, 1.f, 0.f));
775 
776  float totalEnergy(0.f);
777 
778  // showerStartEnergyAsymmetry
779  showerStartEnergyAsymmetry = 0.f;
780 
781  for (const CaloHit *const pCaloHit : postShowerHitList)
782  {
783  const float hitEnergy(std::fabs(pCaloHit->GetElectromagneticEnergy()));
784 
785  totalEnergy += hitEnergy;
786 
787  const CartesianVector position(pCaloHit->GetPositionVector() - fitShowerStart);
788  const float thisL(orthoAxis.GetDotProduct(position));
789 
790  showerStartEnergyAsymmetry += (thisL < 0.f) ? (-1.f * hitEnergy) : hitEnergy;
791  }
792 
793  showerStartEnergyAsymmetry = (totalEnergy < std::numeric_limits<float>::epsilon()) ? m_defaultRatio : (showerStartEnergyAsymmetry / totalEnergy);
794  showerStartEnergyAsymmetry = std::fabs(showerStartEnergyAsymmetry);
795 
796  // showerStartMoliereRadius
797  showerStartMoliereRadius = m_defaultFloat;
798 
799  CaloHitVector showerStartPostShowerHitVector(postShowerHitList.begin(), postShowerHitList.end());
800 
801  std::sort(showerStartPostShowerHitVector.begin(), showerStartPostShowerHitVector.end(),
802  [&fitShowerStart, &directionAxis](const CaloHit *const pCaloHitA, const CaloHit *const pCaloHitB) -> bool
803  {
804  const CartesianVector positionA(pCaloHitA->GetPositionVector() - fitShowerStart);
805  const CartesianVector positionB(pCaloHitB->GetPositionVector() - fitShowerStart);
806 
807  const float tA(directionAxis.GetCrossProduct(positionA).GetMagnitude());
808  const float tB(directionAxis.GetCrossProduct(positionB).GetMagnitude());
809 
810  return tA < tB;
811  });
812 
813  float showerStartRunningEnergySum(0.f);
814 
815  for (const CaloHit *const pCaloHit : showerStartPostShowerHitVector)
816  {
817  const float hitEnergy(std::fabs(pCaloHit->GetElectromagneticEnergy()));
818  showerStartRunningEnergySum += hitEnergy;
819 
820  if ((showerStartRunningEnergySum / totalEnergy) > m_moliereFraction)
821  {
822  const CartesianVector position(pCaloHit->GetPositionVector() - fitShowerStart);
823  showerStartMoliereRadius = directionAxis.GetCrossProduct(position).GetMagnitude();
824  break;
825  }
826  }
827 }
TFile f
Definition: plotHisto.C:6
float m_defaultRatio
Default float value for ratios.
float m_moliereFraction
The energy fraction which corresponds to minShowerStartMoliereRadius.
void lar_content::ShowerRegionFeatureTool::GetShowerHitVariables ( const pandora::CaloHitList &  spineHitList,
const pandora::CaloHitList &  postShowerHitList,
const pandora::ParticleFlowObject *const  pShowerPfo,
const pandora::HitType  hitType,
float &  nHits,
float &  foundHitRatio 
)
private

Evaluate the variables associated with the shower region hit multiplicity.

Parameters
spineHitListthe shower spine hit list
postShowerHitListthe collected shower region hit list
pShowerPfothe shower pfo
hitTypethe 2D view
nHitsthe output number of shower region hits
foundHitRatiothe output found hit ratio

Definition at line 624 of file ConnectionPathwayFeatureTool.cc.

References lar_content::LArPfoHelper::GetCaloHits().

Referenced by GetViewShowerRegionVariables().

626 {
627  int foundHits(spineHitList.size());
628 
629  for (const CaloHit *const pCaloHit : postShowerHitList)
630  {
631  if (std::find(spineHitList.begin(), spineHitList.end(), pCaloHit) == spineHitList.end())
632  ++foundHits;
633  }
634 
635  CaloHitList viewHitList;
636  LArPfoHelper::GetCaloHits(pShowerPfo, hitType, viewHitList);
637 
638  foundHitRatio = static_cast<float>(foundHits) / static_cast<float>(viewHitList.size());
639  nHits = postShowerHitList.size();
640 }
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.
void lar_content::ShowerRegionFeatureTool::GetViewShowerRegionVariables ( const pandora::Algorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pShowerPfo,
const pandora::CartesianVector &  nuVertex3D,
const ProtoShowerMatch protoShowerMatch,
const pandora::HitType  hitType,
const pandora::CartesianVector &  showerStart3D,
float &  nHits,
float &  foundHitRatio,
float &  scatterAngle,
float &  openingAngle,
float &  nuVertexEnergyAsymmetry,
float &  nuVertexEnergyWeightedMeanRadialDistance,
float &  showerStartEnergyAsymmetry,
float &  showerStartMoliereRadius 
)
private

Calculate the shower region variables for the input view.

Parameters
pAlgorithmthe algorithm
pShowerPfothe shower pfo
nuVertex3Dthe 3D neutrino vertex
protoShowerMatchthe ProtoShower match
hitTypethe 2D view
showerStart3Dthe 3D shower start position
nHitsthe output number of shower region hits
foundHitRatiothe output found hit ratio
scatterAnglethe output scatter angle
openingAnglethe output opening angle
nuVertexEnergyAsymmetrythe output neutrino vertex energy asymmetry
nuVertexEnergyWeightedMeanRadialDistancethe output neutrino vertex energy weighted mean radial distance
showerStartEnergyAsymmetrythe output shower start energy asymmetry
showerStartMoliereRadiusthe output shower start moliere radius

Definition at line 502 of file ConnectionPathwayFeatureTool.cc.

References BuildViewShower(), CalculateViewNuVertexConsistencyVariables(), CalculateViewOpeningAngle(), CalculateViewScatterAngle(), CalculateViewShowerStartConsistencyVariables(), f, lar_content::LArPfoHelper::GetCaloHits(), lar_content::TwoDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerDirection(), lar_content::TwoDSlidingFitResult::GetGlobalMinLayerPosition(), lar_content::ProtoShowerMatch::GetProtoShowerU(), lar_content::ProtoShowerMatch::GetProtoShowerV(), lar_content::ProtoShowerMatch::GetProtoShowerW(), GetShowerHitVariables(), lar_content::ProtoShower::GetSpineHitList(), lar_content::LArGeometryHelper::GetWirePitch(), m_showerFitWindow, m_showerRadius, m_spineFitWindow, and lar_content::LArGeometryHelper::ProjectPosition().

Referenced by ShowerRegionFeatureTool().

506 {
507  CaloHitList viewHitList;
508  LArPfoHelper::GetCaloHits(pShowerPfo, hitType, viewHitList);
509 
510  const CartesianVector nuVertex2D(LArGeometryHelper::ProjectPosition(pAlgorithm->GetPandora(), nuVertex3D, hitType));
511  const CartesianVector showerStart2D(LArGeometryHelper::ProjectPosition(pAlgorithm->GetPandora(), showerStart3D, hitType));
512  const bool isDownstream(showerStart2D.GetZ() > nuVertex2D.GetZ());
513 
514  try
515  {
516  // Fit the spine to get the initial shower direction
517  const CaloHitList &spineHitList(hitType == TPC_VIEW_U ? protoShowerMatch.GetProtoShowerU().GetSpineHitList()
518  : (hitType == TPC_VIEW_V ? protoShowerMatch.GetProtoShowerV().GetSpineHitList()
519  : protoShowerMatch.GetProtoShowerW().GetSpineHitList()));
520 
521  CartesianPointVector spinePositions;
522  for (const CaloHit *const pCaloHit : spineHitList)
523  spinePositions.push_back(pCaloHit->GetPositionVector());
524 
525  const TwoDSlidingFitResult spineFitResult(&spinePositions, m_spineFitWindow, LArGeometryHelper::GetWirePitch(pAlgorithm->GetPandora(), hitType));
526 
527  // Now can build the shower
528  CaloHitList postShowerHitList;
529  CartesianPointVector postShowerPositions;
530 
531  this->BuildViewShower(pShowerPfo, spineFitResult, hitType, showerStart2D, nuVertex2D, postShowerHitList, postShowerPositions);
532 
533  this->GetShowerHitVariables(spineHitList, postShowerHitList, pShowerPfo, hitType, nHits, foundHitRatio);
534 
535  // Fit the shower
536  TwoDSlidingFitResult showerFitResult(
537  &postShowerPositions, m_showerFitWindow, LArGeometryHelper::GetWirePitch(pAlgorithm->GetPandora(), hitType));
538 
539  const bool isShowerDownstream((showerStart2D - showerFitResult.GetGlobalMinLayerPosition()).GetMagnitude() <
540  (showerStart2D - showerFitResult.GetGlobalMaxLayerPosition()).GetMagnitude());
541 
542  // Collect more hits
543  for (const CaloHit *const pCaloHit : viewHitList)
544  {
545  if (std::find(postShowerHitList.begin(), postShowerHitList.end(), pCaloHit) != postShowerHitList.end())
546  continue;
547 
548  const CartesianVector &hitPosition(pCaloHit->GetPositionVector());
549  const CartesianVector displacement(hitPosition - showerStart2D);
550  const float l(showerFitResult.GetGlobalMinLayerDirection().GetDotProduct(displacement));
551  const float t(showerFitResult.GetGlobalMinLayerDirection().GetCrossProduct(displacement).GetMagnitude());
552 
553  if (((isDownstream && (l > 0.f)) || (!isDownstream && (l < 0.f))) && (t < m_showerRadius))
554  {
555  postShowerHitList.push_back(pCaloHit);
556  postShowerPositions.push_back(pCaloHit->GetPositionVector());
557  }
558  }
559 
560  this->GetShowerHitVariables(spineHitList, postShowerHitList, pShowerPfo, hitType, nHits, foundHitRatio);
561 
562  this->CalculateViewScatterAngle(nuVertex2D, spineFitResult, showerStart2D, showerFitResult, scatterAngle);
563 
564  this->CalculateViewOpeningAngle(showerFitResult, postShowerHitList, showerStart2D, openingAngle);
565 
567  spineFitResult, postShowerHitList, isDownstream, nuVertex2D, nuVertexEnergyAsymmetry, nuVertexEnergyWeightedMeanRadialDistance);
568 
570  showerFitResult, postShowerHitList, isShowerDownstream, showerStartEnergyAsymmetry, showerStartMoliereRadius);
571  }
572  catch (...)
573  {
574  }
575 }
void CalculateViewShowerStartConsistencyVariables(const TwoDSlidingFitResult &showerFitResult, const pandora::CaloHitList &postShowerHitList, const bool isShowerDownstream, float &showerStartEnergyAsymmetry, float &showerStartMoliereRadius)
Evaluate the shower start consistency variables.
void CalculateViewNuVertexConsistencyVariables(const TwoDSlidingFitResult &spineFitResult, const pandora::CaloHitList &postShowerHitList, const bool isDownstream, const pandora::CartesianVector &nuVertex2D, float &nuVertexEnergyAsymmetry, float &nuVertexEnergyWeightedMeanRadialDistance)
Evaluate the neutrino vertex consistency variables.
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
unsigned int m_showerFitWindow
The shower fit window.
unsigned int m_spineFitWindow
The spine fit window.
TFile f
Definition: plotHisto.C:6
float m_showerRadius
The max. separation distance between a shower region hit and the shower core.
void GetShowerHitVariables(const pandora::CaloHitList &spineHitList, const pandora::CaloHitList &postShowerHitList, const pandora::ParticleFlowObject *const pShowerPfo, const pandora::HitType hitType, float &nHits, float &foundHitRatio)
Evaluate the variables associated with the shower region hit multiplicity.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
void CalculateViewOpeningAngle(const TwoDSlidingFitResult &showerFitResult, const pandora::CaloHitList &postShowerHitList, const pandora::CartesianVector &showerStart2D, float &openingAngle)
Calculate the opening angle of the shower region.
void BuildViewShower(const pandora::ParticleFlowObject *const pShowerPfo, const TwoDSlidingFitResult &spineFit, const pandora::HitType hitType, const pandora::CartesianVector &showerStart2D, const pandora::CartesianVector &nuVertex2D, pandora::CaloHitList &postShowerHitList, pandora::CartesianPointVector &postShowerPositions)
Collect the shower region hits in a given view.
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.
void CalculateViewScatterAngle(const pandora::CartesianVector &nuVertex2D, const TwoDSlidingFitResult &spineFitResult, const pandora::CartesianVector &showerStart2D, const TwoDSlidingFitResult &showerFitResult, float &scatterAngle)
Calculate the connection pathway-shower region scatter angle.
StatusCode lar_content::ShowerRegionFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 831 of file ConnectionPathwayFeatureTool.cc.

References m_defaultFloat, m_defaultRatio, m_edgeStep, m_maxFoundHitRatioLimit, m_maxNHitsLimit, m_maxNuVertexEnergyWeightedMeanRadialDistanceLimit, m_maxOpeningAngleLimit, m_maxScatterAngleLimit, m_minShowerStartMoliereRadiusLimit, m_moliereFraction, m_showerFitWindow, m_showerRadius, and m_spineFitWindow.

832 {
833  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DefaultFloat", m_defaultFloat));
834 
835  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DefaultRatio", m_defaultRatio));
836 
837  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SpineFitWindow", m_spineFitWindow));
838 
839  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ShowerRadius", m_showerRadius));
840 
841  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ShowerFitWindow", m_showerFitWindow));
842 
843  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "EdgeStep", m_edgeStep));
844 
845  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MoliereFraction", m_moliereFraction));
846 
847  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxNHitsLimit", m_maxNHitsLimit));
848 
849  PANDORA_RETURN_RESULT_IF_AND_IF(
850  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxFoundHitRatioLimit", m_maxFoundHitRatioLimit));
851 
852  PANDORA_RETURN_RESULT_IF_AND_IF(
853  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxScatterAngleLimit", m_maxScatterAngleLimit));
854 
855  PANDORA_RETURN_RESULT_IF_AND_IF(
856  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxOpeningAngleLimit", m_maxOpeningAngleLimit));
857 
858  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
859  XmlHelper::ReadValue(xmlHandle, "MaxNuVertexEnergyWeightedMeanRadialDistanceLimit", m_maxNuVertexEnergyWeightedMeanRadialDistanceLimit));
860 
861  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
862  XmlHelper::ReadValue(xmlHandle, "MinShowerStartMoliereRadiusLimit", m_minShowerStartMoliereRadiusLimit));
863 
864  return STATUS_CODE_SUCCESS;
865 }
float m_edgeStep
The binning of the shower boundaries.
float m_maxFoundHitRatioLimit
maxFoundHitRatio max. limit
float m_maxNuVertexEnergyWeightedMeanRadialDistanceLimit
maxNuVertexEnergyWeightedMeanRadialDistance max. limit
float m_maxOpeningAngleLimit
maxOpeningAngle max. limit
float m_maxScatterAngleLimit
maxScatterAngle max. limit
unsigned int m_showerFitWindow
The shower fit window.
unsigned int m_spineFitWindow
The spine fit window.
float m_defaultRatio
Default float value for ratios.
float m_showerRadius
The max. separation distance between a shower region hit and the shower core.
float m_moliereFraction
The energy fraction which corresponds to minShowerStartMoliereRadius.
float m_minShowerStartMoliereRadiusLimit
minShowerStartMoliereRadius max. limit
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::ShowerRegionFeatureTool::Run ( LArMvaHelper::MvaFeatureVector featureVector,
const pandora::Algorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pShowerPfo,
const pandora::CartesianVector &  nuVertex3D,
const ProtoShowerMatch protoShowerMatch,
const pandora::CartesianPointVector &  showerStarts3D 
)

Referenced by ShowerRegionFeatureTool().

void lar_content::ShowerRegionFeatureTool::Run ( LArMvaHelper::MvaFeatureMap featureMap,
pandora::StringVector &  featureOrder,
const std::string &  featureToolName,
const pandora::Algorithm *const  pAlgorithm,
const pandora::ParticleFlowObject *const  pShowerPfo,
const pandora::CartesianVector &  nuVertex3D,
const ProtoShowerMatch protoShowerMatch,
const pandora::CartesianPointVector &  showerStarts3D 
)

Member Data Documentation

float lar_content::ShowerRegionFeatureTool::m_defaultFloat
private
float lar_content::ShowerRegionFeatureTool::m_defaultRatio
private
float lar_content::ShowerRegionFeatureTool::m_edgeStep
private

The binning of the shower boundaries.

Definition at line 253 of file ConnectionPathwayFeatureTool.h.

Referenced by CalculateViewOpeningAngle(), and ReadSettings().

float lar_content::ShowerRegionFeatureTool::m_maxFoundHitRatioLimit
private

maxFoundHitRatio max. limit

Definition at line 256 of file ConnectionPathwayFeatureTool.h.

Referenced by ReadSettings(), and ShowerRegionFeatureTool().

float lar_content::ShowerRegionFeatureTool::m_maxNHitsLimit
private

maxNHits max. limit

Definition at line 255 of file ConnectionPathwayFeatureTool.h.

Referenced by ReadSettings(), and ShowerRegionFeatureTool().

float lar_content::ShowerRegionFeatureTool::m_maxNuVertexEnergyWeightedMeanRadialDistanceLimit
private

maxNuVertexEnergyWeightedMeanRadialDistance max. limit

Definition at line 259 of file ConnectionPathwayFeatureTool.h.

Referenced by ReadSettings(), and ShowerRegionFeatureTool().

float lar_content::ShowerRegionFeatureTool::m_maxOpeningAngleLimit
private

maxOpeningAngle max. limit

Definition at line 258 of file ConnectionPathwayFeatureTool.h.

Referenced by ReadSettings(), and ShowerRegionFeatureTool().

float lar_content::ShowerRegionFeatureTool::m_maxScatterAngleLimit
private

maxScatterAngle max. limit

Definition at line 257 of file ConnectionPathwayFeatureTool.h.

Referenced by ReadSettings(), and ShowerRegionFeatureTool().

float lar_content::ShowerRegionFeatureTool::m_minShowerStartMoliereRadiusLimit
private

minShowerStartMoliereRadius max. limit

Definition at line 260 of file ConnectionPathwayFeatureTool.h.

Referenced by ReadSettings(), and ShowerRegionFeatureTool().

float lar_content::ShowerRegionFeatureTool::m_moliereFraction
private

The energy fraction which corresponds to minShowerStartMoliereRadius.

Definition at line 254 of file ConnectionPathwayFeatureTool.h.

Referenced by CalculateViewShowerStartConsistencyVariables(), and ReadSettings().

unsigned int lar_content::ShowerRegionFeatureTool::m_showerFitWindow
private

The shower fit window.

Definition at line 252 of file ConnectionPathwayFeatureTool.h.

Referenced by CalculateViewOpeningAngle(), GetViewShowerRegionVariables(), and ReadSettings().

float lar_content::ShowerRegionFeatureTool::m_showerRadius
private

The max. separation distance between a shower region hit and the shower core.

Definition at line 251 of file ConnectionPathwayFeatureTool.h.

Referenced by BuildViewShower(), GetViewShowerRegionVariables(), and ReadSettings().

unsigned int lar_content::ShowerRegionFeatureTool::m_spineFitWindow
private

The spine fit window.

Definition at line 250 of file ConnectionPathwayFeatureTool.h.

Referenced by GetViewShowerRegionVariables(), and ReadSettings().


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