9 #include "Pandora/AlgorithmHeaders.h" 23 DeltaRayRemovalTool::DeltaRayRemovalTool() :
24 m_slidingFitWindow(10000),
25 m_minDeviationFromTransverse(0.35
f),
26 m_contaminationWindow(5.
f),
27 m_significantHitThreshold(3),
28 m_minDistanceFromMuon(1.
f),
29 m_maxDistanceToCollected(1.
f)
39 if (PandoraContentApi::GetSettings(*m_pParentAlgorithm)->ShouldDisplayAlgorithmInfo())
40 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() <<
std::endl;
42 bool changesMade(
false);
47 ClusterSet usedKeyClusters;
48 for (
const Cluster *
const pKeyCluster : sortedKeyClusters)
50 if (usedKeyClusters.count(pKeyCluster))
56 for (
const TensorType::Element &element : elementList)
57 usedKeyClusters.insert(element.GetClusterU());
61 changesMade = (changesMade ? changesMade : changesMadeInIteration);
71 ClusterSet modifiedClusters, checkedClusters;
73 for (
const TensorType::Element &element : elementList)
75 for (
const HitType hitType : {TPC_VIEW_U, TPC_VIEW_V, TPC_VIEW_W})
77 const Cluster *pDeltaRayCluster(element.GetCluster(hitType));
78 const ParticleFlowObject *
const pMuonPfo(element.GetOverlapResult().GetCommonMuonPfoList().front());
80 if (checkedClusters.count(pDeltaRayCluster))
84 if ((modifiedClusters.count(element.GetClusterU())) || (modifiedClusters.count(element.GetClusterV())) ||
85 (modifiedClusters.count(element.GetClusterW())))
94 if (!this->
IsBestElement(element, hitType, elementList, modifiedClusters))
97 checkedClusters.insert(pDeltaRayCluster);
99 CaloHitList deltaRayHits;
104 modifiedClusters.insert(pDeltaRayCluster);
110 return !modifiedClusters.empty();
128 const Cluster *pMuonCluster(
nullptr), *
const pDeltaRayCluster(element.GetCluster(hitType));
136 CartesianVector muonDirection(0.
f, 0.
f, 0.
f);
139 const CartesianVector xAxis(1.
f, 0.
f, 0.
f);
146 CartesianVector deltaRayVertex(0.
f, 0.
f, 0.
f), muonVertex(0.
f, 0.
f, 0.
f);
149 CaloHitList minusMuonHits, minusDeltaRayHits, plusMuonHits, plusDeltaRayHits;
151 const CartesianVector plusPosition(muonVertex + (muonDirection * m_contaminationWindow));
180 const Cluster *pDeltaRayCluster(element.GetCluster(hitType)), *pMuonCluster(
nullptr);
183 throw StatusCodeException(STATUS_CODE_FAILURE);
192 clusterVector.push_back(pMuonCluster);
193 pfoVector.push_back(element.GetOverlapResult().GetCommonMuonPfoList().front());
194 clusterVector.push_back(pDeltaRayCluster);
195 pfoVector.push_back(
nullptr);
203 PANDORA_RETURN_RESULT_IF_AND_IF(
204 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"SlidingFitWindow",
m_slidingFitWindow));
206 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
209 PANDORA_RETURN_RESULT_IF_AND_IF(
210 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"ContaminationWindow",
m_contaminationWindow));
212 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
215 PANDORA_RETURN_RESULT_IF_AND_IF(
216 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinDistanceFromMuon",
m_minDistanceFromMuon));
218 PANDORA_RETURN_RESULT_IF_AND_IF(
219 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxDistanceToCollected",
m_maxDistanceToCollected));
221 return STATUS_CODE_SUCCESS;
unsigned int m_slidingFitWindow
The sliding fit window used in cosmic ray parameterisations.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
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...
float m_contaminationWindow
The distance in which to search for delta ray contamination in the cosmic ray track.
void GetConnectedElements(const pandora::Cluster *const pCluster, const bool ignoreUnavailable, ElementList &elementList) const
Get a list of elements connected to a specified cluster.
bool IsContaminated(const TensorType::Element &element, const pandora::HitType hitType) const
Determine whether the cosmic ray cluster under investigation has delta ray contamination.
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.
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.
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
void UpdateUponDeletion(const pandora::Cluster *const pDeletedCluster)
Update to reflect cluster deletion.
float m_minDistanceFromMuon
The minimum distance of a hit from the cosmic ray track required for removal.
bool Run(ThreeViewDeltaRayMatchingAlgorithm *const pAlgorithm, TensorType &overlapTensor)
Run the algorithm tool.
Header file for the geometry helper class.
std::vector< Element > ElementList
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_minDeviationFromTransverse
The minimum deviation from transverse required to avoid mistakes.
Header file for the cluster helper class.
float m_maxDistanceToCollected
The maximim distance of a hit from the projected delta ray hits required for removal.
virtual bool PassElementChecks(const TensorType::Element &element, const pandora::HitType hitType) const =0
Determine whether element satifies simple checks.
Header file for the lar two dimensional sliding fit result class.
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.
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.
ThreeViewDeltaRayMatchingAlgorithm class.
void GetSortedKeyClusters(pandora::ClusterVector &sortedKeyClusters) const
Get a sorted vector of key clusters (U clusters with current implementation)
void GetGlobalDirection(const float dTdL, pandora::CartesianVector &direction) const
Get global direction coordinates for given sliding linear fit gradient.
const LayerFitResultMap & GetLayerFitResultMap() const
Get the layer fit result map.
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.
const std::string & GetClusterListName(const pandora::HitType hitType) const
Get the cluster list name corresponding to a specified hit type.
unsigned int m_significantHitThreshold
The threshold number of hits which define significant contimination.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
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...
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...
TwoDSlidingFitResult class.
QTextStream & endl(QTextStream &s)
bool RemoveDeltaRayHits(const TensorType::ElementList &elementList) const
Remove hits from cosmic ray clusters that belong to a child delta ray.