LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::TwoViewCosmicRayRemovalTool Class Reference

TwoViewCosmicRayRemovalTool class. More...

#include "TwoViewCosmicRayRemovalTool.h"

Inheritance diagram for lar_content::TwoViewCosmicRayRemovalTool:
lar_content::DeltaRayMatrixTool

Public Types

typedef std::vector< pandora::HitType > HitTypeVector
 
typedef TwoViewDeltaRayMatchingAlgorithm::MatchingType::MatrixType MatrixType
 
typedef std::vector< MatrixType::ElementList::const_iteratorIteratorList
 

Public Member Functions

 TwoViewCosmicRayRemovalTool ()
 Default constructor. More...
 

Public Attributes

TwoViewDeltaRayMatchingAlgorithmm_pParentAlgorithm
 Address of the parent matching algorithm. More...
 

Private Member Functions

bool Run (TwoViewDeltaRayMatchingAlgorithm *const pAlgorithm, MatrixType &overlapMatrix)
 Run the algorithm tool. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
bool RemoveCosmicRayHits (const MatrixType::ElementList &elementList) const
 Remove hits from delta ray clusters that belong to the parent muon. More...
 
bool PassElementChecks (const MatrixType::Element &element, const pandora::HitType hitType) const
 Determine whether element satifies simple checks. More...
 
bool IsMuonEndpoint (const MatrixType::Element &element, const pandora::HitType hitType) const
 Determine whether the matched clusters suggest that the delta ray is at the endpoint of the cosmic ray (and is likely to be a michel) More...
 
bool IsContaminated (const MatrixType::Element &element, const pandora::HitType hitType) const
 Determine whether the cluster under investigation has muon contamination. More...
 
bool IsCloseToLine (const pandora::CartesianVector &hitPosition, const pandora::CartesianVector &lineStart, const pandora::CartesianVector &lineEnd, const float distanceToLine) const
 Whether a given position is close to a defined line. More...
 
bool IsInLineSegment (const pandora::CartesianVector &lowerBoundary, const pandora::CartesianVector &upperBoundary, const pandora::CartesianVector &point) const
 Whether the projection of a given position lies on a defined line. More...
 
bool IsBestElement (const MatrixType::Element &element, const pandora::HitType hitType, const MatrixType::ElementList &elementList) const
 Determine whether the input element is the best to use to modify the contaminated cluster (best is defined by the total hit count) More...
 
void CreateSeed (const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits) const
 Collect hits in the delta ray cluster that lie close to calculated projected positions forming a seed to later grow. More...
 
pandora::StatusCode GrowSeed (const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits, pandora::CaloHitList &deltaRayRemantHits) const
 Examine remaining hits in the delta ray cluster adding them to the delta ray seed or parent muon if appropriate and a separate list if not. More...
 
void CollectHitsFromDeltaRay (const pandora::CartesianVector &positionOnMuon, const pandora::CartesianVector &muonDirection, const pandora::Cluster *const pDeltaRayCluster, const float &minDistanceFromMuon, const bool demandCloserToCollected, const pandora::CaloHitList &protectedHits, pandora::CaloHitList &collectedHits) const
 Collect hits from the delta ray cluster to either keep (demandCloserToCollected == true) or separate into a new shower (demandCloserToCollected == false) More...
 
void SplitDeltaRayCluster (const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits, pandora::CaloHitList &deltaRayRemnantHits) const
 Fragment the delta ray cluster, refining the matched delta ray cluster perhaps creating significant remnants in the process. More...
 
void ReclusterRemnant (const pandora::HitType hitType, const pandora::Cluster *const pMuonCluster, const pandora::Cluster *const pDeltaRayRemnant, pandora::ClusterVector &clusterVector, pandora::PfoVector &pfoVector) const
 Reculster the remnant cluster, merging insignificant created clusters into the parent muon (if proximity checks pass) More...
 
pandora::StatusCode ProjectDeltaRayPositions (const MatrixType::Element &element, const pandora::HitType hitType, pandora::CartesianPointVector &projectedPositions) const
 Use two views of a delta ray pfo to calculate projected positions in a given third view. More...
 

Private Attributes

float m_minSeparation
 The minimum delta ray - parent muon cluster separation required to investigate delta ray cluster. More...
 
unsigned int m_slidingFitWindow
 The sliding fit window used in cosmic ray parameterisations. More...
 
float m_distanceToLine
 The maximum perpendicular distance of a position to a line for it to be considered close. More...
 
float m_minContaminationLength
 The minimum projected length of a delta ray cluster onto the muon track for it to be considered contaminated. More...
 
float m_maxDistanceToHit
 The maximum distance of a hit from the cosmic ray track for it to be added into the CR. More...
 
unsigned int m_minRemnantClusterSize
 The minimum hit number of a remnant cluster for it to be considered significant. More...
 
float m_maxDistanceToTrack
 The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merged into the CR. More...
 

Detailed Description

Member Typedef Documentation

typedef std::vector<pandora::HitType> lar_content::TwoViewCosmicRayRemovalTool::HitTypeVector

Definition at line 21 of file TwoViewCosmicRayRemovalTool.h.

Constructor & Destructor Documentation

lar_content::TwoViewCosmicRayRemovalTool::TwoViewCosmicRayRemovalTool ( )

Default constructor.

Definition at line 22 of file TwoViewCosmicRayRemovalTool.cc.

22  :
23  m_minSeparation(2.f),
24  m_slidingFitWindow(10000),
25  m_distanceToLine(0.5f),
30 {
31 }
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
unsigned int m_minRemnantClusterSize
The minimum hit number of a remnant cluster for it to be considered significant.
TFile f
Definition: plotHisto.C:6
float m_distanceToLine
The maximum perpendicular distance of a position to a line for it to be considered close...
float m_maxDistanceToTrack
The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merge...
float m_minContaminationLength
The minimum projected length of a delta ray cluster onto the muon track for it to be considered conta...
float m_minSeparation
The minimum delta ray - parent muon cluster separation required to investigate delta ray cluster...
float m_maxDistanceToHit
The maximum distance of a hit from the cosmic ray track for it to be added into the CR...

Member Function Documentation

