Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
lar_content::TwoViewThreeDKinkTool Class Reference

TwoViewThreeDKinkTool class. More...

#include <TwoViewThreeDKinkTool.h>

Inheritance diagram for lar_content::TwoViewThreeDKinkTool:
lar_content::TransverseMatrixTool

Classes

class  Modification
 Modification class. More...
 
class  Particle
 Particle class. More...
 

Public Member Functions

 TwoViewThreeDKinkTool ()
 Constructor. More...
 
virtual ~TwoViewThreeDKinkTool ()
 Destructor. More...
 
bool Run (TwoViewTransverseTracksAlgorithm *const pAlgorithm, MatrixType &overlapMatrix)
 Run the algorithm tool. More...
 

Private Types

typedef std::vector< ModificationModificationList
 

Private Member Functions

void GetModifications (TwoViewTransverseTracksAlgorithm *const pAlgorithm, const MatrixType &overlapMatrix, ModificationList &modificationList) const
 Get modification objects, identifying required splits and merges for clusters. More...
 
bool PassesElementCuts (MatrixType::ElementList::const_iterator eIter, const pandora::ClusterSet &usedClusters) const
 Whether a provided (iterator to a) matrix element passes the selection cuts for overshoot identification. More...
 
void SelectMatrixElements (MatrixType::ElementList::const_iterator eIter, const MatrixType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
 Select elements representing possible components of interest due to overshoots or undershoots in clustering. More...
 
void GetIteratorListModifications (TwoViewTransverseTracksAlgorithm *const pAlgorithm, const IteratorList &iteratorList, ModificationList &modificationList) const
 Get modification objects for specific elements of the matrix, identifying required splits and merges for clusters. More...
 
bool IsThreeDKink (TwoViewTransverseTracksAlgorithm *const pAlgorithm, const Particle &particle, const pandora::CartesianVector &splitPosition, const bool isALowestInX) const
 Whether the provided particle is consistent with being a kink, when examined in three dimensions at the provided split position. More...
 
float GetXSamplingPoint (const pandora::CartesianVector &splitPosition1, const bool isForwardInX, const TwoDSlidingFitResult &fitResult1, const TwoDSlidingFitResult &fitResult2) const
 Get a sampling point in x that is common to sliding linear fit objects in two views. More...
 
bool ApplyChanges (TwoViewTransverseTracksAlgorithm *const pAlgorithm, const ModificationList &modificationList) const
 Apply the changes cached in a modification list and update the matrix accordingly. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Static Private Member Functions

static bool IsALowestInX (const LArPointingCluster &pointingClusterA, const LArPointingCluster &pointingClusterB)
 Whether pointing cluster labelled A extends to lowest x positions (as opposed to that labelled B) More...
 

Private Attributes

float m_minXOverlapFraction
 The min x overlap fraction value for particle creation. More...
 
float m_minMatchingScore
 The min global matching score for particle creation. More...
 
float m_minLocallyMatchedFraction
 The min locally matched fraction for particle creation. More...
 
float m_minLongitudinalImpactParameter
 The min longitudinal impact parameter for connecting accompanying clusters. More...
 
int m_nLayersForKinkSearch
 The number of sliding fit layers to step in the kink search. More...
 
float m_additionalXStepForKinkSearch
 An additional (safety) step to tack-on when choosing x sampling. More...
 
float m_maxTransverseImpactParameter
 The maximum transverse impact parameter for connecting broken clusters. More...
 
float m_minImpactParameterCosTheta
 The minimum cos theta (angle between vertex directions) for connecting broken clusters. More...
 
float m_cosThetaCutForKinkSearch
 The cos theta cut used for the kink search in three dimensions. More...
 

Additional Inherited Members

- Public Types inherited from lar_content::TransverseMatrixTool
typedef TwoViewTransverseTracksAlgorithm::MatchingType::MatrixType MatrixType
 
typedef std::vector< MatrixType::ElementList::const_iteratorIteratorList
 

Detailed Description

TwoViewThreeDKinkTool class.

Definition at line 21 of file TwoViewThreeDKinkTool.h.

Member Typedef Documentation

Definition at line 50 of file TwoViewThreeDKinkTool.h.

Constructor & Destructor Documentation

lar_content::TwoViewThreeDKinkTool::TwoViewThreeDKinkTool ( )

Constructor.

Parameters
nCommonClustersthe number of common clusters to select

Definition at line 23 of file TwoViewThreeDKinkTool.cc.

23  :
25  m_minMatchingScore(0.95f),
33 {
34 }
float m_minLocallyMatchedFraction
The min locally matched fraction for particle creation.
float m_minMatchingScore
The min global matching score for particle creation.
float m_minXOverlapFraction
The min x overlap fraction value for particle creation.
float m_additionalXStepForKinkSearch
An additional (safety) step to tack-on when choosing x sampling.
float m_maxTransverseImpactParameter
The maximum transverse impact parameter for connecting broken clusters.
int m_nLayersForKinkSearch
The number of sliding fit layers to step in the kink search.
float m_cosThetaCutForKinkSearch
The cos theta cut used for the kink search in three dimensions.
float m_minImpactParameterCosTheta
The minimum cos theta (angle between vertex directions) for connecting broken clusters.
float m_minLongitudinalImpactParameter
The min longitudinal impact parameter for connecting accompanying clusters.
lar_content::TwoViewThreeDKinkTool::~TwoViewThreeDKinkTool ( )
virtual

Destructor.

Definition at line 38 of file TwoViewThreeDKinkTool.cc.

39 {
40 }

Member Function Documentation

bool lar_content::TwoViewThreeDKinkTool::ApplyChanges ( TwoViewTransverseTracksAlgorithm *const  pAlgorithm,
const ModificationList modificationList 
) const
private

Apply the changes cached in a modification list and update the matrix accordingly.

Parameters
pAlgorithmaddress of the calling algorithm
modificationListthe modification list
Returns
whether changes to the matrix have been made

Definition at line 179 of file TwoViewThreeDKinkTool.cc.

180 {
181  ClusterMergeMap consolidatedMergeMap;
182  SplitPositionMap consolidatedSplitMap;
183 
184  for (const Modification &modification : modificationList)
185  {
186  ClusterList parentClusters;
187  for (const auto &mapEntry : modification.m_clusterMergeMap)
188  parentClusters.push_back(mapEntry.first);
189  parentClusters.sort(LArClusterHelper::SortByNHits);
190 
191  for (const Cluster *const pParentCluster : parentClusters)
192  {
193  const ClusterList &daughterClusters(modification.m_clusterMergeMap.at(pParentCluster));
194 
195  for (const Cluster *const pDaughterCluster : daughterClusters)
196  {
197  if (consolidatedMergeMap.count(pDaughterCluster))
198  throw StatusCodeException(STATUS_CODE_FAILURE);
199  }
200 
201  ClusterList &targetClusterList(consolidatedMergeMap[pParentCluster]);
202  targetClusterList.insert(targetClusterList.end(), daughterClusters.begin(), daughterClusters.end());
203  }
204 
205  ClusterList splitClusters;
206  for (const auto &mapEntry : modification.m_splitPositionMap)
207  splitClusters.push_back(mapEntry.first);
208  splitClusters.sort(LArClusterHelper::SortByNHits);
209 
210  for (const Cluster *const pSplitCluster : splitClusters)
211  {
212  const CartesianPointVector &splitPositions(modification.m_splitPositionMap.at(pSplitCluster));
213 
214  CartesianPointVector &cartesianPointVector(consolidatedSplitMap[pSplitCluster]);
215  cartesianPointVector.insert(cartesianPointVector.end(), splitPositions.begin(), splitPositions.end());
216  }
217  }
218 
219  bool changesMade(false);
220  changesMade |= pAlgorithm->MakeClusterMerges(consolidatedMergeMap);
221  changesMade |= pAlgorithm->MakeClusterSplits(consolidatedSplitMap);
222 
223  return changesMade;
224 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
std::unordered_map< const pandora::Cluster *, pandora::CartesianPointVector > SplitPositionMap
std::unordered_map< const pandora::Cluster *, pandora::ClusterList > ClusterMergeMap
void lar_content::TwoViewThreeDKinkTool::GetIteratorListModifications ( TwoViewTransverseTracksAlgorithm *const  pAlgorithm,
const IteratorList iteratorList,
ModificationList modificationList 
) const
private

Get modification objects for specific elements of the matrix, identifying required splits and merges for clusters.

Parameters
pAlgorithmaddress of the calling algorithm
iteratorListlist of iterators to relevant tensor elements
modificationListto be populated with modifications

Definition at line 268 of file TwoViewThreeDKinkTool.cc.

270 {
271  for (IteratorList::const_iterator iIter1 = iteratorList.begin(), iIter1End = iteratorList.end(); iIter1 != iIter1End; ++iIter1)
272  {
273  for (IteratorList::const_iterator iIter2 = std::next(iIter1); iIter2 != iIter1End; ++iIter2)
274  {
275  try
276  {
277  const unsigned int nMatchedReUpsampledSamplingPoints1((*iIter1)->GetOverlapResult().GetNMatchedReUpsampledSamplingPoints());
278  const unsigned int nMatchedReUpsampledSamplingPoints2((*iIter2)->GetOverlapResult().GetNMatchedReUpsampledSamplingPoints());
279  IteratorList::const_iterator iIterA((nMatchedReUpsampledSamplingPoints1 >= nMatchedReUpsampledSamplingPoints2) ? iIter1 : iIter2);
280  IteratorList::const_iterator iIterB((nMatchedReUpsampledSamplingPoints1 >= nMatchedReUpsampledSamplingPoints2) ? iIter2 : iIter1);
281 
282  Particle particle(*(*iIterA), *(*iIterB));
283  const LArPointingCluster pointingClusterA(pAlgorithm->GetCachedSlidingFitResult(particle.m_pClusterA));
284  const LArPointingCluster pointingClusterB(pAlgorithm->GetCachedSlidingFitResult(particle.m_pClusterB));
285 
286  LArPointingCluster::Vertex vertexA, vertexB;
287  LArPointingClusterHelper::GetClosestVertices(pointingClusterA, pointingClusterB, vertexA, vertexB);
288 
289  float transverseAB(std::numeric_limits<float>::max()), transverseBA(std::numeric_limits<float>::max());
290  float longitudinalAB(-std::numeric_limits<float>::max()), longitudinalBA(-std::numeric_limits<float>::max());
291 
292  LArPointingClusterHelper::GetImpactParameters(vertexA, vertexB, longitudinalAB, transverseAB);
293  LArPointingClusterHelper::GetImpactParameters(vertexB, vertexA, longitudinalBA, transverseBA);
294 
295  if (std::min(longitudinalAB, longitudinalBA) < m_minLongitudinalImpactParameter)
296  continue;
297 
298  if (std::min(transverseAB, transverseBA) > m_maxTransverseImpactParameter)
299  continue;
300 
301  const float cosTheta(-vertexA.GetDirection().GetCosOpeningAngle(vertexB.GetDirection()));
302 
303  if (cosTheta < m_minImpactParameterCosTheta)
304  continue;
305 
306  const bool isALowestInX(this->IsALowestInX(pointingClusterA, pointingClusterB));
307  const CartesianVector splitPosition((vertexA.GetPosition() + vertexB.GetPosition()) * 0.5f);
308  const bool isThreeDKink(this->IsThreeDKink(pAlgorithm, particle, splitPosition, isALowestInX));
309 
310  // Construct the modification object
311  Modification modification;
312 
313  if (isThreeDKink)
314  {
315  const TwoDSlidingFitResult &fitResultCommon(pAlgorithm->GetCachedSlidingFitResult(particle.m_pCommonCluster));
316 
317  CartesianVector splitPositionCommon(0.f, 0.f, 0.f);
318  if (STATUS_CODE_SUCCESS != fitResultCommon.GetGlobalFitPositionAtX(splitPosition.GetX(), splitPositionCommon))
319  {
320  continue;
321  }
322 
323  modification.m_splitPositionMap[particle.m_pCommonCluster].push_back(splitPositionCommon);
324  }
325  else
326  {
327  const bool vertexAIsLowX(vertexA.GetPosition().GetX() < vertexB.GetPosition().GetX());
328  const Cluster *const pLowXCluster(vertexAIsLowX ? particle.m_pClusterA : particle.m_pClusterB);
329  const Cluster *const pHighXCluster(vertexAIsLowX ? particle.m_pClusterB : particle.m_pClusterA);
330  modification.m_clusterMergeMap[pLowXCluster].push_back(pHighXCluster);
331  }
332 
333  modification.m_affectedClusters.push_back(particle.m_pClusterA);
334  modification.m_affectedClusters.push_back(particle.m_pClusterB);
335  modification.m_affectedClusters.push_back(particle.m_pCommonCluster);
336 
337  modificationList.push_back(modification);
338  }
339  catch (const StatusCodeException &statusCodeException)
340  {
341  if (STATUS_CODE_FAILURE == statusCodeException.GetStatusCode())
342  throw statusCodeException;
343 
344  continue;
345  }
346  }
347  }
348 }
static bool IsALowestInX(const LArPointingCluster &pointingClusterA, const LArPointingCluster &pointingClusterB)
Whether pointing cluster labelled A extends to lowest x positions (as opposed to that labelled B) ...
static void GetImpactParameters(const LArPointingCluster::Vertex &pointingVertex, const LArPointingCluster::Vertex &targetVertex, float &longitudinal, float &transverse)
Calculate impact parameters between a pair of pointing vertices.
intermediate_table::const_iterator const_iterator
static void GetClosestVertices(const bool useX, const bool useY, const bool useZ, const LArPointingCluster &pointingClusterI, const LArPointingCluster &pointingClusterJ, LArPointingCluster::Vertex &closestVertexI, LArPointingCluster::Vertex &closestVertexJ)
Given a pair of pointing clusters, receive the closest or farthest pair of vertices.
bool IsThreeDKink(TwoViewTransverseTracksAlgorithm *const pAlgorithm, const Particle &particle, const pandora::CartesianVector &splitPosition, const bool isALowestInX) const
Whether the provided particle is consistent with being a kink, when examined in three dimensions at t...
float m_maxTransverseImpactParameter
The maximum transverse impact parameter for connecting broken clusters.
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
float m_minImpactParameterCosTheta
The minimum cos theta (angle between vertex directions) for connecting broken clusters.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
float m_minLongitudinalImpactParameter
The min longitudinal impact parameter for connecting accompanying clusters.
void lar_content::TwoViewThreeDKinkTool::GetModifications ( TwoViewTransverseTracksAlgorithm *const  pAlgorithm,
const MatrixType overlapMatrix,
ModificationList modificationList 
) const
private

Get modification objects, identifying required splits and merges for clusters.

Parameters
pAlgorithmaddress of the calling algorithm
overlapMatrixthe overlap matrix
modificationListto be populated with modifications

Definition at line 131 of file TwoViewThreeDKinkTool.cc.

133 {
134  ClusterSet usedClusters;
135  ClusterVector sortedKeyClusters;
136  overlapMatrix.GetSortedKeyClusters(sortedKeyClusters);
137 
138  for (const Cluster *const pKeyCluster : sortedKeyClusters)
139  {
140  if (!pKeyCluster->IsAvailable())
141  continue;
142 
143  unsigned int n1(0), n2(0);
144  MatrixType::ElementList elementList;
145  overlapMatrix.GetConnectedElements(pKeyCluster, true, elementList, n1, n2);
146 
147  if (n1 * n2 < 2)
148  continue;
149 
150  for (MatrixType::ElementList::const_iterator eIter = elementList.begin(); eIter != elementList.end(); ++eIter)
151  {
152  if (!this->PassesElementCuts(eIter, usedClusters))
153  continue;
154 
155  IteratorList iteratorList;
156  this->SelectMatrixElements(eIter, elementList, usedClusters, iteratorList);
157 
158  if (iteratorList.size() < 2)
159  continue;
160 
161  ModificationList localModificationList;
162  this->GetIteratorListModifications(pAlgorithm, iteratorList, localModificationList);
163 
164  if (localModificationList.empty())
165  continue;
166 
167  for (ModificationList::const_iterator mIter = localModificationList.begin(), mIterEnd = localModificationList.end(); mIter != mIterEnd; ++mIter)
168  {
169  usedClusters.insert(mIter->m_affectedClusters.begin(), mIter->m_affectedClusters.end());
170  }
171 
172  modificationList.insert(modificationList.end(), localModificationList.begin(), localModificationList.end());
173  }
174  }
175 }
intermediate_table::const_iterator const_iterator
std::vector< Modification > ModificationList
void SelectMatrixElements(MatrixType::ElementList::const_iterator eIter, const MatrixType::ElementList &elementList, const pandora::ClusterSet &usedClusters, IteratorList &iteratorList) const
Select elements representing possible components of interest due to overshoots or undershoots in clus...
bool PassesElementCuts(MatrixType::ElementList::const_iterator eIter, const pandora::ClusterSet &usedClusters) const
Whether a provided (iterator to a) matrix element passes the selection cuts for overshoot identificat...
void GetIteratorListModifications(TwoViewTransverseTracksAlgorithm *const pAlgorithm, const IteratorList &iteratorList, ModificationList &modificationList) const
Get modification objects for specific elements of the matrix, identifying required splits and merges ...
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::vector< MatrixType::ElementList::const_iterator > IteratorList
float lar_content::TwoViewThreeDKinkTool::GetXSamplingPoint ( const pandora::CartesianVector &  splitPosition1,
const bool  isForwardInX,
const TwoDSlidingFitResult fitResult1,
const TwoDSlidingFitResult fitResult2 
) const
private

Get a sampling point in x that is common to sliding linear fit objects in two views.

Parameters
splitPosition1the split position in view 1
isForwardInXwhether to work forwards (or backwards) in x
fitResult1the sliding fit result in view 1
fitResult2the sliding fit result in view 2
Returns
the sampling point

Definition at line 80 of file TwoViewThreeDKinkTool.cc.

82 {
83  // Nearest common x position
84  float xMin1(std::numeric_limits<float>::max()), xMax1(std::numeric_limits<float>::lowest());
85  float xMin2(std::numeric_limits<float>::max()), xMax2(std::numeric_limits<float>::lowest());
86  fitResult1.GetMinAndMaxX(xMin1, xMax1);
87  fitResult2.GetMinAndMaxX(xMin2, xMax2);
88 
89  const float commonX(isForwardInX ? std::max(xMin1, xMin2) : std::min(xMax1, xMax2));
90 
91  if (isForwardInX && ((commonX > xMax1) || (commonX > xMax2)))
92  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
93 
94  if (!isForwardInX && ((commonX < xMin1) || (commonX < xMin2)))
95  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
96 
97  // Layer step x position
98  float rL1(0.f), rT1(0.f);
99  fitResult1.GetLocalPosition(splitPosition1, rL1, rT1);
100  const int splitLayer(fitResult1.GetLayer(rL1));
101 
102  const int lowLayer(std::max(fitResult1.GetMinLayer(), std::min(fitResult1.GetMaxLayer(), splitLayer - m_nLayersForKinkSearch)));
103  const int highLayer(std::max(fitResult1.GetMinLayer(), std::min(fitResult1.GetMaxLayer(), splitLayer + m_nLayersForKinkSearch)));
104 
105  CartesianVector minus(0.f, 0.f, 0.f), plus(0.f, 0.f, 0.f);
106  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, fitResult1.GetGlobalFitPosition(fitResult1.GetL(lowLayer), minus));
107  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, fitResult1.GetGlobalFitPosition(fitResult1.GetL(highLayer), plus));
108 
109  if (minus.GetX() > plus.GetX())
110  std::swap(minus, plus);
111 
112  const float layerStepX(isForwardInX ? plus.GetX() : minus.GetX());
113 
114  // Final x position selection
115  const float chosenX(isForwardInX ? std::max(layerStepX, commonX) : std::min(layerStepX, commonX));
116  const float finalX(isForwardInX ? chosenX + m_additionalXStepForKinkSearch : chosenX - m_additionalXStepForKinkSearch);
117  return finalX;
118 }
float m_additionalXStepForKinkSearch
An additional (safety) step to tack-on when choosing x sampling.
void swap(Handle< T > &a, Handle< T > &b)
int m_nLayersForKinkSearch
The number of sliding fit layers to step in the kink search.
static int max(int a, int b)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
bool lar_content::TwoViewThreeDKinkTool::IsALowestInX ( const LArPointingCluster pointingClusterA,
const LArPointingCluster pointingClusterB 
)
staticprivate

Whether pointing cluster labelled A extends to lowest x positions (as opposed to that labelled B)

Parameters
pointingClusterApointing cluster A
pointingClusterBpointing cluster B

Definition at line 122 of file TwoViewThreeDKinkTool.cc.

123 {
124  const float xMinA{std::min(pointingClusterA.GetInnerVertex().GetPosition().GetX(), pointingClusterA.GetOuterVertex().GetPosition().GetX())};
125  const float xMinB{std::min(pointingClusterB.GetInnerVertex().GetPosition().GetX(), pointingClusterB.GetOuterVertex().GetPosition().GetX())};
126  return xMinA < xMinB;
127 }
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:55
bool lar_content::TwoViewThreeDKinkTool::IsThreeDKink ( TwoViewTransverseTracksAlgorithm *const  pAlgorithm,
const Particle particle,
const pandora::CartesianVector &  splitPosition,
const bool  isALowestInX 
) const
private

Whether the provided particle is consistent with being a kink, when examined in three dimensions at the provided split position.

Parameters
pAlgorithmthe calling algorithm
particlethe particle
splitPositionthe candidate split position
isALowestInXwhether cluster associated with matrix element a extends to lowest x positions
Returns
boolean

Definition at line 352 of file TwoViewThreeDKinkTool.cc.

