Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
egammaMVASvc Class Reference

#include <egammaMVASvc.h>

Inheritance diagram for egammaMVASvc:
Collaboration diagram for egammaMVASvc:

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 23 of file egammaMVASvc.h.

Constructor & Destructor Documentation

◆ ~egammaMVASvc()

virtual egammaMVASvc::~egammaMVASvc ( )
inlineoverridevirtual

Definition at line 28 of file egammaMVASvc.h.

28 {};

Member Function Documentation

◆ execute() [1/2]

StatusCode egammaMVASvc::execute ( xAOD::CaloCluster cluster,
const xAOD::Egamma eg 
) 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 177 of file egammaMVASvc.cxx.

179 {
180  double mvaE = 0.;
181 
182  ATH_CHECK(getEnergy(cluster, eg, mvaE));
183 
184  if (mvaE > eg.m()) {
185  cluster.setCalE(mvaE);
186  }
187  else {
188  ATH_MSG_DEBUG("MVA energy (" << mvaE << ") < particle mass ("
189  << eg.m() << "), setting e = cluster energy (" << cluster.e() << ")");
190  cluster.setCalE(cluster.e());
191  }
192  return StatusCode::SUCCESS;
193 }

◆ execute() [2/2]

StatusCode egammaMVASvc::execute ( xAOD::CaloCluster cluster,
const xAOD::EgammaParameters::EgammaType  egType 
) 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 195 of file egammaMVASvc.cxx.

197 {
198 
199  double mvaE = 0.;
200 
201  ATH_CHECK(getEnergy(cluster, egType, mvaE));
202 
203  if (mvaE > 0) {
204  cluster.setCalE(mvaE);
205  }
206  else {
207  ATH_MSG_DEBUG("MVA energy (" << mvaE << ") < 0, setting e = cluster energy ("
208  << cluster.e() << ")");
209  cluster.setCalE(cluster.e());
210  }
211  return StatusCode::SUCCESS;
212 }

◆ getEnergy() [1/2]

StatusCode egammaMVASvc::getEnergy ( const xAOD::CaloCluster cluster,
const xAOD::Egamma eg,
double &  mvaE 
) const
finaloverride

Compute the calibrated energy.

Definition at line 97 of file egammaMVASvc.cxx.

100 {
101 
102  ATH_MSG_DEBUG("calling egammaMVASvc::getEnergy with cluster and eg");
103 
104  mvaE = 0.;
105 
107  if (!m_mvaElectron.empty()) {
108  mvaE = m_mvaElectron->getEnergy(cluster, &eg);
109  } else {
110  ATH_MSG_FATAL("Trying to calibrate an electron, but disabled");
111  return StatusCode::FAILURE;
112  }
113  } else if (xAOD::EgammaHelpers::isPhoton(&eg)) {
114  const xAOD::Photon* ph = static_cast<const xAOD::Photon*>(&eg);
115  const bool is_conv_calib = isConvCalib(*ph);
116  if (is_conv_calib) {
117  if (!m_mvaConvertedPhoton.empty()) {
118  mvaE = m_mvaConvertedPhoton->getEnergy(cluster, &eg);
119  } else {
120  ATH_MSG_FATAL("Trying to calibrate a converted photon, but disabled");
121  return StatusCode::FAILURE;
122  }
123  } else {
124  if (!m_mvaUnconvertedPhoton.empty()) {
125  mvaE = m_mvaUnconvertedPhoton->getEnergy(cluster, &eg);
126  } else {
127  ATH_MSG_FATAL("Trying to calibrate an unconverted photon, but disabled");
128  return StatusCode::FAILURE;
129  }
130  }
131  } else {
132  ATH_MSG_FATAL("Egamma object is of unsupported type");
133  return StatusCode::FAILURE;
134  }
135 
136  ATH_MSG_DEBUG( "Calculated MVA calibrated energy = " << mvaE );
137  return StatusCode::SUCCESS;
138 }

◆ getEnergy() [2/2]

