10 #include "Pandora/AlgorithmHeaders.h"
26 const ClusterVector &clusterVector,
const CartesianVector &localWeightedDirectionSum)
const
29 float beforeVtxEnergy(0.f), afterVtxEnergy(0.f);
30 unsigned int beforeVtxHits(0), afterVtxHits(0);
32 const CartesianVector localWeightedDirection(localWeightedDirectionSum.GetUnitVector());
33 const float evtProjectedVtxPos(vertexPosition2D.GetDotProduct(localWeightedDirection));
35 float minBeforeProjectedPos(std::numeric_limits<float>::max());
36 float maxBeforeProjectedPos(-std::numeric_limits<float>::max());
38 float minAfterProjectedPos(std::numeric_limits<float>::max());
39 float maxAfterProjectedPos(-std::numeric_limits<float>::max());
41 for (
const Cluster *
const pCluster : clusterVector)
43 CaloHitList caloHitList;
44 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
46 CaloHitVector caloHitVector(caloHitList.begin(), caloHitList.end());
49 for (
const CaloHit *
const pCaloHit : caloHitVector)
51 if (pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection) < evtProjectedVtxPos)
53 minBeforeProjectedPos = std::min(minBeforeProjectedPos, pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection));
54 maxBeforeProjectedPos = std::max(maxBeforeProjectedPos, pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection));
56 beforeVtxEnergy += pCaloHit->GetElectromagneticEnergy();
62 minAfterProjectedPos = std::min(minAfterProjectedPos, pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection));
63 maxAfterProjectedPos = std::max(maxAfterProjectedPos, pCaloHit->GetPositionVector().GetDotProduct(localWeightedDirection));
65 afterVtxEnergy += pCaloHit->GetElectromagneticEnergy();
72 const unsigned int totalHits(beforeVtxHits + afterVtxHits);
74 const float beforeLength(std::fabs(maxBeforeProjectedPos - minBeforeProjectedPos));
75 const float afterLength(std::fabs(maxAfterProjectedPos - minAfterProjectedPos));
77 const float beforeVtxEnergyDeposition(beforeLength < std::numeric_limits<float>::epsilon() ? 0 : beforeVtxEnergy / beforeLength);
79 const float afterVtxEnergyDeposition(afterLength < std::numeric_limits<float>::epsilon() ? 0 : afterVtxEnergy / afterLength);
81 const float totalEnergyDeposition(beforeVtxEnergyDeposition + afterVtxEnergyDeposition);
83 if (useEnergyMetrics && totalEnergyDeposition > std::numeric_limits<float>::epsilon())
84 return std::fabs((afterVtxEnergyDeposition - beforeVtxEnergyDeposition)) / totalEnergyDeposition;
87 throw StatusCodeException(STATUS_CODE_FAILURE);
89 const float beforeVtxHitDeposition(beforeLength < std::numeric_limits<float>::epsilon() ? 0 : beforeVtxHits / beforeLength);
91 const float afterVtxHitDeposition(afterLength < std::numeric_limits<float>::epsilon() ? 0 : afterVtxHits / afterLength);
93 const float totalHitDeposition(beforeVtxHitDeposition + afterVtxHitDeposition);
95 if (totalHitDeposition > std::numeric_limits<float>::epsilon())
96 return std::fabs((afterVtxHitDeposition - beforeVtxHitDeposition)) / totalHitDeposition;
float CalculateAsymmetry(const bool useEnergyMetrics, const pandora::CartesianVector &vertexPosition2D, const pandora::ClusterVector &clusterVector, const pandora::CartesianVector &localWeightedDirectionSum) const override
Calculate the energy deposition asymmetry feature.
Header file for the geometry helper class.
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
Header file for the cluster helper class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle) override
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle) override
required by fuzzyCluster table::sbnd_g4_services gaushitTruthMatch pandora
GlobalAsymmetryFeatureTool class.
std::vector< art::Ptr< recob::Cluster > > ClusterVector