ATLAS Offline Software
TrigGlobalEfficiencyCorrectionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // contact: jmaurer@cern.ch
6 
8 
9 #include <algorithm>
10 #include <array>
11 #include <cctype>
12 #include <cmath>
13 #include <limits>
14 #include <regex>
15 #include <sstream>
16 #include <type_traits>
17 
23 #include "xAODEgamma/Electron.h"
24 #include "xAODEgamma/Photon.h"
26 
32 
33 TrigGlobalEfficiencyCorrectionTool::TrigGlobalEfficiencyCorrectionTool(
34  const std::string& name)
35  : asg::AsgTool(name),
36  m_trigMatchTool("", nullptr),
37  m_checkElectronLegTag(false),
38  m_checkMuonLegTag(false),
39  m_seed(1),
40  m_validTrigMatchTool(false),
41  m_runNumberDecorator("RandomRunNumber"),
42  m_calculator() {
43  declareProperty("ElectronEfficiencyTools", m_suppliedElectronEfficiencyTools,
44  "electron MC efficiency tools (one for each kind of electron "
45  "trigger leg)");
46  declareProperty("ElectronScaleFactorTools",
47  m_suppliedElectronScaleFactorTools,
48  "electron scale factor tools (one for each kind of electron "
49  "trigger leg)");
50  declareProperty(
51  "PhotonEfficiencyTools", m_suppliedPhotonEfficiencyTools,
52  "photon MC efficiency tools (one for each kind of photon trigger leg)");
53  declareProperty(
54  "PhotonScaleFactorTools", m_suppliedPhotonScaleFactorTools,
55  "photon scale factor tools (one for each kind of photon trigger leg)");
56  declareProperty("MuonTools", m_suppliedMuonTools,
57  "muon efficiency/scale factor tool (one per year)");
58  declareProperty("ListOfLegsPerTool", m_legsPerTool,
59  "comma-separated list of trigger legs supported by each "
60  "electron or photon tool");
61  declareProperty("TriggerCombination", m_triggerCb,
62  "map of trigger combination per period and/or range of runs");
63  for (int y : {15, 16, 17, 18, 22, 23, 24, 25, 26}) {
64  std::string year = std::to_string(2000 + y);
65  declareProperty("TriggerCombination" + year, m_triggerCbPerYear[year] = "",
66  "trigger combination \"trigger1 || trigger2 || ...\"");
67  }
68  declareProperty("LeptonTagDecorations", m_leptonTagDecorations = "",
69  "comma-separated list of decorations for the lepton "
70  "selection tags, ordered by increasing tightness. "
71  "If a name ends with =, the tag is the decorated value, "
72  "otherwise it is the decoration name");
73  declareProperty(
74  "ListOfTagsPerTool", m_tagsPerTool,
75  "comma-separated list of lepton selection tags associated to each tool");
76  declareProperty("ElectronLegsPerTag", m_electronLegsPerTag,
77  "DEPRECATED, use ListOfLegsPerTag instead");
78  declareProperty("MuonLegsPerTag", m_muonLegsPerTag,
79  "DEPRECATED, use ListOfLegsPerTag instead");
80  declareProperty("ListOfLegsPerTag", m_legsPerTag,
81  "map of allowed trigger legs for each tag");
82  declareProperty(
83  "NumberOfToys", m_numberOfToys = 0,
84  "if different from 0, use toy experiments instead of explicit formulas");
85  declareProperty("OverrideThresholds", m_overrideThresholds,
86  "new thresholds (in MeV) for the plateaux of the indicated "
87  "trigger legs -- use at your own risk!");
88  declareProperty("UseInternalSeed", m_useInternalSeed = false,
89  "do not use event number as random number generation seed");
90  declareProperty("TriggerMatchingTool", m_trigMatchTool,
91  "handle to an IMatchingTool instance");
92 
93  m_cpCode.ignore();
94 }
95 
96 TrigGlobalEfficiencyCorrectionTool::~TrigGlobalEfficiencyCorrectionTool() {
97  m_cpCode.ignore();
98 }
99 
101  if (m_initialized) {
102  ATH_MSG_ERROR("Tool has already been initialized");
103  return StatusCode::FAILURE;
104  }
105  ATH_MSG_INFO("Initializing " << name() << "...");
106 
107  m_dictionary.emplace(0, "");
108 
110  return StatusCode::FAILURE;
111 
112  ATH_MSG_DEBUG("Importing data from configuration files");
113  ImportData data(*this);
114  if (!data.importAll(m_overrideThresholds))
115  return StatusCode::FAILURE;
117  m_hierarchyMeta = data.getHierarchyMeta();
118  m_hierarchyData = data.getHierarchyData();
119  m_thresholds = data.getTriggerThresholds();
120 
121  ATH_MSG_DEBUG("Retrieving tools");
122  if (m_suppliedElectronEfficiencyTools.retrieve() != StatusCode::SUCCESS ||
123  m_suppliedElectronScaleFactorTools.retrieve() != StatusCode::SUCCESS ||
124  m_suppliedMuonTools.retrieve() != StatusCode::SUCCESS ||
125  m_suppliedPhotonEfficiencyTools.retrieve() != StatusCode::SUCCESS ||
126  m_suppliedPhotonScaleFactorTools.retrieve() != StatusCode::SUCCESS) {
127  ATH_MSG_ERROR("Unable to retrieve CP tools");
128  return StatusCode::FAILURE;
129  }
130 
131  ATH_MSG_DEBUG("Retrieving trigger matching tool (if provided)");
132  m_validTrigMatchTool = false;
133  if (m_trigMatchTool.name() != "") {
134  if (m_trigMatchTool.retrieve() != StatusCode::SUCCESS) {
135  ATH_MSG_ERROR("Unable to retrieve trigger matching tool");
136  return StatusCode::FAILURE;
137  }
138  ATH_MSG_DEBUG("Trigger matching support enabled");
139  m_validTrigMatchTool = true;
140  }
141 
142  ATH_MSG_DEBUG("Basic checks");
143  CheckConfig checks(*this);
144  if (!checks.basicConfigChecks())
145  return StatusCode::FAILURE;
146 
147  ATH_MSG_DEBUG("Enumerating tools");
148  flat_set<std::size_t> collectedElectronTags, collectedMuonTags,
149  collectedPhotonTags;
151  m_electronEffToolIndex, collectedElectronTags) ||
153  m_electronSfToolIndex, collectedElectronTags) ||
155  collectedMuonTags) ||
157  m_photonEffToolIndex, collectedPhotonTags) ||
159  m_photonSfToolIndex, collectedPhotonTags)) {
160  return StatusCode::FAILURE;
161  }
162  // List legs (if any) for which a dummy scale factor should be returned.
163  auto itr = m_legsPerTool.find(toolnameForDefaultScaleFactor());
164  if (itr != m_legsPerTool.end()) {
165  bool success = true;
166  for (ToolKey leg : parseListOfLegs(data, itr->second, success)) {
167  m_unsupportedLegs.insert(leg);
168  }
169  }
170 
171  ATH_MSG_DEBUG("Loading user-defined trigger combination");
172  bool useDefaultElectronTools =
173  (m_suppliedElectronEfficiencyTools.size() == 1) &&
174  (m_suppliedElectronScaleFactorTools.size() == 1) &&
175  (m_legsPerTool.size() == 0);
176  bool useDefaultPhotonTools = (m_suppliedPhotonEfficiencyTools.size() == 1) &&
177  (m_suppliedPhotonScaleFactorTools.size() == 1) &&
178  (m_legsPerTool.size() == 0);
179  if (!loadTriggerCombination(data, useDefaultElectronTools,
180  useDefaultPhotonTools))
181  return StatusCode::FAILURE;
182 
183  ATH_MSG_DEBUG("Loading lepton selection tags decorators");
184  if (!loadTagDecorators(collectedElectronTags, collectedMuonTags,
185  collectedPhotonTags))
186  return StatusCode::FAILURE;
187 
188  ATH_MSG_DEBUG("Loading list of legs allowed for each tag");
189  if (!loadListOfLegsPerTag())
190  return StatusCode::FAILURE;
191 
192  ATH_MSG_DEBUG("Advanced checks");
193  if (!checks.advancedConfigChecks())
194  return StatusCode::FAILURE;
195 
196  ATH_MSG_INFO("Initialization successful");
197  m_initialized = true;
198  return StatusCode::SUCCESS;
199 }
200 
202  if (m_electronLegsPerTag.size()) {
204  "The property 'ElectronLegsPerTag' is deprecated, please use "
205  "'ListOfLegsPerTag' instead");
206  for (auto& kv : m_electronLegsPerTag) {
207  auto insert = m_legsPerTag.insert(kv);
208  if (!insert.second)
209  insert.first->second += "," + kv.second;
210  }
211  }
212  if (m_muonLegsPerTag.size()) {
214  "The property 'MuonLegsPerTag' is deprecated, please use "
215  "'ListOfLegsPerTag' instead");
216  for (auto& kv : m_muonLegsPerTag) {
217  auto insert = m_legsPerTag.insert(kv);
218  if (!insert.second)
219  insert.first->second += "," + kv.second;
220  }
221  }
222  return true;
223 }
224 
226  const std::string& tagstring, flat_set<std::size_t>& allTags) {
227  bool success = true;
228  const std::size_t star = m_hasher("*");
229  for (std::size_t tag : listNonOrderedCSValues(tagstring, success)) {
230  allTags.insert((tag != star) ? tag : 0);
231  }
232  if (!success) {
233  ATH_MSG_ERROR("List of tags \"" << tagstring
234  << "\" is not provided in a valid format");
235  }
236  return success;
237 }
238 
239 template <class CPTool>
241  ImportData& data, ToolHandleArray<CPTool>& suppliedTools,
242  std::map<ToolKey, std::size_t>& toolIndex,
243  flat_set<std::size_t>& collectedTags) {
244  bool success = true;
245  for (unsigned index = 0; index < suppliedTools.size(); ++index) {
246  auto& handle = suppliedTools[index];
247  const std::string& name = handle.name();
248  const std::string& altname = handle->name(); // athena: not always the same
249  flat_set<ToolKey> listOfLegs;
251  if (suppliedTools.size() != 1 || m_legsPerTool.size() != 0) {
252  auto itrLegs = m_legsPerTool.find(name);
253  if (itrLegs == m_legsPerTool.end())
254  itrLegs = m_legsPerTool.find(altname);
255  if (itrLegs != m_legsPerTool.end()) {
256  listOfLegs = parseListOfLegs(data, itrLegs->second, success);
257  if (!success) {
259  "The 'ListOfLegsPerTool' property has an invalid entry for the "
260  "tool'"
261  << name << "'");
262  continue;
263  }
264  } else if (std::is_same<CPTool,
266  std::is_same<CPTool,
268  ATH_MSG_ERROR("Property 'ListOfLegsPerTool' empty for tool '" << name
269  << "'");
270  success = false;
271  continue;
272  } else {
273  listOfLegs.emplace();
274  }
275  } else
276  listOfLegs.emplace();
279  auto itrTags = m_tagsPerTool.find(name);
280  if (itrTags == m_tagsPerTool.end())
281  itrTags = m_tagsPerTool.find(altname);
282  if (itrTags != m_tagsPerTool.end()) {
283  success = success && parseTagString(itrTags->second, tags);
284  collectedTags.insert(tags.begin(), tags.end());
285  } else
286  tags.emplace(0);
287 
289  unsigned short nUncheckedLegs = 0;
290  for (auto& key : listOfLegs) {
291  std::size_t leg = key.hash;
292  if (leg) {
293  auto flavour = data.associatedLeptonFlavour(leg, success);
294  if (!(flavour == xAOD::Type::Electron &&
295  std::is_same<CPTool,
297  !(flavour == xAOD::Type::Photon &&
298  std::is_same<CPTool,
300  ATH_MSG_ERROR("Unexpected association of trigger leg '"
301  << m_dictionary[leg] << "' to tool '" << name << "'");
302  success = false;
303  }
304  }
305  for (std::size_t tag : tags) {
306  if (!toolIndex.emplace(ToolKey(leg, tag, key.boundaries), index)
307  .second) {
308  if (leg && tag)
309  ATH_MSG_ERROR("Multiple tools associated to the selection tag '"
310  << m_dictionary[tag] << "' for the trigger leg '"
311  << m_dictionary[leg] << "'");
312  else if (leg)
313  ATH_MSG_ERROR("Multiple tools associated to the trigger leg '"
314  << m_dictionary[leg] << "'");
315  else if (tag)
316  ATH_MSG_ERROR("Multiple tools associated to the selection tag '"
317  << m_dictionary[tag] << "'");
318  else
320  "Multiple tools not associated to any trigger leg / selection "
321  "tag");
322  success = false;
323  }
324  }
325  ++nUncheckedLegs;
326  }
327  if (!nUncheckedLegs) {
328  ATH_MSG_ERROR("Tool " << name
329  << " hasn't been associated to any trigger leg");
330  success = false;
331  }
332  }
333  return success;
334 }
335 
337  ImportData& data, const std::string& inputList, bool& success)
338  -> flat_set<ToolKey> {
339  if (!inputList.length())
340  return {};
341  std::regex rx(
342  "\\s*([[:alnum:]_]+)\\s*(?:\\[\\s*([^,\\[\\]]+)\\s*\\]\\s*)?(?:,|$)");
344  std::smatch sm;
345  auto itr = inputList.cbegin();
346  do {
347  if (sm.ready())
348  itr += sm.length();
349  if (!std::regex_search(itr, inputList.cend(), sm, rx) ||
350  sm.prefix().length()) {
351  ATH_MSG_ERROR("Invalid format for the property \"ListOfLegsPerTool\"");
352  success = false;
353  break;
354  }
355  std::size_t leg = m_hasher(sm[1].str());
356  if (m_thresholds.find(leg) == m_thresholds.end()) {
357  ATH_MSG_ERROR("Unknown trigger leg '"
358  << sm[1].str() << "' found in 'ListOfLegsPerTool'");
359  success = false;
360  continue;
361  }
362  ToolKey key(leg, 0);
363  if (sm.length(2)) {
364  if (!data.getPeriodBoundaries(sm[2].str(), key.boundaries)) {
365  ATH_MSG_ERROR("Invalid period \""
366  << sm[2].str()
367  << "\"found in the property \"ListOfLegsPerTool\"");
368  success = false;
369  continue;
370  }
371  }
372  if (!keys.emplace(key).second) {
373  ATH_MSG_ERROR("Trigger leg '"
374  << sm[1].str()
375  << "' mentioned several times with overlapping time "
376  "periods in the property 'ListOfLegsPerTool'");
377  success = false;
378  continue;
379  }
380  } while (sm.suffix().length());
381  return keys;
382 }
383 
385  ImportData& data, bool useDefaultElectronTools,
386  bool useDefaultPhotonTools) {
387  bool success = true, mustBeEmpty = m_triggerCb.size();
388  for (auto& kv : m_triggerCbPerYear) {
389  if (!kv.second.size())
390  continue;
391  if (mustBeEmpty) {
393  "You're not allowed to use simultaneously the 'TriggerCombination' "
394  "and 'TriggerCombination"
395  << kv.first << "' properties.");
396  return false;
397  }
398  m_triggerCb.insert(kv);
399  }
400 
401  m_calculator = std::make_unique<Calculator>(*this, m_triggerCb.size());
402  std::set<std::size_t> allUniqueElectronLegs, allUniquePhotonLegs;
403  for (auto& kv : m_triggerCb) {
404  std::pair<unsigned, unsigned> boundaries;
405  if (!data.getPeriodBoundaries(kv.first, boundaries)) {
406  success = false;
407  continue;
408  }
409  std::size_t uniqueElectronLeg = !useDefaultElectronTools,
410  uniquePhotonLeg = !useDefaultPhotonTools;
411  if (!m_calculator->addPeriod(data, boundaries, kv.second, m_numberOfToys,
412  uniqueElectronLeg, uniquePhotonLeg)) {
413  success = false;
414  continue;
415  }
416  if (uniqueElectronLeg && useDefaultElectronTools)
417  allUniqueElectronLegs.insert(uniqueElectronLeg);
418  if (uniquePhotonLeg && useDefaultPhotonTools)
419  allUniquePhotonLegs.insert(uniquePhotonLeg);
420  }
421  if (!success)
422  return false;
423 
424  auto remapTools = [](auto& toolIndex, auto& allUniqueLegs) {
425  typename std::remove_reference<decltype(toolIndex)>::type remappedToolIndex;
426  for (std::size_t leg : allUniqueLegs) {
427  if (!leg)
428  continue;
429  for (auto& kv : toolIndex) {
432  const ToolKey& key = kv.first;
433  remappedToolIndex.emplace(ToolKey(leg, key.hash, key.boundaries),
434  kv.second);
435  }
436  }
437  toolIndex.swap(remappedToolIndex);
438  };
439 
440  if (useDefaultElectronTools && allUniqueElectronLegs.size()) {
441  remapTools(m_electronSfToolIndex, allUniqueElectronLegs);
442  remapTools(m_electronEffToolIndex, allUniqueElectronLegs);
443  }
444  if (useDefaultPhotonTools && allUniquePhotonLegs.size()) {
445  remapTools(m_photonSfToolIndex, allUniquePhotonLegs);
446  remapTools(m_photonEffToolIndex, allUniquePhotonLegs);
447  }
448  return success;
449 }
450 
452  const flat_set<std::size_t>& collectedElectronTags,
453  const flat_set<std::size_t>& collectedMuonTags,
454  const flat_set<std::size_t>& collectedPhotonTags) {
455  bool success = true;
456 
457  flat_set<std::size_t> collectedTags(collectedElectronTags);
458  collectedTags.insert(collectedMuonTags.begin(), collectedMuonTags.end());
459  collectedTags.insert(collectedPhotonTags.begin(), collectedPhotonTags.end());
460  flat_set<std::size_t> allTags = collectedTags;
461 
465  std::stringstream ss(
467  std::string decoration;
468  flat_set<std::size_t> allDecorations;
469  while (std::getline(ss, decoration, ',')) {
470  if (!decoration.length() || decoration == "?") {
472  "Found an empty string in the 'LeptonTagDecorations' property");
473  success = false;
474  break;
475  }
476 
477  bool found = false, suffixed = false;
478  std::size_t h;
479  if (decoration.back() != '?') {
481  h = m_hasher(decoration);
482  found = (allTags.find(h) != allTags.end());
483  } else {
485  decoration.pop_back();
486  suffixed = true;
487  for (std::size_t tag :
488  allTags)
489  {
490  auto& s = m_dictionary[tag];
491  if (s.find(decoration) != 0)
492  continue;
493  if (std::all_of(s.begin() + decoration.length(), s.end(),
494  [](char c) { return std::isdigit(c); })) {
495  found = true;
496  break;
497  }
498  }
499  h = m_hasher(decoration);
500  }
501  if (!allDecorations.insert(h).second) {
503  "The selection tag '"
504  << decoration
505  << "' is listed twice in the property 'LeptonTagDecorations'");
506  success = false;
507  continue;
508  }
509  if (!found) {
511  "the selection tag '"
512  << decoration
513  << "' is only referred to in the property 'LeptonTagDecorations'");
514  success = false;
515  continue;
516  }
517  m_leptonTagDecorators.emplace_back(decoration, h, suffixed);
518  m_dictionary.emplace(h, decoration);
519  }
521  if (!success)
522  return false;
523 
526  for (std::size_t tag : collectedTags) {
527  if (!tag)
528  continue;
529  auto itr =
530  std::find_if(m_leptonTagDecorators.begin(), m_leptonTagDecorators.end(),
531  [tag](const TagDecorator& ltd) {
532  return (!ltd.suffixed) && (ltd.hash == tag);
533  });
534  if (itr != m_leptonTagDecorators.end())
535  continue;
536  bool found = false;
537  auto& s = m_dictionary[tag];
538  for (auto& ltd : m_leptonTagDecorators) {
539  auto& name = m_dictionary[ltd.hash];
540  if (s.find(name) != 0)
541  continue;
542  if (std::all_of(s.begin() + name.length(), s.end(),
543  [](char c) { return std::isdigit(c); })) {
544  found = true;
545  break;
546  }
547  }
548  if (!found) {
549  ATH_MSG_ERROR("the selection tag '"
550  << m_dictionary[tag]
551  << "' hasn't been found in in 'LeptonTagDecorations'");
552  success = false;
553  continue;
554  }
555  }
556  if (!success)
557  return false;
558 
559  return success;
560 }
561 
563  bool success = true;
564 
567  for (auto& kv : m_legsPerTag) {
568  std::size_t tag;
569  if (!kv.first.size() || kv.first == "*")
570  tag = 0;
571  else
572  tag = m_hasher(kv.first);
573  auto listOfLegs = listNonOrderedCSValues(kv.second, success);
574  if (!success) {
576  "The property 'ListOfLegsPerTag' has an invalid entry for the tag '"
577  << kv.first << "'");
578  break;
579  }
580  for (std::size_t leg : listOfLegs) {
581  auto type =
583  if (type == xAOD::Type::Electron &&
584  m_electronSfToolIndex.find(ToolKey(leg, tag)) ==
585  m_electronSfToolIndex.end()) {
586  ATH_MSG_ERROR("No electron tool has been provided for trigger leg '"
587  << m_dictionary[leg] << "' and selection tag " << kv.first
588  << " mentioned in the property 'ListOfLegsPerTag'");
589  success = false;
590  } else if (type == xAOD::Type::Muon &&
591  m_muonToolIndex.find(ToolKey(0, tag)) ==
592  m_muonToolIndex.end()) {
593  ATH_MSG_ERROR("No muon tool has been provided for selection tag "
594  << kv.first
595  << " mentioned in the property 'ListOfLegsPerTag'");
596  success = false;
597  } else if (type == xAOD::Type::Photon &&
598  m_photonSfToolIndex.find(ToolKey(leg, tag)) ==
599  m_photonSfToolIndex.end()) {
600  ATH_MSG_ERROR("No photon tool has been provided for trigger leg '"
601  << m_dictionary[leg] << "' and selection tag " << kv.first
602  << " mentioned in the property 'ListOfLegsPerTag'");
603  success = false;
604  }
605  if (m_validLegTagPairs.insert(leg ^ tag).second) {
606  if (type == xAOD::Type::Electron)
607  m_checkElectronLegTag = true;
608  if (type == xAOD::Type::Muon)
609  m_checkMuonLegTag = true;
610  if (type == xAOD::Type::Photon)
611  m_checkPhotonLegTag = true;
612  } else {
613  ATH_MSG_ERROR("The combination of trigger leg '"
614  << m_dictionary[leg] << "' and selection tag " << kv.first
615  << " is mentioned more than once in the property "
616  "'ListOfLegsPerTag'");
617  success = false;
618  }
619  }
620  }
621  if (!success)
622  return false;
623 
624  return success;
625 }
626 
629  cc.setChecked();
630  if (cc > m_cpCode)
631  m_cpCode = cc;
632  return cc == CP::CorrectionCode::Ok;
633 }
634 
639  const std::string& s, bool& success) -> flat_set<std::size_t> {
640  std::stringstream ss(TrigGlobEffCorr::removeWhitespaces(s));
642  std::string token;
643  while (std::getline(ss, token, ',')) {
644  if (token.length()) {
645  std::size_t h = m_hasher(token);
646  if (hashes.insert(h).second) {
647  m_dictionary.emplace(h, std::move(token));
648  } else {
649  success = false;
651  "Found duplicate entry while parsing comma-separated list '"
652  << s << "'");
653  }
654  } else {
655  success = false;
657  "Found null-length entry while parsing comma-separated list '"
658  << s << "'");
659  }
660  }
661  if (!success)
662  hashes.clear();
663  return hashes;
664 }
665 
666 template <class ParticleType>
668  const ParticleType* p, unsigned runNumber, std::size_t leg, std::size_t tag,
669  Efficiencies& efficiencies) -> TLE_RESULT {
671  auto ptype = []() {
674  : "<unknown type>";
675  };
676  auto pp = static_cast<const xAOD::IParticle*>(p);
677  ATH_MSG_DEBUG("Retrieving efficiencies for "
678  << ptype() << ' ' << p << " (pt=" << pp->pt()
679  << ", eta=" << pp->eta() << ", tag='" << m_dictionary[tag]
680  << "') for trigger leg " << m_dictionary[leg]);
681  auto itrSf = GetScaleFactorToolIndex(p).find(ToolKey(leg, tag, runNumber));
682  auto itrEff = GetEfficiencyToolIndex(p).find(ToolKey(leg, tag, runNumber));
683  if (itrSf == GetScaleFactorToolIndex(p).end() ||
684  itrEff == GetEfficiencyToolIndex(p).end()) {
685  if (m_unsupportedLegs.count(ToolKey(leg, 0u, runNumber))) {
686  efficiencies.data() = 0.5;
687  efficiencies.mc() = 0.5;
688  return TLE_UNAVAILABLE;
689  }
690  if (!tag)
691  ATH_MSG_ERROR("Unable to find "
692  << ptype() << " tools needed for trigger leg "
693  << m_dictionary[leg] << " (run number = " << runNumber
694  << ")");
695  else
696  ATH_MSG_ERROR("Unable to find "
697  << ptype() << " tools needed for trigger leg "
698  << m_dictionary[leg] << " and selection tag "
699  << m_dictionary[tag] << " (run number = " << runNumber
700  << ")");
701  return TLE_ERROR;
702  }
703  double sf;
704  bool success =
705  checkAndRecord(GetScaleFactorTool(p, itrSf->second)
706  .getEfficiencyScaleFactor(*p, sf)) &&
707  checkAndRecord(GetEfficiencyTool(p, itrEff->second)
708  .getEfficiencyScaleFactor(*p, efficiencies.mc()));
709  efficiencies.data() = sf * efficiencies.mc();
710  ATH_MSG_DEBUG("found for that " << ptype()
711  << " eff(data) = " << efficiencies.data()
712  << " and eff(MC) = " << efficiencies.mc());
713  return success ? TLE_OK : TLE_ERROR;
714 }
715 
717  const xAOD::Electron* p, unsigned runNumber, std::size_t leg,
718  std::size_t tag, Efficiencies& efficiencies) -> TLE_RESULT {
719  return getEgammaTriggerLegEfficiencies(p, runNumber, leg, tag, efficiencies);
720 }
721 
723  const xAOD::Photon* p, unsigned runNumber, std::size_t leg, std::size_t tag,
724  Efficiencies& efficiencies) -> TLE_RESULT {
725  return getEgammaTriggerLegEfficiencies(p, runNumber, leg, tag, efficiencies);
726 }
727 
729  const xAOD::Muon* p, unsigned runNumber, std::size_t leg, std::size_t tag,
730  Efficiencies& efficiencies) -> TLE_RESULT {
731  ATH_MSG_DEBUG("Retrieving efficiencies for muon "
732  << p << " (pt=" << p->pt() << ", eta=" << p->eta() << ", tag='"
733  << m_dictionary[tag] << "') for trigger leg "
734  << m_dictionary[leg]);
735  if (m_unsupportedLegs.size() &&
736  m_unsupportedLegs.count(ToolKey(leg, 0u, runNumber))) {
737  efficiencies.data() = 0.5;
738  efficiencies.mc() = 0.5;
739  return TLE_UNAVAILABLE;
740  }
741  auto itr = m_muonToolIndex.find(ToolKey(0, tag, 0));
742  if (itr == m_muonToolIndex.end()) {
743  if (!tag)
744  ATH_MSG_ERROR("Unable to find muon tool");
745  else
746  ATH_MSG_ERROR("Unable to find muon tool needed for selection tag "
747  << m_dictionary[tag]);
748  m_cpCode = CP::CorrectionCode::Error;
749  return TLE_ERROR;
750  }
751  auto& tool = *m_suppliedMuonTools[itr->second];
752  auto& hltTrig = m_dictionary[leg ^ 0xB0DDD56fF8E3250D];
753  if (!hltTrig.size()) {
754  hltTrig = "HLT_" + m_dictionary[leg];
755  while (true) {
756  std::size_t i = hltTrig.find("_OR_m");
757  if (i == std::string::npos)
758  break;
759  hltTrig.insert(i + 4, "HLT_", 4);
760  }
761  }
762  bool success = checkAndRecord(tool.getTriggerEfficiency(*p, efficiencies.mc(),
763  hltTrig, kFALSE)) &&
764  checkAndRecord(tool.getTriggerEfficiency(
765  *p, efficiencies.data(), hltTrig, kTRUE));
766  ATH_MSG_DEBUG("found for that muon eff(data) = " << efficiencies.data()
767  << " and eff(MC) = "
768  << efficiencies.mc());
769  return success ? TLE_OK : TLE_ERROR;
770 }
771 
773  unsigned& runNumber) {
774  runNumber = 0;
775  auto eventInfo = evtStore()->retrieve<const xAOD::EventInfo>("EventInfo");
776  if (!eventInfo) {
777  ATH_MSG_ERROR("Can't retrieve 'EventInfo' from evtStore()");
778  return false;
779  }
780  if (eventInfo->eventType(xAOD::EventInfo::IS_SIMULATION)) {
781  if (!m_runNumberDecorator.isAvailable(*eventInfo)) {
782  ATH_MSG_ERROR("Can't retrieve 'RandomRunNumber' from EventInfo");
783  return false;
784  }
785  runNumber = m_runNumberDecorator(*eventInfo);
786  } else
787  runNumber = eventInfo->runNumber();
788  return true;
789 }
790 
792  unsigned long& eventNumber) {
793  auto eventInfo = evtStore()->retrieve<const xAOD::EventInfo>("EventInfo");
794  if (!eventInfo) {
795  ATH_MSG_WARNING("Can't retrieve event number from evtStore()");
796  eventNumber = 0;
797  return false;
798  }
799  eventNumber = eventInfo->eventNumber();
800  return true;
801 }
802 
803 template <class Particle>
805  LeptonList& leptons, const std::vector<const Particle*>& particles) {
806  for (auto lep : particles) {
807  std::size_t tag = 0;
808  for (auto& ltd : m_leptonTagDecorators) {
809  if (ltd.decorator.isAvailable(*lep)) {
810  char v = ltd.decorator(*lep);
811  if (v) {
812  if (ltd.suffixed)
813  {
814  std::string s = m_dictionary.at(ltd.hash) + std::to_string(v);
815  tag = m_hasher(s);
816  m_dictionary.emplace(tag, s);
817  } else
818  tag = ltd.hash;
819  }
820  }
821  }
822  leptons.emplace_back(lep, tag);
823  }
824  return true;
825 }
826 
828  const std::vector<const xAOD::IParticle*>& leptons,
829  double& efficiencyScaleFactor) {
830  unsigned runNumber;
833  return getEfficiencyScaleFactor(runNumber, leptons, efficiencyScaleFactor);
834 }
835 
837  const std::vector<const xAOD::IParticle*>& leptons, double& efficiencyData,
838  double& efficiencyMc) {
839  unsigned runNumber;
842  return getEfficiency(runNumber, leptons, efficiencyData, efficiencyMc);
843 }
844 
846  unsigned runNumber, const std::vector<const xAOD::IParticle*>& particles,
847  double& efficiencyScaleFactor) {
849  efficiencyScaleFactor = 1.;
851 
854  efficiencies.mc());
855  if (cc == CP::CorrectionCode::Ok) {
856  if (efficiencies.data() > 0. && efficiencies.mc() > 0.) {
857  efficiencyScaleFactor = efficiencies.data() / efficiencies.mc();
858  return CP::CorrectionCode::Ok;
859  } else {
860  efficiencyScaleFactor = 1.;
862  "Efficiencies do not seem valid, forcing the scale factor to 1.");
864  }
865  }
866  efficiencyScaleFactor = 1.;
867  return cc;
868 }
869 
871  unsigned runNumber, const std::vector<const xAOD::IParticle*>& particles,
872  double& efficiencyData, double& efficiencyMc) {
874  efficiencyData = 0.;
876  efficiencyMc = 0.;
877 
878  ATH_MSG_DEBUG("Computing global trigger efficiency for this event with "
879  << particles.size()
880  << " lepton(s) as input; run number = " << runNumber);
881 
882 #ifdef XAOD_STANDALONE
883  if (!m_initialized) {
884  ATH_MSG_WARNING("Tool hasn't been initialized, trying now");
885  if (initialize() != StatusCode::SUCCESS) {
886  ATH_MSG_ERROR("Giving up.");
887  m_cpCode.ignore();
889  }
890  }
891 #endif
892 
893  LeptonList leptons;
894  updateLeptonList(leptons, particles);
895 
897  if (m_calculator->compute(*this, leptons, runNumber, efficiencies)) {
898  efficiencyData = efficiencies.data();
899  efficiencyMc = efficiencies.mc();
900  if (std::isnan(efficiencies.data()) || efficiencies.data() <= 0. ||
901  std::isnan(efficiencies.mc()) || efficiencies.mc() <= 0.) {
902  ATH_MSG_WARNING("Efficiencies do not seem valid");
903  m_cpCode.ignore();
905  }
906  } else {
909  }
910  }
911  return m_cpCode;
912 }
913 
915  bool& matched, const std::vector<const xAOD::IParticle*>& particles) {
916  unsigned runNumber;
919  "Unable to retrieve run number, aborting checkTriggerMatching()");
921  }
922  if (!m_validTrigMatchTool) {
924  "A valid IMatchingTool instance should be provided via the property "
925  "'TriggerMatchingTool'");
927  }
928  LeptonList leptons;
929  updateLeptonList(leptons, particles);
930  return m_calculator->checkTriggerMatching(*this, matched, leptons, runNumber)
933 }
934 
936  std::vector<std::string>& triggers) {
937  unsigned runNumber;
940  "Unable to retrieve run number, aborting getRelevantTriggers()");
942  }
943  return m_calculator->getRelevantTriggersForUser(*this, triggers, runNumber)
946 }
947 
949  const std::string& trigger, std::size_t& numberOfLegs) {
950  numberOfLegs = 0;
955  constexpr std::size_t magic = 0xa3bad03e613527c9;
956  const std::size_t name = m_hasher(trigger), key = name ^ magic;
957  std::string& value = m_dictionary[key];
958  if (!value.length()) {
960  if (!data.importTriggers())
962  auto itr = data.getTriggerDefs().find(name);
963  if (itr == data.getTriggerDefs().end()) {
964  m_dictionary.erase(key);
965  ATH_MSG_ERROR("The trigger " << trigger << " is not recognized");
967  }
968  auto type = itr->second.type;
971  value = "~";
973  value = "~~";
975  value = "~~~";
976  else {
977  m_dictionary.erase(key);
978  ATH_MSG_ERROR("Unrecognized trigger type, implementation must be fixed!");
980  }
981  }
982  numberOfLegs = value.length();
983  return CP::CorrectionCode::Ok;
984 }
985 
987  std::size_t leg) const {
988  bool decision = (lepton.pt() >= m_thresholds.at(leg));
989  if (m_validLegTagPairs.size()) {
990  if ((lepton.type() == xAOD::Type::Electron && m_checkElectronLegTag) ||
991  (lepton.type() == xAOD::Type::Muon && m_checkMuonLegTag) ||
992  (lepton.type() == xAOD::Type::Photon && m_checkPhotonLegTag)) {
993  decision = decision && (m_validLegTagPairs.find(leg ^ lepton.tag()) !=
994  m_validLegTagPairs.end());
995  }
996  }
997  ATH_MSG_DEBUG("Lepton " << lepton.particle() << " (pt=" << lepton.pt()
998  << ") is " << (decision ? "" : "not ")
999  << "considered suitable for firing trigger leg "
1000  << m_dictionary.at(leg));
1001  return decision;
1002 }
1003 
1005  const flat_set<std::size_t>& legs) {
1006  if (legs.size() < 2)
1007  return 0;
1008  std::size_t combinedHash = 0;
1009  for (auto& leg : legs)
1010  combinedHash ^= leg;
1011  return combinedHash;
1012 }
1013 
1015  std::size_t leg1, std::size_t leg2) {
1016  return leg1 ^
1017  leg2;
1018 }
1019 
1021  const flat_set<std::size_t>& legs) -> const flat_set<std::size_t>& {
1022  return legs;
1023 }
1024 
1025 inline constexpr std::array<std::size_t, 2>
1027  std::size_t leg2) {
1028  if (leg1 < leg2)
1029  return {leg1, leg2};
1030  else
1031  return {leg2, leg1};
1032 }
1033 
1034 template <class... ListOfLegs>
1036  const Lepton& lepton, ListOfLegs... legs) {
1037  auto combinedHash = getCombinedHash(legs...);
1038  if (!combinedHash)
1039  return 0xFEDCBA9876543210; // only one (distinct) leg
1040  auto cachedRankings = m_cachedLegRankings.equal_range(combinedHash);
1041  auto rankingItr = cachedRankings.first;
1042  float pt = lepton.pt();
1043  while (rankingItr != cachedRankings.second &&
1044  (pt < rankingItr->second.minPt || pt >= rankingItr->second.maxPt))
1045  ++rankingItr;
1046  if (rankingItr == cachedRankings.second) {
1047  CachedRanking r = rankTriggerLegs(pt, forwardLegs(legs...));
1048  if (r)
1049  m_cachedLegRankings.emplace(combinedHash, r);
1050  return r.ranking;
1051  }
1052  return rankingItr->second.ranking;
1053 }
1054 
1055 template <class Container>
1057  const Container& legs)
1058  -> CachedRanking {
1059  const std::size_t nLegs = legs.size();
1060  CachedRanking r;
1061  r.ranking = std::numeric_limits<decltype(r.ranking)>::max();
1062  r.minPt = 0.f;
1064  if (nLegs >= 2 * sizeof(r.ranking)) {
1065  ATH_MSG_ERROR(
1066  "Implementation currently doesn't support ranking of more than "
1067  << 2 * sizeof(r.ranking) << " trigger legs");
1068  return r;
1069  }
1070  std::vector<uint8_t> counts(nLegs);
1071 
1075  auto legI = legs.begin();
1076  for (unsigned i = 0; i < nLegs; ++i) {
1077  auto legJ = legI;
1078  for (unsigned j = i + 1; j < nLegs; ++j) {
1079  ++legJ;
1080  bool found = false;
1081  for (auto& meta : m_hierarchyMeta) {
1082  if (pt < meta.minPt || pt >= meta.maxPt)
1083  continue;
1084  auto data = m_hierarchyData.begin() + meta.offset;
1085  auto end = data + meta.nLegs;
1086  auto a = std::find(data, end, *legI);
1087  if (a == end)
1088  continue;
1089  auto b = std::find(data, end, *legJ);
1090  if (b == end)
1091  continue;
1092  r.minPt = std::max(r.minPt, meta.minPt);
1093  r.maxPt = std::min(r.maxPt, meta.maxPt);
1094  ++(counts[(a > b) ? i : j]);
1095  found = true;
1096  break;
1097  }
1098  if (!found) {
1101  ATH_MSG_ERROR("Unable to rank trigger legs "
1102  << m_dictionary[*legI] << " and " << m_dictionary[*legJ]);
1103  return r;
1104  }
1105  }
1106  ++legI;
1107  }
1108  decltype(r.ranking) ranking = 0;
1109  for (unsigned i = 0; i < nLegs; ++i) {
1110  unsigned char index =
1111  std::find(counts.begin(), counts.end(), i) - counts.begin();
1112  if (index >= nLegs) {
1113  ATH_MSG_ERROR("Inconsistency found while trying to rank "
1114  << nLegs << " trigger legs");
1115  return r;
1116  }
1117  ranking = (ranking << 4 | index);
1118  }
1119  r.ranking = ranking;
1120  return r;
1121 }
1122 
1124  const Lepton& lepton, std::size_t leg1, std::size_t leg2, bool& success) {
1125  auto ranking = getCachedTriggerLegsRanking(lepton, leg1, leg2);
1126  if (CachedRanking::invalid(ranking)) {
1127  success = false;
1128  return -1;
1129  }
1130  return forwardLegs(leg1, leg2)[ranking & 0xF];
1131 }
1132 
1133 std::pair<std::size_t, std::size_t>
1135  const Lepton& lepton, const flat_set<std::size_t>& legs, bool& success) {
1136  auto ranking = getCachedTriggerLegsRanking(lepton, legs);
1137  if (CachedRanking::invalid(ranking)) {
1138  success = false;
1139  return {0, 0};
1140  }
1141  std::pair<std::size_t, std::size_t> looseLegs{0, 0};
1142  looseLegs.first = *legs.nth(ranking & 0xF);
1143  if (legs.size() >= 2)
1144  looseLegs.second = *legs.nth((ranking >> 4) & 0xF);
1145  return looseLegs;
1146 }
1147 
1149  const Lepton& lepton, const flat_set<std::size_t>& legs, bool& success) {
1150  flat_set<std::size_t> validLegs;
1151  for (auto leg : legs)
1152  if (aboveThreshold(lepton, leg))
1153  validLegs.insert(leg);
1154  if (validLegs.size() == 0)
1155  return 0;
1156  if (validLegs.size() == 1)
1157  return *validLegs.begin();
1158  auto ranking = getCachedTriggerLegsRanking(lepton, legs);
1159  if (CachedRanking::invalid(ranking)) {
1160  success = false;
1161  return 0;
1162  }
1163  return *legs.nth(ranking & 0xF);
1164 }
1165 
1166 std::vector<std::size_t> TrigGlobalEfficiencyCorrectionTool::getSortedLegs(
1167  const Lepton& lepton, const flat_set<std::size_t>& legs, bool& success) {
1168  const int nLegs = legs.size();
1169  unsigned long ranking = getCachedTriggerLegsRanking(lepton, legs);
1170  if (CachedRanking::invalid(ranking)) {
1171  success = false;
1172  ranking = 0xFEDCBA9876543210;
1173  }
1174  std::vector<std::size_t> sorted_legs(nLegs);
1175  for (int i = 0; i < nLegs; ++i) {
1176  sorted_legs[i] = *legs.nth(ranking & 0xF);
1177  ranking >>= 4;
1178  }
1179  return sorted_legs;
1180 }
1181 
1183  const std::map<std::string, std::string>& triggerCombination,
1184  const std::string& version, std::map<std::string, std::string>& legsPerKey,
1186  ImportData data;
1187  bool success =
1188  data.suggestEgammaMapKeys(triggerCombination, version, legsPerKey, type);
1190 }
1191 
1193  const CP::SystematicVariation& systematic) const {
1194  auto sys = affectingSystematics();
1195  return !systematic.empty() && sys.find(systematic) != sys.end();
1196 }
1197 
1199  const {
1200  return CP::SystematicSet();
1201 }
1202 
1204  const {
1205  return {};
1206 }
1207 
1209  const CP::SystematicSet& systematic) {
1210  for (auto&& t : m_suppliedElectronEfficiencyTools)
1211  ANA_CHECK(t->applySystematicVariation(systematic));
1212  for (auto&& t : m_suppliedElectronScaleFactorTools)
1213  ANA_CHECK(t->applySystematicVariation(systematic));
1214  for (auto&& t : m_suppliedPhotonEfficiencyTools)
1215  ANA_CHECK(t->applySystematicVariation(systematic));
1216  for (auto&& t : m_suppliedPhotonScaleFactorTools)
1217  ANA_CHECK(t->applySystematicVariation(systematic));
1218  for (auto&& t : m_suppliedMuonTools)
1219  ANA_CHECK(t->applySystematicVariation(systematic));
1220 
1221  return StatusCode::SUCCESS;
1222 }
python.root_lsr_rank.hashes
hashes
Definition: root_lsr_rank.py:34
TrigGlobalEfficiencyCorrectionTool::getLoosestLegAboveThreshold
std::size_t getLoosestLegAboveThreshold(const TrigGlobEffCorr::Lepton &lepton, const flat_set< std::size_t > &legs, bool &success)
TrigGlobalEfficiencyCorrectionTool::checkTriggerMatching
virtual CP::CorrectionCode checkTriggerMatching(bool &matched, const std::vector< const xAOD::IParticle * > &particles) override
sTgcDigitEffiDump.efficiencies
list efficiencies
translate the station name indices into the string staiton name
Definition: sTgcDigitEffiDump.py:23
beamspotman.r
def r
Definition: beamspotman.py:674
TrigGlobalEfficiencyCorrectionTool::recommendedSystematics
virtual CP::SystematicSet recommendedSystematics() const override
the list of all systematics this tool recommends to use
TrigGlobalEfficiencyCorrectionTool::getSortedLegs
std::vector< std::size_t > getSortedLegs(const TrigGlobEffCorr::Lepton &lepton, const flat_set< std::size_t > &legs, bool &success)
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
TrigGlobalEfficiencyCorrectionTool::checkAndRecord
bool checkAndRecord(CP::CorrectionCode &&cc)
Internal methods (III) – misc. helpers.
TrigGlobalEfficiencyCorrectionTool::getCombinedHash
std::size_t getCombinedHash(const flat_set< std::size_t > &legs)
CheckConfig.h
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
TrigGlobalEfficiencyCorrectionTool::listNonOrderedCSValues
flat_set< std::size_t > listNonOrderedCSValues(const std::string &s, bool &success)
Calculator.h
TrigGlobalEfficiencyCorrectionTool::LeptonList
std::vector< TrigGlobEffCorr::Lepton > LeptonList
Definition: TrigGlobalEfficiencyCorrectionTool.h:140
TrigGlobalEfficiencyCorrectionTool::m_checkPhotonLegTag
bool m_checkPhotonLegTag
Definition: TrigGlobalEfficiencyCorrectionTool.h:176
TrigGlobalEfficiencyCorrectionTool::enumerateTools
bool enumerateTools(TrigGlobEffCorr::ImportData &data, ToolHandleArray< CPTool > &suppliedTools, std::map< ToolKey, std::size_t > &toolIndex, flat_set< std::size_t > &collectedTags)
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
TrigGlobalEfficiencyCorrectionTool::m_leptonTagDecorators
std::vector< TagDecorator > m_leptonTagDecorators
Definition: TrigGlobalEfficiencyCorrectionTool.h:188
CP::CorrectionCode::ignore
void ignore() const noexcept
Ignore the correction code.
Definition: CorrectionCode.h:57
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
TrigGlobalEfficiencyCorrectionTool::m_legsPerTool
std::map< std::string, std::string > m_legsPerTool
Definition: TrigGlobalEfficiencyCorrectionTool.h:152
TrigGlobalEfficiencyCorrectionTool::m_suppliedPhotonEfficiencyTools
ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > m_suppliedPhotonEfficiencyTools
Definition: TrigGlobalEfficiencyCorrectionTool.h:148
ObjectType
ObjectType
Definition: BaseObject.h:11
TrigGlobalEfficiencyCorrectionTool::m_photonEffToolIndex
std::map< ToolKey, std::size_t > m_photonEffToolIndex
Definition: TrigGlobalEfficiencyCorrectionTool.h:171
TrigGlobalEfficiencyCorrectionTool::m_muonLegsPerTag
std::map< std::string, std::string > m_muonLegsPerTag
deprecated
Definition: TrigGlobalEfficiencyCorrectionTool.h:158
TrigGlobEffCorr::CheckConfig::basicConfigChecks
bool basicConfigChecks()
Definition: CheckConfig.cxx:39
index
Definition: index.py:1
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
TrigGlobalEfficiencyCorrectionTool::m_hierarchyData
std::vector< std::size_t > m_hierarchyData
Definition: TrigGlobalEfficiencyCorrectionTool.h:181
TrigGlobalEfficiencyCorrectionTool::m_cachedLegRankings
std::multimap< std::size_t, CachedRanking > m_cachedLegRankings
Definition: TrigGlobalEfficiencyCorrectionTool.h:167
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
TrigGlobalEfficiencyCorrectionTool::m_runNumberDecorator
SG::AuxElement::ConstAccessor< unsigned int > m_runNumberDecorator
Definition: TrigGlobalEfficiencyCorrectionTool.h:189
IAsgPhotonEfficiencyCorrectionTool
Definition: IAsgPhotonEfficiencyCorrectionTool.h:23
TrigGlobEffCorr::Lepton::pt
float pt() const
Definition: Lepton.h:28
TrigGlobalEfficiencyCorrectionTool::suggestEgammaMapKeys
static CP::CorrectionCode suggestEgammaMapKeys(const std::map< std::string, std::string > &triggerCombination, const std::string &version, std::map< std::string, std::string > &legsPerKey, xAOD::Type::ObjectType type)
python.SystemOfUnits.second
float second
Definition: SystemOfUnits.py:135
asg
Definition: DataHandleTestTool.h:28
test_pyathena.pt
pt
Definition: test_pyathena.py:11
ImportData
TrigGlobEffCorr::ImportData ImportData
Definition: TrigGlobalEfficiencyCorrectionTool.cxx:29
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
Efficiencies
TrigGlobEffCorr::Efficiencies Efficiencies
Definition: TrigGlobalEfficiencyCorrectionTool.cxx:30
TrigGlobEffCorr::TT_SINGLELEPTON_FLAG
@ TT_SINGLELEPTON_FLAG
Definition: ImportData.h:35
TrigGlobalEfficiencyCorrectionTool::m_muonToolIndex
std::map< ToolKey, std::size_t > m_muonToolIndex
Definition: TrigGlobalEfficiencyCorrectionTool.h:172
TrigGlobalEfficiencyCorrectionTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: TrigGlobalEfficiencyCorrectionTool.cxx:100
TrigGlobEffCorr::Lepton::particle
const xAOD::IParticle * particle() const
Definition: Lepton.h:40
TrigGlobalEfficiencyCorrectionTool::m_suppliedElectronScaleFactorTools
ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > m_suppliedElectronScaleFactorTools
Definition: TrigGlobalEfficiencyCorrectionTool.h:146
athena.value
value
Definition: athena.py:124
Calculator
TrigGlobEffCorr::Calculator Calculator
Definition: TrigGlobalEfficiencyCorrectionTool.cxx:28
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
TrigGlobEffCorr::Efficiencies
Definition: Efficiencies.h:14
Lepton.h
TrigGlobalEfficiencyCorrectionTool::m_calculator
std::unique_ptr< TrigGlobEffCorr::Calculator > m_calculator
Definition: TrigGlobalEfficiencyCorrectionTool.h:190
TrigGlobalEfficiencyCorrectionTool::getTwoLoosestLegs
std::pair< std::size_t, std::size_t > getTwoLoosestLegs(const TrigGlobEffCorr::Lepton &lepton, const flat_set< std::size_t > &legs, bool &success)
TrigGlobalEfficiencyCorrectionTool.h
Efficiencies.h
TrigGlobalEfficiencyCorrectionTool::m_legsPerTag
std::map< std::string, std::string > m_legsPerTag
deprecated
Definition: TrigGlobalEfficiencyCorrectionTool.h:159
TrigGlobalEfficiencyCorrectionTool::CachedRanking::invalid
static bool invalid(unsigned long ranking)
Definition: TrigGlobalEfficiencyCorrectionTool.h:113
TrigGlobalEfficiencyCorrectionTool::ToolKey
Definition: TrigGlobalEfficiencyCorrectionTool.h:115
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
python.TrigTLAMonitorAlgorithm.triggers
triggers
Definition: TrigTLAMonitorAlgorithm.py:196
CP::SystematicVariation
Definition: SystematicVariation.h:47
python.AtlRunQueryAMI.year
year
Definition: AtlRunQueryAMI.py:225
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
TrigGlobalEfficiencyCorrectionTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const CP::SystematicSet &systConfig) override
effects: configure this tool for the given list of systematic variations.
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
TrigGlobalEfficiencyCorrectionTool::m_leptonTagDecorations
std::string m_leptonTagDecorations
Definition: TrigGlobalEfficiencyCorrectionTool.h:155
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
flat_set
boost::container::flat_set< Key > flat_set
Definition: CheckConfig.cxx:14
TrigGlobalEfficiencyCorrectionTool::parseTagString
bool parseTagString(const std::string &tagstring, flat_set< std::size_t > &tags)
Definition: TrigGlobalEfficiencyCorrectionTool.cxx:225
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:92
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
TrigGlobalEfficiencyCorrectionTool::getLoosestLeg
std::size_t getLoosestLeg(const TrigGlobEffCorr::Lepton &lepton, std::size_t leg1, std::size_t leg2, bool &success)
Container
storage of the time histories of all the cells
ImportData.h
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
TrigGlobalEfficiencyCorrectionTool::getEfficiencyScaleFactor
virtual CP::CorrectionCode getEfficiencyScaleFactor(const std::vector< const xAOD::IParticle * > &particles, double &efficiencyScaleFactor) override
TrigGlobalEfficiencyCorrectionTool::affectingSystematics
virtual CP::SystematicSet affectingSystematics() const override
the list of all systematics this tool can be affected by
TrigGlobalEfficiencyCorrectionTool::m_triggerCb
std::map< std::string, std::string > m_triggerCb
Definition: TrigGlobalEfficiencyCorrectionTool.h:153
TrigGlobalEfficiencyCorrectionTool::updateLeptonList
bool updateLeptonList(LeptonList &leptons, const std::vector< const Particle * > &particles)
TrigGlobEffCorr::Lepton::tag
std::size_t tag() const
Definition: Lepton.h:30
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
TrigGlobalEfficiencyCorrectionTool::getEfficiency
virtual CP::CorrectionCode getEfficiency(const std::vector< const xAOD::IParticle * > &particles, double &efficiencyData, double &efficiencyMc) override
TrigGlobalEfficiencyCorrectionTool::m_electronLegsPerTag
std::map< std::string, std::string > m_electronLegsPerTag
Definition: TrigGlobalEfficiencyCorrectionTool.h:157
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
tags
std::vector< std::string > tags
Definition: hcg.cxx:102
TrigGlobalEfficiencyCorrectionTool::loadTriggerCombination
bool loadTriggerCombination(TrigGlobEffCorr::ImportData &data, bool useDefaultElectronTools, bool useDefaultPhotonTools)
TrigGlobalEfficiencyCorrectionTool::countTriggerLegs
virtual CP::CorrectionCode countTriggerLegs(const std::string &trigger, std::size_t &numberOfLegs) override
This utility function provides the number of legs for the specified trigger.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
TrigGlobalEfficiencyCorrectionTool::m_unsupportedLegs
std::set< ToolKey > m_unsupportedLegs
Definition: TrigGlobalEfficiencyCorrectionTool.h:178
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigGlobEffCorr::Calculator
Definition: Calculator.h:26
TrigGlobalEfficiencyCorrectionTool::m_overrideThresholds
std::map< std::string, std::string > m_overrideThresholds
Definition: TrigGlobalEfficiencyCorrectionTool.h:160
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
L1TopoRatesCalculator_submatrix_plotter.counts
counts
Definition: L1TopoRatesCalculator_submatrix_plotter.py:74
Photon.h
TrigGlobEffCorr::ImportData
Definition: ImportData.h:86
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
extractSporadic.h
list h
Definition: extractSporadic.py:96
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
python.CaloAddPedShiftConfig.str
str
Definition: CaloAddPedShiftConfig.py:42
TrigGlobalEfficiencyCorrectionTool::getEgammaTriggerLegEfficiencies
TLE_RESULT getEgammaTriggerLegEfficiencies(const ParticleType *p, unsigned runNumber, std::size_t leg, std::size_t tag, TrigGlobEffCorr::Efficiencies &efficiencies)
TrigGlobalEfficiencyCorrectionTool::aboveThreshold
bool aboveThreshold(const TrigGlobEffCorr::Lepton &p, std::size_t leg) const
TrigGlobEffCorr::CheckConfig
Definition: CheckConfig.h:18
TrigGlobalEfficiencyCorrectionTool::m_cpCode
CP::CorrectionCode m_cpCode
Definition: TrigGlobalEfficiencyCorrectionTool.h:184
compute_lumi.leg
leg
Definition: compute_lumi.py:95
TrigGlobalEfficiencyCorrectionTool::getRelevantTriggers
virtual CP::CorrectionCode getRelevantTriggers(std::vector< std::string > &triggers) override
This will fill the 'triggers' argument with the names of the triggers relevant for the current run nu...
TrigGlobalEfficiencyCorrectionTool::parseListOfLegs
flat_set< ToolKey > parseListOfLegs(TrigGlobEffCorr::ImportData &data, const std::string &inputList, bool &success)
Definition: TrigGlobalEfficiencyCorrectionTool.cxx:336
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
TrigGlobalEfficiencyCorrectionTool::m_triggerCbPerYear
std::map< std::string, std::string > m_triggerCbPerYear
Definition: TrigGlobalEfficiencyCorrectionTool.h:154
TrigGlobalEfficiencyCorrectionTool::m_validTrigMatchTool
bool m_validTrigMatchTool
Definition: TrigGlobalEfficiencyCorrectionTool.h:186
TrigGlobalEfficiencyCorrectionTool::m_suppliedPhotonScaleFactorTools
ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > m_suppliedPhotonScaleFactorTools
Definition: TrigGlobalEfficiencyCorrectionTool.h:150
TrigGlobalEfficiencyCorrectionTool::m_hierarchyMeta
std::vector< Hierarchy > m_hierarchyMeta
Definition: TrigGlobalEfficiencyCorrectionTool.h:180
TrigGlobEffCorr::TT_TRILEPTON_FLAG
@ TT_TRILEPTON_FLAG
Definition: ImportData.h:53
TrigGlobalEfficiencyCorrectionTool::processDeprecatedProperties
bool processDeprecatedProperties()
Definition: TrigGlobalEfficiencyCorrectionTool.cxx:201
TrigGlobalEfficiencyCorrectionTool::m_tagsPerTool
std::map< std::string, std::string > m_tagsPerTool
Definition: TrigGlobalEfficiencyCorrectionTool.h:156
TrigGlobEffCorr::TriggerType
TriggerType
Definition: ImportData.h:22
TrigGlobEffCorr::Lepton
Definition: Lepton.h:16
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
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
TrigGlobalEfficiencyCorrectionTool::m_checkElectronLegTag
bool m_checkElectronLegTag
Definition: TrigGlobalEfficiencyCorrectionTool.h:174
TrigGlobalEfficiencyCorrectionTool::m_photonSfToolIndex
std::map< ToolKey, std::size_t > m_photonSfToolIndex
Definition: TrigGlobalEfficiencyCorrectionTool.h:170
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:452
TrigGlobalEfficiencyCorrectionTool::getCachedTriggerLegsRanking
unsigned long getCachedTriggerLegsRanking(const TrigGlobEffCorr::Lepton &lepton, ListOfLegs... legs)
python.ElectronD3PDObject.matched
matched
Definition: ElectronD3PDObject.py:138
TrigGlobalEfficiencyCorrectionTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const CP::SystematicVariation &systematic) const override
Declare the interface that this class provides.
checkTriggerxAOD.found
found
Definition: checkTriggerxAOD.py:328
xAOD::Electron_v1
Definition: Electron_v1.h:34
TrigGlobEffCorr::Lepton::type
xAOD::Type::ObjectType type() const
Definition: Lepton.h:29
TrigGlobEffCorr::CheckConfig::advancedConfigChecks
bool advancedConfigChecks()
Definition: CheckConfig.cxx:244
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
Muon
struct TBPatternUnitContext Muon
TrigGlobalEfficiencyCorrectionTool::getTriggerLegEfficiencies
TLE_RESULT getTriggerLegEfficiencies(const xAOD::Electron *p, unsigned runNumber, std::size_t leg, std::size_t tag, TrigGlobEffCorr::Efficiencies &efficiencies)
python.PyAthena.v
v
Definition: PyAthena.py:154
get_generator_info.version
version
Definition: get_generator_info.py:33
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
TrigGlobalEfficiencyCorrectionTool::forwardLegs
static constexpr const flat_set< std::size_t > & forwardLegs(const flat_set< std::size_t > &legs)
TrigGlobalEfficiencyCorrectionTool::m_validLegTagPairs
std::set< std::size_t > m_validLegTagPairs
Definition: TrigGlobalEfficiencyCorrectionTool.h:173
TrigGlobalEfficiencyCorrectionTool::m_electronEffToolIndex
std::map< ToolKey, std::size_t > m_electronEffToolIndex
Definition: TrigGlobalEfficiencyCorrectionTool.h:169
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
DeMoScan.index
string index
Definition: DeMoScan.py:362
a
TList * a
Definition: liststreamerinfos.cxx:10
TrigGlobalEfficiencyCorrectionTool::flat_set
boost::container::flat_set< Key > flat_set
Definition: TrigGlobalEfficiencyCorrectionTool.h:193
TrigGlobalEfficiencyCorrectionTool::m_electronSfToolIndex
std::map< ToolKey, std::size_t > m_electronSfToolIndex
Definition: TrigGlobalEfficiencyCorrectionTool.h:168
y
#define y
h
TrigGlobalEfficiencyCorrectionTool::m_suppliedMuonTools
ToolHandleArray< CP::IMuonTriggerScaleFactors > m_suppliedMuonTools
Definition: TrigGlobalEfficiencyCorrectionTool.h:151
xAOD::Photon_v1
Definition: Photon_v1.h:37
TrigGlobalEfficiencyCorrectionTool::loadTagDecorators
bool loadTagDecorators(const flat_set< std::size_t > &collectedElectronTags, const flat_set< std::size_t > &collectedMuonTags, const flat_set< std::size_t > &collectedPhotonTags)
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
TrigGlobalEfficiencyCorrectionTool::m_trigMatchTool
ToolHandle< Trig::IMatchingTool > m_trigMatchTool
Definition: TrigGlobalEfficiencyCorrectionTool.h:163
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
TrigGlobalEfficiencyCorrectionTool::m_numberOfToys
unsigned long m_numberOfToys
Definition: TrigGlobalEfficiencyCorrectionTool.h:161
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
TrigGlobEffCorr::TT_DILEPTON_FLAG
@ TT_DILEPTON_FLAG
Definition: ImportData.h:40
run_AODTCCLinking.inputList
list inputList
Definition: run_AODTCCLinking.py:93
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:56
TrigGlobalEfficiencyCorrectionTool::m_checkMuonLegTag
bool m_checkMuonLegTag
Definition: TrigGlobalEfficiencyCorrectionTool.h:175
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
TrigGlobalEfficiencyCorrectionTool::m_suppliedElectronEfficiencyTools
ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > m_suppliedElectronEfficiencyTools
Properties:
Definition: TrigGlobalEfficiencyCorrectionTool.h:144
Electron.h
CheckConfig
TrigGlobEffCorr::CheckConfig CheckConfig
Definition: TrigGlobalEfficiencyCorrectionTool.cxx:27
TrigGlobEffCorr::removeWhitespaces
std::string removeWhitespaces(const std::string &s)
Definition: ImportData.h:170
IAsgElectronEfficiencyCorrectionTool
Definition: IAsgElectronEfficiencyCorrectionTool.h:18
CaloCondBlobAlgs_fillNoiseFromASCII.tag
string tag
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:23
TrigGlobalEfficiencyCorrectionTool::retrieveEventNumber
bool retrieveEventNumber(unsigned long &eventNumber)
TrigGlobalEfficiencyCorrectionTool::loadListOfLegsPerTag
bool loadListOfLegsPerTag()
Lepton
TrigGlobEffCorr::Lepton Lepton
Definition: TrigGlobalEfficiencyCorrectionTool.cxx:31
TrigGlobalEfficiencyCorrectionTool::retrieveRunNumber
bool retrieveRunNumber(unsigned &runNumber)
Internal methods (II) – core task.
ParticleType
ParticleType
Definition: TruthClasses.h:8
TrigGlobalEfficiencyCorrectionTool::m_initialized
bool m_initialized
Definition: TrigGlobalEfficiencyCorrectionTool.h:183
TrigGlobalEfficiencyCorrectionTool::m_dictionary
std::map< std::size_t, std::string > m_dictionary
Definition: TrigGlobalEfficiencyCorrectionTool.h:177
python.compressB64.c
def c
Definition: compressB64.py:93
TrigGlobalEfficiencyCorrectionTool::m_hasher
std::hash< std::string > m_hasher
Definition: TrigGlobalEfficiencyCorrectionTool.h:165
python.handimod.cc
int cc
Definition: handimod.py:522
TrigGlobalEfficiencyCorrectionTool::rankTriggerLegs
CachedRanking rankTriggerLegs(float pt, const Container &legs)
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
TrigGlobalEfficiencyCorrectionTool::m_thresholds
std::map< std::size_t, float > m_thresholds
Definition: TrigGlobalEfficiencyCorrectionTool.h:166