LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
CutPfoCharacterisationAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
14 
16 
19 
20 using namespace pandora;
21 
22 namespace lar_content
23 {
24 
25 CutPfoCharacterisationAlgorithm::CutPfoCharacterisationAlgorithm() :
26  m_postBranchAddition(false),
27  m_slidingFitWindow(5),
28  m_slidingShowerFitWindow(10),
29  m_maxShowerLengthCut(80.f),
30  m_dTdLWidthRatioCut(0.045f),
31  m_vertexDistanceRatioCut(0.6f),
32  m_showerWidthRatioCut(0.2f)
33 {
34 }
35 
36 //------------------------------------------------------------------------------------------------------------------------------------------
37 
38 bool CutPfoCharacterisationAlgorithm::IsClearTrack(const Cluster *const pCluster) const
39 {
40  float straightLineLength(-1.f);
41  float dTdLMin(+std::numeric_limits<float>::max()), dTdLMax(-std::numeric_limits<float>::max());
42 
43  try
44  {
45  const HitType view{LArClusterHelper::GetClusterHitType(pCluster)};
46  const TwoDSlidingFitResult slidingFitResult(pCluster, m_slidingFitWindow, LArGeometryHelper::GetWirePitch(this->GetPandora(), view));
47  straightLineLength = (slidingFitResult.GetGlobalMaxLayerPosition() - slidingFitResult.GetGlobalMinLayerPosition()).GetMagnitude();
48 
49  for (const auto &mapEntry : slidingFitResult.GetLayerFitResultMap())
50  {
51  dTdLMin = std::min(dTdLMin, static_cast<float>(mapEntry.second.GetGradient()));
52  dTdLMax = std::max(dTdLMax, static_cast<float>(mapEntry.second.GetGradient()));
53  }
54  }
55  catch (const StatusCodeException &)
56  {
57  }
58 
59  if (straightLineLength < std::numeric_limits<float>::epsilon())
60  return false;
61 
62  if (straightLineLength > m_maxShowerLengthCut)
63  return true;
64 
65  if ((dTdLMax - dTdLMin) / straightLineLength > m_dTdLWidthRatioCut)
66  return false;
67 
68  const float vertexDistance(CutClusterCharacterisationAlgorithm::GetVertexDistance(this, pCluster));
69 
70  if ((vertexDistance > std::numeric_limits<float>::epsilon()) && ((vertexDistance / straightLineLength) > m_vertexDistanceRatioCut))
71  return false;
72 
73  const float showerFitWidth(CutClusterCharacterisationAlgorithm::GetShowerFitWidth(this, pCluster, m_slidingShowerFitWindow));
74 
75  if ((showerFitWidth < std::numeric_limits<float>::epsilon()) || ((showerFitWidth / straightLineLength) > m_showerWidthRatioCut))
76  return false;
77 
78  return true;
79 }
80 
81 //------------------------------------------------------------------------------------------------------------------------------------------
82 
83 bool CutPfoCharacterisationAlgorithm::IsClearTrack(const pandora::ParticleFlowObject *const /*pPfo*/) const
84 {
85  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
86 }
87 
88 //------------------------------------------------------------------------------------------------------------------------------------------
89 
90 StatusCode CutPfoCharacterisationAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
91 {
92  PANDORA_RETURN_RESULT_IF_AND_IF(
93  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PostBranchAddition", m_postBranchAddition));
94 
95  // Allow change in default values via a single xml tag, can subsequently override all individual values below, if required
97  {
98  m_maxShowerLengthCut = 80.f;
99  m_dTdLWidthRatioCut = 0.03f;
101  m_showerWidthRatioCut = 0.3f;
102  }
103 
104  PANDORA_RETURN_RESULT_IF_AND_IF(
105  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
106 
107  PANDORA_RETURN_RESULT_IF_AND_IF(
108  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingShowerFitWindow", m_slidingShowerFitWindow));
109 
110  PANDORA_RETURN_RESULT_IF_AND_IF(
111  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxShowerLengthCut", m_maxShowerLengthCut));
112 
113  PANDORA_RETURN_RESULT_IF_AND_IF(
114  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DTDLWidthRatioCut", m_dTdLWidthRatioCut));
115 
116  PANDORA_RETURN_RESULT_IF_AND_IF(
117  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "VertexDistanceRatioCut", m_vertexDistanceRatioCut));
118 
119  PANDORA_RETURN_RESULT_IF_AND_IF(
120  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ShowerWidthRatioCut", m_showerWidthRatioCut));
121 
123 }
124 
125 } // 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 pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
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.
float m_vertexDistanceRatioCut
The maximum ratio of vertex separation to straight line length to qualify as a track.
Header file for the cluster helper class.
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.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
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.
HitType
Definition: HitType.h:12
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.