ATLAS Offline Software
Public 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

 egammaMVASvc (const std::string &name, ISvcLocator *svc)
 
virtual ~egammaMVASvc () override
 
virtual StatusCode initialize () override
 set up/tear down functions More...
 
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...
 
virtual void print () const
 Print the state of the service. More...
 
template<typename T >
void declareServiceInterface ()
 add the given interface to the list of interfaces More...
 
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvi)
 query interface for gaudi More...
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 
 DeclareInterfaceID (IegammaMVASvc, 1, 0)
 

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< bool > m_removeTRTConvBarrel
 
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
 list of interfaces we have More...
 

Detailed Description

Definition at line 19 of file egammaMVASvc.h.

Constructor & Destructor Documentation

◆ egammaMVASvc()

egammaMVASvc::egammaMVASvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 14 of file egammaMVASvc.cxx.

14  :
16 {
17  declareServiceInterface<IegammaMVASvc>();
18 }

◆ ~egammaMVASvc()

virtual egammaMVASvc::~egammaMVASvc ( )
inlineoverridevirtual

Definition at line 23 of file egammaMVASvc.h.

23 {};

Member Function Documentation

◆ DeclareInterfaceID()

IegammaMVASvc::DeclareInterfaceID ( IegammaMVASvc  ,
,
 
)
inherited

◆ declareServiceInterface()

template<typename T >
void asg::AsgService::declareServiceInterface
inherited

add the given interface to the list of interfaces

Definition at line 76 of file AsgService.h.

77  {
78 #ifndef XAOD_STANDALONE
79  m_interfaces.emplace_back (T::interfaceID, [] (AsgService *self) -> void* {return dynamic_cast<T*>(self);});
80 #endif
81  }

◆ execute() [1/2]

StatusCode egammaMVASvc::execute ( xAOD::CaloCluster cluster,
const xAOD::Egamma eg 
) const
finaloverridevirtual

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

Implements IegammaMVASvc.

Definition at line 140 of file egammaMVASvc.cxx.

142 {
143  double mvaE = 0.;
144 
145  ATH_CHECK(getEnergy(cluster, eg, mvaE));
146 
147  if (mvaE > eg.m()) {
148  cluster.setCalE(mvaE);
149  }
150  else {
151  ATH_MSG_DEBUG("MVA energy (" << mvaE << ") < particle mass ("
152  << eg.m() << "), setting e = cluster energy (" << cluster.e() << ")");
153  cluster.setCalE(cluster.e());
154  }
155  return StatusCode::SUCCESS;
156 }

◆ execute() [2/2]

StatusCode egammaMVASvc::execute ( xAOD::CaloCluster cluster,
const xAOD::EgammaParameters::EgammaType  egType 
) const
finaloverridevirtual

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.

Implements IegammaMVASvc.

Definition at line 158 of file egammaMVASvc.cxx.

160 {
161 
162  double mvaE = 0.;
163 
164  ATH_CHECK(getEnergy(cluster, egType, mvaE));
165 
166  if (mvaE > 0) {
167  cluster.setCalE(mvaE);
168  }
169  else {
170  ATH_MSG_DEBUG("MVA energy (" << mvaE << ") < 0, setting e = cluster energy ("
171  << cluster.e() << ")");
172  cluster.setCalE(cluster.e());
173  }
174  return StatusCode::SUCCESS;
175 }

◆ finalize()

StatusCode asg::AsgService::finalize ( )
virtualinherited

Reimplemented in TrackAnalysisDefinitionSvc, CP::SystematicsSvc, PlotsDefinitionSvc, and AthOnnx::OnnxRuntimeSvc.

Definition at line 40 of file AsgService.cxx.

42  {
43  return StatusCode::SUCCESS;
44  }

◆ getEnergy() [1/2]

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

Compute the calibrated energy.

Implements IegammaMVASvc.

Definition at line 51 of file egammaMVASvc.cxx.

