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 // apply boosted jet taggers
302 if (!m_WtagConfig.empty())
303 ATH_CHECK(m_WTaggerTool->decorate(*copy));
304 if (!m_ZtagConfig.empty())
305 ATH_CHECK(m_ZTaggerTool->decorate(*copy));
306
307 for (const auto jet : *copy) {
308 ATH_CHECK( this->FillJet(*jet, true, true, doLargeRdecorations) );
309 //
310 // For OR, selected if it passed cuts
311 if ( acc_baseline(*jet) ){
312 dec_selected(*jet) = 1;
313 }
314 else{
315 dec_selected(*jet) = 0;
316 }
317 }
318 if (recordSG) {
319 ATH_CHECK( evtStore()->record(copy, "STCalib" + jetkey_tmp + m_currentSyst.name()) );
320 ATH_CHECK( evtStore()->record(copyaux, "STCalib" + jetkey_tmp + m_currentSyst.name() + "Aux.") );
321 }
322 return StatusCode::SUCCESS;
323 }
324
325
326 StatusCode SUSYObjDef_xAOD::GetJetsSyst(const xAOD::JetContainer& calibjets, xAOD::JetContainer*& copy, xAOD::ShallowAuxContainer*& copyaux, bool recordSG, const std::string& jetkey)
327 {
328 if (!m_tool_init) {
329 ATH_MSG_ERROR("SUSYTools was not initialized!!");
330 return StatusCode::FAILURE;
331 }
332
333 std::string jetkey_tmp = jetkey;
334 if (jetkey.empty()) {
335 jetkey_tmp = m_defaultJets;
336 }
337
338 std::pair<xAOD::JetContainer*, xAOD::ShallowAuxContainer*> shallowcopy = xAOD::shallowCopyContainer(calibjets);
339 copy = shallowcopy.first;
340 copyaux = shallowcopy.second;
341
342 bool setLinks = xAOD::setOriginalObjectLink(calibjets, *copy);
343 if (!setLinks) {
344 ATH_MSG_WARNING("Failed to set original object links on " << jetkey_tmp);
345 }
346
347 // ghost associate the muons to the jets (needed by MET muon-jet OR later)
348 ATH_MSG_VERBOSE("Run muon-to-jet ghost association");
349 const xAOD::MuonContainer* muons = nullptr;
350 // Do a little guessing
351 if (jetkey!="AnalysisJets"){
352 ATH_CHECK( evtStore()->retrieve(muons, "Muons") );
353 } else {
354 ATH_CHECK( evtStore()->retrieve(muons, "AnalysisMuons") );
355 }
356 met::addGhostMuonsToJets(*muons, *copy);
357
358 // Update the jets
359 for (const auto jet : *copy) {
360 ATH_CHECK( this->FillJet(*jet, false) );
361 }
362
363 for (const auto jet : *copy) {
364 // Update the JVT decorations if needed
365 if( m_doFwdJVT){
367
368 //new state for OR . 0=non-baseline objects, 1=for baseline jets not passing JVT, 2=for any other baseline object
369 if ( acc_baseline(*jet) ){
370 if( acc_passJvt(*jet) ) dec_selected(*jet) = 2;
371 else dec_selected(*jet) = 1;
372 }
373 else{
374 dec_selected(*jet) = 0;
375 }
376 }
377 this->IsBadJet(*jet);
379 if (!isData())this->IsTruthBJet(*jet);
380 }
381 if (recordSG) {
382 ATH_CHECK( evtStore()->record(copy, "STCalib" + jetkey_tmp + m_currentSyst.name()) );
383 ATH_CHECK( evtStore()->record(copyaux, "STCalib" + jetkey_tmp + m_currentSyst.name() + "Aux.") );
384 }
385 return StatusCode::SUCCESS;
386 }
387
388 StatusCode SUSYObjDef_xAOD::FillJet(xAOD::Jet& input, bool doCalib, bool isFat, bool doLargeRdecorations) {
389
390 ATH_MSG_VERBOSE( "Starting FillJet on jet with pt=" << input.pt() );
391 ATH_MSG_VERBOSE( "jet (pt,eta,phi) before calibration " << input.pt() << " " << input.eta() << " " << input.phi() );
392
393 static const SG::ConstAccessor<char> acc_wValidKinRange(m_WDecorName+"_ValidKinRange");
394 static const SG::ConstAccessor<char> acc_zValidKinRange(m_ZDecorName+"_ValidKinRange");
395 static const SG::ConstAccessor<char> acc_topValidKinRange(m_TopDecorName+"_ValidKinRange");
396 static const SG::ConstAccessor<char> acc_wtagged(m_WDecorName+"_Tagged");
397 static const SG::ConstAccessor<char> acc_ztagged(m_ZDecorName+"_Tagged");
399
400 if (doCalib) {
401 if(!isFat){
402 //disable - obsoleted ATH_CHECK( m_jetCalibTool->applyCalibration(input) );
403 }
404 else {
405 //disable - obsoleted ATH_CHECK( m_jetFatCalibTool->applyCalibration(input) );
406 dec_baseline(input) = ( input.pt() > m_jetPt ) || ( input.pt() > 20e3 ); // Allows for setting m_jetPt < 20e3
407 dec_bad(input) = false;
408 dec_signal(input) = false;
409 dec_bjet_loose(input) = false;
410 dec_effscalefact(input) = 1.;
411 dec_passOR(input) = true;
412 dec_bjet_jetunc(input) = false;
413 dec_btag_weight(input) = -999.;
414
415 dec_wtagged(input) = -1;
416 dec_ztagged(input) = -1;
417 dec_toptagged(input) = -1;
418 if (doLargeRdecorations) {
419
420 // Retrieve large-R tagging results for W/Z/top
421 if (!m_WtagConfig.empty()) {
422 // Only tag jets if they are inside the kinematic range
423 if ( !acc_wValidKinRange(input) ) {
424 ATH_MSG_VERBOSE("Large-R W candidate jet outside of recommended tagging range. Will set score to 0.");
425 dec_wtagged(input) = 0;
426 }
427 else dec_wtagged(input) = acc_wtagged(input);
428 }
429 if (!m_ZtagConfig.empty()) {
430 // Only tag jets if they are inside the kinematic range
431 if ( !acc_zValidKinRange(input) ) {
432 ATH_MSG_VERBOSE("Large-R Z candidate jet outside of recommended tagging range. Will set score to 0.");
433 dec_ztagged(input) = 0;
434 }
435 else dec_ztagged(input) = acc_ztagged(input);
436 }
437 if (!m_ToptagConfig.empty()) {
438 ATH_CHECK(m_TopTaggerTool->tag(input));
439 // Only tag jets if they are inside the kinematic range
440 if ( !acc_topValidKinRange(input) ) {
441 ATH_MSG_VERBOSE("Large-R Top candidate jet outside of recommended tagging range. Will set score to 0.");
442 dec_toptagged(input) = 0;
443 }
444 else dec_toptagged(input) = acc_toptagged(input);
445 }
446
447 }
448
449 // If a user hasn't specified an uncertainty config, then this tool will be empty
450 // for large R jets
451 if (!m_WTagjetUncertaintiesTool.empty() && !m_WTagUncConfig.empty() && !m_WtagConfig.empty() && doLargeRdecorations) {
452 CP::CorrectionCode result = m_WTagjetUncertaintiesTool->applyCorrection(input);
453 switch (result) {
455 ATH_MSG_ERROR( "Failed to apply largeR W-tag jet scale uncertainties.");
456 return StatusCode::FAILURE;
457 //break;
459 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR W-tag jet scale uncertainties. ");
460 break;
461 default:
462 break;
463 }
464 } else {
465 ATH_MSG_DEBUG( "No valid large-R W-tagged fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
466 }
467
468 if (!m_ZTagjetUncertaintiesTool.empty() && !m_ZTagUncConfig.empty() && !m_ZtagConfig.empty() && doLargeRdecorations) {
469 CP::CorrectionCode result = m_ZTagjetUncertaintiesTool->applyCorrection(input);
470 switch (result) {
472 ATH_MSG_ERROR( "Failed to apply largeR Z-tag jet scale uncertainties.");
473 return StatusCode::FAILURE;
474 //break;
476 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR Z-tag jet scale uncertainties. ");
477 break;
478 default:
479 break;
480 }
481 } else {
482 ATH_MSG_DEBUG( "No valid large-R Z-tagged fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
483 }
484
485 if (!m_TopTagjetUncertaintiesTool.empty() && !m_TopTagUncConfig.empty() && !m_ToptagConfig.empty() && doLargeRdecorations) {
487 switch (result) {
489 ATH_MSG_ERROR( "Failed to apply largeR Top-tag jet scale uncertainties.");
490 return StatusCode::FAILURE;
491 //break;
493 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR Top-tag jet scale uncertainties. ");
494 break;
495 default:
496 break;
497 }
498 } else {
499 ATH_MSG_DEBUG( "No valid large-R Top-tagged fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
500 }
501
502 if (!m_fatjetUncertaintiesTool.empty() && m_currentSyst.name().find("PseudoData") == std::string::npos) {
503 CP::CorrectionCode result = m_fatjetUncertaintiesTool->applyCorrection(input);
504 switch (result) {
506 ATH_MSG_ERROR( "Failed to apply largeR jet scale uncertainties.");
507 return StatusCode::FAILURE;
508 //break;
510 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR jet scale uncertainties. ");
511 break;
512 default:
513 break;
514 }
515 } else {
516 ATH_MSG_DEBUG( "No valid fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
517 }
518
519 // Use the PDSmeared uncertainties tool on the systematic with PseudoData in the name
520 if (!m_fatjetUncertaintiesPDSmearTool.empty() && m_fatJetUncertaintiesPDsmearing && m_currentSyst.name().find("PseudoData")) {
522 switch (result) {
524 ATH_MSG_ERROR( "Failed to apply largeR jet scale PD uncertainties.");
525 return StatusCode::FAILURE;
526 //break;
528 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR jet scale uncertainties. ");
529 break;
530 default:
531 break;
532 }
533 } else {
534 ATH_MSG_DEBUG( "No valid fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
535 }
536
538 CP::CorrectionCode result = m_fatjetFFSmearingTool->applyCorrection(input);
539 switch (result) {
541 ATH_MSG_ERROR( "Failed to apply largeR jet scale uncertainties.");
542 return StatusCode::FAILURE;
543 //break;
545 ATH_MSG_VERBOSE( "No valid pt/eta/m range for largeR jet scale uncertainties. ");
546 break;
547 default:
548 break;
549 }
550 } else {
551 ATH_MSG_DEBUG( "No valid fat jet uncertainty, but FillJet called with a fat jet. Skipping uncertainties." );
552 }
553
554 ATH_MSG_VERBOSE( "Large-R jet (pt,eta,phi) after calibration " << input.pt() << " " << input.eta() << " " << input.phi() );
555
556 return StatusCode::SUCCESS;
557 }
558 ATH_MSG_VERBOSE( "jet (pt,eta,phi) after calibration " << input.pt() << " " << input.eta() << " " << input.phi() );
559
560 }
561
562 dec_passOR(input) = true;
563 dec_bjet_jetunc(input) = false;
564
565 if (m_useBtagging) {
566 if (m_BtagWP != "Continuous") this->IsBJet(input);
567 else this->IsBJetContinuous(input);
568 }
569
570 if ( (input.pt() > m_jetPt) || (input.pt() > 15e3) ) {
571 if(!isFat && m_currentSyst.name().find("PseudoData") == std::string::npos) {
572 // Use the normal jet uncertainties tool for this systematic and do not use the PDSmeared initialised tool
573 CP::CorrectionCode result = m_jetUncertaintiesTool->applyCorrection(input);
574 switch (result) {
576 ATH_MSG_ERROR( "Failed to apply JES correction" );
577 break;
579 ATH_MSG_WARNING( "JES correction OutOfValidity range."); // Jet (pt,eta,phi) = (" << input.pt() << ", " << input.eta() << ", " << input.phi() << ")");
580 break;
581 default:
582 break;
583 }
584 }
585 }
586
588 if ( (input.pt() > m_jetPt) || (input.pt() > 15e3) ) {
589 if(!isFat && m_currentSyst.name().find("PseudoData")){
590 // Use the PDSmeared uncertainties tool on the systematic with PseudoData in the name
592 switch (result) {
594 ATH_MSG_ERROR( "Failed to apply JES correction" );
595 break;
597 ATH_MSG_WARNING( "JES correction OutOfValidity range."); // Jet (pt,eta,phi) = (" << input.pt() << ", " << input.eta() << ", " << input.phi() << ")");
598 break;
599 default:
600 break;
601 }
602 }
603 }
604 }
605
606
607 ATH_MSG_VERBOSE( "jet (pt,eta,phi) after JES correction " << input.pt() << " " << input.eta() << " " << input.phi() );
608
609 dec_passJvt(input) = !m_applyJVTCut || m_jetNNJvtSelectionTool->accept(&input);
610 dec_passFJvt(input) = !m_doFwdJVT || m_jetfJvtSelectionTool->accept(&input);
611 dec_baseline(input) = ( input.pt() > m_jetPt ) || ( input.pt() > 20e3 ); // Allows for setting m_jetPt < 20e3
612 dec_bad(input) = false;
613 dec_signal_less_JVT(input) = false;
614 dec_signal(input) = false;
615 dec_bjet_loose(input) = false;
616 dec_effscalefact(input) = 1.;
617
618 //new state for OR . 0=non-baseline objects, 1=for baseline jets not passing JVT, 2=for any other baseline object
619 if (acc_baseline(input) ){
620 if( acc_passJvt(input) ) dec_selected(input) = 2;
621 else dec_selected(input) = 1;
622 }
623 else{
624 dec_selected(input) = 0;
625 }
626
627 if (m_useBtagging && !m_orBtagWP.empty()) {
628 dec_bjet_loose(input) = this->IsBJetLoose(input);
629 }
630
631 if (m_debug) {
632 ATH_MSG_INFO( "JET pt: " << input.pt() );
633 ATH_MSG_INFO( "JET eta: " << input.eta() );
634 ATH_MSG_INFO( "JET phi: " << input.phi() );
635 ATH_MSG_INFO( "JET E: " << input.e() );
636 ATH_MSG_INFO( "JET Ceta: " << input.jetP4(xAOD::JetConstitScaleMomentum).eta() );
637 ATH_MSG_INFO( "JET Cphi: " << input.jetP4(xAOD::JetConstitScaleMomentum).phi() );
638 ATH_MSG_INFO( "JET CE: " << input.jetP4(xAOD::JetConstitScaleMomentum).e() );
639 ATH_MSG_INFO( "JET Cm: " << input.jetP4(xAOD::JetConstitScaleMomentum).M() ); // fix-me M
640
641 }
642
643 return StatusCode::SUCCESS;
644 }
645
647
648 ATH_MSG_VERBOSE( "Starting FillTrackJet on jet with pt=" << input.pt() );
649
650 dec_btag_weight(input) = -999.;
651 dec_effscalefact(input) = 1.;
652
653 if (m_defaultTrackJets == "AntiKtVR30Rmax4Rmin02TrackJets") {
654 // VR recommendation
655 // https://twiki.cern.ch/twiki/bin/view/AtlasProtected/BTagCalib2017#Recommendations_for_variable_rad
656 dec_baseline(input) = input.pt() >= 5e3 && input.numConstituents() >= 2;
657 if (m_trkJetPt < 10e3)
658 ATH_MSG_WARNING ("The pt threshold of VR jets you set is: " << m_trkJetPt/1000. << " GeV. But VR jets with pt < 10GeV are uncalibrated.");
659 dec_signal(input) = acc_baseline(input) && input.pt() >= m_trkJetPt && std::abs(input.eta()) <= m_trkJetEta;
660 dec_VRradius(input) = std::max(0.02,std::min(0.4,30000./input.pt()));
661 dec_passDRcut(input) = acc_signal(input);
662 } else {
663 dec_baseline(input) = input.pt() >= m_trkJetPt && std::abs(input.eta()) <= m_trkJetEta;
664 dec_signal(input) = acc_baseline(input);
665 }
666
668 if (m_BtagWP_trkJet != "Continuous") this->IsTrackBJet(input);
669 else this->IsTrackBJetContinuous(input);
670 }
671
672 if (m_debug) {
673 ATH_MSG_INFO( "TRK JET pt: " << input.pt() );
674 ATH_MSG_INFO( "TRK JET eta: " << input.eta() );
675 ATH_MSG_INFO( "TRK JET phi: " << input.phi() );
676 ATH_MSG_INFO( "TRK JET E: " << input.e() );
677 }
678
679 return StatusCode::SUCCESS;
680 }
681
682
683 bool SUSYObjDef_xAOD::IsBJetLoose(const xAOD::Jet& input) const {
684 bool isbjet_loose = false;
686 isbjet_loose = bool(m_btagSelTool_OR->accept(input)); //note : b-tag applies only to jet with eta < 2.5
687 return isbjet_loose;
688 }
689
691 char pass_jvt = !m_applyJVTCut || m_jetNNJvtSelectionTool->accept(&input);
692 dec_passJvt(input) = pass_jvt;
693 return pass_jvt;
694 }
695
696 bool SUSYObjDef_xAOD::IsSignalJet(const xAOD::Jet& input, float ptcut, float etacut) const {
697 if ( !acc_baseline(input) || !acc_passOR(input) ) return false;
698
699 if ( input.pt() <= ptcut || std::abs(input.eta()) >= etacut) return false;
700
701 bool isgoodjet = !acc_bad(input) && acc_passJvt(input);
702
703 dec_signal(input) = isgoodjet;
704
705 // For JVT calculation
706 dec_signal_less_JVT(input) = !acc_bad(input);
707
708
709 if (m_debug) {
710 float emfrac, hecf, LArQuality, HECQuality, Timing, fracSamplingMax, NegativeE, AverageLArQF;
711 std::vector<float> sumpttrk_vec;
712
713 input.getAttribute(xAOD::JetAttribute::EMFrac, emfrac);
714 input.getAttribute(xAOD::JetAttribute::HECFrac, hecf);
715 input.getAttribute(xAOD::JetAttribute::LArQuality, LArQuality);
716 input.getAttribute(xAOD::JetAttribute::HECQuality, HECQuality);
717 input.getAttribute(xAOD::JetAttribute::Timing, Timing);
718 input.getAttribute(xAOD::JetAttribute::SumPtTrkPt500, sumpttrk_vec);
719 input.getAttribute(xAOD::JetAttribute::FracSamplingMax, fracSamplingMax);
720 input.getAttribute(xAOD::JetAttribute::NegativeE, NegativeE);
721 input.getAttribute(xAOD::JetAttribute::AverageLArQF, AverageLArQF);
722
723 float sumpttrk;
724 if (!sumpttrk_vec.empty() && this->GetPrimVtx()) {
725 sumpttrk = sumpttrk_vec[this->GetPrimVtx()->index()];
726 } else {
727 sumpttrk = 0.;
728 }
729
730 ATH_MSG_INFO( "JET pt: " << input.pt() );
731 ATH_MSG_INFO( "JET eta: " << input.eta() );
732 ATH_MSG_INFO( "JET emfrac: " << emfrac );
733 ATH_MSG_INFO( "JET hecfrac: " << hecf );
734 ATH_MSG_INFO( "JET LArQuality: " << LArQuality );
735 ATH_MSG_INFO( "JET HECQuality: " << HECQuality );
736 ATH_MSG_INFO( "JET Timing: " << Timing );
737 ATH_MSG_INFO( "JET sumpttrk: " << sumpttrk );
738 ATH_MSG_INFO( "JET fracSamplingMax: " << fracSamplingMax );
739 ATH_MSG_INFO( "JET AverageLArQF: " << AverageLArQF );
740 }
741
742 ATH_MSG_VERBOSE( "JET isbad?: " << static_cast<int>(acc_bad(input)));
743
744 return isgoodjet;
745 }
746
747
748 bool SUSYObjDef_xAOD::IsBadJet(const xAOD::Jet& input) const {
749
750 if ( !acc_passOR(input) ) return false;
751
752 float ptcut = 20e3;
753 if ( m_jetPt < ptcut ) ptcut = m_jetPt;
754
755 bool isPileup = !acc_passJvt(input);
756
757 if ( input.pt() <= ptcut || isPileup ) return false;
758
759 if (m_acc_jetClean.isAvailable(input)) {
760 dec_bad(input) = !m_acc_jetClean(input);
761 } else {
762 ATH_MSG_VERBOSE("DFCommon jet cleaning variable not available ... setting 'bad' decorator to 0.");
763 dec_bad(input) = 0;
764 // the jet cleaning decisions are only calculable at AOD now
765 // dec_bad(input) = m_jetCleaningTool.empty() ? false : !m_jetCleaningTool->keep(input);
766 }
767
768 ATH_MSG_VERBOSE( "JET isbad?: " << static_cast<int>(acc_bad(input)));
769
770 return acc_bad(input);
771 }
772
773
774 bool SUSYObjDef_xAOD::IsBJet(const xAOD::Jet& input) const {
775
776 bool isbjet = bool(m_btagSelTool->accept(input));
777 dec_bjet(input) = isbjet;
778
779 if (SetBtagWeightDecorations(input, m_btagSelTool, m_BtagTagger).isFailure())
780 ANA_MSG_ERROR("Couldn't set b-tag decorations for jet, is-b = " << (isbjet?"true":"false") << ", pT = " << input.pt()/1000.);
781
782 return isbjet;
783 }
784
785 bool SUSYObjDef_xAOD::IsTrackBJet(const xAOD::Jet& input) const {
786
787 bool isbjet = bool(m_btagSelTool_trkJet->accept(input));
788 dec_bjet(input) = isbjet;
789
791 ANA_MSG_ERROR("Couldn't set b-tag decorations for trackjet, is-b = " << (isbjet?"true":"false") << ", pT = " << input.pt()/1000.);
792
793 return isbjet;
794 }
795
798 // Cheatsheet:
799 // returns 6 if between 65% and 0%
800 // returns 5 if between 70% and 65%
801 // returns 4 if between 77% and 70%
802 // returns 3 if between 85% and 77%
803 // returns 2 if between 90% and 85%
804 // returns 1 if between 100% and 90%
805 // returns 0 if smaller than -1e4-> should never happen
806 // return -1 if bigger than 1e4 or not in b-tagging acceptance
808
809 int isbjet = m_btagSelTool->getQuantile(input);
810 dec_bjet(input) = isbjet;
811
813 ANA_MSG_ERROR("Couldn't set continuous b-tag decorations for jet, is-b = " << isbjet << ", pT = " << input.pt()/1000.);
814
815 return isbjet;
816 }
817
819
820 int isbjet = m_btagSelTool_trkJet->getQuantile(input);
821 dec_bjet(input) = isbjet;
822
824 ANA_MSG_ERROR("Couldn't set continuous b-tag decorations for trackjet, is-b = " << isbjet << ", pT = " << input.pt()/1000.);
825
826 return isbjet;
827 }
828
830
831 float totalSF = 1.;
832 for ( const xAOD::Jet* jet : *jets ) {
833
834 float sf = 1.;
835
836 if ( std::abs(jet->eta()) > 2.5 ) {
837 ATH_MSG_VERBOSE( "Trying to retrieve b-tagging SF for jet with |eta|>2.5 (jet eta=" << jet->eta() << "), jet will be skipped");
838 } else if ( jet->pt() < 20e3 ){
839 ATH_MSG_VERBOSE( "Trying to retrieve b-tagging SF for jet with invalid pt (jet pt=" << jet->pt() << "), jet will be skipped");
840 } else {
841
843 int truthlabel(-1);
844 if (!jet->getAttribute("HadronConeExclTruthLabelID", truthlabel)) {
845 ATH_MSG_ERROR("Failed to get jet truth label!");
846 }
847 ATH_MSG_VERBOSE("This jet is " << (acc_bjet(*jet) ? "" : "not ") << "b-tagged.");
848 ATH_MSG_VERBOSE("This jet's truth label is " << truthlabel);
849
850 if ( acc_bjet(*jet) or m_BtagWP == "Continuous") {
851 result = m_btagEffTool->getScaleFactor(*jet, sf);
852
853 switch (result) {
855 ATH_MSG_ERROR( "Failed to retrieve SF for b-tagged jets in SUSYTools_xAOD::BtagSF" );
856 break;
858 ATH_MSG_VERBOSE( "No valid SF for b-tagged jets in SUSYTools_xAOD::BtagSF" );
859 break;
860 default:
861 ATH_MSG_VERBOSE( "Retrieve SF for b-tagged jets in SUSYTools_xAOD::BtagSF with value " << sf );
862 }
863 } else {
864
865 result = m_btagEffTool->getInefficiencyScaleFactor(*jet, sf);
866
867 switch (result) {
869 ATH_MSG_ERROR( "Failed to retrieve SF for non-b-tagged jets in SUSYTools_xAOD::BtagSF" );
870 break;
872 ATH_MSG_VERBOSE( "No valid inefficiency SF for non-b-tagged jets in SUSYTools_xAOD::BtagSF" );
873 break;
874 default:
875 ATH_MSG_VERBOSE( "Retrieve SF for non-b-tagged jets in SUSYTools_xAOD::BtagSF with value " << sf );
876 }
877 }
878 }
879
880 dec_effscalefact(*jet) = sf;
881
882 if( acc_signal(*jet) && acc_passOR(*jet) ) totalSF *= sf; //consider goodjets only
883
884 }
885
886 return totalSF;
887 }
888
889
891 {
892 float totalSF = 1.;
893
894 //Set the new systematic variation
895 StatusCode ret = m_btagEffTool->applySystematicVariation(systConfig);
896 if ( ret != StatusCode::SUCCESS) {
897 ATH_MSG_ERROR("Cannot configure BTaggingEfficiencyTool for systematic var. " << systConfig.name() );
898 }
899
900 totalSF = BtagSF( jets );
901
902 ret = m_btagEffTool->applySystematicVariation(m_currentSyst);
903 if ( ret != StatusCode::SUCCESS) {
904 ATH_MSG_ERROR("Cannot configure BTaggingEfficiencyTool for systematic var. " << systConfig.name() );
905 }
906
907 return totalSF;
908 }
909
911
912 float totalSF = 1.;
913 for ( const xAOD::Jet* trkjet : *trkjets ) {
914
915 float sf = 1.;
916
917 if ( std::abs(trkjet->eta()) > 2.5 ) {
918 ATH_MSG_VERBOSE( "Trying to retrieve b-tagging SF for trkjet with |eta|>2.5 (trkjet eta=" << trkjet->eta() << "), trkjet will be skipped");
919 } else if ( trkjet->pt() < 10e3 ){
920 ATH_MSG_VERBOSE( "Trying to retrieve b-tagging SF for trkjet with invalid pt (trkjet pt=" << trkjet->pt() << "), jet will be skipped");
921 } else {
922
924 int truthlabel(-1);
925 if (!trkjet->getAttribute("HadronConeExclTruthLabelID", truthlabel)) {
926 ATH_MSG_ERROR("Failed to get jet truth label!");
927 }
928 ATH_MSG_VERBOSE("This jet is " << (acc_bjet(*trkjet) ? "" : "not ") << "b-tagged.");
929 ATH_MSG_VERBOSE("This jet's truth label is " << truthlabel);
930
931 if ( acc_bjet(*trkjet) ) {
932 result = m_btagEffTool_trkJet->getScaleFactor(*trkjet, sf);
933
934 switch (result) {
936 ATH_MSG_ERROR( "Failed to retrieve SF for b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet" );
937 break;
939 ATH_MSG_VERBOSE( "No valid SF for b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet" );
940 break;
941 default:
942 ATH_MSG_VERBOSE( "Retrieve SF for b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet with value " << sf );
943 }
944 } else {
945
946 result = m_btagEffTool_trkJet->getInefficiencyScaleFactor(*trkjet, sf);
947
948 switch (result) {
950 ATH_MSG_ERROR( "Failed to retrieve SF for non-b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet" );
951 break;
953 ATH_MSG_VERBOSE( "No valid inefficiency SF for non-b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet" );
954 break;
955 default:
956 ATH_MSG_VERBOSE( "Retrieve SF for non-b-tagged trk jets in SUSYTools_xAOD::BtagSF_trkJet with value " << sf );
957 }
958 }
959 }
960
961 dec_effscalefact(*trkjet) = sf;
962
963 if( acc_signal(*trkjet) ) totalSF *= sf;
964
965 }
966
967 return totalSF;
968 }
969
970
972 {
973 float totalSF = 1.;
974
975 //Set the new systematic variation
976 StatusCode ret = m_btagEffTool_trkJet->applySystematicVariation(systConfig);
977 if ( ret != StatusCode::SUCCESS) {
978 ATH_MSG_ERROR("Cannot configure BTaggingEfficiencyTool (track jets) for systematic var. " << systConfig.name() );
979 }
980
981 totalSF = BtagSF_trkJet( trkjets );
982
983 ret = m_btagEffTool_trkJet->applySystematicVariation(m_currentSyst);
984 if ( ret != StatusCode::SUCCESS) {
985 ATH_MSG_ERROR("Cannot configure BTaggingEfficiencyTool (track jets) for systematic var. " << systConfig.name() );
986 }
987
988 return totalSF;
989 }
990
992
993 float totalSF = 1.;
994 if (!m_applyJVTCut) return totalSF;
995
997 for (const xAOD::Jet* jet : *jets) {
998 // Only jets that were good for every cut except JVT
1000 jvtjets.push_back(jet);
1001 }
1002 }
1003
1004 for (const xAOD::Jet* jet : jvtjets) {
1005 float current_sf = 0;
1006
1007 // the SF are only applied for HS jets and implicitely requires the presence of the isHS decoration
1009 if (acc_passJvt(*jet)) {
1010 result = m_jetNNJvtEfficiencyTool->getEfficiencyScaleFactor(*jet,current_sf);
1011 }
1012 else {
1013 result = m_jetNNJvtEfficiencyTool->getInefficiencyScaleFactor(*jet,current_sf);
1014 }
1015
1016 switch (result) {
1018 // this is probably not right, should report an error here
1019 ATH_MSG_ERROR("Inexplicably failed JVT calibration" );
1020 break;
1022 // no NNJvt SF for jet, that is ok e.g. for jets with |eta| > 2.5
1023 ATH_MSG_VERBOSE( "Skip SF application in SUSYTools_xAOD::JVT_SF as jet outside validate range" );
1024 break;
1025 default:
1026 ATH_MSG_VERBOSE( "Retrieve SF for jet in SUSYTools_xAOD::JVT_SF with value " << current_sf );
1027 totalSF *= current_sf;
1028 }
1029
1030 }
1031
1032 ATH_MSG_VERBOSE( "Retrieve total SF for jet container in SUSYTools_xAOD::JVT_SF with value " << totalSF );
1033
1034 return totalSF;
1035 }
1036
1037
1038 double SUSYObjDef_xAOD::JVT_SFsys(const xAOD::JetContainer* jets, const CP::SystematicSet& systConfig) {
1039
1040 float totalSF = 1.;
1041 if (!m_applyJVTCut) return totalSF;
1042
1043 //Set the new systematic variation
1044 StatusCode ret = m_jetNNJvtEfficiencyTool->applySystematicVariation(systConfig);
1045 if ( ret != StatusCode::SUCCESS) {
1046 ATH_MSG_ERROR("Cannot configure NNjvtEfficiencyTool for systematic var. " << systConfig.name() );
1047 }
1048
1049 // Delegate
1050 totalSF = SUSYObjDef_xAOD::JVT_SF( jets );
1051
1052 // }
1053 if (m_applyJVTCut) {
1054 ret = m_jetNNJvtEfficiencyTool->applySystematicVariation(m_currentSyst);
1055 if ( ret != StatusCode::SUCCESS) {
1056 ATH_MSG_ERROR("Cannot configure NNjvtEfficiencyTool for systematic var. " << systConfig.name() );
1057 }
1058 }
1059
1060 return totalSF;
1061 }
1062
1064
1065 float totalSF = 1.;
1066 if (!m_doFwdJVT) return totalSF;
1067
1069 for (const xAOD::Jet* jet : *jets) {
1070 // Only jets that were good for every cut except JVT
1072 fjvtjets.push_back(jet);
1073 }
1074 }
1075
1076 for (const xAOD::Jet* jet : fjvtjets) {
1077 float current_sf = 0;
1078
1079 // the SF are only applied for HS jets and implicitely requires the presense of the isHS decoration
1081 if (acc_passFJvt(*jet)) {
1082 result = m_jetfJvtEfficiencyTool->getEfficiencyScaleFactor(*jet,current_sf);
1083 }
1084 else {
1085 result = m_jetfJvtEfficiencyTool->getInefficiencyScaleFactor(*jet,current_sf);
1086 }
1087
1088 switch (result) {
1090 // this is probably not right, should report an error here
1091 ATH_MSG_ERROR("Inexplicably failed fJVT calibration" );
1092 break;
1094 // no fJvt SF for jet, that is ok e.g. for jets with |eta| < 2.5
1095 ATH_MSG_VERBOSE( "Skip SF application in SUSYTools_xAOD::FJVT_SF as jet outside validate range" );
1096 break;
1097 default:
1098 ATH_MSG_VERBOSE( "Retrieve SF for jet in SUSYTools_xAOD::FJVT_SF with value " << current_sf );
1099 totalSF *= current_sf;
1100 }
1101
1102 }
1103
1104 ATH_MSG_VERBOSE( "Retrieve total SF for jet container in SUSYTools_xAOD::FJVT_SF with value " << totalSF );
1105
1106 return totalSF;
1107 }
1108
1110
1111 float totalSF = 1.;
1112 if (!m_doFwdJVT) return totalSF;
1113
1114 //Set the new systematic variation
1115 StatusCode ret = m_jetfJvtEfficiencyTool->applySystematicVariation(systConfig);
1116 if ( ret != StatusCode::SUCCESS) {
1117 ATH_MSG_ERROR("Cannot configure fJvtEfficiencyTool for systematic var. " << systConfig.name() );
1118 }
1119
1120 // Delegate
1121 totalSF = SUSYObjDef_xAOD::FJVT_SF( jets );
1122
1123 if (m_doFwdJVT) {
1124 ret = m_jetfJvtEfficiencyTool->applySystematicVariation(m_currentSyst);
1125 if ( ret != StatusCode::SUCCESS) {
1126 ATH_MSG_ERROR("Cannot configure fJvtEfficiencyTool for systematic var. " << systConfig.name() );
1127 }
1128 }
1129
1130 return totalSF;
1131 }
1132
1133 double SUSYObjDef_xAOD::GetTotalJetSF(const xAOD::JetContainer* jets, const bool btagSF, const bool jvtSF, const bool fjvtSF) {
1134
1135 double totalSF = 1.;
1136 if (btagSF) totalSF *= BtagSF(jets);
1137
1138 if (jvtSF && m_applyJVTCut) totalSF *= JVT_SF(jets);
1139
1140 if (fjvtSF) totalSF *= FJVT_SF(jets);
1141
1142 return totalSF;
1143 }
1144
1145
1146 double SUSYObjDef_xAOD::GetTotalJetSFsys(const xAOD::JetContainer* jets, const CP::SystematicSet& systConfig, const bool btagSF, const bool jvtSF, const bool fjvtSF) {
1147
1148 double totalSF = 1.;
1149 if (btagSF) totalSF *= BtagSFsys(jets, systConfig);
1150
1151 if (jvtSF && m_applyJVTCut) totalSF *= JVT_SFsys(jets, systConfig);
1152
1153 if (fjvtSF) totalSF *= FJVT_SFsys(jets, systConfig);
1154
1155 return totalSF;
1156 }
1157
1158 StatusCode SUSYObjDef_xAOD::SetBtagWeightDecorations(const xAOD::Jet& input, const asg::AnaToolHandle<IBTaggingSelectionTool>& btagSelTool, const std::string& btagTagger) const {
1159 double weight = 0.;
1160 if ( btagSelTool->getTaggerWeight(input, weight, false/*useVetoWP=false*/) != CP::CorrectionCode::Ok ) {
1161 ATH_MSG_ERROR( btagSelTool->name() << ": could not retrieve b-tag weight (" << btagTagger << ")." );
1162 return StatusCode::FAILURE;
1163 }
1164 dec_btag_weight(input) = weight;
1165 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag weight: " << weight );
1166
1167 double btag_pb(-10), btag_pc(-10), btag_pu(-10), btag_ptau(-10);
1168 // following name change is needed given different name is used for GN2v00 in derivation and in CDI
1169 std::string actualTagger = btagTagger;
1170 if (btagTagger == "GN2v00LegacyWP" || btagTagger == "GN2v00NewAliasWP"){
1171 actualTagger = "GN2v00";
1172 }
1173 xAOD::BTaggingUtilities::getBTagging(input)->pb(actualTagger, btag_pb);
1174 xAOD::BTaggingUtilities::getBTagging(input)->pc(actualTagger, btag_pc);
1175 xAOD::BTaggingUtilities::getBTagging(input)->pu(actualTagger, btag_pu);
1176 xAOD::BTaggingUtilities::getBTagging(input)->pu(actualTagger, btag_ptau);
1177 dec_btag_pb(input) = btag_pb;
1178 dec_btag_pc(input) = btag_pc;
1179 dec_btag_pu(input) = btag_pu;
1180 dec_btag_ptau(input) = btag_ptau;
1181 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag " << btagTagger << "-type pb: " << btag_pb );
1182 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag " << btagTagger << "-type pc: " << btag_pc );
1183 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag " << btagTagger << "-type pu: " << btag_pu );
1184 ATH_MSG_DEBUG( btagSelTool->name() << " b-tag " << btagTagger << "-type ptau: " << btag_ptau );
1185 // backwards compatibility
1186 if ( btagSelTool->name().find("DL1")!=std::string::npos ) {
1187 dec_btag_dl1pb(input) = btag_pb;
1188 dec_btag_dl1pc(input) = btag_pc;
1189 dec_btag_dl1pu(input) = btag_pu;
1190 }
1191 else {
1192 dec_btag_dl1pb(input) = -10;
1193 dec_btag_dl1pc(input) = -10;
1194 dec_btag_dl1pu(input) = -10;
1195 }
1196 return StatusCode::SUCCESS;
1197 }
1198}
#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:326
std::string m_BtagWP_trkJet
bool IsBJetLoose(const xAOD::Jet &input) const override final
Definition Jets.cxx:683
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:1038
asg::AnaToolHandle< ICPJetUncertaintiesTool > m_ZTagjetUncertaintiesTool
double FJVT_SF(const xAOD::JetContainer *jets) override final
Definition Jets.cxx:1063
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:971
double FJVT_SFsys(const xAOD::JetContainer *jets, const CP::SystematicSet &systConfig) override final
Definition Jets.cxx:1109
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:1146
bool isData() const override final
float BtagSFsys(const xAOD::JetContainer *jets, const CP::SystematicSet &systConfig) override final
Definition Jets.cxx:890
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:1133
asg::AnaToolHandle< JetPileupLabelingTool > m_jetPileupLabelingTool
bool IsTrackBJet(const xAOD::Jet &input) const override final
Definition Jets.cxx:785
StatusCode FillTrackJet(xAOD::Jet &input) override final
Definition Jets.cxx:646
float BtagSF_trkJet(const xAOD::JetContainer *trkjets) override final
Definition Jets.cxx:910
asg::AnaToolHandle< JSSWTopTaggerDNN > m_TopTaggerTool
int IsBJetContinuous(const xAOD::Jet &input) const override final
Definition Jets.cxx:796
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:818
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:690
asg::AnaToolHandle< ICPJetUncertaintiesTool > m_fatjetUncertaintiesTool
double JVT_SF(const xAOD::JetContainer *jets) override final
Definition Jets.cxx:991
float BtagSF(const xAOD::JetContainer *jets) override final
Definition Jets.cxx:829
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:1158
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:748
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:696
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:388
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:774
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".