All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TwoViewCosmicRayRemovalTool.h
Go to the documentation of this file.
1 /**
2  * @file larpandoracontent/LArThreeDReco/LArCosmicRay/TwoViewCosmicRayRemovalTool.h
3  *
4  * @brief Header file for the cosmic ray removal tool class
5  *
6  * $Log: $
7  */
8 #ifndef TWO_VIEW_COSMIC_RAY_REMOVAL_TOOL_H
9 #define TWO_VIEW_COSMIC_RAY_REMOVAL_TOOL_H 1
10 
12 
13 namespace lar_content
14 {
15 /**
16  * @brief TwoViewCosmicRayRemovalTool class
17  */
19 {
20 public:
21  typedef std::vector<pandora::HitType> HitTypeVector;
22  /**
23  * @brief Default constructor
24  */
26 
27 private:
28  bool Run(TwoViewDeltaRayMatchingAlgorithm *const pAlgorithm, MatrixType &overlapMatrix);
29  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
30 
31  /**
32  * @brief Remove hits from delta ray clusters that belong to the parent muon
33  *
34  * @param elementList the matrix element list
35  *
36  * @return whether any clusters have been modified
37  */
38  bool RemoveCosmicRayHits(const MatrixType::ElementList &elementList) const;
39 
40  /**
41  * @brief Determine whether element satifies simple checks
42  *
43  * @param element the matrix element
44  * @param hitType the hit type of the cluster under investigation
45  *
46  * @return whether the checks pass
47  */
48  bool PassElementChecks(const MatrixType::Element &element, const pandora::HitType hitType) const;
49 
50  /**
51  * @brief 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)
52  *
53  * @param element the matrix element
54  * @param ignoreHitType whether to ignore the cluster under investigation
55  * @param hitTypeToIgnore the hit type to ignore
56  *
57  * @return whether the delta ray is at the endpoint of the cosmic ray
58  */
59  bool IsMuonEndpoint(const MatrixType::Element &element, const pandora::HitType hitType) const;
60 
61  /**
62  * @brief Determine whether the cluster under investigation has muon contamination
63  *
64  * @param element the matrix element
65  * @param hitType the hit type of the cluster under investigation
66  *
67  * @return whether the cluster contains muon hits to remove
68  */
69  bool IsContaminated(const MatrixType::Element &element, const pandora::HitType hitType) const;
70 
71  /**
72  * @brief Whether a given position is close to a defined line
73  *
74  * @param hitPosition the input position
75  * @param lineStart the start position of the line
76  * @param lineEnd the end position of the line
77  * @param distanceToLine the definition of close
78  *
79  * @return whether the position is close to the definied line
80  */
81  bool IsCloseToLine(const pandora::CartesianVector &hitPosition, const pandora::CartesianVector &lineStart,
82  const pandora::CartesianVector &lineEnd, const float distanceToLine) const;
83 
84  /**
85  * @brief Whether the projection of a given position lies on a defined line
86  *
87  * @param lowerBoundary the start position of the line
88  * @param upperBoundary the end position of the line
89  * @param point the input position
90  *
91  * @return whether the position lies between the two points
92  */
93  bool IsInLineSegment(const pandora::CartesianVector &lowerBoundary, const pandora::CartesianVector &upperBoundary,
94  const pandora::CartesianVector &point) const;
95 
96  /**
97  * @brief Determine whether the input element is the best to use to modify the contaminated cluster (best is defined by the total hit count)
98  *
99  * @param element the matrix element
100  * @param hitType the hit type of the cluster under investigation
101  * @param elementList the matrix element list
102  *
103  * @return whether the input element is the best element
104  */
105  bool IsBestElement(const MatrixType::Element &element, const pandora::HitType hitType, const MatrixType::ElementList &elementList) const;
106 
107  /**
108  * @brief Collect hits in the delta ray cluster that lie close to calculated projected positions forming a seed to later grow
109  *
110  * @param element the matrix element
111  * @param hitType the hit type of the cluster under investigation
112  * @param collectedHits the output list of identified delta ray hits
113  */
114  void CreateSeed(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits) const;
115 
116  /**
117  * @brief 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
118  *
119  * @param element the matrix element
120  * @param hitType the hit type of the cluster under investigation
121  * @param collectedHits the list of identified delta ray hits
122  * @param deltaRayRemantHits the list of remainder hits
123  *
124  * @return whether the muon projection mechanics were successful - abort process if not
125  */
126  pandora::StatusCode GrowSeed(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits,
127  pandora::CaloHitList &deltaRayRemantHits) const;
128 
129  /**
130  * @brief Collect hits from the delta ray cluster to either keep (demandCloserToCollected == true) or separate into a new shower (demandCloserToCollected == false)
131  *
132  * @param positionOnMuon the parameterised muon position
133  * @param muonDirection the parameterised muon direction
134  * @param pDeltaRayCluster the delta ray cluster under investigation
135  * @param minDistanceFromMuon the minimum distance of a hit from the muon track for it to not belong to the muon
136  * @param demandCloserToCollected whether to demand a hit be closer to the collected hits than to the muon hits for it to be collected
137  * @param protectedHits the hits that are protected from being collected
138  * @param collectedHits the output list of collected hits
139  */
140  void CollectHitsFromDeltaRay(const pandora::CartesianVector &positionOnMuon, const pandora::CartesianVector &muonDirection,
141  const pandora::Cluster *const pDeltaRayCluster, const float &minDistanceFromMuon, const bool demandCloserToCollected,
142  const pandora::CaloHitList &protectedHits, pandora::CaloHitList &collectedHits) const;
143 
144  /**
145  * @brief Fragment the delta ray cluster, refining the matched delta ray cluster perhaps creating significant remnants in the process
146  *
147  * @param element the matrix element
148  * @param hitType the hit type of the cluster under investigation
149  * @param collectedHits the list of identified delta ray hits
150  * @param deltaRayRemantHits the list of remainder hits
151  */
152  void SplitDeltaRayCluster(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits,
153  pandora::CaloHitList &deltaRayRemnantHits) const;
154 
155  /**
156  * @brief Reculster the remnant cluster, merging insignificant created clusters into the parent muon (if proximity checks pass)
157  *
158  * @param hitType the hit type of the cluster under investigation
159  * @param pMuonCluster the address of the parent muon cluster
160  * @param pDeltaRayRemnant the address of the delta ray remnant
161  * @param clusterVector a vector containing the address of created/modified clusters for bookeeping purposes
162  * @param pfoVector a vector containing the address of the pfo to which a modified muon cluster belongs for bookeeping purposes
163  */
164  void ReclusterRemnant(const pandora::HitType hitType, const pandora::Cluster *const pMuonCluster,
165  const pandora::Cluster *const pDeltaRayRemnant, pandora::ClusterVector &clusterVector, pandora::PfoVector &pfoVector) const;
166 
167  /**
168  * @brief Use two views of a delta ray pfo to calculate projected positions in a given third view
169  *
170  * @param element the matrix element
171  * @param hitType the view to be projected into
172  * @param projectedPositions the output list of projected positions
173  *
174  * @return a status code reflecting whether the procedure ran smoothly and if the outcome is good
175  */
176  pandora::StatusCode ProjectDeltaRayPositions(
177  const MatrixType::Element &element, const pandora::HitType hitType, pandora::CartesianPointVector &projectedPositions) const;
178 
179  float m_minSeparation; ///< The minimum delta ray - parent muon cluster separation required to investigate delta ray cluster
180  unsigned int m_slidingFitWindow; ///< The sliding fit window used in cosmic ray parameterisations
181  float m_distanceToLine; ///< The maximum perpendicular distance of a position to a line for it to be considered close
182  float m_minContaminationLength; ///< The minimum projected length of a delta ray cluster onto the muon track for it to be considered contaminated
183  float m_maxDistanceToHit; ///< The maximum distance of a hit from the cosmic ray track for it to be added into the CR
184  unsigned int m_minRemnantClusterSize; ///< The minimum hit number of a remnant cluster for it to be considered significant
185  float m_maxDistanceToTrack; ///< The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merged into the CR
186 };
187 
188 } // namespace lar_content
189 
190 #endif // #ifndef TWO_VIEW_COSMIC_RAY_REMOVAL_TOOL_H
void SplitDeltaRayCluster(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits, pandora::CaloHitList &deltaRayRemnantHits) const
Fragment the delta ray cluster, refining the matched delta ray cluster perhaps creating significant r...
void 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 ...
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
bool RemoveCosmicRayHits(const MatrixType::ElementList &elementList) const
Remove hits from delta ray clusters that belong to the parent muon.
void CreateSeed(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits) const
Collect hits in the delta ray cluster that lie close to calculated projected positions forming a seed...
unsigned int m_minRemnantClusterSize
The minimum hit number of a remnant cluster for it to be considered significant.
pandora::StatusCode ProjectDeltaRayPositions(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CartesianPointVector &projectedPositions) const
Use two views of a delta ray pfo to calculate projected positions in a given third view...
bool PassElementChecks(const MatrixType::Element &element, const pandora::HitType hitType) const
Determine whether element satifies simple checks.
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.
pandora::StatusCode GrowSeed(const MatrixType::Element &element, const pandora::HitType hitType, pandora::CaloHitList &collectedHits, pandora::CaloHitList &deltaRayRemantHits) const
Examine remaining hits in the delta ray cluster adding them to the delta ray seed or parent muon if a...
void ReclusterRemnant(const pandora::HitType hitType, const pandora::Cluster *const pMuonCluster, const pandora::Cluster *const pDeltaRayRemnant, pandora::ClusterVector &clusterVector, pandora::PfoVector &pfoVector) const
Reculster the remnant cluster, merging insignificant created clusters into the parent muon (if proxim...
bool IsBestElement(const MatrixType::Element &element, const pandora::HitType hitType, const MatrixType::ElementList &elementList) const
Determine whether the input element is the best to use to modify the contaminated cluster (best is de...
float m_maxDistanceToTrack
The minimum distance of an insignificant remnant cluster from the cosmic ray track for it to be merge...
float m_minContaminationLength
The minimum projected length of a delta ray cluster onto the muon track for it to be considered conta...
bool Run(TwoViewDeltaRayMatchingAlgorithm *const pAlgorithm, MatrixType &overlapMatrix)
Run the algorithm tool.
bool IsContaminated(const MatrixType::Element &element, const pandora::HitType hitType) const
Determine whether the cluster under investigation has muon contamination.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
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 IsMuonEndpoint(const MatrixType::Element &element, const pandora::HitType hitType) const
Determine whether the matched clusters suggest that the delta ray is at the endpoint of the cosmic ra...
float m_minSeparation
The minimum delta ray - parent muon cluster separation required to investigate delta ray cluster...
float m_maxDistanceToHit
The maximum distance of a hit from the cosmic ray track for it to be added into the CR...
std::vector< art::Ptr< recob::Cluster > > ClusterVector