ATLAS Offline Software
Loading...
Searching...
No Matches
Jets.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// This source file implements all of the functions related to Jets
6// in the SUSYObjDef_xAOD class
7
8// Local include(s):
10
13
20
24
26
29#ifndef XAOD_STANDALONE // For now metadata is Athena-only
31#endif
32
33namespace ST {
34
35 const static SG::Decorator<char> dec_bad("bad");
36
37 const static SG::Decorator<char> dec_passJvt("passJvt");
38 const static SG::ConstAccessor<char> acc_passJvt("passJvt");
39 const static SG::Decorator<char> dec_passFJvt("passFJvt");
40 const static SG::ConstAccessor<char> acc_passFJvt("passFJvt");
41
42 const static SG::Decorator<float> dec_jvt("Jvt");
43 const static SG::ConstAccessor<float> acc_jvt("NNJvt");
44 const static SG::Decorator<float> dec_fjvt("fJvt");
45 const static SG::ConstAccessor<float> acc_fjvt("DFCommonJets_fJvt");
46
47 const static SG::Decorator<char> dec_bjet("bjet");
48
49 const static SG::Decorator<char> dec_bjet_jetunc("bjet_jetunc"); //added for JetUncertainties usage
50 const static SG::Decorator<char> dec_bjet_loose("bjet_loose");
51
52 const static SG::Decorator<double> dec_btag_weight("btag_weight");
53 const static SG::Decorator<float> dec_btag_pb("btag_pb");
54 const static SG::Decorator<float> dec_btag_pc("btag_pc");
55 const static SG::Decorator<float> dec_btag_pu("btag_pu");
56 const static SG::Decorator<float> dec_btag_ptau("btag_ptau");
57 // for backwards compatibility
58 const static SG::Decorator<float> dec_btag_dl1pb("btag_dl1pb");
59 const static SG::Decorator<float> dec_btag_dl1pc("btag_dl1pc");
60 const static SG::Decorator<float> dec_btag_dl1pu("btag_dl1pu");
61
62
63 const static SG::Decorator<float> dec_VRradius("VRradius");
64 const static SG::ConstAccessor<float> acc_VRradius("VRradius");
65
66 const static SG::Decorator<char> dec_passDRcut("passDRcut");
67 const static SG::ConstAccessor<char> acc_passDRcut("passDRcut");
68
69 const static SG::Decorator<int> dec_wtagged("wtagged");
70 const static SG::Decorator<int> dec_ztagged("ztagged");
71 const static SG::Decorator<int> dec_toptagged("toptagged");
72
73 StatusCode SUSYObjDef_xAOD::GetJets(xAOD::JetContainer*& copy, xAOD::ShallowAuxContainer*& copyaux, bool recordSG, const std::string& jetkey, const xAOD::JetContainer* containerToBeCopied)
74 {
75 if (!m_tool_init) {
76 ATH_MSG_ERROR("SUSYTools was not initialized!!");
77 return StatusCode::FAILURE;
78 }
79
80 if (m_isPHYSLITE && jetkey.find("AnalysisJets") == std::string::npos){
81 ATH_MSG_ERROR("You are running on PHYSLITE derivation. Please change the Jets container to 'AnalysisJets'");
82 return StatusCode::FAILURE;
83 }
84
85 ATH_MSG_DEBUG("Default jetkey: " << m_defaultJets);
86 ATH_MSG_DEBUG("Function argument jetkey: " << jetkey);
87
88 // load default regular & btag jet keys
89 std::string jetkey_tmp = m_defaultJets; // use default for regular jetkey_tmp
90
91 // override default if user is passing a jetkey
92 if (!jetkey.empty()) {
93 jetkey_tmp = jetkey;
94 }
95
96 // final settings
97 ATH_MSG_DEBUG("Key for retrieving jet collection: jetkey = " << jetkey_tmp);
98
99 const xAOD::JetContainer* jets = nullptr;
100 if (copy==nullptr) { // empty container provided
101 if (containerToBeCopied != nullptr) {
102 jets = containerToBeCopied;
103 }
104 else {
105 ATH_MSG_DEBUG("Retrieve jet collection: " << jetkey_tmp);
106 ATH_CHECK( evtStore()->retrieve(jets, jetkey_tmp) );
107 }
109 copy = shallowcopy.first.get();
110 copyaux = shallowcopy.second.get();
111 bool setLinks = xAOD::setOriginalObjectLink(*jets, *copy);
112 if (!setLinks) {
113 ATH_MSG_WARNING("Failed to set original object links on " << jetkey_tmp);
114 }
115 if (recordSG) {
116 std::string auxname = copyaux->name();
117 if (auxname.compare("UNKNOWN")==0) copyaux->setName(std::string("STCalib" + jetkey_tmp + m_currentSyst.name() + "AuxCopy").c_str());
118 ATH_CHECK( evtStore()->record(std::move(shallowcopy.first), "STCalib" + jetkey_tmp + m_currentSyst.name()) );
119 ATH_CHECK( evtStore()->record(std::move(shallowcopy.second), "STCalib" + jetkey_tmp + m_currentSyst.name() + "Aux.") );
120 } else {
121 ATH_MSG_ERROR("Shallow copy not recorded in StoreGate!");
122 return StatusCode::FAILURE;
123 }
124 } else { // use the user-supplied collection instead
125 ATH_MSG_DEBUG("Not retrieving jet collecton, using existing one provided by user");
126 jets = copy;
127 }
128
129 // Calibrate the jets
130 ATH_CHECK(m_jetCalibTool->applyCalibration(*copy));
131
132 // Add isHS labels to jets (required for JvtEfficiencyTools)
133 if (!isData()) {
134 ATH_CHECK(m_jetPileupLabelingTool->decorate(*copy));
135 }
136
137 // Calculate Jvt scores (required by METSignificance)
138 for (const auto jet : *copy) {
139 dec_jvt(*jet) = m_jetJvtMomentTool->updateJvt(*jet);
140 }
141
142 // Re-calculate NNJvt scores
143 if (m_applyJVTCut) ATH_CHECK(m_jetNNJvtMomentTool->decorate(*copy));
144
145 // Update the jets
146 for (const auto jet : *copy) {
147 ATH_CHECK( this->FillJet(*jet) );
148 }
149
150 for (const auto jet : *copy) {
151 // Update the JVT decorations if needed
152 if( m_doFwdJVT){
154 dec_fjvt(*jet) = acc_fjvt(*jet);
155
156 //new state for OR . 0=non-baseline objects, 1=for baseline jets not passing JVT, 2=for any other baseline object
157 if ( acc_baseline(*jet) ){
158 if( acc_passJvt(*jet) ) dec_selected(*jet) = 2;
159 else dec_selected(*jet) = 1;
160 }
161 else{
162 dec_selected(*jet) = 0;
163 }
164 }
165 this->IsBadJet(*jet);
167 if (!isData())this->IsTruthBJet(*jet);
168 }
169
170 return StatusCode::SUCCESS;
171 }
172
173 StatusCode SUSYObjDef_xAOD::GetTrackJets(xAOD::JetContainer*& copy, xAOD::ShallowAuxContainer*& copyaux, bool recordSG, const std::string& jetkey, const xAOD::JetContainer* containerToBeCopied)
174 {
175 if (!m_tool_init) {
176 ATH_MSG_ERROR("SUSYTools was not initialized!!");
177 return StatusCode::FAILURE;
178 }
179
180 ATH_MSG_DEBUG("Default jetkey (trkjet): " << m_defaultTrackJets);
181 ATH_MSG_DEBUG("Function argument jetkey (trkjet): " << jetkey);
182
183 // load default regular & btag jet keys
184 std::string jetkey_tmp = m_defaultTrackJets;
185
186 // override default if user is passing a jetkey
187 if (!jetkey.empty()) {
188 jetkey_tmp = jetkey;
189 }
190
191 // final settings
192 ATH_MSG_DEBUG("Key for retrieving trkjet collection (as well as bjet info): jetkey = " << jetkey_tmp);
193
194 const xAOD::JetContainer* jets = nullptr;
195 if (copy==nullptr) { // empty container provided
196 if (containerToBeCopied != nullptr) {
197 jets = containerToBeCopied;
198 }
199 else {
200 ATH_MSG_DEBUG("Retrieve jet collection: " << jetkey_tmp);
201 ATH_CHECK( evtStore()->retrieve(jets, jetkey_tmp) );
202 }
204 copy = shallowcopy.first.get();
205 copyaux = shallowcopy.second.get();
206 bool setLinks = xAOD::setOriginalObjectLink(*jets, *copy);
207 if (!setLinks) {
208 ATH_MSG_WARNING("Failed to set original object links on " << jetkey_tmp);
209 }
210 if (recordSG) {
211 ATH_CHECK( evtStore()->record(std::move(shallowcopy.first), "STCalib" + jetkey_tmp + m_currentSyst.name()) );
212 ATH_CHECK( evtStore()->record(std::move(shallowcopy.second), "STCalib" + jetkey_tmp + m_currentSyst.name() + "Aux.") );
213 } else {
214 ATH_MSG_ERROR("Shallow copy not recorded in StoreGate!");
215 return StatusCode::FAILURE;
216 }
217 } else { // use the user-supplied collection instead
218 ATH_MSG_DEBUG("Not retrieving jet collection, using existing one provided by user");
219 jets = copy;
220 }
221
222 //disable - notfortrackjets? // Calibrate the jets
223 //disable - notfortrackjets? ATH_CHECK(m_jetCalibTool->applyCalibration(*copy));
224
225 // Update the jets
226 for (const auto jet : *copy) {
227 ATH_CHECK( this->FillTrackJet(*jet) );
228 }
229
230 if (copy->size() > 1 && m_defaultTrackJets == "AntiKtVR30Rmax4Rmin02TrackJets") {
231 // Use iterators to avoid pairing the jets twice
232 for (xAOD::JetContainer::const_iterator j1 = copy->begin()+1; j1!= copy->end();++j1) {
233 const xAOD::Jet* jet1 = (*j1);
234 if (!acc_signal(*jet1)) continue;
235 for (xAOD::JetContainer::const_iterator j2 = copy->begin(); j2 != j1; ++j2) {
236 const xAOD::Jet* jet2 = (*j2);
237 if (!acc_baseline(*jet2)) continue;
238 //Reference to the use method in P4Helper: deltaR2( const xAOD::IParticle& p4, const xAOD::IParticle& , bool useRapidity=true )
239 float dr_jets = xAOD::P4Helpers::deltaR(jet1,jet2, false);
240 const xAOD::Jet* to_check = acc_VRradius(*jet1) < acc_VRradius(*jet2) ? jet1 : jet2;
241 if( dr_jets < acc_VRradius(*to_check)) dec_passDRcut(*to_check) = false;
242 //break the loop at this point???
243 }
244 }
245 }
246
247 return StatusCode::SUCCESS;
248 }
249
250 StatusCode SUSYObjDef_xAOD::GetFatJets(xAOD::JetContainer*& copy, xAOD::ShallowAuxContainer*& copyaux, bool recordSG, const std::string& jetkey, const bool doLargeRdecorations, const xAOD::JetContainer* containerToBeCopied)
251 {
252 if (!m_tool_init) {
253 ATH_MSG_ERROR("SUSYTools was not initialized!!");
254 return StatusCode::FAILURE;
255 }
256
257 if (m_fatJets.empty()) {
258 ATH_MSG_ERROR("JetFatCalibTool was not initialized for largeR jet!!");
259 return StatusCode::FAILURE;
260 }
261
262 std::string jetkey_tmp = jetkey;
263 if (jetkey.empty()) {
264 jetkey_tmp = m_fatJets;
265 }
266
267 const xAOD::JetContainer* jets = nullptr;
268 if (copy==nullptr) { // empty container provided
269 if (containerToBeCopied != nullptr) {
270 jets = containerToBeCopied;
271 }
272 else {
273 ATH_MSG_DEBUG("Retrieve jet collection: " << jetkey_tmp);
274 ATH_CHECK( evtStore()->retrieve(jets, jetkey_tmp) );
275 }
276
278 copy = shallowcopy.first.get();
279 copyaux = shallowcopy.second.get();
280 bool setLinks = xAOD::setOriginalObjectLink(*jets, *copy);
281 if (!setLinks) {
282 ATH_MSG_WARNING("Failed to set original object links on " << jetkey_tmp);
283 }
284 if (recordSG) {
285 ATH_CHECK( evtStore()->record(std::move(shallowcopy.first), "STCalib" + jetkey_tmp + m_currentSyst.name()) );
286 ATH_CHECK( evtStore()->record(std::move(shallowcopy.second), "STCalib" + jetkey_tmp + m_currentSyst.name() + "Aux.") );
287 } else {
288 ATH_MSG_ERROR("Shallow copy not recorded in StoreGate!");
289 return StatusCode::FAILURE;
290 }
291 } else { // use the user-supplied collection instead
292 ATH_MSG_DEBUG("Not retrieving jet collection, using existing one provided by user");
293 jets=copy;
294 }
295
296 if(jets->size()==0) {
297 ATH_MSG_DEBUG("Large R jet collection is empty");
298 return StatusCode::SUCCESS;
299 }
300
301 // Calibrate the jets - only insitu for data for now
302 if (isData()) ATH_CHECK(m_jetFatCalibTool->applyCalibration(*copy));
303
304
305 if (!isData() && !m_JetTruthLabelName.empty()){
306 ATH_MSG_DEBUG("Checking if decorator for JetTruthLabelingTool is available:");
307 std::string fatjetcoll = m_fatJets;
308 m_label_truthKey = fatjetcoll+"."+m_JetTruthLabelName;
310 ATH_MSG_DEBUG("Reading JetTruthLabelingTool truthKey:" << m_label_truthKey << " isAvailable " << labelHandle_truthKey.isAvailable());
311 // Truth Labeling (MC only)
312 if (!labelHandle_truthKey.isAvailable() && !m_isPHYSLITE) ATH_CHECK(m_jetTruthLabelingTool->decorate(*copy));
313 }
314
315
316 // apply boosted jet taggers
317 if (!m_WtagConfig.empty())
318 ATH_CHECK(m_WTaggerTool->decorate(*copy));
319 if (!m_ZtagConfig.empty())
320 ATH_CHECK(m_ZTaggerTool->decorate(*copy));
321
322 for (const auto jet : *copy) {
323 ATH_CHECK( this->FillJet(*jet, true, true, doLargeRdecorations) );
324 //
325 // For OR, selected if it passed cuts
326 if ( acc_baseline(*jet) ){
327 dec_selected(*jet) = 1;
328 }
329 else{
330 dec_selected(*jet) = 0;
331 }
332 }
333
334 return StatusCode::SUCCESS;
335 }
336
337
338 StatusCode SUSYObjDef_xAOD::GetJetsSyst(const xAOD::JetContainer& calibjets, xAOD::JetContainer*& copy, xAOD::ShallowAuxContainer*& copyaux, bool recordSG, const std::string& jetkey)
339 {
340 if (!m_tool_init) {
341 ATH_MSG_ERROR("SUSYTools was not initialized!!");
342 return StatusCode::FAILURE;
343 }
344
345 std::string jetkey_tmp = jetkey;
346 if (jetkey.empty()) {
347 jetkey_tmp = m_defaultJets;
348 }
349
351 copy = shallowcopy.first.get();
352 copyaux = shallowcopy.second.get();
353
354 bool setLinks = xAOD::setOriginalObjectLink(calibjets, *copy);
355 if (!setLinks) {
356 ATH_MSG_WARNING("Failed to set original object links on " << jetkey_tmp);
357 }
358
359 // ghost associate the muons to the jets (needed by MET muon-jet OR later)
360 ATH_MSG_VERBOSE("Run muon-to-jet ghost association");
361 const xAOD::MuonContainer* muons = nullptr;
362 // Do a little guessing
363 if (jetkey!="AnalysisJets"){
364 ATH_CHECK( evtStore()->retrieve(muons, "Muons") );
365 } else {
366 ATH_CHECK( evtStore()->retrieve(muons, "AnalysisMuons") );
367 }
368 met::addGhostMuonsToJets(*muons, *copy);
369
370 // Update the jets
371 for (const auto jet : *copy) {
372 ATH_CHECK( this->FillJet(*jet, false) );
373 }
374
375 for (const auto jet : *copy) {
376 // Update the JVT decorations if needed
377 if( m_doFwdJVT){
379
380 //new state for OR . 0=non-baseline objects, 1=for baseline jets not passing JVT, 2=for any other baseline object
381 if ( acc_baseline(*jet) ){
382 if( acc_passJvt(*jet) ) dec_selected(*jet) = 2;
383 else dec_selected(*jet) = 1;
384 }
385 else{
386 dec_selected(*jet) = 0;
387 }
388 }
389 this->IsBadJet(*jet);
391 if (!isData())this->IsTruthBJet(*jet);
392 }
393 if (recordSG) {
394 ATH_CHECK( evtStore()->record(std::move(shallowcopy.first), "STCalib" + jetkey_tmp + m_currentSyst.name()) );
395 ATH_CHECK( evtStore()->record(std::move(shallowcopy.second), "STCalib" + jetkey_tmp + m_currentSyst.name() + "Aux.") );
396 } else {
397 ATH_MSG_ERROR("Shallow copy not recorded in StoreGate!");
398 return StatusCode::FAILURE;
399 }
400 return StatusCode::SUCCESS;
401 }
402
403 StatusCode SUSYObjDef_xAOD::FillJet(xAOD::Jet& input, bool doCalib, bool isFat, bool doLargeRdecorations) {
404
405 ATH_MSG_VERBOSE( "Starting FillJet on jet with pt=" << input.pt() );
406 ATH_MSG_VERBOSE( "jet (pt,eta,phi) before calibration " << input.pt() << " " << input.eta() << " " << input.phi() );
407
408 static const SG::ConstAccessor<char> acc_wValidKinRange(m_WDecorName+"_ValidKinRange");
409 static const SG::ConstAccessor<char> acc_zValidKinRange(m_ZDecorName+"_ValidKinRange");
410 static const SG::ConstAccessor<char> acc_topValidKinRange(m_TopDecorName+"_ValidKinRange");
411 static const SG::ConstAccessor<char> acc_wtagged(m_WDecorName+"_Tagged");
412 static const SG::ConstAccessor<char> acc_ztagged(m_ZDecorName+"_Tagged");
414
415 if (doCalib) {
416 if(!isFat){
417 //disable - obsoleted ATH_CHECK( m_jetCalibTool->applyCalibration(input) );
418 }
419 else {
420 //disable - obsoleted ATH_CHECK( m_jetFatCalibTool->applyCalibration(input) );
421 dec_baseline(input) = ( input.pt() > m_jetPt ) || ( input.pt() > 20e3 ); // Allows for setting m_jetPt < 20e3
422 dec_bad(input) = false;
423 dec_signal(input) = false;
424 dec_bjet_loose(input) = false;
425 dec_effscalefact(input) = 1.;
426 dec_passOR(input) = true;
427 dec_bjet_jetunc(input) = false;
428 dec_btag_weight(input) = -999.;
429
430 dec_wtagged(input) = -1;
431 dec_ztagged(input) = -1;
432 dec_toptagged(input) = -1;
433 if (doLargeRdecorations) {
434
435 // Retrieve large-R tagging results for W/Z/top
436 if (!m_WtagConfig.empty()) {
437 // Only tag jets if they are inside the kinematic range
438 if ( !acc_wValidKinRange(input) ) {
439 ATH_MSG_VERBOSE("Large-R W candidate jet outside of recommended tagging range. Will set score to 0.");
440 dec_wtagged(input) = 0;
441 }
442 else dec_wtagged(input) = acc_wtagged(input);
443 }
444 if (!m_ZtagConfig.empty()) {
445 // Only tag jets if they are inside the kinematic range
446 if ( !acc_zValidKinRange(input) ) {
447 ATH_MSG_VERBOSE("Large-R Z candidate jet outside of recommended tagging range. Will set score to 0.");
448 dec_ztagged(input) = 0;
449 }
450 else dec_ztagged(input) = acc_ztagged(input);
451 }
452 if (!m_ToptagConfig.empty()) {
453 ATH_CHECK(m_TopTaggerTool->tag(input));
454 // Only tag jets if they are inside the kinematic range
455 if ( !acc_topValidKinRange(input) ) {
456 ATH_MSG_VERBOSE("Large-R Top candidate jet outside of recommended tagging range. Will set score to 0.");
457 dec_toptagged(input) = 0;
458 }
459 else dec_toptagged(input) = acc_toptagged(input);
460 }
461
462 }
463
464 // If a user hasn't specified an uncertainty config, then this tool will be empty
465 // for large R jets
466 if (!m_WTagjetUncertaintiesTool.empty() && !m_WTagUncConfig.empty() && !m_WtagConfig.empty() && doLargeRdecorations) {
467 CP::CorrectionCode result = m_WTagjetUncertaintiesTool->applyCorrection(input);
468 switch (result) {
470 ATH_MSG_ERROR( "Failed to apply largeR W-tag jet scale uncertainties.");
471 return StatusCode::FAILURE;
472 //break;
474 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR W-tag jet scale uncertainties. ");
475 break;
476 default:
477 break;
478 }
479 } else {
480 ATH_MSG_DEBUG( "No valid large-R W-tagged fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
481 }
482
483 if (!m_ZTagjetUncertaintiesTool.empty() && !m_ZTagUncConfig.empty() && !m_ZtagConfig.empty() && doLargeRdecorations) {
484 CP::CorrectionCode result = m_ZTagjetUncertaintiesTool->applyCorrection(input);
485 switch (result) {
487 ATH_MSG_ERROR( "Failed to apply largeR Z-tag jet scale uncertainties.");
488 return StatusCode::FAILURE;
489 //break;
491 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR Z-tag jet scale uncertainties. ");
492 break;
493 default:
494 break;
495 }
496 } else {
497 ATH_MSG_DEBUG( "No valid large-R Z-tagged fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
498 }
499
500 if (!m_TopTagjetUncertaintiesTool.empty() && !m_TopTagUncConfig.empty() && !m_ToptagConfig.empty() && doLargeRdecorations) {
501 CP::CorrectionCode result = m_TopTagjetUncertaintiesTool->applyCorrection(input);
502 switch (result) {
504 ATH_MSG_ERROR( "Failed to apply largeR Top-tag jet scale uncertainties.");
505 return StatusCode::FAILURE;
506 //break;
508 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR Top-tag jet scale uncertainties. ");
509 break;
510 default:
511 break;
512 }
513 } else {
514 ATH_MSG_DEBUG( "No valid large-R Top-tagged fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
515 }
516
517 if (!m_fatjetUncertaintiesTool.empty() && m_currentSyst.name().find("PseudoData") == std::string::npos) {
518 CP::CorrectionCode result = m_fatjetUncertaintiesTool->applyCorrection(input);
519 switch (result) {
521 ATH_MSG_ERROR( "Failed to apply largeR jet scale uncertainties.");
522 return StatusCode::FAILURE;
523 //break;
525 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR jet scale uncertainties. ");
526 break;
527 default:
528 break;
529 }
530 } else {
531 ATH_MSG_DEBUG( "No valid fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
532 }
533
534 // Use the PDSmeared uncertainties tool on the systematic with PseudoData in the name
535 if (!m_fatjetUncertaintiesPDSmearTool.empty() && m_fatJetUncertaintiesPDsmearing && m_currentSyst.name().find("PseudoData")) {
536 CP::CorrectionCode result = m_fatjetUncertaintiesPDSmearTool->applyCorrection(input);
537 switch (result) {
539 ATH_MSG_ERROR( "Failed to apply largeR jet scale PD uncertainties.");
540 return StatusCode::FAILURE;
541 //break;
543 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR jet scale uncertainties. ");
544 break;
545 default:
546 break;
547 }
548 } else {
549 ATH_MSG_DEBUG( "No valid fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
550 }
551
553 CP::CorrectionCode result = m_fatjetFFSmearingTool->applyCorrection(input);
554 switch (result) {
556 ATH_MSG_ERROR( "Failed to apply largeR jet scale uncertainties.");
557 return StatusCode::FAILURE;
558 //break;
560 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR jet scale uncertainties. ");
561 break;
562 default:
563 break;
564 }
565 } else {
566 ATH_MSG_DEBUG( "No valid fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
567 }
568
569 ATH_MSG_VERBOSE( "Large-R jet (pt,eta,phi) after calibration " << input.pt() << " " << input.eta() << " " << input.phi() );
570
571 return StatusCode::SUCCESS;
572 }
573 ATH_MSG_VERBOSE( "jet (pt,eta,phi) after calibration " << input.pt() << " " << input.eta() << " " << input.phi() );
574
575 }
576
577 dec_passOR(input) = true;
578 dec_bjet_jetunc(input) = false;
579
580 if (m_useBtagging) {
581 if (m_BtagWP != "Continuous") this->IsBJet(input);
582 else this->IsBJetContinuous(input);
583 }
584
585 if ( (input.pt() > m_jetPt) || (input.pt() > 15e3) ) {
586 if(!isFat && m_currentSyst.name().find("PseudoData") == std::string::npos) {
587 // Use the normal jet uncertainties tool for this systematic and do not use the PDSmeared initialised tool
588 CP::CorrectionCode result = m_jetUncertaintiesTool->applyCorrection(input);
589 switch (result) {
591 ATH_MSG_ERROR( "Failed to apply JES correction" );
592 break;
594 ATH_MSG_WARNING( "JES correction OutOfValidity range."); // Jet (pt,eta,phi) = (" << input.pt() << ", " << input.eta() << ", " << input.phi() << ")");
595 break;
596 default:
597 break;
598 }
599 }
600 }
601
603 if ( (input.pt() > m_jetPt) || (input.pt() > 15e3) ) {
604 if(!isFat && m_currentSyst.name().find("PseudoData")){
605 // Use the PDSmeared uncertainties tool on the systematic with PseudoData in the name
606 CP::CorrectionCode result = m_jetUncertaintiesPDSmearTool->applyCorrection(input);
607 switch (result) {
609 ATH_MSG_ERROR( "Failed to apply JES correction" );
610 break;
612 ATH_MSG_WARNING( "JES correction OutOfValidity range."); // Jet (pt,eta,phi) = (" << input.pt() << ", " << input.eta() << ", " << input.phi() << ")");
613 break;
614 default:
615 break;
616 }
617 }
618 }
619 }
620
621
622 ATH_MSG_VERBOSE( "jet (pt,eta,phi) after JES correction " << input.pt() << " " << input.eta() << " " << input.phi() );
623
624 dec_passJvt(input) = !m_applyJVTCut || m_jetNNJvtSelectionTool->accept(&input);
625 dec_passFJvt(input) = !m_doFwdJVT || m_jetfJvtSelectionTool->accept(&input);
626 dec_baseline(input) = ( input.pt() > m_jetPt ) || ( input.pt() > 20e3 ); // Allows for setting m_jetPt < 20e3
627 dec_bad(input) = false;
628 dec_signal_less_JVT(input) = false;
629 dec_signal(input) = false;
630 dec_bjet_loose(input) = false;
631 dec_effscalefact(input) = 1.;
632
633 //new state for OR . 0=non-baseline objects, 1=for baseline jets not passing JVT, 2=for any other baseline object
634 if (acc_baseline(input) ){
635 if( acc_passJvt(input) ) dec_selected(input) = 2;
636 else dec_selected(input) = 1;
637 }
638 else{
639 dec_selected(input) = 0;
640 }
641
642 if (m_useBtagging && !m_orBtagWP.empty()) {
643 dec_bjet_loose(input) = this->IsBJetLoose(input);
644 }
645
646 if (m_debug) {
647 ATH_MSG_INFO( "JET pt: " << input.pt() );
648 ATH_MSG_INFO( "JET eta: " << input.eta() );
649 ATH_MSG_INFO( "JET phi: " << input.phi() );
650 ATH_MSG_INFO( "JET E: " << input.e() );
651 ATH_MSG_INFO( "JET Ceta: " << input.jetP4(xAOD::JetConstitScaleMomentum).eta() );
652 ATH_MSG_INFO( "JET Cphi: " << input.jetP4(xAOD::JetConstitScaleMomentum).phi() );
653 ATH_MSG_INFO( "JET CE: " << input.jetP4(xAOD::JetConstitScaleMomentum).e() );
654 ATH_MSG_INFO( "JET Cm: " << input.jetP4(xAOD::JetConstitScaleMomentum).M() ); // fix-me M
655
656 }
657
658 return StatusCode::SUCCESS;
659 }
660
662
663 ATH_MSG_VERBOSE( "Starting FillTrackJet on jet with pt=" << input.pt() );
664
665 dec_btag_weight(input) = -999.;
666 dec_effscalefact(input) = 1.;
667
668 if (m_defaultTrackJets == "AntiKtVR30Rmax4Rmin02TrackJets") {
669 // VR recommendation
670 // https://twiki.cern.ch/twiki/bin/view/AtlasProtected/BTagCalib2017#Recommendations_for_variable_rad
671 dec_baseline(input) = input.pt() >= 5e3 && input.numConstituents() >= 2;
672 if (m_trkJetPt < 10e3)
673 ATH_MSG_WARNING ("The pt threshold of VR jets you set is: " << m_trkJetPt/1000. << " GeV. But VR jets with pt < 10GeV are uncalibrated.");
674 dec_signal(input) = acc_baseline(input) && input.pt() >= m_trkJetPt && std::abs(input.eta()) <= m_trkJetEta;
675 dec_VRradius(input) = std::max(0.02,std::min(0.4,30000./input.pt()));
676 dec_passDRcut(input) = acc_signal(input);
677 } else {
678 dec_baseline(input) = input.pt() >= m_trkJetPt && std::abs(input.eta()) <= m_trkJetEta;
679 dec_signal(input) = acc_baseline(input);
680 }
681
683 if (m_BtagWP_trkJet != "Continuous") this->IsTrackBJet(input);
684 else this->IsTrackBJetContinuous(input);
685 }
686
687 if (m_debug) {
688 ATH_MSG_INFO( "TRK JET pt: " << input.pt() );
689 ATH_MSG_INFO( "TRK JET eta: " << input.eta() );
690 ATH_MSG_INFO( "TRK JET phi: " << input.phi() );
691 ATH_MSG_INFO( "TRK JET E: " << input.e() );
692 }
693
694 return StatusCode::SUCCESS;
695 }
696
697
698 bool SUSYObjDef_xAOD::IsBJetLoose(const xAOD::Jet& input) const {
699 bool isbjet_loose = false;
701 isbjet_loose = bool(m_btagSelTool_OR->accept(input)); //note : b-tag applies only to jet with eta < 2.5
702 return isbjet_loose;
703 }
704
706 char pass_jvt = !m_applyJVTCut || m_jetNNJvtSelectionTool->accept(&input);
707 dec_passJvt(input) = pass_jvt;
708 return pass_jvt;
709 }
710
711 bool SUSYObjDef_xAOD::IsSignalJet(const xAOD::Jet& input, float ptcut, float etacut) const {
712 if ( !acc_baseline(input) || !acc_passOR(input) ) return false;
713
714 if ( input.pt() <= ptcut || std::abs(input.eta()) >= etacut) return false;
715
716 bool isgoodjet = !acc_bad(input) && acc_passJvt(input);
717
718 dec_signal(input) = isgoodjet;
719
720 // For JVT calculation
721 dec_signal_less_JVT(input) = !acc_bad(input);
722
723
724 if (m_debug) {
725 float emfrac, hecf, LArQuality, HECQuality, Timing, fracSamplingMax, NegativeE, AverageLArQF;
726 std::vector<float> sumpttrk_vec;
727
728 input.getAttribute(xAOD::JetAttribute::EMFrac, emfrac);
729 input.getAttribute(xAOD::JetAttribute::HECFrac, hecf);
730 input.getAttribute(xAOD::JetAttribute::LArQuality, LArQuality);
731 input.getAttribute(xAOD::JetAttribute::HECQuality, HECQuality);
732 input.getAttribute(xAOD::JetAttribute::Timing, Timing);
733 input.getAttribute(xAOD::JetAttribute::SumPtTrkPt500, sumpttrk_vec);
734 input.getAttribute(xAOD::JetAttribute::FracSamplingMax, fracSamplingMax);
735 input.getAttribute(xAOD::JetAttribute::NegativeE, NegativeE);
736 input.getAttribute(xAOD::JetAttribute::AverageLArQF, AverageLArQF);
737
738 float sumpttrk;
739 if (!sumpttrk_vec.empty() && this->GetPrimVtx()) {
740 sumpttrk = sumpttrk_vec[this->GetPrimVtx()->index()];
741 } else {
742 sumpttrk = 0.;
743 }
744
745 ATH_MSG_INFO( "JET pt: " << input.pt() );
746 ATH_MSG_INFO( "JET eta: " << input.eta() );
747 ATH_MSG_INFO( "JET emfrac: " << emfrac );
748 ATH_MSG_INFO( "JET hecfrac: " << hecf );
749 ATH_MSG_INFO( "JET LArQuality: " << LArQuality );
750 ATH_MSG_INFO( "JET HECQuality: " << HECQuality );
751 ATH_MSG_INFO( "JET Timing: " << Timing );
752 ATH_MSG_INFO( "JET sumpttrk: " << sumpttrk );
753 ATH_MSG_INFO( "JET fracSamplingMax: " << fracSamplingMax );
754 ATH_MSG_INFO( "JET AverageLArQF: " << AverageLArQF );
755 }
756
757 ATH_MSG_VERBOSE( "JET isbad?: " << static_cast<int>(acc_bad(input)));
758
759 return isgoodjet;
760 }
761
762
763 bool SUSYObjDef_xAOD::IsBadJet(const xAOD::Jet& input) const {
764
765 if ( !acc_passOR(input) ) return false;
766
767 float ptcut = 20e3;
768 if ( m_jetPt < ptcut ) ptcut = m_jetPt;
769
770 bool isPileup = !acc_passJvt(input);
771
772 if ( input.pt() <= ptcut || isPileup ) return false;
773
774 if (m_acc_jetClean.isAvailable(input)) {
775 dec_bad(input) = !m_acc_jetClean(input);
776 } else {
777 ATH_MSG_VERBOSE("DFCommon jet cleaning variable not available ... setting 'bad' decorator to 0.");
778 dec_bad(input) = 0;
779 // the jet cleaning decisions are only calculable at AOD now
780 // dec_bad(input) = m_jetCleaningTool.empty() ? false : !m_jetCleaningTool->keep(input);
781 }
782
783 ATH_MSG_VERBOSE( "JET isbad?: " << static_cast<int>(acc_bad(input)));
784
785 return acc_bad(input);
786 }
787
788
789 bool SUSYObjDef_xAOD::IsBJet(const xAOD::Jet& input) const {
790
791 bool isbjet = bool(m_btagSelTool->accept(input));
792 dec_bjet(input) = isbjet;
793
794 if (SetBtagWeightDecorations(input, m_btagSelTool, m_BtagTagger).isFailure())
795 ANA_MSG_ERROR("Couldn't set b-tag decorations for jet, is-b = " << (isbjet?"true":"false") << ", pT = " << input.pt()/1000.);
796
797 return isbjet;
798 }
799
800 bool SUSYObjDef_xAOD::IsTrackBJet(const xAOD::Jet& input) const {
801
802 bool isbjet = bool(m_btagSelTool_trkJet->accept(input));
803 dec_bjet(input) = isbjet;
804
806 ANA_MSG_ERROR("Couldn't set b-tag decorations for trackjet, is-b = " << (isbjet?"true":"false") << ", pT = " << input.pt()/1000.);
807
808 return isbjet;
809 }
810
813 // Cheatsheet:
814 // returns 6 if between 65% and 0%
815 // returns 5 if between 70% and 65%
816 // returns 4 if between 77% and 70%
817 // returns 3 if between 85% and 77%
818 // returns 2 if between 90% and 85%
819 // returns 1 if between 100% and 90%
820 // returns 0 if smaller than -1e4-> should never happen
821 // return -1 if bigger than 1e4 or not in b-tagging acceptance
823
824 int isbjet = m_btagSelTool->getQuantile(input);
825 dec_bjet(input) = isbjet;
826
828 ANA_MSG_ERROR("Couldn't set continuous b-tag decorations for jet, is-b = " << isbjet << ", pT = " << input.pt()/1000.);
829
830 return isbjet;
831 }
832
834
835 int isbjet = m_btagSelTool_trkJet->getQuantile(input);
836 dec_bjet(input) = isbjet;
837
839 ANA_MSG_ERROR("Couldn't set continuous b-tag decorations for trackjet, is-b = " << isbjet << ", pT = " << input.pt()/1000.);
840
841 return isbjet;
842 }
843
845
846 float totalSF = 1.;
847 for ( const xAOD::Jet* jet : *jets ) {
848
849 float sf = 1.;
850
851 if ( std::abs(jet->eta()) > 2.5 ) {
852 ATH_MSG_VERBOSE( "Trying to retrieve b-tagging SF for jet with |eta|>2.5 (jet eta=" << jet->eta() << "), jet will be skipped");
853 } else if ( jet->pt() < 20e3 ){
854 ATH_MSG_VERBOSE( "Trying to retrieve b-tagging SF for jet with invalid pt (jet pt=" << jet->pt() << "), jet will be skipped");
855 } else {
856
857 CP::CorrectionCode result;
858 int truthlabel(-1);
859 if (!jet->getAttribute("HadronConeExclTruthLabelID", truthlabel)) {
860 ATH_MSG_ERROR("Failed to get jet truth label!");
861 }
862 ATH_MSG_VERBOSE("This jet is " << (acc_bjet(*jet) ? "" : "not ") << "b-tagged.");
863 ATH_MSG_VERBOSE("This jet's truth label is " << truthlabel);
864
865 if ( acc_bjet(*jet) or m_BtagWP == "Continuous") {
866 result = m_btagEffTool->getScaleFactor(*jet, sf);
867
868 switch (result) {
870 ATH_MSG_ERROR( "Failed to retrieve SF for b-tagged jets in SUSYTools_xAOD::BtagSF" );
871 break;
873 ATH_MSG_VERBOSE( "No valid SF for b-tagged jets in SUSYTools_xAOD::BtagSF" );
874 break;
875 default:
876 ATH_MSG_VERBOSE( "Retrieve SF for b-tagged jets in SUSYTools_xAOD::BtagSF with value " << sf );
877 }
878 } else {
879
880 result = m_btagEffTool->getInefficiencyScaleFactor(*jet, sf);
881
882 switch (result) {
884 ATH_MSG_ERROR( "Failed to retrieve SF for non-b-tagged jets in SUSYTools_xAOD::BtagSF" );
885 break;
887 ATH_MSG_VERBOSE( "No valid inefficiency SF for non-b-tagged jets in SUSYTools_xAOD::BtagSF" );
888 break;
889 default:
890 ATH_MSG_VERBOSE( "Retrieve SF for non-b-tagged jets in SUSYTools_xAOD::BtagSF with value " << sf );
891 }
892 }
893 }
894
895 dec_effscalefact(*jet) = sf;
896
897 if( acc_signal(*jet) && acc_passOR(*jet) ) totalSF *= sf; //consider goodjets only
898
899 }
900
901 return totalSF;
902 }
903
904
906 {
907 float totalSF = 1.;
908
909 //Set the new systematic variation
910 StatusCode ret = m_btagEffTool->applySystematicVariation(systConfig);
911 if ( ret != StatusCode::SUCCESS) {
912 ATH_MSG_ERROR("Cannot configure BTaggingEfficiencyTool for systematic var. " << systConfig.name() );
913 }
914
915 totalSF = BtagSF( jets );
916
917 ret = m_btagEffTool->applySystematicVariation(m_currentSyst);
918 if ( ret != StatusCode::SUCCESS) {
919 ATH_MSG_ERROR("Cannot configure BTaggingEfficiencyTool for systematic var. " << systConfig.name() );
920 }
921
922 return totalSF;
923 }
924
926
927 float totalSF = 1.;
928 for ( const xAOD::Jet* trkjet : *trkjets ) {
929
930 float sf = 1.;
931
932 if ( std::abs(trkjet->eta()) > 2.5 ) {
933 ATH_MSG_VERBOSE( "Trying to retrieve b-tagging SF for trkjet with |eta|>2.5 (trkjet eta=" << trkjet->eta() << "), trkjet will be skipped");
934 } else if ( trkjet->pt() < 10e3 ){
935 ATH_MSG_VERBOSE( "Trying to retrieve b-tagging SF for trkjet with invalid pt (trkjet pt=" << trkjet->pt() << "), jet will be skipped");
936 } else {
937
938 CP::CorrectionCode result;
939 int truthlabel(-1);
940 if (!trkjet->getAttribute("HadronConeExclTruthLabelID", truthlabel)) {
941 ATH_MSG_ERROR("Failed to get jet truth label!");
942 }
943 ATH_MSG_VERBOSE("This jet is " << (acc_bjet(*trkjet) ? "" : "not ") << "b-tagged.");
944 ATH_MSG_VERBOSE("This jet's truth label is " << truthlabel);
945
946 if ( acc_bjet(*trkjet) ) {
947 result = m_btagEffTool_trkJet->getScaleFactor(*trkjet, sf);
948
949 switch (result) {
951 ATH_MSG_ERROR( "Failed to retrieve SF for b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet" );
952 break;
954 ATH_MSG_VERBOSE( "No valid SF for b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet" );
955 break;
956 default:
957 ATH_MSG_VERBOSE( "Retrieve SF for b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet with value " << sf );
958 }
959 } else {
960
961 result = m_btagEffTool_trkJet->getInefficiencyScaleFactor(*trkjet, sf);
962
963 switch (result) {
965 ATH_MSG_ERROR( "Failed to retrieve SF for non-b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet" );
966 break;
968 ATH_MSG_VERBOSE( "No valid inefficiency SF for non-b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet" );
969 break;
970 default:
971 ATH_MSG_VERBOSE( "Retrieve SF for non-b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet with value " << sf );
972 }
973 }
974 }
975
976 dec_effscalefact(*trkjet) = sf;
977
978 if( acc_signal(*trkjet) ) totalSF *= sf;
979
980 }
981
982 return totalSF;
983 }
984
985
987 {
988 float totalSF = 1.;
989
990 //Set the new systematic variation
991 StatusCode ret = m_btagEffTool_trkJet->applySystematicVariation(systConfig);
992 if ( ret != StatusCode::SUCCESS) {
993 ATH_MSG_ERROR("Cannot configure BTaggingEfficiencyTool (track jets) for systematic var. " << systConfig.name() );
994 }
995
996 totalSF = BtagSF_trkJet( trkjets );
997
998 ret = m_btagEffTool_trkJet->applySystematicVariation(m_currentSyst);
999 if ( ret != StatusCode::SUCCESS) {
1000 ATH_MSG_ERROR("Cannot configure BTaggingEfficiencyTool (track jets) for systematic var. " << systConfig.name() );
1001 }
1002
1003 return totalSF;
1004 }
1005
1007
1008 float totalSF = 1.;
1009 if (!m_applyJVTCut) return totalSF;
1010
1012 for (const xAOD::Jet* jet : *jets) {
1013 // Only jets that were good for every cut except JVT
1015 jvtjets.push_back(jet);
1016 }
1017 }
1018
1019 for (const xAOD::Jet* jet : jvtjets) {
1020 float current_sf = 0;
1021
1022 // the SF are only applied for HS jets and implicitely requires the presence of the isHS decoration
1023 CP::CorrectionCode result;
1024 if (acc_passJvt(*jet)) {
1025 result = m_jetNNJvtEfficiencyTool->getEfficiencyScaleFactor(*jet,current_sf);
1026 }
1027 else {
1028 result = m_jetNNJvtEfficiencyTool->getInefficiencyScaleFactor(*jet,current_sf);
1029 }
1030
1031 switch (result) {
1033 // this is probably not right, should report an error here
1034 ATH_MSG_ERROR("Inexplicably failed JVT calibration" );
1035 break;
1037 // no NNJvt SF for jet, that is ok e.g. for jets with |eta| > 2.5
1038 ATH_MSG_VERBOSE( "Skip SF application in SUSYTools_xAOD::JVT_SF as jet outside validate range" );
1039 break;
1040 default:
1041 ATH_MSG_VERBOSE( "Retrieve SF for jet in SUSYTools_xAOD::JVT_SF with value " << current_sf );
1042 totalSF *= current_sf;
1043 }
1044
1045 }
1046
1047 ATH_MSG_VERBOSE( "Retrieve total SF for jet container in SUSYTools_xAOD::JVT_SF with value " << totalSF );
1048
1049 return totalSF;
1050 }
1051
1052
1053 double SUSYObjDef_xAOD::JVT_SFsys(const xAOD::JetContainer* jets, const CP::SystematicSet& systConfig) {
1054
1055 float totalSF = 1.;
1056 if (!m_applyJVTCut) return totalSF;
1057
1058 //Set the new systematic variation
1059 StatusCode ret = m_jetNNJvtEfficiencyTool->applySystematicVariation(systConfig);
1060 if ( ret != StatusCode::SUCCESS) {
1061 ATH_MSG_ERROR("Cannot configure NNjvtEfficiencyTool for systematic var. " << systConfig.name() );
1062 }
1063
1064 // Delegate
1065 totalSF = SUSYObjDef_xAOD::JVT_SF( jets );
1066
1067 // }
1068 if (m_applyJVTCut) {
1069 ret = m_jetNNJvtEfficiencyTool->applySystematicVariation(m_currentSyst);
1070 if ( ret != StatusCode::SUCCESS) {
1071 ATH_MSG_ERROR("Cannot configure NNjvtEfficiencyTool for systematic var. " << systConfig.name() );
1072 }
1073 }
1074
1075 return totalSF;
1076 }
1077
1079
1080 float totalSF = 1.;
1081 if (!m_doFwdJVT) return totalSF;
1082
1084 for (const xAOD::Jet* jet : *jets) {
1085 // Only jets that were good for every cut except JVT
1087 fjvtjets.push_back(jet);
1088 }
1089 }
1090
1091 for (const xAOD::Jet* jet : fjvtjets) {
1092 float current_sf = 0;
1093
1094 // the SF are only applied for HS jets and implicitely requires the presense of the isHS decoration
1095 CP::CorrectionCode result;
1096 if (acc_passFJvt(*jet)) {
1097 result = m_jetfJvtEfficiencyTool->getEfficiencyScaleFactor(*jet,current_sf);
1098 }
1099 else {
1100 result = m_jetfJvtEfficiencyTool->getInefficiencyScaleFactor(*jet,current_sf);
1101 }
1102
1103 switch (result) {
1105 // this is probably not right, should report an error here
1106 ATH_MSG_ERROR("Inexplicably failed fJVT calibration" );
1107 break;
1109 // no fJvt SF for jet, that is ok e.g. for jets with |eta| < 2.5
1110 ATH_MSG_VERBOSE( "Skip SF application in SUSYTools_xAOD::FJVT_SF as jet outside validate range" );
1111 break;
1112 default:
1113 ATH_MSG_VERBOSE( "Retrieve SF for jet in SUSYTools_xAOD::FJVT_SF with value " << current_sf );
1114 totalSF *= current_sf;
1115 }
1116
1117 }
1118
1119 ATH_MSG_VERBOSE( "Retrieve total SF for jet container in SUSYTools_xAOD::FJVT_SF with value " << totalSF );
1120
1121 return totalSF;
1122 }
1123
1125
1126 float totalSF = 1.;
1127 if (!m_doFwdJVT) return totalSF;
1128
1129 //Set the new systematic variation
1130 StatusCode ret = m_jetfJvtEfficiencyTool->applySystematicVariation(systConfig);
1131 if ( ret != StatusCode::SUCCESS) {
1132 ATH_MSG_ERROR("Cannot configure fJvtEfficiencyTool for systematic var. " << systConfig.name() );
1133 }
1134
1135 // Delegate
1136 totalSF = SUSYObjDef_xAOD::FJVT_SF( jets );
1137
1138 if (m_doFwdJVT) {
1139 ret = m_jetfJvtEfficiencyTool->applySystematicVariation(m_currentSyst);
1140 if ( ret != StatusCode::SUCCESS) {
1141 ATH_MSG_ERROR("Cannot configure fJvtEfficiencyTool for systematic var. " << systConfig.name() );
1142 }
1143 }
1144
1145 return totalSF;
1146 }
1147
1148 double SUSYObjDef_xAOD::GetTotalJetSF(const xAOD::JetContainer* jets, const bool btagSF, const bool jvtSF, const bool fjvtSF) {
1149
1150 double totalSF = 1.;
1151 if (btagSF) totalSF *= BtagSF(jets);
1152
1153 if (jvtSF && m_applyJVTCut) totalSF *= JVT_SF(jets);
1154
1155 if (fjvtSF) totalSF *= FJVT_SF(jets);
1156
1157 return totalSF;
1158 }
1159
1160
1161 double SUSYObjDef_xAOD::GetTotalJetSFsys(const xAOD::JetContainer* jets, const CP::SystematicSet& systConfig, const bool btagSF, const bool jvtSF, const bool fjvtSF) {
1162
1163 double totalSF = 1.;
1164 if (btagSF) totalSF *= BtagSFsys(jets, systConfig);
1165
1166 if (jvtSF && m_applyJVTCut) totalSF *= JVT_SFsys(jets, systConfig);
1167
1168 if (fjvtSF) totalSF *= FJVT_SFsys(jets, systConfig);
1169
1170 return totalSF;
1171 }
1172
1173 StatusCode SUSYObjDef_xAOD::SetBtagWeightDecorations(const xAOD::Jet& input, const asg::AnaToolHandle<IBTaggingSelectionTool>& btagSelTool, const std::string& btagTagger) const {
1174 double weight = 0.;
1175 if ( btagSelTool->getTaggerWeight(input, weight, false/*useVetoWP=false*/) != CP::CorrectionCode::Ok ) {
1176 ATH_MSG_ERROR( btagSelTool->name() << ": could not retrieve b-tag weight (" << btagTagger << ")." );
1177 return StatusCode::FAILURE;
1178 }
1179 dec_btag_weight(input) = weight;
1180 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag weight: " << weight );
1181
1182 double btag_pb(-10), btag_pc(-10), btag_pu(-10), btag_ptau(-10);
1183 // following name change is needed given different name is used for GN2v00 in derivation and in CDI
1184 std::string actualTagger = btagTagger;
1185 if (btagTagger == "GN2v00LegacyWP" || btagTagger == "GN2v00NewAliasWP"){
1186 actualTagger = "GN2v00";
1187 }
1188 xAOD::BTaggingUtilities::getBTagging(input)->pb(actualTagger, btag_pb);
1189 xAOD::BTaggingUtilities::getBTagging(input)->pc(actualTagger, btag_pc);
1190 xAOD::BTaggingUtilities::getBTagging(input)->pu(actualTagger, btag_pu);
1191 xAOD::BTaggingUtilities::getBTagging(input)->pu(actualTagger, btag_ptau);
1192 dec_btag_pb(input) = btag_pb;
1193 dec_btag_pc(input) = btag_pc;
1194 dec_btag_pu(input) = btag_pu;
1195 dec_btag_ptau(input) = btag_ptau;
1196 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag " << btagTagger << "-type pb: " << btag_pb );
1197 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag " << btagTagger << "-type pc: " << btag_pc );
1198 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag " << btagTagger << "-type pu: " << btag_pu );
1199 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag " << btagTagger << "-type ptau: " << btag_ptau );
1200 // backwards compatibility
1201 if ( btagSelTool->name().find("DL1")!=std::string::npos ) {
1202 dec_btag_dl1pb(input) = btag_pb;
1203 dec_btag_dl1pc(input) = btag_pc;
1204 dec_btag_dl1pu(input) = btag_pu;
1205 }
1206 else {
1207 dec_btag_dl1pb(input) = -10;
1208 dec_btag_dl1pc(input) = -10;
1209 dec_btag_dl1pu(input) = -10;
1210 }
1211 return StatusCode::SUCCESS;
1212 }
1213}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
DataVector adapter that acts like it holds const pointers.
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
ServiceHandle< StoreGateSvc > & evtStore()
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
Class to wrap a set of SystematicVariations.
std::string name() const
returns: the systematics joined into a single string.
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
size_type size() const noexcept
Returns the number of elements in the collection.
Helper class to provide constant type-safe access to aux data.
Handle class for reading a decoration on an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
std::string m_defaultTrackJets
StatusCode GetJetsSyst(const xAOD::JetContainer &calibjets, xAOD::JetContainer *&copy, xAOD::ShallowAuxContainer *&copyaux, const bool recordSG=true, const std::string &jetkey="") override final
Definition Jets.cxx:338
std::string m_BtagWP_trkJet
bool IsBJetLoose(const xAOD::Jet &input) const override final
Definition Jets.cxx:698
std::string m_JetTruthLabelName
asg::AnaToolHandle< ICPJetUncertaintiesTool > m_WTagjetUncertaintiesTool
double JVT_SFsys(const xAOD::JetContainer *jets, const CP::SystematicSet &systConfig) override final
Definition Jets.cxx:1053
asg::AnaToolHandle< ICPJetUncertaintiesTool > m_ZTagjetUncertaintiesTool
double FJVT_SF(const xAOD::JetContainer *jets) override final
Definition Jets.cxx:1078
asg::AnaToolHandle< IJetCalibrationTool > m_jetFatCalibTool
asg::AnaToolHandle< ICPJetUncertaintiesTool > m_jetUncertaintiesPDSmearTool
float BtagSFsys_trkJet(const xAOD::JetContainer *trkjets, const CP::SystematicSet &systConfig) override final
Definition Jets.cxx:986
double FJVT_SFsys(const xAOD::JetContainer *jets, const CP::SystematicSet &systConfig) override final
Definition Jets.cxx:1124
StatusCode GetTrackJets(xAOD::JetContainer *&copy, xAOD::ShallowAuxContainer *&copyaux, const bool recordSG=true, const std::string &jetkey="", const xAOD::JetContainer *containerToBeCopied=nullptr) override final
Definition Jets.cxx:173
double GetTotalJetSFsys(const xAOD::JetContainer *jets, const CP::SystematicSet &systConfig, const bool btagSF=true, const bool jvtSF=true, const bool fjvtSF=false) override final
Definition Jets.cxx:1161
bool isData() const override final
float BtagSFsys(const xAOD::JetContainer *jets, const CP::SystematicSet &systConfig) override final
Definition Jets.cxx:905
std::string m_ZTagUncConfig
asg::AnaToolHandle< ICPJetCorrectionTool > m_fatjetFFSmearingTool
asg::AnaToolHandle< CP::IJvtEfficiencyTool > m_jetfJvtEfficiencyTool
double GetTotalJetSF(const xAOD::JetContainer *jets, const bool btagSF=true, const bool jvtSF=true, const bool fjvtSF=false) override final
Definition Jets.cxx:1148
asg::AnaToolHandle< JetPileupLabelingTool > m_jetPileupLabelingTool
bool IsTrackBJet(const xAOD::Jet &input) const override final
Definition Jets.cxx:800
StatusCode FillTrackJet(xAOD::Jet &input) override final
Definition Jets.cxx:661
float BtagSF_trkJet(const xAOD::JetContainer *trkjets) override final
Definition Jets.cxx:925
asg::AnaToolHandle< JSSWTopTaggerDNN > m_TopTaggerTool
int IsBJetContinuous(const xAOD::Jet &input) const override final
Definition Jets.cxx:811
asg::AnaToolHandle< IAsgSelectionTool > m_jetNNJvtSelectionTool
asg::AnaToolHandle< SmoothedWZTagger > m_ZTaggerTool
asg::AnaToolHandle< JetPileupTag::JetVertexNNTagger > m_jetNNJvtMomentTool
int IsTrackBJetContinuous(const xAOD::Jet &input) const override final
Definition Jets.cxx:833
CP::SystematicSet m_currentSyst
asg::AnaToolHandle< JetVertexTaggerTool > m_jetJvtMomentTool
asg::AnaToolHandle< ICPJetUncertaintiesTool > m_jetUncertaintiesTool
std::string m_WTagUncConfig
bool JetPassJVT(xAOD::Jet &input) override final
Definition Jets.cxx:705
asg::AnaToolHandle< ICPJetUncertaintiesTool > m_fatjetUncertaintiesTool
double JVT_SF(const xAOD::JetContainer *jets) override final
Definition Jets.cxx:1006
float BtagSF(const xAOD::JetContainer *jets) override final
Definition Jets.cxx:844
asg::AnaToolHandle< IAsgSelectionTool > m_jetfJvtSelectionTool
asg::AnaToolHandle< IBTaggingSelectionTool > m_btagSelTool_trkJet
asg::AnaToolHandle< CP::IJvtEfficiencyTool > m_jetNNJvtEfficiencyTool
asg::AnaToolHandle< IBTaggingEfficiencyTool > m_btagEffTool_trkJet
const xAOD::Vertex * GetPrimVtx() const override final
asg::AnaToolHandle< ICPJetUncertaintiesTool > m_TopTagjetUncertaintiesTool
std::vector< CP::SystematicSet > m_fatjetFFSmearingSyst
StatusCode SetBtagWeightDecorations(const xAOD::Jet &input, const asg::AnaToolHandle< IBTaggingSelectionTool > &btagSelTool, const std::string &btagTagger) const override final
Definition Jets.cxx:1173
StatusCode GetJets(xAOD::JetContainer *&copy, xAOD::ShallowAuxContainer *&copyaux, const bool recordSG=true, const std::string &jetkey="", const xAOD::JetContainer *containerToBeCopied=nullptr) override final
Definition Jets.cxx:73
asg::AnaToolHandle< IBTaggingEfficiencyTool > m_btagEffTool
SG::ReadDecorHandleKey< xAOD::JetContainer > m_label_truthKey
bool IsBadJet(const xAOD::Jet &input) const override final
Definition Jets.cxx:763
asg::AnaToolHandle< IBTaggingSelectionTool > m_btagSelTool_OR
StatusCode GetFatJets(xAOD::JetContainer *&copy, xAOD::ShallowAuxContainer *&copyaux, const bool recordSG=false, const std::string &jetkey="", const bool doLargeRdecorations=false, const xAOD::JetContainer *containerToBeCopied=nullptr) override final
Definition Jets.cxx:250
asg::AnaToolHandle< IBTaggingSelectionTool > m_btagSelTool
SG::ConstAccessor< char > m_acc_jetClean
bool IsTruthBJet(const xAOD::Jet &input) const override final
Definition Truth.cxx:301
std::string m_TopTagUncConfig
bool IsSignalJet(const xAOD::Jet &input, const float ptcut, const float etacut) const override final
Definition Jets.cxx:711
asg::AnaToolHandle< JetTruthLabelingTool > m_jetTruthLabelingTool
asg::AnaToolHandle< ICPJetUncertaintiesTool > m_fatjetUncertaintiesPDSmearTool
StatusCode FillJet(xAOD::Jet &input, const bool doCalib=true, bool isFat=false, bool doLargeRdecorations=false) override final
Definition Jets.cxx:403
asg::AnaToolHandle< SmoothedWZTagger > m_WTaggerTool
asg::AnaToolHandle< IJetCalibrationTool > m_jetCalibTool
std::string m_BtagTagger_trkJet
bool IsBJet(const xAOD::Jet &input) const override final
Definition Jets.cxx:789
a modified tool handle that allows its owner to configure new tools from the C++ side
bool pc(const std::string &taggername, double &value) const
bool pu(const std::string &taggername, double &value) const
bool pb(const std::string &taggername, double &value) const
Class creating a shallow copy of an existing auxiliary container.
void setName(const char *name)
Set the name of the container instance.
const char * name() const
Get the name of the container instance.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
static const SG::Decorator< char > dec_passOR("passOR")
static const SG::Decorator< char > dec_passFJvt("passFJvt")
static const SG::ConstAccessor< float > acc_VRradius("VRradius")
static const SG::ConstAccessor< char > acc_passFJvt("passFJvt")
static const SG::ConstAccessor< char > acc_bad("bad")
static const SG::Decorator< double > dec_effscalefact("effscalefact")
static const SG::ConstAccessor< char > acc_signal_less_JVT("signal_less_JVT")
Accessor for signal jets without a JVT requirement.
static const SG::ConstAccessor< int > acc_ztagged("ztagged")
static const SG::Decorator< float > dec_btag_pc("btag_pc")
static const SG::Decorator< float > dec_btag_dl1pb("btag_dl1pb")
static const SG::ConstAccessor< float > acc_fjvt("DFCommonJets_fJvt")
static const SG::Decorator< char > dec_baseline("baseline")
static const SG::Decorator< float > dec_fjvt("fJvt")
static const SG::Decorator< float > dec_btag_ptau("btag_ptau")
static const SG::Decorator< int > dec_toptagged("toptagged")
static const SG::ConstAccessor< char > acc_passDRcut("passDRcut")
static const SG::Decorator< char > dec_signal_less_JVT("signal_less_JVT")
Decorator for signal jets without a JVT requirement.
static const SG::ConstAccessor< char > acc_passJvt("passJvt")
static const SG::Decorator< char > dec_passJvt("passJvt")
static const SG::Decorator< double > dec_btag_weight("btag_weight")
static const SG::Decorator< float > dec_btag_dl1pc("btag_dl1pc")
static const SG::Decorator< char > dec_bjet("bjet")
static const SG::Decorator< float > dec_VRradius("VRradius")
static const SG::Decorator< float > dec_btag_pu("btag_pu")
static const SG::ConstAccessor< char > acc_signal("signal")
static const SG::ConstAccessor< float > acc_jvt("NNJvt")
static const SG::ConstAccessor< char > acc_baseline("baseline")
static const SG::Decorator< char > dec_bjet_jetunc("bjet_jetunc")
static const SG::Decorator< float > dec_jvt("Jvt")
static const SG::Decorator< int > dec_ztagged("ztagged")
static const SG::Decorator< float > dec_btag_pb("btag_pb")
static const SG::Decorator< float > dec_btag_dl1pu("btag_dl1pu")
static const SG::Decorator< int > dec_wtagged("wtagged")
static const SG::Decorator< char > dec_bad("bad")
static const SG::ConstAccessor< char > acc_bjet("bjet")
static const SG::ConstAccessor< int > acc_wtagged("wtagged")
static const SG::ConstAccessor< int > acc_toptagged("toptagged")
static const SG::ConstAccessor< char > acc_passOR("passOR")
static const SG::Decorator< char > dec_signal("signal")
static const SG::Decorator< char > dec_bjet_loose("bjet_loose")
static const SG::Decorator< char > dec_passDRcut("passDRcut")
static const SG::Decorator< char > dec_selected("selected")
void addGhostMuonsToJets(const xAOD::MuonContainer &muons, xAOD::JetContainer &jets)
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
double deltaR(double rapidity1, double phi1, double rapidity2, double phi2)
from bare bare rapidity,phi
Jet_v1 Jet
Definition of the current "jet version".
typename ShallowCopyResult< T >::type ShallowCopyResult_t
Return type of xAOD::shallowCopy.
Definition ShallowCopy.h:68
ShallowCopyResult_t< T > shallowCopy(const T &cont, const EventContext &ctx)
Create a shallow copy of an existing container.
bool setOriginalObjectLink(const IParticle &original, IParticle &copy)
This function should be used by CP tools when they make a deep copy of an object in their correctedCo...
@ JetConstitScaleMomentum
Definition JetTypes.h:29
setBGCode setTAP setLVL2ErrorBits bool
JetContainer_v1 JetContainer
Definition of the current "jet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".