ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkEGamma
src
EGElectronLikelihoodToolWrapper.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
// Author: Giovanni Marchiori (giovanni.marchiori@cern.ch)
6
7
#include "
DerivationFrameworkEGamma/EGElectronLikelihoodToolWrapper.h
"
8
//
9
#include "
PATCore/AcceptData.h
"
10
#include "
PATCore/AcceptInfo.h
"
11
//
12
#include "
xAODBase/IParticleContainer.h
"
13
#include "
xAODBase/IParticleHelpers.h
"
14
#include "
xAODEgamma/EgammaContainer.h
"
15
#include "
xAODEgamma/Electron.h
"
16
#include "
xAODEgamma/Photon.h
"
17
18
namespace
DerivationFramework
{
19
20
StatusCode
21
EGElectronLikelihoodToolWrapper::initialize
()
22
{
23
ATH_CHECK
(
m_tool
.retrieve());
24
25
ATH_CHECK
(
m_ContainerName
.initialize());
26
ATH_CHECK
(
m_fudgedContainerName
.initialize(!
m_fudgedContainerName
.empty()));
27
//
28
ATH_CHECK
(
m_decoratorPass
.initialize());
29
ATH_CHECK
(
m_decoratorIsEM
.initialize());
30
//
31
ATH_CHECK
(
m_decoratorResult
.initialize(
m_storeTResult
));
32
ATH_CHECK
(
m_decoratorMultipleOutputs
.initialize(
m_storeMultipleOutputs
));
33
return
StatusCode::SUCCESS;
34
}
35
36
StatusCode
37
EGElectronLikelihoodToolWrapper::addBranches
(
const
EventContext& ctx)
const
38
{
39
// retrieve container
40
SG::ReadHandle<xAOD::EgammaContainer>
particles;
41
if
(!
m_fudgedContainerName
.empty()){
42
SG::ReadHandle<xAOD::EgammaContainer>
fudged{
m_fudgedContainerName
, ctx };
43
particles = std::move(fudged);
44
}
else
{
45
SG::ReadHandle<xAOD::EgammaContainer>
egammas{
m_ContainerName
, ctx };
46
particles = std::move(egammas);
47
}
48
49
// Decorators
50
SG::WriteDecorHandle<xAOD::EgammaContainer, char>
decoratorPass{
51
m_decoratorPass
, ctx
52
};
53
SG::WriteDecorHandle<xAOD::EgammaContainer, unsigned int>
decoratorIsEM{
54
m_decoratorIsEM
, ctx
55
};
56
57
std::unique_ptr<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>
58
decoratorResult =
nullptr
;
59
if
(
m_storeTResult
) {
60
decoratorResult =
61
std::make_unique<SG::WriteDecorHandle<xAOD::EgammaContainer, float>>(
62
m_decoratorResult
, ctx);
63
}
64
std::vector<SG::WriteDecorHandle<xAOD::EgammaContainer, float>> decoratorMultipleOutputs{};
65
if
(
m_storeMultipleOutputs
) {
66
decoratorMultipleOutputs =
m_decoratorMultipleOutputs
.makeHandles(ctx);
67
}
68
69
// Write mask for each element and record to SG for subsequent selection
70
for
(
const
auto
&
egamma
: *particles) {
71
// compute the output of the selector
72
asg::AcceptData
theAccept(
m_tool
->accept(ctx,
egamma
));
73
// this should work for both the
74
// cut-based and the LH selectors
75
const
unsigned
int
isEM =
76
static_cast<
unsigned
int
>
(theAccept.
getCutResultInvertedBitSet
()
77
.to_ulong());
78
79
// decorate the original object
80
const
xAOD::IParticle
* original =
m_fudgedContainerName
.empty() ?
81
egamma
:
xAOD::getOriginalObject
(*
egamma
);
82
if
(
m_cut
.empty()) {
83
const
bool
pass_selection =
static_cast<
bool
>
(theAccept);
84
decoratorPass(*original) = pass_selection ? 1 : 0;
85
}
else
{
86
decoratorPass(*original) = theAccept.
getCutResult
(
m_cut
) ? 1 : 0;
87
}
88
decoratorIsEM(*original) = isEM;
89
if
(decoratorResult) {
90
(*decoratorResult)(*original) =
91
static_cast<
float
>
(
m_tool
->calculate(ctx,
egamma
));
92
}
93
if
(
m_storeMultipleOutputs
) {
94
// calculateMultipleOutputs only supports xAOD::Electron as input
95
const
xAOD::Electron
*eCopy =
static_cast<
const
xAOD::Electron
*
>
(
egamma
);
96
std::vector<float> toolOutput =
m_tool
->calculateMultipleOutputs(ctx, eCopy);
97
for
(
size_t
i = 0; i < toolOutput.size(); i++){
98
decoratorMultipleOutputs.at(i)(*original) = toolOutput.at(i);
99
}
100
}
101
}
102
103
return
StatusCode::SUCCESS;
104
}
105
}
AcceptData.h
AcceptInfo.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
EGElectronLikelihoodToolWrapper.h
EgammaContainer.h
Electron.h
Photon.h
IParticleHelpers.h
DerivationFramework::EGElectronLikelihoodToolWrapper::m_ContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_ContainerName
Definition
EGElectronLikelihoodToolWrapper.h:49
DerivationFramework::EGElectronLikelihoodToolWrapper::m_fudgedContainerName
SG::ReadHandleKey< xAOD::EgammaContainer > m_fudgedContainerName
Definition
EGElectronLikelihoodToolWrapper.h:53
DerivationFramework::EGElectronLikelihoodToolWrapper::m_tool
ToolHandle< IAsgElectronLikelihoodTool > m_tool
Definition
EGElectronLikelihoodToolWrapper.h:42
DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeTResult
Gaudi::Property< bool > m_storeTResult
Definition
EGElectronLikelihoodToolWrapper.h:67
DerivationFramework::EGElectronLikelihoodToolWrapper::addBranches
virtual StatusCode addBranches(const EventContext &ctx) const override final
Definition
EGElectronLikelihoodToolWrapper.cxx:37
DerivationFramework::EGElectronLikelihoodToolWrapper::m_cut
Gaudi::Property< std::string > m_cut
Definition
EGElectronLikelihoodToolWrapper.h:66
DerivationFramework::EGElectronLikelihoodToolWrapper::m_storeMultipleOutputs
Gaudi::Property< bool > m_storeMultipleOutputs
Definition
EGElectronLikelihoodToolWrapper.h:68
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorPass
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorPass
Definition
EGElectronLikelihoodToolWrapper.h:59
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorIsEM
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorIsEM
Definition
EGElectronLikelihoodToolWrapper.h:61
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorMultipleOutputs
SG::WriteDecorHandleKeyArray< xAOD::EgammaContainer, float > m_decoratorMultipleOutputs
Definition
EGElectronLikelihoodToolWrapper.h:65
DerivationFramework::EGElectronLikelihoodToolWrapper::initialize
virtual StatusCode initialize() override final
Definition
EGElectronLikelihoodToolWrapper.cxx:21
DerivationFramework::EGElectronLikelihoodToolWrapper::m_decoratorResult
SG::WriteDecorHandleKey< xAOD::EgammaContainer > m_decoratorResult
Definition
EGElectronLikelihoodToolWrapper.h:63
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::getCutResultInvertedBitSet
std::bitset< NBITS > getCutResultInvertedBitSet() const
Get an inverted bitset of the cut result.
Definition
AcceptData.h:120
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
egamma
elec/gamma data class.
Definition
egamma.h:59
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
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition
Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
IParticleContainer.h
Generated on
for ATLAS Offline Software by
1.17.0