LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
CutPfoCharacterisationAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
13 
15 
18 
19 using namespace pandora;
20 
21 namespace lar_content
22 {
23 
24 CutPfoCharacterisationAlgorithm::CutPfoCharacterisationAlgorithm() :
25  m_postBranchAddition(false),
26  m_slidingFitWindow(5),
27  m_slidingShowerFitWindow(10),
28  m_maxShowerLengthCut(80.f),
29  m_dTdLWidthRatioCut(0.045f),
30  m_vertexDistanceRatioCut(0.6f),
31  m_showerWidthRatioCut(0.2f)
32 {
33 }
34 
35 //------------------------------------------------------------------------------------------------------------------------------------------
36 
37 bool CutPfoCharacterisationAlgorithm::IsClearTrack(const Cluster *const pCluster) const
38 {
39  float straightLineLength(-1.f);
41 
42  try
43  {
44  const TwoDSlidingFitResult slidingFitResult(pCluster, m_slidingFitWindow, LArGeometryHelper::GetWireZPitch(this->GetPandora()));
45  straightLineLength = (slidingFitResult.GetGlobalMaxLayerPosition() - slidingFitResult.GetGlobalMinLayerPosition()).GetMagnitude();
46 
47  for (const auto &mapEntry : slidingFitResult.GetLayerFitResultMap())
48  {
49  dTdLMin = std::min(dTdLMin, static_cast<float>(mapEntry.second.GetGradient()));
50  dTdLMax = std::max(dTdLMax, static_cast<float>(mapEntry.second.GetGradient()));
51  }
52  }
53  catch (const StatusCodeException &)
54  {
55  }
56 
57  if (straightLineLength < std::numeric_limits<float>::epsilon())
58  return false;
59 
60  if (straightLineLength > m_maxShowerLengthCut)
61  return true;
62 
63  if ((dTdLMax - dTdLMin) / straightLineLength > m_dTdLWidthRatioCut)
64  return false;
65 
66  const float vertexDistance(CutClusterCharacterisationAlgorithm::GetVertexDistance(this, pCluster));
67 
68  if ((vertexDistance > std::numeric_limits<float>::epsilon()) && ((vertexDistance / straightLineLength) > m_vertexDistanceRatioCut))
69  return false;
70 
71  const float showerFitWidth(CutClusterCharacterisationAlgorithm::GetShowerFitWidth(this, pCluster, m_slidingShowerFitWindow));
72 
73  if ((showerFitWidth < std::numeric_limits<float>::epsilon()) || ((showerFitWidth / straightLineLength) > m_showerWidthRatioCut))
74  return false;
75 
76  return true;
77 }
78 
79 //------------------------------------------------------------------------------------------------------------------------------------------
80 
81 bool CutPfoCharacterisationAlgorithm::IsClearTrack(const pandora::ParticleFlowObject *const /*pPfo*/) const
82 {
83  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
84 }
85 
86 //------------------------------------------------------------------------------------------------------------------------------------------
87 
88 StatusCode CutPfoCharacterisationAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
89 {
90  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
91  "PostBranchAddition", m_postBranchAddition));
92 
93  // Allow change in default values via a single xml tag, can subsequently override all individual values below, if required
95  {
96  m_maxShowerLengthCut = 80.f;
97  m_dTdLWidthRatioCut = 0.03f;
99  m_showerWidthRatioCut = 0.3f;
100  }
101 
102  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
103  "SlidingFitWindow", m_slidingFitWindow));
104 
105  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
106  "SlidingShowerFitWindow", m_slidingShowerFitWindow));
107 
108  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
109  "MaxShowerLengthCut", m_maxShowerLengthCut));
110 
111  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
112  "DTDLWidthRatioCut", m_dTdLWidthRatioCut));
113 
114  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
115  "VertexDistanceRatioCut", m_vertexDistanceRatioCut));
116 
117  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
118  "ShowerWidthRatioCut", m_showerWidthRatioCut));
119 
121 }
122 
123 } // namespace lar_content
Header file for the pfo helper class.
Header file for the cut based pfo characterisation algorithm class.
Header file for the cut based cluster characterisation algorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_dTdLWidthRatioCut
The maximum ratio of transverse fit gradient width to straight line length to qualify as a track...
unsigned int m_slidingShowerFitWindow
The layer window for the sliding shower fits.
static float GetVertexDistance(const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster)
Get the distance between the interaction vertex (if present in the current vertex list) and a provide...
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
TFile f
Definition: plotHisto.C:6
Header file for the geometry helper class.
float m_showerWidthRatioCut
The maximum ratio of shower fit width to straight line length to qualify as a track.
Int_t max
Definition: plot.C:27
float m_vertexDistanceRatioCut
The maximum ratio of vertex separation to straight line length to qualify as a track.
float m_maxShowerLengthCut
The maximum cluster length to qualify as a shower.
Header file for the lar two dimensional sliding fit result class.
pandora::CartesianVector GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
bool IsClearTrack(const pandora::Cluster *const pCluster) const
Whether cluster is identified as a clear track.
const LayerFitResultMap & GetLayerFitResultMap() const
Get the layer fit result map.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
unsigned int m_slidingFitWindow
The layer window for the sliding linear fits.
Int_t min
Definition: plot.C:26
static float GetShowerFitWidth(const pandora::Algorithm *const pAlgorithm, const pandora::Cluster *const pCluster, const unsigned int showerFitWindow)
Get a measure of the width of a cluster, using a sliding shower fit result.
bool m_postBranchAddition
Whether to use configuration for shower clusters post branch addition.
pandora::CartesianVector GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.