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

DeltaRayRemovalTool class. More...

#include "DeltaRayRemovalTool.h"

Inheritance diagram for lar_content::DeltaRayRemovalTool:
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

 DeltaRayRemovalTool ()
 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 RemoveDeltaRayHits (const TensorType::ElementList &elementList) const
 Remove hits from cosmic ray clusters that belong to a child delta ray. 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 cosmic ray cluster under investigation has delta ray contamination. More...
 
void SplitMuonCluster (const TensorType::Element &element, const pandora::HitType hitType, const pandora::CaloHitList &deltaRayHits) const
 Remove collected delta ray hits from the cosmic ray pfo. More...
 

Private Attributes

unsigned int m_slidingFitWindow
 The sliding fit window used in cosmic ray parameterisations. More...
 
float m_minDeviationFromTransverse
 The minimum deviation from transverse required to avoid mistakes. More...
 
float m_contaminationWindow
 The distance in which to search for delta ray contamination in the cosmic ray track. More...
 
unsigned int m_significantHitThreshold
 The threshold number of hits which define significant contimination. More...
 
float m_minDistanceFromMuon
 The minimum distance of a hit from the cosmic ray track required for removal. More...
 
float m_maxDistanceToCollected
 The maximim distance of a hit from the projected delta ray hits required for removal. More...
 

Detailed Description

DeltaRayRemovalTool class.

Definition at line 19 of file DeltaRayRemovalTool.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::DeltaRayRemovalTool::DeltaRayRemovalTool ( )

Default constructor.

Definition at line 23 of file DeltaRayRemovalTool.cc.

23  :
24  m_slidingFitWindow(10000),
30 {
31 }
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
float m_contaminationWindow
The distance in which to search for delta ray contamination in the cosmic ray track.
float m_minDistanceFromMuon
The minimum distance of a hit from the cosmic ray track required for removal.
TFile f
Definition: plotHisto.C:6
float m_minDeviationFromTransverse
The minimum deviation from transverse required to avoid mistakes.
float m_maxDistanceToCollected
The maximim distance of a hit from the projected delta ray hits required for removal.
unsigned int m_significantHitThreshold
The threshold number of hits which define significant contimination.

Member Function Documentation

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 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.
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 lar_content::CosmicRayRemovalTool::RemoveCosmicRayHits(), and 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 lar_content::CosmicRayRemovalTool::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::DeltaRayRemovalTool::IsContaminated ( const TensorType::Element &  element,
const pandora::HitType  hitType 
) const
private

Determine whether the cosmic ray cluster under investigation has delta ray contamination.

Parameters
elementthe tensor element
hitTypethe hit type of the view under investigation
Returns
whether the cosmic ray cluster is likely to contain delta ray hits that can be removed

Definition at line 126 of file DeltaRayRemovalTool.cc.

References f, lar_content::RemovalBaseTool::FindExtrapolatedHits(), lar_content::LArClusterHelper::GetClosestPositions(), lar_content::TwoDSlidingFitResult::GetGlobalDirection(), lar_content::TwoDSlidingFitResult::GetLayerFitResultMap(), lar_content::NViewDeltaRayMatchingAlgorithm< T >::GetMuonCluster(), lar_content::LArGeometryHelper::GetWirePitch(), m_contaminationWindow, m_minDeviationFromTransverse, lar_content::DeltaRayTensorTool::m_pParentAlgorithm, m_significantHitThreshold, and m_slidingFitWindow.

Referenced by RemoveDeltaRayHits().

127 {
128  const Cluster *pMuonCluster(nullptr), *const pDeltaRayCluster(element.GetCluster(hitType));
129 
130  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
131  return false;
132 
133  const float slidingFitPitch(LArGeometryHelper::GetWirePitch(this->GetPandora(), hitType));
134  const TwoDSlidingFitResult slidingFitResult(pMuonCluster, m_slidingFitWindow, slidingFitPitch);
135 
136  CartesianVector muonDirection(0.f, 0.f, 0.f);
137  slidingFitResult.GetGlobalDirection(slidingFitResult.GetLayerFitResultMap().begin()->second.GetGradient(), muonDirection);
138 
139  const CartesianVector xAxis(1.f, 0.f, 0.f);
140  const bool isTransverse((muonDirection.GetOpeningAngle(xAxis) < m_minDeviationFromTransverse) ||
141  ((M_PI - muonDirection.GetOpeningAngle(xAxis)) < m_minDeviationFromTransverse));
142 
143  if (isTransverse)
144  return false;
145 
146  CartesianVector deltaRayVertex(0.f, 0.f, 0.f), muonVertex(0.f, 0.f, 0.f);
147  LArClusterHelper::GetClosestPositions(pDeltaRayCluster, pMuonCluster, deltaRayVertex, muonVertex);
148 
149  CaloHitList minusMuonHits, minusDeltaRayHits, plusMuonHits, plusDeltaRayHits;
150  const CartesianVector minusPosition(muonVertex - (muonDirection * m_contaminationWindow));
151  const CartesianVector plusPosition(muonVertex + (muonDirection * m_contaminationWindow));
152 
153  this->FindExtrapolatedHits(pMuonCluster, muonVertex, minusPosition, minusMuonHits);
154  this->FindExtrapolatedHits(pMuonCluster, muonVertex, plusPosition, plusMuonHits);
155  this->FindExtrapolatedHits(pDeltaRayCluster, muonVertex, minusPosition, minusDeltaRayHits);
156  this->FindExtrapolatedHits(pDeltaRayCluster, muonVertex, plusPosition, plusDeltaRayHits);
157 
158  if ((minusMuonHits.size() < m_significantHitThreshold) && (plusMuonHits.size() < m_significantHitThreshold))
159  return true;
160 
161  if ((minusMuonHits.size() < m_significantHitThreshold) && (minusDeltaRayHits.size() >= m_significantHitThreshold) &&
162  (plusDeltaRayHits.size() < m_significantHitThreshold) && (plusMuonHits.size() >= m_significantHitThreshold))
163  {
164  return true;
165  }
166 
167  if ((plusMuonHits.size() < m_significantHitThreshold) && (plusDeltaRayHits.size() >= m_significantHitThreshold) &&
168  (minusDeltaRayHits.size() < m_significantHitThreshold) && (minusMuonHits.size() >= m_significantHitThreshold))
169  {
170  return true;
171  }
172 
173  return false;
174 }
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
float m_contaminationWindow
The distance in which to search for delta ray contamination in the cosmic ray track.
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
float m_minDeviationFromTransverse
The minimum deviation from transverse required to avoid mistakes.
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.
static float GetWirePitch(const pandora::Pandora &pandora, const pandora::HitType view, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
unsigned int m_significantHitThreshold
The threshold number of hits which define significant contimination.
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 lar_content::CosmicRayRemovalTool::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 PassElementChecks(), and lar_content::CosmicRayRemovalTool::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::DeltaRayRemovalTool::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 115 of file DeltaRayRemovalTool.cc.

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

Referenced by RemoveDeltaRayHits().

116 {
117  // ATTN: Avoid endpoints, topological michel reconstruction is very ambiguous
118  if (this->IsMuonEndpoint(element, false))
119  return false;
120 
121  return RemovalBaseTool::PassElementChecks(element, hitType);
122 }
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 lar_content::CosmicRayRemovalTool::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::DeltaRayRemovalTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
privatevirtual

Implements lar_content::RemovalBaseTool.

Definition at line 201 of file DeltaRayRemovalTool.cc.

References m_contaminationWindow, m_maxDistanceToCollected, m_minDeviationFromTransverse, m_minDistanceFromMuon, m_significantHitThreshold, and m_slidingFitWindow.

202 {
203  PANDORA_RETURN_RESULT_IF_AND_IF(
204  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
205 
206  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
207  XmlHelper::ReadValue(xmlHandle, "MinDeviationFromTransverse", m_minDeviationFromTransverse));
208 
209  PANDORA_RETURN_RESULT_IF_AND_IF(
210  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ContaminationWindow", m_contaminationWindow));
211 
212  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
213  XmlHelper::ReadValue(xmlHandle, "SignificantHitThreshold", m_significantHitThreshold));
214 
215  PANDORA_RETURN_RESULT_IF_AND_IF(
216  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinDistanceFromMuon", m_minDistanceFromMuon));
217 
218  PANDORA_RETURN_RESULT_IF_AND_IF(
219  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MaxDistanceToCollected", m_maxDistanceToCollected));
220 
221  return STATUS_CODE_SUCCESS;
222 }
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
float m_contaminationWindow
The distance in which to search for delta ray contamination in the cosmic ray track.
float m_minDistanceFromMuon
The minimum distance of a hit from the cosmic ray track required for removal.
float m_minDeviationFromTransverse
The minimum deviation from transverse required to avoid mistakes.
float m_maxDistanceToCollected
The maximim distance of a hit from the projected delta ray hits required for removal.
unsigned int m_significantHitThreshold
The threshold number of hits which define significant contimination.
bool lar_content::DeltaRayRemovalTool::RemoveDeltaRayHits ( const TensorType::ElementList elementList) const
private

Remove hits from cosmic ray clusters that belong to a child delta ray.

Parameters
elementListthe tensor element list
Returns
changesMade whether clusters in element have been modified

Definition at line 69 of file DeltaRayRemovalTool.cc.

References lar_content::NViewDeltaRayMatchingAlgorithm< T >::CollectHitsFromMuon(), lar_content::RemovalBaseTool::IsBestElement(), IsContaminated(), m_maxDistanceToCollected, m_minDistanceFromMuon, lar_content::DeltaRayTensorTool::m_pParentAlgorithm, PassElementChecks(), and SplitMuonCluster().

Referenced by Run().

70 {
71  ClusterSet modifiedClusters, checkedClusters;
72 
73  for (const TensorType::Element &element : elementList)
74  {
75  for (const HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
76  {
77  const Cluster *pDeltaRayCluster(element.GetCluster(hitType));
78  const ParticleFlowObject *const pMuonPfo(element.GetOverlapResult().GetCommonMuonPfoList().front());
79 
80  if (checkedClusters.count(pDeltaRayCluster))
81  continue;
82 
83  // ATTN: The underlying tensor will update during this loop, do not proceed if element has been modified
84  if ((modifiedClusters.count(element.GetClusterU())) || (modifiedClusters.count(element.GetClusterV())) ||
85  (modifiedClusters.count(element.GetClusterW())))
86  continue;
87 
88  if (!this->PassElementChecks(element, hitType))
89  continue;
90 
91  if (!this->IsContaminated(element, hitType))
92  continue;
93 
94  if (!this->IsBestElement(element, hitType, elementList, modifiedClusters))
95  continue;
96 
97  checkedClusters.insert(pDeltaRayCluster);
98 
99  CaloHitList deltaRayHits;
100  if (m_pParentAlgorithm->CollectHitsFromMuon(nullptr, nullptr, pDeltaRayCluster, pMuonPfo, m_minDistanceFromMuon,
101  m_maxDistanceToCollected, deltaRayHits) != STATUS_CODE_SUCCESS)
102  continue;
103 
104  modifiedClusters.insert(pDeltaRayCluster);
105 
106  this->SplitMuonCluster(element, hitType, deltaRayHits);
107  }
108  }
109 
110  return !modifiedClusters.empty();
111 }
pandora::StatusCode CollectHitsFromMuon(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pThirdViewCluster, const pandora::ParticleFlowObject *const pParentMuon, const float minDistanceFromMuon, const float maxDistanceToCollected, pandora::CaloHitList &collectedHits) const
In one view, pull out any hits from a cosmic ray cluster that belong to the child delta ray cluster...
bool IsContaminated(const TensorType::Element &element, const pandora::HitType hitType) const
Determine whether the cosmic ray cluster under investigation has delta ray contamination.
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
float m_minDistanceFromMuon
The minimum distance of a hit from the cosmic ray track required for removal.
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...
float m_maxDistanceToCollected
The maximim distance of a hit from the projected delta ray hits required for removal.
void SplitMuonCluster(const TensorType::Element &element, const pandora::HitType hitType, const pandora::CaloHitList &deltaRayHits) const
Remove collected delta ray hits from the cosmic ray pfo.
virtual bool PassElementChecks(const TensorType::Element &element, const pandora::HitType hitType) const
Determine whether element satifies simple checks.
HitType
Definition: HitType.h:12
bool lar_content::DeltaRayRemovalTool::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 35 of file DeltaRayRemovalTool.cc.

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

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  overlapTensor.GetSortedKeyClusters(sortedKeyClusters);
46 
47  ClusterSet usedKeyClusters;
48  for (const Cluster *const pKeyCluster : sortedKeyClusters)
49  {
50  if (usedKeyClusters.count(pKeyCluster))
51  continue;
52 
53  TensorType::ElementList elementList;
54  overlapTensor.GetConnectedElements(pKeyCluster, true, elementList);
55 
56  for (const TensorType::Element &element : elementList)
57  usedKeyClusters.insert(element.GetClusterU());
58 
59  const bool changesMadeInIteration = this->RemoveDeltaRayHits(elementList);
60 
61  changesMade = (changesMade ? changesMade : changesMadeInIteration);
62  }
63 
64  return changesMade;
65 }
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
bool RemoveDeltaRayHits(const TensorType::ElementList &elementList) const
Remove hits from cosmic ray clusters that belong to a child delta ray.
void lar_content::DeltaRayRemovalTool::SplitMuonCluster ( const TensorType::Element &  element,
const pandora::HitType  hitType,
const pandora::CaloHitList &  deltaRayHits 
) const
private

Remove collected delta ray hits from the cosmic ray pfo.

Parameters
elementthe tensor element
hitTypethe hit type of the cluster under investigation
deltaRayHitsthe list of delta ray hits to remove

Definition at line 178 of file DeltaRayRemovalTool.cc.

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

Referenced by RemoveDeltaRayHits().

179 {
180  const Cluster *pDeltaRayCluster(element.GetCluster(hitType)), *pMuonCluster(nullptr);
181 
182  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
183  throw StatusCodeException(STATUS_CODE_FAILURE);
184 
185  m_pParentAlgorithm->UpdateUponDeletion(pMuonCluster);
186  m_pParentAlgorithm->UpdateUponDeletion(pDeltaRayCluster);
187 
188  m_pParentAlgorithm->SplitMuonCluster(m_pParentAlgorithm->GetClusterListName(hitType), pMuonCluster, deltaRayHits, pDeltaRayCluster);
189 
190  ClusterVector clusterVector;
191  PfoVector pfoVector;
192  clusterVector.push_back(pMuonCluster);
193  pfoVector.push_back(element.GetOverlapResult().GetCommonMuonPfoList().front());
194  clusterVector.push_back(pDeltaRayCluster);
195  pfoVector.push_back(nullptr);
196  m_pParentAlgorithm->UpdateForNewClusters(clusterVector, pfoVector);
197 }
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 SplitMuonCluster(const std::string &clusterListName, const pandora::Cluster *const pMuonCluster, const pandora::CaloHitList &collectedHits, const pandora::Cluster *&pDeltaRayCluster) const
Move a list of hits from a cosmic ray cluster into the given child delta ray cluster.
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::DeltaRayRemovalTool::m_contaminationWindow
private

The distance in which to search for delta ray contamination in the cosmic ray track.

Definition at line 71 of file DeltaRayRemovalTool.h.

Referenced by IsContaminated(), and ReadSettings().

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(), lar_content::CosmicRayRemovalTool::IsContaminated(), and lar_content::RemovalBaseTool::ReadSettings().

float lar_content::DeltaRayRemovalTool::m_maxDistanceToCollected
private

The maximim distance of a hit from the projected delta ray hits required for removal.

Definition at line 74 of file DeltaRayRemovalTool.h.

Referenced by ReadSettings(), and RemoveDeltaRayHits().

float lar_content::DeltaRayRemovalTool::m_minDeviationFromTransverse
private

The minimum deviation from transverse required to avoid mistakes.

Definition at line 70 of file DeltaRayRemovalTool.h.

Referenced by IsContaminated(), and ReadSettings().

float lar_content::DeltaRayRemovalTool::m_minDistanceFromMuon
private

The minimum distance of a hit from the cosmic ray track required for removal.

Definition at line 73 of file DeltaRayRemovalTool.h.

Referenced by ReadSettings(), and RemoveDeltaRayHits().

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::DeltaRayRemovalTool::m_significantHitThreshold
private

The threshold number of hits which define significant contimination.

Definition at line 72 of file DeltaRayRemovalTool.h.

Referenced by IsContaminated(), and ReadSettings().

unsigned int lar_content::DeltaRayRemovalTool::m_slidingFitWindow
private

The sliding fit window used in cosmic ray parameterisations.

Definition at line 69 of file DeltaRayRemovalTool.h.

Referenced by IsContaminated(), and ReadSettings().


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