Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Trigger.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 // This source file implements all of the functions related to trigger
6 // in the SUSYObjDef_xAOD class
7 
8 // Local include(s):
10 
17 
19 
20 #ifndef XAOD_STANDALONE // For now metadata is Athena-only
22 #endif
23 
24 #include <regex>
25 
26 namespace ST {
27 
28  const static SG::Decorator<char> dec_trigmatched("trigmatched");
29 
30 bool SUSYObjDef_xAOD::IsMETTrigPassed(unsigned int runnumber, bool j400_OR) const {
31 
32  // Returns MET trigger decision for recommended lowest unprescaled evolution described in
33  // https://twiki.cern.ch/twiki/bin/viewauth/Atlas/LowestUnprescaled
34  // For period vs run number, see https://atlas-tagservices.cern.ch/tagservices/RunBrowser/runBrowserReport/rBR_Period_Report.php
35 
36  // if no runNumber specified, just read it from the current event
37  unsigned int rn;
38  if(runnumber>0){
39  rn = runnumber;
40  }
41  else{
42  rn = GetRunNumber(); // it takes care of dealing with data and MC
43  }
44 
45  int year = treatAsYear(rn);
46 
47  if (year == 2015) return IsMETTrigPassed("HLT_xe70_mht",j400_OR); //2015
48  else if(year == 2016 && rn >= 296939 && rn <= 302872 ) return IsMETTrigPassed("HLT_xe90_mht_L1XE50",j400_OR); //2016 A-D3
49  else if(year == 2016 && rn >= 302919 && rn <= 303892 ) return IsMETTrigPassed("HLT_xe100_mht_L1XE50",j400_OR); //2016 D4-F1
50  else if(year == 2016 && rn >= 303943) return IsMETTrigPassed("HLT_xe110_mht_L1XE50",j400_OR); //2016 F2-(open)
51  else if(year == 2017 && rn >= 325713 && rn <= 331975 ) return IsMETTrigPassed("HLT_xe110_pufit_L1XE55", false,"L1_XE55"); // 2017 B1-D5
52  else if(year == 2017 && rn >= 332303 ) return IsMETTrigPassed("HLT_xe110_pufit_L1XE50", false); // 2017 D6-(open)
53  else if(year == 2018 && rn >= 348885 && rn <= 350013 ) return IsMETTrigPassed("HLT_xe110_pufit_xe70_L1XE50", false); // 2018 B-C5
54  else if(year == 2018 && rn >= 350067 ) return IsMETTrigPassed("HLT_xe110_pufit_xe65_L1XE50", false); // 2018 C5-(open)
55  else if(year == 2022) return IsMETTrigPassed("HLT_xe65_cell_xe90_pfopufit_L1XE50",false); // 2022
56  else if(year == 2023) return IsMETTrigPassed("HLT_xe65_cell_xe90_pfopufit_L1XE50",false); // 2023
57  else if(year == 2024) return IsMETTrigPassed("HLT_xe65_cell_xe105_nn_L1jXE100",false,"L1_jXE100"); // 2024
58 
59  return false;
60 }
61 
62 // Can't be const because of the lazy init of the map - JBurr: Now fixed
63 bool SUSYObjDef_xAOD::IsMETTrigPassed(const std::string& triggerName, bool j400_OR, const std::string& L1_name) const {
64  // NB - this now applies to the entire function...
65 
66  // First check if we're affected by the L1_XE50 bug
67  bool L1_pass = m_trigDecTool->isPassed(L1_name);
68  bool HLT_noalg_L1J400 = m_trigDecTool->isPassed("HLT_noalg_L1J400");
69  if (!L1_pass && j400_OR && HLT_noalg_L1J400) {
70  return emulateHLT(triggerName);
71  }
72  else if (L1_pass) {
73  // See if the TDT knows about this
74  {
75  std::scoped_lock lock (m_triggerCacheMutex);
76  if (isTrigInTDT(lock, triggerName) ) return m_trigDecTool->isPassed(triggerName);
77  }
78  return emulateHLT(triggerName);
79  }
80  return false;
81 }
82 
83 bool SUSYObjDef_xAOD::isTrigInTDT(std::scoped_lock<std::mutex>& /*lock*/,
84  const std::string& triggerName) const
85 {
86  auto mapItr = m_checkedTriggers.find(triggerName);
87  if ( mapItr == m_checkedTriggers.end() ) {
88  const auto *cg = m_trigDecTool->getChainGroup(triggerName);
89  return m_checkedTriggers[triggerName] = cg->getListOfTriggers().size() != 0;
90  }
91  else {
92  return mapItr->second;
93  }
94 }
95 
96 
97 bool SUSYObjDef_xAOD::emulateHLT(const std::string& triggerName) const {
98  std::scoped_lock lock (m_triggerCacheMutex);
99  // First, check if we've already tried using this trigger
100  auto funcItr = m_metTriggerFuncs.find(triggerName);
101  if (funcItr != m_metTriggerFuncs.end() )
102  return funcItr->second();
103 
104  // Next, check that it really is a HLT MET trigger
105  if (triggerName.substr(0,6) != "HLT_xe") {
106  ATH_MSG_ERROR( "Requested trigger " << triggerName << " isn't a MET trigger! (HLT MET items should begin with 'HLT_xe'). Will return false." );
107  return false;
108  }
109 
110  // Next, parse the name to work out which containers are needed to emulate the decision
111  std::vector<std::pair<int, std::string> > hypos; // algorithms and thresholds needed
112  std::string temp(triggerName);
113  // Note, we need to split on '_AND_' used for the combined mht+cell trigger
114  do {
115  auto pos = temp.find("_AND_");
116  std::string itemName = temp.substr(0, pos);
117  ATH_MSG_DEBUG( "Split trigger item " << itemName );
118  if (pos == std::string::npos)
119  temp = "";
120  else
121  temp = temp.substr(pos + 5);
122 
123  std::regex expr("HLT_xe([[:digit:]]+)_?(mht|pufit|pueta|tc_lcw|)_?(?:L1XE([[:digit:]]+)|)");
124  std::smatch sm;
125  if (!std::regex_match(itemName, sm, expr) ) {
126  ATH_MSG_WARNING( "Regex reading for item " << itemName << " (" << triggerName << ") failed! Will be ignored!" );
127  continue;
128  }
129  if (sm.size() < 4) { // first object is the whole match, then there are three capture groups
130  ATH_MSG_WARNING( "Regex failed to capture the right groups for item " << itemName << " (" << triggerName << ") failed! Will be ignored!" );
131  for (unsigned int ii = 0; ii < sm.size(); ++ii) {
132  ATH_MSG_WARNING( sm[ii] );
133  }
134  continue;
135  }
136  int threshold = std::stoi(sm[1] );
137  std::string algKey = sm[2];
138  std::string metContBaseName = "HLT_xAOD__TrigMissingETContainer_TrigEFMissingET";
139  if (algKey.empty()) hypos.push_back(std::make_pair(threshold, metContBaseName) );
140  else if (algKey == "mht") hypos.push_back(std::make_pair(threshold, metContBaseName+"_mht") );
141  else if (algKey == "pufit") hypos.push_back(std::make_pair(threshold, metContBaseName+"_topocl_PUC") );
142  else if (algKey == "pueta") hypos.push_back(std::make_pair(threshold, metContBaseName+"_topocl_PS") );
143  else if (algKey == "tc_lcw") hypos.push_back(std::make_pair(threshold, metContBaseName+"topocl") );
144 
145  ATH_MSG_DEBUG( "Container: " << hypos.back().second << ", Threshold: " << hypos.back().first );
146 
147  if (sm[3] != "" && sm[3] != "50") {
148  ATH_MSG_WARNING( "The trigger requires a different L1 item to L1_XE50! This currently isn't allowed for in the code so the emulation will be slightly wrong" );
149  // Note, now the L1 part is done in the previous section. However I'm keeping this warning here.
150  }
151  }
152  while (!temp.empty());
153 
154  // Check if we have the containers and construct the lambda
155  // Already done the L1 decision - only care about HLT
156  std::function<bool()> lambda;
157  bool hasRequired = true;
158  if (hypos.empty()) lambda = [] () {return false;};
159  else {
160  for (const auto& pair : hypos) {
161  if (evtStore()->contains<xAOD::TrigMissingETContainer>(pair.second) ) {
162  auto lambda_hypo = [this, pair] () {
163  const xAOD::TrigMissingETContainer* cont(nullptr);
164  if (evtStore()->retrieve(cont, pair.second) ) {
165  if (cont->empty()) return false;
166  float ex = cont->front()->ex() * 0.001;
167  float ey = cont->front()->ey() * 0.001;
168  float met = std::sqrt(ex*ex + ey*ey);
169  return met > pair.first;
170  }
171  else {
172  return false;
173  }
174  };
175  // an empty std::function evaluates to false
176  if (lambda) {
177  lambda = [lambda, lambda_hypo] () {
178  return lambda() && lambda_hypo();
179  };
180  }
181  else {
182  lambda = lambda_hypo;
183  }
184  }
185  else {
186  hasRequired = false;
187  ATH_MSG_WARNING( "Container: " << pair.second << " missing!" );
188  }
189  }
190  }
191  if (hasRequired) {
192  m_metTriggerFuncs[triggerName] = lambda;
193  return m_metTriggerFuncs.at(triggerName)();
194  }
195  // We can't get the exact trigger decision :( . Look for an alternative
196  std::vector<std::string> replacementTriggers({"HLT_xe110_mht_L1XE50", "HLT_xe100_mht_L1XE50", "HLT_xe90_mht_L1XE50", "HLT_xe70_mht"});
197  for (const std::string& trigName : replacementTriggers) {
198  if (isTrigInTDT(lock, trigName) ) {
199  ATH_MSG_WARNING( "Trigger " << triggerName << " not available and direct emulation impossible! Will use " << trigName << " instead!");
200  m_metTriggerFuncs[triggerName] = [this, trigName] () {
201  return m_trigDecTool->isPassed(trigName);
202  };
203  return m_metTriggerFuncs.at(triggerName)();
204  }
205  }
206  ATH_MSG_ERROR( "Cannot find the trigger in the menu, direct emulation is impossible and no replacement triggers are available! Will return false" );
207  m_metTriggerFuncs.at(triggerName) = [] () {return false;};
208  return m_metTriggerFuncs.at(triggerName)();
209 }
210 
211 
212 
213 bool SUSYObjDef_xAOD::IsTrigPassed(const std::string& tr_item, unsigned int condition) const {
214  return m_trigDecTool->isPassed(tr_item, condition);
215 }
216 
217 
218 bool SUSYObjDef_xAOD::IsTrigMatched(const xAOD::IParticle *part, const std::string& tr_item) {
219  return this->IsTrigMatched({part}, tr_item);
220 }
221 
222 
223 bool SUSYObjDef_xAOD::IsTrigMatched(const xAOD::IParticle *part1, const xAOD::IParticle *part2, const std::string& tr_item) {
224  return this->IsTrigMatched({part1, part2}, tr_item);
225 }
226 
227 
228 bool SUSYObjDef_xAOD::IsTrigMatched(const std::vector<const xAOD::IParticle*>& v, const std::string& tr_item) {
229  return m_trigMatchingTool->match(v, tr_item);
230 }
231 
232 
233 bool SUSYObjDef_xAOD::IsTrigMatched(const std::initializer_list<const xAOD::IParticle*> &v, const std::string& tr_item) {
234  return m_trigMatchingTool->match(v, tr_item);
235 }
236 
237 
239  dec_trigmatched(*p) = 0;
240 
241  for(const auto *it = i1; it != i2; ++it) {
242  auto result = static_cast<int>(this->IsTrigMatched(p, *it));
243  dec_trigmatched(*p) += result;
244  const SG::Decorator<char> dec(*it);
245  dec(*p) = result;
246  }
247 }
248 
249 
250 void SUSYObjDef_xAOD::TrigMatch(const xAOD::IParticle* p, const std::initializer_list<std::string>& items) {
251  this->TrigMatch(p, items.begin(), items.end());
252 }
253 
254 
255 void SUSYObjDef_xAOD::TrigMatch(const xAOD::IParticle* p, const std::vector<std::string>& items) {
256  dec_trigmatched(*p) = 0;
257 
258  for(const auto& item: items) {
259  auto result = static_cast<int>(this->IsTrigMatched(p, item));
260  dec_trigmatched(*p) += result;
261  const SG::Decorator<char> dec(item);
262  dec(*p) = result;
263  }
264 }
265 
266 
267 void SUSYObjDef_xAOD::TrigMatch(const std::initializer_list<const xAOD::IParticle*> &v, const std::initializer_list<std::string> &items) {
268  for(const auto& p : v) {
269  this->TrigMatch(p, items);
270  }
271 }
272 
273 
274 void SUSYObjDef_xAOD::TrigMatch(const std::initializer_list<const xAOD::IParticle*> &v, const std::vector<std::string>& items) {
275  for(const auto& p : v) {
276  this->TrigMatch(p, items);
277  }
278 }
279 
280 
281 void SUSYObjDef_xAOD::TrigMatch(const xAOD::IParticleContainer* v, const std::vector<std::string>& items) {
282  for(const auto p : *v) {
283  this->TrigMatch(p, items);
284  }
285 }
286 
287 
288 void SUSYObjDef_xAOD::TrigMatch(const xAOD::IParticleContainer* v, const std::initializer_list<std::string>& items) {
289  for(const auto p : *v) {
290  this->TrigMatch(p, items);
291  }
292 }
293 
294 
295 void SUSYObjDef_xAOD::TrigMatch(const xAOD::IParticle* p, const std::string& item) {
296  return this->TrigMatch(p, {item});
297 }
298 
299 
300 void SUSYObjDef_xAOD::TrigMatch(const xAOD::IParticleContainer* v, const std::string& item) {
301  return this->TrigMatch(v, {item});
302 }
303 
304 
305 void SUSYObjDef_xAOD::TrigMatch(const std::initializer_list<const xAOD::IParticle*> &v, const std::string& item) {
306  return this->TrigMatch(v, {item});
307 }
308 
309 
310 float SUSYObjDef_xAOD::GetTrigPrescale(const std::string & tr_item) const {
311  return m_trigDecTool->getPrescale(tr_item);
312 }
313 
314 
315 const Trig::ChainGroup* SUSYObjDef_xAOD::GetTrigChainGroup(const std::string& tr_item) const {
316  return m_trigDecTool->getChainGroup(tr_item);
317 }
318 
319 
320  std::vector<std::string> SUSYObjDef_xAOD::GetTriggerOR(const std::string& trigExpr) const {
321 
322  static const std::string delOR = "_OR_";
323  std::vector<std::string> trigchains = {};
324  std::string newtrigExpr = TString(trigExpr).Copy().ReplaceAll("||",delOR).Data();
325  newtrigExpr = TString(trigExpr).Copy().ReplaceAll(" ","").Data();
326 
327  size_t pos = 0;
328  while ((pos = newtrigExpr.find(delOR)) != std::string::npos) {
329  trigchains.push_back( "HLT_"+newtrigExpr.substr(0, pos) );
330  newtrigExpr.erase(0, pos + delOR.length());
331  }
332  if(pos==std::string::npos)
333  trigchains.push_back("HLT_"+newtrigExpr);
334 
335  return trigchains;
336  }
337 
338  void SUSYObjDef_xAOD::GetTriggerTokens(std::string trigExpr, std::vector<std::string>& v_trigs15_cache, std::vector<std::string>& v_trigs16_cache, std::vector<std::string>& v_trigs17_cache, std::vector<std::string>& v_trigs18_cache, std::vector<std::string>& v_trigs22_cache) const {
339 
340  // e.g. SINGLE_E_2015_e24_lhmedium_L1EM20VH_OR_e60_lhmedium_OR_e120_lhloose_2016_2018_e26_lhtight_nod0_ivarloose_OR_e60_lhmedium_nod0_OR_e140_lhloose_nod0
341 
342  static const std::string del15 = "_2015_";
343  static const std::string del16 = "_2016_";
344  static const std::string del17 = "_2017_";
345  static const std::string del18 = "_2018_";
346  static const std::string del22 = "_2022_";
347 
348  size_t pos = 0;
349  std::string token15, token16, token17, token18, token22;
350 
351  //get trigger tokens for 2015, 2016, 2017, 2018 and 2022
352  if ( (pos = trigExpr.find(del15)) != std::string::npos) {
353  trigExpr.erase(0, pos + del15.length());
354 
355  pos = 0;
356  while ((pos = trigExpr.find(del16)) != std::string::npos) {
357  token15 = trigExpr.substr(0, pos);
358  token16 = trigExpr.erase(0, pos + del16.length() + del17.length() - 1);
359  // 2016-2018 use exact the same trigger string
360  token17 = token16;
361  token18 = token16;
362  }
363  }
364 
365  if ( (pos = trigExpr.find(del22)) != std::string::npos) {
366  trigExpr.erase(0, pos + del22.length());
367  }
368 
369  //redefine in case of custom user input
370  if(!m_isRun3){
371  if(token15.empty()) token15 = trigExpr;
372  if(token16.empty()) token16 = trigExpr;
373  if(token17.empty()) token17 = trigExpr;
374  if(token18.empty()) token18 = trigExpr;
375  }
376  else{
377  if(token22.empty()) token22 = trigExpr;
378  }
379 
380  //get trigger chains for matching in 2015 and 2018
381  if(!m_isRun3){
382  v_trigs15_cache = GetTriggerOR(token15);
383  v_trigs16_cache = GetTriggerOR(token16);
384  v_trigs17_cache = GetTriggerOR(token17);
385  v_trigs18_cache = GetTriggerOR(token18);
386  }
387  //get trigger chains for matching in 2022
388  else{
389  v_trigs22_cache = GetTriggerOR(token22);
390  }
391  }
392 
394  {
396  }
397 
399 
400  double trig_sf(1.);
401 
402  if (trigExpr!="multiLepton" && trigExpr!="diLepton") {
403  ATH_MSG_ERROR( "Failed to retrieve multi-lepton trigger SF");
404  return trig_sf;
405  }
406 
407  std::vector<const xAOD::Electron*> elec_trig;
408  for (const xAOD::Electron* electron : electrons) {
409  if (!acc_passOR(*electron)) continue;
410  if (!acc_signal(*electron)) continue;
411  elec_trig.push_back(electron);
412  }
413 
414  std::vector<const xAOD::Muon*> muon_trig;
415  for (const xAOD::Muon* muon : muons) {
416  if (!acc_passOR(*muon)) continue;
417  if (!acc_signal(*muon)) continue;
418  muon_trig.push_back(muon);
419  }
420 
421  bool matched = false;
422  if ((elec_trig.size()+muon_trig.size())>1 && trigExpr=="diLepton") {
424  ATH_MSG_ERROR ("trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
425  }
426  } else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr=="multiLepton") {
428  ATH_MSG_ERROR ("trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
429  }
430  }
431 
433  if ((elec_trig.size()+muon_trig.size())>1 && trigExpr=="diLepton" && matched) {
434  result = m_trigGlobalEffCorrTool_diLep->getEfficiencyScaleFactor( elec_trig, muon_trig, trig_sf);
435  }
436  else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr=="multiLepton" && matched) {
437  result = m_trigGlobalEffCorrTool_multiLep->getEfficiencyScaleFactor( elec_trig, muon_trig, trig_sf);
438  }
439 
440  switch (result) {
442  ATH_MSG_ERROR( "Failed to retrieve multi-lepton trigger SF");
443  return 1.;
445  ATH_MSG_VERBOSE( "OutOfValidityRange found for multi-lepton trigger SF");
446  return 1.;
447  default:
448  break;
449  }
450 
451  return trig_sf;
452 }
453 
454 double SUSYObjDef_xAOD::GetTriggerGlobalEfficiencySFsys(const xAOD::ElectronContainer& electrons, const xAOD::MuonContainer& muons, const CP::SystematicSet& systConfig, const std::string& trigExpr) {
455 
456  double sf(1.);
457 
458  //Set the new systematic variation
459  if (trigExpr == "diLepton") {
461  if (ret != StatusCode::SUCCESS) {
462  ATH_MSG_ERROR("Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) for systematic var. " << systConfig.name() );
463  }
464  }
465 
466  if (trigExpr == "multiLepton") {
468  if (ret != StatusCode::SUCCESS) {
469  ATH_MSG_ERROR("Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) for systematic var. " << systConfig.name() );
470  }
471  }
472 
473  //Get the SF for new config
474  sf = GetTriggerGlobalEfficiencySF (electrons, muons, trigExpr);
475 
476  //Roll back to default
477  if (trigExpr == "diLepton") {
479  if (ret != StatusCode::SUCCESS) {
480  ATH_MSG_ERROR("Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) back to default.");
481  }
482  }
483  if (trigExpr == "multiLepton") {
485  if (ret != StatusCode::SUCCESS) {
486  ATH_MSG_ERROR("Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) back to default.");
487  }
488  }
489 
490  return sf;
491 }
492 
493 //
494 // GetTriggerGlobalEfficiencySF function is meant to be used for "asymmetric" diphoton trigger SFs
495 //
496 double SUSYObjDef_xAOD::GetTriggerGlobalEfficiencySF(const xAOD::PhotonContainer& photons, const std::string& trigExpr) {
497 
498  double trig_sf(1.);
499 
500  if (trigExpr!="diPhoton") {
501  ATH_MSG_ERROR( "Failed to retrieve diphoton trigger SF");
502  return trig_sf;
503  }
504 
505  std::vector<const xAOD::Photon*> ph_trig;
506  for (const xAOD::Photon* photon : photons) {
507  if (!acc_passOR(*photon)) continue;
508  if (!acc_signal(*photon)) continue;
509  ph_trig.push_back(photon);
510  }
511 
513  if (ph_trig.size()>1) {
515  }
516 
517  switch (result) {
519  ATH_MSG_ERROR( "Failed to retrieve diphoton trigger SF");
520  return 1.;
522  ATH_MSG_VERBOSE( "OutOfValidityRange found for diphoton trigger SF");
523  return 1.;
524  default:
525  break;
526  }
527 
528  return trig_sf;
529 }
530 
531 double SUSYObjDef_xAOD::GetTriggerGlobalEfficiencySFsys(const xAOD::PhotonContainer& photons, const CP::SystematicSet& systConfig, const std::string& trigExpr) {
532 
533  double sf(1.);
534 
535  //Set the new systematic variation
537  if (ret != StatusCode::SUCCESS) {
538  ATH_MSG_ERROR("Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) for systematic var. " << systConfig.name() );
539  }
540 
541  //Get the SF for new config
542  sf = GetTriggerGlobalEfficiencySF (photons, trigExpr);
543 
544  //Roll back to default
546  if (ret != StatusCode::SUCCESS) {
547  ATH_MSG_ERROR("Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) back to default.");
548  }
549 
550  return sf;
551 }
552 
554 
555  double trig_eff(1.);
556  double trig_eff_data(1.);
557 
558  if (trigExpr!="multiLepton" && trigExpr!="diLepton") {
559  ATH_MSG_ERROR( "Failed to retrieve multi-lepton trigger efficiency");
560  return trig_eff;
561  }
562 
563  std::vector<const xAOD::Electron*> elec_trig;
564  for (const xAOD::Electron* electron : electrons) {
565  if (!acc_passOR(*electron)) continue;
566  if (!acc_signal(*electron)) continue;
567  elec_trig.push_back(electron);
568  }
569 
570  std::vector<const xAOD::Muon*> muon_trig;
571  for (const xAOD::Muon* muon : muons) {
572  if (!acc_passOR(*muon)) continue;
573  if (!acc_signal(*muon)) continue;
574  muon_trig.push_back(muon);
575  }
576 
577  bool matched = false;
578  if ((elec_trig.size()+muon_trig.size())>1 && trigExpr=="diLepton") {
580  ATH_MSG_ERROR ("trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
581  }
582  } else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr=="multiLepton") {
584  ATH_MSG_ERROR ("trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
585  }
586  }
587 
589  if ((elec_trig.size()+muon_trig.size())>1 && trigExpr=="diLepton" && matched) {
590  result = m_trigGlobalEffCorrTool_diLep->getEfficiency( elec_trig, muon_trig, trig_eff_data, trig_eff);
591  }
592  else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr=="multiLepton" && matched) {
593  result = m_trigGlobalEffCorrTool_multiLep->getEfficiency( elec_trig, muon_trig, trig_eff_data, trig_eff);
594  }
595 
596  switch (result) {
598  ATH_MSG_ERROR( "Failed to retrieve multi-lepton trigger efficiency");
599  return 1.;
601  ATH_MSG_VERBOSE( "OutOfValidityRange found for multi-lepton trigger efficiency");
602  return 1.;
603  default:
604  break;
605  }
606 
607  if (isData()) return trig_eff_data;
608  else return trig_eff;
609 }
610 
611 //
612 // GetTriggerGlobalEfficiency function is meant to be used for "asymmetric" diphoton trigger SFs
613 //
614 double SUSYObjDef_xAOD::GetTriggerGlobalEfficiency(const xAOD::PhotonContainer& photons, const std::string& trigExpr) {
615 
616  double trig_eff(1.);
617  double trig_eff_data(1.);
618 
619  if (trigExpr!="diPhoton") {
620  ATH_MSG_ERROR( "Failed to retrieve diphoton trigger efficiency");
621  return trig_eff;
622  }
623 
624  std::vector<const xAOD::Photon*> ph_trig;
625  for (const xAOD::Photon* photon : photons) {
626  if (!acc_passOR(*photon)) continue;
627  if (!acc_signal(*photon)) continue;
628  ph_trig.push_back(photon);
629  }
630 
632  if (ph_trig.size()>1) {
633  result = m_trigGlobalEffCorrTool_diPhoton->getEfficiency(ph_trig, trig_eff_data, trig_eff);
634  }
635 
636  switch (result) {
638  ATH_MSG_ERROR( "Failed to retrieve diphoton trigger efficiency");
639  return 1.;
641  ATH_MSG_VERBOSE( "OutOfValidityRange found for diphoton trigger efficiency");
642  return 1.;
643  default:
644  break;
645  }
646 
647  if (isData()) return trig_eff_data;
648  else return trig_eff;
649 }
650 
651 }
652 
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
ST::SUSYObjDef_xAOD::emulateHLT
bool emulateHLT(const std::string &triggerName) const
Definition: Trigger.cxx:97
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
ST::SUSYObjDef_xAOD::m_trigGlobalEffCorrTool_multiLep
asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > m_trigGlobalEffCorrTool_multiLep
Definition: SUSYObjDef_xAOD.h:950
ST::SUSYObjDef_xAOD::GetTriggerGlobalEfficiencySFsys
double GetTriggerGlobalEfficiencySFsys(const xAOD::ElectronContainer &electrons, const xAOD::MuonContainer &muons, const CP::SystematicSet &systConfig, const std::string &trigExpr="diLepton") override final
Definition: Trigger.cxx:454
ST::SUSYObjDef_xAOD::m_triggerCacheMutex
std::mutex m_triggerCacheMutex
Definition: SUSYObjDef_xAOD.h:446
get_generator_info.result
result
Definition: get_generator_info.py:21
ST::SUSYObjDef_xAOD::m_trigGlobalEffCorrTool_diPhoton
asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > m_trigGlobalEffCorrTool_diPhoton
Definition: SUSYObjDef_xAOD.h:958
FeatureContainer.h
ITrigConfigTool.h
ITrigGlobalEfficiencyCorrectionTool.h
ST::SUSYObjDef_xAOD::GetTriggerOR
std::vector< std::string > GetTriggerOR(const std::string &trigExpr) const
Definition: Trigger.cxx:320
ST::SUSYObjDef_xAOD::GetTriggerTokens
void GetTriggerTokens(std::string, std::vector< std::string > &, std::vector< std::string > &, std::vector< std::string > &, std::vector< std::string > &, std::vector< std::string > &) const
Definition: Trigger.cxx:338
ST::SUSYObjDef_xAOD::GetTriggerFeatures
Trig::FeatureContainer GetTriggerFeatures(const std::string &chainName="EF_.*", unsigned int condition=TrigDefs::Physics) const
Definition: Trigger.cxx:393
ST
Definition: Electrons.cxx:41
skel.it
it
Definition: skel.GENtoEVGEN.py:407
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::SystematicSet::name
std::string name() const
returns: the systematics joined into a single string.
Definition: SystematicSet.cxx:278
SUSYObjDef_xAOD.h
TrigDecisionTool.h
LArG4GenerateShowerLib.condition
condition
Definition: LArG4GenerateShowerLib.py:19
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ST::SUSYObjDef_xAOD::m_trigMatchingTool
asg::AnaToolHandle< Trig::IMatchingTool > m_trigMatchingTool
Definition: SUSYObjDef_xAOD.h:962
python.AtlRunQueryAMI.year
year
Definition: AtlRunQueryAMI.py:226
Trig::TrigDecisionToolCore::features
FeatureContainer features(const Trig::ChainGroup *group, unsigned int condition=TrigDefs::Physics) const
Runs 1, 2.
Definition: DecisionAccess.cxx:92
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
Trig::FeatureContainer
Definition: FeatureContainer.h:54
part1
Definition: part1.py:1
ST::SUSYObjDef_xAOD::m_trigGlobalEffCorrTool_diLep
asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > m_trigGlobalEffCorrTool_diLep
Definition: SUSYObjDef_xAOD.h:942
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
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
met
Definition: IMETSignificance.h:24
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ST::SUSYObjDef_xAOD::GetRunNumber
unsigned int GetRunNumber() const override final
Definition: SUSYObjDef_xAOD.cxx:3054
SG::Decorator< char >
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ST::SUSYObjDef_xAOD::IsTrigPassed
bool IsTrigPassed(const std::string &, unsigned int condition=TrigDefs::Physics) const override final
Definition: Trigger.cxx:213
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
python.BunchSpacingUtils.rn
rn
Definition: BunchSpacingUtils.py:86
TrigMissingETContainer.h
ST::SUSYObjDef_xAOD::isData
bool isData() const override final
Definition: SUSYObjDef_xAOD.h:157
ST::SUSYObjDef_xAOD::IsTrigMatched
bool IsTrigMatched(const xAOD::IParticle *part, const std::string &tr_item) override final
Definition: Trigger.cxx:218
ST::SUSYObjDef_xAOD::GetTriggerGlobalEfficiency
double GetTriggerGlobalEfficiency(const xAOD::ElectronContainer &electrons, const xAOD::MuonContainer &muons, const std::string &trigExpr="diLepton") override final
Definition: Trigger.cxx:553
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
Trig::TrigDecisionTool::isPassed
virtual bool isPassed(const std::string &chain, unsigned int condition) const
true if given chain passed
Definition: TrigDecisionTool.cxx:270
DeMoScan.runnumber
runnumber
Definition: DeMoScan.py:266
part2
Definition: part2.py:1
Trig::ChainGroup
Definition: ChainGroup.h:51
ST::SUSYObjDef_xAOD::IsMETTrigPassed
bool IsMETTrigPassed(unsigned int runnumber=0, bool j400_OR=false) const override final
Definition: Trigger.cxx:30
ST::SUSYObjDef_xAOD::TrigMatch
void TrigMatch(const xAOD::IParticle *p, std::initializer_list< std::string >::iterator, std::initializer_list< std::string >::iterator) override final
Definition: Trigger.cxx:238
threshold
Definition: chainparser.cxx:74
python.ElectronD3PDObject.matched
matched
Definition: ElectronD3PDObject.py:138
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
item
Definition: ItemListSvc.h:43
xAOD::Electron_v1
Definition: Electron_v1.h:34
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Conditions.h
ST::SUSYObjDef_xAOD::GetTrigPrescale
float GetTrigPrescale(const std::string &) const override final
Definition: Trigger.cxx:310
AthAnalysisHelper.h
Trig::TrigDecisionToolCore::getPrescale
float getPrescale(const Trig::ChainGroup *chaingroup, unsigned int condition=TrigDefs::Physics) const
Definition: ConfigurationAccess.cxx:88
python.PyAthena.v
v
Definition: PyAthena.py:154
ST::SUSYObjDef_xAOD::GetTrigChainGroup
const Trig::ChainGroup * GetTrigChainGroup(const std::string &) const override final
Definition: Trigger.cxx:315
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
ITrigGlobalEfficiencyCorrectionTool::getEfficiencyScaleFactor
virtual CP::CorrectionCode getEfficiencyScaleFactor(const std::vector< const xAOD::IParticle * > &particles, double &efficiencyScaleFactor)=0
IMatchingTool.h
xAOD::photon
@ photon
Definition: TrackingPrimitives.h:200
ITrigGlobalEfficiencyCorrectionTool::checkTriggerMatching
virtual CP::CorrectionCode checkTriggerMatching(bool &matched, const std::vector< const xAOD::IParticle * > &particles)=0
xAOD::Photon_v1
Definition: Photon_v1.h:37
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ITrigGlobalEfficiencyCorrectionTool::getEfficiency
virtual CP::CorrectionCode getEfficiency(const std::vector< const xAOD::IParticle * > &particles, double &efficiencyData, double &efficiencyMc)=0
ST::SUSYObjDef_xAOD::GetTriggerGlobalEfficiencySF
double GetTriggerGlobalEfficiencySF(const xAOD::ElectronContainer &electrons, const xAOD::MuonContainer &muons, const std::string &trigExpr="diLepton") override final
Definition: Trigger.cxx:398
ST::SUSYObjDef_xAOD::m_isRun3
bool m_isRun3
Definition: SUSYObjDef_xAOD.h:800
ST::SUSYObjDef_xAOD::m_trigDecTool
asg::AnaToolHandle< Trig::TrigDecisionTool > m_trigDecTool
Definition: SUSYObjDef_xAOD.h:961
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:426
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
ST::SUSYObjDef_xAOD::m_currentSyst
CP::SystematicSet m_currentSyst
Definition: SUSYObjDef_xAOD.h:813
Trig::TrigDecisionToolCore::getChainGroup
const Trig::ChainGroup * getChainGroup(const std::vector< std::string > &patterns, TrigDefs::Group props=TrigDefs::Group::Default) const
Create/get chain group (.
Definition: ChainGroupFunctions.cxx:38
Trig::ChainGroup::getListOfTriggers
std::vector< std::string > getListOfTriggers() const
Definition: ChainGroup.cxx:467
Trig::IMatchingTool::match
virtual bool match(const xAOD::IParticle &recoObject, const std::string &chain, double matchThreshold=0.1, bool rerun=false) const =0
single object trigger matching. matchThreshold is typically the deltaR requirement to obtain positive...
ST::SUSYObjDef_xAOD::treatAsYear
int treatAsYear(const int runNumber=-1) const override final
Definition: SUSYObjDef_xAOD.cxx:3111
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
CP::ISystematicsTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig)=0
effects: configure this tool for the given list of systematic variations.
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
ST::SUSYObjDef_xAOD::isTrigInTDT
bool isTrigInTDT(std::scoped_lock< std::mutex > &lock, const std::string &triggerName) const
Definition: Trigger.cxx:83