ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
egamma
egammaTools
src
EMPIDBuilder.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
EMPIDBuilder.h
"
6
#include "
AthenaKernel/errorcheck.h
"
7
#include "
PATCore/AcceptData.h
"
8
#include "
xAODEgamma/Egamma.h
"
9
10
namespace
{
11
const
SG::AuxElement::Accessor<float> accLH(
"LHValue"
);
12
}
13
14
EMPIDBuilder::EMPIDBuilder
(
const
std::string&
type
,
15
const
std::string& name,
16
const
IInterface* parent)
17
:
egammaBaseTool
(
type
, name, parent)
18
{
19
// declare interface
20
declareInterface<IegammaBaseTool>(
this
);
21
}
22
23
StatusCode
24
EMPIDBuilder::initialize
()
25
{
26
ATH_MSG_DEBUG
(
" Initializing EMPIDBuilder"
);
27
28
ATH_CHECK
(
m_electronIsEMselectors
.retrieve());
29
30
if
(
m_electronIsEMselectors
.size() !=
31
m_electronIsEMselectorResultNames
.size()) {
32
ATH_MSG_ERROR
(
"The number of selectors does not match the number of given "
33
"electronIsEMselector names"
);
34
return
StatusCode::FAILURE;
35
}
36
37
ATH_CHECK
(
m_electronLHselectors
.retrieve());
38
39
if
(
m_electronLHselectors
.size() !=
m_electronLHselectorResultNames
.size()) {
40
ATH_MSG_ERROR
(
"The number of selectors does not match the number of given "
41
"electron LH selector names"
);
42
return
StatusCode::FAILURE;
43
}
44
45
ATH_CHECK
(
m_genericIsEMselectors
.retrieve());
46
47
if
(
m_genericIsEMselectors
.size() !=
48
m_genericIsEMselectorResultNames
.size()) {
49
ATH_MSG_ERROR
(
"The number of selectors does not match the number of given "
50
"generic selector names"
);
51
return
StatusCode::FAILURE;
52
}
53
54
ATH_CHECK
(
m_photonIsEMselectors
.retrieve());
55
56
if
(
m_photonIsEMselectors
.size() !=
m_photonIsEMselectorResultNames
.size()) {
57
ATH_MSG_ERROR
(
"The number of selectors does not match the number of given "
58
"photon selector names"
);
59
return
StatusCode::FAILURE;
60
}
61
62
if
(
m_UselumiBlockMuTool
) {
63
if
(
m_lumiBlockMuTool
.retrieve().isFailure()) {
64
ATH_MSG_FATAL
(
"Unable to retrieve Luminosity Tool"
);
65
return
StatusCode::FAILURE;
66
}
67
ATH_MSG_DEBUG
(
"Successfully retrieved Luminosity Tool"
);
68
}
else
{
69
m_lumiBlockMuTool
.disable();
70
}
71
return
StatusCode::SUCCESS;
72
}
73
74
StatusCode
75
EMPIDBuilder::execute
(
const
EventContext& ctx,
xAOD::Egamma
* eg)
const
76
{
77
78
ATH_MSG_DEBUG
(
"Executing EMPIDBuilder::execute"
);
79
80
// Protection against bad pointers
81
if
(eg ==
nullptr
) {
82
ATH_MSG_WARNING
(
"NULL egamma object given to execute function"
);
83
return
StatusCode::SUCCESS;
84
}
85
86
size_t
size
=
m_electronIsEMselectors
.size();
87
88
for
(
size_t
i = 0; i <
size
; ++i) {
89
asg::AcceptData
accept =
m_electronIsEMselectors
[i]->accept(ctx, eg);
90
// save the bool result
91
eg->
setPassSelection
(
static_cast<
bool
>
(accept),
92
m_electronIsEMselectorResultNames
[i]);
93
// save the isem
94
unsigned
int
isEM = (~0);
95
if
(
m_electronIsEMselectors
[i]->
execute
(ctx, eg, isEM).isFailure()) {
96
ATH_MSG_ERROR
(
"problem to get isEM for "
97
<<
m_electronIsEMselectorResultNames
[i]);
98
return
StatusCode::FAILURE;
99
}
100
eg->
setSelectionisEM
(isEM,
"isEM"
+
m_electronIsEMselectorResultNames
[i]);
101
}
102
103
size_t
sizePh =
m_photonIsEMselectors
.size();
104
105
for
(
size_t
i = 0; i < sizePh; ++i) {
106
asg::AcceptData
accept =
m_photonIsEMselectors
[i]->accept(ctx, eg);
107
// save the bool result
108
eg->
setPassSelection
(
static_cast<
bool
>
(accept),
109
m_photonIsEMselectorResultNames
[i]);
110
// save the isem
111
unsigned
int
isEM = ~0;
112
if
(
m_photonIsEMselectors
[i]->
execute
(ctx, eg, isEM).isFailure()) {
113
ATH_MSG_ERROR
(
"problem to get isEM for "
114
<<
m_photonIsEMselectorResultNames
[i]);
115
return
StatusCode::FAILURE;
116
}
117
eg->
setSelectionisEM
(isEM,
"isEM"
+
m_photonIsEMselectorResultNames
[i]);
118
}
119
120
size_t
sizeLH =
m_electronLHselectors
.size();
121
122
// negative mu means the default behaviour --> retrieve the one in xAOD
123
double
mu = -99.;
124
double
avg_mu = -99.;
125
if
(
m_UselumiBlockMuTool
) {
//
126
mu =
m_lumiBlockMuTool
->actualInteractionsPerCrossing(ctx);
127
avg_mu =
m_lumiBlockMuTool
->averageInteractionsPerCrossing(ctx);
128
ATH_MSG_DEBUG
(
"REGTEST: Retrieved Mu Value : "
<< mu);
129
ATH_MSG_DEBUG
(
"REGTEST: Average Mu Value : "
<< avg_mu);
130
}
131
132
for
(
size_t
i = 0; i < sizeLH; ++i) {
133
asg::AcceptData
accept =
m_electronLHselectors
[i]->accept(ctx, eg, avg_mu);
134
// save the bool result
135
eg->
setPassSelection
(
static_cast<
bool
>
(accept),
136
m_electronLHselectorResultNames
[i]);
137
// save the isem
138
eg->
setSelectionisEM
(
139
static_cast<
unsigned
int
>
(accept.getCutResultInverted()),
140
"isEM"
+
m_electronLHselectorResultNames
[i]);
141
142
// save the LHValue only once
143
if
(i == 0) {
144
accLH(*eg) =
static_cast<
float
>
(
145
m_electronLHselectors
[i]->calculate(ctx, eg, avg_mu));
146
}
147
}
148
149
size_t
sizeGen =
m_genericIsEMselectors
.size();
150
for
(
size_t
i = 0; i < sizeGen; ++i) {
151
asg::AcceptData
accept =
m_genericIsEMselectors
[i]->accept(eg);
152
// save the bool result
153
eg->
setPassSelection
(
static_cast<
bool
>
(accept),
154
m_genericIsEMselectorResultNames
[i]);
155
// save the isem
156
eg->
setSelectionisEM
(
157
static_cast<
unsigned
int
>
(accept.getCutResultInverted()),
158
"isEM"
+
m_genericIsEMselectorResultNames
[i]);
159
}
160
161
return
StatusCode::SUCCESS;
162
}
163
AcceptData.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition
AthMsgStreamMacros.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
errorcheck.h
Helpers for checking error return status codes and reporting errors.
EMPIDBuilder.h
Egamma.h
size
size_t size() const
Number of registered mappings.
EMPIDBuilder::m_lumiBlockMuTool
ToolHandle< ILumiBlockMuTool > m_lumiBlockMuTool
Definition
EMPIDBuilder.h:100
EMPIDBuilder::m_photonIsEMselectors
ToolHandleArray< IAsgPhotonIsEMSelector > m_photonIsEMselectors
Definition
EMPIDBuilder.h:87
EMPIDBuilder::m_electronIsEMselectorResultNames
Gaudi::Property< std::vector< std::string > > m_electronIsEMselectorResultNames
Definition
EMPIDBuilder.h:53
EMPIDBuilder::EMPIDBuilder
EMPIDBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
Definition
EMPIDBuilder.cxx:14
EMPIDBuilder::m_electronIsEMselectors
ToolHandleArray< IAsgElectronIsEMSelector > m_electronIsEMselectors
Handle to the selectors.
Definition
EMPIDBuilder.h:47
EMPIDBuilder::m_genericIsEMselectorResultNames
Gaudi::Property< std::vector< std::string > > m_genericIsEMselectorResultNames
Definition
EMPIDBuilder.h:80
EMPIDBuilder::m_photonIsEMselectorResultNames
Gaudi::Property< std::vector< std::string > > m_photonIsEMselectorResultNames
Definition
EMPIDBuilder.h:93
EMPIDBuilder::m_UselumiBlockMuTool
Gaudi::Property< bool > m_UselumiBlockMuTool
Definition
EMPIDBuilder.h:112
EMPIDBuilder::m_electronLHselectorResultNames
Gaudi::Property< std::vector< std::string > > m_electronLHselectorResultNames
Definition
EMPIDBuilder.h:66
EMPIDBuilder::m_electronLHselectors
ToolHandleArray< IAsgElectronLikelihoodTool > m_electronLHselectors
Definition
EMPIDBuilder.h:60
EMPIDBuilder::initialize
virtual StatusCode initialize() override final
initialize method
Definition
EMPIDBuilder.cxx:24
EMPIDBuilder::execute
virtual StatusCode execute(const EventContext &ctx, xAOD::Egamma *) const override final
standard execute method
Definition
EMPIDBuilder.cxx:75
EMPIDBuilder::m_genericIsEMselectors
ToolHandleArray< IAsgSelectionTool > m_genericIsEMselectors
Definition
EMPIDBuilder.h:73
asg::AcceptData
Definition
AcceptData.h:31
egammaBaseTool::egammaBaseTool
egammaBaseTool(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
Definition
egammaBaseTool.cxx:7
xAOD::Egamma_v1::setSelectionisEM
void setSelectionisEM(unsigned int value, const std::string &isEM)
Set the isEM word for a selection menu (using the name).
Definition
Egamma_v1.cxx:436
xAOD::Egamma_v1::setPassSelection
void setPassSelection(bool value, const std::string &menu)
Set the selection decision for a menu (using the name).
xAOD::Egamma
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition
Egamma.h:17
type
Generated on
for ATLAS Offline Software by
1.17.0