ATLAS Offline Software
Loading...
Searching...
No Matches
ImportData.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// contact: jmaurer@cern.ch
6
8
9#include <algorithm>
10#include <fstream>
11#include <functional>
12#include <limits>
13
15
17
19 :
21 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),
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
47bool ImportData::readDataFile(const char* filename,
48 std::vector<std::string>& contents) {
49 contents.clear();
50 bool success = true;
51 auto name = PathResolverFindCalibFile(filename);
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) {
110 ATH_MSG_DEBUG(line);
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;
147 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 if (year < 2015) {
463 ATH_MSG_ERROR("Malformed line from TrigGlobalEfficiencyCorrection/MapKeys.cfg: " << line);
464 return false;
465 }
466 year = 1 << (year - 2015);
467 std::size_t leg = m_hasher(token);
468 auto& keys = keysPerLeg[leg];
469 while (ss >> token) {
470 std::size_t h = m_hasher(token);
471 auto insertion = keys.emplace(h, year);
472 if (insertion.second)
473 m_dictionary.emplace(h, token);
474 else
475 insertion.first->second |= year;
476 }
477 }
478 if (!keysPerLeg.size()) {
479 ATH_MSG_ERROR("Unable to import the available map keys for the version "
480 << version);
481 return false;
482 }
483 return true;
484}
485
487 const std::string& period, std::pair<unsigned, unsigned>& boundaries) {
488 // First possibility: a defined period keyword
489 auto itr = m_dataPeriods.find(period);
490 if (itr != m_dataPeriods.end()) {
491 boundaries = itr->second;
492 return true;
493 }
494 // Otherwise it's a '-'-separated range
495 auto sep = period.find_first_of('-');
496 if (sep != std::string::npos) {
497 std::string kwMin = period.substr(0, sep);
498 std::string kwMax = period.substr(sep + 1);
499 // Second possibility: a range of defined period keywords
500 auto itrMin = m_dataPeriods.find(kwMin);
501 auto itrMax = m_dataPeriods.find(kwMax);
502 if (itrMin != m_dataPeriods.end() && itrMax != m_dataPeriods.end()) {
503 boundaries = std::minmax({itrMin->second.first, itrMax->second.first,
504 itrMin->second.second, itrMax->second.second});
505 return true;
506 }
507 // Third possibility: a range of run numbers
508 try {
509 boundaries = std::minmax(std::stoi(kwMin), std::stoi(kwMax));
510 return true;
511 } catch (...) {
512 }
513 }
514 ATH_MSG_ERROR("Unable to understand the period/range " << period);
515 return false;
516}
517
519 const std::string& leg, bool& success) {
520 // note: 'success' is not set to 'true', only downgraded to 'false' if needed
521 if (leg.length() >= 2 && leg[0] == 'e' && leg[1] >= '1' && leg[1] <= '9')
523 else if (leg.length() >= 3 && leg[0] == 'm' && leg[1] == 'u' &&
524 leg[2] >= '1' && leg[2] <= '9')
525 return xAOD::Type::Muon;
526 else if (leg.length() >= 3 && leg[0] == 'g' && leg[1] >= '1' && leg[1] <= '9')
527 return xAOD::Type::Photon;
528 else if (leg.length() >= 4 && leg[0] == 't' && leg[1] == 'a' &&
529 leg[2] == 'u' && leg[3] >= '1' && leg[3] <= '9')
530 return xAOD::Type::Tau;
531 success = false;
532 return xAOD::Type::Other;
533}
534
536 bool& success) {
537 // note: 'success' is not set to 'true', only downgraded to 'false' if needed
538 auto itr = m_dictionary.find(leg);
539 if (itr != m_dictionary.end()) {
540 return associatedLeptonFlavour(itr->second, success);
541 }
542 success = false;
543 return xAOD::Type::Other;
544}
545
546std::vector<ImportData::TrigDef> ImportData::parseTriggerString(
547 const std::string& triggerString, bool& success) {
548 std::string s = TrigGlobEffCorr::removeWhitespaces(triggerString);
549 if (s.find("|||") != std::string::npos) {
550 ATH_MSG_ERROR("Invalid format for the trigger combination '"
551 << triggerString << "'");
552 success = false;
553 return {};
554 }
556 while (true) {
557 auto i = s.find("||");
558 if (i == std::string::npos)
559 break;
560 s.replace(i, 1, "");
561 }
562 if (s == "" || s == "|") {
563 ATH_MSG_ERROR("Invalid format for the trigger combination '"
564 << triggerString << "'");
565 success = false;
566 return {};
567 }
568 std::vector<TrigDef> triggers;
569 std::set<std::size_t> hashes;
570 std::stringstream ss(s);
571 while (std::getline(ss, s, '|')) {
572 std::size_t trig = m_hasher(s);
573 ATH_MSG_DEBUG(std::to_string(trig) << " --> " << s);
574 auto itr = m_triggerDefs.find(trig);
575 if (itr == m_triggerDefs.end()) {
576 ATH_MSG_ERROR("Unknown trigger '"
577 << s << "' found while parsing trigger combination");
578 success = false;
579 return {};
580 }
581 if (!hashes.insert(trig).second) {
582 ATH_MSG_ERROR("The trigger '"
583 << s << "' is present more than once in the combination");
584 success = false;
585 return {};
586 }
587 triggers.push_back(itr->second);
588 }
589 success = success && triggers.size();
590 return triggers;
591}
592
594 const std::map<std::string, std::string>& triggerCombination,
595 const std::string& version, std::map<std::string, std::string>& legsPerKey,
597 legsPerKey.clear();
598 if (!importAll())
599 return false;
600
601 bool success = true;
602 std::map<std::size_t, int> legs;
603
604 for (auto& kv : triggerCombination) {
605 auto itrPeriod = m_dataPeriods.find(kv.first);
606 if (itrPeriod == m_dataPeriods.end()) {
607 ATH_MSG_ERROR("Unknown period " << kv.first);
608 success = false;
609 continue;
610 }
611 int years = 0;
612 for (int k = 0; k < 32; ++k) {
613 auto itr = m_dataPeriods.find(std::to_string(2015 + k));
614 if (itr != m_dataPeriods.end() &&
615 itrPeriod->second.first <= itr->second.second &&
616 itrPeriod->second.second >= itr->second.first) {
617 years |= (1 << k);
618 }
619 }
620 auto triggers = parseTriggerString(kv.second, success);
621 if (!success)
622 continue;
623 for (auto& trig : triggers) {
624 for (std::size_t leg : trig.leg) {
625 if (leg && associatedLeptonFlavour(leg, success) == type) {
626 auto insertion = legs.emplace(leg, years);
627 if (!insertion.second)
628 insertion.first->second |= years;
629 }
630 }
631 }
632 }
633 if (!success)
634 return false;
635
636 if (version != "") {
637 std::map<std::size_t, std::map<std::size_t, int> > allKeys;
638 if (!importMapKeys(version, allKeys))
639 return false;
640 std::map<std::size_t, std::vector<std::size_t> > allLegsPerKey;
641 std::set<std::size_t> legsWithMultipleKeys;
642 bool sameKeyForAllyears = true;
643 while (legs.size()) {
644 allLegsPerKey.clear();
645 for (auto& kvLegs : legs) // loop on remaining legs
646 {
647 std::size_t leg = kvLegs.first;
648 int years = kvLegs.second;
649 auto itrKeys = allKeys.find(leg); // list of keys for that leg
650 if (itrKeys != allKeys.end()) {
651 for (auto& kvKeys : itrKeys->second) // loop on those keys
652 {
653 auto y = (kvKeys.second & years);
654 if ((y == years) ||
655 (!sameKeyForAllyears &&
656 y != 0)) // key must support all years needed for that leg --
657 // until no longer possible
658 {
659 auto insertion = allLegsPerKey.emplace(
660 kvKeys.first, std::vector<std::size_t>{leg});
661 if (!insertion.second)
662 insertion.first->second.push_back(leg);
663 }
664 }
665 } else {
667 "Sorry, no idea what the map key should be for the trigger leg '"
668 << m_dictionary.at(leg) << "', manual configuration is needed");
669 success = false;
670 }
671 }
672 if (!success)
673 break;
674
675 if (!allLegsPerKey.size()) {
676 if (sameKeyForAllyears) {
677 sameKeyForAllyears = false;
678 continue;
679 }
680 success = false;
681 break;
682 }
683
684 using T = decltype(allLegsPerKey)::value_type;
685 auto itrKey = std::max_element(
686 allLegsPerKey.begin(), allLegsPerKey.end(),
687 [](T& x, T& y) { return x.second.size() < y.second.size(); });
688 std::string& strLegs = legsPerKey[m_dictionary.at(itrKey->first)];
689 for (std::size_t leg : itrKey->second) {
690 int& wantedYears = legs.at(leg);
691 int supportedYears = (allKeys.at(leg).at(itrKey->first)) & wantedYears;
692 if (supportedYears != wantedYears || legsWithMultipleKeys.count(leg)) {
693 legsWithMultipleKeys.insert(leg);
694 for (int i = 0; i < 32; ++i) {
695 if (supportedYears & (1u << i)) {
696 if (strLegs.length() && strLegs.back() != ',')
697 strLegs += ',';
698 strLegs +=
699 m_dictionary.at(leg) + "[" + std::to_string(2015 + i) + "]";
700 }
701 }
702 } else {
703 if (strLegs.length() && strLegs.back() != ',')
704 strLegs += ',';
705 strLegs += m_dictionary.at(leg);
706 }
707 if (supportedYears == wantedYears)
708 legs.erase(leg);
709 else
710 wantedYears &= ~supportedYears;
711 }
712 }
713 } else {
715 for (auto& kv : legs) {
716 legsPerKey.emplace(std::to_string(legsPerKey.size()),
717 m_dictionary.at(kv.first));
718 }
719 }
720 for (auto& [key, legs] : legsPerKey) {
721 if (key ==
724 "Some of the requested triggers will result in "
725 "a default scale factor of 1 being returned");
726 }
727 }
728 if (!success)
729 legsPerKey.clear();
730 return success;
731}
732
734 std::vector<ImportData::TrigDef>& triggers) {
736 std::set<std::size_t> extraItems;
737 std::vector<ImportData::TrigDef> updatedTriggers;
738 for (auto& trig : triggers) {
739 auto& name = m_dictionary.at(trig.name);
740 std::size_t pos = 0, len = name.find("_OR_");
741 if (len == std::string::npos) {
742 updatedTriggers.emplace_back(trig);
743 continue;
744 }
745 while (true) {
746 std::string item = name.substr(pos, len);
747 auto h = m_hasher(item);
748 auto def = m_triggerDefs.find(h);
749 if (def == m_triggerDefs.end()) {
750 ATH_MSG_ERROR("while listing triggers for trigger matching; trigger \""
751 << item << "\" extracted from \"" << name
752 << "\" is not recognized");
753 return false;
754 }
755 if (extraItems.emplace(h).second)
756 updatedTriggers.emplace_back(def->second);
757 if (len == std::string::npos)
758 break;
759 pos += len + 4;
760 len = name.find("_OR_", pos);
761 if (len != std::string::npos)
762 len -= pos;
763 }
764 }
765 triggers.swap(updatedTriggers);
766 return true;
767}
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
TrigGlobEffCorr::ImportData ImportData
static Double_t ss
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
#define y
#define x
Header file for AthHistogramAlgorithm.
static std::string toolnameForDefaultScaleFactor()
To be used with the ListOfLegsPerTool property:
bool readDataFile(const char *filename, std::vector< std::string > &contents)
xAOD::Type::ObjectType associatedLeptonFlavour(std::size_t leg, bool &success)
bool adaptTriggerListForTriggerMatching(std::vector< ImportData::TrigDef > &triggers)
TrigGlobalEfficiencyCorrectionTool::Hierarchy Hierarchy
Definition ImportData.h:87
bool importThresholds(const std::map< std::string, std::string > &overridenThresholds={})
std::vector< TrigDef > parseTriggerString(const std::string &triggerString, bool &success)
bool importMapKeys(const std::string &tag, std::map< std::size_t, std::map< std::size_t, int > > &keysPerLeg)
std::hash< std::string > & m_hasher
Definition ImportData.h:161
void setNonMixed3LType(TrigDef &def, TriggerType flavourFlag)
bool importAll(const std::map< std::string, std::string > &overridenThresholds={})
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)
std::vector< std::size_t > m_hierarchyData
Definition ImportData.h:167
bool getPeriodBoundaries(const std::string &period, std::pair< unsigned, unsigned > &boundaries)
TrigGlobalEfficiencyCorrectionTool * m_parent
Definition ImportData.h:159
ImportData()
the following two variables are owned by this tool and released in the destructor
std::map< std::string, std::pair< unsigned, unsigned > > m_dataPeriods
Definition ImportData.h:165
std::map< std::size_t, TrigDef > m_triggerDefs
Definition ImportData.h:163
std::map< std::size_t, float > m_triggerThresholds
Definition ImportData.h:164
std::vector< Hierarchy > m_hierarchyMeta
Definition ImportData.h:166
std::map< std::size_t, std::string > & m_dictionary
Definition ImportData.h:160
MsgStream & msg() const
The standard message stream.
AsgMessaging(const std::string &name)
Constructor with a name.
STL class.
STL class.
void contents(std::vector< std::string > &keys, TDirectory *td, const std::string &directory, const std::string &pattern, const std::string &path)
std::string removeWhitespaces(const std::string &s)
Definition ImportData.h:170
-diff
STL namespace.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
@ Photon
The object is a photon.
Definition ObjectType.h:47
@ Other
An object not falling into any of the other categories.
Definition ObjectType.h:34
@ Muon
The object is a muon.
Definition ObjectType.h:48
@ Electron
The object is an electron.
Definition ObjectType.h:46
@ Tau
The object is a tau (jet).
Definition ObjectType.h:49
std::array< std::size_t, 4 > leg
Definition ImportData.h:93