ATLAS Offline Software
Loading...
Searching...
No Matches
NeutralPFOClusterMLCorrectionTool Class Referencefinal

Applies ML corrections to PFO ML corrections are stored in linked CaloClusters as decorations. More...

#include <NeutralPFOClusterMLCorrectionTool.h>

Inheritance diagram for NeutralPFOClusterMLCorrectionTool:
Collaboration diagram for NeutralPFOClusterMLCorrectionTool:

Public Member Functions

 NeutralPFOClusterMLCorrectionTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~NeutralPFOClusterMLCorrectionTool ()=default
virtual StatusCode initialize () override
virtual void correctContainer (xAOD::FlowElementContainer &neutral_pfos, xAOD::FlowElementContainer &charged_pfos) const override

Private Member Functions

void correctNeutralFlowElement (xAOD::FlowElement &pfo) const
double getClusterMLCorrectedEnergy (const xAOD::CaloCluster &cls) const
const xAOD::CaloClustergetLinkedCluster (const xAOD::FlowElement &pfo) const

Private Attributes

Gaudi::Property< std::string > m_clusterMLCorrectedEnergyKey {this, "ClusterMLCorrectedEnergyDecorationKey", "clusterE_ML", "Name of the decoration storing the ML-corrected cluster energy"}
Gaudi::Property< float > m_max_allowed_charged_correction_fraction {this, "MaxAllowedChargedCorrectionFraction", 0.001, "ClusterML correction will be applied only if |npfo_E - cls_EM_E| <= |MaxAllowedChargedCorrectionFraction * cls_EM_E|"}
Gaudi::Property< float > m_min_allowed_em_energy {this,"MinAllowedEMEnergyMeV", 300, "Minimum allowed energy in MeV of matched cluster at EM scale. ClusterML correction will not be applied below this limit."}

Detailed Description

Applies ML corrections to PFO ML corrections are stored in linked CaloClusters as decorations.

The correction is applied as a scale factor to the PFO.

Definition at line 26 of file NeutralPFOClusterMLCorrectionTool.h.

Constructor & Destructor Documentation

◆ NeutralPFOClusterMLCorrectionTool()

NeutralPFOClusterMLCorrectionTool::NeutralPFOClusterMLCorrectionTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 7 of file NeutralPFOClusterMLCorrectionTool.cxx.

8 : base_class(type, name, parent) {}

◆ ~NeutralPFOClusterMLCorrectionTool()

virtual NeutralPFOClusterMLCorrectionTool::~NeutralPFOClusterMLCorrectionTool ( )
virtualdefault

Member Function Documentation

◆ correctContainer()

void NeutralPFOClusterMLCorrectionTool::correctContainer ( xAOD::FlowElementContainer & neutral_pfos,
xAOD::FlowElementContainer & charged_pfos ) const
overridevirtual

Definition at line 17 of file NeutralPFOClusterMLCorrectionTool.cxx.

18{
19 for (xAOD::FlowElement *neutral_pfo : neutral_pfos)
20 { correctNeutralFlowElement(*neutral_pfo); }
21}
void correctNeutralFlowElement(xAOD::FlowElement &pfo) const
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16

◆ correctNeutralFlowElement()

void NeutralPFOClusterMLCorrectionTool::correctNeutralFlowElement ( xAOD::FlowElement & pfo) const
private

Definition at line 24 of file NeutralPFOClusterMLCorrectionTool.cxx.

25{
26 // The correction is applied only if link to cluster exists.
27 // If no link exists, it can be due to negative cell subtraction. In this case, no correction is applied.
28 // The corrected neutral pfo energy is calculated from ML-corrected cluster energy
29 if (neutral_pfo.isCharged())
30 {
31 throw std::runtime_error("Charged FlowElement found in neutral FlowElementContainer with index " + std::to_string(neutral_pfo.index()));
32 }
33 const xAOD::CaloCluster *cls = getLinkedCluster(neutral_pfo);
34 if (cls == nullptr)
35 { return; }
36
37 const double cluster_EM_energy = cls->rawE();
38
39 bool apply_ML_correction = (std::abs(neutral_pfo.e() - cluster_EM_energy) <= std::abs(m_max_allowed_charged_correction_fraction.value() * cluster_EM_energy));
40 apply_ML_correction = (cluster_EM_energy > m_min_allowed_em_energy.value());
41 if (apply_ML_correction)
42 {
43 const double cluster_ML_energy = getClusterMLCorrectedEnergy(*cls);
44 neutral_pfo.setP4(cluster_ML_energy / cosh(neutral_pfo.eta()), neutral_pfo.eta(), neutral_pfo.phi(), neutral_pfo.m());
45 }
46
47}
const xAOD::CaloCluster * getLinkedCluster(const xAOD::FlowElement &pfo) const
double getClusterMLCorrectedEnergy(const xAOD::CaloCluster &cls) const
Gaudi::Property< float > m_max_allowed_charged_correction_fraction
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.

◆ getClusterMLCorrectedEnergy()

