9 #include "Pandora/AlgorithmHeaders.h" 19 ShowerAsymmetryFeatureTool::ShowerAsymmetryFeatureTool() :
20 m_vertexClusterDistance(4.
f)
30 if (PandoraContentApi::GetSettings(*pAlgorithm)->ShouldDisplayAlgorithmInfo())
31 std::cout <<
"----> Running Algorithm Tool: " << this->GetInstanceName() <<
", " << this->GetType() << std::endl;
33 float showerAsymmetry(0.
f);
36 showerClusterListMap.at(TPC_VIEW_U));
39 showerClusterListMap.at(TPC_VIEW_V));
42 showerClusterListMap.at(TPC_VIEW_W));
44 featureVector.push_back(showerAsymmetry);
52 float showerAsymmetry(1.
f);
60 float rL(0.
f), rT(0.
f);
63 CartesianVector showerDirection(0.
f, 0.
f, 0.
f);
66 const float projectedVtxPosition = vertexPosition2D.GetDotProduct(showerDirection);
68 float beforeVtxEnergy(0.
f), afterVtxEnergy(0.
f);
71 if (beforeVtxEnergy + afterVtxEnergy > 0.
f)
72 showerAsymmetry = std::fabs(afterVtxEnergy - beforeVtxEnergy) / (afterVtxEnergy + beforeVtxEnergy);
78 return showerAsymmetry;
86 for (
const Cluster *
const pCluster : showerCluster.
GetClusters())
98 const float projectedVtxPosition,
const CartesianVector &showerDirection,
float &beforeVtxEnergy,
float &afterVtxEnergy)
const 100 beforeVtxEnergy = 0.f;
101 afterVtxEnergy = 0.f;
103 for (
const Cluster *
const pCluster : showerCluster.
GetClusters())
105 CaloHitList caloHitList;
106 pCluster->GetOrderedCaloHitList().FillCaloHitList(caloHitList);
108 CaloHitVector caloHitVector(caloHitList.begin(), caloHitList.end());
111 for (
const CaloHit *
const pCaloHit : caloHitVector)
113 if (pCaloHit->GetPositionVector().GetDotProduct(showerDirection) < projectedVtxPosition)
114 beforeVtxEnergy += pCaloHit->GetElectromagneticEnergy();
116 else if (pCaloHit->GetPositionVector().GetDotProduct(showerDirection) > projectedVtxPosition)
117 afterVtxEnergy += pCaloHit->GetElectromagneticEnergy();
127 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
130 return STATUS_CODE_SUCCESS;
MvaTypes::MvaFeatureVector MvaFeatureVector
std::vector< ShowerCluster > ShowerClusterList
static pandora::CartesianVector ProjectPosition(const pandora::Pandora &pandora, const pandora::CartesianVector &position3D, const pandora::HitType view)
Project 3D position into a given 2D view.
void Run(LArMvaHelper::MvaFeatureVector &featureVector, const VertexSelectionBaseAlgorithm *const pAlgorithm, const pandora::Vertex *const pVertex, const VertexSelectionBaseAlgorithm::SlidingFitDataListMap &, const VertexSelectionBaseAlgorithm::ClusterListMap &, const VertexSelectionBaseAlgorithm::KDTreeMap &, const VertexSelectionBaseAlgorithm::ShowerClusterListMap &showerClusterListMap, const float, float &)
Run the tool.
const pandora::ClusterList & GetClusters() const
Get the cluster list.
void CalculateAsymmetryParameters(const VertexSelectionBaseAlgorithm::ShowerCluster &showerCluster, const float projectedVtxPosition, const pandora::CartesianVector &showerDirection, float &beforeVtxEnergy, float &afterVtxEnergy) const
Calculate the parameters for the asymmetry calculation.
Header file for the geometry helper class.
std::map< pandora::HitType, const ShowerClusterList > ShowerClusterListMap
Map of shower cluster lists for passing to tools.
float m_vertexClusterDistance
The distance around the vertex to look for shower clusters.
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)
float GetShowerAsymmetryForView(const pandora::CartesianVector &vertexPosition2D, const VertexSelectionBaseAlgorithm::ShowerClusterList &showerClusterList) const
Get the shower asymmetry feature for a given view.
Header file for the cluster helper class.
std::map< pandora::HitType, const pandora::ClusterList & > ClusterListMap
Map array of cluster lists for passing to tools.
VertexSelectionBaseAlgorithm class.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
pandora::StatusCode GetGlobalFitDirection(const float rL, pandora::CartesianVector &direction) const
Get global fit direction for a given longitudinal coordinate.
std::map< pandora::HitType, const SlidingFitDataList > SlidingFitDataListMap
Map of sliding fit data lists for passing to tools.
std::map< pandora::HitType, const std::reference_wrapper< HitKDTree2D > > KDTreeMap
Map array of hit kd trees for passing to tools.
bool ShouldUseShowerCluster(const pandora::CartesianVector &vertexPosition, const VertexSelectionBaseAlgorithm::ShowerCluster &showerCluster) const
Get whether we should use a given shower cluster for asymmetry calculation.
void GetLocalPosition(const pandora::CartesianVector &position, float &rL, float &rT) const
Get local sliding fit coordinates for a given global position.
TwoDSlidingFitResult class.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.