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

CosmicRayRemovalTool class. More...

#include "CosmicRayRemovalTool.h"

Inheritance diagram for lar_content::CosmicRayRemovalTool:
lar_content::RemovalBaseTool lar_content::DeltaRayTensorTool

Public Types

typedef std::vector< pandora::HitType > HitTypeVector
 
typedef ThreeViewDeltaRayMatchingAlgorithm::MatchingType::TensorType TensorType
 
typedef std::vector< TensorType::ElementList::const_iteratorIteratorList
 

Public Member Functions

 CosmicRayRemovalTool ()
 Default constructor. More...
 

Public Attributes

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

Protected Member Functions

bool IsMuonEndpoint (const TensorType::Element &element, const bool ignoreHitType, const pandora::HitType hitTypeToIgnore=pandora::TPC_VIEW_U) 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 IsBestElement (const TensorType::Element &element, const pandora::HitType hitType, const TensorType::ElementList &elementList, const pandora::ClusterSet &modifiedClusters) 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...
 
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...
 
void FindExtrapolatedHits (const pandora::Cluster *const pCluster, const pandora::CartesianVector &lowerBoundary, const pandora::CartesianVector &upperBoundary, pandora::CaloHitList &collectedHits) const
 Collect the hits that are closest to and can be projected onto a defined line. More...
 
pandora::StatusCode ProjectDeltaRayPositions (const TensorType::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...
 

Protected Attributes

float m_minSeparation
 The minimum delta ray - parent muon cluster separation required to investigate a delta/cosmic ray cluster. More...
 
float m_distanceToLine
 The maximum perpendicular distance of a position to a line for it to be considered close. More...
 

Private Member Functions

bool Run (ThreeViewDeltaRayMatchingAlgorithm *const pAlgorithm, TensorType &overlapTensor)
 Run the algorithm tool. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
bool RemoveCosmicRayHits (const TensorType::ElementList &elementList) const
 Remove hits from delta ray clusters that belong to the parent muon. More...
 
virtual bool PassElementChecks (const TensorType::Element &element, const pandora::HitType hitType) const
 Determine whether element satifies simple checks. More...
 
bool IsContaminated (const TensorType::Element &element, const pandora::HitType hitType) const
 Determine whether the cluster under investigation has muon contamination. More...
 
void CreateSeed (const TensorType::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 TensorType::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 TensorType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits, pandora::CaloHitList &deltaRayRemnantHits) const
 Fragment the delta ray cluster adding hits to the muon track and 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 a given remnant cluster, merging insignificant created clusters into the parent muon (if proximity checks pass) More...
 

Private Attributes

unsigned int m_slidingFitWindow
 The sliding fit window used in cosmic ray parameterisations. 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

CosmicRayRemovalTool class.

Definition at line 20 of file CosmicRayRemovalTool.h.

Member Typedef Documentation

typedef std::vector<pandora::HitType> lar_content::RemovalBaseTool::HitTypeVector
inherited

Definition at line 21 of file RemovalBaseTool.h.

Constructor & Destructor Documentation

lar_content::CosmicRayRemovalTool::CosmicRayRemovalTool ( )

Default constructor.

Definition at line 23 of file CosmicRayRemovalTool.cc.

23  :
24  m_slidingFitWindow(10000),
29 {
30 }
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
float m_maxDistanceToHit
The maximum distance of a hit from the cosmic ray track for it to be added into the CR...
TFile f
Definition: plotHisto.C:6
float m_maxDistanceToTrack
The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merge...
unsigned int m_minRemnantClusterSize
The minimum hit number of a remnant cluster for it to be considered significant.
float m_minContaminationLength
The minimum projected length of a delta ray cluster onto the muon track for it to be considered conta...

Member Function Documentation

void lar_content::CosmicRayRemovalTool::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 262 of file CosmicRayRemovalTool.cc.

References lar_content::LArClusterHelper::GetClosestDistance().

Referenced by GrowSeed().

265 {
266  CaloHitList deltaRayHitList;
267  pDeltaRayCluster->GetOrderedCaloHitList().FillCaloHitList(deltaRayHitList);
268 
269  bool hitsAdded(false);
270 
271  do
272  {
273  hitsAdded = false;
274 
275  for (const CaloHit *const pCaloHit : deltaRayHitList)
276  {
277  if (std::find(protectedHits.begin(), protectedHits.end(), pCaloHit) != protectedHits.end())
278  continue;
279 
280  if (std::find(collectedHits.begin(), collectedHits.end(), pCaloHit) != collectedHits.end())
281  continue;
282 
283  const float distanceToCollectedHits(collectedHits.empty()
284  ? std::numeric_limits<float>::max()
285  : LArClusterHelper::GetClosestDistance(pCaloHit->GetPositionVector(), collectedHits));
286  const float distanceToMuonHits(muonDirection.GetCrossProduct(pCaloHit->GetPositionVector() - positionOnMuon).GetMagnitude());
287 
288  if ((distanceToMuonHits < minDistanceFromMuon) || (demandCloserToCollected && (distanceToCollectedHits > distanceToMuonHits)))
289  continue;
290 
291  collectedHits.push_back(pCaloHit);
292  hitsAdded = true;
293  }
294  } while (hitsAdded);
295 }
void lar_content::CosmicRayRemovalTool::CreateSeed ( const TensorType::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 tensor element
hitTypethe hit type of the cluster under investigation
collectedHitsthe output list of identified delta ray hits

Definition at line 191 of file CosmicRayRemovalTool.cc.

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

Referenced by RemoveCosmicRayHits().

192 {
193  // To avoid fluctuations, parameterise the muon track
194  CartesianVector positionOnMuon(0.f, 0.f, 0.f), muonDirection(0.f, 0.f, 0.f);
195  if (m_pParentAlgorithm->ParameteriseMuon(element.GetOverlapResult().GetCommonMuonPfoList().front(), element.GetCluster(hitType),
196  positionOnMuon, muonDirection) != STATUS_CODE_SUCCESS)
197  return;
198 
199  CartesianPointVector deltaRayProjectedPositions;
200  if (this->ProjectDeltaRayPositions(element, hitType, deltaRayProjectedPositions) != STATUS_CODE_SUCCESS)
201  return;
202 
203  CaloHitList deltaRayHitList;
204  element.GetCluster(hitType)->GetOrderedCaloHitList().FillCaloHitList(deltaRayHitList);
205 
206  CaloHitVector deltaRayHitVector(deltaRayHitList.begin(), deltaRayHitList.end());
207  std::sort(deltaRayHitVector.begin(), deltaRayHitVector.end(), LArClusterHelper::SortHitsByPosition);
208 
209  for (const CaloHit *const pCaloHit : deltaRayHitVector)
210  {
211  const CartesianVector &position(pCaloHit->GetPositionVector());
212 
213  for (const CartesianVector &projectedPosition : deltaRayProjectedPositions)
214  {
215  const float distanceToProjectionSquared((position - projectedPosition).GetMagnitudeSquared());
216 
217  if (distanceToProjectionSquared < m_maxDistanceToHit * m_maxDistanceToHit)
218  {
219  // To prevent gappy seeds
220  if ((!collectedHits.empty()) && (LArClusterHelper::GetClosestDistance(position, collectedHits) > m_maxDistanceToHit))
221  continue;
222 
223  const float distanceToMuonHitsSquared(muonDirection.GetCrossProduct(position - positionOnMuon).GetMagnitudeSquared());
224 
225  if (distanceToMuonHitsSquared < m_maxDistanceToHit * m_maxDistanceToHit)
226  continue;
227 
228  collectedHits.push_back(pCaloHit);
229 
230  break;
231  }
232  }
233  }
234 }
ThreeViewDeltaRayMatchingAlgorithm * 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...
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.
pandora::StatusCode ProjectDeltaRayPositions(const TensorType::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...
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
void lar_content::RemovalBaseTool::FindExtrapolatedHits ( const pandora::Cluster *const  pCluster,
const pandora::CartesianVector &  lowerBoundary,
const pandora::CartesianVector &  upperBoundary,
pandora::CaloHitList &  collectedHits 
) const
protectedinherited

Collect the hits that are closest to and can be projected onto a defined line.

Parameters
pClusterthe address of the input cluster containing the hits to be investigated
lowerBoundarythe start position of the line
upperBoundarythe end position of the line
collectedHitsthe collected hits

Definition at line 152 of file RemovalBaseTool.cc.

References lar_content::RemovalBaseTool::IsCloseToLine(), lar_content::RemovalBaseTool::IsInLineSegment(), and lar_content::RemovalBaseTool::m_distanceToLine.

Referenced by lar_content::DeltaRayRemovalTool::IsContaminated().

154 {
155  CaloHitList caloHitList;
156  pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
157 
158  for (const CaloHit *const pCaloHit : caloHitList)
159  {
160  if (!this->IsInLineSegment(lowerBoundary, upperBoundary, pCaloHit->GetPositionVector()))
161  continue;
162 
163  if (!this->IsCloseToLine(pCaloHit->GetPositionVector(), lowerBoundary, upperBoundary, m_distanceToLine))
164  continue;
165 
166  collectedHits.push_back(pCaloHit);
167  }
168 }
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.
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.
StatusCode lar_content::CosmicRayRemovalTool::GrowSeed ( const TensorType::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 tensor 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 238 of file CosmicRayRemovalTool.cc.

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

Referenced by RemoveCosmicRayHits().

239 {
240  const Cluster *const pDeltaRayCluster(element.GetCluster(hitType)), *pMuonCluster(nullptr);
241 
242  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
243  return STATUS_CODE_NOT_FOUND;
244 
245  // To avoid fluctuatuions, parameterise the muon track
246  CartesianVector positionOnMuon(0.f, 0.f, 0.f), muonDirection(0.f, 0.f, 0.f);
247  if (m_pParentAlgorithm->ParameteriseMuon(element.GetOverlapResult().GetCommonMuonPfoList().front(), pDeltaRayCluster, positionOnMuon,
248  muonDirection) != STATUS_CODE_SUCCESS)
249  return STATUS_CODE_NOT_FOUND;
250 
251  // Identify delta ray hits
252  this->CollectHitsFromDeltaRay(positionOnMuon, muonDirection, pDeltaRayCluster, m_maxDistanceToHit, true, deltaRayHits, deltaRayHits);
253 
254  // Identify remnant hits
255  this->CollectHitsFromDeltaRay(positionOnMuon, muonDirection, pDeltaRayCluster, m_maxDistanceToHit, false, deltaRayHits, remnantHits);
256 
257  return STATUS_CODE_SUCCESS;
258 }
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 ...
ThreeViewDeltaRayMatchingAlgorithm * 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...
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.
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::RemovalBaseTool::IsBestElement ( const TensorType::Element &  element,
const pandora::HitType  hitType,
const TensorType::ElementList elementList,
const pandora::ClusterSet &  modifiedClusters 
) const
protectedinherited

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 tensor element
hitTypethe hit type of the cluster under investigation
elementListthe tensor element list
modifiedClustersthe set of modified clusters
Returns
whether the input element is the best element

Definition at line 78 of file RemovalBaseTool.cc.

References lar_content::RemovalBaseTool::PassElementChecks().

Referenced by RemoveCosmicRayHits(), and lar_content::DeltaRayRemovalTool::RemoveDeltaRayHits().

80 {
81  const float chiSquared(element.GetOverlapResult().GetReducedChi2());
82  const unsigned int hitSum(element.GetClusterU()->GetNCaloHits() + element.GetClusterV()->GetNCaloHits() + element.GetClusterW()->GetNCaloHits());
83 
84  for (const TensorType::Element &testElement : elementList)
85  {
86  if (modifiedClusters.count(testElement.GetClusterU()) || modifiedClusters.count(testElement.GetClusterV()) ||
87  modifiedClusters.count(testElement.GetClusterW()))
88  continue;
89 
90  if (testElement.GetCluster(hitType) != element.GetCluster(hitType))
91  continue;
92 
93  if ((testElement.GetClusterU() == element.GetClusterU()) && (testElement.GetClusterV() == element.GetClusterV()) &&
94  (testElement.GetClusterW() == element.GetClusterW()))
95  continue;
96 
97  const unsigned int testHitSum(
98  testElement.GetClusterU()->GetNCaloHits() + testElement.GetClusterV()->GetNCaloHits() + testElement.GetClusterW()->GetNCaloHits());
99  const float testChiSquared(testElement.GetOverlapResult().GetReducedChi2());
100 
101  if ((testHitSum < hitSum) || ((testHitSum == hitSum) && (testChiSquared > chiSquared)))
102  continue;
103 
104  if (this->PassElementChecks(testElement, hitType))
105  return false;
106  }
107 
108  return true;
109 }
virtual bool PassElementChecks(const TensorType::Element &element, const pandora::HitType hitType) const =0
Determine whether element satifies simple checks.
bool lar_content::RemovalBaseTool::IsCloseToLine ( const pandora::CartesianVector &  hitPosition,
const pandora::CartesianVector &  lineStart,
const pandora::CartesianVector &  lineEnd,
const float  distanceToLine 
) const
protectedinherited

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 113 of file RemovalBaseTool.cc.

Referenced by lar_content::RemovalBaseTool::FindExtrapolatedHits(), and IsContaminated().

115 {
116  CartesianVector lineDirection(lineStart - lineEnd);
117  lineDirection = lineDirection.GetUnitVector();
118 
119  const float transverseDistanceFromLine(lineDirection.GetCrossProduct(hitPosition - lineStart).GetMagnitude());
120 
121  if (transverseDistanceFromLine > distanceToLine)
122  return false;
123 
124  return true;
125 }
bool lar_content::CosmicRayRemovalTool::IsContaminated ( const TensorType::Element &  element,
const pandora::HitType  hitType 
) const
private

Determine whether the cluster under investigation has muon contamination.

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

Definition at line 134 of file CosmicRayRemovalTool.cc.

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

Referenced by RemoveCosmicRayHits().

135 {
136  const Cluster *pMuonCluster(nullptr), *const pDeltaRayCluster(element.GetCluster(hitType));
137 
138  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
139  return false;
140 
141  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), hitType));
142  const TwoDSlidingFitResult slidingFitResult(pMuonCluster, m_slidingFitWindow, slidingFitPitch);
143 
144  CartesianVector muonDirection(0.f, 0.f, 0.f);
145  slidingFitResult.GetGlobalDirection(slidingFitResult.GetLayerFitResultMap().begin()->second.GetGradient(), muonDirection);
146 
147  CartesianVector deltaRayVertex(0.f, 0.f, 0.f), muonVertex(0.f, 0.f, 0.f);
148  LArClusterHelper::GetClosestPositions(pDeltaRayCluster, pMuonCluster, deltaRayVertex, muonVertex);
149 
150  // Find furthest point in DR cluster that lies on the projected muon track
151  float furthestSeparation(0.f);
152  CartesianVector extendedPoint(0.f, 0.f, 0.f);
153 
154  CaloHitList deltaRayHitList;
155  pDeltaRayCluster->GetOrderedCaloHitList().FillCaloHitList(deltaRayHitList);
156 
157  for (const CaloHit *const pCaloHit : deltaRayHitList)
158  {
159  const CartesianVector &position(pCaloHit->GetPositionVector());
160  const float separation((position - muonVertex).GetMagnitude());
161 
162  if (separation > furthestSeparation)
163  {
164  if (this->IsCloseToLine(position, muonVertex, muonVertex + muonDirection, m_distanceToLine))
165  {
166  furthestSeparation = separation;
167  extendedPoint = position;
168  }
169  }
170  }
171 
172  // Check if delta ray has significant track contamination
173  if (furthestSeparation < m_minContaminationLength)
174  return false;
175 
176  // ATTN: Avoid cases where opening angle is small - it is easy to make mistakes in these instances
177  CaloHitList muonHitList;
178  pMuonCluster->GetOrderedCaloHitList().FillCaloHitList(muonHitList);
179 
180  for (const CaloHit *const pCaloHit : muonHitList)
181  {
182  if (this->IsInLineSegment(deltaRayVertex, extendedPoint, pCaloHit->GetPositionVector()))
183  return false;
184  }
185 
186  return true;
187 }
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
float m_distanceToLine
The maximum perpendicular distance of a position to a line for it to be considered close...
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
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
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.
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.
float m_minContaminationLength
The minimum projected length of a delta ray cluster onto the muon track for it to be considered conta...
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::RemovalBaseTool::IsInLineSegment ( const pandora::CartesianVector &  lowerBoundary,
const pandora::CartesianVector &  upperBoundary,
const pandora::CartesianVector &  point 
) const
protectedinherited

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 129 of file RemovalBaseTool.cc.

Referenced by lar_content::RemovalBaseTool::FindExtrapolatedHits(), and IsContaminated().

130 {
131  const float segmentBoundaryGradient = (-1.f) * (upperBoundary.GetX() - lowerBoundary.GetX()) / (upperBoundary.GetZ() - lowerBoundary.GetZ());
132  const float xPointOnUpperLine((point.GetZ() - upperBoundary.GetZ()) / segmentBoundaryGradient + upperBoundary.GetX());
133  const float xPointOnLowerLine((point.GetZ() - lowerBoundary.GetZ()) / segmentBoundaryGradient + lowerBoundary.GetX());
134 
135  if (std::fabs(xPointOnUpperLine - point.GetX()) < std::numeric_limits<float>::epsilon())
136  return true;
137 
138  if (std::fabs(xPointOnLowerLine - point.GetX()) < std::numeric_limits<float>::epsilon())
139  return true;
140 
141  if ((point.GetX() > xPointOnUpperLine) && (point.GetX() > xPointOnLowerLine))
142  return false;
143 
144  if ((point.GetX() < xPointOnUpperLine) && (point.GetX() < xPointOnLowerLine))
145  return false;
146 
147  return true;
148 }
bool lar_content::RemovalBaseTool::IsMuonEndpoint ( const TensorType::Element &  element,
const bool  ignoreHitType,
const pandora::HitType  hitTypeToIgnore = pandora::TPC_VIEW_U 
) const
protectedinherited

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 tensor 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 42 of file RemovalBaseTool.cc.

References lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetMuonCluster(), and lar_content::DeltaRayTensorTool::m_pParentAlgorithm.

Referenced by lar_content::DeltaRayRemovalTool::PassElementChecks(), and PassElementChecks().

43 {
44  for (const HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
45  {
46  if (ignoreHitType && (hitType == hitTypeToIgnore))
47  continue;
48 
49  const Cluster *pMuonCluster(nullptr), *const pDeltaRayCluster(element.GetCluster(hitType));
50 
51  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
52  return true;
53 
54  float xMinDR(-std::numeric_limits<float>::max()), xMaxDR(+std::numeric_limits<float>::max());
55  pDeltaRayCluster->GetClusterSpanX(xMinDR, xMaxDR);
56 
57  float xMinCR(-std::numeric_limits<float>::max()), xMaxCR(+std::numeric_limits<float>::max());
58  pMuonCluster->GetClusterSpanX(xMinCR, xMaxCR);
59 
60  if ((xMinDR < xMinCR) || (xMaxDR > xMaxCR))
61  return true;
62 
63  float zMinDR(-std::numeric_limits<float>::max()), zMaxDR(+std::numeric_limits<float>::max());
64  pDeltaRayCluster->GetClusterSpanZ(xMinDR, xMaxDR, zMinDR, zMaxDR);
65 
66  float zMinCR(-std::numeric_limits<float>::max()), zMaxCR(+std::numeric_limits<float>::max());
67  pMuonCluster->GetClusterSpanZ(xMinCR, xMaxCR, zMinCR, zMaxCR);
68 
69  if ((zMinDR < zMinCR) || (zMaxDR > zMaxCR))
70  return true;
71  }
72 
73  return false;
74 }
ThreeViewDeltaRayMatchingAlgorithm * 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::CosmicRayRemovalTool::PassElementChecks ( const TensorType::Element &  element,
const pandora::HitType  hitType 
) const
privatevirtual

Determine whether element satifies simple checks.

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

Implements lar_content::RemovalBaseTool.

Definition at line 123 of file CosmicRayRemovalTool.cc.

References lar_content::RemovalBaseTool::IsMuonEndpoint(), and lar_content::RemovalBaseTool::PassElementChecks().

Referenced by RemoveCosmicRayHits().

124 {
125  // ATTN: Avoid endpoints, topological michel reconstruction is very ambiguous
126  if (this->IsMuonEndpoint(element, true, hitType))
127  return false;
128 
129  return RemovalBaseTool::PassElementChecks(element, hitType);
130 }
virtual bool PassElementChecks(const TensorType::Element &element, const pandora::HitType hitType) const =0
Determine whether element satifies simple checks.
bool IsMuonEndpoint(const TensorType::Element &element, const bool ignoreHitType, const pandora::HitType hitTypeToIgnore=pandora::TPC_VIEW_U) const
Determine whether the matched clusters suggest that the delta ray is at the endpoint of the cosmic ra...
StatusCode lar_content::RemovalBaseTool::ProjectDeltaRayPositions ( const TensorType::Element &  element,
const pandora::HitType  hitType,
pandora::CartesianPointVector &  projectedPositions 
) const
protectedinherited

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

Parameters
elementthe tensor 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 172 of file RemovalBaseTool.cc.

References lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetProjectedPositions(), and lar_content::DeltaRayTensorTool::m_pParentAlgorithm.

Referenced by CreateSeed().

173 {
174  HitTypeVector hitTypes({TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W});
175 
176  hitTypes.erase(std::find(hitTypes.begin(), hitTypes.end(), hitType));
177 
178  const Cluster *const pCluster1(element.GetCluster(hitTypes[0]));
179  const Cluster *const pCluster2(element.GetCluster(hitTypes[1]));
180 
181  return m_pParentAlgorithm->GetProjectedPositions(pCluster1, pCluster2, projectedPositions);
182 }
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...
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
std::vector< pandora::HitType > HitTypeVector
StatusCode lar_content::CosmicRayRemovalTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Implements lar_content::RemovalBaseTool.

Definition at line 399 of file CosmicRayRemovalTool.cc.

References m_maxDistanceToHit, m_maxDistanceToTrack, m_minContaminationLength, m_minRemnantClusterSize, m_slidingFitWindow, and lar_content::RemovalBaseTool::ReadSettings().

400 {
401  PANDORA_RETURN_RESULT_IF_AND_IF(
402  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
403 
404  PANDORA_RETURN_RESULT_IF_AND_IF(
405  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinContaminationLength", m_minContaminationLength));
406 
407  PANDORA_RETURN_RESULT_IF_AND_IF(
408  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxDistanceToHit", m_maxDistanceToHit));
409 
410  PANDORA_RETURN_RESULT_IF_AND_IF(
411  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinRemnantClusterSize", m_minRemnantClusterSize));
412 
413  PANDORA_RETURN_RESULT_IF_AND_IF(
414  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxDistanceToTrack", m_maxDistanceToTrack));
415 
416  return RemovalBaseTool::ReadSettings(xmlHandle);
417 }
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
float m_maxDistanceToHit
The maximum distance of a hit from the cosmic ray track for it to be added into the CR...
float m_maxDistanceToTrack
The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merge...
unsigned int m_minRemnantClusterSize
The minimum hit number of a remnant cluster for it to be considered significant.
float m_minContaminationLength
The minimum projected length of a delta ray cluster onto the muon track for it to be considered conta...
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)=0
void lar_content::CosmicRayRemovalTool::ReclusterRemnant ( const pandora::HitType  hitType,
const pandora::Cluster *const  pMuonCluster,
const pandora::Cluster *const  pDeltaRayRemnant,
pandora::ClusterVector &  clusterVector,
pandora::PfoVector &  pfoVector 
) const
private

Reculster a given 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 359 of file CosmicRayRemovalTool.cc.

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

Referenced by SplitDeltaRayCluster().

361 {
362  std::string caloHitListName(hitType == TPC_VIEW_U ? "CaloHitListU" : hitType == TPC_VIEW_V ? "CaloHitListV" : "CaloHitListW");
363 
364  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::ReplaceCurrentList<CaloHit>(*m_pParentAlgorithm, caloHitListName));
365  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
366  PandoraContentApi::ReplaceCurrentList<Cluster>(*m_pParentAlgorithm, m_pParentAlgorithm->GetClusterListName(hitType)));
367  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Delete<Cluster>(*m_pParentAlgorithm, pDeltaRayRemnant));
368 
369  const ClusterList *pClusterList(nullptr);
370  std::string newClusterListName;
371  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
372  PandoraContentApi::RunClusteringAlgorithm(*m_pParentAlgorithm, m_pParentAlgorithm->GetClusteringAlgName(), pClusterList, newClusterListName));
373 
374  const ClusterList remnantClusters(pClusterList->begin(), pClusterList->end());
375 
376  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
377  PandoraContentApi::SaveList<Cluster>(*m_pParentAlgorithm, newClusterListName, m_pParentAlgorithm->GetClusterListName(hitType)));
378  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
379  PandoraContentApi::ReplaceCurrentList<Cluster>(*m_pParentAlgorithm, m_pParentAlgorithm->GetClusterListName(hitType)));
380 
381  for (const Cluster *const pRemnant : remnantClusters)
382  {
383  if (pRemnant->GetNCaloHits() < m_minRemnantClusterSize)
384  {
385  if (LArClusterHelper::GetClosestDistance(pRemnant, pMuonCluster) < m_maxDistanceToTrack)
386  {
387  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::MergeAndDeleteClusters(*m_pParentAlgorithm, pMuonCluster, pRemnant));
388  continue;
389  }
390  }
391 
392  clusterVector.push_back(pRemnant);
393  pfoVector.push_back(nullptr);
394  }
395 }
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
float m_maxDistanceToTrack
The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merge...
std::string GetClusteringAlgName() const
Get the name of the clustering algorithm to be used to recluster created delta ray remnants...
unsigned int m_minRemnantClusterSize
The minimum hit number of a remnant cluster for it to be considered significant.
const std::string & GetClusterListName(const pandora::HitType hitType) const
Get the cluster list name corresponding to a specified hit type.
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::CosmicRayRemovalTool::RemoveCosmicRayHits ( const TensorType::ElementList elementList) const
private

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

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

Definition at line 68 of file CosmicRayRemovalTool.cc.

References CreateSeed(), GrowSeed(), lar_content::RemovalBaseTool::IsBestElement(), IsContaminated(), PassElementChecks(), and SplitDeltaRayCluster().

Referenced by Run().

69 {
70  ClusterSet modifiedClusters, checkedClusters;
71 
72  for (const TensorType::Element &element : elementList)
73  {
74  for (const HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
75  {
76  const Cluster *const pDeltaRayCluster(element.GetCluster(hitType));
77 
78  if (checkedClusters.count(pDeltaRayCluster))
79  continue;
80 
81  // ATTN: The underlying tensor will update during this loop, do not proceed if element has been modified
82  if ((modifiedClusters.count(element.GetClusterU())) || (modifiedClusters.count(element.GetClusterV())) ||
83  (modifiedClusters.count(element.GetClusterW())))
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, modifiedClusters))
93  continue;
94 
95  checkedClusters.insert(pDeltaRayCluster);
96 
97  CaloHitList deltaRayHits;
98  this->CreateSeed(element, hitType, deltaRayHits);
99 
100  if (deltaRayHits.empty())
101  continue;
102 
103  // ATTN: Abort if seed cannot be grown
104  CaloHitList remnantHits;
105  if (this->GrowSeed(element, hitType, deltaRayHits, remnantHits) != STATUS_CODE_SUCCESS)
106  continue;
107 
108  // ATTN: Abort if reformed DR cluster
109  if (deltaRayHits.size() == pDeltaRayCluster->GetNCaloHits())
110  continue;
111 
112  modifiedClusters.insert(pDeltaRayCluster);
113 
114  this->SplitDeltaRayCluster(element, hitType, deltaRayHits, remnantHits);
115  }
116  }
117 
118  return !modifiedClusters.empty();
119 }
bool IsContaminated(const TensorType::Element &element, const pandora::HitType hitType) const
Determine whether the cluster under investigation has muon contamination.
bool IsBestElement(const TensorType::Element &element, const pandora::HitType hitType, const TensorType::ElementList &elementList, const pandora::ClusterSet &modifiedClusters) const
Determine whether the input element is the best to use to modify the contaminated cluster (best is de...
virtual bool PassElementChecks(const TensorType::Element &element, const pandora::HitType hitType) const
Determine whether element satifies simple checks.
void SplitDeltaRayCluster(const TensorType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits, pandora::CaloHitList &deltaRayRemnantHits) const
Fragment the delta ray cluster adding hits to the muon track and perhaps creating significant remnant...
pandora::StatusCode GrowSeed(const TensorType::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...
HitType
Definition: HitType.h:12
void CreateSeed(const TensorType::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...
bool lar_content::CosmicRayRemovalTool::Run ( ThreeViewDeltaRayMatchingAlgorithm *const  pAlgorithm,
TensorType overlapTensor 
)
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::RemovalBaseTool.

Definition at line 34 of file CosmicRayRemovalTool.cc.

References lar_content::OverlapTensor< T >::GetConnectedElements(), lar_content::OverlapTensor< T >::GetSortedKeyClusters(), lar_content::DeltaRayTensorTool::m_pParentAlgorithm, and RemoveCosmicRayHits().

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

Fragment the delta ray cluster adding hits to the muon track and perhaps creating significant remnants in the process.

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

Definition at line 299 of file CosmicRayRemovalTool.cc.

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

Referenced by RemoveCosmicRayHits().

301 {
302  const Cluster *const pDeltaRayCluster(element.GetCluster(hitType)), *pMuonCluster(nullptr);
303 
304  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
305  return;
306 
307  m_pParentAlgorithm->UpdateUponDeletion(pMuonCluster);
308  m_pParentAlgorithm->UpdateUponDeletion(pDeltaRayCluster);
309 
310  std::string originalListName, fragmentListName;
311  ClusterList originalClusterList(1, pDeltaRayCluster);
312 
313  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
314  PandoraContentApi::ReplaceCurrentList<Cluster>(*m_pParentAlgorithm, m_pParentAlgorithm->GetClusterListName(hitType)));
315  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=,
316  PandoraContentApi::InitializeFragmentation(*m_pParentAlgorithm, originalClusterList, originalListName, fragmentListName));
317 
318  CaloHitList deltaRayHitList;
319  pDeltaRayCluster->GetOrderedCaloHitList().FillCaloHitList(deltaRayHitList);
320 
321  const Cluster *pDeltaRay(nullptr), *pDeltaRayRemnant(nullptr);
322 
323  for (const CaloHit *const pCaloHit : deltaRayHitList)
324  {
325  const bool isDeltaRay(std::find(collectedHits.begin(), collectedHits.end(), pCaloHit) != collectedHits.end());
326  const bool isDeltaRayRemnant(
327  !isDeltaRay && (std::find(deltaRayRemnantHits.begin(), deltaRayRemnantHits.end(), pCaloHit) != deltaRayRemnantHits.end()));
328  const Cluster *&pCluster(isDeltaRay ? pDeltaRay : isDeltaRayRemnant ? pDeltaRayRemnant : pMuonCluster);
329 
330  if (!pCluster)
331  {
332  PandoraContentApi::Cluster::Parameters parameters;
333  parameters.m_caloHitList.push_back(pCaloHit);
334  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Cluster::Create(*m_pParentAlgorithm, parameters, pCluster));
335  }
336  else
337  {
338  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::AddToCluster(*m_pParentAlgorithm, pCluster, pCaloHit));
339  }
340  }
341 
342  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::EndFragmentation(*m_pParentAlgorithm, fragmentListName, originalListName));
343 
344  ClusterVector clusterVector;
345  PfoVector pfoVector;
346  if (pDeltaRayRemnant)
347  this->ReclusterRemnant(hitType, pMuonCluster, pDeltaRayRemnant, clusterVector, pfoVector);
348 
349  clusterVector.push_back(pMuonCluster);
350  pfoVector.push_back(element.GetOverlapResult().GetCommonMuonPfoList().front());
351  clusterVector.push_back(pDeltaRay);
352  pfoVector.push_back(nullptr);
353 
354  m_pParentAlgorithm->UpdateForNewClusters(clusterVector, pfoVector);
355 }
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...
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
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 a given remnant cluster, merging insignificant created clusters into the parent muon (if pr...
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::RemovalBaseTool::m_distanceToLine
protectedinherited

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

Definition at line 115 of file RemovalBaseTool.h.

Referenced by lar_content::RemovalBaseTool::FindExtrapolatedHits(), IsContaminated(), and lar_content::RemovalBaseTool::ReadSettings().

float lar_content::CosmicRayRemovalTool::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 123 of file CosmicRayRemovalTool.h.

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

float lar_content::CosmicRayRemovalTool::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 125 of file CosmicRayRemovalTool.h.

Referenced by ReadSettings(), and ReclusterRemnant().

float lar_content::CosmicRayRemovalTool::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 122 of file CosmicRayRemovalTool.h.

Referenced by IsContaminated(), and ReadSettings().

unsigned int lar_content::CosmicRayRemovalTool::m_minRemnantClusterSize
private

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

Definition at line 124 of file CosmicRayRemovalTool.h.

Referenced by ReadSettings(), and ReclusterRemnant().

float lar_content::RemovalBaseTool::m_minSeparation
protectedinherited

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

Definition at line 114 of file RemovalBaseTool.h.

Referenced by lar_content::RemovalBaseTool::PassElementChecks(), and lar_content::RemovalBaseTool::ReadSettings().

unsigned int lar_content::CosmicRayRemovalTool::m_slidingFitWindow
private

The sliding fit window used in cosmic ray parameterisations.

Definition at line 121 of file CosmicRayRemovalTool.h.

Referenced by IsContaminated(), and ReadSettings().


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