9 #include "Pandora/AlgorithmHeaders.h"
20 LocalAsymmetryFeatureTool::LocalAsymmetryFeatureTool() :
22 m_minAsymmetryCosAngle(0.9962),
23 m_maxAsymmetryNClusters(2)
32 bool useEnergy(
true), useAsymmetry(
true);
33 CartesianVector energyWeightedDirectionSum(0.f, 0.f, 0.f), hitWeightedDirectionSum(0.f, 0.f, 0.f);
38 const Cluster *
const pCluster(slidingFitData.GetCluster());
40 if (pCluster->GetElectromagneticEnergy() < std::numeric_limits<float>::epsilon())
43 const CartesianVector vertexToMinLayer(slidingFitData.GetMinLayerPosition() - vertexPosition2D);
44 const CartesianVector vertexToMaxLayer(slidingFitData.GetMaxLayerPosition() - vertexPosition2D);
46 const bool minLayerClosest(vertexToMinLayer.GetMagnitudeSquared() < vertexToMaxLayer.GetMagnitudeSquared());
47 const CartesianVector &clusterDirection((minLayerClosest) ? slidingFitData.GetMinLayerDirection() : slidingFitData.GetMaxLayerDirection());
51 useAsymmetry &= this->
CheckAngle(energyWeightedDirectionSum, clusterDirection);
54 useAsymmetry &= this->
CheckAngle(hitWeightedDirectionSum, clusterDirection);
57 asymmetryClusters.push_back(pCluster);
65 if ((useEnergy && energyWeightedDirectionSum == CartesianVector(0.f, 0.f, 0.f)) ||
66 (!useEnergy && hitWeightedDirectionSum == CartesianVector(0.f, 0.f, 0.f)))
72 const CartesianVector &localWeightedDirectionSum(useEnergy ? energyWeightedDirectionSum : hitWeightedDirectionSum);
73 return this->
CalculateAsymmetry(useEnergy, vertexPosition2D, asymmetryClusters, localWeightedDirectionSum);
80 if (!(weightedDirectionSum.GetMagnitudeSquared() > std::numeric_limits<float>::epsilon()))
83 const float cosOpeningAngle(weightedDirectionSum.GetCosOpeningAngle(clusterDirection));
91 PANDORA_RETURN_RESULT_IF_AND_IF(
92 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MinAsymmetryCosAngle",
m_minAsymmetryCosAngle));
94 PANDORA_RETURN_RESULT_IF_AND_IF(
95 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
"MaxAsymmetryNClusters",
m_maxAsymmetryNClusters));
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle) override
virtual float CalculateAsymmetry(const bool useEnergyMetrics, const pandora::CartesianVector &vertexPosition2D, const pandora::ClusterVector &asymmetryClusters, const pandora::CartesianVector &localWeightedDirectionSum) const
Calculate the asymmetry feature.
std::vector< ShowerCluster > ShowerClusterList
bool CheckAngle(const pandora::CartesianVector &weightedDirectionSum, const pandora::CartesianVector &clusterDirection) const
Check whether a cluster's direction agrees with the current weighted direction.
float m_maxAsymmetryDistance
The max distance between cluster (any hit) and vertex to calculate asymmetry score.
std::vector< SlidingFitData > SlidingFitDataList
Header file for the cluster helper class.
float GetAsymmetryForView(const pandora::CartesianVector &vertexPosition2D, const VertexSelectionBaseAlgorithm::SlidingFitDataList &slidingFitDataList, const VertexSelectionBaseAlgorithm::ShowerClusterList &) const override
Get the local asymmetry feature in a given view.
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
AsymmetryFeatureBaseTool class.
void IncrementAsymmetryParameters(const float weight, const pandora::CartesianVector &clusterDirection, pandora::CartesianVector &localWeightedDirectionSum) const
Increment the asymmetry parameters.
float m_minAsymmetryCosAngle
The min opening angle cosine used to determine viability of asymmetry score.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
unsigned int m_maxAsymmetryNClusters
The max number of associated clusters to calculate the asymmetry.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.