void lar_content::TwoViewCosmicRayRemovalTool::CollectHitsFromDeltaRay ( const pandora::CartesianVector &  positionOnMuon,
const pandora::CartesianVector &  muonDirection,
const pandora::Cluster *const  pDeltaRayCluster,
const float &  minDistanceFromMuon,
const bool  demandCloserToCollected,
const pandora::CaloHitList &  protectedHits,
pandora::CaloHitList &  collectedHits 
) const
private

Collect hits from the delta ray cluster to either keep (demandCloserToCollected == true) or separate into a new shower (demandCloserToCollected == false)

Parameters
positionOnMuonthe parameterised muon position
muonDirectionthe parameterised muon direction
pDeltaRayClusterthe delta ray cluster under investigation
minDistanceFromMuonthe minimum distance of a hit from the muon track for it to not belong to the muon
demandCloserToCollectedwhether to demand a hit be closer to the collected hits than to the muon hits for it to be collected
protectedHitsthe hits that are protected from being collected
collectedHitsthe output list of collected hits

Definition at line 374 of file TwoViewCosmicRayRemovalTool.cc.

References lar_content::LArClusterHelper::GetClosestDistance().

Referenced by GrowSeed().

377 {
378  CaloHitList deltaRayHitList;
379  pDeltaRayCluster->GetOrderedCaloHitList().FillCaloHitList(deltaRayHitList);
380 
381  bool hitsAdded(false);
382 
383  do
384  {
385  hitsAdded = false;
386 
387  for (const CaloHit *const pCaloHit : deltaRayHitList)
388  {
389  if (std::find(protectedHits.begin(), protectedHits.end(), pCaloHit) != protectedHits.end())
390  continue;
391 
392  if (std::find(collectedHits.begin(), collectedHits.end(), pCaloHit) != collectedHits.end())
393  continue;
394 
395  const float distanceToCollectedHits(collectedHits.empty()
396  ? std::numeric_limits<float>::max()
397  : LArClusterHelper::GetClosestDistance(pCaloHit->GetPositionVector(), collectedHits));
398  const float distanceToMuonHits(muonDirection.GetCrossProduct(pCaloHit->GetPositionVector() - positionOnMuon).GetMagnitude());
399 
400  if ((distanceToMuonHits < minDistanceFromMuon) || (demandCloserToCollected && (distanceToCollectedHits > distanceToMuonHits)))
401  continue;
402 
403  collectedHits.push_back(pCaloHit);
404  hitsAdded = true;
405  }
406  } while (hitsAdded);
407 }
void lar_content::TwoViewCosmicRayRemovalTool::CreateSeed ( const MatrixType::Element &  element,
const pandora::HitType  hitType,
pandora::CaloHitList &  collectedHits 
) const
private

Collect hits in the delta ray cluster that lie close to calculated projected positions forming a seed to later grow.

Parameters
elementthe matrix element
hitTypethe hit type of the cluster under investigation
collectedHitsthe output list of identified delta ray hits

Definition at line 302 of file TwoViewCosmicRayRemovalTool.cc.

References f, lar_content::LArClusterHelper::GetClosestDistance(), lar_content::TwoViewDeltaRayMatchingAlgorithm::GetCluster(), m_maxDistanceToHit, lar_content::DeltaRayMatrixTool::m_pParentAlgorithm, lar_content::NViewDeltaRayMatchingAlgorithm< T >::ParameteriseMuon(), ProjectDeltaRayPositions(), and lar_content::LArClusterHelper::SortHitsByPosition().

Referenced by RemoveCosmicRayHits().

303 {
304  // To avoid fluctuations, parameterise the muon track
305  CartesianVector positionOnMuon(0.f, 0.f, 0.f), muonDirection(0.f, 0.f, 0.f);
306  if (m_pParentAlgorithm->ParameteriseMuon(element.GetOverlapResult().GetCommonMuonPfoList().front(),
307  m_pParentAlgorithm->GetCluster(element, hitType), positionOnMuon, muonDirection) != STATUS_CODE_SUCCESS)
308  return;
309 
310  CartesianPointVector deltaRayProjectedPositions;
311  if (this->ProjectDeltaRayPositions(element, hitType, deltaRayProjectedPositions) != STATUS_CODE_SUCCESS)
312  return;
313 
314  CaloHitList deltaRayHitList;
315  m_pParentAlgorithm->GetCluster(element, hitType)->GetOrderedCaloHitList().FillCaloHitList(deltaRayHitList);
316 
317  CaloHitVector deltaRayHitVector(deltaRayHitList.begin(), deltaRayHitList.end());
318  std::sort(deltaRayHitVector.begin(), deltaRayHitVector.end(), LArClusterHelper::SortHitsByPosition);
319 
320  for (const CaloHit *const pCaloHit : deltaRayHitVector)
321  {
322  const CartesianVector &position(pCaloHit->GetPositionVector());
323 
324  for (const CartesianVector &projectedPosition : deltaRayProjectedPositions)
325  {
326  const float distanceToProjectionSquared((position - projectedPosition).GetMagnitudeSquared());
327 
328  if (distanceToProjectionSquared < m_maxDistanceToHit * m_maxDistanceToHit)
329  {
330  // To prevent gappy seeds
331  if ((!collectedHits.empty()) && (LArClusterHelper::GetClosestDistance(position, collectedHits) > m_maxDistanceToHit))
332  continue;
333 
334  const float distanceToMuonHitsSquared(muonDirection.GetCrossProduct(position - positionOnMuon).GetMagnitudeSquared());
335 
336  if (distanceToMuonHitsSquared < m_maxDistanceToHit * m_maxDistanceToHit)
337  continue;
338 
339  collectedHits.push_back(pCaloHit);
340 
341  break;
342  }
343  }
344  }
345 }
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
pandora::StatusCode ProjectDeltaRayPositions(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CartesianPointVector &projectedPositions) const
Use two views of a delta ray pfo to calculate projected positions in a given third view...
TFile f
Definition: plotHisto.C:6
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
pandora::StatusCode ParameteriseMuon(const pandora::ParticleFlowObject *const pParentMuon, const pandora::Cluster *const pDeltaRayCluster, pandora::CartesianVector &positionOnMuon, pandora::CartesianVector &muonDirection) const
Parameterise the projection of a cosmic ray track in order to avoid poor/sparse projections.
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
float m_maxDistanceToHit
The maximum distance of a hit from the cosmic ray track for it to be added into the CR...
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
StatusCode lar_content::TwoViewCosmicRayRemovalTool::GrowSeed ( const MatrixType::Element &  element,
const pandora::HitType  hitType,
pandora::CaloHitList &  collectedHits,
pandora::CaloHitList &  deltaRayRemantHits 
) const
private

