20 #ifndef XAOD_STANDALONE // For now metadata is Athena-only
51 else if(
year == 2017 &&
rn >= 325713 &&
rn <= 331975 )
return IsMETTrigPassed(
"HLT_xe110_pufit_L1XE55",
false,
"L1_XE55");
53 else if(
year == 2018 &&
rn >= 348885 &&
rn <= 350013 )
return IsMETTrigPassed(
"HLT_xe110_pufit_xe70_L1XE50",
false);
57 else if(
year == 2024)
return IsMETTrigPassed(
"HLT_xe65_cell_xe105_nn_L1jXE100",
false,
"L1_jXE100");
69 if (!L1_pass && j400_OR && HLT_noalg_L1J400) {
84 const std::string& triggerName)
const
86 auto mapItr = m_checkedTriggers.find(triggerName);
87 if ( mapItr == m_checkedTriggers.end() ) {
92 return mapItr->second;
100 auto funcItr = m_metTriggerFuncs.find(triggerName);
101 if (funcItr != m_metTriggerFuncs.end() )
102 return funcItr->second();
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." );
111 std::vector<std::pair<int, std::string> > hypos;
112 std::string temp(triggerName);
115 auto pos = temp.find(
"_AND_");
116 std::string itemName = temp.substr(0,
pos);
118 if (
pos == std::string::npos)
121 temp = temp.substr(
pos + 5);
123 std::regex expr(
"HLT_xe([[:digit:]]+)_?(mht|pufit|pueta|tc_lcw|)_?(?:L1XE([[:digit:]]+)|)");
125 if (!std::regex_match(itemName, sm, expr) ) {
126 ATH_MSG_WARNING(
"Regex reading for item " << itemName <<
" (" << triggerName <<
") failed! Will be ignored!" );
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) {
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") );
145 ATH_MSG_DEBUG(
"Container: " << hypos.back().second <<
", Threshold: " << hypos.back().first );
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" );
152 while (!temp.empty());
156 std::function<
bool()> lambda;
157 bool hasRequired =
true;
158 if (hypos.empty()) lambda = [] () {
return false;};
160 for (
const auto& pair : hypos) {
162 auto lambda_hypo = [
this, pair] () {
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;
177 lambda = [lambda, lambda_hypo] () {
178 return lambda() && lambda_hypo();
182 lambda = lambda_hypo;
192 m_metTriggerFuncs[triggerName] = lambda;
193 return m_metTriggerFuncs.at(triggerName)();
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) {
199 ATH_MSG_WARNING(
"Trigger " << triggerName <<
" not available and direct emulation impossible! Will use " << trigName <<
" instead!");
200 m_metTriggerFuncs[triggerName] = [
this, trigName] () {
203 return m_metTriggerFuncs.at(triggerName)();
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)();
239 dec_trigmatched(*
p) = 0;
241 for(
const auto *
it = i1;
it != i2; ++
it) {
256 dec_trigmatched(*
p) = 0;
268 for(
const auto&
p :
v) {
275 for(
const auto&
p :
v) {
282 for(
const auto p : *
v) {
289 for(
const auto p : *
v) {
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();
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());
332 if(
pos==std::string::npos)
333 trigchains.push_back(
"HLT_"+newtrigExpr);
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, std::vector<std::string>& v_trigs23_cache, std::vector<std::string>& v_trigs24_cache)
const {
342 static const std::string del15 =
"_2015_";
343 static const std::string del16 =
"_2016_";
344 static const std::string del17 =
"_2017_";
347 std::string token15, token16, token17, token18, token22, token23, token24;
350 if ( (
pos = trigExpr.find(del15)) != std::string::npos) {
351 trigExpr.erase(0,
pos + del15.length());
354 while ((
pos = trigExpr.find(del16)) != std::string::npos) {
355 token15 = trigExpr.substr(0,
pos);
356 token16 = trigExpr.erase(0,
pos + del16.length() + del17.length() - 1);
364 size_t p22 = trigExpr.find(
"2022");
365 size_t p23 = trigExpr.find(
"2023");
366 size_t p24 = trigExpr.find(
"2024");
368 auto next_pos = [&](
size_t self) {
369 size_t next = std::string::npos;
372 if (p23 >
self && p23 <
next)
next = p23;
373 if (p24 >
self && p24 <
next)
next = p24;
375 else if (
self == p23) {
376 if (p22 >
self && p22 <
next)
next = p22;
377 if (p24 >
self && p24 <
next)
next = p24;
379 else if (
self == p24) {
380 if (p22 >
self && p22 <
next)
next = p22;
381 if (p23 >
self && p23 <
next)
next = p23;
388 if (p22 != std::string::npos) {
size_t end = next_pos(p22); token22 = trigExpr.substr(p22,
end - p22);}
389 if (p23 != std::string::npos) {
size_t end = next_pos(p23); token23 = trigExpr.substr(p23,
end - p23);}
390 if (p24 != std::string::npos) {
size_t end = next_pos(p24); token24 = trigExpr.substr(p24,
end - p24);}
393 std::string* toks[] = { &token22, &token23, &token24 };
394 for (
auto t : toks) {
395 while (!
t->empty() &&
t->back() ==
'_')
t->pop_back();
400 if(token15.empty()) token15 = trigExpr;
401 if(token16.empty()) token16 = trigExpr;
402 if(token17.empty()) token17 = trigExpr;
403 if(token18.empty()) token18 = trigExpr;
406 if(token22.empty()) token22 = trigExpr;
407 if(token23.empty()) token23 = trigExpr;
408 if(token24.empty()) token24 = trigExpr;
435 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
436 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
440 std::vector<const xAOD::Electron*> elec_trig;
442 if (!acc_passOR(*
electron))
continue;
443 if (!acc_signal(*
electron))
continue;
447 std::vector<const xAOD::Muon*> muon_trig;
449 if (!acc_passOR(*
muon))
continue;
450 if (!acc_signal(*
muon))
continue;
451 muon_trig.push_back(
muon);
455 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
457 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
459 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
461 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
466 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
469 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
475 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
478 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger SF");
492 if (trigExpr ==
"diLepton") {
494 if (ret != StatusCode::SUCCESS) {
495 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) for systematic var. " << systConfig.
name() );
499 if (trigExpr ==
"multiLepton") {
501 if (ret != StatusCode::SUCCESS) {
502 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) for systematic var. " << systConfig.
name() );
510 if (trigExpr ==
"diLepton") {
512 if (ret != StatusCode::SUCCESS) {
513 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) back to default.");
516 if (trigExpr ==
"multiLepton") {
518 if (ret != StatusCode::SUCCESS) {
519 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) back to default.");
533 if (trigExpr!=
"diPhoton") {
538 std::vector<const xAOD::Photon*> ph_trig;
540 if (!acc_passOR(*
photon))
continue;
541 if (!acc_signal(*
photon))
continue;
542 ph_trig.push_back(
photon);
546 if (ph_trig.size()>1) {
570 if (ret != StatusCode::SUCCESS) {
571 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) for systematic var. " << systConfig.
name() );
579 if (ret != StatusCode::SUCCESS) {
580 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) back to default.");
589 double trig_eff_data(1.);
591 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
592 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
596 std::vector<const xAOD::Electron*> elec_trig;
598 if (!acc_passOR(*
electron))
continue;
599 if (!acc_signal(*
electron))
continue;
603 std::vector<const xAOD::Muon*> muon_trig;
605 if (!acc_passOR(*
muon))
continue;
606 if (!acc_signal(*
muon))
continue;
607 muon_trig.push_back(
muon);
611 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
613 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
615 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
617 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
622 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
625 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
631 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
634 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger efficiency");
640 if (
isData())
return trig_eff_data;
641 else return trig_eff;
650 double trig_eff_data(1.);
652 if (trigExpr!=
"diPhoton") {
653 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
657 std::vector<const xAOD::Photon*> ph_trig;
659 if (!acc_passOR(*
photon))
continue;
660 if (!acc_signal(*
photon))
continue;
661 ph_trig.push_back(
photon);
665 if (ph_trig.size()>1) {
671 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
674 ATH_MSG_VERBOSE(
"OutOfValidityRange found for diphoton trigger efficiency");
680 if (
isData())
return trig_eff_data;
681 else return trig_eff;