StatusCode egammaMVASvc::getEnergy ( const xAOD::CaloCluster cluster,
const xAOD::EgammaParameters::EgammaType  egType,
double &  mvaE 
) const
finaloverride

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

Definition at line 140 of file egammaMVASvc.cxx.

143 {
144 
145  ATH_MSG_DEBUG("calling egammaMVASvc::getEnergy with cluster and egType (" << egType <<")");
146 
147  mvaE = 0.0;
148  switch (egType) {
150  if (!m_mvaElectron.empty()) {
151  mvaE = m_mvaElectron->getEnergy(cluster,nullptr);
152  } else {
153  ATH_MSG_FATAL("Trying to calibrate an electron, but disabled");
154  return StatusCode::FAILURE;
155  }
156  break;
159  // treat converted photons like unconverted photons since don't have access to vertex
160  if (!m_mvaUnconvertedPhoton.empty()) {
161  mvaE = m_mvaUnconvertedPhoton->getEnergy(cluster,nullptr);
162  } else {
163  ATH_MSG_FATAL("Trying to calibrate an unconverted photon, but disabled");
164  return StatusCode::FAILURE;
165  }
166  break;
167  default:
168  ATH_MSG_FATAL("Egamma object is of unsupported type");
169  return StatusCode::FAILURE;
170  }
171 
172  ATH_MSG_DEBUG( "Calculated MVA calibrated energy = " << mvaE );
173  return StatusCode::SUCCESS;
174 }

◆ initialize()

StatusCode egammaMVASvc::initialize ( )
overridevirtual

Definition at line 18 of file egammaMVASvc.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_mvaUnconvertedPhoton.empty()) {
31  ATH_MSG_DEBUG("Retrieving mvaUnconvertedPhoton");
33  } else {
34  ATH_MSG_DEBUG("Disabling mvaUnconvertedPhoton");
35  m_mvaUnconvertedPhoton.disable();
36  }
37 
38  if (!m_mvaConvertedPhoton.empty()) {
39  ATH_MSG_DEBUG("Retrieving mvaConvertedPhoton");
40  ATH_CHECK(m_mvaConvertedPhoton.retrieve());
41  } else {
42  ATH_MSG_DEBUG("Disabling mvaConvertedPhoton");
43  m_mvaConvertedPhoton.disable();
44  }
45 
47 
50 
51  return StatusCode::SUCCESS;
52 }

◆ isConvCalib()

bool egammaMVASvc::isConvCalib ( const xAOD::Photon ph) const
private

Decide if the photon is converted or not.

Definition at line 86 of file egammaMVASvc.cxx.

87 {
91  // special case in Run3 to avoid TRT converted photons in the barrel
93  }
94  return isConvCalib;
95 }

◆ resolve_flags()

StatusCode egammaMVASvc::resolve_flags ( )
private

Definition at line 54 of file egammaMVASvc.cxx.

55 {
56  if (m_removeTRTConvBarrel == -1) {
57  const bool removeTRTConvBarrelDefault = false;
58  if (!m_mvaConvertedPhoton.empty() and !m_folder.empty()) {
59  const std::string mva_filename = PathResolverFindCalibFile(m_folder + "/MVACalib_convertedPhoton.weights.root");
60  std::unique_ptr<TFile> f(TFile::Open(mva_filename.c_str()));
61  if (!f || f->IsZombie()) {
62  ATH_MSG_ERROR("Could not open file: " << mva_filename);
63  m_removeTRTConvBarrel = removeTRTConvBarrelDefault;
64  }
65  else { // we have the MVA for converted photons
66  TObjString* conversionDefinitionObj = nullptr;
67  f->GetObject("conversionDefinition", conversionDefinitionObj);
68  if (conversionDefinitionObj) {
69  m_removeTRTConvBarrel = (conversionDefinitionObj->GetString() == "removeTRTConvBarrel");
70  } else {
71  // the conversion definition is not encoded in the file, this is true for the old ones
72  m_removeTRTConvBarrel = removeTRTConvBarrelDefault;
73  }
74  }
75  } else { // we are running without converted
76  m_removeTRTConvBarrel = removeTRTConvBarrelDefault;
77  }
78  }
79  if (m_removeTRTConvBarrel == -1) {
80  ATH_MSG_ERROR("Could not determine if TRT converted photons should be removed in the barrel");
81  return StatusCode::FAILURE;
82  }
83  return StatusCode::SUCCESS;
84 }