354 {
355  try
356  {
357  const TwoDSlidingFitResult &fitResultCommon(pAlgorithm->GetCachedSlidingFitResult(particle.m_pCommonCluster));
358  const TwoDSlidingFitResult &lowXFitResult(isALowestInX ? pAlgorithm->GetCachedSlidingFitResult(particle.m_pClusterA)
359  : pAlgorithm->GetCachedSlidingFitResult(particle.m_pClusterB));
360  const TwoDSlidingFitResult &highXFitResult(isALowestInX ? pAlgorithm->GetCachedSlidingFitResult(particle.m_pClusterB)
361  : pAlgorithm->GetCachedSlidingFitResult(particle.m_pClusterA));
362 
363  const float minusX(this->GetXSamplingPoint(splitPosition, false, lowXFitResult, fitResultCommon));
364  const float plusX(this->GetXSamplingPoint(splitPosition, true, highXFitResult, fitResultCommon));
365  const float splitX(splitPosition.GetX());
366 
367  CartesianVector minus1(0.f, 0.f, 0.f), split1(0.f, 0.f, 0.f), plus1(0.f, 0.f, 0.f);
368  CartesianVector minus2(0.f, 0.f, 0.f), split2(splitPosition), plus2(0.f, 0.f, 0.f);
369 
370  if ((STATUS_CODE_SUCCESS != fitResultCommon.GetGlobalFitPositionAtX(minusX, minus1)) ||
371  (STATUS_CODE_SUCCESS != fitResultCommon.GetGlobalFitPositionAtX(splitX, split1)) ||
372  (STATUS_CODE_SUCCESS != fitResultCommon.GetGlobalFitPositionAtX(plusX, plus1)) ||
373  (STATUS_CODE_SUCCESS != lowXFitResult.GetGlobalFitPositionAtX(minusX, minus2)) ||
374  (STATUS_CODE_SUCCESS != highXFitResult.GetGlobalFitPositionAtX(plusX, plus2)))
375  {
376  return true; // split by default
377  }
378 
379  // Extract results
380  const HitType hitType1(LArClusterHelper::GetClusterHitType(particle.m_pCommonCluster));
381  const HitType hitType2(LArClusterHelper::GetClusterHitType(particle.m_pClusterA));
382 
383  CartesianVector minus(0.f, 0.f, 0.f), split(0.f, 0.f, 0.f), plus(0.f, 0.f, 0.f);
384  float chi2Dummy(std::numeric_limits<float>::max());
385  LArGeometryHelper::MergeTwoPositions3D(this->GetPandora(), hitType1, hitType2, minus1, minus2, minus, chi2Dummy);
386  LArGeometryHelper::MergeTwoPositions3D(this->GetPandora(), hitType1, hitType2, split1, split2, split, chi2Dummy);
387  LArGeometryHelper::MergeTwoPositions3D(this->GetPandora(), hitType1, hitType2, plus1, plus2, plus, chi2Dummy);
388 
389  // Apply final cuts
390  const CartesianVector minusToSplit((split - minus).GetUnitVector());
391  const CartesianVector splitToPlus((plus - split).GetUnitVector());
392  const float dotProduct(minusToSplit.GetDotProduct(splitToPlus));
393 
394  if (dotProduct < m_cosThetaCutForKinkSearch)
395  return true;
396  }
397  catch (const StatusCodeException &)
398  {
399  }
400 
401  return false;
402 }
static void MergeTwoPositions3D(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const pandora::CartesianVector &position1, const pandora::CartesianVector &position2, pandora::CartesianVector &position3D, float &chiSquared)
Merge 2D positions from two views to give unified 3D position.
enum cvn::HType HitType
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
static int max(int a, int b)
float m_cosThetaCutForKinkSearch
The cos theta cut used for the kink search in three dimensions.
void split(std::string const &s, char c, OutIter dest)
Definition: split.h:35
float GetXSamplingPoint(const pandora::CartesianVector &splitPosition1, const bool isForwardInX, const TwoDSlidingFitResult &fitResult1, const TwoDSlidingFitResult &fitResult2) const
Get a sampling point in x that is common to sliding linear fit objects in two views.
bool lar_content::TwoViewThreeDKinkTool::PassesElementCuts ( MatrixType::ElementList::const_iterator  eIter,
const pandora::ClusterSet &  usedClusters 
) const
private

