ATLAS Offline Software
Loading...
Searching...
No Matches
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"
8#include "xAODEgamma/Egamma.h"
9
10namespace {
11const SG::AuxElement::Accessor<float> accLH("LHValue");
12}
13
15 const std::string& name,
16 const IInterface* parent)
17 : egammaBaseTool(type, name, parent)
18{
19 // declare interface
20 declareInterface<IegammaBaseTool>(this);
21}
22
23StatusCode
25{
26 ATH_MSG_DEBUG(" Initializing EMPIDBuilder");
27
29
30 if (m_electronIsEMselectors.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
38
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
46
47 if (m_genericIsEMselectors.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
55
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
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
74StatusCode
75EMPIDBuilder::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),
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 "
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),
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 "
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),
137 // save the isem
138 eg->setSelectionisEM(
139 static_cast<unsigned int>(accept.getCutResultInverted()),
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),
155 // save the isem
156 eg->setSelectionisEM(
157 static_cast<unsigned int>(accept.getCutResultInverted()),
159 }
160
161 return StatusCode::SUCCESS;
162}
163
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
ToolHandle< ILumiBlockMuTool > m_lumiBlockMuTool
ToolHandleArray< IAsgPhotonIsEMSelector > m_photonIsEMselectors
Gaudi::Property< std::vector< std::string > > m_electronIsEMselectorResultNames
EMPIDBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
ToolHandleArray< IAsgElectronIsEMSelector > m_electronIsEMselectors
Handle to the selectors.
Gaudi::Property< std::vector< std::string > > m_genericIsEMselectorResultNames
Gaudi::Property< std::vector< std::string > > m_photonIsEMselectorResultNames
Gaudi::Property< bool > m_UselumiBlockMuTool
Gaudi::Property< std::vector< std::string > > m_electronLHselectorResultNames
ToolHandleArray< IAsgElectronLikelihoodTool > m_electronLHselectors
virtual StatusCode initialize() override final
initialize method
virtual StatusCode execute(const EventContext &ctx, xAOD::Egamma *) const override final
standard execute method
ToolHandleArray< IAsgSelectionTool > m_genericIsEMselectors
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
egammaBaseTool(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17