ATLAS Offline Software
Loading...
Searching...
No Matches
TauEfficiencyCorrectionsTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// EDM include(s):
8
9// Local include(s):
13
14namespace TauAnalysisTools
15{
16
17//______________________________________________________________________________
19 : asg::AsgMetadataTool( sName )
21 , m_bIsData(false)
22 , m_bIsConfigured(false)
23 , m_iRunNumber(0)
24{}
25
26//______________________________________________________________________________
32
33//______________________________________________________________________________
35{
36 ATH_MSG_INFO( "Initializing TauEfficiencyCorrectionsTool" );
37
39
41 ATH_MSG_WARNING("Truth match check will be skipped. This is ONLY FOR TESTING PURPOSE!");
42
43 // check efficiency correction type
45 {
46 ATH_MSG_ERROR("Could not retrieve any EfficiencyCorrectionType");
47 return StatusCode::FAILURE;
48 }
49
50 if(m_sRecommendationTag == "2025-prerec") {
52 } else {
53 ATH_MSG_ERROR("Unknown RecommendationTag " << m_sRecommendationTag);
54 return StatusCode::FAILURE;
55 }
56
57 // for (auto tCommonEfficiencyTool : m_vCommonEfficiencyTools)
58 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
59 {
60 ATH_CHECK((**it).setProperty("OutputLevel", this->msg().level()));
61 ATH_CHECK((**it).initialize());
62 }
63
64 // Add the affecting systematics to the global registry
66 if (!registry.registerSystematics(*this))
67 {
68 ATH_MSG_ERROR ("Unable to register the systematics");
69 return StatusCode::FAILURE;
70 }
71
73
74 return StatusCode::SUCCESS;
75}
76
78{
79 return StatusCode::SUCCESS;
80}
81
83{
84 if (!m_bIsConfigured)
85 {
86 const xAOD::EventInfo* xEventInfo = nullptr;
87 ATH_CHECK(evtStore()->retrieve(xEventInfo,"EventInfo"));
89 m_bIsConfigured = true;
90 }
91
92 if (!m_firstEvent){
94 m_firstEvent = true;
95
96 }
97 if (m_bIsData)
98 return StatusCode::SUCCESS;
99
100 const xAOD::EventInfo* xEventInfo = nullptr;
101 ATH_CHECK(evtStore()->retrieve(xEventInfo, "EventInfo"));
102
104 {
105 // Reset the number at the beginning of event
106 m_iRunNumber = 0;
107 }
108
109 return StatusCode::SUCCESS;
110}
111
112//______________________________________________________________________________
114{
115 ATH_MSG_DEBUG( "TauEfficiencyCorrectionsTool with name " << name() << " is configured as follows:" );
116 for (auto iEfficiencyCorrectionType : m_vEfficiencyCorrectionTypes) {
117 ATH_MSG_DEBUG( " EfficiencyCorrectionTypes " << iEfficiencyCorrectionType );
118 }
119 ATH_MSG_DEBUG( " InputFilePathRecoHadTau " << m_sInputFilePathRecoHadTau );
120 ATH_MSG_DEBUG( " InputFilePathEleIDHadTau " << m_sInputFilePathEleIDHadTau );
121 ATH_MSG_DEBUG( " InputFilePathEleIDElectron " << m_sInputFilePathEleIDElectron );
122 ATH_MSG_DEBUG( " InputFilePathJetIDHadTau " << m_sInputFilePathJetIDHadTau );
123 ATH_MSG_DEBUG( " InputFilePathDecayModeHadTau " << m_sInputFilePathDecayModeHadTau );
124 ATH_MSG_DEBUG( " InputFilePathTriggerHadTau " << m_sInputFilePathTriggerHadTau );
125 ATH_MSG_DEBUG( " RecommendationTag " << m_sRecommendationTag );
126 ATH_MSG_DEBUG( " TriggerName " << m_sTriggerName );
127 ATH_MSG_DEBUG( " UseTauSubstructure " << m_bUseTauSubstructure );
128 ATH_MSG_DEBUG( " JetIDLevel " << m_iJetIDLevel );
129 ATH_MSG_DEBUG( " EleIDLevel " << m_iEleIDLevel );
130 ATH_MSG_DEBUG( " Campaign " << m_sCampaign );
131 ATH_MSG_DEBUG( " useFastSim " << m_useFastSim);
132}
133
134//______________________________________________________________________________
136 double& eff, unsigned int /*iRunNumber*/)
137{
138 eff = 1.;
139
140 if (m_bIsData)
142
145
146 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
147 {
148 if ( !(**it)->isSupportedRunNumber(m_iRunNumber) )
149 continue;
150 double dToolEff = 1.;
151 CP::CorrectionCode tmpCorrectionCode = (**it)->getEfficiencyScaleFactor(xTau, dToolEff, m_iRunNumber);
152 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
153 return tmpCorrectionCode;
154 eff *= dToolEff;
155 }
157}
158
159//______________________________________________________________________________
161{
162 if (m_bIsData)
164
167
168 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
169 {
170 CP::CorrectionCode tmpCorrectionCode = (**it)->applyEfficiencyScaleFactor(xTau, m_iRunNumber);
171 if (tmpCorrectionCode != CP::CorrectionCode::Ok)
172 return tmpCorrectionCode;
173 }
175}
176
178//______________________________________________________________________________
180{
181 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
182 if ((**it)->isAffectedBySystematic(systematic))
183 return true;
184 return false;
185}
186
188//______________________________________________________________________________
190{
191 CP::SystematicSet sAffectingSystematics;
192 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
193 sAffectingSystematics.insert((**it)->affectingSystematics());
194 return sAffectingSystematics;
195}
196
198//______________________________________________________________________________
200{
201 CP::SystematicSet sRecommendedSystematics;
202 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
203 sRecommendedSystematics.insert((**it)->recommendedSystematics());
204 return sRecommendedSystematics;
205}
206
207//______________________________________________________________________________
209{
210 for (auto it = m_vCommonEfficiencyTools.begin(); it != m_vCommonEfficiencyTools.end(); it++)
211 if ((**it)->applySystematicVariation(sSystematicSet) == StatusCode::FAILURE)
212 return StatusCode::FAILURE;
213 return StatusCode::SUCCESS;
214}
215
216//=================================PRIVATE-PART=================================
218{
219 std::string sDirectory = "TauAnalysisTools/" + std::string(sSharedFilesVersion) + "/EfficiencyCorrections/";
220 for (auto iEfficiencyCorrectionType : m_vEfficiencyCorrectionTypes){
221
222 if (iEfficiencyCorrectionType == SFJetIDHadTau)
223 {
224 if (m_sInputFilePathJetIDHadTau.empty()) {
225
226 if(m_useGNTau){
227 if(m_sCampaign=="mc23"){
228 m_sInputFilePathJetIDHadTau = sDirectory + "GNTauID_TrueHadTau_Run3.root";
229 } else {
230 ATH_MSG_ERROR("GNTau ID correction not supported for campaign "<< m_sCampaign);
231 return StatusCode::FAILURE;
232 }
233 } else {
234
235 if(m_sCampaign=="mc23"){
236 m_sInputFilePathJetIDHadTau = m_useFastSim ? sDirectory + "RNNID_TrueHadTau_mc23_v2_incl_AF3.root" : sDirectory + "RNNID_TrueHadTau_mc23_v2.root";
237 } else if (m_sCampaign=="mc20"){
238 m_sInputFilePathJetIDHadTau = m_useFastSim ? sDirectory + "RNNID_TrueHadTau_mc20_v1_incl_AF3.root" : sDirectory + "RNNID_TrueHadTau_mc20_v1.root";
239 }
240 }
241 }
242 m_sVarName = "TauScaleFactorJetIDHadTau";
243
244 std::string sJetIDWP = ConvertJetIDToString(m_iJetIDLevel);
245 if (sJetIDWP.empty()) {
246 ATH_MSG_WARNING("Could not find valid ID working point. Skip ID efficiency corrections.");
247 continue;
248 }
249
250 asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>* tTool = new asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>("TauAnalysisTools::CommonEfficiencyTool/JetIDHadTauTool", this);
251 m_vCommonEfficiencyTools.push_back(tTool);
252 ATH_CHECK(tTool->setProperty("InputFilePath", m_sInputFilePathJetIDHadTau));
253 ATH_CHECK(tTool->setProperty("VarName", m_sVarName));
254 ATH_CHECK(tTool->setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
255 ATH_CHECK(tTool->setProperty("WP", sJetIDWP));
256 }
257 else if (iEfficiencyCorrectionType == SFRecoHadTau)
258 {
259 if (m_sInputFilePathRecoHadTau.empty()) m_sInputFilePathRecoHadTau = sDirectory + "Reco_TrueHadTau_2026_v0.root";
260 m_sVarName = "TauScaleFactorReconstructionHadTau";
261
262 asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>* tTool = new asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>("TauAnalysisTools::CommonEfficiencyTool/RecoHadTauTool", this);
263 m_vCommonEfficiencyTools.push_back(tTool);
264 ATH_CHECK(tTool->setProperty("InputFilePath", m_sInputFilePathRecoHadTau));
265 ATH_CHECK(tTool->setProperty("VarName", m_sVarName));
266 ATH_CHECK(tTool->setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
267 }
268 else if (iEfficiencyCorrectionType == SFEleIDHadTau)
269 {
270 if (m_sInputFilePathEleIDHadTau.empty()) {
271 if( m_iEleIDLevel == static_cast<int>(ELEIDRNNLOOSE)){
272 m_sInputFilePathEleIDHadTau = sDirectory + "EleRNN_TrueHadTau_2026_eRNNLoose.root";
273 } else if( m_iEleIDLevel == static_cast<int>(ELEIDRNNMEDIUM)){
274 m_sInputFilePathEleIDHadTau = sDirectory + "EleRNN_TrueHadTau_2026_eRNNMedium.root";
275 } else {
276 ATH_MSG_ERROR("SFEleIDHadTau correction not supported for EleIDLevel="<<m_iEleIDLevel);
277 return StatusCode::FAILURE;
278 }
279 }
280 m_sVarName = "TauScaleFactorEleIDHadTau";
281
282 asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>* tTool = new asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>("TauAnalysisTools::CommonEfficiencyTool/EleIDHadTauTool", this);
283 m_vCommonEfficiencyTools.push_back(tTool);
284 ATH_CHECK(tTool->setProperty("InputFilePath", m_sInputFilePathEleIDHadTau));
285 ATH_CHECK(tTool->setProperty("VarName", m_sVarName));
286 ATH_CHECK(tTool->setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
287 ATH_CHECK(tTool->setProperty("WP", ConvertEleIDToString(m_iEleIDLevel)));
288 ATH_CHECK(tTool->setProperty("UseTauSubstructure", false));
289 }
290 else if (iEfficiencyCorrectionType == SFEleIDElectron)
291 {
292 // the path must be updated once RNN eVeto SFs are available
293 if (m_sInputFilePathEleIDElectron.empty()) {
294 if(m_useFastSim) {
295 ATH_MSG_WARNING("No fast-sim recommendation for tau electron veto, using full sim");
296 }
297
298 if(m_sCampaign=="mc23"){
299 if(m_useGNTau){
300 if( m_iJetIDLevel == static_cast<int>(JETIDGNTAULOOSE)){
301 m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_TrueElectron_2026_looseGNTauID_1p.root";
302 } else if( m_iJetIDLevel == static_cast<int>(JETIDGNTAUMEDIUM)){
303 m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_TrueElectron_2026_mediumGNTauID_1p.root";
304 }
305 else {
306 ATH_MSG_ERROR("SFEleIDElectron correction not supported for JetIDLevel="<<m_iJetIDLevel);
307 return StatusCode::FAILURE;
308 }
309 } else {
310 if( m_iJetIDLevel == static_cast<int>(JETIDRNNLOOSE)){
311 m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_TrueElectron_2022_looseRNNTauID_1p.root";
312 } else if( m_iJetIDLevel == static_cast<int>(JETIDRNNMEDIUM)){
313 m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_TrueElectron_2022_mediumRNNTauID_1p.root";
314 }
315 else {
316 ATH_MSG_ERROR("SFEleIDElectron correction not supported for JetIDLevel="<<m_iJetIDLevel);
317 return StatusCode::FAILURE;
318 }
319 }
320 } else if(m_sCampaign=="mc20"){
321 if(m_useGNTau){
322 ATH_MSG_ERROR("Eveto with GNTau ID correction not supported for campaign "<< m_sCampaign);
323 return StatusCode::FAILURE;
324 } else {
325 if( m_iJetIDLevel == static_cast<int>(JETIDRNNLOOSE)){
326 m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_TrueElectron_Run2_looseRNNTauID_1p.root";
327 } else if( m_iJetIDLevel == static_cast<int>(JETIDRNNMEDIUM)){
328 m_sInputFilePathEleIDElectron = sDirectory + "EleRNN_TrueElectron_Run2_mediumRNNTauID_1p_v1.root";
329 }
330 else {
331 ATH_MSG_ERROR("SFEleIDElectron correction not supported for JetIDLevel="<<m_iJetIDLevel);
332 return StatusCode::FAILURE;
333 }
334 }
335 }
336 }
337 m_sVarName = "TauScaleFactorEleIDElectron";
338
339 asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>* tTool = new asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>("TauAnalysisTools::CommonEfficiencyTool/EleIDElectronTool", this);
340 m_vCommonEfficiencyTools.push_back(tTool);
341 ATH_CHECK(tTool->setProperty("InputFilePath", m_sInputFilePathEleIDElectron));
342 ATH_CHECK(tTool->setProperty("VarName", m_sVarName));
343 ATH_CHECK(tTool->setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
344 ATH_CHECK(tTool->setProperty("WP", ConvertEleIDToString(m_iEleIDLevel)));
345 ATH_CHECK(tTool->setProperty("UseTauSubstructure", false));
346
347 } else if (iEfficiencyCorrectionType == SFTriggerHadTau){
348
349 if (m_sTriggerName.empty()) {
350 ATH_MSG_ERROR("Property \"Trigger\" was not set, please provide a trigger name.");
351 return StatusCode::FAILURE;
352 }
353 if (m_sInputFilePathTriggerHadTau.empty()) {
354 // Determine the input file name from the given trigger name.
355 if(m_sCampaign=="mc23a"){
356 if (m_sTriggerName.value().find("mediumRNN_tracktwoMVA") != std::string::npos) {
357 m_sInputFilePathTriggerHadTau = sDirectory+"Trigger/RNN/Trigger_TrueHadTau_data2022"+GetTriggerSFMeasurementString()+m_sTriggerName+".root";
358 }
359 else {
360 ATH_MSG_ERROR("Trigger " << m_sTriggerName << " is not supported for " << m_sCampaign << " campaign. Please fix \"TriggerName\" property. In case of doubt please consult with TauTrigger coordinators");
361 return StatusCode::FAILURE;
362 }
363 } else if(m_sCampaign=="mc23d"){
364 if (m_sTriggerName.value().find("mediumRNN_tracktwoMVA") != std::string::npos) {
365 m_sInputFilePathTriggerHadTau = sDirectory+"Trigger/RNN/Trigger_TrueHadTau_data2023"+GetTriggerSFMeasurementString()+m_sTriggerName+".root";
366 }
367 else {
368 ATH_MSG_ERROR("Trigger " << m_sTriggerName << " is not supported for " << m_sCampaign << " campaign. Please fix \"TriggerName\" property. In case of doubt please consult with TauTrigger coordinators");
369 return StatusCode::FAILURE;
370 }
371 } else if(m_sCampaign=="mc20"){
372 if (m_sTriggerName.value().find("tracktwoEF") != std::string::npos) {
373 // check explicitly tau160 as the root file for this trigger was renamed
374 if (m_sTriggerName.value().find("tau160") != std::string::npos) {
375 m_sInputFilePathTriggerHadTau = sDirectory+"Trigger/RNN_R22/Trigger_TrueHadTau_data2018_comb_HLT_tau160L1TAU100_medium1_tracktwoEF_v1.root";
376 } else {
377 m_sInputFilePathTriggerHadTau = sDirectory+"Trigger/RNN_R22/Trigger_TrueHadTau_data2018"+GetTriggerSFMeasurementString()+m_sTriggerName+".root";
378 }
379 } else if (m_sTriggerName.value().find("tracktwo") != std::string::npos) {
380 // check explicitly tau160 as the root file for this trigger was renamed
381 if (m_sTriggerName.value().find("tau160") != std::string::npos) {
382 m_sInputFilePathTriggerHadTau = sDirectory+"Trigger/RNN_R22/Trigger_TrueHadTau_data161718_comb_HLT_tau160_medium1_tracktwo_v1.root";
383 } else if (m_sTriggerName.value().find("tau125") != std::string::npos) {
384 // fall back to R21 recommendations for tau125 as currently SFs are not available for this trigger
385 m_sInputFilePathTriggerHadTau = sDirectory+"Trigger/RNN/Trigger_TrueHadTau_2019-summer_data161718_comb_HLT_tau125_medium1_tracktwo.root";
386 } else if (m_sTriggerName.value().find("tau60") != std::string::npos) {
387 // SFs for tau60 are only for partial period
388 m_sInputFilePathTriggerHadTau = sDirectory+"Trigger/RNN_R22/Trigger_TrueHadTau_data1718"+GetTriggerSFMeasurementString()+m_sTriggerName+".root";
389 } else {
390 m_sInputFilePathTriggerHadTau = sDirectory+"Trigger/RNN_R22/Trigger_TrueHadTau_data161718"+GetTriggerSFMeasurementString()+m_sTriggerName+".root";
391 }
392 } else {
393 ATH_MSG_ERROR("Trigger " << m_sTriggerName << " is not supported. Please fix \"TriggerName\" property. If this is correct, then please contact the tau trigger coordinators");
394 return StatusCode::FAILURE;
395 }
396 } else {
397 ATH_MSG_ERROR("SFs are not available for " << m_sCampaign << " campaign. If the config is correct, then please contact the tau trigger coordinators");
398 return StatusCode::FAILURE;
399 }
400 }
401 m_sVarName = "TauScaleFactorTriggerHadTau";
402
403 asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>* tTool = new asg::AnaToolHandle<ITauEfficiencyCorrectionsTool>("TauAnalysisTools::CommonEfficiencyTool/TriggerHadTauTool", this);
404 m_vCommonEfficiencyTools.push_back(tTool);
405 ATH_CHECK(tTool->setProperty("InputFilePath", m_sInputFilePathTriggerHadTau));
406 ATH_CHECK(tTool->setProperty("VarName", m_sVarName));
407 ATH_CHECK(tTool->setProperty("SkipTruthMatchCheck", m_bSkipTruthMatchCheck));
408 ATH_CHECK(tTool->setProperty("WP", ConvertTriggerIDToString(m_iJetIDLevel)));
409 ATH_CHECK(tTool->setProperty("DoTauTrig", true));
410 }
411 else {
412 ATH_MSG_WARNING("unsupported EfficiencyCorrectionsType with enum " << iEfficiencyCorrectionType);
413 }
414 }
415
416 return StatusCode::SUCCESS;
417}
418
419// auto detection of simulation flavour, used to cross check configuration of tool
420//______________________________________________________________________________
422{
423 if (inputMetaStore()->contains<xAOD::FileMetaData>("FileMetaData")) {
424 const xAOD::FileMetaData* fmd = nullptr;
425 ATH_CHECK( inputMetaStore()->retrieve( fmd, "FileMetaData" ) );
426 std::string simType("");
427 bool result = fmd->value( xAOD::FileMetaData::simFlavour , simType );
428 // if no result -> no simFlavor metadata, so must be data
429 if(result) std::transform(simType.begin(), simType.end(), simType.begin(), ::toupper);
430
431 if( simType.find("ATLFAST3") != std::string::npos && !m_useFastSim){
432 ATH_MSG_WARNING("Input file is AF3 sample but you are _not_ using AF3 corrections and uncertainties, you should set \"useFastSim\" to \"true\"");
433 } else if (simType.find("FULLG4")!=std::string::npos && m_useFastSim){
434 ATH_MSG_WARNING("Input file is full simulation but you are using AF3 corrections and uncertainties, you should set \"useFastSim\" to \"false\"");
435 }
436 }
437
438 return StatusCode::SUCCESS;
439}
440
441//______________________________________________________________________________
442std::string TauEfficiencyCorrectionsTool::ConvertJetIDToString(const int iLevel) const
443{
444 switch(iLevel)
445 {
446 case JETIDNONE:
447 return "none";
448 case JETIDRNNVERYLOOSE:
449 ATH_MSG_WARNING("Efficiency corrections for JETIDRNNVERYLOOSE working point are not supported.");
450 return "";
451 case JETIDRNNLOOSE:
452 return "jetrnnsigloose";
453 case JETIDRNNMEDIUM:
454 return "jetrnnsigmedium";
455 case JETIDRNNTIGHT:
456 return "jetrnnsigtight";
458 ATH_MSG_WARNING("Efficiency corrections for JETIDGNTAUVERYLOOSE working point are not supported.");
459 return "";
460 case JETIDGNTAULOOSE:
461 return "jetgntausigloose";
462 case JETIDGNTAUMEDIUM:
463 return "jetgntausigmedium";
464 case JETIDGNTAUTIGHT:
465 return "jetgntausigtight";
466 default:
467 ATH_MSG_WARNING("No valid JetID level passed.");
468 return "";
469 }
470}
471
472std::string TauEfficiencyCorrectionsTool::ConvertEleIDToString(const int iLevel) const
473{
474 switch(iLevel)
475 {
476 case ELEIDRNNTIGHT:
477 return "eleRNNTight";
478 case ELEIDRNNMEDIUM:
479 return "eleRNNMedium";
480 case ELEIDRNNLOOSE:
481 return "eleRNNLoose";
482 default:
483 ATH_MSG_WARNING("No valid EleID level passed.");
484 return "";
485 }
486}
487
488//______________________________________________________________________________
490{
491 switch(iLevel)
492 {
493 case JETIDRNNLOOSE:
494 return "loose";
495 case JETIDRNNMEDIUM:
496 return "medium";
497 case JETIDRNNTIGHT:
498 return "tight";
499 default:
500 ATH_MSG_WARNING("No valid TriggerID level passed.");
501 return "";
502 }
503}
504
505//______________________________________________________________________________
507{
508 std::string sMeasurement = "_comb_";
509
510 if (m_sTriggerSFMeasurement == "Ztautau")
511 sMeasurement = "_Ztt_";
512 else if (m_sTriggerSFMeasurement == "ttbar")
513 sMeasurement = "_ttbar_";
514 else if (m_sTriggerSFMeasurement != "combined")
515 ATH_MSG_WARNING("Trigger scale factor measurement \'" << m_sTriggerSFMeasurement << "\' is not supported. \'combined\' is used instead.");
516
517 return sMeasurement;
518}
519
521{
522 // read the random run rumber from the EventInfo
524 {
525 static const SG::ConstAccessor<unsigned int> acc_rnd("RandomRunNumber");
526 const xAOD::EventInfo* eventInfo = nullptr;
527 if (!evtStore()->contains<xAOD::EventInfo>("EventInfo") || !evtStore()->retrieve(eventInfo, "EventInfo").isSuccess())
528 {
529 ANA_MSG_ERROR("Could not retrieve EventInfo");
530 return StatusCode::FAILURE;
531 }
532
533 if (!acc_rnd.isAvailable(*eventInfo))
534 {
535 ANA_MSG_ERROR("Failed to find the RandomRunNumber decoration. Call the apply() method from the PileupReweightingTool beforehand to get period dependent SFs.");
536 return StatusCode::FAILURE;
537 }
538
539 m_iRunNumber = acc_rnd(*eventInfo);
540
541 ANA_MSG_VERBOSE("Read RandomRunNumber as " << m_iRunNumber);
542 }
543
544 return StatusCode::SUCCESS;
545}
546
547} // namespace TauAnalysisTools
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_MSG_VERBOSE(xmsg)
Macro printing verbose messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
static const char *const sSharedFilesVersion
Version of the calibration files.
ServiceHandle< StoreGateSvc > & evtStore()
Return value from object correction CP tools.
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
Class to wrap a set of SystematicVariations.
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual StatusCode initialize()
Function initialising the tool.
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const
returns: whether this tool is affected by the given systematics
virtual void printConfig() const
Print tool configuration.
virtual CP::SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by
TauEfficiencyCorrectionsTool(const std::string &sName)
Create a proper constructor for Athena.
virtual StatusCode beginInputFile()
Function called when a new input file is opened.
virtual CP::SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool recommends to use
Gaudi::Property< std::vector< int > > m_vecEfficiencyCorrectionTypes
virtual CP::CorrectionCode getEfficiencyScaleFactor(const xAOD::TauJet &xTau, double &eff, unsigned int iRunNumber=0)
Get the tau efficiency scale factor.
StatusCode beginEvent()
Function called when a new events is loaded.
std::vector< asg::AnaToolHandle< ITauEfficiencyCorrectionsTool > * > m_vCommonEfficiencyTools
virtual CP::CorrectionCode applyEfficiencyScaleFactor(const xAOD::TauJet &xTau, unsigned int iRunNumber=0)
Decorate the tau with its efficiency scale factor.
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
a modified tool handle that allows its owner to configure new tools from the C++ side
AsgMetadataTool(const std::string &name)
Normal ASG tool constructor with a name.
MetaStorePtr_t inputMetaStore() const
Accessor for the input metadata store.
bool eventType(EventType type) const
Check for one particular bitmask value.
@ IS_SIMULATION
true: simulation, false: data
@ simFlavour
Fast or Full sim [string].
bool value(MetaDataType type, std::string &val) const
Get a pre-defined string value out of the object.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
EventInfo_v1 EventInfo
Definition of the latest event info version.
TauJet_v3 TauJet
Definition of the current "tau version".
FileMetaData_v1 FileMetaData
Declare the latest version of the class.