ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkEGamma
src
EGPhotonBDTToolWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
DerivationFrameworkEGamma/EGPhotonBDTToolWrapper.h
"
6
#include "
StoreGate/ReadHandle.h
"
7
#include "
StoreGate/WriteDecorHandle.h
"
8
#include "
PATCore/AcceptData.h
"
9
#include "
xAODEgamma/Electron.h
"
10
#include "
xAODEgamma/Photon.h
"
11
#include "
xAODBase/IParticleHelpers.h
"
12
13
namespace
DerivationFramework
{
14
15
StatusCode
16
EGPhotonBDTToolWrapper::initialize
()
17
{
18
ATH_CHECK
(
m_selectorTool
.retrieve());
19
20
ATH_CHECK
(
m_ContainerName
.initialize());
21
ATH_CHECK
(
m_fudgedContainerName
.initialize(!
m_fudgedContainerName
.empty()));
22
23
ATH_CHECK
(
m_decoratorPass
.initialize());
24
ATH_CHECK
(
m_decoratorIsEM
.initialize());
25
26
return
StatusCode::SUCCESS;
27
}
28
29
StatusCode
30
EGPhotonBDTToolWrapper::addBranches
(
const
EventContext& ctx)
const
31
{
32
// retrieve container
33
SG::ReadHandle<xAOD::EgammaContainer>
particles;
34
if
(!
m_fudgedContainerName
.empty()){
35
SG::ReadHandle<xAOD::EgammaContainer>
fudged{
m_fudgedContainerName
, ctx };
36
particles = std::move(fudged);
37
}
else
{
38
SG::ReadHandle<xAOD::EgammaContainer>
photons{
m_ContainerName
, ctx };
39
particles = std::move(photons);
40
}
41
42
// Decorators
43
SG::WriteDecorHandle<xAOD::EgammaContainer, char>
decoratorPass{
44
m_decoratorPass
, ctx
45
};
46
SG::WriteDecorHandle<xAOD::EgammaContainer, unsigned int>
decoratorIsEM{
47
m_decoratorIsEM
, ctx
48
};
49
50
for
(
const
auto
& photon : *particles) {
51
// compute the output of the selector with the fudged photon
52
asg::AcceptData
theAccept(
m_selectorTool
->accept(ctx, photon));
53
// compute the is EM word
54
unsigned
int
isEM = 0;
55
ATH_CHECK
(
m_selectorTool
->execute(ctx, photon, isEM));
56
57
// decorate the original object
58
const
xAOD::IParticle
* original =
m_fudgedContainerName
.empty() ?
59
photon :
xAOD::getOriginalObject
(*photon);
60
if
(
m_cut
.empty()) {
61
decoratorPass(*original) =
static_cast<
bool
>
(theAccept) ? 1 : 0;
62
}
else
{
63
decoratorPass(*original) = theAccept.
getCutResult
(
m_cut
) ? 1 : 0;
64
}
65
decoratorIsEM(*original) = isEM;
66
}
67
68
return
StatusCode::SUCCESS;
69
}
70
}
AcceptData.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
EGPhotonBDTToolWrapper.h
Electron.h
Photon.h
IParticleHelpers.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
DerivationFramework::EGPhotonBDTToolWrapper::m_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
Definition
EGPhotonBDTToolWrapper.h:43
DerivationFramework::EGPhotonBDTToolWrapper::m_ContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
Definition
EGPhotonBDTToolWrapper.h:37
DerivationFramework::EGPhotonBDTToolWrapper::m_selectorTool
ToolHandle< IAsgEGammaIsEMSelector > m_selectorTool
Definition
EGPhotonBDTToolWrapper.h:35
DerivationFramework::EGPhotonBDTToolWrapper::m_decoratorIsEM
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorIsEM
Definition
EGPhotonBDTToolWrapper.h:45
DerivationFramework::EGPhotonBDTToolWrapper::initialize
virtual StatusCode initialize() override final
Definition
EGPhotonBDTToolWrapper.cxx:16
DerivationFramework::EGPhotonBDTToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition
EGPhotonBDTToolWrapper.h:47
DerivationFramework::EGPhotonBDTToolWrapper::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
EGPhotonBDTToolWrapper.cxx:30
DerivationFramework::EGPhotonBDTToolWrapper::m_fudgedContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_fudgedContainerName
Definition
EGPhotonBDTToolWrapper.h:39
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition
StoreGate/StoreGate/WriteDecorHandle.h:100
asg::AcceptData
Definition
AcceptData.h:31
asg::AcceptData::getCutResult
bool getCutResult(std::string_view cutName) const
Get the result of a cut, based on the cut name (safer).
Definition
AcceptData.h:99
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
DerivationFramework
THE reconstruction tool.
Definition
CascadeTools.h:16
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::getOriginalObject
const IParticle * getOriginalObject(const IParticle ©)
This function can be used to conveniently get a pointer back to the original object from which a copy...
Definition
IParticleHelpers.cxx:140
Generated on
for ATLAS Offline Software by
1.17.0