Whether a provided (iterator to a) matrix element passes the selection cuts for overshoot identification.

Parameters
eIterthe iterator to the matrix element
usedClustersthe list of used clusters

Definition at line 58 of file TwoViewThreeDKinkTool.cc.

59 {
60  if (usedClusters.count(eIter->GetCluster1()) || usedClusters.count(eIter->GetCluster2()))
61  return false;
62 
63  if (eIter->GetOverlapResult().GetTwoViewXOverlap().GetXOverlapFraction0() - m_minXOverlapFraction < std::numeric_limits<float>::epsilon())
64  return false;
65 
66  if (eIter->GetOverlapResult().GetTwoViewXOverlap().GetXOverlapFraction1() - m_minXOverlapFraction < std::numeric_limits<float>::epsilon())
67  return false;
68 
69  if (eIter->GetOverlapResult().GetMatchingScore() - m_minMatchingScore < std::numeric_limits<float>::epsilon())
70  return false;
71 
72  if (eIter->GetOverlapResult().GetLocallyMatchedFraction() - m_minLocallyMatchedFraction < std::numeric_limits<float>::epsilon())
73  return false;
74 
75  return true;
76 }
StatusCode lar_content::TwoViewThreeDKinkTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 419 of file TwoViewThreeDKinkTool.cc.

420 {
421  PANDORA_RETURN_RESULT_IF_AND_IF(
422  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinMatchingScore", m_minMatchingScore));
423 
424  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
425  XmlHelper::ReadValue(xmlHandle, "MinLocallyMatchedFraction", m_minLocallyMatchedFraction));
426 
427  PANDORA_RETURN_RESULT_IF_AND_IF(
428  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinXOverlapFraction", m_minXOverlapFraction));
429 
430  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
431  XmlHelper::ReadValue(xmlHandle, "MinLongitudinalImpactParameter", m_minLongitudinalImpactParameter));
432 
433  PANDORA_RETURN_RESULT_IF_AND_IF(
434  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NLayersForKinkSearch", m_nLayersForKinkSearch));
435 
436  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
437  XmlHelper::ReadValue(xmlHandle, "AdditionalXStepForKinkSearch", m_additionalXStepForKinkSearch));
438 
439  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
440  XmlHelper::ReadValue(xmlHandle, "MaxTransverseImpactParameter", m_maxTransverseImpactParameter));
441 
442  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
443  XmlHelper::ReadValue(xmlHandle, "MinImpactParameterCosTheta", m_minImpactParameterCosTheta));
444 
445  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
446  XmlHelper::ReadValue(xmlHandle, "CosThetaCutForKinkSearch", m_cosThetaCutForKinkSearch));
447 
448  return STATUS_CODE_SUCCESS;
449 }
float m_minLocallyMatchedFraction
The min locally matched fraction for particle creation.
float m_minMatchingScore
The min global matching score for particle creation.
float m_minXOverlapFraction
The min x overlap fraction value for particle creation.
float m_additionalXStepForKinkSearch
An additional (safety) step to tack-on when choosing x sampling.
float m_maxTransverseImpactParameter
The maximum transverse impact parameter for connecting broken clusters.
int m_nLayersForKinkSearch
The number of sliding fit layers to step in the kink search.
float m_cosThetaCutForKinkSearch
The cos theta cut used for the kink search in three dimensions.
float m_minImpactParameterCosTheta
The minimum cos theta (angle between vertex directions) for connecting broken clusters.
float m_minLongitudinalImpactParameter
The min longitudinal impact parameter for connecting accompanying clusters.
bool lar_content::TwoViewThreeDKinkTool::Run ( TwoViewTransverseTracksAlgorithm *const  pAlgorithm,
MatrixType overlapMatrix 
)
virtual

