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

ConnectionRegionFeatureTool to calculate variables related to the connection pathway region. More...

#include "ConnectionPathwayFeatureTool.h"

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

Public Types

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

Public Member Functions

 ConnectionRegionFeatureTool ()
 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)
 
float Get2DKink (const pandora::Algorithm *const pAlgorithm, const ProtoShowerMatch &protoShowerMatch, const pandora::CartesianVector &showerStart3D) const
 Obtain a cautious estimate of the largest 2D deflection of the connection pathway. More...
 
float GetLargest2DKinkFromView (const pandora::Algorithm *const pAlgorithm, const TwoDSlidingFitResult &spineFit, const pandora::HitType hitType, const pandora::CartesianVector &showerStart3D) const
 Obtain a cautious estimate of the largest 2D deflection of a connection pathway in a given view. More...
 

Private Attributes

float m_defaultFloat
 Default float value. More...
 
unsigned int m_spineFitWindow
 The spine fit window. More...
 
int m_nLayersHalfWindow
 The half window of each segment. More...
 
float m_pathwayLengthLimit
 pathwayLengthLimit max. limit More...
 
float m_pathwayScatteringAngle2DLimit
 pathwayScatteringAngle2DLimit max. limit More...
 

Detailed Description

ConnectionRegionFeatureTool to calculate variables related to the connection pathway region.

Definition at line 72 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::ConnectionRegionFeatureTool::ConnectionRegionFeatureTool ( )

Default constructor.

Definition at line 135 of file ConnectionPathwayFeatureTool.cc.

References Get2DKink(), m_pathwayLengthLimit, m_pathwayScatteringAngle2DLimit, and Run().

135  :
136  m_defaultFloat(-10.f),
137  m_spineFitWindow(10),
141 {
142 }
unsigned int m_spineFitWindow
The spine fit window.
TFile f
Definition: plotHisto.C:6
float m_pathwayScatteringAngle2DLimit
pathwayScatteringAngle2DLimit max. limit
float m_pathwayLengthLimit
pathwayLengthLimit max. limit
int m_nLayersHalfWindow
The half window of each segment.

Member Function Documentation

float lar_content::ConnectionRegionFeatureTool::Get2DKink ( const pandora::Algorithm *const  pAlgorithm,
const ProtoShowerMatch protoShowerMatch,
const pandora::CartesianVector &  showerStart3D 
) const
private

Obtain a cautious estimate of the largest 2D deflection of the connection pathway.

Parameters
pAlgorithmthe algorithm
protoShowerMatchthe ProtoShower match
showerStart3Dthe 3D shower start position
Returns
a cautious estimate of the largest 2D deflection of the connection pathway

Definition at line 187 of file ConnectionPathwayFeatureTool.cc.

References GetLargest2DKinkFromView(), lar_content::LArConnectionPathwayHelper::GetMinMiddleMax(), lar_content::ProtoShowerMatch::GetProtoShowerU(), lar_content::ProtoShowerMatch::GetProtoShowerV(), lar_content::ProtoShowerMatch::GetProtoShowerW(), lar_content::ProtoShower::GetSpineHitList(), lar_content::LArGeometryHelper::GetWirePitch(), m_defaultFloat, and m_spineFitWindow.

Referenced by ConnectionRegionFeatureTool().

