ATLAS Offline Software
ImportData.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 // contact: jmaurer@cern.ch
6 
8 
9 #include <algorithm>
10 #include <fstream>
11 #include <functional>
12 #include <limits>
13 
15 
17 
19  :
20  asg::AsgMessaging("TrigGlobalEfficiencyCorrectionTool"),
22  m_parent(nullptr),
23  m_dictionary(*new std::map<std::size_t, std::string>),
24  m_hasher(*new std::hash<std::string>) {}
25 
27  : asg::AsgMessaging(&parent),
28  m_parent(&parent),
29  m_dictionary(parent.m_dictionary),
30  m_hasher(parent.m_hasher) {
31  msg().setLevel(parent.msg().level());
32 }
33 
35  if (!m_parent) {
36  delete &m_dictionary;
37  delete &m_hasher;
38  }
39 }
40 
42  const std::map<std::string, std::string>& overridenThresholds) {
43  return importPeriods() && importThresholds(overridenThresholds) &&
45 }
46 
48  std::vector<std::string>& contents) {
49  contents.clear();
50  bool success = true;
52  if (name.length()) {
53  std::ifstream f(name.c_str(), std::ios_base::in);
54  if (f.is_open()) {
55  std::string line;
56  while (f.good()) {
57  if (std::getline(f, line)) {
58  const std::string::size_type i = line.find('#');
59  if (i != std::string::npos)
60  line.resize(i);
61  if (line.length() >= 3)
62  contents.emplace_back(std::move(line));
63  }
64  }
65  if (!f.eof()) {
66  ATH_MSG_ERROR("Issue encountered while reading configuration file "
67  << filename);
68  success = false;
69  }
70  f.close();
71  return true;
72  } else {
73  ATH_MSG_ERROR("Unable to open configuration file " << filename);
74  success = false;
75  }
76  } else {
77  ATH_MSG_ERROR("Unable to find configuration file " << filename);
78  success = false;
79  }
80  return success;
81 }
82 
84  if (def.leg[0] == def.leg[1] && def.leg[1] == def.leg[2])
85  def.type = static_cast<TriggerType>(TT_TRILEPTON_SYM | flavourFlag);
86  else if (def.leg[0] != def.leg[1] && def.leg[1] != def.leg[2] &&
87  def.leg[0] != def.leg[2])
88  def.type = static_cast<TriggerType>(TT_TRILEPTON_ASYM | flavourFlag);
89  else
90  {
91  if (def.leg[1] != def.leg[0] && def.leg[1] != def.leg[2])
92  std::swap(def.leg[0], def.leg[1]);
93  else if (def.leg[2] != def.leg[0] && def.leg[2] != def.leg[1])
94  std::swap(def.leg[0], def.leg[2]);
95  def.type = static_cast<TriggerType>(TT_TRILEPTON_HALFSYM | flavourFlag);
96  }
97 }
98 
100  if (!m_triggerThresholds.size() && !importThresholds())
101  return false;
102  m_triggerDefs.clear();
103  std::vector<std::string> config;
104  if (!readDataFile("TrigGlobalEfficiencyCorrection/Triggers.cfg", config))
105  return false;
106  std::stringstream ss;
107  std::string triggerName, token;
108  bool success = true;
109  for (auto& line : config) {
111  ss.clear();
112  ss.str(line);
113  ss >> triggerName;
114  std::size_t h = m_hasher(triggerName);
115  auto& def = m_triggerDefs[h];
116  def.name = h;
117 
118  ss.clear();
119  ss.str(line);
120  ss >> triggerName;
121  m_dictionary[h] = triggerName;
122  ATH_MSG_DEBUG(std::to_string(h) << " " << triggerName);
123 
124  bool hasTauLeg{};
125  for (std::size_t& leg : def.leg) {
126  if (!(ss >> token))
127  break;
128  auto flavour = associatedLeptonFlavour(token, success);
129  if (flavour == xAOD::Type::Tau) {
130  // we don't support taus for now
131  leg = 0;
132  hasTauLeg = true;
133  } else {
134  h = m_hasher(token);
135  m_dictionary.emplace(h, token);
136  leg = h;
137  if (m_triggerThresholds.find(h) == m_triggerThresholds.end()) {
138  ATH_MSG_ERROR("Unknown trigger leg '" << token
139  << "' found in Triggers.cfg");
140  success = false;
141  }
142  }
143  }
144  if (!def.leg[0]) {
145  def.leg[0] = h;
146  if (m_triggerThresholds.find(h) == m_triggerThresholds.end()) {
149  "Unknown trigger leg '"
150  << triggerName
151  << "' (inferred from trigger name) found in Triggers.cfg");
152  success = false;
153  }
154  }
155  if (!success)
156  continue;
157 
160  def.type = TT_UNKNOWN;
161  // triggers with tau legs should stay unknown
162  if (hasTauLeg) {
163  continue;
164  }
165 
166  auto flavour0 = associatedLeptonFlavour(def.leg[0], success);
167  int ne = (flavour0 == xAOD::Type::Electron) * 1;
168  int nm = (flavour0 == xAOD::Type::Muon) * 1;
169  if (def.leg[1]) {
170  auto flavour1 = associatedLeptonFlavour(def.leg[1], success);
171  if (flavour1 == xAOD::Type::Electron) {
172  if (!ne)
173  std::swap(def.leg[0], def.leg[1]);
174  ++ne;
175  } else if (flavour1 == xAOD::Type::Muon) {
176  if (!(ne + nm))
177  std::swap(def.leg[0], def.leg[1]);
178  ++nm;
179  } else if (flavour1 != xAOD::Type::Photon)
180  success = false;
181  if (def.leg[2]) {
182  auto flavour2 = associatedLeptonFlavour(def.leg[2], success);
183  if (flavour2 == xAOD::Type::Electron) {
184  if (!ne)
185  std::swap(def.leg[0], def.leg[2]);
186  else if (ne == 1)
187  std::swap(def.leg[1], def.leg[2]);
188  ++ne;
189  } else if (flavour2 == xAOD::Type::Muon) {
190  if (!(ne + nm))
191  std::swap(def.leg[0], def.leg[2]);
192  else if ((ne + nm) == 1)
193  std::swap(def.leg[1], def.leg[2]);
194  ++nm;
195  } else if (flavour2 != xAOD::Type::Photon)
196  success = false;
197  if (def.leg[3]) {
199  if (std::count(def.leg.cbegin(), def.leg.cend(), def.leg[0]) == 4) {
200  def.type = nm ? TT_4MU_SYM : TT_4E_SYM;
201  } else
202  success = false;
203  } else if (ne + nm == 0 || ne == 3 ||
204  nm == 3)
205  {
207  : nm ? TT_MUON_FLAG
208  : TT_PHOTON_FLAG));
209  } else
210  {
211  bool sym = (def.leg[0] == def.leg[1] || def.leg[1] == def.leg[2]);
212  if (ne == 2)
213  def.type = nm ? (sym ? TT_2E_MU_SYM : TT_2E_MU_ASYM)
214  : (sym ? TT_2E_G_SYM : TT_2E_G_ASYM);
215  else if (nm == 2)
216  def.type = ne ? (sym ? TT_E_2MU_SYM : TT_E_2MU_ASYM)
217  : (sym ? TT_2MU_G_SYM : TT_2MU_G_ASYM);
218  else if (ne + nm == 1)
219  def.type = ne ? (sym ? TT_E_2G_SYM : TT_E_2G_ASYM)
220  : (sym ? TT_MU_2G_SYM : TT_MU_2G_ASYM);
221  else
222  success = false;
223  }
224  } else
225  {
226  if (ne == 2)
227  def.type = (def.leg[0] == def.leg[1]) ? TT_2E_SYM : TT_2E_ASYM;
228  else if (nm == 2)
229  def.type = (def.leg[0] == def.leg[1]) ? TT_2MU_SYM : TT_2MU_ASYM;
230  else if (ne + nm == 0)
231  def.type = (def.leg[0] == def.leg[1]) ? TT_2G_SYM : TT_2G_ASYM;
232  else if (ne == 1 && nm == 1)
233  def.type = TT_E_MU;
234  else if (ne == 1)
235  def.type = TT_E_G;
236  else if (nm == 1)
237  def.type = TT_MU_G;
238  }
239  } else
240  {
241  def.type = ne ? TT_SINGLE_E : nm ? TT_SINGLE_MU : TT_SINGLE_G;
242  }
243  if (!success || def.type == TT_UNKNOWN) {
244  success = false;
245  ATH_MSG_ERROR("Configuration issue for trigger " << triggerName);
246  }
247  }
248  return success;
249 }
250 
252  const std::map<std::string, std::string>& overridenThresholds) {
253  m_triggerThresholds.clear();
254  std::vector<std::string> config;
255  if (!readDataFile("TrigGlobalEfficiencyCorrection/Thresholds.cfg", config))
256  return false;
257  std::stringstream ss;
258  std::string leg, unit;
259  float pt;
260  bool success = true;
261  for (auto& line : config) {
262  ss.clear();
263  ss.str(line);
264  if (ss >> leg >> pt >> unit) {
265  std::size_t h = m_hasher(leg);
266  m_dictionary.emplace(h, leg);
267  if (unit == "GeV")
268  pt *= 1e3f;
269  else if (unit != "MeV") {
270  ATH_MSG_ERROR("Unable to import pT threshold for leg \""
271  << leg << "\" (missing unit)");
272  success = false;
273  }
275  } else {
276  ATH_MSG_ERROR("Unable to import pT threshold for leg \"" << leg << '"');
277  success = false;
278  }
279  }
280  if (!success) {
281  m_triggerThresholds.clear();
282  return false;
283  }
284 
286  bool belowRecommended = false;
287  for (auto& kv : overridenThresholds) {
288  auto itr = m_triggerThresholds.find(m_hasher(kv.first));
289  if (itr != m_triggerThresholds.end()) {
290  float pt = 0.f;
291  try {
292  pt = std::stof(kv.second);
293  } catch (...) {
294  ATH_MSG_ERROR("Unable to convert threshold argument \""
295  << kv.second << "\" to floating-point value");
296  success = false;
297  continue;
298  }
299  if (pt < 1e3f) {
300  ATH_MSG_WARNING("Suspiciously low threshold ("
301  << pt << " MeV) set for trigger leg " << kv.first
302  << ", please make sure you provided the threshold in "
303  "MeV and not in GeV!");
304  }
305  if (pt < itr->second)
306  belowRecommended = true;
307  itr->second = pt;
308  } else {
309  ATH_MSG_ERROR("Can't override threshold for unknown trigger leg "
310  << kv.first);
311  success = false;
312  }
313  }
314  if (belowRecommended) {
316  "Tool configured to use trigger thresholds below those recommended!");
317  }
318  return success;
319 }
320 
322  m_dataPeriods.clear();
323  std::vector<std::string> config;
324  if (!readDataFile("TrigGlobalEfficiencyCorrection/DataPeriods.cfg", config))
325  return false;
326  std::stringstream ss;
327  std::string key;
328  std::pair<unsigned, unsigned> runs;
329  for (auto& line : config) {
330  ss.clear();
331  ss.str(line);
332  ss >> key >> runs.first >> runs.second;
333  if (ss.fail()) {
334  m_dataPeriods.clear();
335  return false;
336  }
337  m_dataPeriods.emplace(key, runs);
338  }
339  return true;
340 }
341 
343  if (!m_triggerThresholds.size() && !importThresholds())
344  return false;
345  m_hierarchyMeta.clear();
346  m_hierarchyData.clear();
347  std::vector<std::string> config;
348  if (!readDataFile("TrigGlobalEfficiencyCorrection/Hierarchies.cfg", config))
349  return false;
350  std::stringstream ss;
351  std::string token, unit;
352  std::map<std::size_t, std::vector<std::size_t> > aliases;
353  for (auto& line : config) {
354  bool success = true;
355  ss.clear();
356  ss.str(line);
357  if (line[0] == '[') {
358  auto& meta = *m_hierarchyMeta.emplace(
359  m_hierarchyMeta.end(),
360  Hierarchy{(short)m_hierarchyData.size(), 0, 0.f,
361  std::numeric_limits<float>::max()});
362  if (line[1] == '-' && line[2] == ']')
363  ss.ignore(3);
364  else {
365  char sep = '-';
366  if (line[1] == '>')
367  ss.ignore(2) >> meta.minPt >> unit;
368  else if (line[1] == '<')
369  ss.ignore(2) >> meta.maxPt >> unit;
370  else
371  ss.ignore(1) >> meta.minPt >> sep >> meta.maxPt >> unit;
372  if (!ss || sep != '-' || (unit != "GeV]" && unit != "MeV]")) {
373  ATH_MSG_ERROR("Unable to parse pT restrictions in Hierarchies.cfg");
374  success = false;
375  }
376  if (unit == "GeV]") {
377  meta.minPt *= 1e3f;
378  if (meta.maxPt < std::numeric_limits<float>::max())
379  meta.maxPt *= 1e3f;
380  }
381  }
382  while (ss >> token) {
383  std::size_t h = m_hasher(token);
384  auto itr = aliases.find(h);
385  if (itr == aliases.end()) {
386  if (m_triggerThresholds.find(h) == m_triggerThresholds.end()) {
387  ATH_MSG_ERROR("Unknown trigger leg '"
388  << token << "' found in Hierarchies.cfg");
389  success = false;
390  }
391  m_dictionary.emplace(h, token);
392  m_hierarchyData.push_back(h);
393  } else
394  m_hierarchyData.insert(m_hierarchyData.end(), itr->second.begin(),
395  itr->second.end());
396  if (ss >> token && token != ">")
397  success = false;
398  }
399  meta.nLegs = m_hierarchyData.size() - meta.offset;
400  success = success && meta.nLegs;
401  } else {
402  ss >> token;
403  auto& legs = aliases[m_hasher(token)];
404  if (ss >> token && token == ":=") {
405  legs.clear();
406  while (ss >> token) {
407  std::size_t h = m_hasher(token);
408  m_dictionary.emplace(h, token);
409  legs.push_back(h);
410  if (m_triggerThresholds.find(h) == m_triggerThresholds.end()) {
411  ATH_MSG_ERROR("Unknown trigger leg '"
412  << token << "' found in Hierarchies.cfg");
413  success = false;
414  }
415  if (ss >> token && token != ">")
416  success = false;
417  }
418  success = success && legs.size();
419  } else
420  success = false;
421  }
422  if (!success) {
423  ATH_MSG_ERROR("Failed parsing line from Hierarchies.cfg:\n" << line);
424  m_hierarchyMeta.clear();
425  m_hierarchyData.clear();
426  return false;
427  }
428  }
429  return true;
430 }
431 
433  const std::string& version,
434  std::map<std::size_t, std::map<std::size_t, int> >& keysPerLeg) {
435  keysPerLeg.clear();
436  std::vector<std::string> config;
437  if (!readDataFile("TrigGlobalEfficiencyCorrection/MapKeys.cfg", config))
438  return false;
439  std::stringstream ss;
440  std::string token;
441  bool reading = false;
442  for (auto& line : config) {
443  std::size_t pos = line.find("[VERSION]");
444  if (pos != std::string::npos) {
445  reading = false;
446  ss.clear();
447  ss.str(TrigGlobEffCorr::removeWhitespaces(line.substr(pos + 9)));
448  while (std::getline(ss, token, ',')) {
449  if (token == version) {
450  reading = true;
451  break;
452  }
453  }
454  continue;
455  }
456  if (!reading)
457  continue;
458  ss.clear();
459  ss.str(line);
460  int year;
461  ss >> year >> token;
462  year = 1 << (year - 2015);
463  std::size_t leg = m_hasher(token);
464  auto& keys = keysPerLeg[leg];
465  while (ss >> token) {
466  std::size_t h = m_hasher(token);
467  auto insertion = keys.emplace(h, year);
468  if (insertion.second)
469  m_dictionary.emplace(h, token);
470  else
471  insertion.first->second |= year;
472  }
473  }
474  if (!keysPerLeg.size()) {
475  ATH_MSG_ERROR("Unable to import the available map keys for the version "
476  << version);
477  return false;
478  }
479  return true;
480 }
481 
483  const std::string& period, std::pair<unsigned, unsigned>& boundaries) {
484  // First possibility: a defined period keyword
485  auto itr = m_dataPeriods.find(period);
486  if (itr != m_dataPeriods.end()) {
487  boundaries = itr->second;
488  return true;
489  }
490  // Otherwise it's a '-'-separated range
491  auto sep = period.find_first_of('-');
492  if (sep != std::string::npos) {
493  std::string kwMin = period.substr(0, sep);
494  std::string kwMax = period.substr(sep + 1);
495  // Second possibility: a range of defined period keywords
496  auto itrMin = m_dataPeriods.find(kwMin);
497  auto itrMax = m_dataPeriods.find(kwMax);
498  if (itrMin != m_dataPeriods.end() && itrMax != m_dataPeriods.end()) {
499  boundaries = std::minmax({itrMin->second.first, itrMax->second.first,
500  itrMin->second.second, itrMax->second.second});
501  return true;
502  }
503  // Third possibility: a range of run numbers
504  try {
505  boundaries = std::minmax(std::stoi(kwMin), std::stoi(kwMax));
506  return true;
507  } catch (...) {
508  }
509  }
510  ATH_MSG_ERROR("Unable to understand the period/range " << period);
511  return false;
512 }
513 
515  const std::string& leg, bool& success) {
516  // note: 'success' is not set to 'true', only downgraded to 'false' if needed
517  if (leg.length() >= 2 && leg[0] == 'e' && leg[1] >= '1' && leg[1] <= '9')
518  return xAOD::Type::Electron;
519  else if (leg.length() >= 3 && leg[0] == 'm' && leg[1] == 'u' &&
520  leg[2] >= '1' && leg[2] <= '9')
521  return xAOD::Type::Muon;
522  else if (leg.length() >= 3 && leg[0] == 'g' && leg[1] >= '1' && leg[1] <= '9')
523  return xAOD::Type::Photon;
524  else if (leg.length() >= 4 && leg[0] == 't' && leg[1] == 'a' &&
525  leg[2] == 'u' && leg[3] >= '1' && leg[3] <= '9')
526  return xAOD::Type::Tau;
527  success = false;
528  return xAOD::Type::Other;
529 }
530 
532  bool& success) {
533  // note: 'success' is not set to 'true', only downgraded to 'false' if needed
534  auto itr = m_dictionary.find(leg);
535  if (itr != m_dictionary.end()) {
536  return associatedLeptonFlavour(itr->second, success);
537  }
538  success = false;
539  return xAOD::Type::Other;
540 }
541 
542 std::vector<ImportData::TrigDef> ImportData::parseTriggerString(
543  const std::string& triggerString, bool& success) {
544  std::string s = TrigGlobEffCorr::removeWhitespaces(triggerString);
545  if (s.find("|||") != std::string::npos) {
546  ATH_MSG_ERROR("Invalid format for the trigger combination '"
547  << triggerString << "'");
548  success = false;
549  return {};
550  }
552  while (true) {
553  auto i = s.find("||");
554  if (i == std::string::npos)
555  break;
556  s.replace(i, 1, "");
557  }
558  if (s == "" || s == "|") {
559  ATH_MSG_ERROR("Invalid format for the trigger combination '"
560  << triggerString << "'");
561  success = false;
562  return {};
563  }
564  std::vector<TrigDef> triggers;
565  std::set<std::size_t> hashes;
566  std::stringstream ss(s);
567  while (std::getline(ss, s, '|')) {
568  std::size_t trig = m_hasher(s);
569  ATH_MSG_DEBUG(std::to_string(trig) << " --> " << s);
570  auto itr = m_triggerDefs.find(trig);
571  if (itr == m_triggerDefs.end()) {
572  ATH_MSG_ERROR("Unknown trigger '"
573  << s << "' found while parsing trigger combination");
574  success = false;
575  return {};
576  }
577  if (!hashes.insert(trig).second) {
578  ATH_MSG_ERROR("The trigger '"
579  << s << "' is present more than once in the combination");
580  success = false;
581  return {};
582  }
583  triggers.push_back(itr->second);
584  }
585  success = success && triggers.size();
586  return triggers;
587 }
588 
590  const std::map<std::string, std::string>& triggerCombination,
591  const std::string& version, std::map<std::string, std::string>& legsPerKey,
593  legsPerKey.clear();
594  if (!importAll())
595  return false;
596 
597  bool success = true;
598  std::map<std::size_t, int> legs;
599 
600  for (auto& kv : triggerCombination) {
601  auto itrPeriod = m_dataPeriods.find(kv.first);
602  if (itrPeriod == m_dataPeriods.end()) {
603  ATH_MSG_ERROR("Unknown period " << kv.first);
604  success = false;
605  continue;
606  }
607  int years = 0;
608  for (int k = 0; k < 32; ++k) {
609  auto itr = m_dataPeriods.find(std::to_string(2015 + k));
610  if (itr != m_dataPeriods.end() &&
611  itrPeriod->second.first <= itr->second.second &&
612  itrPeriod->second.second >= itr->second.first) {
613  years |= (1 << k);
614  }
615  }
616  auto triggers = parseTriggerString(kv.second, success);
617  if (!success)
618  continue;
619  for (auto& trig : triggers) {
620  for (std::size_t leg : trig.leg) {
621  if (leg && associatedLeptonFlavour(leg, success) == type) {
622  auto insertion = legs.emplace(leg, years);
623  if (!insertion.second)
624  insertion.first->second |= years;
625  }
626  }
627  }
628  }
629  if (!success)
630  return false;
631 
632  if (version != "") {
633  std::map<std::size_t, std::map<std::size_t, int> > allKeys;
634  if (!importMapKeys(version, allKeys))
635  return false;
636  std::map<std::size_t, std::vector<std::size_t> > allLegsPerKey;
637  std::set<std::size_t> legsWithMultipleKeys;
638  bool sameKeyForAllyears = true;
639  while (legs.size()) {
640  allLegsPerKey.clear();
641  for (auto& kvLegs : legs) // loop on remaining legs
642  {
643  std::size_t leg = kvLegs.first;
644  int years = kvLegs.second;
645  auto itrKeys = allKeys.find(leg); // list of keys for that leg
646  if (itrKeys != allKeys.end()) {
647  for (auto& kvKeys : itrKeys->second) // loop on those keys
648  {
649  auto y = (kvKeys.second & years);
650  if ((y == years) ||
651  (!sameKeyForAllyears &&
652  y != 0)) // key must support all years needed for that leg --
653  // until no longer possible
654  {
655  auto insertion = allLegsPerKey.emplace(
656  kvKeys.first, std::vector<std::size_t>{leg});
657  if (!insertion.second)
658  insertion.first->second.push_back(leg);
659  }
660  }
661  } else {
663  "Sorry, no idea what the map key should be for the trigger leg '"
664  << m_dictionary.at(leg) << "', manual configuration is needed");
665  success = false;
666  }
667  }
668  if (!success)
669  break;
670 
671  if (!allLegsPerKey.size()) {
672  if (sameKeyForAllyears) {
673  sameKeyForAllyears = false;
674  continue;
675  }
676  success = false;
677  break;
678  }
679 
680  using T = decltype(allLegsPerKey)::value_type;
681  auto itrKey = std::max_element(
682  allLegsPerKey.begin(), allLegsPerKey.end(),
683  [](T& x, T& y) { return x.second.size() < y.second.size(); });
684  std::string& strLegs = legsPerKey[m_dictionary.at(itrKey->first)];
685  for (std::size_t leg : itrKey->second) {
686  int& wantedYears = legs.at(leg);
687  int supportedYears = (allKeys.at(leg).at(itrKey->first)) & wantedYears;
688  if (supportedYears != wantedYears || legsWithMultipleKeys.count(leg)) {
689  legsWithMultipleKeys.insert(leg);
690  for (int i = 0; i < 32; ++i) {
691  if (supportedYears & (1u << i)) {
692  if (strLegs.length() && strLegs.back() != ',')
693  strLegs += ',';
694  strLegs +=
695  m_dictionary.at(leg) + "[" + std::to_string(2015 + i) + "]";
696  }
697  }
698  } else {
699  if (strLegs.length() && strLegs.back() != ',')
700  strLegs += ',';
701  strLegs += m_dictionary.at(leg);
702  }
703  if (supportedYears == wantedYears)
704  legs.erase(leg);
705  else
706  wantedYears &= ~supportedYears;
707  }
708  }
709  } else {
711  for (auto& kv : legs) {
712  legsPerKey.emplace(std::to_string(legsPerKey.size()),
713  m_dictionary.at(kv.first));
714  }
715  }
716  for (auto& [key, legs] : legsPerKey) {
717  if (key ==
720  "Some of the requested triggers will result in "
721  "a default scale factor of 1 being returned");
722  }
723  }
724  if (!success)
725  legsPerKey.clear();
726  return success;
727 }
728 
730  std::vector<ImportData::TrigDef>& triggers) {
732  std::set<std::size_t> extraItems;
733  std::vector<ImportData::TrigDef> updatedTriggers;
734  for (auto& trig : triggers) {
735  auto& name = m_dictionary.at(trig.name);
736  std::size_t pos = 0, len = name.find("_OR_");
737  if (len == std::string::npos) {
738  updatedTriggers.emplace_back(trig);
739  continue;
740  }
741  while (true) {
742  std::string item = name.substr(pos, len);
743  auto h = m_hasher(item);
744  auto def = m_triggerDefs.find(h);
745  if (def == m_triggerDefs.end()) {
746  ATH_MSG_ERROR("while listing triggers for trigger matching; trigger \""
747  << item << "\" extracted from \"" << name
748  << "\" is not recognized");
749  return false;
750  }
751  if (extraItems.emplace(h).second)
752  updatedTriggers.emplace_back(def->second);
753  if (len == std::string::npos)
754  break;
755  pos += len + 4;
756  len = name.find("_OR_", pos);
757  if (len != std::string::npos)
758  len -= pos;
759  }
760  }
761  triggers.swap(updatedTriggers);
762  return true;
763 }
python.root_lsr_rank.hashes
hashes
Definition: root_lsr_rank.py:34
TrigGlobEffCorr::TT_E_MU
@ TT_E_MU
Definition: ImportData.h:47
python.AtlRunQueryAMI.period
period
Definition: AtlRunQueryAMI.py:224
TrigGlobEffCorr::ImportData::m_triggerDefs
std::map< std::size_t, TrigDef > m_triggerDefs
Definition: ImportData.h:163
TrigGlobEffCorr::TT_2MU_SYM
@ TT_2MU_SYM
Definition: ImportData.h:45
TrigGlobEffCorr::TT_2E_MU_SYM
@ TT_2E_MU_SYM
Definition: ImportData.h:63
TrigGlobEffCorr::TT_2G_ASYM
@ TT_2G_ASYM
Definition: ImportData.h:49
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
TrigGlobEffCorr::TT_SINGLE_MU
@ TT_SINGLE_MU
Definition: ImportData.h:37
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
ObjectType
ObjectType
Definition: BaseObject.h:11
TrigGlobEffCorr::ImportData::m_dictionary
std::map< std::size_t, std::string > & m_dictionary
Definition: ImportData.h:160
TrigGlobEffCorr::ImportData::adaptTriggerListForTriggerMatching
bool adaptTriggerListForTriggerMatching(std::vector< ImportData::TrigDef > &triggers)
Definition: ImportData.cxx:729
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
TrigGlobEffCorr::ImportData::getPeriodBoundaries
bool getPeriodBoundaries(const std::string &period, std::pair< unsigned, unsigned > &boundaries)
Definition: ImportData.cxx:482
python.base_data.config
config
Definition: base_data.py:20
find_tgc_unfilled_channelids.runs
int runs
Definition: find_tgc_unfilled_channelids.py:10
TrigGlobEffCorr::ImportData::~ImportData
~ImportData()
Definition: ImportData.cxx:34
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
python.SystemOfUnits.second
float second
Definition: SystemOfUnits.py:135
asg
Definition: DataHandleTestTool.h:28
test_pyathena.pt
pt
Definition: test_pyathena.py:11
TrigGlobEffCorr::TT_2E_ASYM
@ TT_2E_ASYM
Definition: ImportData.h:44
TrigGlobEffCorr::TT_E_2MU_SYM
@ TT_E_2MU_SYM
Definition: ImportData.h:64
TrigGlobEffCorr::TT_SINGLE_E
@ TT_SINGLE_E
Definition: ImportData.h:36
python.TrigTLAMonitorAlgorithm.triggers
triggers
Definition: TrigTLAMonitorAlgorithm.py:196
TrigGlobEffCorr::ImportData::m_dataPeriods
std::map< std::string, std::pair< unsigned, unsigned > > m_dataPeriods
Definition: ImportData.h:165
TrigGlobEffCorr::ImportData::importHierarchies
bool importHierarchies()
Definition: ImportData.cxx:342
python.AtlRunQueryAMI.year
year
Definition: AtlRunQueryAMI.py:225
TrigGlobEffCorr::ImportData::importMapKeys
bool importMapKeys(const std::string &tag, std::map< std::size_t, std::map< std::size_t, int >> &keysPerLeg)
Definition: ImportData.cxx:432
x
#define x
TrigGlobEffCorr::TT_MUON_FLAG
@ TT_MUON_FLAG
Definition: ImportData.h:26
TrigGlobEffCorr::TT_E_2MU_ASYM
@ TT_E_2MU_ASYM
Definition: ImportData.h:66
dq_defect_bulk_create_defects.line
line
Definition: dq_defect_bulk_create_defects.py:27
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
XMLtoHeader.count
count
Definition: XMLtoHeader.py:84
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
TrigGlobEffCorr::TT_ELECTRON_FLAG
@ TT_ELECTRON_FLAG
Definition: ImportData.h:25
ImportData.h
TrigGlobEffCorr::TT_2MU_G_SYM
@ TT_2MU_G_SYM
Definition: ImportData.h:74
TrigGlobEffCorr::ImportData::parseTriggerString
std::vector< TrigDef > parseTriggerString(const std::string &triggerString, bool &success)
Definition: ImportData.cxx:542
TrigGlobEffCorr::TT_2G_SYM
@ TT_2G_SYM
Definition: ImportData.h:48
TrigGlobEffCorr::ImportData::m_hierarchyData
std::vector< std::size_t > m_hierarchyData
Definition: ImportData.h:167
PyPoolBrowser.item
item
Definition: PyPoolBrowser.py:129
TrigGlobEffCorr::TT_2E_SYM
@ TT_2E_SYM
Definition: ImportData.h:43
TrigGlobEffCorr::TT_MU_2G_ASYM
@ TT_MU_2G_ASYM
Definition: ImportData.h:77
TrigGlobEffCorr::ImportData::importThresholds
bool importThresholds(const std::map< std::string, std::string > &overridenThresholds={})
Definition: ImportData.cxx:251
TrigGlobEffCorr::ImportData::TrigDef::leg
std::array< std::size_t, 4 > leg
Definition: ImportData.h:93
TrigGlobEffCorr::TT_2E_MU_ASYM
@ TT_2E_MU_ASYM
Definition: ImportData.h:65
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigGlobEffCorr::ImportData::m_hierarchyMeta
std::vector< Hierarchy > m_hierarchyMeta
Definition: ImportData.h:166
TrigGlobEffCorr::TT_PHOTON_FLAG
@ TT_PHOTON_FLAG
Definition: ImportData.h:27
TrigGlobEffCorr::ImportData::ImportData
ImportData()
the following two variables are owned by this tool and released in the destructor
Definition: ImportData.cxx:18
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigGlobEffCorr::ImportData::associatedLeptonFlavour
xAOD::Type::ObjectType associatedLeptonFlavour(std::size_t leg, bool &success)
Definition: ImportData.cxx:531
TrigGlobEffCorr::TT_TRILEPTON_ASYM
@ TT_TRILEPTON_ASYM
Definition: ImportData.h:56
TrigGlobEffCorr::ImportData
Definition: ImportData.h:86
extractSporadic.h
list h
Definition: extractSporadic.py:96
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrigGlobEffCorr::TT_TRILEPTON_HALFSYM
@ TT_TRILEPTON_HALFSYM
Definition: ImportData.h:55
asg::AsgMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AsgMessaging.cxx:49
test_pyathena.parent
parent
Definition: test_pyathena.py:15
compute_lumi.leg
leg
Definition: compute_lumi.py:95
TrigGlobEffCorr::ImportData::importPeriods
bool importPeriods()
Definition: ImportData.cxx:321
hist_file_dump.f
f
Definition: hist_file_dump.py:140
TrigGlobEffCorr::TT_4E_SYM
@ TT_4E_SYM
Definition: ImportData.h:81
TrigGlobEffCorr::ImportData::m_hasher
std::hash< std::string > & m_hasher
Definition: ImportData.h:161
TrigGlobEffCorr::TT_E_2G_ASYM
@ TT_E_2G_ASYM
Definition: ImportData.h:73
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
contents
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory, const std::string &pattern, const std::string &path)
Definition: computils.cxx:321
plotting.yearwise_efficiency.years
list years
Definition: yearwise_efficiency.py:29
TrigGlobEffCorr::ImportData::TrigDef::type
TriggerType type
Definition: ImportData.h:91
ImportData
TrigGlobEffCorr::ImportData ImportData
Definition: ImportData.cxx:16
grepfile.sep
sep
Definition: grepfile.py:38
TrigGlobEffCorr::TT_2E_G_ASYM
@ TT_2E_G_ASYM
Definition: ImportData.h:72
PathResolver.h
TrigGlobEffCorr::TriggerType
TriggerType
Definition: ImportData.h:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TrigGlobEffCorr::ImportData::suggestEgammaMapKeys
bool suggestEgammaMapKeys(const std::map< std::string, std::string > &triggerCombination, const std::string &version, std::map< std::string, std::string > &legsPerKey, xAOD::Type::ObjectType type)
Definition: ImportData.cxx:589
TrigGlobalEfficiencyCorrectionTool
Definition: TrigGlobalEfficiencyCorrectionTool.h:37
TrigGlobEffCorr::ImportData::readDataFile
bool readDataFile(const char *filename, std::vector< std::string > &contents)
Definition: ImportData.cxx:47
TrigGlobEffCorr::ImportData::TrigDef
Definition: ImportData.h:90
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:283
Muon
struct TBPatternUnitContext Muon
get_generator_info.version
version
Definition: get_generator_info.py:33
TrigGlobEffCorr::ImportData::m_triggerThresholds
std::map< std::size_t, float > m_triggerThresholds
Definition: ImportData.h:164
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:109
y
#define y
h
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
TrigGlobEffCorr::TT_UNKNOWN
@ TT_UNKNOWN
Definition: ImportData.h:23
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TrigGlobEffCorr::TT_E_2G_SYM
@ TT_E_2G_SYM
Definition: ImportData.h:71
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:21
TrigGlobEffCorr::TT_2MU_G_ASYM
@ TT_2MU_G_ASYM
Definition: ImportData.h:76
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23
TrigGlobEffCorr::ImportData::importAll
bool importAll(const std::map< std::string, std::string > &overridenThresholds={})
Definition: ImportData.cxx:41
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
ITrigGlobalEfficiencyCorrectionTool::toolnameForDefaultScaleFactor
static std::string toolnameForDefaultScaleFactor()
To be used with the ListOfLegsPerTool property:
Definition: ITrigGlobalEfficiencyCorrectionTool.h:57
xAODType::Tau
@ Tau
The object is a tau (jet)
Definition: ObjectType.h:49
TrigGlobEffCorr::TT_4MU_SYM
@ TT_4MU_SYM
Definition: ImportData.h:82
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
TrigGlobEffCorr::ImportData::importTriggers
bool importTriggers()
Definition: ImportData.cxx:99
TrigGlobEffCorr::TT_MU_2G_SYM
@ TT_MU_2G_SYM
Definition: ImportData.h:75
TrigGlobEffCorr::removeWhitespaces
std::string removeWhitespaces(const std::string &s)
Definition: ImportData.h:170
TrigGlobEffCorr::TT_2E_G_SYM
@ TT_2E_G_SYM
Definition: ImportData.h:70
TrigGlobEffCorr::ImportData::setNonMixed3LType
void setNonMixed3LType(TrigDef &def, TriggerType flavourFlag)
Definition: ImportData.cxx:83
value_type
Definition: EDM_MasterSearch.h:11
TrigGlobEffCorr::ImportData::m_parent
TrigGlobalEfficiencyCorrectionTool * m_parent
Definition: ImportData.h:159
TrigGlobEffCorr::TT_MU_G
@ TT_MU_G
Definition: ImportData.h:51
TrigGlobEffCorr::TT_E_G
@ TT_E_G
Definition: ImportData.h:50
TrigGlobEffCorr::TT_TRILEPTON_SYM
@ TT_TRILEPTON_SYM
Definition: ImportData.h:54
TrigGlobalEfficiencyCorrectionTool::Hierarchy
Definition: TrigGlobalEfficiencyCorrectionTool.h:99
fitman.k
k
Definition: fitman.py:528
TrigGlobEffCorr::TT_SINGLE_G
@ TT_SINGLE_G
Definition: ImportData.h:38
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
TrigGlobEffCorr::TT_2MU_ASYM
@ TT_2MU_ASYM
Definition: ImportData.h:46