LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
KinkSplittingAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
13 using namespace pandora;
14 
15 namespace lar_content
16 {
17 
18 KinkSplittingAlgorithm::KinkSplittingAlgorithm() :
19  m_maxScatterRms(0.2f),
20  m_maxScatterCosTheta(0.905f),
21  m_maxSlidingCosTheta(0.985f)
22 {
23 }
24 
25 //------------------------------------------------------------------------------------------------------------------------------------------
26 
27 StatusCode KinkSplittingAlgorithm::FindBestSplitPosition(const TwoDSlidingFitResult &slidingFitResult, CartesianVector& splitPosition) const
28 {
29  // Search for scatters by scanning over the layers in the sliding fit result
30  const LayerFitResultMap &layerFitResultMap(slidingFitResult.GetLayerFitResultMap());
31  const int minLayer(layerFitResultMap.begin()->first), maxLayer(layerFitResultMap.rbegin()->first);
32 
33  const int nLayersHalfWindow(slidingFitResult.GetLayerFitHalfWindow());
34  const int nLayersSpanned(1 + maxLayer - minLayer);
35 
36  if (nLayersSpanned <= 2 * nLayersHalfWindow)
37  return STATUS_CODE_NOT_FOUND;
38 
39  bool foundSplit(false);
40 
41  float bestCosTheta(1.f);
42 
43  for (LayerFitResultMap::const_iterator iter = layerFitResultMap.begin(), iterEnd = layerFitResultMap.end(); iter != iterEnd; ++iter)
44  {
45  const int iLayer(iter->first);
46 
47  const float rL(slidingFitResult.GetL(iLayer));
48  const float rL1(slidingFitResult.GetL(iLayer - nLayersHalfWindow));
49  const float rL2(slidingFitResult.GetL(iLayer + nLayersHalfWindow));
50 
51  CartesianVector centralPosition(0.f,0.f,0.f), firstDirection(0.f,0.f,0.f), secondDirection(0.f,0.f,0.f);
52 
53  if ((STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitPosition(rL, centralPosition)) ||
54  (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitDirection(rL1, firstDirection)) ||
55  (STATUS_CODE_SUCCESS != slidingFitResult.GetGlobalFitDirection(rL2, secondDirection)))
56  {
57  continue;
58  }
59 
60  const float cosTheta(firstDirection.GetDotProduct(secondDirection));
61  const float rms1(slidingFitResult.GetFitRms(rL1));
62  const float rms2(slidingFitResult.GetFitRms(rL2));
63  const float rms(std::max(rms1, rms2));
64 
65  float rmsCut(m_maxScatterRms);
66 
67  if (cosTheta > m_maxScatterCosTheta)
68  {
69  rmsCut *= ((m_maxSlidingCosTheta > cosTheta) ? (m_maxSlidingCosTheta - cosTheta) /
71  }
72 
73  if (rms < rmsCut && cosTheta < bestCosTheta)
74  {
75  bestCosTheta = cosTheta;
76  splitPosition = centralPosition;
77  foundSplit = true;
78  }
79  }
80 
81  if (!foundSplit)
82  return STATUS_CODE_NOT_FOUND;
83 
84  return STATUS_CODE_SUCCESS;
85 }
86 
87 //------------------------------------------------------------------------------------------------------------------------------------------
88 
89 StatusCode KinkSplittingAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
90 {
91  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
92  "MaxScatterRms", m_maxScatterRms));
93 
94  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
95  "MaxScatterCosTheta", m_maxScatterCosTheta));
96 
97  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
98  "MaxSlidingCosTeta", m_maxSlidingCosTheta));
99 
101 }
102 
103 } // namespace lar_content
unsigned int GetLayerFitHalfWindow() const
Get the layer fit half window.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
TFile f
Definition: plotHisto.C:6
Int_t max
Definition: plot.C:27
intermediate_table::const_iterator const_iterator
float GetFitRms(const float rL) const
Get fit rms for a given longitudinal coordinate.
pandora::StatusCode GetGlobalFitPosition(const float rL, pandora::CartesianVector &position) const
Get global fit position for a given longitudinal coordinate.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
std::map< int, LayerFitResult > LayerFitResultMap
const LayerFitResultMap & GetLayerFitResultMap() const
Get the layer fit result map.
pandora::StatusCode GetGlobalFitDirection(const float rL, pandora::CartesianVector &direction) const
Get global fit direction for a given longitudinal coordinate.
float GetL(const int layer) const
Get longitudinal coordinate for a given sliding linear fit layer number.
pandora::StatusCode FindBestSplitPosition(const TwoDSlidingFitResult &slidingFitResult, pandora::CartesianVector &splitPosition) const
Use sliding linear fit to identify the best split position.
Header file for the kink splitting algorithm class.