189 {
190  try
191  {
192  CartesianPointVector spinePositionsU, spinePositionsV, spinePositionsW;
193 
194  for (HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
195  {
196  const ProtoShower &protoShower(hitType == TPC_VIEW_U
197  ? protoShowerMatch.GetProtoShowerU()
198  : (hitType == TPC_VIEW_V ? protoShowerMatch.GetProtoShowerV() : protoShowerMatch.GetProtoShowerW()));
199  CartesianPointVector &spinePositions(hitType == TPC_VIEW_U ? spinePositionsU : (hitType == TPC_VIEW_V ? spinePositionsV : spinePositionsW));
200 
201  for (const CaloHit *const pCaloHit : protoShower.GetSpineHitList())
202  spinePositions.push_back(pCaloHit->GetPositionVector());
203  }
204 
205  const TwoDSlidingFitResult spineFitU(&spinePositionsU, m_spineFitWindow, LArGeometryHelper::GetWirePitch(pAlgorithm->GetPandora(), TPC_VIEW_U));
206  const TwoDSlidingFitResult spineFitV(&spinePositionsV, m_spineFitWindow, LArGeometryHelper::GetWirePitch(pAlgorithm->GetPandora(), TPC_VIEW_V));
207  const TwoDSlidingFitResult spineFitW(&spinePositionsW, m_spineFitWindow, LArGeometryHelper::GetWirePitch(pAlgorithm->GetPandora(), TPC_VIEW_W));
208 
209  const float scatterAngleU(this->GetLargest2DKinkFromView(pAlgorithm, spineFitU, TPC_VIEW_U, showerStart3D));
210  const float scatterAngleV(this->GetLargest2DKinkFromView(pAlgorithm, spineFitV, TPC_VIEW_V, showerStart3D));
211  const float scatterAngleW(this->GetLargest2DKinkFromView(pAlgorithm, spineFitW, TPC_VIEW_W, showerStart3D));
212 
213  float minScatterAngle(m_defaultFloat), middleScatterAngle(m_defaultFloat), maxScatterAngle(m_defaultFloat);
214  LArConnectionPathwayHelper::GetMinMiddleMax(scatterAngleU, scatterAngleV, scatterAngleW, minScatterAngle, middleScatterAngle, maxScatterAngle);
215 
216  return middleScatterAngle;
217  }
218  catch (...)
219  {
220  }
221 
222  return m_defaultFloat;
223 }
unsigned int m_spineFitWindow
The spine fit window.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
HitType
Definition: HitType.h:12
static void GetMinMiddleMax(const float value1, const float value2, const float value3, float &minValue, float &middleValue, float &maxValue)
Determine the lowest, median and highest value from an input of three numbers.
float GetLargest2DKinkFromView(const pandora::Algorithm *const pAlgorithm, const TwoDSlidingFitResult &spineFit, const pandora::HitType hitType, const pandora::CartesianVector &showerStart3D) const
Obtain a cautious estimate of the largest 2D deflection of a connection pathway in a given view...
float lar_content::ConnectionRegionFeatureTool::GetLargest2DKinkFromView ( const pandora::Algorithm *const  pAlgorithm,
const TwoDSlidingFitResult spineFit,
const pandora::HitType  hitType,
const pandora::CartesianVector &  showerStart3D 
) const
private

Obtain a cautious estimate of the largest 2D deflection of a connection pathway in a given view.

Parameters
pAlgorithmthe algorithm
spineFitthe shower spine fit
hitTypethe 2D view
showerStart3Dthe 3D shower start position
Returns
a cautious estimate of the largest 2D deflection of a connection pathway in a given view

Definition at line 227 of file ConnectionPathwayFeatureTool.cc.

References f, lar_content::TwoDSlidingFitResult::GetGlobalFitPosition(), lar_content::TwoDSlidingFitResult::GetL(), lar_content::TwoDSlidingFitResult::GetLayer(), lar_content::TwoDSlidingFitResult::GetLayerFitResultMap(), lar_content::TwoDSlidingFitResult::GetLocalPosition(), m_defaultFloat, m_nLayersHalfWindow, and lar_content::LArGeometryHelper::ProjectPosition().

Referenced by Get2DKink().

229 {
230  const LayerFitResultMap &layerFitResultMap(spineFit.GetLayerFitResultMap());
231  const int minLayer(layerFitResultMap.begin()->first), maxLayer(layerFitResultMap.rbegin()->first);
232  const int nLayersSpanned(1 + maxLayer - minLayer);
233 
234  if (nLayersSpanned <= 2 * m_nLayersHalfWindow)
235  return m_defaultFloat;
236 
237  const CartesianVector projectedShowerStart(LArGeometryHelper::ProjectPosition(pAlgorithm->GetPandora(), showerStart3D, hitType));
238 
239  float showerStartL(0.f), showerStartT(0.f);
240  spineFit.GetLocalPosition(projectedShowerStart, showerStartL, showerStartT);
241 
242  float maxCentralLayer(spineFit.GetLayer(showerStartL) - m_nLayersHalfWindow);
243  float minCentralLayer(layerFitResultMap.begin()->first + m_nLayersHalfWindow + 1);
244 
245  float highestOpeningAngle(m_defaultFloat);
246  CartesianVector kinkPosition(0.f, 0.f, 0.f);
247  CartesianVector highestKinkPosition(0.f, 0.f, 0.f);
248 
249  for (LayerFitResultMap::const_iterator iter = layerFitResultMap.begin(), iterEnd = layerFitResultMap.end(); iter != iterEnd; ++iter)
250  {
251  const int layer(iter->first);
252 
253  if (layer < minCentralLayer)
254  continue;
255 
256  if (layer > maxCentralLayer)
257  continue;
258 
259  bool found(false);
260  float openingAngle2D(std::numeric_limits<float>::max());
261 
262  float thisHighestOpeningAngle(m_defaultFloat);
263  CartesianVector thisHighestKinkPosition(0.f, 0.f, 0.f);
264 
265  for (int i = 0; i < m_nLayersHalfWindow; ++i)
266  {
267  const int testLayer(layer + i);
268  const float rL(spineFit.GetL(testLayer));
269  const float rL1(spineFit.GetL(testLayer - m_nLayersHalfWindow));
270  const float rL2(spineFit.GetL(testLayer + m_nLayersHalfWindow));
271 
272  CartesianVector firstPosition(0.f, 0.f, 0.f), centralPosition(0.f, 0.f, 0.f), secondPosition(0.f, 0.f, 0.f);
273 
274  if ((STATUS_CODE_SUCCESS != spineFit.GetGlobalFitPosition(rL1, firstPosition)) ||
275  (STATUS_CODE_SUCCESS != spineFit.GetGlobalFitPosition(rL, centralPosition)) ||
276  (STATUS_CODE_SUCCESS != spineFit.GetGlobalFitPosition(rL2, secondPosition)))
277  {
278  continue;
279  }
280 
281  const CartesianVector firstDirection((centralPosition - firstPosition).GetUnitVector());
282  const CartesianVector secondDirection((secondPosition - centralPosition).GetUnitVector());
283 
284  const float testOpeningAngle2D(secondDirection.GetOpeningAngle(firstDirection) * 180.f / M_PI);
285 
286  if (testOpeningAngle2D < openingAngle2D)
287  {
288  openingAngle2D = testOpeningAngle2D;
289  found = true;
290  }
291 
292  if (testOpeningAngle2D > thisHighestOpeningAngle)
293  {
294  thisHighestOpeningAngle = openingAngle2D;
295  thisHighestKinkPosition = centralPosition;
296  }
297  }
298 
299  if (found)
300  {
301  if (openingAngle2D > highestOpeningAngle)
302  {
303  highestOpeningAngle = openingAngle2D;
304  highestKinkPosition = thisHighestKinkPosition;
305  }
306  }
307  }
308 
309  return highestOpeningAngle;
310 }
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
intermediate_table::const_iterator const_iterator
TFile f
Definition: plotHisto.C:6
std::map< int, LayerFitResult > LayerFitResultMap
int m_nLayersHalfWindow
The half window of each segment.
StatusCode lar_content::ConnectionRegionFeatureTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 314 of file ConnectionPathwayFeatureTool.cc.

References m_defaultFloat, m_nLayersHalfWindow, m_pathwayLengthLimit, m_pathwayScatteringAngle2DLimit, and m_spineFitWindow.

315 {
316  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DefaultFloat", m_defaultFloat));
317 
318  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SpineFitWindow", m_spineFitWindow));
319 
320  PANDORA_RETURN_RESULT_IF_AND_IF(
321  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NLayersHalfWindow", m_nLayersHalfWindow));
322 
323  PANDORA_RETURN_RESULT_IF_AND_IF(
324  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PathwayLengthLimit", m_pathwayLengthLimit));
325 
326  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
327  XmlHelper::ReadValue(xmlHandle, "PathwayScatteringAngle2DLimit", m_pathwayScatteringAngle2DLimit));
328 
329  return STATUS_CODE_SUCCESS;
330 }
unsigned int m_spineFitWindow
The spine fit window.
float m_pathwayScatteringAngle2DLimit
pathwayScatteringAngle2DLimit max. limit
float m_pathwayLengthLimit
pathwayLengthLimit max. limit
int m_nLayersHalfWindow
The half window of each segment.
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::ConnectionRegionFeatureTool::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 lar_content::ConnectionRegionFeatureTool::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::ConnectionRegionFeatureTool::m_defaultFloat
private

Default float value.

Definition at line 116 of file ConnectionPathwayFeatureTool.h.

Referenced by Get2DKink(), GetLargest2DKinkFromView(), and ReadSettings().

int lar_content::ConnectionRegionFeatureTool::m_nLayersHalfWindow
private

The half window of each segment.

Definition at line 118 of file ConnectionPathwayFeatureTool.h.

Referenced by GetLargest2DKinkFromView(), and ReadSettings().

float lar_content::ConnectionRegionFeatureTool::m_pathwayLengthLimit
private

pathwayLengthLimit max. limit

Definition at line 119 of file ConnectionPathwayFeatureTool.h.

Referenced by ConnectionRegionFeatureTool(), and ReadSettings().

float lar_content::ConnectionRegionFeatureTool::m_pathwayScatteringAngle2DLimit
private

pathwayScatteringAngle2DLimit max. limit

Definition at line 120 of file ConnectionPathwayFeatureTool.h.

Referenced by ConnectionRegionFeatureTool(), and ReadSettings().

unsigned int lar_content::ConnectionRegionFeatureTool::m_spineFitWindow
private

The spine fit window.

Definition at line 117 of file ConnectionPathwayFeatureTool.h.

Referenced by Get2DKink(), and ReadSettings().


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