54 {
55 
56  ATH_MSG_DEBUG("calling egammaMVASvc::getEnergy with cluster and eg");
57 
58  mvaE = 0.;
59 
61  if (!m_mvaElectron.empty()) {
62  mvaE = m_mvaElectron->getEnergy(cluster, &eg);
63  } else {
64  ATH_MSG_FATAL("Trying to calibrate an electron, but disabled");
65  return StatusCode::FAILURE;
66  }
67  } else if (xAOD::EgammaHelpers::isPhoton(&eg)) {
68  const xAOD::Photon* ph = static_cast<const xAOD::Photon*>(&eg);
69  bool isConvCalib = xAOD::EgammaHelpers::isConvertedPhoton(ph) &&
72  // special case in Run3 to avoid TRT converted photons in the barrel
75  const bool isTRTConv = (conversionType == singleTRT) || (conversionType == doubleTRT); // 2 or 4
76  const bool isTRTEndcap = std::abs(ph->eta()) > 0.8;
77  isConvCalib = isConvCalib && (isTRTEndcap || !isTRTConv);
78  }
79  if (isConvCalib) {
80  if (!m_mvaConvertedPhoton.empty()) {
81  mvaE = m_mvaConvertedPhoton->getEnergy(cluster, &eg);
82  } else {
83  ATH_MSG_FATAL("Trying to calibrate a converted photon, but disabled");
84  return StatusCode::FAILURE;
85  }
86  } else {
87  if (!m_mvaUnconvertedPhoton.empty()) {
88  mvaE = m_mvaUnconvertedPhoton->getEnergy(cluster, &eg);
89  } else {
90  ATH_MSG_FATAL("Trying to calibrate an unconverted photon, but disabled");
91  return StatusCode::FAILURE;
92  }
93  }
94  } else {
95  ATH_MSG_FATAL("Egamma object is of unsupported type");
96  return StatusCode::FAILURE;
97  }
98 
99  ATH_MSG_DEBUG( "Calculated MVA calibrated energy = " << mvaE );
100  return StatusCode::SUCCESS;
101 }

◆ getEnergy() [2/2]

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

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

Implements IegammaMVASvc.

Definition at line 103 of file egammaMVASvc.cxx.

106 {
107 
108  ATH_MSG_DEBUG("calling egammaMVASvc::getEnergy with cluster and egType (" << egType <<")");
109 
110  mvaE = 0.0;
111  switch (egType) {
113  if (!m_mvaElectron.empty()) {
114  mvaE = m_mvaElectron->getEnergy(cluster,nullptr);
115  } else {
116  ATH_MSG_FATAL("Trying to calibrate an electron, but disabled");
117  return StatusCode::FAILURE;
118  }
119  break;
122  // treat converted photons like unconverted photons since don't have access to vertex
123  if (!m_mvaUnconvertedPhoton.empty()) {
124  mvaE = m_mvaUnconvertedPhoton->getEnergy(cluster,nullptr);
125  } else {
126  ATH_MSG_FATAL("Trying to calibrate an unconverted photon, but disabled");
127  return StatusCode::FAILURE;
128  }
129  break;
130  default:
131  ATH_MSG_FATAL("Egamma object is of unsupported type");
132  return StatusCode::FAILURE;
133  }
134 
135  ATH_MSG_DEBUG( "Calculated MVA calibrated energy = " << mvaE );
136  return StatusCode::SUCCESS;
137 }

◆ initialize()

StatusCode egammaMVASvc::initialize ( )
overridevirtual

set up/tear down functions

Reimplemented from asg::AsgService.

Definition at line 20 of file egammaMVASvc.cxx.

21 {
22  ATH_MSG_DEBUG("In initialize of " << name() << "..." );
23 
24  if (!m_mvaElectron.empty()) {
25  ATH_MSG_DEBUG("Retrieving mvaElectron");
26  ATH_CHECK(m_mvaElectron.retrieve());
27  } else {
28  ATH_MSG_DEBUG("Disabling mvaElectron");
29  m_mvaElectron.disable();
30  }
31 
32  if (!m_mvaUnconvertedPhoton.empty()) {
33  ATH_MSG_DEBUG("Retrieving mvaUnconvertedPhoton");
35  } else {
36  ATH_MSG_DEBUG("Disabling mvaUnconvertedPhoton");
37  m_mvaUnconvertedPhoton.disable();
38  }
39 
40  if (!m_mvaConvertedPhoton.empty()) {
41  ATH_MSG_DEBUG("Retrieving mvaConvertedPhoton");
42  ATH_CHECK(m_mvaConvertedPhoton.retrieve());
43  } else {
44  ATH_MSG_DEBUG("Disabling mvaConvertedPhoton");
45  m_mvaConvertedPhoton.disable();
46  }
47 
48  return StatusCode::SUCCESS;
49 }

◆ msg() [1/2]

MsgStream& AthCommonMsg< Service >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Service >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Service >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ print()

void asg::AsgService::print ( ) const
virtualinherited

Print the state of the service.

Implements asg::IAsgService.

Definition at line 48 of file AsgService.cxx.