double NeutralPFOClusterMLCorrectionTool::getClusterMLCorrectedEnergy ( const xAOD::CaloCluster & cls) const
private

Definition at line 69 of file NeutralPFOClusterMLCorrectionTool.cxx.

70{
71 const SG::Accessor<double> clusterMLCorrectedEnergyAccessor(m_clusterMLCorrectedEnergyKey.value());
72 if (!clusterMLCorrectedEnergyAccessor.isAvailable(cls))
73 {
74 throw std::runtime_error("No ML energy decoration '" + m_clusterMLCorrectedEnergyKey.value()
75 + "' found for cluster with index " + std::to_string(cls.index())
76 + ". Returning EM energy.");
77 }
78 return clusterMLCorrectedEnergyAccessor(cls);
79}
Gaudi::Property< std::string > m_clusterMLCorrectedEnergyKey
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:573

◆ getLinkedCluster()

const xAOD::CaloCluster * NeutralPFOClusterMLCorrectionTool::getLinkedCluster ( const xAOD::FlowElement & pfo) const
private

Definition at line 50 of file NeutralPFOClusterMLCorrectionTool.cxx.

51{
52 // Returns xAOD::Type::CaloCluster type link. There should be at most one such link.
53 // It can happen that no such link exists. This can happen due to negative cells subtraction.
54 // Empty link is returned if no valid cluster link is found.
55 const std::vector<ElementLink<xAOD::IParticleContainer>> &otherObjectLinks = neutral_pfo.otherObjectLinks();
56 if (otherObjectLinks.size() > 1)
57 throw std::runtime_error("NeutralPFOClusterMLCorrectionTool: Multiple links found for neutral FlowElement with index " + std::to_string(neutral_pfo.index()));
58
59 bool hasValidLink = !otherObjectLinks.empty() && otherObjectLinks[0].isValid();
60 if (!hasValidLink)
61 { return nullptr; }
62
63 if ((**otherObjectLinks[0]).type() != xAOD::Type::CaloCluster)
64 throw std::runtime_error("NeutralPFOClusterMLCorrectionTool: Link for neutral FlowElement with index " + std::to_string(neutral_pfo.index()) + " is not of type CaloCluster");
65
66 return static_cast<const xAOD::CaloCluster *>(*otherObjectLinks[0]);
67}
@ CaloCluster
The object is a calorimeter cluster.
Definition ObjectType.h:39

◆ initialize()

StatusCode NeutralPFOClusterMLCorrectionTool::initialize ( )
overridevirtual

Definition at line 10 of file NeutralPFOClusterMLCorrectionTool.cxx.

10 {
11 ATH_MSG_DEBUG("Initializing with ClusterMLCorrectedEnergyDecorationKey: " << m_clusterMLCorrectedEnergyKey.value());
12 ATH_MSG_DEBUG("Initializing with MaxAllowedChargedCorrectionFraction: " << m_max_allowed_charged_correction_fraction.value());
13 ATH_MSG_DEBUG("Initializing with MinAllowedEMEnergyMeV: " << m_min_allowed_em_energy.value());
14 return StatusCode::SUCCESS;
15}
#define ATH_MSG_DEBUG(x)

Member Data Documentation

◆ m_clusterMLCorrectedEnergyKey

Gaudi::Property<std::string> NeutralPFOClusterMLCorrectionTool::m_clusterMLCorrectedEnergyKey {this, "ClusterMLCorrectedEnergyDecorationKey", "clusterE_ML", "Name of the decoration storing the ML-corrected cluster energy"}
private

Definition at line 37 of file NeutralPFOClusterMLCorrectionTool.h.

37{this, "ClusterMLCorrectedEnergyDecorationKey", "clusterE_ML", "Name of the decoration storing the ML-corrected cluster energy"};

◆ m_max_allowed_charged_correction_fraction

Gaudi::Property<float> NeutralPFOClusterMLCorrectionTool::m_max_allowed_charged_correction_fraction {this, "MaxAllowedChargedCorrectionFraction", 0.001, "ClusterML correction will be applied only if |npfo_E - cls_EM_E| <= |MaxAllowedChargedCorrectionFraction * cls_EM_E|"}
private

Definition at line 38 of file NeutralPFOClusterMLCorrectionTool.h.

38{this, "MaxAllowedChargedCorrectionFraction", 0.001, "ClusterML correction will be applied only if |npfo_E - cls_EM_E| <= |MaxAllowedChargedCorrectionFraction * cls_EM_E|"};

◆ m_min_allowed_em_energy

Gaudi::Property<float> NeutralPFOClusterMLCorrectionTool::m_min_allowed_em_energy {this,"MinAllowedEMEnergyMeV", 300, "Minimum allowed energy in MeV of matched cluster at EM scale. ClusterML correction will not be applied below this limit."}
private

Definition at line 39 of file NeutralPFOClusterMLCorrectionTool.h.

39{this,"MinAllowedEMEnergyMeV", 300, "Minimum allowed energy in MeV of matched cluster at EM scale. ClusterML correction will not be applied below this limit."};

The documentation for this class was generated from the following files: