ATLAS Offline Software
Loading...
Searching...
No Matches
egammaTransformerSvc Class Reference

#include <egammaTransformerSvc.h>

Inheritance diagram for egammaTransformerSvc:
Collaboration diagram for egammaTransformerSvc:

Public Member Functions

virtual ~egammaTransformerSvc () override
virtual StatusCode initialize () override
StatusCode getEnergy (const xAOD::CaloCluster &cluster, const xAOD::Egamma &eg, double &mvaE, const egammaMVACalib::GlobalEventInfo &gei=egammaMVACalib::GlobalEventInfo()) const override final
 Compute the calibrated energy.
StatusCode getEnergy (const xAOD::CaloCluster &cluster, const xAOD::EgammaParameters::EgammaType egType, double &mvaE, const egammaMVACalib::GlobalEventInfo &gei=egammaMVACalib::GlobalEventInfo()) const override final
 Compute the calibrated energy when the full egamma object is not available.
StatusCode execute (xAOD::CaloCluster &cluster, const xAOD::Egamma &eg, const egammaMVACalib::GlobalEventInfo &gei=egammaMVACalib::GlobalEventInfo()) const override final
 Main execute.
StatusCode execute (xAOD::CaloCluster &cluster, const xAOD::EgammaParameters::EgammaType egType, const egammaMVACalib::GlobalEventInfo &gei=egammaMVACalib::GlobalEventInfo()) const override final
 Calibrate the cluster, when the full egamma object is not available.

Private Member Functions

bool isConvCalib (const xAOD::Photon &ph) const
 Decide if the photon is converted or not.
StatusCode resolve_flags ()

Private Attributes

ToolHandle< IegammaMVACalibToolm_mvaElectron
 MVA tool for electron.
ToolHandle< IegammaMVACalibToolm_mvaFwdElectron
 MVA tool for forward electron.
ToolHandle< IegammaMVACalibToolm_mvaUnconvertedPhoton
 MVA tool for unconverted photon.
ToolHandle< IegammaMVACalibToolm_mvaConvertedPhoton
 MVA tool for converted photon.
Gaudi::Property< float > m_maxConvR
Gaudi::Property< int > m_removeTRTConvBarrel
Gaudi::Property< std::string > m_folder

Detailed Description

Definition at line 21 of file egammaTransformerSvc.h.

Constructor & Destructor Documentation

◆ ~egammaTransformerSvc()

virtual egammaTransformerSvc::~egammaTransformerSvc ( )
inlineoverridevirtual

Definition at line 26 of file egammaTransformerSvc.h.

26{};

Member Function Documentation

◆ execute() [1/2]

StatusCode egammaTransformerSvc::execute ( xAOD::CaloCluster & cluster,
const xAOD::Egamma & eg,
const egammaMVACalib::GlobalEventInfo & gei = egammaMVACalib::GlobalEventInfo() ) const
finaloverride

Main execute.

We need to calibrate the cluster. Use full egamma object instead of Type As we employ further variables than the ones present in the cluster This method needs to be valid also for reconstruction

Definition at line 196 of file egammaTransformerSvc.cxx.

199{
200 double mvaE = 0.;
201
202 ATH_CHECK(getEnergy(cluster, eg, mvaE, gei));
203
204 if (mvaE > eg.m()) {
205 cluster.setCalE(mvaE);
206 }
207 else {
208 ATH_MSG_DEBUG("MVA energy (" << mvaE << ") < particle mass ("
209 << eg.m() << "), setting e = cluster energy (" << cluster.e() << ")");
210 cluster.setCalE(cluster.e());
211 }
212 return StatusCode::SUCCESS;
213}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
StatusCode getEnergy(const xAOD::CaloCluster &cluster, const xAOD::Egamma &eg, double &mvaE, const egammaMVACalib::GlobalEventInfo &gei=egammaMVACalib::GlobalEventInfo()) const override final
Compute the calibrated energy.
virtual double e() const
The total energy of the particle.
void setCalE(flt_t)
Set Energy for signal state CALIBRATED.
virtual double m() const =0
The invariant mass of the particle.

◆ execute() [2/2]

StatusCode egammaTransformerSvc::execute ( xAOD::CaloCluster & cluster,
const xAOD::EgammaParameters::EgammaType egType,
const egammaMVACalib::GlobalEventInfo & gei = egammaMVACalib::GlobalEventInfo() ) const
finaloverride

Calibrate the cluster, when the full egamma object is not available.

Only variables related to the cluster are used (e.g. no conversion are used here) If the full egamma object use the other version.

Definition at line 215 of file egammaTransformerSvc.cxx.

218{
219
220 double mvaE = 0.;
221
222 ATH_CHECK(getEnergy(cluster, egType, mvaE, gei));
223
224 if (mvaE > 0) {
225 cluster.setCalE(mvaE);
226 }
227 else {
228 ATH_MSG_DEBUG("MVA energy (" << mvaE << ") < 0, setting e = cluster energy ("
229 << cluster.e() << ")");
230 cluster.setCalE(cluster.e());
231 }
232 return StatusCode::SUCCESS;
233}

◆ getEnergy() [1/2]

StatusCode egammaTransformerSvc::getEnergy ( const xAOD::CaloCluster & cluster,
const xAOD::Egamma & eg,
double & mvaE,
const egammaMVACalib::GlobalEventInfo & gei = egammaMVACalib::GlobalEventInfo() ) const
finaloverride

Compute the calibrated energy.

Definition at line 99 of file egammaTransformerSvc.cxx.

103{
104
105 ATH_MSG_DEBUG("calling egammaTransformerSvc::getEnergy with cluster and eg");
106
107 mvaE = 0.;
108
110 if (!m_mvaElectron.empty()) {
111 mvaE = m_mvaElectron->getEnergy(cluster, &eg, gei);
112 } else {
113 ATH_MSG_FATAL("Trying to calibrate an electron, but disabled");
114 return StatusCode::FAILURE;
115 }
116 } else if (xAOD::EgammaHelpers::isFwdElectron(&eg)) {
117 if (!m_mvaFwdElectron.empty()) {
118 mvaE = m_mvaFwdElectron->getEnergy(cluster, &eg, gei);
119 } else {
120 ATH_MSG_FATAL("Trying to calibrate a forward electron, but disabled");
121 return StatusCode::FAILURE;
122 }
123 } else if (xAOD::EgammaHelpers::isPhoton(&eg)) {
124 const xAOD::Photon* ph = static_cast<const xAOD::Photon*>(&eg);
125 const bool is_conv_calib = isConvCalib(*ph);
126 if (is_conv_calib) {
127 if (!m_mvaConvertedPhoton.empty()) {
128 mvaE = m_mvaConvertedPhoton->getEnergy(cluster, &eg, gei);
129 } else {
130 ATH_MSG_FATAL("Trying to calibrate a converted photon, but disabled");
131 return StatusCode::FAILURE;
132 }
133 } else {
134 if (!m_mvaUnconvertedPhoton.empty()) {
135 mvaE = m_mvaUnconvertedPhoton->getEnergy(cluster, &eg, gei);
136 } else {
137 ATH_MSG_FATAL("Trying to calibrate an unconverted photon, but disabled");
138 return StatusCode::FAILURE;
139 }
140 }
141 } else {
142 ATH_MSG_FATAL("Egamma object is of unsupported type");
143 return StatusCode::FAILURE;
144 }
145
146 ATH_MSG_DEBUG( "Calculated MVA calibrated energy = " << mvaE );
147 return StatusCode::SUCCESS;
148}
#define ATH_MSG_FATAL(x)
ToolHandle< IegammaMVACalibTool > m_mvaElectron
MVA tool for electron.
ToolHandle< IegammaMVACalibTool > m_mvaFwdElectron
MVA tool for forward electron.
bool isConvCalib(const xAOD::Photon &ph) const
Decide if the photon is converted or not.
ToolHandle< IegammaMVACalibTool > m_mvaConvertedPhoton
MVA tool for converted photon.
ToolHandle< IegammaMVACalibTool > m_mvaUnconvertedPhoton
MVA tool for unconverted photon.
bool isFwdElectron(const xAOD::Egamma *eg)
is the object a Fwd electron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
Photon_v1 Photon
Definition of the current "egamma version".

◆ getEnergy() [2/2]