49  {
50  ATH_MSG_INFO( "AsgService " << name() << " @ " << this );
51  return;
52  }

◆ queryInterface()

StatusCode asg::AsgService::queryInterface ( const InterfaceID &  riid,
void **  ppvi 
)
virtualinherited

query interface for gaudi

Definition at line 57 of file AsgService.cxx.

59  {
60  for (const auto& interface : m_interfaces)
61  {
62  if (riid == interface.first())
63  {
64  *ppvi = interface.second (this);
65  addRef();
66  return StatusCode::SUCCESS;
67  }
68  }
69  return AsgServiceBase::queryInterface (riid, ppvi);
70  }

Member Data Documentation

◆ m_interfaces

std::vector<std::pair<const InterfaceID& (*)(),void *(*)(AsgService*)> > asg::AsgService::m_interfaces
privateinherited

list of interfaces we have

Definition at line 68 of file AsgService.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 67 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 64 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 56 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 60 of file egammaMVASvc.h.

◆ m_removeTRTConvBarrel

Gaudi::Property<bool> egammaMVASvc::m_removeTRTConvBarrel
private
Initial value:
{this,
"RemoveTRTConvBarrel", false,
"Remove TRT converted photons in the barrel"}

Definition at line 71 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
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
xAOD::EgammaParameters::ConversionType
ConversionType
Definition: EgammaEnums.h:268
asg::AsgService::m_interfaces
std::vector< std::pair< const InterfaceID &(*)(), void *(*)(AsgService *)> > m_interfaces
list of interfaces we have
Definition: AsgService.h:68
egammaMVASvc::m_maxConvR
Gaudi::Property< float > m_maxConvR
Definition: egammaMVASvc.h:67
egammaMVASvc::m_mvaElectron
ToolHandle< IegammaMVACalibTool > m_mvaElectron
MVA tool for electron.
Definition: egammaMVASvc.h:56
xAOD::EgammaHelpers::isConvertedPhoton
bool isConvertedPhoton(const xAOD::Egamma *eg, bool excludeTRT=false)
is the object a converted photon
Definition: EgammaxAODHelpers.cxx:26
asg::AsgService
Base class for the dual-use service implementation classes.
Definition: AsgService.h:43
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:13
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
xAOD::EgammaParameters::singleTRT
@ singleTRT
one track only, no Si hits (TRT only)
Definition: EgammaEnums.h:276
egammaMVASvc::getEnergy
StatusCode getEnergy(const xAOD::CaloCluster &cluster, const xAOD::Egamma &eg, double &mvaE) const override final
Compute the calibrated energy.
Definition: egammaMVASvc.cxx:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
xAOD::EgammaHelpers::conversionRadius
float conversionRadius(const xAOD::Vertex *vx)
return the conversion radius or 9999.
Definition: PhotonxAODHelpers.cxx:76
xAOD::CaloCluster_v1::setCalE
void setCalE(flt_t)
Set Energy for signal state CALIBRATED.
Definition: CaloCluster_v1.cxx:306
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:22
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
xAOD::EgammaHelpers::conversionType
xAOD::EgammaParameters::ConversionType conversionType(const xAOD::Photon *ph)
return the photon conversion type (see EgammaEnums)
Definition: PhotonxAODHelpers.cxx:26
xAOD::Egamma_v1::eta
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
Definition: Egamma_v1.cxx:70
xAOD::EgammaParameters::doubleTRT
@ doubleTRT
two tracks, none with Si hits (TRT only)
Definition: EgammaEnums.h:282
egammaMVASvc::m_removeTRTConvBarrel
Gaudi::Property< bool > m_removeTRTConvBarrel
Definition: egammaMVASvc.h:71
asg::AsgService::AsgService
AsgService(const std::string &name, ISvcLocator *pSvcLocator)
Definition: AsgService.cxx:19
egammaMVASvc::m_mvaUnconvertedPhoton
ToolHandle< IegammaMVACalibTool > m_mvaUnconvertedPhoton
MVA tool for unconverted photon.
Definition: egammaMVASvc.h:60
xAOD::CaloCluster_v1::e
virtual double e() const
The total energy of the particle.
Definition: CaloCluster_v1.cxx:265
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
egammaMVASvc::m_mvaConvertedPhoton
ToolHandle< IegammaMVACalibTool > m_mvaConvertedPhoton
MVA tool for converted photon.
Definition: egammaMVASvc.h:64
xAOD::EgammaParameters::unconvertedPhoton
@ unconvertedPhoton
Definition: EgammaEnums.h:19