Member Data Documentation

◆ m_folder

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

Definition at line 80 of file egammaMVASvc.h.

◆ m_maxConvR

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

Definition at line 72 of file egammaMVASvc.h.

◆ m_mvaConvertedPhoton

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

MVA tool for converted photon.

Definition at line 69 of file egammaMVASvc.h.

◆ m_mvaElectron

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

MVA tool for electron.

Definition at line 61 of file egammaMVASvc.h.

◆ m_mvaUnconvertedPhoton

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

MVA tool for unconverted photon.

Definition at line 65 of file egammaMVASvc.h.

◆ m_removeTRTConvBarrel

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

Definition at line 76 of file egammaMVASvc.h.


The documentation for this class was generated from the following files:
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
egammaMVASvc::m_folder
Gaudi::Property< std::string > m_folder
Definition: egammaMVASvc.h:80
egammaMVASvc::m_removeTRTConvBarrel
Gaudi::Property< int > m_removeTRTConvBarrel
Definition: egammaMVASvc.h:76
xAOD::EgammaParameters::convertedPhoton
@ convertedPhoton
Definition: EgammaEnums.h:20
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ParticleTest.eg
eg
Definition: ParticleTest.py:29
egammaMVASvc::resolve_flags
StatusCode resolve_flags()
Definition: egammaMVASvc.cxx:54
egammaMVASvc::m_maxConvR
Gaudi::Property< float > m_maxConvR
Definition: egammaMVASvc.h:72
egammaMVASvc::m_mvaElectron
ToolHandle< IegammaMVACalibTool > m_mvaElectron
MVA tool for electron.
Definition: egammaMVASvc.h:61
xAOD::EgammaHelpers::isConvertedPhoton
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon
Definition: EgammaxAODHelpers.cxx:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
columnar::ContainerId::cluster
@ cluster
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::EgammaHelpers::isElectron
bool isElectron(const xAOD::Egamma *eg)
is the object an electron (not Fwd)
Definition: EgammaxAODHelpers.cxx:12
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
hist_file_dump.f
f
Definition: hist_file_dump.py:141
egammaMVASvc::getEnergy
StatusCode getEnergy(const xAOD::CaloCluster &cluster, const xAOD::Egamma &eg, double &mvaE) const override final
Compute the calibrated energy.
Definition: egammaMVASvc.cxx:97
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
xAOD::EgammaHelpers::conversionRadius
float conversionRadius(const xAOD::Vertex *vx)
return the conversion radius or 9999.
Definition: PhotonxAODHelpers.cxx:77
egammaMVASvc::isConvCalib
bool isConvCalib(const xAOD::Photon &ph) const
Decide if the photon is converted or not.
Definition: egammaMVASvc.cxx:86
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
xAOD::Photon_v1
Definition: Photon_v1.h:37
xAOD::EgammaHelpers::isPhoton
bool isPhoton(const xAOD::Egamma *eg)
is the object a photon
Definition: EgammaxAODHelpers.cxx:21
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
egammaMVASvc::m_mvaUnconvertedPhoton
ToolHandle< IegammaMVACalibTool > m_mvaUnconvertedPhoton
MVA tool for unconverted photon.
Definition: egammaMVASvc.h:65
egammaMVASvc::m_mvaConvertedPhoton
ToolHandle< IegammaMVACalibTool > m_mvaConvertedPhoton
MVA tool for converted photon.
Definition: egammaMVASvc.h:69
xAOD::EgammaParameters::unconvertedPhoton
@ unconvertedPhoton
Definition: EgammaEnums.h:19