LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ThreeViewRemnantsAlgorithm.cc
Go to the documentation of this file.
1 
9 #include "Pandora/AlgorithmHeaders.h"
10 
12 
15 
16 using namespace pandora;
17 
18 namespace lar_content
19 {
20 
21 ThreeViewRemnantsAlgorithm::ThreeViewRemnantsAlgorithm() :
22  m_nMaxTensorToolRepeats(1000),
23  m_minClusterCaloHits(5),
24  m_xOverlapWindow(2.f),
25  m_pseudoChi2Cut(10.f)
26 {
27 }
28 
29 //------------------------------------------------------------------------------------------------------------------------------------------
30 
31 void ThreeViewRemnantsAlgorithm::SelectInputClusters(const ClusterList *const pInputClusterList, ClusterList &selectedClusterList) const
32 {
33  for (ClusterList::const_iterator iter = pInputClusterList->begin(), iterEnd = pInputClusterList->end(); iter != iterEnd; ++iter)
34  {
35  const Cluster *const pCluster = *iter;
36 
37  if (!pCluster->IsAvailable())
38  continue;
39 
40  if (pCluster->GetNCaloHits() < m_minClusterCaloHits)
41  continue;
42 
43  selectedClusterList.push_back(pCluster);
44  }
45 }
46 
47 //------------------------------------------------------------------------------------------------------------------------------------------
48 
49 void ThreeViewRemnantsAlgorithm::CalculateOverlapResult(const Cluster *const pClusterU, const Cluster *const pClusterV, const Cluster *const pClusterW)
50 {
51  // Requirements on X matching
52  float xMinU(0.f), xMinV(0.f), xMinW(0.f), xMaxU(0.f), xMaxV(0.f), xMaxW(0.f);
53  pClusterU->GetClusterSpanX(xMinU, xMaxU);
54  pClusterV->GetClusterSpanX(xMinV, xMaxV);
55  pClusterW->GetClusterSpanX(xMinW, xMaxW);
56 
57  const float xMin(std::max(xMinU, std::max(xMinV, xMinW)) - m_xOverlapWindow);
58  const float xMax(std::min(xMaxU, std::min(xMaxV, xMaxW)) + m_xOverlapWindow);
59  const float xOverlap(xMax - xMin);
60 
61  if (xOverlap < std::numeric_limits<float>::epsilon())
62  return;
63 
64  // Requirements on 3D matching
65  float u(std::numeric_limits<float>::max()), v(std::numeric_limits<float>::max()), w(std::numeric_limits<float>::max());
66 
67  if ((STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pClusterU, xMin, xMax, u)) ||
68  (STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pClusterV, xMin, xMax, v)) ||
69  (STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pClusterW, xMin, xMax, w)))
70  {
71  return;
72  }
73 
74  const float uv2w(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_V, u, v));
75  const float vw2u(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_V, TPC_VIEW_W, v, w));
76  const float wu2v(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_W, TPC_VIEW_U, w, u));
77 
78  const float pseudoChi2(((u - vw2u) * (u - vw2u) + (v - wu2v) * (v - wu2v) + (w - uv2w) * (w - uv2w)) / 3.f);
79 
80  if (pseudoChi2 > m_pseudoChi2Cut)
81  return;
82 
83  // ATTN Essentially a boolean result; actual value matters only so as to ensure that overlap results can be sorted
84  const float hackValue(
85  pseudoChi2 + pClusterU->GetElectromagneticEnergy() + pClusterV->GetElectromagneticEnergy() + pClusterW->GetElectromagneticEnergy());
86  this->GetMatchingControl().GetOverlapTensor().SetOverlapResult(pClusterU, pClusterV, pClusterW, hackValue);
87 }
88 
89 //------------------------------------------------------------------------------------------------------------------------------------------
90 
92 {
93  unsigned int repeatCounter(0);
94 
95  for (RemnantTensorToolVector::const_iterator iter = m_algorithmToolVector.begin(), iterEnd = m_algorithmToolVector.end(); iter != iterEnd;)
96  {
97  if ((*iter)->Run(this, this->GetMatchingControl().GetOverlapTensor()))
98  {
99  iter = m_algorithmToolVector.begin();
100 
101  if (++repeatCounter > m_nMaxTensorToolRepeats)
102  break;
103  }
104  else
105  {
106  ++iter;
107  }
108  }
109 }
110 
111 //------------------------------------------------------------------------------------------------------------------------------------------
112 
113 StatusCode ThreeViewRemnantsAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
114 {
115  AlgorithmToolVector algorithmToolVector;
116  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle, "TrackTools", algorithmToolVector));
117 
118  for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
119  {
120  RemnantTensorTool *const pRemnantTensorTool(dynamic_cast<RemnantTensorTool *>(*iter));
121 
122  if (!pRemnantTensorTool)
123  return STATUS_CODE_INVALID_PARAMETER;
124 
125  m_algorithmToolVector.push_back(pRemnantTensorTool);
126  }
127 
128  PANDORA_RETURN_RESULT_IF_AND_IF(
129  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NMaxTensorToolRepeats", m_nMaxTensorToolRepeats));
130 
131  PANDORA_RETURN_RESULT_IF_AND_IF(
132  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterCaloHits", m_minClusterCaloHits));
133 
134  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "OverlapWindow", m_xOverlapWindow));
135 
136  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PseudoChi2Cut", m_pseudoChi2Cut));
137 
138  return BaseAlgorithm::ReadSettings(xmlHandle);
139 }
140 
141 } // namespace lar_content
float m_pseudoChi2Cut
The selection cut on the matched chi2.
TensorType & GetOverlapTensor()
Get the overlap tensor.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in container.
intermediate_table::const_iterator const_iterator
static pandora::StatusCode GetAverageZ(const pandora::Cluster *const pCluster, const float xmin, const float xmax, float &averageZ)
Get average Z positions of the calo hits in a cluster in range xmin to xmax.
RemnantTensorToolVector m_algorithmToolVector
The algorithm tool list.
TFile f
Definition: plotHisto.C:6
Header file for the geometry helper class.
void SetOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, const OverlapResult &overlapResult)
Set overlap result.
Header file for the cluster helper class.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
void ExamineOverlapContainer()
Examine contents of overlap container, collect together best-matching 2D particles and modify cluster...
unsigned int m_minClusterCaloHits
The selection cut on the number of cluster calo hits.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Float_t w
Definition: plot.C:20
float m_xOverlapWindow
The sampling pitch in the x coordinate.
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
Header file for the three view remnants algorithm class.
void SelectInputClusters(const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters for processing in this algorithm.