Run the algorithm tool.

Parameters
pAlgorithmaddress of the calling algorithm
overlapMatrixthe overlap matrix
Returns
whether changes have been made by the tool

Implements lar_content::TransverseMatrixTool.

Definition at line 44 of file TwoViewThreeDKinkTool.cc.

45 {
46  if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
47  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
48 
49  ModificationList modificationList;
50  this->GetModifications(pAlgorithm, overlapMatrix, modificationList);
51  const bool changesMade(this->ApplyChanges(pAlgorithm, modificationList));
52 
53  return changesMade;
54 }
std::vector< Modification > ModificationList
void GetModifications(TwoViewTransverseTracksAlgorithm *const pAlgorithm, const MatrixType &overlapMatrix, ModificationList &modificationList) const
Get modification objects, identifying required splits and merges for clusters.
bool ApplyChanges(TwoViewTransverseTracksAlgorithm *const pAlgorithm, const ModificationList &modificationList) const
Apply the changes cached in a modification list and update the matrix accordingly.
QTextStream & endl(QTextStream &s)
void lar_content::TwoViewThreeDKinkTool::SelectMatrixElements ( MatrixType::ElementList::const_iterator  eIter,
const MatrixType::ElementList elementList,
const pandora::ClusterSet &  usedClusters,
IteratorList iteratorList 
) const
private

