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) {
253 p->auxdecor<
char>(*it) =
result;
264 dec_trigmatched(*
p) = 0;
275 for(
const auto&
p :
v) {
282 for(
const auto&
p :
v) {
289 for(
const auto&
p : *
v) {
296 for(
const auto&
p : *
v) {
329 static const std::string delOR =
"_OR_";
330 std::vector<std::string> trigchains = {};
331 std::string newtrigExpr = TString(trigExpr).Copy().ReplaceAll(
"||",delOR).Data();
332 newtrigExpr = TString(trigExpr).Copy().ReplaceAll(
" ",
"").Data();
335 while ((
pos = newtrigExpr.find(delOR)) != std::string::npos) {
336 trigchains.push_back(
"HLT_"+newtrigExpr.substr(0,
pos) );
337 newtrigExpr.erase(0,
pos + delOR.length());
339 if(
pos==std::string::npos)
340 trigchains.push_back(
"HLT_"+newtrigExpr);
345 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 {
349 static const std::string del15 =
"_2015_";
350 static const std::string del16 =
"_2016_";
351 static const std::string del17 =
"_2017_";
352 static const std::string del18 =
"_2018_";
353 static const std::string del22 =
"_2022_";
356 std::string token15, token16, token17, token18, token22;
359 if ( (
pos = trigExpr.find(del15)) != std::string::npos) {
360 trigExpr.erase(0,
pos + del15.length());
363 while ((
pos = trigExpr.find(del16)) != std::string::npos) {
364 token15 = trigExpr.substr(0,
pos);
365 token16 = trigExpr.erase(0,
pos + del16.length() + del17.length() - 1);
372 if ( (
pos = trigExpr.find(del22)) != std::string::npos) {
373 trigExpr.erase(0,
pos + del22.length());
378 if(token15.empty()) token15 = trigExpr;
379 if(token16.empty()) token16 = trigExpr;
380 if(token17.empty()) token17 = trigExpr;
381 if(token18.empty()) token18 = trigExpr;
384 if(token22.empty()) token22 = trigExpr;
409 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
410 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
414 std::vector<const xAOD::Electron*> elec_trig;
416 if (!acc_passOR(*
electron))
continue;
417 if (!acc_signal(*
electron))
continue;
421 std::vector<const xAOD::Muon*> muon_trig;
423 if (!acc_passOR(*
muon))
continue;
424 if (!acc_signal(*
muon))
continue;
425 muon_trig.push_back(
muon);
429 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
431 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
433 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
435 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
440 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
443 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
449 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
452 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger SF");
466 if (trigExpr ==
"diLepton") {
468 if (
ret != StatusCode::SUCCESS) {
469 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) for systematic var. " << systConfig.
name() );
473 if (trigExpr ==
"multiLepton") {
475 if (
ret != StatusCode::SUCCESS) {
476 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) for systematic var. " << systConfig.
name() );
484 if (trigExpr ==
"diLepton") {
486 if (
ret != StatusCode::SUCCESS) {
487 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) back to default.");
490 if (trigExpr ==
"multiLepton") {
492 if (
ret != StatusCode::SUCCESS) {
493 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) back to default.");
507 if (trigExpr!=
"diPhoton") {
512 std::vector<const xAOD::Photon*> ph_trig;
514 if (!acc_passOR(*
photon))
continue;
515 if (!acc_signal(*
photon))
continue;
516 ph_trig.push_back(
photon);
520 if (ph_trig.size()>1) {
544 if (
ret != StatusCode::SUCCESS) {
545 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) for systematic var. " << systConfig.
name() );
553 if (
ret != StatusCode::SUCCESS) {
554 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) back to default.");
563 double trig_eff_data(1.);
565 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
566 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
570 std::vector<const xAOD::Electron*> elec_trig;
572 if (!acc_passOR(*
electron))
continue;
573 if (!acc_signal(*
electron))
continue;
577 std::vector<const xAOD::Muon*> muon_trig;
579 if (!acc_passOR(*
muon))
continue;
580 if (!acc_signal(*
muon))
continue;
581 muon_trig.push_back(
muon);
585 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
587 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
589 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
591 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
596 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
599 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
605 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
608 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger efficiency");
614 if (
isData())
return trig_eff_data;
615 else return trig_eff;
624 double trig_eff_data(1.);
626 if (trigExpr!=
"diPhoton") {
627 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
631 std::vector<const xAOD::Photon*> ph_trig;
633 if (!acc_passOR(*
photon))
continue;
634 if (!acc_signal(*
photon))
continue;
635 ph_trig.push_back(
photon);
639 if (ph_trig.size()>1) {
645 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
648 ATH_MSG_VERBOSE(
"OutOfValidityRange found for diphoton trigger efficiency");
654 if (
isData())
return trig_eff_data;
655 else return trig_eff;