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