Select elements representing possible components of interest due to overshoots or undershoots in clustering.

Parameters
eIteriterator to a candidate element
elementListthe provided element list
usedClustersthe list of used clusters
iteratorListto receive a list of iterators to relevant elements

Definition at line 228 of file TwoViewThreeDKinkTool.cc.

230 {
231  iteratorList.push_back(eIter);
232 
233  for (MatrixType::ElementList::const_iterator eIter2 = elementList.begin(); eIter2 != elementList.end(); ++eIter2)
234  {
235  if (eIter == eIter2)
236  continue;
237 
238  if (!this->PassesElementCuts(eIter2, usedClusters))
239  continue;
240 
241  for (IteratorList::const_iterator iIter = iteratorList.begin(); iIter != iteratorList.end(); ++iIter)
242  {
243  if ((*iIter) == eIter2)
244  continue;
245 
246  unsigned int nMatchedClusters(0);
247 
248  if ((*iIter)->GetCluster1() == eIter2->GetCluster1())
249  ++nMatchedClusters;
250 
251  if ((*iIter)->GetCluster2() == eIter2->GetCluster2())
252  ++nMatchedClusters;
253 
254  if (nMatchedClusters > 1)
255  continue;
256 
257  if (nMatchedClusters)
258  {
259  iteratorList.push_back(eIter2);
260  return;
261  }
262  }
263  }
264 }
intermediate_table::const_iterator const_iterator
bool PassesElementCuts(MatrixType::ElementList::const_iterator eIter, const pandora::ClusterSet &usedClusters) const
Whether a provided (iterator to a) matrix element passes the selection cuts for overshoot identificat...

