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 EventContext &ctx) const override

Private Member Functions

void correctNeutralFlowElement (xAOD::FlowElement &pfo, const SG::ReadDecorHandle< xAOD::CaloClusterContainer, double > &clusterMLReadHandle) const
const xAOD::CaloClustergetLinkedCluster (const xAOD::FlowElement &pfo) const

Private Attributes

SG::ReadDecorHandleKey< xAOD::CaloClusterContainerm_clusterMLCorrectedEnergyKey
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 29 of file NeutralPFOClusterMLCorrectionTool.h.

Constructor & Destructor Documentation

◆ NeutralPFOClusterMLCorrectionTool()

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

Definition at line 11 of file NeutralPFOClusterMLCorrectionTool.cxx.

12 : 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 EventContext & ctx ) const
overridevirtual

Definition at line 22 of file NeutralPFOClusterMLCorrectionTool.cxx.

23{
24
25 SG::ReadDecorHandle<xAOD::CaloClusterContainer, double> clusterMLReadHandle(m_clusterMLCorrectedEnergyKey, ctx);
26 if (!clusterMLReadHandle.isValid()) {
27 throw std::runtime_error("Invalid decoration handle: " +
29 }
30
31 for (xAOD::FlowElement *neutral_pfo : neutral_pfos)
32 { correctNeutralFlowElement(*neutral_pfo, clusterMLReadHandle); }
33}
SG::ReadDecorHandleKey< xAOD::CaloClusterContainer > m_clusterMLCorrectedEnergyKey
void correctNeutralFlowElement(xAOD::FlowElement &pfo, const SG::ReadDecorHandle< xAOD::CaloClusterContainer, double > &clusterMLReadHandle) const
FlowElement_v1 FlowElement
Definition of the current "pfo version".
Definition FlowElement.h:16

◆ correctNeutralFlowElement()

void NeutralPFOClusterMLCorrectionTool::correctNeutralFlowElement ( xAOD::FlowElement & pfo,
const SG::ReadDecorHandle< xAOD::CaloClusterContainer, double > & clusterMLReadHandle ) const
private

Definition at line 36 of file NeutralPFOClusterMLCorrectionTool.cxx.

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

◆ getLinkedCluster()

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

Definition at line 62 of file NeutralPFOClusterMLCorrectionTool.cxx.

63{
64 // Returns xAOD::Type::CaloCluster type link. There should be at most one such link.
65 // It can happen that no such link exists. This can happen due to negative cells subtraction.
66 // Empty link is returned if no valid cluster link is found.
67 const std::vector<ElementLink<xAOD::IParticleContainer>> &otherObjectLinks = neutral_pfo.otherObjectLinks();
68 if (otherObjectLinks.size() > 1)
69 throw std::runtime_error("NeutralPFOClusterMLCorrectionTool: Multiple links found for neutral FlowElement with index " + std::to_string(neutral_pfo.index()));
70
71 bool hasValidLink = !otherObjectLinks.empty() && otherObjectLinks[0].isValid();
72 if (!hasValidLink)
73 { return nullptr; }
74
75 if ((**otherObjectLinks[0]).type() != xAOD::Type::CaloCluster)
76 throw std::runtime_error("NeutralPFOClusterMLCorrectionTool: Link for neutral FlowElement with index " + std::to_string(neutral_pfo.index()) + " is not of type CaloCluster");
77
78 return static_cast<const xAOD::CaloCluster *>(*otherObjectLinks[0]);
79}
@ CaloCluster
The object is a calorimeter cluster.
Definition ObjectType.h:39

◆ initialize()

StatusCode NeutralPFOClusterMLCorrectionTool::initialize ( )
overridevirtual

Definition at line 14 of file NeutralPFOClusterMLCorrectionTool.cxx.

14 {
16 ATH_MSG_DEBUG("Initializing with ClusterMLCorrectedEnergyDecorationKey: " << m_clusterMLCorrectedEnergyKey.key());
17 ATH_MSG_DEBUG("Initializing with MaxAllowedChargedCorrectionFraction: " << m_max_allowed_charged_correction_fraction.value());
18 ATH_MSG_DEBUG("Initializing with MinAllowedEMEnergyMeV: " << m_min_allowed_em_energy.value());
19 return StatusCode::SUCCESS;
20}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)

Member Data Documentation

◆ m_clusterMLCorrectedEnergyKey

SG::ReadDecorHandleKey<xAOD::CaloClusterContainer> NeutralPFOClusterMLCorrectionTool::m_clusterMLCorrectedEnergyKey
private
Initial value:
{
this,
"ClusterMLCorrectedEnergyDecorationKey",
"CaloCalTopoClusters.clusterE_ML",
"Decoration storing ML-corrected cluster energy"
}

Definition at line 40 of file NeutralPFOClusterMLCorrectionTool.h.

40 {
41 this,
42 "ClusterMLCorrectedEnergyDecorationKey",
43 "CaloCalTopoClusters.clusterE_ML",
44 "Decoration storing ML-corrected cluster energy"
45 };

◆ 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 47 of file NeutralPFOClusterMLCorrectionTool.h.

47{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 48 of file NeutralPFOClusterMLCorrectionTool.h.

48{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: