ATLAS Offline Software
MuonTriggerScaleFactors.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  */
4 
5 #include <sstream>
6 #include <TRandom3.h>
7 #include "TROOT.h"
8 #include "TH1.h"
9 #include "TH2.h"
10 #include "TFile.h"
11 #include "TKey.h"
12 
13 #include "xAODMuon/MuonContainer.h"
17 
24 
25 #include <iostream>
26 #include <functional>
27 #include <string>
28 #include <cmath>
29 
30 namespace CP {
31  static const double muon_barrel_endcap_boundary = 1.05;
33  asg::AsgTool(name),
34  m_systFilter(),
35  m_appliedSystematics(nullptr),
36  m_fileName(),
37  m_efficiencyMap(),
38  m_efficiencyMapReplicaArray(),
39  m_muonquality("Medium"),
40  m_calibration_version("230222_Winter_r22"),
41  m_custom_dir(),
42  m_binning("fine"),
43  m_allowZeroSF(false),
44  m_experimental(false),
45  m_forceYear(-1),
46  m_forcePeriod(""),
47  m_replicaTriggerList(),
48  m_replicaSet(),
49  m_nReplicas(100),
50  m_ReplicaRandomSeed(12345) {
51 
52  declareProperty("MuonQuality", m_muonquality); // HighPt,Tight,Medium,Loose,LowPt
53  declareProperty("CalibrationRelease", m_calibration_version);
54  // these are for debugging / testing, *not* for general use!
55  declareProperty("filename", m_fileName);
56  declareProperty("CustomInputFolder", m_custom_dir);
57  declareProperty("Binning", m_binning); // fine or coarse
58  declareProperty("UseExperimental", m_experimental); // enable experimental features like single muon SF
59  //Properties needed for TOY setup for a given trigger: No replicas if m_replicaTriggerList is empty
60  declareProperty("ReplicaTriggerList", m_replicaTriggerList, "List of triggers on which we want to generate stat. uncertainty toy replicas.");
61  declareProperty("NReplicas", m_nReplicas, "Number of generated toy replicas, if replicas are required.");
62  declareProperty("ReplicaRandomSeed", m_ReplicaRandomSeed, "Random seed for toy replica generation.");
63  declareProperty("AllowZeroSF", m_allowZeroSF, "If a trigger is not available will return 0 instead of throwing an error. More difficult to spot configuration issues. Use at own risk");
64  declareProperty("forceYear", m_forceYear, "Only for developers. Never use this in any analysis!!!!!!");
65  declareProperty("forcePeriod", m_forcePeriod, "Only for developers. Never use this in any analysis!!!!!!");
66  }
67 
69 
71  std::string fileName = m_fileName;
72  if (fileName.empty()) {
73  if (year == 2015) fileName = "muontrigger_sf_2015_mc20a_v1.root";
74  else if (year == 2016) fileName = "muontrigger_sf_2016_mc20a_v1.root";
75  else if (year == 2017) fileName = "muontrigger_sf_2017_mc20d_v1.root";
76  else if (year == 2018) fileName = "muontrigger_sf_2018_mc20e_v2.root";
77  else if (year == 2022) fileName = "muontrigger_sf_2022_mc21_v05.root";
78  else{
79  ATH_MSG_WARNING("There is no SF file for year " << year << " yet");
80  return StatusCode::SUCCESS;
81  }
82  }
83 
84  TDirectory* origDir = gDirectory;
85 
86  std::string filePath;
87 
88  if (m_custom_dir.empty()) {
89  filePath = PathResolverFindCalibFile(Form("MuonEfficiencyCorrections/%s/%s", m_calibration_version.c_str(), fileName.c_str()));
90  if (filePath.empty()) {
91  ATH_MSG_ERROR("Unable to resolve the input file " << fileName << " via PathResolver.");
92  }
93  }
94  else {
95  ATH_MSG_INFO("Note: setting up with user specified input file location " << m_custom_dir << " - this is not encouraged!");
96  filePath = PathResolverFindCalibFile(Form("%s/%s", m_custom_dir.c_str(), fileName.c_str()));
97  }
98 
99  TFile* file = TFile::Open(filePath.c_str());
100 
101  if (file == nullptr || !file->IsOpen()) {
102  ATH_MSG_FATAL("MuonTriggerScaleFactors::initialize Couldn't open file " << filePath);
103  return StatusCode::FAILURE;
104  }
105  TDirectory* tempDir = getTemporaryDirectory();
106  tempDir->cd();
107 
108  static const std::vector<std::string> type { "data", "mc" };
109  static const std::vector<std::string> region { "barrel", "endcap" };
110  static const std::vector<std::string> systematic { "nominal", "stat_up", "stat_down", "syst_up", "syst_down" };
111  if(m_muonquality.compare("LowPt") == 0)
112  m_muonquality = "Medium";
113  const std::string quality = m_muonquality;
114  TDirectory* qualityDirectory = file->GetDirectory(m_muonquality.c_str());
115  if (qualityDirectory == nullptr) {
116  ATH_MSG_FATAL("MuonTriggerScaleFactors::initialize cannot find directory with selected quality");
117  return StatusCode::FAILURE;
118  }
119  TKey* periodKey;
120  TIter nextPeriod(qualityDirectory->GetListOfKeys());
121  while ((periodKey = (TKey*) nextPeriod())) {
122  if (not periodKey->IsFolder()) continue;
123  TDirectory* periodDirectory = qualityDirectory->GetDirectory(periodKey->GetName());
124  std::string periodName = std::string(periodKey->GetName());
125  std::string periodName_InMap = periodName.substr(std::string("Period").size(), periodName.size());
126  YearPeriod period = YearPeriod(year, periodName_InMap);
127  TKey* triggerKey;
128  TIter nextTrigger(periodDirectory->GetListOfKeys());
129  while ((triggerKey = (TKey*) nextTrigger())) {
130  if (not triggerKey->IsFolder()) continue;
131  TDirectory* triggerDirectory = periodDirectory->GetDirectory(triggerKey->GetName());
132  std::string triggerName = std::string(triggerKey->GetName());
133  if(!std::set<std::string>{"HLT_mu26_ivarmedium", "HLT_mu50", "HLT_mu26_ivarmedium_OR_HLT_mu50"}.count(triggerName) && m_binning == "coarse"){
134  ATH_MSG_DEBUG("Coarse binning not supported for di-muon trigger legs at the moment");
135  continue;
136  }
137  for (const auto& iregion : region) {
138  bool isBarrel = iregion.find("barrel") != std::string::npos;
139  for (const auto& itype : type) {
140  bool isData = itype.find("data") != std::string::npos;
141  std::string histname = ("_MuonTrigEff_" + periodName + "_" + triggerName + "_" + quality + "_" + "_EtaPhi_" + m_binning + "_" + iregion + "_" + itype);
142  for (const auto& isys : systematic) {
143  if (itype.find("data") != std::string::npos && isys.find("syst") != std::string::npos) continue;
144  std::string path = "eff_etaphi_" + m_binning + "_" + iregion + "_" + itype + "_" + isys;
145  TH2* hist = dynamic_cast<TH2*>(triggerDirectory->Get(path.c_str()));
146  if (not hist) {
147 
148  ATH_MSG_FATAL("MuonTriggerScaleFactors::initialize " << path << " not found under trigger " << triggerName << " and period " << periodName << " for year: " << year);
149  continue;
150  }
151  hist->SetDirectory(0);
152 
153  EffiHistoIdent HistoId = EffiHistoIdent(period, encodeHistoName(periodName_InMap, triggerName, isData, isys, isBarrel));
154  if (m_efficiencyMap.find(HistoId) != m_efficiencyMap.end()) {
155  ATH_MSG_FATAL("MuonTriggerScaleFactors::initialize(): histogram " << path << " is duplicated for year" << year << " in period " << periodName);
156  return StatusCode::FAILURE;
157  }
158  m_efficiencyMap.insert(std::pair<EffiHistoIdent, TH1_Ptr>(HistoId, std::shared_ptr < TH1 > (hist)));
159 
160  }
161  //If the trigger is chosen for toy evaluation, generate all the replicas from
162  // NOMINAL with STAT variations stored in the data hist, load them in corresponding vector
163  if (m_replicaSet.find(triggerName) != m_replicaSet.end() && itype.find("data") != std::string::npos) {
164 
165  TH1_Ptr Nominal_H = getEfficiencyHistogram(year, periodName, triggerName, isData, "nominal", isBarrel);
166  TH1_Ptr StatUp_H = getEfficiencyHistogram(year, periodName, triggerName, isData, "stat_up", isBarrel);
167 
168  TH1_Ptr tmp_h2 = TH1_Ptr(dynamic_cast<TH2F*>(Nominal_H->Clone(Form("tmp_h2_%s", Nominal_H->GetName()))));
169  const int xbins = tmp_h2->GetNbinsX(), ybins = tmp_h2->GetNbinsY();
170  for (int x_i = 0; x_i <= xbins; ++x_i) {
171  for (int y_i = 0; y_i <= ybins; ++y_i) {
172  double statErr = std::abs(tmp_h2->GetBinContent(x_i, y_i) - StatUp_H->GetBinContent(x_i, y_i));
173  tmp_h2->SetBinError(x_i, y_i, statErr);
174  }
175  }
177  }
178  }
179  }
180  }
181  }
182  file->Close();
183  delete file;
184  origDir->cd();
185  return StatusCode::SUCCESS;
186  }
187  // ==================================================================================
188  // == MuonTriggerScaleFactors::initialize()
189  // ==================================================================================
191 
192  ATH_MSG_INFO("MuonQuality = '" << m_muonquality << "'");
193  ATH_MSG_INFO("Binning = '" << m_binning << "'");
194  ATH_MSG_INFO("CalibrationRelease = '" << m_calibration_version << "'");
195  ATH_MSG_INFO("CustomInputFolder = '" << m_custom_dir << "'");
196  ATH_MSG_INFO("AllowZeroSF = " << m_allowZeroSF);
197  ATH_MSG_INFO("experimental = " << m_experimental);
198 
200 
201  if (registerSystematics() != StatusCode::SUCCESS) {
202  return StatusCode::FAILURE;
203  }
204 
205  if (applySystematicVariation(CP::SystematicSet()) != StatusCode::SUCCESS) {
206  ATH_MSG_ERROR("Could not configure for nominal settings");
207  return StatusCode::FAILURE;
208  }
209  // Initialize indexes of replicas for trigges which are asked
210  for (auto trigToy : m_replicaTriggerList)
211  m_replicaSet.insert(trigToy);
212 
213  ATH_MSG_INFO("MuonTriggerScaleFactors::initialize");
214  static const int years_to_run[5] = {2015, 2016, 2017, 2018, 2022};
215  for (const int &year: years_to_run) {
216 
217  // skip 2022 Tight WP as it is not supported
218  if ((year == 2022) && (m_muonquality == "Tight")) continue;
220  }
221  return StatusCode::SUCCESS;
222  }
223 
224  CorrectionCode MuonTriggerScaleFactors::getTriggerScaleFactor(const xAOD::Muon& muon, Double_t& triggersf, const std::string& trigger) const {
225  if(!m_experimental){
226  ATH_MSG_ERROR("MuonTriggerScaleFactors::getTriggerScaleFactor This is an experimental function. If you really know what you are doing set UseExperimental property.");
227  return CorrectionCode::Error;
228  }
229 
230  if (trigger.empty()) {
231  ATH_MSG_ERROR("MuonTriggerScaleFactors::getTriggerScaleFactor Trigger must have value.");
232  return CorrectionCode::Error;
233  }
234 
235  TrigMuonEff::Configuration configuration;
236 
237  if (trigger == "HLT_mu8noL1")
238  ATH_MSG_WARNING("What you are trying to do is not correct. For di-muon triggers you should get the efficiency with getTriggerEfficiency and compute the SF by yourself.");
239  else if (trigger.find("HLT_2mu10") != std::string::npos || trigger.find("HLT_2mu14") != std::string::npos)
240  ATH_MSG_WARNING("Di-muon trigger scale factors for single reco muons are not supported!");
241  else
242  return GetTriggerSF(triggersf, configuration, muon, trigger);
243  return CorrectionCode::Ok;
244  }
245 
246  CorrectionCode MuonTriggerScaleFactors::getTriggerScaleFactor(const xAOD::MuonContainer& mucont, Double_t& triggersf, const std::string& trigger) const{
247  if (trigger.empty()) {
248  ATH_MSG_ERROR("MuonTriggerScaleFactors::getTriggerScaleFactor Trigger must have value.");
249  return CorrectionCode::Error;
250  }
251 
252  TrigMuonEff::Configuration configuration;
253 
254  if (trigger == "HLT_mu8noL1") {
255  ATH_MSG_WARNING("What you are trying to do is not correct. For di-muon triggers you should get the efficiency with getTriggerEfficiency and compute the SF by yourself.");
256  }
257  else if (trigger.find("HLT_2mu10") != std::string::npos || trigger.find("HLT_2mu14") != std::string::npos) {
258  CorrectionCode cc = GetTriggerSF_dimu(triggersf, configuration, mucont, trigger);
259  return cc;
260  } else {
261  CorrectionCode cc = GetTriggerSF(triggersf, configuration, mucont, trigger);
262  return cc;
263  }
264  return CorrectionCode::Ok;
265  }
266 
267  // ==================================================================================
268  // == MuonTriggerScaleFactors::getReplica_index
269  // ==================================================================================
270  // Gets replica index correponding to the toy.
271  // Also checks if the sys_name contains "MCTOY" and if the trigger has replicas generated.
272  // Returns -1 if conditions are note satisfied
273  int MuonTriggerScaleFactors::getReplica_index(const std::string& sysBaseName, const std::string& trigStr) const{
274  if (m_replicaSet.find(trigStr) == m_replicaSet.end()) return -1; //No toys for this trigger
275  std::size_t pos = sysBaseName.find("MCTOY");
276  if (pos == std::string::npos) return -1; //sys variation not affected by TOYS
277  return atoi(sysBaseName.substr(pos + 5, pos + 8).c_str()); //toys for this trigger are around get the 3-digit number
278  }
279 
281  if (trigger.empty()) {
282  ATH_MSG_ERROR("MuonTriggerScaleFactors::getTriggerEfficiency Trigger must have value.");
283  return CorrectionCode::Error;
284  }
285  TrigMuonEff::Configuration configuration;
286  configuration.isData = dataType;
287  configuration.replicaIndex = -1;
288  Int_t threshold;
290  if (result != CorrectionCode::Ok) return result;
291  if (mu.pt() < threshold) {
292  efficiency = 0;
293  return CorrectionCode::Ok;
294  }
295 
296  // Pre-define uncertainty variations
297  static const CP::SystematicVariation stat_up("MUON_EFF_TrigStatUncertainty", 1);
298  static const CP::SystematicVariation stat_down("MUON_EFF_TrigStatUncertainty", -1);
299  static const CP::SystematicVariation syst_up("MUON_EFF_TrigSystUncertainty", 1);
300  static const CP::SystematicVariation syst_down("MUON_EFF_TrigSystUncertainty", -1);
301 
302  std::string systype = "";
303  if (appliedSystematics().matchSystematic(syst_down) && !dataType) {
304  systype = "syst_down";
305  } else if (appliedSystematics().matchSystematic(syst_up) && !dataType) {
306  systype = "syst_up";
307  } else if (appliedSystematics().matchSystematic(stat_down)) {
308  systype = "stat_down";
309  } else if (appliedSystematics().matchSystematic(stat_up)) {
310  systype = "stat_up";
311  } else {
312  systype = "nominal";
313  }
314 
315  // Toys, if found, will overwrite the data hists stat with the generated toy
316  //+++++++++++++
317  // The best way is the use of filterByName with the 000MCTOY at the end. See:
318  // if( !(appliedSystematics().filterByBaseName("MUON_EFF_Trig_MCTOY000")).empty()){//The following is a hack!!!
319  //++++++++++THE FOLLOWING IS A PARTIAL HACK!!!
320  if (!appliedSystematics().empty() && configuration.isData == true) {
322  if (configuration.replicaIndex != -1) systype = "replicas";
323  }
324  CorrectionCode cc = getMuonEfficiency(efficiency, configuration, mu, trigger, systype);
325  return cc;
326  }
327 
329  // Private functions //
331 
332  // ==================================================================================
333  // == MuonTriggerScaleFactors::generateReplicas
334  // ==================================================================================
335  // Generate replicas of h for Toys with each bin of h varied with Gaussian distribution
336  // with mean from bin content and sigma from bin error
337  std::vector<TH1_Ptr> MuonTriggerScaleFactors::generateReplicas(TH1_Ptr h, int nrep, int seed) const {
338  TRandom3 Rndm(seed);
339  std::vector<TH1_Ptr> replica_v;
340  const int xbins = h->GetNbinsX(), ybins = h->GetNbinsY();
341 
342  for (int t = 0; t < nrep; ++t) {
343  TH2* replica = dynamic_cast<TH2*>(h->Clone(Form("rep%d_%s", t, h->GetName())));
344 
345  for (int x_i = 0; x_i <= xbins; ++x_i) {
346  for (int y_i = 0; y_i <= ybins; ++y_i) {
347  replica->SetBinContent(x_i, y_i, Rndm.Gaus(h->GetBinContent(x_i, y_i), h->GetBinError(x_i, y_i)));
348  }
349  }
350  replica_v.push_back(TH1_Ptr(replica));
351  }
352  return replica_v;
353  }
354 
355  bool MuonTriggerScaleFactors::isTriggerSupported(const std::string& trigger) const{
356  TH1_Ptr H1 = getEfficiencyHistogram(trigger, true, "nominal");
357  return H1.get() != nullptr;
358  }
359 
360  int MuonTriggerScaleFactors::getBinNumber(const xAOD::Muon& muon, const std::string& trigger) const{
361  if(!m_experimental){
362  ATH_MSG_ERROR("MuonTriggerScaleFactors::getTriggerScaleFactor This is an experimental function. If you really know what you are doing set UseExperimental property.");
363  return CorrectionCode::Error;
364  }
365 
366  const double mu_eta = muon.eta();
367  const double mu_phi = muon.phi();
368  bool isBarrel = std::abs(mu_eta) < muon_barrel_endcap_boundary;
369  TH1_Ptr cit = getEfficiencyHistogram(trigger, true, "nominal", isBarrel);
370  if(!cit.get()){
371  if(!m_allowZeroSF)
372  ATH_MSG_ERROR("Could not find efficiency map for muon with eta: " << mu_eta << " and phi: " << mu_phi << ". Something is inconsistent. Please check your settings for year, mc and trigger." );
373  return -1;
374  }
375  auto eff_h2 = cit;
376  double mu_phi_corr = mu_phi;
377  if (mu_phi_corr < eff_h2->GetYaxis()->GetXmin()) mu_phi_corr += 2.0 * M_PI;
378  if (mu_phi_corr > eff_h2->GetYaxis()->GetXmax()) mu_phi_corr -= 2.0 * M_PI;
379  return eff_h2->FindFixBin(mu_eta, mu_phi_corr);
380  }
381 
382  unsigned int MuonTriggerScaleFactors::encodeHistoName(const std::string& period, const std::string& Trigger, bool isData, const std::string& Systematic, bool isBarrel) const {
383  //keep the string as short as possible
384  const std::string histName = period + "_" + Trigger + "_" + (isBarrel ? "b" : "e") + "_" + (isData ? "data" : "mc") + Systematic;
385  return std::hash<std::string>()(histName);
386  }
387 
388  unsigned int MuonTriggerScaleFactors::encodeHistoName(const std::string& Trigger, const TrigMuonEff::Configuration& configuration, const std::string& Systematic, bool isBarrel) const {
389  //keep the string as short as possible
390  return encodeHistoName(getDataPeriod(), Trigger, configuration.isData, Systematic, isBarrel);
391 
392  }
393  TH1_Ptr MuonTriggerScaleFactors::getEfficiencyHistogram(unsigned int year, const std::string& period, const std::string& trigger, bool isData, const std::string& Systematic, bool isBarrel) const {
395  EfficiencyMap::const_iterator Itr = m_efficiencyMap.find(Ident);
396 
397  if (Itr == m_efficiencyMap.end()) {
398  return TH1_Ptr();
399  }
400  return Itr->second;
401  }
402  TH1_Ptr MuonTriggerScaleFactors::getEfficiencyHistogram(const std::string& trigger, bool isData, const std::string& Systematic, bool isBarrel) const {
403  unsigned int run = getRunNumber();
405  }
406 
407  CorrectionCode MuonTriggerScaleFactors::getMuonEfficiency(Double_t& eff, const TrigMuonEff::Configuration& configuration, const xAOD::Muon& muon, const std::string& trigger, const std::string& systematic) const{
408  const double mu_eta = muon.eta();
409  const double mu_phi = muon.phi();
410  bool isBarrel = std::abs(mu_eta) < muon_barrel_endcap_boundary;
411 
412  TH1_Ptr eff_h2 = nullptr;
413  if (configuration.replicaIndex >= 0) { //Only look into the replicas if asking for them
414 
415  unsigned int run = getRunNumber();
417  std::map<EffiHistoIdent, std::vector<TH1_Ptr> >::const_iterator cit = m_efficiencyMapReplicaArray.find(Ident);
418  if (cit == m_efficiencyMapReplicaArray.end()) {
419  if (m_allowZeroSF) {
420  ATH_MSG_WARNING("Could not find what you are looking for in the efficiency map. The trigger you are looking for, year and mc are not consistent, or the trigger is unavailable in this data period. Returning efficiency = 0.");
421  eff = 0.;
422  return CorrectionCode::Ok;
423  }
424 
425  else {
426  ATH_MSG_ERROR("Could not find what you are looking for in the efficiency map. The trigger you are looking for, year and mc are not consistent, or the trigger is unavailable in this data period. Please check how you set up the tool.");
428  }
429  }
430 
431  if (configuration.replicaIndex >= (int) cit->second.size()) {
432  ATH_MSG_ERROR("MuonTriggerScaleFactors::getMuonEfficiency ; index for replicated histograms is out of range.");
434  }
435 
436  eff_h2 = cit->second[configuration.replicaIndex];
437  } else { //Standard case, look into the usual eff map
438  TH1_Ptr cit = getEfficiencyHistogram(trigger, configuration.isData, systematic, isBarrel);
439  if (cit.get() == nullptr) {
440  if (m_allowZeroSF) {
441  ATH_MSG_WARNING("Could not find what you are looking for in the efficiency map. The trigger you are looking for, year and mc are not consistent, or the trigger is unavailable in this data period. Returning efficiency = 0.");
442  eff = 0.;
443  return CorrectionCode::Ok;
444  } else {
445  ATH_MSG_ERROR("Could not find what you are looking for in the efficiency map. The trigger you are looking for, year and mc are not consistent, or the trigger is unavailable in this data period. Please check how you set up the tool.");
447  }
448  }
449  eff_h2 = cit;
450  }
451 
452  double mu_phi_corr = mu_phi;
453  if (mu_phi_corr < eff_h2->GetYaxis()->GetXmin()) mu_phi_corr += 2.0 * M_PI;
454  if (mu_phi_corr > eff_h2->GetYaxis()->GetXmax()) mu_phi_corr -= 2.0 * M_PI;
455 
456  const int bin = eff_h2->FindFixBin(mu_eta, mu_phi_corr);
457  const double efficiency = eff_h2->GetBinContent(bin);
458 
459  eff = efficiency;
460 
461  ATH_MSG_DEBUG("getMuonEfficiency [eta,phi,phi_corr]=[" << mu_eta << "," << mu_phi << "," << mu_phi_corr << "], ibin=" << bin << " eff=" << eff);
462 
463  return CorrectionCode::Ok;
464 
465  }
466 
467  CorrectionCode MuonTriggerScaleFactors::GetTriggerSF_dimu(Double_t& TriggerSF, TrigMuonEff::Configuration& configuration, const xAOD::MuonContainer& mucont, const std::string& trigger) const{
468 
469  if (mucont.size() != 2) {
470  ATH_MSG_FATAL("MuonTriggerScaleFactors::GetTriggerSF;Currently dimuon trigger chains only implemented for events with exactly 2 muons.");
471  }
472  ATH_MSG_DEBUG("The trigger that you choose : " << trigger);
473 
474  Double_t eff_data = 0;
475  Double_t eff_mc = 0;
476 
477  std::string data_err = "";
478  std::string mc_err = "";
479 
480  if (appliedSystematics().matchSystematic(CP::SystematicVariation("MUON_EFF_TrigSystUncertainty", -1))) {
481  data_err = "nominal";
482  mc_err = "syst_up";
483  } else if (appliedSystematics().matchSystematic(CP::SystematicVariation("MUON_EFF_TrigSystUncertainty", 1))) {
484  data_err = "nominal";
485  mc_err = "syst_down";
486  } else if (appliedSystematics().matchSystematic(CP::SystematicVariation("MUON_EFF_TrigStatUncertainty", -1))) {
487  data_err = "stat_down";
488  mc_err = "nominal";
489  } else if (appliedSystematics().matchSystematic(CP::SystematicVariation("MUON_EFF_TrigStatUncertainty", 1))) {
490  data_err = "stat_up";
491  mc_err = "nominal";
492  } else {
493  data_err = "nominal";
494  mc_err = "nominal";
495  }
496 
497  //Toys, if found, will overwrite the data hists with the sys generated with one toy
498  //+++++++++++++
499  //The best way is the use of filterByName with the 000MCTOY at the end. See:
500  // if( !(appliedSystematics().filterByBaseName("MUON_EFF_Trig_MCTOY000")).empty()){//The following is a hack!!!
501  //++++++++++THE FOLLOWING IS A PARTIAL HACK!!!
502  if (!appliedSystematics().empty()) {
504  if (configuration.replicaIndex != -1) data_err = "replicas";
505  }
506 
507  configuration.isData = true;
508  CorrectionCode result = getDimuonEfficiency(eff_data, configuration, mucont, trigger, data_err);
509  if (result != CorrectionCode::Ok) return result;
510 
511  configuration.isData = false;
512  configuration.replicaIndex = -1;
513  result = getDimuonEfficiency(eff_mc, configuration, mucont, trigger, mc_err);
514  if (result != CorrectionCode::Ok) return result;
515 
516  double event_SF = 1.;
517 
518  if (std::abs(1. - eff_mc) > 0.0001) {
519  event_SF = eff_data / eff_mc;
520  }
521 
522  TriggerSF = event_SF;
523  return CorrectionCode::Ok;
524  }
525 
526  CorrectionCode MuonTriggerScaleFactors::GetTriggerSF(Double_t& TriggerSF, TrigMuonEff::Configuration& configuration, const xAOD::MuonContainer& mucont, const std::string& trigger) const{
527  Int_t threshold;
529  if (result != CorrectionCode::Ok) return result;
530 
531  double rate_not_fired_data = 1.;
532  double rate_not_fired_mc = 1.;
533 
534  for (const auto mu : mucont) {
535 
536  double eff_data = 0., eff_mc = 0.;
537 
538  if (mu->pt() < threshold) {
539 
540  eff_data = 0.;
541  eff_mc = 0.;
542 
543  } else {
544 
545  std::string muon_trigger_name = trigger;
546  std::string data_err = "";
547  std::string mc_err = "";
548 
549  // Pre-define uncertainty variations
550  static const CP::SystematicVariation stat_up("MUON_EFF_TrigStatUncertainty", 1);
551  static const CP::SystematicVariation stat_down("MUON_EFF_TrigStatUncertainty", -1);
552  static const CP::SystematicVariation syst_up("MUON_EFF_TrigSystUncertainty", 1);
553  static const CP::SystematicVariation syst_down("MUON_EFF_TrigSystUncertainty", -1);
554 
555  if (appliedSystematics().matchSystematic(syst_down)) {
556  data_err = "nominal";
557  mc_err = "syst_up";
558  } else if (appliedSystematics().matchSystematic(syst_up)) {
559  data_err = "nominal";
560  mc_err = "syst_down";
561  } else if (appliedSystematics().matchSystematic(stat_down)) {
562  data_err = "stat_down";
563  mc_err = "nominal";
564  } else if (appliedSystematics().matchSystematic(stat_up)) {
565  data_err = "stat_up";
566  mc_err = "nominal";
567  } else {
568  data_err = "nominal";
569  mc_err = "nominal";
570  }
571 
572  //Toys, if found, will overwrite the data hists, on which toys for stat uncertainty have been generated
573  //+++++++++++++
574  //The best way is the use of filterByName with the 000MCTOY at the end. See:
575  // if( !(appliedSystematics().filterByBaseName("MUON_EFF_Trig_MCTOY000")).empty()){//The following is a hack!!!
576  //++++++++++The following is a hack!!!
577  if (!appliedSystematics().empty()) {
579  if (configuration.replicaIndex != -1) data_err = "replicas";
580  }
581 
582  configuration.isData = true;
583  CorrectionCode result_data = getMuonEfficiency(eff_data, configuration, *mu, muon_trigger_name, data_err);
584  if (result_data != CorrectionCode::Ok) return result_data;
585  configuration.isData = false;
586  configuration.replicaIndex = -1;
587  CorrectionCode result_mc = getMuonEfficiency(eff_mc, configuration, *mu, muon_trigger_name, mc_err);
588  if (result_mc != CorrectionCode::Ok) return result_mc;
589  }
590  rate_not_fired_data *= (1. - eff_data);
591  rate_not_fired_mc *= (1. - eff_mc);
592  }
593 
594  double event_SF = 1.;
595  if (1 - rate_not_fired_data == 0) event_SF = 0;
596  if ((mucont.size()) and (std::abs(1. - rate_not_fired_mc) > 0.0001)) {
597 
598  event_SF = (1. - rate_not_fired_data) / (1. - rate_not_fired_mc);
599  }
600  TriggerSF = event_SF;
601 
602  return CorrectionCode::Ok;
603  }
604 
605  CorrectionCode MuonTriggerScaleFactors::GetTriggerSF(Double_t& TriggerSF, TrigMuonEff::Configuration& configuration, const xAOD::Muon& mu, const std::string& trigger) const{
606  Int_t threshold;
608  if (result != CorrectionCode::Ok)
609  return result;
610 
611  double eff_data = 0., eff_mc = 0.;
612 
613  if (mu.pt() < threshold) {
614  eff_data = 0.;
615  eff_mc = 0.;
616  TriggerSF = 1.;
617  return CorrectionCode::Ok;
618  }
619 
620  std::string muon_trigger_name = trigger;
621  std::string data_err = "";
622  std::string mc_err = "";
623 
624  // Pre-define uncertainty variations
625  static const CP::SystematicVariation stat_up("MUON_EFF_TrigStatUncertainty", 1);
626  static const CP::SystematicVariation stat_down("MUON_EFF_TrigStatUncertainty", -1);
627  static const CP::SystematicVariation syst_up("MUON_EFF_TrigSystUncertainty", 1);
628  static const CP::SystematicVariation syst_down("MUON_EFF_TrigSystUncertainty", -1);
629 
630  if (appliedSystematics().matchSystematic(syst_down)) {
631  data_err = "nominal";
632  mc_err = "syst_up";
633  } else if (appliedSystematics().matchSystematic(syst_up)) {
634  data_err = "nominal";
635  mc_err = "syst_down";
636  } else if (appliedSystematics().matchSystematic(stat_down)) {
637  data_err = "stat_down";
638  mc_err = "nominal";
639  } else if (appliedSystematics().matchSystematic(stat_up)) {
640  data_err = "stat_up";
641  mc_err = "nominal";
642  } else {
643  data_err = "nominal";
644  mc_err = "nominal";
645  }
646 
647  if (!appliedSystematics().empty()) {
649  if (configuration.replicaIndex != -1) data_err = "replicas";
650  }
651 
652  configuration.isData = true;
653  CorrectionCode result_data = getMuonEfficiency(eff_data, configuration, mu, muon_trigger_name, data_err);
654  if (result_data != CorrectionCode::Ok)
655  return result_data;
656  configuration.isData = false;
657  configuration.replicaIndex = -1;
658  CorrectionCode result_mc = getMuonEfficiency(eff_mc, configuration, mu, muon_trigger_name, mc_err);
659  if (result_mc != CorrectionCode::Ok)
660  return result_mc;
661  if (eff_data == 0)
662  TriggerSF = 0;
663  if (std::abs(eff_mc) > 0.0001)
664  TriggerSF = eff_data / eff_mc;
665  return CorrectionCode::Ok;
666  }
667 
668  CorrectionCode MuonTriggerScaleFactors::getDimuonEfficiency(Double_t& eff, const TrigMuonEff::Configuration& configuration, const xAOD::MuonContainer& mucont, const std::string& chain, const std::string& systematic) const{
669 
671  Int_t threshold;
673  if (result != CorrectionCode::Ok) return result;
674 
676  xAOD::MuonContainer::const_iterator mu2 = mucont.begin() + 1;
677 
678  Double_t eff1 = 0;
679  if ((**mu1).pt() > threshold) {
680  CorrectionCode result1 = getMuonEfficiency(eff1, configuration, (**mu1), trigger, systematic);
681  if (result1 != CorrectionCode::Ok) return result1;
682  }
683  Double_t eff2 = 0;
684  if ((**mu2).pt() > threshold) {
685  CorrectionCode result2 = getMuonEfficiency(eff2, configuration, (**mu2), trigger, systematic);
686  if (result2 != CorrectionCode::Ok) return result2;
687  }
688 
689  eff = eff1 * eff2;
690  return CorrectionCode::Ok;
691  }
692 
694  if (trigger.find("2mu10") != std::string::npos) return "HLT_mu10";
695  if (trigger.find("2mu14") != std::string::npos) return "HLT_mu14";
696  throw std::runtime_error("Unknown dimuon trigger");
697  }
698 
700  std::size_t index = trigger.find("HLT_mu");
701  if (index != std::string::npos) {
702  std::string rawNumber = trigger.substr(index + 6);
703  if (!rawNumber.empty() && isdigit(rawNumber[0])) {
704  std::stringstream(rawNumber) >> threshold;
705  if (threshold < 10) threshold = 10000;
706  else threshold = (threshold + 1) * 1000;
707  return CorrectionCode::Ok;
708  }
709  }
710  ATH_MSG_ERROR("MuonTriggerScaleFactors::getThreshold Could not extract threshold for trigger " << trigger);
711  return CorrectionCode::Error;
712  }
713 
714  unsigned int MuonTriggerScaleFactors::getYear(unsigned int run) const {
715  if(m_forceYear != -1){
716  return m_forceYear;
717  }
718  if (run <= 284484) return 2015;
719  else if (run <= 311481) return 2016;
720  else if (run <= 340453) return 2017;
721  else if (run <= 364292) return 2018;
722  else return 2022;
723  }
724 
726  return getDataPeriod(getRunNumber());
727  }
728 
729  std::string MuonTriggerScaleFactors::getDataPeriod(unsigned int run) const {
730  return getDataPeriod(run, getYear(run));
731  }
732 
733  std::string MuonTriggerScaleFactors::getDataPeriod(unsigned int runNumber, unsigned year) const {
734  if(!m_forcePeriod.empty())
735  return m_forcePeriod;
736  if (year == 2015) {
737  if (runNumber >= 266904 && runNumber <= 272531) return "AC";
738  else if (runNumber >= 276073 && runNumber <= 276954) return "D";
739  else if (runNumber >= 278727 && runNumber <= 279928) return "E";
740  else if (runNumber >= 279932 && runNumber <= 280422) return "F";
741  else if (runNumber >= 280423 && runNumber <= 281075) return "G";
742  else if (runNumber >= 281130 && runNumber <= 281411) return "H";
743  else if (runNumber >= 281662 && runNumber <= 282482) return "I"; // special ALFA run
744  else if (runNumber >= 282625 && runNumber <= 284484) return "J";
745  }
746  else if (year == 2016) {
747  if (runNumber >= 296939 && runNumber <= 300287) return "A";
748  else if (runNumber >= 300345 && runNumber <= 300908) return "B";
749  else if (runNumber >= 301912 && runNumber <= 302393) return "C";
750  else if (runNumber >= 302737 && runNumber <= 302872) return "D1D3";
751  else if (runNumber >= 302919 && runNumber <= 303560) return "D4D8";
752  else if (runNumber >= 303638 && runNumber <= 303892) return "E";
753  else if (runNumber >= 303943 && runNumber <= 304494) return "F";
754  else if (runNumber >= 305291 && runNumber <= 306714) return "G";
755  else if (runNumber >= 307124 && runNumber <= 308084) return "I";
756  else if (runNumber >= 309311 && runNumber <= 309759) return "K";
757  else if (runNumber >= 310015 && runNumber <= 311481) return "L";
758  }
759  else if (year == 2017) {
760  if (runNumber >= 324320 && runNumber <= 325558) return "A";
761  else if (runNumber >= 325713 && runNumber <= 328393) return "B";
762  else if (runNumber >= 329385 && runNumber <= 330470) return "C";
763  else if (runNumber >= 330857 && runNumber <= 332304) return "D";
764  else if (runNumber >= 332720 && runNumber <= 334779) return "E";
765  else if (runNumber >= 334842 && runNumber <= 335290) return "F";
766  else if (runNumber >= 336497 && runNumber <= 336782) return "H";
767  else if (runNumber >= 336832 && runNumber <= 337833) return "I";
768  else if (runNumber >= 338183 && runNumber <= 340453) return "K";
769  }
770  else if (year == 2018) {
771  if (runNumber >= 348197 && runNumber <= 348836) return "A";
772  else if (runNumber >= 348885 && runNumber <= 349533) return "B";
773  else if (runNumber >= 349534 && runNumber <= 350220) return "C";
774  else if (runNumber >= 350310 && runNumber <= 352107) return "D";
775  else if (runNumber >= 352123 && runNumber <= 352137) return "E";
776  else if (runNumber >= 352274 && runNumber <= 352514) return "F";
777  else if (runNumber >= 354107 && runNumber <= 354494) return "G";
778  else if (runNumber >= 354826 && runNumber <= 355224) return "H";
779  else if (runNumber >= 355261 && runNumber <= 355273) return "I";
780  else if (runNumber >= 355331 && runNumber <= 355468) return "J";
781  else if (runNumber >= 355529 && runNumber <= 356259) return "K";
782  else if (runNumber >= 357050 && runNumber <= 359171) return "L";
783  else if (runNumber >= 359191 && runNumber <= 360414) return "M";
784  else if (runNumber >= 361635 && runNumber <= 361696) return "N";
785  else if (runNumber >= 361738 && runNumber <= 363400) return "O";
786  else if (runNumber >= 363664 && runNumber <= 364292) return "Q";
787  }
788  else if (year == 2022) {
789  if(runNumber >= 430536 && runNumber <= 432180) return "F";
790  else if (runNumber >= 435816 && runNumber <= 439927) return "H";
791  else if (runNumber >= 440407 && runNumber <= 440613) return "J";
792  }
793 
794  ATH_MSG_FATAL("RunNumber: " << runNumber << " not known! Will stop the code to prevent using wrong SFs.");
795  throw std::invalid_argument{""};
796  }
797 
799  static const SG::AuxElement::ConstAccessor<unsigned int> acc_rnd("RandomRunNumber");
801  if (info.operator->()==nullptr) {
802  ATH_MSG_FATAL("Could not retrieve the xAOD::EventInfo with name: " << m_eventInfo.key() << ". Exiting the code.");
803  throw std::invalid_argument{""};
804  }
805  if (!info->eventType(xAOD::EventInfo::IS_SIMULATION)) {
806  ATH_MSG_DEBUG("The current event is a data event. Return runNumber instead.");
807  return info->runNumber();
808  }
809  if (!acc_rnd.isAvailable(*info)) {
810  if(m_forceYear == -1 && m_forcePeriod == "")
811  ATH_MSG_FATAL("Failed to find the RandomRunNumber decoration. Please call the apply() method from the PileupReweightingTool beforehand in order to get period dependent SFs");
812  throw std::invalid_argument{""};
813  } else if (acc_rnd(*info) == 0) {
814  ATH_MSG_FATAL("Pile up tool has given runNumber 0. Exiting the code.");
815  throw std::invalid_argument{""};
816  }
817 
818  // standard behaviour for MC, get the random RunNumber
819  return acc_rnd(*info);
820  }
821 
823  gROOT->cd();
824  TDirectory* tempDir = 0;
825  int counter = 0;
826  while (not tempDir) {
827  std::stringstream dirname;
828  dirname << "MuonTriggerScaleFactorsTempDir_%i" << counter;
829  if (gROOT->GetDirectory((dirname.str()).c_str())) {
830  ++counter;
831  continue;
832  }
833  tempDir = gROOT->mkdir((dirname.str()).c_str());
834  if (not tempDir) {
835  ATH_MSG_ERROR("getTemporaryDirectory::Temporary directory could not be created");
836  }
837  }
838  return tempDir;
839  }
840 
841  //=======================================================================
842  // Systematics Interface
843  //=======================================================================
845  if (!systematic.empty()) {
847  return sys.find(systematic) != sys.end();
848  }
849  return true;
850  }
851 
854  CP::SystematicSet mySysSet;
855 
856  mySysSet.insert(CP::SystematicVariation("MUON_EFF_TrigSystUncertainty", 1));
857  mySysSet.insert(CP::SystematicVariation("MUON_EFF_TrigSystUncertainty", -1));
858 
859  //Consider full statUncertainty if TOY replicas are not used
860  if (m_replicaTriggerList.size() == 0) {
861  mySysSet.insert(CP::SystematicVariation("MUON_EFF_TrigStatUncertainty", 1));
862  mySysSet.insert(CP::SystematicVariation("MUON_EFF_TrigStatUncertainty", -1));
863  } else {
864  for (int i = 0; i < m_nReplicas; ++i) { //TOFIX Hack with just up variations! needs ASG reserved words for a clean handling//+++++++
865  mySysSet.insert(CP::SystematicVariation(Form("MUON_EFF_Trig_MCTOY%03d", i), 1));
866  }
867  }
868 
869  return mySysSet;
870  }
871 
872  // Register the systematics with the registry and add them to the recommended list
875  if (registry.registerSystematics(*this) != StatusCode::SUCCESS) {
876  ATH_MSG_ERROR("Failed to add systematic to list of recommended systematics.");
877  return StatusCode::FAILURE;
878  }
879  return StatusCode::SUCCESS;
880  }
881 
884  return affectingSystematics();
885  }
886 
888  // First, check if we already know this systematic configuration
889  auto itr = m_systFilter.find(systConfig);
890 
891  // If it's a new input set, we need to filter it
892  if (itr == m_systFilter.end()) {
893 
894  // New systematic. We need to parse it.
895  static const CP::SystematicSet affectingSys = affectingSystematics();
896  CP::SystematicSet filteredSys;
897  if (!CP::SystematicSet::filterForAffectingSystematics(systConfig, affectingSys, filteredSys)) {
898  ATH_MSG_ERROR("Unsupported combination of systematics passed to the tool!");
899  return StatusCode::FAILURE;
900  }
901 
902  // Insert filtered set into the map
903  itr = m_systFilter.insert(std::make_pair(systConfig, filteredSys)).first;
904  }
905 
906  CP::SystematicSet& mySysConf = itr->second;
907 
908  // Check to see if the set of variations tries to add in the uncertainty up and down. Since the errors
909  // are symetric this would result in 0 and so should not be done.
910  static const CP::SystematicVariation stat_up("MUON_EFF_TrigStatUncertainty", 1);
911  static const CP::SystematicVariation stat_down("MUON_EFF_TrigStatUncertainty", -1);
912  static const CP::SystematicVariation syst_up("MUON_EFF_TrigSystUncertainty", 1);
913  static const CP::SystematicVariation syst_down("MUON_EFF_TrigSystUncertainty", -1);
914 
915  if ((mySysConf.matchSystematic(stat_up) && mySysConf.matchSystematic(stat_down)) || (mySysConf.matchSystematic(syst_up) && mySysConf.matchSystematic(syst_down))) {
916  return StatusCode::FAILURE;
917  }
918 
919  m_appliedSystematics = &mySysConf;
920  return StatusCode::SUCCESS;
921  }
922 
923 } /* namespace CP */
grepfile.info
info
Definition: grepfile.py:38
python.Dso.registry
registry
Definition: Control/AthenaServices/python/Dso.py:159
CP::MuonTriggerScaleFactors::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by
Definition: MuonTriggerScaleFactors.cxx:853
python.AtlRunQueryAMI.period
period
Definition: AtlRunQueryAMI.py:225
CP::MuonTriggerScaleFactors::m_replicaSet
std::set< std::string > m_replicaSet
Definition: MuonTriggerScaleFactors.h:132
CP::MuonTriggerScaleFactors::getTriggerCorrespondingToDimuonTrigger
std::string getTriggerCorrespondingToDimuonTrigger(const std::string &trigger) const
Definition: MuonTriggerScaleFactors.cxx:693
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:195
CP::MuonTriggerScaleFactors::getReplica_index
virtual int getReplica_index(const std::string &sysBaseName, const std::string &trigStr) const
Definition: MuonTriggerScaleFactors.cxx:273
CP::TH1_Ptr
std::shared_ptr< TH1 > TH1_Ptr
Definition: MuonTriggerScaleFactors.h:28
CP::MuonTriggerScaleFactors::m_ReplicaRandomSeed
int m_ReplicaRandomSeed
Definition: MuonTriggerScaleFactors.h:134
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
CP::MuonTriggerScaleFactors::initialize
virtual StatusCode initialize(void)
Dummy implementation of the initialisation function.
Definition: MuonTriggerScaleFactors.cxx:190
MuonTriggerScaleFactors.h
get_generator_info.result
result
Definition: get_generator_info.py:21
CP::MuonTriggerScaleFactors::getYear
unsigned int getYear(unsigned int run) const
Definition: MuonTriggerScaleFactors.cxx:714
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
CP::MuonTriggerScaleFactors::appliedSystematics
const CP::SystematicSet & appliedSystematics() const
Definition: MuonTriggerScaleFactors.h:74
AddEmptyComponent.histName
string histName
Definition: AddEmptyComponent.py:64
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CP::MuonTriggerScaleFactors::m_muonquality
std::string m_muonquality
Definition: MuonTriggerScaleFactors.h:120
CP::MuonTriggerScaleFactors::m_binning
std::string m_binning
Definition: MuonTriggerScaleFactors.h:125
TH2F
Definition: rootspy.cxx:420
TrigMuonEff::Configuration::isData
bool isData
Definition: IMuonTriggerScaleFactors.h:24
CP::MuonTriggerScaleFactors::getDimuonEfficiency
virtual CorrectionCode getDimuonEfficiency(Double_t &eff, const TrigMuonEff::Configuration &configuration, const xAOD::MuonContainer &mucont, const std::string &chain, const std::string &systematic) const
Definition: MuonTriggerScaleFactors.cxx:668
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
xAODP4Helpers.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
MuonRoIContainer.h
CP::MuonTriggerScaleFactors::m_appliedSystematics
CP::SystematicSet * m_appliedSystematics
Definition: MuonTriggerScaleFactors.h:115
plotmaker.hist
hist
Definition: plotmaker.py:148
CP::MuonTriggerScaleFactors::m_forcePeriod
std::string m_forcePeriod
Definition: MuonTriggerScaleFactors.h:129
CP::MuonTriggerScaleFactors::m_nReplicas
int m_nReplicas
Definition: MuonTriggerScaleFactors.h:133
CP::MuonTriggerScaleFactors::EffiHistoIdent
std::pair< YearPeriod, unsigned int > EffiHistoIdent
Definition: MuonTriggerScaleFactors.h:91
CP::MuonTriggerScaleFactors::generateReplicas
std::vector< TH1_Ptr > generateReplicas(TH1_Ptr h, int nrep, int seed) const
Definition: MuonTriggerScaleFactors.cxx:337
CP::MuonTriggerScaleFactors::m_allowZeroSF
bool m_allowZeroSF
Definition: MuonTriggerScaleFactors.h:126
CP::MuonTriggerScaleFactors::getTemporaryDirectory
TDirectory * getTemporaryDirectory(void) const
Definition: MuonTriggerScaleFactors.cxx:822
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
dirname
std::string dirname(std::string name)
Definition: utils.cxx:200
asg
Definition: DataHandleTestTool.h:28
PixelAthClusterMonAlgCfg.ybins
ybins
Definition: PixelAthClusterMonAlgCfg.py:163
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
M_PI
#define M_PI
Definition: ActiveFraction.h:11
bin
Definition: BinsDiffFromStripMedian.h:43
CP::MuonTriggerScaleFactors::getTriggerScaleFactor
virtual CorrectionCode getTriggerScaleFactor(const xAOD::MuonContainer &mucont, Double_t &triggersf, const std::string &trigger) const
Definition: MuonTriggerScaleFactors.cxx:246
downloadSingle.dataType
string dataType
Definition: downloadSingle.py:18
CP::MuonTriggerScaleFactors::m_replicaTriggerList
std::vector< std::string > m_replicaTriggerList
Definition: MuonTriggerScaleFactors.h:131
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:54
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
CP::SystematicVariation
Definition: SystematicVariation.h:47
python.AtlRunQueryAMI.year
year
Definition: AtlRunQueryAMI.py:226
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::MuonTriggerScaleFactors::~MuonTriggerScaleFactors
virtual ~MuonTriggerScaleFactors()
Definition: MuonTriggerScaleFactors.cxx:68
DeMoAtlasDataLoss.periodName
list periodName
Definition: DeMoAtlasDataLoss.py:129
CP::MuonTriggerScaleFactors::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
Definition: MuonTriggerScaleFactors.cxx:887
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::MuonTriggerScaleFactors::getBinNumber
virtual int getBinNumber(const xAOD::Muon &muon, const std::string &trigger) const
Definition: MuonTriggerScaleFactors.cxx:360
CP::MuonTriggerScaleFactors::GetTriggerSF_dimu
virtual CorrectionCode GetTriggerSF_dimu(Double_t &TriggerSF, TrigMuonEff::Configuration &configuration, const xAOD::MuonContainer &mucont, const std::string &trigger) const
Definition: MuonTriggerScaleFactors.cxx:467
MuonAuxContainer.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TrigMuonEff::Configuration
structure to hold variables to configure behaviour of the tool
Definition: IMuonTriggerScaleFactors.h:23
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
efficiency
void efficiency(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:128
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
PixelAthClusterMonAlgCfg.histname
histname
Definition: PixelAthClusterMonAlgCfg.py:106
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:92
SystematicRegistry.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CP::MuonTriggerScaleFactors::LoadTriggerMap
StatusCode LoadTriggerMap(unsigned int year)
Definition: MuonTriggerScaleFactors.cxx:70
mergePhysValFiles.origDir
origDir
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:24
CP::MuonTriggerScaleFactors::m_calibration_version
std::string m_calibration_version
Definition: MuonTriggerScaleFactors.h:123
file
TFile * file
Definition: tile_monitor.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
run
Definition: run.py:1
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TrigMuonEff::Configuration::replicaIndex
int replicaIndex
index of replicated histograms to access
Definition: IMuonTriggerScaleFactors.h:25
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
TH2
Definition: rootspy.cxx:373
plotIsoValidation.mu_phi
mu_phi
Definition: plotIsoValidation.py:152
CP::MuonTriggerScaleFactors::isAffectedBySystematic
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const
Declare the interface that this class provides.
Definition: MuonTriggerScaleFactors.cxx:844
StatusCode.h
CP::MuonTriggerScaleFactors::getDataPeriod
std::string getDataPeriod() const
Definition: MuonTriggerScaleFactors.cxx:725
PathResolver.h
CP::SystematicSet::insert
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Definition: SystematicSet.cxx:88
hancool.filePath
string filePath
Definition: hancool.py:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
ReadHandle.h
Handle class for reading from StoreGate.
threshold
Definition: chainparser.cxx:74
CP::MuonTriggerScaleFactors::getMuonEfficiency
virtual CorrectionCode getMuonEfficiency(Double_t &eff, const TrigMuonEff::Configuration &configuration, const xAOD::Muon &muon, const std::string &trigger, const std::string &systematic) const
Definition: MuonTriggerScaleFactors.cxx:407
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
MuonContainer.h
LArCellBinning.xbins
int xbins
Definition: LArCellBinning.py:163
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
CP::MuonTriggerScaleFactors::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Definition: MuonTriggerScaleFactors.h:105
CP::MuonTriggerScaleFactors::m_fileName
std::string m_fileName
Definition: MuonTriggerScaleFactors.h:116
CP::MuonTriggerScaleFactors::m_custom_dir
std::string m_custom_dir
Definition: MuonTriggerScaleFactors.h:124
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
CP::MuonTriggerScaleFactors::MuonTriggerScaleFactors
MuonTriggerScaleFactors(const std::string &name)
Definition: MuonTriggerScaleFactors.cxx:32
CP::MuonTriggerScaleFactors::m_systFilter
std::unordered_map< CP::SystematicSet, CP::SystematicSet > m_systFilter
Definition: MuonTriggerScaleFactors.h:113
CP::MuonTriggerScaleFactors::YearPeriod
std::pair< unsigned int, std::string > YearPeriod
Definition: MuonTriggerScaleFactors.h:90
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
CP::MuonTriggerScaleFactors::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool recommends to use
Definition: MuonTriggerScaleFactors.cxx:883
CP::MuonTriggerScaleFactors::getRunNumber
unsigned int getRunNumber() const
Definition: MuonTriggerScaleFactors.cxx:798
CP::MuonTriggerScaleFactors::m_efficiencyMap
EfficiencyMap m_efficiencyMap
Definition: MuonTriggerScaleFactors.h:117
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CP::SystematicVariation::empty
bool empty() const
returns: whether this is an empty systematic, i.e.
Definition: SystematicVariation.cxx:294
CP::MuonTriggerScaleFactors::encodeHistoName
unsigned int encodeHistoName(const std::string &period, const std::string &Trigger, bool isData, const std::string &Systematic, bool isBarrel=true) const
Definition: MuonTriggerScaleFactors.cxx:382
CP::SystematicRegistry
This module implements the central registry for handling systematic uncertainties with CP tools.
Definition: SystematicRegistry.h:25
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
CP::SystematicSet::matchSystematic
bool matchSystematic(const SystematicVariation &systematic, MATCHTYPE type=FULL) const
Definition: SystematicSet.cxx:128
CP::MuonTriggerScaleFactors::getTriggerEfficiency
virtual CorrectionCode getTriggerEfficiency(const xAOD::Muon &mu, Double_t &efficiency, const std::string &trigger, Bool_t dataType) const
Definition: MuonTriggerScaleFactors.cxx:280
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
python.LArCondContChannels.isBarrel
isBarrel
Definition: LArCondContChannels.py:659
python.grid.isData
def isData(dataset)
Definition: grid.py:491
CP::MuonTriggerScaleFactors::registerSystematics
StatusCode registerSystematics()
Definition: MuonTriggerScaleFactors.cxx:873
CP::MuonTriggerScaleFactors::isTriggerSupported
virtual bool isTriggerSupported(const std::string &trigger) const
Returns whether the trigger is supported by the tool or not. The decision depends on the present (ran...
Definition: MuonTriggerScaleFactors.cxx:355
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
plotIsoValidation.mu_eta
mu_eta
Definition: plotIsoValidation.py:151
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
CP::MuonTriggerScaleFactors::getThreshold
CorrectionCode getThreshold(Int_t &threshold, const std::string &trigger) const
Definition: MuonTriggerScaleFactors.cxx:699
CP::MuonTriggerScaleFactors::m_experimental
bool m_experimental
Definition: MuonTriggerScaleFactors.h:127
test_pyathena.counter
counter
Definition: test_pyathena.py:15
Analysis::Systematic
@ Systematic
Definition: CalibrationDataInterfaceROOT.h:70
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
CP::MuonTriggerScaleFactors::getEfficiencyHistogram
virtual std::shared_ptr< TH1 > getEfficiencyHistogram(unsigned int year, const std::string &period, const std::string &trigger, bool isData, const std::string &Systematic, bool isBarrel=true) const
Definition: MuonTriggerScaleFactors.cxx:393
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
dumpTgcDigiThreshold.threshold
list threshold
Definition: dumpTgcDigiThreshold.py:34
CP::MuonTriggerScaleFactors::m_efficiencyMapReplicaArray
std::map< EffiHistoIdent, std::vector< TH1_Ptr > > m_efficiencyMapReplicaArray
Definition: MuonTriggerScaleFactors.h:118
SystematicVariation.h
CP::SystematicSet::filterForAffectingSystematics
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Definition: SystematicSet.cxx:213
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
python.handimod.cc
int cc
Definition: handimod.py:523
PhysDESDM_Quirks.trigger
trigger
Definition: PhysDESDM_Quirks.py:27
CP::SystematicRegistry::getInstance
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Definition: SystematicRegistry.cxx:25
CP::MuonTriggerScaleFactors::GetTriggerSF
virtual CorrectionCode GetTriggerSF(Double_t &TriggerSF, TrigMuonEff::Configuration &configuration, const xAOD::MuonContainer &mucont, const std::string &trigger) const
Definition: MuonTriggerScaleFactors.cxx:526
CP::MuonTriggerScaleFactors::m_forceYear
int m_forceYear
Definition: MuonTriggerScaleFactors.h:128
beamspotman.basename
basename
Definition: beamspotman.py:640