19 {
20
21
22
23
24
25 METMakerAlg::~METMakerAlg() = default;
26
27
28
29 StatusCode METMakerAlg::initialize() {
32
33
34 if( m_metmaker.retrieve().isFailure() ) {
35 ATH_MSG_ERROR(
"Failed to retrieve tool: " << m_metmaker->name());
36 return StatusCode::FAILURE;
37 };
38
39 if( m_muonSelTool.retrieve().isFailure() ) {
40 ATH_MSG_ERROR(
"Failed to retrieve tool: " << m_muonSelTool->name());
41 return StatusCode::FAILURE;
42 };
43
44 if( m_elecSelLHTool.retrieve().isFailure() ) {
45 ATH_MSG_ERROR(
"Failed to retrieve tool: " << m_elecSelLHTool->name());
46 return StatusCode::FAILURE;
47 };
48
49 if( m_photonSelIsEMTool.retrieve().isFailure() ) {
50 ATH_MSG_ERROR(
"Failed to retrieve tool: " << m_photonSelIsEMTool->name());
51 return StatusCode::FAILURE;
52 };
53
54 if( m_tauSelTool.retrieve().isFailure() ) {
55 ATH_MSG_ERROR(
"Failed to retrieve tool: " << m_tauSelTool->name());
56 return StatusCode::FAILURE;
57 };
58 ATH_CHECK( m_ElectronContainerKey.initialize() );
59 ATH_CHECK( m_PhotonContainerKey.initialize() );
60 ATH_CHECK( m_TauJetContainerKey.initialize() );
61 ATH_CHECK( m_MuonContainerKey.initialize() );
62 ATH_CHECK( m_JetContainerKey.initialize() );
66
67 return StatusCode::SUCCESS;
68 }
69
70
71
72 StatusCode METMakerAlg::finalize() {
74 return StatusCode::SUCCESS;
75 }
76
77
78
79 StatusCode METMakerAlg::execute(const EventContext& ctx) const {
81
82
84 ATH_CHECK( metHandle.record (std::make_unique<xAOD::MissingETContainer>(),
85 std::make_unique<xAOD::MissingETAuxContainer>()) );
87
89 if (!metMap.isValid()) {
90 ATH_MSG_WARNING(
"Unable to retrieve MissingETAssociationMap: " << m_metMapKey.key());
91 return StatusCode::FAILURE;
92 }
93
95
96
99 if (!coreMet.isValid()) {
100 ATH_MSG_WARNING(
"Unable to retrieve MissingETContainer: " << m_CoreMetKey.key());
101 return StatusCode::FAILURE;
102 }
103
104
107 if (!
Jets.isValid()) {
109 return StatusCode::FAILURE;
110 }
111
114 if (!Electrons.isValid()) {
115 ATH_MSG_WARNING(
"Unable to retrieve ElectronContainer: " << Electrons.key());
116 return StatusCode::FAILURE;
117 }
118
121 if (!
Gamma.isValid()) {
123 return StatusCode::FAILURE;
124 }
125
128 if (!TauJets.isValid()) {
129 ATH_MSG_WARNING(
"Unable to retrieve TauJetContainer: " << TauJets.key());
130 return StatusCode::FAILURE;
131 }
132
135 if (!
Muons.isValid()) {
137 return StatusCode::FAILURE;
138 }
139
140
141
144
145 if(!m_ElectronContainerKey.empty()) {
147 for(const auto *const el : *Electrons) {
149 metElectrons.push_back(el);
150
151 }
152 }
154 metElectrons.asDataVector(),
155 metHelper, objScale).isFailure() ) {
157 }
158 ATH_MSG_DEBUG(
"Selected " << metElectrons.size() <<
" MET electrons. "
159 << getMETElements(*(*newMet)[
"RefEle"]).
size() <<
" are non-overlapping.");
160 }
161
162
163 if(!m_PhotonContainerKey.empty()) {
165 for(const auto *const ph : *Gamma) {
167 metPhotons.push_back(ph);
168 }
169 }
171 metPhotons.asDataVector(),
172 metHelper, objScale).isFailure() ) {
174 }
175 ATH_MSG_DEBUG(
"Selected " << metPhotons.size() <<
" MET photons. "
176 << getMETElements(*(*newMet)[
"RefGamma"]).
size() <<
" are non-overlapping.");
177 }
178
179
180 if(!m_TauJetContainerKey.empty()) {
182 for(const auto *const tau : *TauJets) {
184 metTaus.push_back(tau);
185 }
186 }
188 metTaus.asDataVector(),
189 metHelper, objScale).isFailure() ){
191 }
193 << getMETElements(*(*newMet)[
"RefTau"]).
size() <<
" are non-overlapping.");
194 }
195
196
197 if(!m_MuonContainerKey.empty()) {
199 for(
const auto *
const mu : *
Muons) {
201 metMuons.push_back(mu);
202 }
203 }
204
207 metMuons.asDataVector(),
208 metHelper, objScale).isFailure() ) {
210 }
211 ATH_MSG_DEBUG(
"Selected " << metMuons.size() <<
" MET muons. "
212 << getMETElements(*(*newMet)[
"Muons"]).
size() <<
" are non-overlapping.");
213 }
214
215 if( m_metmaker->rebuildJetMET("RefJet", m_softclname, m_softtrkname, newMet,
216 Jets.cptr(), coreMet.cptr(), metHelper,
false ).isFailure() ) {
218 }
220 << getMETElements(*(*newMet)[
"RefJet"]).
size() <<
" are non-overlapping, "
221 << getMETElements(*(*newMet)[m_softtrkname]).
size() <<
" are soft");
222
223 auto jets_and_weights = getMETElementsWeights<xAOD::Jet>(*(*newMet)["RefJet"]);
224 for (
const auto& [
jet, weight] : jets_and_weights) {
226 << " contributes with weight " <<weight
227 );
228 }
229
230
232 if((*newMet)[m_softtrkname]) trksource = (*newMet)[m_softtrkname]->source();
233 if( buildMETSum("FinalTrk", newMet, trksource).isFailure() ){
235 }
237 if((*newMet)[m_softclname]) clsource = (*newMet)[m_softclname]->source();
238 if( buildMETSum("FinalClus", newMet, clsource).isFailure() ) {
240 }
241
242 return StatusCode::SUCCESS;
243 }
244
245
246
247 bool METMakerAlg::accept(
const xAOD::Muon* mu)
const
248 {
249 if(
mu->pt()<2.5e3 ||
mu->pt()/cosh(
mu->eta())<4e3 )
return false;
250 return static_cast<bool>(m_muonSelTool->accept(*mu));
251 }
252
254 {
255 if( fabs(
el->eta())>2.47 ||
el->pt()<10e3 )
return false;
256 return static_cast<bool> (m_elecSelLHTool->accept(el));
257 }
258
260 {
261 if( !(ph->
author()&20) || fabs(ph->
eta())>2.47 || ph->
pt()<10e3 )
return false;
262 return static_cast<bool> (m_photonSelIsEMTool->accept(ph));
263 }
264
266 {
267 return static_cast<bool>(m_tauSelTool->accept( *tau ));
268 }
269
270}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
size_t size() const
Number of registered mappings.
DataVector adapter that acts like it holds const pointers.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
uint16_t author(uint16_t bitmask=EgammaParameters::AuthorALL) const
Get author.
StatusCode accept(const xAOD::Muon *mu)
uint64_t bitmask_t
Type for status word bit mask.
Policy
Policies on usage checks.
@ OnlyTrack
Track based only.
@ TruthParticle
Truth particle based.
@ PhysicsObject
Physics object based.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
@ Photon
The object is a photon.
@ Muon
The object is a muon.
@ Electron
The object is an electron.
@ Tau
The object is a tau (jet).
TauJet_v3 TauJet
Definition of the current "tau version".
MissingETContainer_v1 MissingETContainer
Muon_v1 Muon
Reference the current persistent version:
Photon_v1 Photon
Definition of the current "egamma version".
Electron_v1 Electron
Definition of the current "egamma version".
@ LCTopo
Indicator for MET contribution from TopoClusters with LCW calibration applied.
@ Track
Indicator for MET contribution from reconstructed charged particle tracks.