ATLAS Offline Software
dumpNPs.cxx
Go to the documentation of this file.
1 #ifdef XAOD_STANDALONE
2  #include "xAODRootAccess/Init.h"
3  #include "xAODRootAccess/TEvent.h"
4  #include "xAODRootAccess/TStore.h"
5 #endif
6 #include "CaloGeoHelpers/CaloSampling.h"
11 #include "CreateDummyEl.h"
12 
13 #include <vector>
14 #include <map> //includes std::pair
15 #include <tuple>
16 #include <bitset>
17 #include <sstream>
18 #include <type_traits>
19 #include <cstdlib>
20 #include <limits>
21 #include <algorithm> //for std::sort, std::transform
22 
23 #define MSGSOURCE "EgEfficiencyCorr_dumpNPs"
24 
25 
26 struct Domain
27 {
28  float etamin{}, etamax{}, ptmin{}, ptmax{};
29  std::string str(const bool abs_eta=false) const;
30 };
31 
32 
33 struct NP
34 {
35  int index{};
36  bool uncorr{};
37  bool operator<(const NP& rhs) const {
38  return (uncorr!=rhs.uncorr)? (uncorr<rhs.uncorr): (index<rhs.index);
39  }
40  bool operator==(const NP& rhs) const {
41  return (index == rhs.index) && (uncorr == rhs.uncorr);
42  }
43 };
44 
45 
46 struct Config
47 {
49  "AsgElectronEfficiencyCorrectionTool/tool"};
50  std::vector<std::tuple<CP::SystematicSet, NP>> systematics{};
51  std::vector<Domain> domains{};
52  int run_number{0};
53  bool analysis_mode{false};
54  bool initialize(int argc, char* argv[]);
55 };
56 
57 
58 using map_t = std::map<NP, std::vector<std::size_t>>;
59 
60 
61 template<typename... Args> bool parse_csv_list(std::string val, Args&... args);
62 bool scanPhaseSpace(Config& config, map_t& affected_bins);
63 bool displayFindings(const Config& config, const map_t& affected_bins);
64 bool displayFindings_analysis(const Config& cfg, const map_t& affected_bins);
65 bool find_boundaries(const Config& cfg,
66  const map_t::mapped_type& affected_bins,
67  Domain& bounds, bool& abs_eta, bool& holes);
68 int get_run_number(const int year);
69 
70 
71 std::vector<float> eta_edges = { // eta<0 bins are auto-added in main()
72  0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f,
73  1.15f, 1.2f, 1.3f, 1.37f, 1.52f, 1.6f, 1.65f, 1.7f, 1.8f, 1.9f, 2.0f,
74  2.1f, 2.2f, 2.3f, 2.37f, 2.4f, 2.47f};
75 
76 std::vector<float> pt_edges = { // in MeV
77  45e2f, 7e3f, 1e4f, 15e3f, 2e4f, 25e3f, 3e4f, 35e3f, 4e4f, 45e3f, 5e4f,
78  6e4f, 8e4f, 15e4f, 25e4f, 5e5f, 1e7f};
79 
80 // number of equidistant scanned points within a bin:
81 const std::size_t subdiv_eta{5};
82 const std::size_t subdiv_pt{3};
83 
84 
85 int main(int argc, char* argv[])
86 {
87  using namespace asg::msgUserCode;
88 
89  #ifdef XAOD_STANDALONE
90  StatusCode::enableFailure();
93  #endif
94 
96  //copy negated elements onto end of vector without duplicating the first element (which is zero)
97  std::transform(eta_edges.begin()+1,eta_edges.end(), std::back_inserter(eta_edges),std::negate());
98  //
99  std::sort(eta_edges.begin(), eta_edges.end());
100  std::sort(pt_edges.begin(), pt_edges.end());
101  const bool duplicates_eta{
102  std::adjacent_find(eta_edges.begin(), eta_edges.end()) != eta_edges.end()};
103  const bool duplicates_pt{
104  std::adjacent_find(pt_edges.begin(), pt_edges.end()) != pt_edges.end()};
105  if (duplicates_eta || duplicates_pt) {
106  Error(MSGSOURCE, "Duplicated values in the specified bin edges.");
107  std::abort();
108  }
109 
110  // Setup tool using command-line arguments
111  Config cfg;
112  ANA_CHECK( cfg.initialize(argc, argv) );
113  ANA_CHECK( cfg.tool.initialize() );
114 
115  // List nuisance parameters for systematics
116  const CP::SystematicSet allsysts(cfg.tool->recommendedSystematics());
117  try {
118  std::set<std::string> recorded;
119  for (const auto& var : allsysts) {
120  std::string name(var.basename());
121  if (!recorded.emplace(name).second) continue;
122  NP np;
123  if (name.find("UncorrUncertainty") != std::string::npos) {
124  np.uncorr = true;
125  } else if (name.find("CorrUncertainty") != std::string::npos) {
126  np.uncorr = false;
127  } else {
128  throw std::invalid_argument("");
129  }
130  np.index = std::stoul(name.substr(name.find("NP") + 2));
131  cfg.systematics.emplace_back(CP::SystematicSet{var}, np);
132  }
133  } catch (std::invalid_argument&) {
134  Error(MSGSOURCE, "The pattern of the SystematicVariation names seems to have changed.");
135  std::abort();
136  }
137  std::sort(cfg.systematics.begin(), cfg.systematics.end(),
138  [](auto& x, auto& y) { return std::get<NP>(x) < std::get<NP>(y); });
139 
140  if (cfg.analysis_mode) {
141  for (const int year : {2015, 2016, 2017, 2018}) {
142  map_t affected_bins;
143  cfg.run_number = get_run_number(year);
144  ANA_CHECK( scanPhaseSpace(cfg, affected_bins) );
145  Info(MSGSOURCE, "%s", "");
146  Info(MSGSOURCE, "Relevant nuisance parameters for the year %i:", year);
147  ANA_CHECK( displayFindings_analysis(cfg, affected_bins) );
148  }
149  } else {
150  map_t affected_bins;
151  ANA_CHECK( scanPhaseSpace(cfg, affected_bins) );
152  ANA_CHECK( displayFindings(cfg, affected_bins) );
153  }
154 
155  return 0;
156 }
157 
158 
159 bool Config::initialize(int argc, char* argv[])
160 {
161  using namespace asg::msgUserCode;
162 
163  auto help = [&]() {
164  Info(MSGSOURCE, "Usage (1): EgEfficiencyCorr_dumpNPs Year=<value> IdKey=<value> <property1=value1> ... <property N=value N>");
165  Info(MSGSOURCE, " ++ prints eta x pt region of influence of each nuisance parameter for the chosen year");
166  Info(MSGSOURCE, "Usage (2): EgEfficiencyCorr_dumpNPs AnalysisEta=<list> AnalysisPt=<list> IdKey=<value> <property1=value1> ... <property N=value N>");
167  Info(MSGSOURCE, " ++ prints a short list of all NPs relevant in the selected eta x pt (in MeV) region");
168  Info(MSGSOURCE, " ++ e.g. EgEfficiencyCorr_dumpNPs AnalysisEta=-2.0..2.0,nocrack AnalysisPt=20e3..150e3");
169  Info(MSGSOURCE, " ++ one of the Analysis* arguments can be omitted, in which case the full range is scanned");
170  Info(MSGSOURCE, " ++ several intervals can be specified, separated by commas, e.g. AnalysisEta=0..0.6,0.8..1.37");
171  Info(MSGSOURCE, " ++ recognized aliases: 'nocrack' (crack veto), 'sym' (duplicates for eta<0), 'barrel', 'endcap'");
172  Info(MSGSOURCE, "Common details:");
173  Info(MSGSOURCE, " ++ for other SFs, IdKey can be replaced by RecoKey/IsoKey/TriggerKey");
174  Info(MSGSOURCE, " ++ CorrectionFileNameList can also be used instead of keys");
175  Info(MSGSOURCE, " ++ optional arguments are other configurable properties of the AsgElectronEfficiencyCorrectionTool.");
176  Info(MSGSOURCE, " ++ e.g. EgEfficiencyCorr_dumpNPs Year=2015 IdKey=Tight CorrelationModel=SIMPLIFIED UncorrEtaBinsUser=0,1.37,2.47");
177  std::abort();
178  };
179 
180  if (argc < 2) help();
181 
182  const std::set<std::string> string_properties{
183  "MapFilePath", "RecoKey", "IdKey", "IsoKey", "TriggerKey",
184  "CorrelationModel"};
185  const std::set<std::string> int_properties{"ForceDataType"};
186  const std::set<std::string> vector_properties{
187  "UncorrEtaBinsUser", "UncorrEtBinsUser"};
188 
189  // Set default values.
190  const int mc_type{static_cast<int>(PATCore::ParticleDataType::Full)};
191  ANA_CHECK( tool.setProperty("ForceDataType", mc_type) );
192  ANA_CHECK( tool.setProperty("CorrelationModel", "FULL") );
193  ANA_CHECK( tool.setProperty("UseRandomRunNumber", true) );
194 
195  run_number = 0;
196  std::vector<int8_t> eta_flags(eta_edges.size()-1, 0);
197  std::vector<int8_t> pt_flags(pt_edges.size()-1, 0);
198 
199  for (int i=1; i<argc; ++i) {
200  std::string key{argv[i]};
201  const std::size_t pos{key.find('=')};
202  if (pos == std::string::npos) help();
203  std::string val(key.substr(pos + 1));
204  key.resize(pos);
205  if (!key.length() || !val.length()) help();
206  if (key == "CorrectionFileNameList") {
207  std::vector<std::string> files{val};
208  ANA_CHECK( tool.setProperty(key, files) );
209  } else if (key == "Year") {
210  run_number = get_run_number(std::stoi(val));
211  } else if (string_properties.count(key)) {
212  ANA_CHECK( tool.setProperty(key, val) );
213  } else if (int_properties.count(key)) {
214  ANA_CHECK( tool.setProperty(key, std::stoi(val)) );
215  } else if (vector_properties.count(key)) {
216  std::vector<float> bins;
218  ANA_CHECK( tool.setProperty(key, bins) );
219  } else if (key == "AnalysisEta") {
220  ANA_CHECK( parse_csv_list(val, eta_flags, eta_edges) );
221  analysis_mode = true;
222  } else if (key == "AnalysisPt") {
223  ANA_CHECK( parse_csv_list(val, pt_flags, pt_edges) );
224  analysis_mode = true;
225  } else {
226  Error(MSGSOURCE, "Unrecognized property %s", key.c_str());
227  help();
228  }
229  }
230 
231  if (analysis_mode) {
232  if (run_number) {
233  Warning(MSGSOURCE,
234  "When Analysis* arguments are provided, "
235  "Year is ignored.");
236  }
237  } else if (!run_number) {
238  Error(MSGSOURCE, "Command-line arguments must include Year");
239  help();
240  }
241 
242  // Enable negative-eta bins, when the 'sym' alias was specified:
243  for (std::size_t i{0}; i<eta_flags.size(); ++i) {
244  if (eta_flags[i] != 2) continue;
245  float z{0.5f * (eta_edges[i] + eta_edges[i+1])};
246  auto eeb{eta_edges.cbegin()}, eee{eta_edges.cend()};
247  const auto j = static_cast<std::size_t>(
248  std::upper_bound(eeb, eee, -z) - eeb - 1);
249  if (i == j) continue;
250  if (j >= eta_edges.size()) return false;
251  eta_flags[i] = eta_flags[j];
252  }
253 
254  // By default, scan whole ranges (except crack if vetoed)
255  auto efb{eta_flags.begin()}, efe{eta_flags.end()};
256  if (!std::count(efb, efe, 1)) {
257  std::replace(efb, efe, 0, 1);
258  }
259  auto pfb{pt_flags.begin()}, pfe{pt_flags.end()};
260  if (!std::count(pfb, pfe, 1)) {
261  std::fill(pfb, pfe, 1);
262  }
263 
264  domains.clear();
265  for (std::size_t i{0}; i<eta_flags.size(); ++i) {
266  if (eta_flags[i] < 1) continue;
267  for (std::size_t j{0}; j<pt_flags.size(); ++j) {
268  if (pt_flags[j] < 1) continue;
269  domains.emplace_back(Domain{
270  eta_edges[i], eta_edges[i+1],
271  pt_edges[j], pt_edges[j+1]
272  });
273  }
274  }
275  return true;
276 }
277 
278 
279 bool scanPhaseSpace(Config& cfg, map_t& affected_bins)
280 {
281  using namespace asg::msgUserCode;
282 
283  static int display_count{-1};
284  if (!++display_count) {
285  Info(MSGSOURCE,
286  "Scanning the eta/pt plane, this will take a bit of time...");
287  }
288 
290 
291  using RealTool = const AsgElectronEfficiencyCorrectionTool;
292  const auto *asgtool = dynamic_cast<RealTool*>(&*cfg.tool);
293  const std::size_t jmax{subdiv_eta + 1}, kmax{subdiv_pt + 1};
294  const std::size_t dmax{cfg.domains.size()};
295  for (std::size_t d{0}; d<dmax; ++d) {
296  const auto& dom = cfg.domains[d];
297  std::bitset<1024> zero_uncorr{}, nonzero_uncorr{}, expected_uncorr{};
298  std::bitset<256> zero_corr{}, nonzero_corr{};
299  bool multi_np{false};
300  for (std::size_t j{1}; j<jmax; ++j) {
301  const float eta{((jmax-j)*dom.etamin + j*dom.etamax) / jmax};
302  for (std::size_t k{1}; k<kmax; ++k) {
303  const float pt{((kmax-k)*dom.ptmin + k*dom.ptmax) / kmax};
304  ANA_CHECK( getElectrons({{pt, eta}}, cfg.run_number, store) );
305  const xAOD::ElectronContainer* electrons{nullptr};
306  ANA_CHECK( store.retrieve(electrons, "MyElectrons") );
307  const xAOD::Electron& electron{*electrons->at(0)};
308  double sf_nom{}, sf{};
309  ANA_CHECK( cfg.tool->applySystematicVariation({}) );
310  ANA_CHECK( cfg.tool->getEfficiencyScaleFactor(electron, sf_nom) );
311  int vi{asgtool->systUncorrVariationIndex(electron)};
312  expected_uncorr.set(vi);
313  unsigned n_nonzero_uncorr{0};
314  for (const auto& s : cfg.systematics) {
315  const auto& sys = std::get<CP::SystematicSet>(s);
316  ANA_CHECK( cfg.tool->applySystematicVariation(sys) );
317  ANA_CHECK( cfg.tool->getEfficiencyScaleFactor(electron, sf) );
318  const double delta{sf - sf_nom};
319  const NP np{std::get<NP>(s)};
320  if (delta != 0.) {
321  if (np.uncorr) {
322  nonzero_uncorr.set(np.index);
323  ++n_nonzero_uncorr;
324  }
325  else nonzero_corr.set(np.index);
326  } else {
327  if (np.uncorr) zero_uncorr.set(np.index);
328  else zero_corr.set(np.index);
329  }
330  }
331  multi_np = multi_np || (n_nonzero_uncorr > 1);
332  store.clear();
333  }
334  }
335  if (multi_np) {
336  std::string w("several uncorrelated NPs seem to affect the bin at "
337  + dom.str() + ".");
338  Warning(MSGSOURCE, "%s", w.c_str());
339  } else if (nonzero_uncorr.count() > 1) {
340  std::string w{"the binning used for the scan is unadapted at " +
341  dom.str() + " (too coarse?)."};
342  Warning(MSGSOURCE, "%s", w.c_str());
343  }
344  if ((zero_uncorr & nonzero_uncorr).any() ||
345  (zero_corr & nonzero_corr).any()) {
346  std::string w("the binning used for the scan is unadapted at " +
347  dom.str() + " (wrong boundaries?).");
348  Warning(MSGSOURCE, "%s", w.c_str());
349  }
350  if ((nonzero_uncorr!=expected_uncorr) && nonzero_uncorr.any()) {
351  std::string snz, se;
352  for (std::size_t i{0}; i<nonzero_uncorr.size(); ++i) {
353  std::string x{std::to_string(i) + ','};
354  if (nonzero_uncorr[i] && !expected_uncorr[i]) snz += x;
355  if (!nonzero_uncorr[i] && expected_uncorr[i]) se += x;
356  }
357  if (snz.length()) snz.pop_back();
358  if (se.length()) se.pop_back();
359  std::string w{"systUncorrVariationIndex() at " + dom.str() +
360  " indicates different NP(s) than those found in the scan, "
361  "(%s) vs (%s)."};
362  Warning(MSGSOURCE, w.c_str(), se.c_str(), snz.c_str());
363  }
364  for (const auto& s : cfg.systematics) {
365  const NP np{std::get<NP>(s)};
366  const bool impact{
367  np.uncorr? nonzero_uncorr.test(np.index)
368  : nonzero_corr.test(np.index)};
369  if (impact) affected_bins[np].emplace_back(d);
370  }
371  }
372  return true;
373 }
374 
375 
376 bool displayFindings(const Config& cfg, const map_t& affected_bins)
377 {
378  using namespace asg::msgUserCode;
379  for (const auto& s : cfg.systematics) {
380  const NP np{std::get<NP>(s)};
381  const std::string name(std::get<CP::SystematicSet>(s).begin()->basename());
382  Domain bounds{};
383  bool valid{false}, holes{false}, abs_eta{false};
384  auto itr = affected_bins.find(np);
385  if (itr != affected_bins.end()) {
386  valid = find_boundaries(cfg, itr->second, bounds, abs_eta, holes);
387  }
388  if (!valid) {
389  Warning(MSGSOURCE, "%s seems to not affect any bin", name.c_str());
390  continue;
391  }
392  std::string txt(name + " --> ");
393  if (holes) txt += "subdomain of ";
394  txt += bounds.str(abs_eta) + '.';
395  if (!holes) {
396  Info(MSGSOURCE, "%s", txt.c_str());
397  } else {
398  Warning(MSGSOURCE, "%s", txt.c_str());
399  }
400  }
401  return true;
402 }
403 
404 
405 bool displayFindings_analysis(const Config& cfg, const map_t& affected_bins)
406 {
407  using namespace asg::msgUserCode;
408 
409  std::vector<std::pair<std::string, int>> summary;
410  NP prev{-888, false};
411  for (const auto& kv : affected_bins) {
412  const auto& bins{kv.second};
413  if (bins.empty()) continue;
414  const NP np{kv.first};
415  const bool next{prev.uncorr==np.uncorr && np.index==prev.index+1};
416  prev = np;
417  if (!summary.empty() && next) {
418  std::get<int>(summary.back()) = np.index;
419  continue;
420  }
421  const auto& sys{
422  std::get<CP::SystematicSet>(
423  *std::find_if(
424  cfg.systematics.cbegin(), cfg.systematics.cend(),
425  [=](auto& x){ return std::get<NP>(x) == np; }))};
426  summary.emplace_back(sys.begin()->basename(), -1);
427  }
428  for (const auto& x: summary) {
429  std::string s(" ++ " + std::get<std::string>(x));
430  const int i{std::get<int>(x)};
431  if (i >= 0) s += " to " + std::to_string(i);
432  Info(MSGSOURCE, "%s", s.c_str());
433  }
434  return true;
435 }
436 
437 
438 bool find_boundaries(const Config& cfg,
439  const map_t::mapped_type& affected_bins,
440  Domain& bounds,
441  bool& abs_eta,
442  bool& holes)
443 {
444  if (affected_bins.empty()) return false;
445  constexpr float inf{std::numeric_limits<float>::max()};
446  constexpr float inf_{std::numeric_limits<float>::lowest()};
447  Domain bAC[2] = {{inf, inf_, inf, inf_}, {inf, inf_, inf, inf_}};
448  auto update = [&](const int side, const auto& dom,
449  const float etamin, const float etamax) {
450  auto& b = bAC[side];
451  b.etamin = std::min(b.etamin, etamin);
452  b.etamax = std::max(b.etamax, etamax);
453  b.ptmin = std::min(b.ptmin, dom.ptmin);
454  b.ptmax = std::max(b.ptmax, dom.ptmax);
455  };
456 
457  for (const int bin : affected_bins) {
458  const Domain& dom{cfg.domains.at(bin)};
459  if (dom.etamax > 0.f) update(1, dom, std::max(0.f, dom.etamin), dom.etamax);
460  if (dom.etamin < 0.f) update(0, dom, dom.etamin, std::min(0.f, dom.etamax));
461  }
462 
463  holes = false;
464  const int ac{2*(bAC[1].ptmin!=inf) + (bAC[0].ptmin!=inf)};
465  if (ac == 3) {
466  abs_eta = (bAC[0].ptmin == bAC[1].ptmin) && (bAC[0].ptmax == bAC[1].ptmax) &&
467  (std::fabs(bAC[0].etamax + bAC[1].etamin) < 1e-4f) &&
468  (std::fabs(bAC[0].etamin + bAC[1].etamax) < 1e-4f);
469  if (abs_eta) {
470  bounds = bAC[1];
471  } else {
472  holes = true;
473  bounds.etamin = bAC[0].etamin;
474  bounds.etamax = bAC[1].etamax;
475  bounds.ptmin = std::min(bAC[0].ptmin, bAC[1].ptmin);
476  bounds.ptmax = std::min(bAC[0].ptmax, bAC[1].ptmax);
477  }
478  } else if (ac) bounds = bAC[ac - 1];
479  else return false;
480 
481  if (!holes) {
482  // Search for overlapping domains not affected by this NP.
483  const std::size_t imax{cfg.domains.size()};
484  auto f = [=](const float x) { return abs_eta? std::fabs(x) : x; };
485  for (std::size_t i{0}; i<imax && !holes; ++i) {
486  if (std::count(affected_bins.cbegin(), affected_bins.cend(), i)) continue;
487  const auto& dom{cfg.domains[i]};
488  holes = (dom.ptmax > bounds.ptmin) &&
489  (dom.ptmin < bounds.ptmax) &&
490  (f(dom.etamax) > bounds.etamin) &&
491  (f(dom.etamin) < bounds.etamax);
492  }
493  }
494  return true;
495 }
496 
497 
498 std::string Domain::str(const bool abs_eta) const
499 {
500  std::stringstream s;
501  const char* eta{abs_eta? "|eta|" : "eta"};
502  s << etamin << " < " << eta << " < " << etamax << ", ";
503  if (ptmax != pt_edges.back()) {
504  s << 1e-3f * ptmin << " < pt < "
505  << 1e-3f * ptmax << " GeV";
506  } else {
507  s << "pt > " << 1e-3f * ptmin << " GeV";
508  }
509  return s.str();
510 }
511 
512 
513 bool parse_csv_token(const float x, std::vector<float>& bins)
514 {
515  bins.push_back(x);
516  return true;
517 }
518 
519 
520 bool parse_csv_token(std::string s,
521  std::vector<int8_t>& flags,
522  const std::vector<float>& edges)
523 {
524  const bool accept_aliases{&edges == &eta_edges};
525  if (flags.size() != edges.size() - 1) return false;
526  int alias{0};
527  if (s == "nocrack") alias = 1;
528  else if (s == "barrel") alias = 2;
529  else if (s == "endcap") alias = 3;
530  else if (s == "sym") alias = 4;
531  if (!accept_aliases && alias>0) return false;
532  if (alias>=1 && alias<=3) {
533  for (std::size_t i{0}; i<edges.size()-1; ++i) {
534  const float eta{std::fabs(edges[i])};
535  if (alias==1 && eta>=1.37f && eta<1.52f) flags[i] = -1;
536  if (alias==2 && eta<1.37f) flags[i] = 1;
537  if (alias==3 && eta>1.52f) flags[i] = 1;
538  }
539  return true;
540  } else if (alias == 4) {
541  for (std::size_t i=0;i<edges.size();++i) {
542  if (edges[i] < 0) flags[i] = 2;
543  }
544  return true;
545  }
546  auto pos = s.find("..");
547  if (pos == std::string::npos) return false;
548  std::stringstream ss{s.replace(pos, 2, 1, ' ')};
549  float xmin, xmax;
550  ss >> xmin >> xmax;
551  if (ss.fail() || !(ss >> std::ws).eof()) return false;
552  for (std::size_t i{0}; i<edges.size()-1; ++i) {
553  if (xmin<edges[i+1] && xmax>edges[i] && flags[i]>=0) {
554  flags[i] = 1;
555  }
556  }
557  return true;
558 }
559 
560 
561 template<typename... Args>
562 bool parse_csv_list(std::string val, Args&... args)
563 {
564  std::replace(val.begin(), val.end(), ',', ' ');
565  std::stringstream ss{val};
566  while (true) {
567  std::conditional_t<(sizeof...(Args)<2), float, std::string> x;
568  ss >> x;
569  if (ss.fail()) break;
570  if (!parse_csv_token(x, args...)) return false;
571  }
572  return ss.eof();
573 }
574 
575 
576 int get_run_number(const int year)
577 {
578  using namespace asg::msgUserCode;
579  constexpr int random_runs[] = {280423, 302737, 332720, 354826};
580  switch(year) {
581  case 2015: case 2016: case 2017: case 2018:
582  return random_runs[year - 2015];
583  default:
584  Error(MSGSOURCE,
585  "Invalid year specified, it should be between 2015 and 2018.");
586  std::abort();
587  }
588 }
NP::operator==
bool operator==(const NP &rhs) const
Definition: dumpNPs.cxx:40
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:71
beamspotnt.var
var
Definition: bin/beamspotnt.py:1394
AsgElectronEfficiencyCorrectionTool
Definition: AsgElectronEfficiencyCorrectionTool.h:36
asg::AnaToolHandle< IAsgElectronEfficiencyCorrectionTool >
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
plotting.plot_kinematics.run_number
run_number
Definition: plot_kinematics.py:29
ptmax
double ptmax
Definition: dependence.cxx:60
displayFindings_analysis
bool displayFindings_analysis(const Config &cfg, const map_t &affected_bins)
Definition: dumpNPs.cxx:405
subdiv_pt
const std::size_t subdiv_pt
Definition: dumpNPs.cxx:82
max
#define max(a, b)
Definition: cfImp.cxx:41
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
NP
Definition: dumpNPs.cxx:34
Config::systematics
std::vector< std::tuple< CP::SystematicSet, NP > > systematics
Definition: dumpNPs.cxx:50
Config::domains
std::vector< Domain > domains
Definition: dumpNPs.cxx:51
IAsgElectronEfficiencyCorrectionTool.h
Domain::etamin
float etamin
Definition: dumpNPs.cxx:28
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
index
Definition: index.py:1
CP::CorrectionCode::enableFailure
static void enableFailure() noexcept
Definition: CorrectionCode.h:64
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
InDetDD::holes
@ holes
Definition: InDetDD_Defs.h:17
hist_file_dump.d
d
Definition: hist_file_dump.py:137
scanPhaseSpace
bool scanPhaseSpace(Config &config, map_t &affected_bins)
Definition: dumpNPs.cxx:279
TrigJetMonitorAlgorithm.ptmin
ptmin
Definition: TrigJetMonitorAlgorithm.py:1226
main
int main(int argc, char *argv[])
Definition: dumpNPs.cxx:85
Domain::etamax
float etamax
Definition: dumpNPs.cxx:28
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
test_pyathena.pt
pt
Definition: test_pyathena.py:11
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
bin
Definition: BinsDiffFromStripMedian.h:43
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
eta_edges
std::vector< float > eta_edges
Definition: dumpNPs.cxx:71
AsgElectronEfficiencyCorrectionTool.h
xAOD::TEvent::kClassAccess
@ kClassAccess
Access auxiliary data using the aux containers.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:100
PlotPulseshapeFromCool.np
np
Definition: PlotPulseshapeFromCool.py:64
Args
Definition: test_lwtnn_fastgraph.cxx:12
python.AtlRunQueryAMI.year
year
Definition: AtlRunQueryAMI.py:226
keylayer_zslicemap.se
se
Definition: keylayer_zslicemap.py:194
x
#define x
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
inf
TStreamerInfo * inf
Definition: liststreamerinfos.cxx:12
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
MSGSOURCE
#define MSGSOURCE
Definition: dumpNPs.cxx:23
Config::tool
asg::AnaToolHandle< IAsgElectronEfficiencyCorrectionTool > tool
Definition: dumpNPs.cxx:48
TRT::Hit::side
@ side
Definition: HitInfo.h:83
PATCore::ParticleDataType::Full
@ Full
Definition: PATCoreEnums.h:22
Config::run_number
int run_number
Definition: dumpNPs.cxx:52
calibdata.valid
list valid
Definition: calibdata.py:45
Domain::ptmax
float ptmax
Definition: dumpNPs.cxx:28
Base_Fragment.recorded
list recorded
if USE_PDG_VALUES = True, load PDG value of sin2thetaW and particle masses/widths from parameter dict...
Definition: GeneratorFilters/share/common/Base_Fragment.py:55
python.CaloScaleNoiseConfig.help
help
Definition: CaloScaleNoiseConfig.py:76
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
lumiFormat.i
int i
Definition: lumiFormat.py:85
xmin
double xmin
Definition: listroot.cxx:60
z
#define z
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
Domain::str
std::string str(const bool abs_eta=false) const
Definition: dumpNPs.cxx:498
subdiv_eta
const std::size_t subdiv_eta
Definition: dumpNPs.cxx:81
COOLRates.alias
alias
Definition: COOLRates.py:1172
MessageCheck.h
macros for messaging and checking status codes
Domain::ptmin
float ptmin
Definition: dumpNPs.cxx:28
generateReferenceFile.files
files
Definition: generateReferenceFile.py:12
TEvent.h
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
Init.h
hist_file_dump.f
f
Definition: hist_file_dump.py:135
plotting.yearwise_luminosity_vs_mu.bins
bins
Definition: yearwise_luminosity_vs_mu.py:30
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
Domain
Definition: dumpNPs.cxx:27
imax
int imax(int i, int j)
Definition: TileLaserTimingTool.cxx:33
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Config::analysis_mode
bool analysis_mode
Definition: dumpNPs.cxx:53
Config
Definition: dumpNPs.cxx:47
AnaToolHandle.h
min
#define min(a, b)
Definition: cfImp.cxx:40
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
map_t
std::map< NP, std::vector< std::size_t > > map_t
Definition: dumpNPs.cxx:58
getElectrons
StatusCode getElectrons(const std::vector< std::pair< double, double >> &pt_eta, int runNumber, xAOD::TStore &store)
Definition: CreateDummyEl.cxx:73
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
xAOD::Electron_v1
Definition: Electron_v1.h:34
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:44
y
#define y
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
CreateDummyEl.h
Config::initialize
bool initialize(int argc, char *argv[])
Definition: dumpNPs.cxx:159
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
displayFindings
bool displayFindings(const Config &config, const map_t &affected_bins)
Definition: dumpNPs.cxx:376
NP::operator<
bool operator<(const NP &rhs) const
Definition: dumpNPs.cxx:37
xAOD::EgammaParameters::electron
@ electron
Definition: EgammaEnums.h:18
xmax
double xmax
Definition: listroot.cxx:61
NP::index
int index
Definition: dumpNPs.cxx:35
NP::uncorr
bool uncorr
Definition: dumpNPs.cxx:36
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
parse_csv_token
bool parse_csv_token(const float x, std::vector< float > &bins)
Definition: dumpNPs.cxx:513
LArCellBinning.etamin
etamin
Definition: LArCellBinning.py:137
find_boundaries
bool find_boundaries(const Config &cfg, const map_t::mapped_type &affected_bins, Domain &bounds, bool &abs_eta, bool &holes)
Definition: dumpNPs.cxx:438
WriteBchToCool.update
update
Definition: WriteBchToCool.py:67
readCCLHist.float
float
Definition: readCCLHist.py:83
get_run_number
int get_run_number(const int year)
Definition: dumpNPs.cxx:576
TStore.h
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:84
fitman.k
k
Definition: fitman.py:528
parse_csv_list
bool parse_csv_list(std::string val, Args &... args)
Definition: dumpNPs.cxx:562
xAOD::Init
StatusCode Init(const char *appname)
Function initialising ROOT/PyROOT for using the ATLAS EDM.
Definition: Init.cxx:31
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
pt_edges
std::vector< float > pt_edges
Definition: dumpNPs.cxx:76
beamspotman.basename
basename
Definition: beamspotman.py:640
SCT_Monitoring::summary
@ summary
Definition: SCT_MonitoringNumbers.h:65