Member Data Documentation

float lar_content::TwoViewThreeDKinkTool::m_additionalXStepForKinkSearch
private

An additional (safety) step to tack-on when choosing x sampling.

Definition at line 168 of file TwoViewThreeDKinkTool.h.

float lar_content::TwoViewThreeDKinkTool::m_cosThetaCutForKinkSearch
private

The cos theta cut used for the kink search in three dimensions.

Definition at line 171 of file TwoViewThreeDKinkTool.h.

float lar_content::TwoViewThreeDKinkTool::m_maxTransverseImpactParameter
private

The maximum transverse impact parameter for connecting broken clusters.

Definition at line 169 of file TwoViewThreeDKinkTool.h.

float lar_content::TwoViewThreeDKinkTool::m_minImpactParameterCosTheta
private

The minimum cos theta (angle between vertex directions) for connecting broken clusters.

Definition at line 170 of file TwoViewThreeDKinkTool.h.

float lar_content::TwoViewThreeDKinkTool::m_minLocallyMatchedFraction
private

The min locally matched fraction for particle creation.

Definition at line 165 of file TwoViewThreeDKinkTool.h.

float lar_content::TwoViewThreeDKinkTool::m_minLongitudinalImpactParameter
private

The min longitudinal impact parameter for connecting accompanying clusters.

Definition at line 166 of file TwoViewThreeDKinkTool.h.

float lar_content::TwoViewThreeDKinkTool::m_minMatchingScore
private

The min global matching score for particle creation.

Definition at line 164 of file TwoViewThreeDKinkTool.h.

float lar_content::TwoViewThreeDKinkTool::m_minXOverlapFraction
private

The min x overlap fraction value for particle creation.

Definition at line 163 of file TwoViewThreeDKinkTool.h.

int lar_content::TwoViewThreeDKinkTool::m_nLayersForKinkSearch
private

The number of sliding fit layers to step in the kink search.

Definition at line 167 of file TwoViewThreeDKinkTool.h.


The documentation for this class was generated from the following files: