Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lar_content::RemovalBaseTool Class Referenceabstract

RemovalBaseTool class. More...

#include <RemovalBaseTool.h>

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

Public Types

typedef std::vector< pandora::HitType > HitTypeVector
 
- Public Types inherited from lar_content::DeltaRayTensorTool
typedef ThreeViewDeltaRayMatchingAlgorithm::MatchingType::TensorType TensorType
 
typedef std::vector< TensorType::ElementList::const_iteratorIteratorList
 

Public Member Functions

 RemovalBaseTool ()
 Default constructor. More...
 

Protected Member Functions

virtual bool Run (ThreeViewDeltaRayMatchingAlgorithm *const pAlgorithm, TensorType &overlapTensor)=0
 Run the algorithm tool. More...
 
virtual pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)=0
 
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...
 
virtual bool PassElementChecks (const TensorType::Element &element, const pandora::HitType hitType) const =0
 Determine whether element satifies simple checks. 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...
 

Additional Inherited Members

- Public Attributes inherited from lar_content::DeltaRayTensorTool
ThreeViewDeltaRayMatchingAlgorithmm_pParentAlgorithm
 Address of the parent matching algorithm. More...
 

Detailed Description

RemovalBaseTool class.

Definition at line 18 of file RemovalBaseTool.h.

Member Typedef Documentation

Definition at line 21 of file RemovalBaseTool.h.

Constructor & Destructor Documentation

lar_content::RemovalBaseTool::RemovalBaseTool ( )

Default constructor.

Definition at line 20 of file RemovalBaseTool.cc.

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

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
protected

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

152 {
153  CaloHitList caloHitList;
154  pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
155 
156  for (const CaloHit *const pCaloHit : caloHitList)
157  {
158  if (!this->IsInLineSegment(lowerBoundary, upperBoundary, pCaloHit->GetPositionVector()))
159  continue;
160 
161  if (!this->IsCloseToLine(pCaloHit->GetPositionVector(), lowerBoundary, upperBoundary, m_distanceToLine))
162  continue;
163 
164  collectedHits.push_back(pCaloHit);
165  }
166 }
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
protected

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

78 {
79  const float chiSquared(element.GetOverlapResult().GetReducedChi2());
80  const unsigned int hitSum(element.GetClusterU()->GetNCaloHits() + element.GetClusterV()->GetNCaloHits() + element.GetClusterW()->GetNCaloHits());
81 
82  for (const TensorType::Element &testElement : elementList)
83  {
84  if (modifiedClusters.count(testElement.GetClusterU()) || modifiedClusters.count(testElement.GetClusterV()) ||
85  modifiedClusters.count(testElement.GetClusterW()))
86  continue;
87 
88  if (testElement.GetCluster(hitType) != element.GetCluster(hitType))
89  continue;
90 
91  if ((testElement.GetClusterU() == element.GetClusterU()) && (testElement.GetClusterV() == element.GetClusterV()) &&
92  (testElement.GetClusterW() == element.GetClusterW()))
93  continue;
94 
95  const unsigned int testHitSum(
96  testElement.GetClusterU()->GetNCaloHits() + testElement.GetClusterV()->GetNCaloHits() + testElement.GetClusterW()->GetNCaloHits());
97  const float testChiSquared(testElement.GetOverlapResult().GetReducedChi2());
98 
99  if ((testHitSum < hitSum) || ((testHitSum == hitSum) && (testChiSquared > chiSquared)))
100  continue;
101 
102  if (this->PassElementChecks(testElement, hitType))
103  return false;
104  }
105 
106  return true;
107 }
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
protected

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

113 {
114  CartesianVector lineDirection(lineStart - lineEnd);
115  lineDirection = lineDirection.GetUnitVector();
116 
117  const float transverseDistanceFromLine(lineDirection.GetCrossProduct(hitPosition - lineStart).GetMagnitude());
118 
119  if (transverseDistanceFromLine > distanceToLine)
120  return false;
121 
122  return true;
123 }
bool lar_content::RemovalBaseTool::IsInLineSegment ( const pandora::CartesianVector &  lowerBoundary,
const pandora::CartesianVector &  upperBoundary,
const pandora::CartesianVector &  point 
) const
protected

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

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

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

41 {
42  for (const HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
43  {
44  if (ignoreHitType && (hitType == hitTypeToIgnore))
45  continue;
46 
47  const Cluster *pMuonCluster(nullptr), *const pDeltaRayCluster(element.GetCluster(hitType));
48 
49  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
50  return true;
51 
53  pDeltaRayCluster->GetClusterSpanX(xMinDR, xMaxDR);
54 
56  pMuonCluster->GetClusterSpanX(xMinCR, xMaxCR);
57 
58  if ((xMinDR < xMinCR) || (xMaxDR > xMaxCR))
59  return true;
60 
62  pDeltaRayCluster->GetClusterSpanZ(xMinDR, xMaxDR, zMinDR, zMaxDR);
63 
65  pMuonCluster->GetClusterSpanZ(xMinCR, xMaxCR, zMinCR, zMaxCR);
66 
67  if ((zMinDR < zMinCR) || (zMaxDR > zMaxCR))
68  return true;
69  }
70 
71  return false;
72 }
enum cvn::HType HitType
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
static int max(int a, int b)
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::PassElementChecks ( const TensorType::Element &  element,
const pandora::HitType  hitType 
) const
protectedpure virtual

Determine whether element satifies simple checks.

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

Implemented in lar_content::CosmicRayRemovalTool, and lar_content::DeltaRayRemovalTool.

Definition at line 26 of file RemovalBaseTool.cc.

27 {
28  const Cluster *pMuonCluster(nullptr), *const pDeltaRayCluster(element.GetCluster(hitType));
29 
30  if (m_pParentAlgorithm->GetMuonCluster(element.GetOverlapResult().GetCommonMuonPfoList(), hitType, pMuonCluster) != STATUS_CODE_SUCCESS)
31  return false;
32 
33  const float separation(LArClusterHelper::GetClosestDistance(pDeltaRayCluster, pMuonCluster));
34 
35  return separation <= m_minSeparation;
36 }
float m_minSeparation
The minimum delta ray - parent muon cluster separation required to investigate a delta/cosmic ray clu...
ThreeViewDeltaRayMatchingAlgorithm * m_pParentAlgorithm
Address of the parent matching algorithm.
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::RemovalBaseTool::ProjectDeltaRayPositions ( const TensorType::Element &  element,
const pandora::HitType  hitType,
pandora::CartesianPointVector &  projectedPositions 
) const
protected

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

171 {
172  HitTypeVector hitTypes({TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W});
173 
174  hitTypes.erase(std::find(hitTypes.begin(), hitTypes.end(), hitType));
175 
176  const Cluster *const pCluster1(element.GetCluster(hitTypes[0]));
177  const Cluster *const pCluster2(element.GetCluster(hitTypes[1]));
178 
179  return m_pParentAlgorithm->GetProjectedPositions(pCluster1, pCluster2, projectedPositions);
180 }
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::RemovalBaseTool::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
protectedpure virtual

Implemented in lar_content::CosmicRayRemovalTool, and lar_content::DeltaRayRemovalTool.

Definition at line 184 of file RemovalBaseTool.cc.

185 {
186  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinSeparation", m_minSeparation));
187 
188  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "DistanceToLine", m_distanceToLine));
189 
190  return STATUS_CODE_SUCCESS;
191 }
float m_minSeparation
The minimum delta ray - parent muon cluster separation required to investigate a delta/cosmic ray clu...
float m_distanceToLine
The maximum perpendicular distance of a position to a line for it to be considered close...
virtual bool lar_content::RemovalBaseTool::Run ( ThreeViewDeltaRayMatchingAlgorithm *const  pAlgorithm,
TensorType overlapTensor 
)
protectedpure virtual

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::DeltaRayTensorTool.

Implemented in lar_content::CosmicRayRemovalTool, and lar_content::DeltaRayRemovalTool.

Member Data Documentation

float lar_content::RemovalBaseTool::m_distanceToLine
protected

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

Definition at line 115 of file RemovalBaseTool.h.

float lar_content::RemovalBaseTool::m_minSeparation
protected

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

Definition at line 114 of file RemovalBaseTool.h.


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