LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ThreeDRemnantsAlgorithm.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 ThreeDRemnantsAlgorithm::ThreeDRemnantsAlgorithm() :
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 ThreeDRemnantsAlgorithm::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 ThreeDRemnantsAlgorithm::SetPfoParameters(const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
50 {
51  // TODO Correct these placeholder parameters
52  pfoParameters.m_particleId = E_MINUS; // Shower
53  pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
54  pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
55  pfoParameters.m_energy = 0.f;
56  pfoParameters.m_momentum = CartesianVector(0.f, 0.f, 0.f);
57  pfoParameters.m_clusterList.insert(pfoParameters.m_clusterList.end(), protoParticle.m_clusterListU.begin(), protoParticle.m_clusterListU.end());
58  pfoParameters.m_clusterList.insert(pfoParameters.m_clusterList.end(), protoParticle.m_clusterListV.begin(), protoParticle.m_clusterListV.end());
59  pfoParameters.m_clusterList.insert(pfoParameters.m_clusterList.end(), protoParticle.m_clusterListW.begin(), protoParticle.m_clusterListW.end());
60 }
61 
62 //------------------------------------------------------------------------------------------------------------------------------------------
63 
64 void ThreeDRemnantsAlgorithm::CalculateOverlapResult(const Cluster *const pClusterU, const Cluster *const pClusterV, const Cluster *const pClusterW)
65 {
66  // Requirements on X matching
67  float xMinU(0.f), xMinV(0.f), xMinW(0.f), xMaxU(0.f), xMaxV(0.f), xMaxW(0.f);
68  LArClusterHelper::GetClusterSpanX(pClusterU, xMinU, xMaxU);
69  LArClusterHelper::GetClusterSpanX(pClusterV, xMinV, xMaxV);
70  LArClusterHelper::GetClusterSpanX(pClusterW, xMinW, xMaxW);
71 
72  const float xMin(std::max(xMinU, std::max(xMinV, xMinW)) - m_xOverlapWindow);
73  const float xMax(std::min(xMaxU, std::min(xMaxV, xMaxW)) + m_xOverlapWindow);
74  const float xOverlap(xMax - xMin);
75 
76  if (xOverlap < std::numeric_limits<float>::epsilon())
77  return;
78 
79  // Requirements on 3D matching
81 
82  if ((STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pClusterU, xMin, xMax, u)) ||
83  (STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pClusterV, xMin, xMax, v)) ||
84  (STATUS_CODE_SUCCESS != LArClusterHelper::GetAverageZ(pClusterW, xMin, xMax, w)))
85  {
86  return;
87  }
88 
89  const float uv2w(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_U, TPC_VIEW_V, u, v));
90  const float vw2u(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_V, TPC_VIEW_W, v, w));
91  const float wu2v(LArGeometryHelper::MergeTwoPositions(this->GetPandora(), TPC_VIEW_W, TPC_VIEW_U, w, u));
92 
93  const float pseudoChi2(((u - vw2u) * (u - vw2u) + (v - wu2v) * (v - wu2v) + (w - uv2w) * (w - uv2w)) / 3.f);
94 
95  if (pseudoChi2 > m_pseudoChi2Cut)
96  return;
97 
98  // ATTN Essentially a boolean result; actual value matters only so as to ensure that overlap results can be sorted
99  const float hackValue(pseudoChi2 + pClusterU->GetElectromagneticEnergy() + pClusterV->GetElectromagneticEnergy() + pClusterW->GetElectromagneticEnergy());
100  m_overlapTensor.SetOverlapResult(pClusterU, pClusterV, pClusterW, hackValue);
101 }
102 
103 //------------------------------------------------------------------------------------------------------------------------------------------
104 
106 {
107  unsigned int repeatCounter(0);
108 
109  for (RemnantTensorToolVector::const_iterator iter = m_algorithmToolVector.begin(), iterEnd = m_algorithmToolVector.end(); iter != iterEnd; )
110  {
111  if ((*iter)->Run(this, m_overlapTensor))
112  {
113  iter = m_algorithmToolVector.begin();
114 
115  if (++repeatCounter > m_nMaxTensorToolRepeats)
116  break;
117  }
118  else
119  {
120  ++iter;
121  }
122  }
123 }
124 
125 //------------------------------------------------------------------------------------------------------------------------------------------
126 
127 StatusCode ThreeDRemnantsAlgorithm::ReadSettings(const TiXmlHandle xmlHandle)
128 {
129  AlgorithmToolVector algorithmToolVector;
130  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*this, xmlHandle,
131  "TrackTools", algorithmToolVector));
132 
133  for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
134  {
135  RemnantTensorTool *const pRemnantTensorTool(dynamic_cast<RemnantTensorTool*>(*iter));
136 
137  if (NULL == pRemnantTensorTool)
138  return STATUS_CODE_INVALID_PARAMETER;
139 
140  m_algorithmToolVector.push_back(pRemnantTensorTool);
141  }
142 
143  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
144  "NMaxTensorToolRepeats", m_nMaxTensorToolRepeats));
145 
146  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
147  "MinClusterCaloHits", m_minClusterCaloHits));
148 
149  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
150  "OverlapWindow", m_xOverlapWindow));
151 
152  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
153  "PseudoChi2Cut", m_pseudoChi2Cut));
154 
156 }
157 
158 } // namespace lar_content
void SelectInputClusters(const pandora::ClusterList *const pInputClusterList, pandora::ClusterList &selectedClusterList) const
Select a subset of input clusters for processing in this algorithm.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
unsigned int m_minClusterCaloHits
The selection cut on the number of cluster calo hits.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
float m_pseudoChi2Cut
The selection cut on the matched chi2.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in tensor.
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.
TFile f
Definition: plotHisto.C:6
Header file for the geometry helper class.
pandora::ClusterList m_clusterListW
List of 2D W clusters in a 3D proto particle.
void SetPfoParameters(const ProtoParticle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Calculate Pfo properties from proto particle.
void SetOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, const OverlapResult &overlapResult)
Set overlap result.
Int_t max
Definition: plot.C:27
intermediate_table::const_iterator const_iterator
Header file for the cluster helper class.
TensorType m_overlapTensor
The overlap tensor.
Header file for the three dimensional remnants algorithm class.
pandora::ClusterList m_clusterListV
List of 2D V clusters in a 3D proto particle.
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).
pandora::ClusterList m_clusterListU
List of 2D U clusters in a 3D proto particle.
float m_xOverlapWindow
The sampling pitch in the x coordinate.
Int_t min
Definition: plot.C:26
RemnantTensorToolVector m_algorithmToolVector
The algorithm tool list.
static void GetClusterSpanX(const pandora::Cluster *const pCluster, float &xmin, float &xmax)
Get minimum and maximum X positions of the calo hits in a cluster.
Float_t w
Definition: plot.C:23
void ExamineTensor()
Examine contents of tensor, collect together best-matching 2D particles and modify clusters as requir...
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.