StatusCode egammaTransformerSvc::getEnergy ( const xAOD::CaloCluster & cluster,
const xAOD::EgammaParameters::EgammaType egType,
double & mvaE,
const egammaMVACalib::GlobalEventInfo & gei = egammaMVACalib::GlobalEventInfo() ) const
finaloverride

Compute the calibrated energy when the full egamma object is not available.

Definition at line 150 of file egammaTransformerSvc.cxx.

154{
155
156 ATH_MSG_DEBUG("calling egammaTransformerSvc::getEnergy with cluster and egType (" << egType <<")");
157
158 mvaE = 0.0;
159 switch (egType) {
161 if (!m_mvaElectron.empty()) {
162 mvaE = m_mvaElectron->getEnergy(cluster,nullptr, gei);
163 } else {
164 ATH_MSG_FATAL("Trying to calibrate an electron, but disabled");
165 return StatusCode::FAILURE;
166 }
167 break;
169 if (!m_mvaFwdElectron.empty()) {
170 mvaE = m_mvaFwdElectron->getEnergy(cluster,nullptr, gei);
171 } else {
172 ATH_MSG_FATAL("Trying to calibrate a forward electron, but disabled");
173 return StatusCode::FAILURE;
174 }
175 break;
178 // treat converted photons like unconverted photons since don't have access to vertex
179 if (!m_mvaUnconvertedPhoton.empty()) {
180 mvaE = m_mvaUnconvertedPhoton->getEnergy(cluster,nullptr, gei);
181 } else {
182 ATH_MSG_FATAL("Trying to calibrate an unconverted photon, but disabled");
183 return StatusCode::FAILURE;
184 }
185 break;
186 default:
187 ATH_MSG_FATAL("Egamma object " << egType << " is of unsupported type");
188 return StatusCode::FAILURE;
189 }
190
191 ATH_MSG_DEBUG( "Calculated MVA calibrated energy = " << mvaE );
192 return StatusCode::SUCCESS;
193}

◆ initialize()

StatusCode egammaTransformerSvc::initialize ( )
overridevirtual

Definition at line 18 of file egammaTransformerSvc.cxx.

19{
20 ATH_MSG_DEBUG("In initialize of " << name() << "..." );
21
22 if (!m_mvaElectron.empty()) {
23 ATH_MSG_DEBUG("Retrieving mvaElectron");
24 ATH_CHECK(m_mvaElectron.retrieve());
25 } else {
26 ATH_MSG_DEBUG("Disabling mvaElectron");
27 m_mvaElectron.disable();
28 }
29
30 if (!m_mvaFwdElectron.empty()) {
31 ATH_MSG_DEBUG("Retrieving mvaFwdElectron");
32 ATH_CHECK(m_mvaFwdElectron.retrieve());
33 } else {
34 ATH_MSG_DEBUG("Disabling mvaFwdElectron");
35 m_mvaFwdElectron.disable();
36 }
37
38 if (!m_mvaUnconvertedPhoton.empty()) {
39 ATH_MSG_DEBUG("Retrieving mvaUnconvertedPhoton");
41 } else {
42 ATH_MSG_DEBUG("Disabling mvaUnconvertedPhoton");
43 m_mvaUnconvertedPhoton.disable();
44 }
45
46 if (!m_mvaConvertedPhoton.empty()) {
47 ATH_MSG_DEBUG("Retrieving mvaConvertedPhoton");
49 } else {
50 ATH_MSG_DEBUG("Disabling mvaConvertedPhoton");
51 m_mvaConvertedPhoton.disable();
52 }
53
55
58
59 return StatusCode::SUCCESS;
60}
#define ATH_MSG_INFO(x)
Gaudi::Property< int > m_removeTRTConvBarrel
Gaudi::Property< float > m_maxConvR

◆ isConvCalib()

bool egammaTransformerSvc::isConvCalib ( const xAOD::Photon & ph) const
private

Decide if the photon is converted or not.

Definition at line 80 of file egammaTransformerSvc.cxx.

81{
85 // special case in Run3 to avoid TRT converted photons in the barrel
87 }
88 return isConvCalib;
89}
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon
float conversionRadius(const xAOD::Vertex *vx)
return the conversion radius or 9999.

◆ resolve_flags()

StatusCode egammaTransformerSvc::resolve_flags ( )
private

Definition at line 62 of file egammaTransformerSvc.cxx.

63{
64 // For transformer, we always remove the TRT converted photons in the barrel to make it consistent with the training. Therefore we do not support other options for m_removeTRTConvBarrel and set it to true by default. If users set it to other values, we will print a warning and set it to true.
65 const bool removeTRTConvBarrelDefault = true;
66 if (m_removeTRTConvBarrel == -1) {
67 m_removeTRTConvBarrel = removeTRTConvBarrelDefault;
68 }
69 else if (!m_removeTRTConvBarrel) {
70 ATH_MSG_WARNING("m_removeTRTConvBarrel is set to " << m_removeTRTConvBarrel << " which is not supported for Transformer which excluded TRT conversion in the model training. Setting it to " << removeTRTConvBarrelDefault);
71 m_removeTRTConvBarrel = removeTRTConvBarrelDefault;
72 }
73 else {
74 ATH_MSG_DEBUG("TRT converted photons in the barrel will be removed for calibration, which is consistent with the training of the Transformer model.");
75 }
76
77 return StatusCode::SUCCESS;
78}
#define ATH_MSG_WARNING(x)

Member Data Documentation

◆ m_folder

Gaudi::Property<std::string> egammaTransformerSvc::m_folder
private
Initial value:
{this,
"folder", "", "folder for weight files"}

Definition at line 92 of file egammaTransformerSvc.h.

92 {this,
93 "folder", "", "folder for weight files"};

◆ m_maxConvR

Gaudi::Property<float> egammaTransformerSvc::m_maxConvR
private
Initial value:
{this,
"MaxConvRadius", 800.0,
"The maximum conversion radius for a photon to be considered converted"}

Definition at line 84 of file egammaTransformerSvc.h.

84 {this,
85 "MaxConvRadius", 800.0,
86 "The maximum conversion radius for a photon to be considered converted"};

◆ m_mvaConvertedPhoton

ToolHandle<IegammaMVACalibTool> egammaTransformerSvc::m_mvaConvertedPhoton
private
Initial value:
{this,
"ConvertedPhotonTool", "", "Tool to handle MVA trees for converted photons"}

MVA tool for converted photon.

Definition at line 81 of file egammaTransformerSvc.h.

81 {this,
82 "ConvertedPhotonTool", "", "Tool to handle MVA trees for converted photons"};

◆ m_mvaElectron

ToolHandle<IegammaMVACalibTool> egammaTransformerSvc::m_mvaElectron
private
Initial value:
{this,
"ElectronTool", "", "Tool to handle MVA trees for electrons"}

MVA tool for electron.

Definition at line 69 of file egammaTransformerSvc.h.

69 {this,
70 "ElectronTool", "", "Tool to handle MVA trees for electrons"};

◆ m_mvaFwdElectron

ToolHandle<IegammaMVACalibTool> egammaTransformerSvc::m_mvaFwdElectron
private
Initial value:
{this,
"FwdElectronTool", "", "Tool to handle MVA trees for forward electrons"}

MVA tool for forward electron.

Definition at line 73 of file egammaTransformerSvc.h.

73 {this,
74 "FwdElectronTool", "", "Tool to handle MVA trees for forward electrons"};

◆ m_mvaUnconvertedPhoton

ToolHandle<IegammaMVACalibTool> egammaTransformerSvc::m_mvaUnconvertedPhoton
private
Initial value:
{this,
"UnconvertedPhotonTool", "", "Tool to handle MVA trees for unconverted photons"}

MVA tool for unconverted photon.

Definition at line 77 of file egammaTransformerSvc.h.

77 {this,
78 "UnconvertedPhotonTool", "", "Tool to handle MVA trees for unconverted photons"};

◆ m_removeTRTConvBarrel

Gaudi::Property<int> egammaTransformerSvc::m_removeTRTConvBarrel
private
Initial value:
{this,
"RemoveTRTConvBarrel", -1,
"Remove TRT converted photons in the barrel: no=0, yes=1, automatic=-1"}

Definition at line 88 of file egammaTransformerSvc.h.

88 {this,
89 "RemoveTRTConvBarrel", -1,
90 "Remove TRT converted photons in the barrel: no=0, yes=1, automatic=-1"};

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