Examine remaining hits in the delta ray cluster adding them to the delta ray seed or parent muon if appropriate and a separate list if not.

Parameters
elementthe matrix element
hitTypethe hit type of the cluster under investigation
collectedHitsthe list of identified delta ray hits
deltaRayRemantHitsthe list of remainder hits
Returns
whether the muon projection mechanics were successful - abort process if not

Definition at line 349 of file TwoViewCosmicRayRemovalTool.cc.

References CollectHitsFromDeltaRay(), f, lar_content::TwoViewDeltaRayMatchingAlgorithm::GetCluster(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetMuonCluster(), m_maxDistanceToHit, lar_content::DeltaRayMatrixTool::m_pParentAlgorithm, and lar_content::NViewDeltaRayMatchingAlgorithm< T >::ParameteriseMuon().

Referenced by RemoveCosmicRayHits().

351 {
352  const Cluster *const pDeltaRayCluster(m_pParentAlgorithm->GetCluster(element, hitType)), *pMuonCluster(nullptr);
353 
354  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
355  return STATUS_CODE_NOT_FOUND;
356 
357  // To avoid fluctuatuions, parameterise the muon track
358  CartesianVector positionOnMuon(0.f, 0.f, 0.f), muonDirection(0.f, 0.f, 0.f);
359  if (m_pParentAlgorithm->ParameteriseMuon(element.GetOverlapResult().GetCommonMuonPfoList().front(), pDeltaRayCluster, positionOnMuon,
360  muonDirection) != STATUS_CODE_SUCCESS)
361  return STATUS_CODE_NOT_FOUND;
362 
363  // Identify delta ray hits
364  this->CollectHitsFromDeltaRay(positionOnMuon, muonDirection, pDeltaRayCluster, m_maxDistanceToHit, true, deltaRayHits, deltaRayHits);
365 
366  // Identify remnant hits
367  this->CollectHitsFromDeltaRay(positionOnMuon, muonDirection, pDeltaRayCluster, m_maxDistanceToHit, false, deltaRayHits, remnantHits);
368 
369  return STATUS_CODE_SUCCESS;
370 }
void CollectHitsFromDeltaRay(const pandora::CartesianVector &positionOnMuon, const pandora::CartesianVector &muonDirection, const pandora::Cluster *const pDeltaRayCluster, const float &minDistanceFromMuon, const bool demandCloserToCollected, const pandora::CaloHitList &protectedHits, pandora::CaloHitList &collectedHits) const
Collect hits from the delta ray cluster to either keep (demandCloserToCollected == true) or separate ...
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
TFile f
Definition: plotHisto.C:6
pandora::StatusCode ParameteriseMuon(const pandora::ParticleFlowObject *const pParentMuon, const pandora::Cluster *const pDeltaRayCluster, pandora::CartesianVector &positionOnMuon, pandora::CartesianVector &muonDirection) const
Parameterise the projection of a cosmic ray track in order to avoid poor/sparse projections.
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
float m_maxDistanceToHit
The maximum distance of a hit from the cosmic ray track for it to be added into the CR...
pandora::StatusCode GetMuonCluster(const pandora::PfoList &commonMuonPfoList, const pandora::HitType hitType, const pandora::Cluster *&pMuonCluster) const
Return the cluster of the common cosmic ray pfo in a given view (function demands there to be only on...
bool lar_content::TwoViewCosmicRayRemovalTool::IsBestElement ( const MatrixType::Element &  element,
const pandora::HitType  hitType,
const MatrixType::ElementList elementList 
) const
private

Determine whether the input element is the best to use to modify the contaminated cluster (best is defined by the total hit count)

Parameters
elementthe matrix element
hitTypethe hit type of the cluster under investigation
elementListthe matrix element list
Returns
whether the input element is the best element

Definition at line 274 of file TwoViewCosmicRayRemovalTool.cc.

References lar_content::TwoViewDeltaRayMatchingAlgorithm::GetCluster(), lar_content::DeltaRayMatrixTool::m_pParentAlgorithm, and PassElementChecks().

Referenced by RemoveCosmicRayHits().

275 {
276  const float chiSquared(element.GetOverlapResult().GetReducedChiSquared());
277  const unsigned int hitSum(element.GetCluster1()->GetNCaloHits() + element.GetCluster2()->GetNCaloHits());
278 
279  for (const MatrixType::Element &testElement : elementList)
280  {
281  if (m_pParentAlgorithm->GetCluster(testElement, hitType) != m_pParentAlgorithm->GetCluster(element, hitType))
282  continue;
283 
284  if ((testElement.GetCluster1() == element.GetCluster1()) && (testElement.GetCluster2() == element.GetCluster2()))
285  continue;
286 
287  const float testChiSquared(testElement.GetOverlapResult().GetReducedChiSquared());
288  const unsigned int testHitSum(testElement.GetCluster1()->GetNCaloHits() + testElement.GetCluster2()->GetNCaloHits());
289 
290  if ((testHitSum < hitSum) || ((testHitSum == hitSum) && (testChiSquared > chiSquared)))
291  continue;
292 
293  if (this->PassElementChecks(testElement, hitType))
294  return false;
295  }
296 
297  return true;
298 }
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
bool PassElementChecks(const MatrixType::Element &element, const pandora::HitType hitType) const
Determine whether element satifies simple checks.
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
bool lar_content::TwoViewCosmicRayRemovalTool::IsCloseToLine ( const pandora::CartesianVector &  hitPosition,
const pandora::CartesianVector &  lineStart,
const pandora::CartesianVector &  lineEnd,
const float  distanceToLine 
) const
private

Whether a given position is close to a defined line.

Parameters
hitPositionthe input position
lineStartthe start position of the line
lineEndthe end position of the line
distanceToLinethe definition of close
Returns
whether the position is close to the definied line

Definition at line 234 of file TwoViewCosmicRayRemovalTool.cc.

Referenced by IsContaminated().

236 {
237  CartesianVector lineDirection(lineStart - lineEnd);
238  lineDirection = lineDirection.GetUnitVector();
239 
240  const float transverseDistanceFromLine(lineDirection.GetCrossProduct(hitPosition - lineStart).GetMagnitude());
241 
242  if (transverseDistanceFromLine > distanceToLine)
243  return false;
244 
245  return true;
246 }
bool lar_content::TwoViewCosmicRayRemovalTool::IsContaminated ( const MatrixType::Element &  element,
const pandora::HitType  hitType 
) const
private

Determine whether the cluster under investigation has muon contamination.

Parameters
elementthe matrix element
hitTypethe hit type of the cluster under investigation
Returns
whether the cluster contains muon hits to remove

Definition at line 177 of file TwoViewCosmicRayRemovalTool.cc.

References f, lar_content::LArClusterHelper::GetClosestPositions(), lar_content::TwoViewDeltaRayMatchingAlgorithm::GetCluster(), lar_content::TwoDSlidingFitResult::GetGlobalDirection(), lar_content::TwoDSlidingFitResult::GetLayerFitResultMap(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetMuonCluster(), lar_content::LArGeometryHelper::GetWirePitch(), IsCloseToLine(), IsInLineSegment(), m_distanceToLine, m_minContaminationLength, lar_content::DeltaRayMatrixTool::m_pParentAlgorithm, and m_slidingFitWindow.

Referenced by RemoveCosmicRayHits().

178 {
179  const Cluster *pMuonCluster(nullptr), *const pDeltaRayCluster(m_pParentAlgorithm->GetCluster(element, hitType));
180 
181  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
182  return false;
183 
184  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), hitType));
185  const TwoDSlidingFitResult slidingFitResult(pMuonCluster, m_slidingFitWindow, slidingFitPitch);
186 
187  CartesianVector muonDirection(0.f, 0.f, 0.f);
188  slidingFitResult.GetGlobalDirection(slidingFitResult.GetLayerFitResultMap().begin()->second.GetGradient(), muonDirection);
189 
190  CartesianVector deltaRayVertex(0.f, 0.f, 0.f), muonVertex(0.f, 0.f, 0.f);
191  LArClusterHelper::GetClosestPositions(pDeltaRayCluster, pMuonCluster, deltaRayVertex, muonVertex);
192 
193  // Find furthest point in DR cluster that lies on the projected muon track
194  float furthestSeparation(0.f);
195  CartesianVector extendedPoint(0.f, 0.f, 0.f);
196 
197  CaloHitList deltaRayHitList;
198  pDeltaRayCluster->GetOrderedCaloHitList().FillCaloHitList(deltaRayHitList);
199 
200  for (const CaloHit *const pCaloHit : deltaRayHitList)
201  {
202  const CartesianVector &position(pCaloHit->GetPositionVector());
203  const float separation((position - muonVertex).GetMagnitude());
204 
205  if (separation > furthestSeparation)
206  {
207  if (this->IsCloseToLine(position, muonVertex, muonVertex + muonDirection, m_distanceToLine))
208  {
209  furthestSeparation = separation;
210  extendedPoint = position;
211  }
212  }
213  }
214 
215  // Check if delta ray has significant track contamination
216  if (furthestSeparation < m_minContaminationLength)
217  return false;
218 
219  // ATTN: Avoid cases where opening angle is small - it is easy to make mistakes in these instances
220  CaloHitList muonHitList;
221  pMuonCluster->GetOrderedCaloHitList().FillCaloHitList(muonHitList);
222 
223  for (const CaloHit *const pCaloHit : muonHitList)
224  {
225  if (this->IsInLineSegment(deltaRayVertex, extendedPoint, pCaloHit->GetPositionVector()))
226  return false;
227  }
228 
229  return true;
230 }
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
static void GetClosestPositions(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::CartesianVector &position1, pandora::CartesianVector &position2)
Get pair of closest positions for a pair of clusters.
TFile f
Definition: plotHisto.C:6
float m_distanceToLine
The maximum perpendicular distance of a position to a line for it to be considered close...
bool IsInLineSegment(const pandora::CartesianVector &lowerBoundary, const pandora::CartesianVector &upperBoundary, const pandora::CartesianVector &point) const
Whether the projection of a given position lies on a defined line.
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
float m_minContaminationLength
The minimum projected length of a delta ray cluster onto the muon track for it to be considered conta...
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
bool IsCloseToLine(const pandora::CartesianVector &hitPosition, const pandora::CartesianVector &lineStart, const pandora::CartesianVector &lineEnd, const float distanceToLine) const
Whether a given position is close to a defined line.
pandora::StatusCode GetMuonCluster(const pandora::PfoList &commonMuonPfoList, const pandora::HitType hitType, const pandora::Cluster *&pMuonCluster) const
Return the cluster of the common cosmic ray pfo in a given view (function demands there to be only on...
bool lar_content::TwoViewCosmicRayRemovalTool::IsInLineSegment ( const pandora::CartesianVector &  lowerBoundary,
const pandora::CartesianVector &  upperBoundary,
const pandora::CartesianVector &  point 
) const
private

Whether the projection of a given position lies on a defined line.

Parameters
lowerBoundarythe start position of the line
upperBoundarythe end position of the line
pointthe input position
Returns
whether the position lies between the two points

Definition at line 250 of file TwoViewCosmicRayRemovalTool.cc.

Referenced by IsContaminated().

252 {
253  const float segmentBoundaryGradient = (-1.f) * (upperBoundary.GetX() - lowerBoundary.GetX()) / (upperBoundary.GetZ() - lowerBoundary.GetZ());
254  const float xPointOnUpperLine((point.GetZ() - upperBoundary.GetZ()) / segmentBoundaryGradient + upperBoundary.GetX());
255  const float xPointOnLowerLine((point.GetZ() - lowerBoundary.GetZ()) / segmentBoundaryGradient + lowerBoundary.GetX());
256 
257  if (std::fabs(xPointOnUpperLine - point.GetX()) < std::numeric_limits<float>::epsilon())
258  return true;
259 
260  if (std::fabs(xPointOnLowerLine - point.GetX()) < std::numeric_limits<float>::epsilon())
261  return true;
262 
263  if ((point.GetX() > xPointOnUpperLine) && (point.GetX() > xPointOnLowerLine))
264  return false;
265 
266  if ((point.GetX() < xPointOnUpperLine) && (point.GetX() < xPointOnLowerLine))
267  return false;
268 
269  return true;
270 }
bool lar_content::TwoViewCosmicRayRemovalTool::IsMuonEndpoint ( const MatrixType::Element &  element,
const pandora::HitType  hitType 
) const
private

Determine whether the matched clusters suggest that the delta ray is at the endpoint of the cosmic ray (and is likely to be a michel)

Parameters
elementthe matrix element
ignoreHitTypewhether to ignore the cluster under investigation
hitTypeToIgnorethe hit type to ignore
Returns
whether the delta ray is at the endpoint of the cosmic ray

Definition at line 141 of file TwoViewCosmicRayRemovalTool.cc.

References lar_content::TwoViewDeltaRayMatchingAlgorithm::GetCluster(), lar_content::TwoViewDeltaRayMatchingAlgorithm::GetHitTypeVector(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetMuonCluster(), and lar_content::DeltaRayMatrixTool::m_pParentAlgorithm.

Referenced by PassElementChecks().

142 {
143  for (const HitType &otherHitType : m_pParentAlgorithm->GetHitTypeVector())
144  {
145  if (otherHitType == hitType)
146  continue;
147 
148  const Cluster *pMuonCluster(nullptr), *const pDeltaRayCluster(m_pParentAlgorithm->GetCluster(element, hitType));
149 
150  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
151  return false;
152 
153  float xMinDR(+std::numeric_limits<float>::max()), xMaxDR(-std::numeric_limits<float>::max());
154  pDeltaRayCluster->GetClusterSpanX(xMinDR, xMaxDR);
155 
156  float xMinCR(-std::numeric_limits<float>::max()), xMaxCR(+std::numeric_limits<float>::max());
157  pMuonCluster->GetClusterSpanX(xMinCR, xMaxCR);
158 
159  if ((xMinDR < xMinCR) || (xMaxDR > xMaxCR))
160  return false;
161 
162  float zMinDR(+std::numeric_limits<float>::max()), zMaxDR(-std::numeric_limits<float>::max());
163  pDeltaRayCluster->GetClusterSpanZ(xMinDR, xMaxDR, zMinDR, zMaxDR);
164 
165  float zMinCR(-std::numeric_limits<float>::max()), zMaxCR(+std::numeric_limits<float>::max());
166  pMuonCluster->GetClusterSpanZ(xMinCR, xMaxCR, zMinCR, zMaxCR);
167 
168  if ((zMinDR < zMinCR) || (zMaxDR > zMaxCR))
169  return false;
170  }
171 
172  return true;
173 }
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
HitTypeVector GetHitTypeVector()
Obtain the HitTypeVector of input views.
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
HitType
Definition: HitType.h:12
pandora::StatusCode GetMuonCluster(const pandora::PfoList &commonMuonPfoList, const pandora::HitType hitType, const pandora::Cluster *&pMuonCluster) const
Return the cluster of the common cosmic ray pfo in a given view (function demands there to be only on...
bool lar_content::TwoViewCosmicRayRemovalTool::PassElementChecks ( const MatrixType::Element &  element,
const pandora::HitType  hitType 
) const
private

Determine whether element satifies simple checks.

Parameters
elementthe matrix element
hitTypethe hit type of the cluster under investigation
Returns
whether the checks pass

Definition at line 123 of file TwoViewCosmicRayRemovalTool.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), lar_content::TwoViewDeltaRayMatchingAlgorithm::GetCluster(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetMuonCluster(), IsMuonEndpoint(), m_minSeparation, and lar_content::DeltaRayMatrixTool::m_pParentAlgorithm.

Referenced by IsBestElement(), and RemoveCosmicRayHits().

124 {
125  // ATTN: Avoid endpoints, topological michel reconstruction is very ambiguous
126  if (this->IsMuonEndpoint(element, hitType))
127  return false;
128 
129  const Cluster *pMuonCluster(nullptr), *const pDeltaRayCluster(m_pParentAlgorithm->GetCluster(element, hitType));
130 
131  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
132  return false;
133 
134  const float separation(LArClusterHelper::GetClosestDistance(pDeltaRayCluster, pMuonCluster));
135 
136  return separation <= m_minSeparation;
137 }
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
bool IsMuonEndpoint(const MatrixType::Element &element, const pandora::HitType hitType) const
Determine whether the matched clusters suggest that the delta ray is at the endpoint of the cosmic ra...
float m_minSeparation
The minimum delta ray - parent muon cluster separation required to investigate delta ray cluster...
pandora::StatusCode GetMuonCluster(const pandora::PfoList &commonMuonPfoList, const pandora::HitType hitType, const pandora::Cluster *&pMuonCluster) const
Return the cluster of the common cosmic ray pfo in a given view (function demands there to be only on...
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
StatusCode lar_content::TwoViewCosmicRayRemovalTool::ProjectDeltaRayPositions ( const MatrixType::Element &  element,
const pandora::HitType  hitType,
pandora::CartesianPointVector &  projectedPositions 
) const
private

Use two views of a delta ray pfo to calculate projected positions in a given third view.

Parameters
elementthe matrix element
hitTypethe view to be projected into
projectedPositionsthe output list of projected positions
Returns
a status code reflecting whether the procedure ran smoothly and if the outcome is good

Definition at line 511 of file TwoViewCosmicRayRemovalTool.cc.

References lar_content::TwoViewDeltaRayMatchingAlgorithm::GetCluster(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetProjectedPositions(), and lar_content::DeltaRayMatrixTool::m_pParentAlgorithm.

Referenced by CreateSeed().

513 {
514  HitTypeVector hitTypes({TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W});
515 
516  hitTypes.erase(std::find(hitTypes.begin(), hitTypes.end(), hitType));
517 
518  const Cluster *const pCluster1(m_pParentAlgorithm->GetCluster(element, hitTypes[0]));
519  const Cluster *const pCluster2(m_pParentAlgorithm->GetCluster(element, hitTypes[1]));
520 
521  if (!pCluster1 || !pCluster2)
522  return STATUS_CODE_NOT_FOUND;
523 
524  return m_pParentAlgorithm->GetProjectedPositions(pCluster1, pCluster2, projectedPositions);
525 }
pandora::StatusCode GetProjectedPositions(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::CartesianPointVector &projectedPositions) const
Use two clusters from different views to calculate projected positions in the remaining third view...
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
StatusCode lar_content::TwoViewCosmicRayRemovalTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 529 of file TwoViewCosmicRayRemovalTool.cc.

References m_distanceToLine, m_maxDistanceToHit, m_maxDistanceToTrack, m_minContaminationLength, m_minRemnantClusterSize, m_minSeparation, and m_slidingFitWindow.

530 {
531  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinSeparation", m_minSeparation));
532 
533  PANDORA_RETURN_RESULT_IF_AND_IF(
534  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
535 
536  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DistanceToLine", m_distanceToLine));
537 
538  PANDORA_RETURN_RESULT_IF_AND_IF(
539  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinContaminationLength", m_minContaminationLength));
540 
541  PANDORA_RETURN_RESULT_IF_AND_IF(
542  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxDistanceToHit", m_maxDistanceToHit));
543 
544  PANDORA_RETURN_RESULT_IF_AND_IF(
545  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinRemnantClusterSize", m_minRemnantClusterSize));
546 
547  PANDORA_RETURN_RESULT_IF_AND_IF(
548  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxDistanceToTrack", m_maxDistanceToTrack));
549 
550  return STATUS_CODE_SUCCESS;
551 }
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
unsigned int m_minRemnantClusterSize
The minimum hit number of a remnant cluster for it to be considered significant.
float m_distanceToLine
The maximum perpendicular distance of a position to a line for it to be considered close...
float m_maxDistanceToTrack
The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merge...
float m_minContaminationLength
The minimum projected length of a delta ray cluster onto the muon track for it to be considered conta...
float m_minSeparation
The minimum delta ray - parent muon cluster separation required to investigate delta ray cluster...
float m_maxDistanceToHit
The maximum distance of a hit from the cosmic ray track for it to be added into the CR...
void lar_content::TwoViewCosmicRayRemovalTool::ReclusterRemnant ( const pandora::HitType  hitType,
const pandora::Cluster *const  pMuonCluster,
const pandora::Cluster *const  pDeltaRayRemnant,
pandora::ClusterVector &  clusterVector,
pandora::PfoVector &  pfoVector 
) const
private

Reculster the remnant cluster, merging insignificant created clusters into the parent muon (if proximity checks pass)

Parameters
hitTypethe hit type of the cluster under investigation
pMuonClusterthe address of the parent muon cluster
pDeltaRayRemnantthe address of the delta ray remnant
clusterVectora vector containing the address of created/modified clusters for bookeeping purposes
pfoVectora vector containing the address of the pfo to which a modified muon cluster belongs for bookeeping purposes

Definition at line 471 of file TwoViewCosmicRayRemovalTool.cc.

References lar_content::LArClusterHelper::GetClosestDistance(), lar_content::TwoViewDeltaRayMatchingAlgorithm::GetClusteringAlgName(), lar_content::NViewMatchingAlgorithm< T >::GetClusterListName(), m_maxDistanceToTrack, m_minRemnantClusterSize, and lar_content::DeltaRayMatrixTool::m_pParentAlgorithm.

Referenced by SplitDeltaRayCluster().

473 {
474  std::string caloHitListName(hitType == TPC_VIEW_U ? "CaloHitListU" : hitType == TPC_VIEW_V ? "CaloHitListV" : "CaloHitListW");
475 
476  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<CaloHit>(*m_pParentAlgorithm, caloHitListName));
477  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
478  PandoraContentApi::ReplaceCurrentList<Cluster>(*m_pParentAlgorithm, m_pParentAlgorithm->GetClusterListName(hitType)));
479  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Cluster>(*m_pParentAlgorithm, pDeltaRayRemnant));
480 
481  const ClusterList *pClusterList(nullptr);
482  std::string newClusterListName;
483  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
484  PandoraContentApi::RunClusteringAlgorithm(*m_pParentAlgorithm, m_pParentAlgorithm->GetClusteringAlgName(), pClusterList, newClusterListName));
485 
486  const ClusterList remnantClusters(pClusterList->begin(), pClusterList->end());
487 
488  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
489  PandoraContentApi::SaveList<Cluster>(*m_pParentAlgorithm, newClusterListName, m_pParentAlgorithm->GetClusterListName(hitType)));
490  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
491  PandoraContentApi::ReplaceCurrentList<Cluster>(*m_pParentAlgorithm, m_pParentAlgorithm->GetClusterListName(hitType)));
492 
493  for (const Cluster *const pRemnant : remnantClusters)
494  {
495  if (pRemnant->GetNCaloHits() < m_minRemnantClusterSize)
496  {
497  if (LArClusterHelper::GetClosestDistance(pRemnant, pMuonCluster) < m_maxDistanceToTrack)
498  {
499  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*m_pParentAlgorithm, pMuonCluster, pRemnant));
500  continue;
501  }
502  }
503 
504  clusterVector.push_back(pRemnant);
505  pfoVector.push_back(nullptr);
506  }
507 }
unsigned int m_minRemnantClusterSize
The minimum hit number of a remnant cluster for it to be considered significant.
float m_maxDistanceToTrack
The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merge...
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
const std::string & GetClusterListName(const pandora::HitType hitType) const
Get the cluster list name corresponding to a specified hit type.
const std::string & GetClusteringAlgName() const
Get the name of the clustering algorithm to be used to recluster created delta ray remnants...
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
bool lar_content::TwoViewCosmicRayRemovalTool::RemoveCosmicRayHits ( const MatrixType::ElementList elementList) const
private

Remove hits from delta ray clusters that belong to the parent muon.

Parameters
elementListthe matrix element list
Returns
whether any clusters have been modified

Definition at line 69 of file TwoViewCosmicRayRemovalTool.cc.

References CreateSeed(), lar_content::TwoViewDeltaRayMatchingAlgorithm::GetCluster(), lar_content::TwoViewDeltaRayMatchingAlgorithm::GetHitTypeVector(), GrowSeed(), IsBestElement(), IsContaminated(), lar_content::DeltaRayMatrixTool::m_pParentAlgorithm, PassElementChecks(), and SplitDeltaRayCluster().

Referenced by Run().

70 {
71  ClusterSet modifiedClusters, checkedClusters;
72 
73  for (const MatrixType::Element &element : elementList)
74  {
75  for (const HitType hitType : m_pParentAlgorithm->GetHitTypeVector())
76  {
77  const Cluster *const pDeltaRayCluster(m_pParentAlgorithm->GetCluster(element, hitType));
78 
79  if (checkedClusters.count(pDeltaRayCluster))
80  continue;
81 
82  // ATTN: The underlying matrix will update during this loop, do not proceed if element has been modified
83  if ((modifiedClusters.count(element.GetCluster1())) || (modifiedClusters.count(element.GetCluster2())))
84  continue;
85 
86  if (!this->PassElementChecks(element, hitType))
87  continue;
88 
89  if (!this->IsContaminated(element, hitType))
90  continue;
91 
92  if (!this->IsBestElement(element, hitType, elementList))
93  continue;
94 
95  checkedClusters.insert(pDeltaRayCluster);
96 
97  // Attempt to pull delta ray hits out of cluster
98  CaloHitList deltaRayHits;
99  this->CreateSeed(element, hitType, deltaRayHits);
100 
101  if (deltaRayHits.empty())
102  continue;
103 
104  // ATTN: If seed cannot be grown, abort
105  CaloHitList deltaRayRemnantHits;
106  if (this->GrowSeed(element, hitType, deltaRayHits, deltaRayRemnantHits) != STATUS_CODE_SUCCESS)
107  continue;
108 
109  if (deltaRayHits.size() == pDeltaRayCluster->GetNCaloHits())
110  continue;
111 
112  modifiedClusters.insert(pDeltaRayCluster);
113 
114  this->SplitDeltaRayCluster(element, hitType, deltaRayHits, deltaRayRemnantHits);
115  }
116  }
117 
118  return !modifiedClusters.empty();
119 }
void SplitDeltaRayCluster(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits, pandora::CaloHitList &deltaRayRemnantHits) const
Fragment the delta ray cluster, refining the matched delta ray cluster perhaps creating significant r...
void CreateSeed(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits) const
Collect hits in the delta ray cluster that lie close to calculated projected positions forming a seed...
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
HitTypeVector GetHitTypeVector()
Obtain the HitTypeVector of input views.
bool PassElementChecks(const MatrixType::Element &element, const pandora::HitType hitType) const
Determine whether element satifies simple checks.
pandora::StatusCode GrowSeed(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits, pandora::CaloHitList &deltaRayRemantHits) const
Examine remaining hits in the delta ray cluster adding them to the delta ray seed or parent muon if a...
bool IsBestElement(const MatrixType::Element &element, const pandora::HitType hitType, const MatrixType::ElementList &elementList) const
Determine whether the input element is the best to use to modify the contaminated cluster (best is de...
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
bool IsContaminated(const MatrixType::Element &element, const pandora::HitType hitType) const
Determine whether the cluster under investigation has muon contamination.
HitType
Definition: HitType.h:12
bool lar_content::TwoViewCosmicRayRemovalTool::Run ( TwoViewDeltaRayMatchingAlgorithm *const  pAlgorithm,
MatrixType matrixTensor 
)
privatevirtual

Run the algorithm tool.

Parameters
pAlgorithmaddress of the calling algorithm
overlapTensorthe overlap tensor
Returns
whether changes have been made by the tool

Implements lar_content::DeltaRayMatrixTool.

Definition at line 35 of file TwoViewCosmicRayRemovalTool.cc.

References lar_content::OverlapMatrix< T >::GetConnectedElements(), lar_content::OverlapMatrix< T >::GetSortedKeyClusters(), lar_content::DeltaRayMatrixTool::m_pParentAlgorithm, and RemoveCosmicRayHits().

36 {
37  m_pParentAlgorithm = pAlgorithm;
38 
39  if (PandoraContentApi::GetSettings(*m_pParentAlgorithm)->ShouldDisplayAlgorithmInfo())
40  std::cout << "----> Running Algorithm Tool: " << this->GetInstanceName() << ", " << this->GetType() << std::endl;
41 
42  bool changesMade(false);
43 
44  ClusterVector sortedKeyClusters;
45  overlapMatrix.GetSortedKeyClusters(sortedKeyClusters);
46 
47  ClusterSet usedKeyClusters;
48  for (const Cluster *const pKeyCluster : sortedKeyClusters)
49  {
50  if (usedKeyClusters.count(pKeyCluster))
51  continue;
52 
53  MatrixType::ElementList elementList;
54  overlapMatrix.GetConnectedElements(pKeyCluster, true, elementList);
55 
56  for (const MatrixType::Element &element : elementList)
57  usedKeyClusters.insert(element.GetCluster1());
58 
59  const bool changesMadeInIteration = this->RemoveCosmicRayHits(elementList);
60 
61  changesMade = (changesMade ? changesMade : changesMadeInIteration);
62  }
63 
64  return changesMade;
65 }
bool RemoveCosmicRayHits(const MatrixType::ElementList &elementList) const
Remove hits from delta ray clusters that belong to the parent muon.
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
void lar_content::TwoViewCosmicRayRemovalTool::SplitDeltaRayCluster ( const MatrixType::Element &  element,
const pandora::HitType  hitType,
pandora::CaloHitList &  collectedHits,
pandora::CaloHitList &  deltaRayRemnantHits 
) const
private

Fragment the delta ray cluster, refining the matched delta ray cluster perhaps creating significant remnants in the process.

Parameters
elementthe matrix element
hitTypethe hit type of the cluster under investigation
collectedHitsthe list of identified delta ray hits
deltaRayRemantHitsthe list of remainder hits

Definition at line 411 of file TwoViewCosmicRayRemovalTool.cc.

References lar_content::TwoViewDeltaRayMatchingAlgorithm::GetCluster(), lar_content::NViewMatchingAlgorithm< T >::GetClusterListName(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetMuonCluster(), lar_content::DeltaRayMatrixTool::m_pParentAlgorithm, ReclusterRemnant(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::UpdateForNewClusters(), and lar_content::NViewDeltaRayMatchingAlgorithm< T >::UpdateUponDeletion().

Referenced by RemoveCosmicRayHits().

413 {
414  const Cluster *const pDeltaRayCluster(m_pParentAlgorithm->GetCluster(element, hitType)), *pMuonCluster(nullptr);
415 
416  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
417  return;
418 
419  m_pParentAlgorithm->UpdateUponDeletion(pMuonCluster);
420  m_pParentAlgorithm->UpdateUponDeletion(pDeltaRayCluster);
421 
422  std::string originalListName, fragmentListName;
423  ClusterList originalClusterList(1, pDeltaRayCluster);
424 
425  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
426  PandoraContentApi::ReplaceCurrentList<Cluster>(*m_pParentAlgorithm, m_pParentAlgorithm->GetClusterListName(hitType)));
427  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
428  PandoraContentApi::InitializeFragmentation(*m_pParentAlgorithm, originalClusterList, originalListName, fragmentListName));
429 
430  CaloHitList deltaRayHitList;
431  pDeltaRayCluster->GetOrderedCaloHitList().FillCaloHitList(deltaRayHitList);
432 
433  const Cluster *pDeltaRay(nullptr), *pDeltaRayRemnant(nullptr);
434 
435  for (const CaloHit *const pCaloHit : deltaRayHitList)
436  {
437  const bool isDeltaRay(std::find(collectedHits.begin(), collectedHits.end(), pCaloHit) != collectedHits.end());
438  const bool isDeltaRayRemnant(
439  !isDeltaRay && (std::find(deltaRayRemnantHits.begin(), deltaRayRemnantHits.end(), pCaloHit) != deltaRayRemnantHits.end()));
440  const Cluster *&pCluster(isDeltaRay ? pDeltaRay : isDeltaRayRemnant ? pDeltaRayRemnant : pMuonCluster);
441 
442  if (!pCluster)
443  {
444  PandoraContentApi::Cluster::Parameters parameters;
445  parameters.m_caloHitList.push_back(pCaloHit);
446  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*m_pParentAlgorithm, parameters, pCluster));
447  }
448  else
449  {
450  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*m_pParentAlgorithm, pCluster, pCaloHit));
451  }
452  }
453 
454  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*m_pParentAlgorithm, fragmentListName, originalListName));
455 
456  ClusterVector clusterVector;
457  PfoVector pfoVector;
458  if (pDeltaRayRemnant)
459  this->ReclusterRemnant(hitType, pMuonCluster, pDeltaRayRemnant, clusterVector, pfoVector);
460 
461  clusterVector.push_back(pMuonCluster);
462  pfoVector.push_back(element.GetOverlapResult().GetCommonMuonPfoList().front());
463  clusterVector.push_back(pDeltaRay);
464  pfoVector.push_back(nullptr);
465 
466  m_pParentAlgorithm->UpdateForNewClusters(clusterVector, pfoVector);
467 }
void UpdateForNewClusters(const pandora::ClusterVector &newClusterVector, const pandora::PfoVector &pfoVector)
Add a new cluster to algorithm ownership maps and, if it a delta ray cluster, to the underlying match...
const pandora::Cluster * GetCluster(const MatrixType::Element &element, const pandora::HitType hitType)
Get the address of the given hit type cluster.
void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
void ReclusterRemnant(const pandora::HitType hitType, const pandora::Cluster *const pMuonCluster, const pandora::Cluster *const pDeltaRayRemnant, pandora::ClusterVector &clusterVector, pandora::PfoVector &pfoVector) const
Reculster the remnant cluster, merging insignificant created clusters into the parent muon (if proxim...
TwoViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
const std::string & GetClusterListName(const pandora::HitType hitType) const
Get the cluster list name corresponding to a specified hit type.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
pandora::StatusCode GetMuonCluster(const pandora::PfoList &commonMuonPfoList, const pandora::HitType hitType, const pandora::Cluster *&pMuonCluster) const
Return the cluster of the common cosmic ray pfo in a given view (function demands there to be only on...

Member Data Documentation

float lar_content::TwoViewCosmicRayRemovalTool::m_distanceToLine
private

The maximum perpendicular distance of a position to a line for it to be considered close.

Definition at line 181 of file TwoViewCosmicRayRemovalTool.h.

Referenced by IsContaminated(), and ReadSettings().

float lar_content::TwoViewCosmicRayRemovalTool::m_maxDistanceToHit
private

The maximum distance of a hit from the cosmic ray track for it to be added into the CR.

Definition at line 183 of file TwoViewCosmicRayRemovalTool.h.

Referenced by CreateSeed(), GrowSeed(), and ReadSettings().

float lar_content::TwoViewCosmicRayRemovalTool::m_maxDistanceToTrack
private

The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merged into the CR.

Definition at line 185 of file TwoViewCosmicRayRemovalTool.h.

Referenced by ReadSettings(), and ReclusterRemnant().

float lar_content::TwoViewCosmicRayRemovalTool::m_minContaminationLength
private

The minimum projected length of a delta ray cluster onto the muon track for it to be considered contaminated.

Definition at line 182 of file TwoViewCosmicRayRemovalTool.h.

Referenced by IsContaminated(), and ReadSettings().

unsigned int lar_content::TwoViewCosmicRayRemovalTool::m_minRemnantClusterSize
private

The minimum hit number of a remnant cluster for it to be considered significant.

Definition at line 184 of file TwoViewCosmicRayRemovalTool.h.

Referenced by ReadSettings(), and ReclusterRemnant().

float lar_content::TwoViewCosmicRayRemovalTool::m_minSeparation
private

The minimum delta ray - parent muon cluster separation required to investigate delta ray cluster.

Definition at line 179 of file TwoViewCosmicRayRemovalTool.h.

Referenced by PassElementChecks(), and ReadSettings().

TwoViewDeltaRayMatchingAlgorithm* lar_content::DeltaRayMatrixTool::m_pParentAlgorithm
inherited
unsigned int lar_content::TwoViewCosmicRayRemovalTool::m_slidingFitWindow
private

The sliding fit window used in cosmic ray parameterisations.

Definition at line 180 of file TwoViewCosmicRayRemovalTool.h.

Referenced by IsContaminated(), and ReadSettings().


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