20 #ifndef XAOD_STANDALONE // For now metadata is Athena-only
53 else if(
year == 2018 &&
rn >= 348885 &&
rn <= 350013 )
return IsMETTrigPassed(
"HLT_xe110_pufit_xe70_L1XE50",
false);
57 else if(
year == 2023)
return (
IsMETTrigPassed(
"HLT_xe55_cell_xe70_tcpufit_xe90_pfsum_vssk_L1XE50",
false)
58 ||
IsMETTrigPassed(
"HLT_xe55_cell_xe70_tcpufit_xe95_pfsum_cssk_L1XE50",
false)
62 ||
IsMETTrigPassed(
"HLT_xe75_cell_xe65_tcpufit_xe90_trkmht_L1XE50",
false)
78 if (!L1_XE50 && j400_OR && HLT_noalg_L1J400) {
81 else if (L1_XE50 || L1_XE55) {
93 const std::string& triggerName)
const
95 auto mapItr = m_checkedTriggers.find(triggerName);
96 if ( mapItr == m_checkedTriggers.end() ) {
101 return mapItr->second;
109 auto funcItr = m_metTriggerFuncs.find(triggerName);
110 if (funcItr != m_metTriggerFuncs.end() )
111 return funcItr->second();
114 if (triggerName.substr(0,6) !=
"HLT_xe") {
115 ATH_MSG_ERROR(
"Requested trigger " << triggerName <<
" isn't a MET trigger! (HLT MET items should begin with 'HLT_xe'). Will return false." );
120 std::vector<std::pair<int, std::string> > hypos;
121 std::string temp(triggerName);
124 auto pos = temp.find(
"_AND_");
125 std::string itemName = temp.substr(0,
pos);
127 if (
pos == std::string::npos)
130 temp = temp.substr(
pos + 5);
132 std::regex expr(
"HLT_xe([[:digit:]]+)_?(mht|pufit|pueta|tc_lcw|)_?(?:L1XE([[:digit:]]+)|)");
134 if (!std::regex_match(itemName, sm, expr) ) {
135 ATH_MSG_WARNING(
"Regex reading for item " << itemName <<
" (" << triggerName <<
") failed! Will be ignored!" );
139 ATH_MSG_WARNING(
"Regex failed to capture the right groups for item " << itemName <<
" (" << triggerName <<
") failed! Will be ignored!" );
140 for (
unsigned int ii = 0; ii < sm.size(); ++ii) {
146 std::string algKey = sm[2];
147 std::string metContBaseName =
"HLT_xAOD__TrigMissingETContainer_TrigEFMissingET";
148 if (algKey.empty()) hypos.push_back(std::make_pair(
threshold, metContBaseName) );
149 else if (algKey ==
"mht") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"_mht") );
150 else if (algKey ==
"pufit") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"_topocl_PUC") );
151 else if (algKey ==
"pueta") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"_topocl_PS") );
152 else if (algKey ==
"tc_lcw") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"topocl") );
154 ATH_MSG_DEBUG(
"Container: " << hypos.back().second <<
", Threshold: " << hypos.back().first );
156 if (sm[3] !=
"" && sm[3] !=
"50") {
157 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" );
161 while (!temp.empty());
165 std::function<
bool()> lambda;
166 bool hasRequired =
true;
167 if (hypos.empty()) lambda = [] () {
return false;};
169 for (
const auto& pair : hypos) {
171 auto lambda_hypo = [
this, pair] () {
174 if (cont->
empty())
return false;
175 float ex = cont->
front()->ex() * 0.001;
176 float ey = cont->
front()->ey() * 0.001;
177 float met = std::sqrt(ex*ex + ey*ey);
178 return met > pair.first;
186 lambda = [lambda, lambda_hypo] () {
187 return lambda() && lambda_hypo();
191 lambda = lambda_hypo;
201 m_metTriggerFuncs[triggerName] = lambda;
202 return m_metTriggerFuncs.at(triggerName)();
205 std::vector<std::string> replacementTriggers({
"HLT_xe110_mht_L1XE50",
"HLT_xe100_mht_L1XE50",
"HLT_xe90_mht_L1XE50",
"HLT_xe70_mht"});
206 for (
const std::string& trigName : replacementTriggers) {
208 ATH_MSG_WARNING(
"Trigger " << triggerName <<
" not available and direct emulation impossible! Will use " << trigName <<
" instead!");
209 m_metTriggerFuncs[triggerName] = [
this, trigName] () {
212 return m_metTriggerFuncs.at(triggerName)();
215 ATH_MSG_ERROR(
"Cannot find the trigger in the menu, direct emulation is impossible and no replacement triggers are available! Will return false" );
216 m_metTriggerFuncs.at(triggerName) = [] () {
return false;};
217 return m_metTriggerFuncs.at(triggerName)();
248 dec_trigmatched(*
p) = 0;
250 for(
const auto *
it = i1;
it != i2; ++
it) {
265 dec_trigmatched(*
p) = 0;
277 for(
const auto&
p :
v) {
284 for(
const auto&
p :
v) {
291 for(
const auto&
p : *
v) {
298 for(
const auto&
p : *
v) {
331 static const std::string delOR =
"_OR_";
332 std::vector<std::string> trigchains = {};
333 std::string newtrigExpr = TString(trigExpr).Copy().ReplaceAll(
"||",delOR).Data();
334 newtrigExpr = TString(trigExpr).Copy().ReplaceAll(
" ",
"").Data();
337 while ((
pos = newtrigExpr.find(delOR)) != std::string::npos) {
338 trigchains.push_back(
"HLT_"+newtrigExpr.substr(0,
pos) );
339 newtrigExpr.erase(0,
pos + delOR.length());
341 if(
pos==std::string::npos)
342 trigchains.push_back(
"HLT_"+newtrigExpr);
347 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 {
351 static const std::string del15 =
"_2015_";
352 static const std::string del16 =
"_2016_";
353 static const std::string del17 =
"_2017_";
354 static const std::string del18 =
"_2018_";
355 static const std::string del22 =
"_2022_";
358 std::string token15, token16, token17, token18, token22;
361 if ( (
pos = trigExpr.find(del15)) != std::string::npos) {
362 trigExpr.erase(0,
pos + del15.length());
365 while ((
pos = trigExpr.find(del16)) != std::string::npos) {
366 token15 = trigExpr.substr(0,
pos);
367 token16 = trigExpr.erase(0,
pos + del16.length() + del17.length() - 1);
374 if ( (
pos = trigExpr.find(del22)) != std::string::npos) {
375 trigExpr.erase(0,
pos + del22.length());
380 if(token15.empty()) token15 = trigExpr;
381 if(token16.empty()) token16 = trigExpr;
382 if(token17.empty()) token17 = trigExpr;
383 if(token18.empty()) token18 = trigExpr;
386 if(token22.empty()) token22 = trigExpr;
411 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
412 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
416 std::vector<const xAOD::Electron*> elec_trig;
418 if (!acc_passOR(*
electron))
continue;
419 if (!acc_signal(*
electron))
continue;
423 std::vector<const xAOD::Muon*> muon_trig;
425 if (!acc_passOR(*
muon))
continue;
426 if (!acc_signal(*
muon))
continue;
427 muon_trig.push_back(
muon);
431 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
433 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
435 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
437 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
442 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
445 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
451 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
454 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger SF");
468 if (trigExpr ==
"diLepton") {
470 if (ret != StatusCode::SUCCESS) {
471 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) for systematic var. " << systConfig.
name() );
475 if (trigExpr ==
"multiLepton") {
477 if (ret != StatusCode::SUCCESS) {
478 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) for systematic var. " << systConfig.
name() );
486 if (trigExpr ==
"diLepton") {
488 if (ret != StatusCode::SUCCESS) {
489 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) back to default.");
492 if (trigExpr ==
"multiLepton") {
494 if (ret != StatusCode::SUCCESS) {
495 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) back to default.");
509 if (trigExpr!=
"diPhoton") {
514 std::vector<const xAOD::Photon*> ph_trig;
516 if (!acc_passOR(*
photon))
continue;
517 if (!acc_signal(*
photon))
continue;
518 ph_trig.push_back(
photon);
522 if (ph_trig.size()>1) {
546 if (ret != StatusCode::SUCCESS) {
547 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) for systematic var. " << systConfig.
name() );
555 if (ret != StatusCode::SUCCESS) {
556 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) back to default.");
565 double trig_eff_data(1.);
567 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
568 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
572 std::vector<const xAOD::Electron*> elec_trig;
574 if (!acc_passOR(*
electron))
continue;
575 if (!acc_signal(*
electron))
continue;
579 std::vector<const xAOD::Muon*> muon_trig;
581 if (!acc_passOR(*
muon))
continue;
582 if (!acc_signal(*
muon))
continue;
583 muon_trig.push_back(
muon);
587 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
589 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
591 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
593 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
598 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
601 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
607 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
610 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger efficiency");
616 if (
isData())
return trig_eff_data;
617 else return trig_eff;
626 double trig_eff_data(1.);
628 if (trigExpr!=
"diPhoton") {
629 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
633 std::vector<const xAOD::Photon*> ph_trig;
635 if (!acc_passOR(*
photon))
continue;
636 if (!acc_signal(*
photon))
continue;
637 ph_trig.push_back(
photon);
641 if (ph_trig.size()>1) {
647 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
650 ATH_MSG_VERBOSE(
"OutOfValidityRange found for diphoton trigger efficiency");
656 if (
isData())
return trig_eff_data;
657 else return trig_eff;