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)
const {
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_";
349 std::string token15, token16, token17, token18, token22;
352 if ( (
pos = trigExpr.find(del15)) != std::string::npos) {
353 trigExpr.erase(0,
pos + del15.length());
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);
365 if ( (
pos = trigExpr.find(del22)) != std::string::npos) {
366 trigExpr.erase(0,
pos + del22.length());
371 if(token15.empty()) token15 = trigExpr;
372 if(token16.empty()) token16 = trigExpr;
373 if(token17.empty()) token17 = trigExpr;
374 if(token18.empty()) token18 = trigExpr;
377 if(token22.empty()) token22 = trigExpr;
402 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
403 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
407 std::vector<const xAOD::Electron*> elec_trig;
409 if (!acc_passOR(*electron))
continue;
410 if (!acc_signal(*electron))
continue;
411 elec_trig.push_back(electron);
414 std::vector<const xAOD::Muon*> muon_trig;
416 if (!acc_passOR(*
muon))
continue;
417 if (!acc_signal(*
muon))
continue;
418 muon_trig.push_back(
muon);
422 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
424 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
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.");
433 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
436 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
442 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
445 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger SF");
459 if (trigExpr ==
"diLepton") {
461 if (ret != StatusCode::SUCCESS) {
462 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) for systematic var. " << systConfig.
name() );
466 if (trigExpr ==
"multiLepton") {
468 if (ret != StatusCode::SUCCESS) {
469 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) for systematic var. " << systConfig.
name() );
477 if (trigExpr ==
"diLepton") {
479 if (ret != StatusCode::SUCCESS) {
480 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) back to default.");
483 if (trigExpr ==
"multiLepton") {
485 if (ret != StatusCode::SUCCESS) {
486 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) back to default.");
500 if (trigExpr!=
"diPhoton") {
505 std::vector<const xAOD::Photon*> ph_trig;
507 if (!acc_passOR(*
photon))
continue;
508 if (!acc_signal(*
photon))
continue;
509 ph_trig.push_back(
photon);
513 if (ph_trig.size()>1) {
537 if (ret != StatusCode::SUCCESS) {
538 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) for systematic var. " << systConfig.
name() );
546 if (ret != StatusCode::SUCCESS) {
547 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) back to default.");
556 double trig_eff_data(1.);
558 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
559 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
563 std::vector<const xAOD::Electron*> elec_trig;
565 if (!acc_passOR(*electron))
continue;
566 if (!acc_signal(*electron))
continue;
567 elec_trig.push_back(electron);
570 std::vector<const xAOD::Muon*> muon_trig;
572 if (!acc_passOR(*
muon))
continue;
573 if (!acc_signal(*
muon))
continue;
574 muon_trig.push_back(
muon);
578 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
580 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
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.");
589 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
592 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
598 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
601 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger efficiency");
607 if (
isData())
return trig_eff_data;
608 else return trig_eff;
617 double trig_eff_data(1.);
619 if (trigExpr!=
"diPhoton") {
620 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
624 std::vector<const xAOD::Photon*> ph_trig;
626 if (!acc_passOR(*
photon))
continue;
627 if (!acc_signal(*
photon))
continue;
628 ph_trig.push_back(
photon);
632 if (ph_trig.size()>1) {
638 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
641 ATH_MSG_VERBOSE(
"OutOfValidityRange found for diphoton trigger efficiency");
647 if (
isData())
return trig_eff_data;
648 else return trig_eff;