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);
71 if (!L1_XE50 && j400_OR && HLT_noalg_L1J400) {
74 else if (L1_XE50 || L1_XE55) {
86 const std::string& triggerName)
const
88 auto mapItr = m_checkedTriggers.find(triggerName);
89 if ( mapItr == m_checkedTriggers.end() ) {
94 return mapItr->second;
102 auto funcItr = m_metTriggerFuncs.find(triggerName);
103 if (funcItr != m_metTriggerFuncs.end() )
104 return funcItr->second();
107 if (triggerName.substr(0,6) !=
"HLT_xe") {
108 ATH_MSG_ERROR(
"Requested trigger " << triggerName <<
" isn't a MET trigger! (HLT MET items should begin with 'HLT_xe'). Will return false." );
113 std::vector<std::pair<int, std::string> > hypos;
114 std::string temp(triggerName);
117 auto pos = temp.find(
"_AND_");
118 std::string itemName = temp.substr(0,
pos);
120 if (
pos == std::string::npos)
123 temp = temp.substr(
pos + 5);
125 std::regex expr(
"HLT_xe([[:digit:]]+)_?(mht|pufit|pueta|tc_lcw|)_?(?:L1XE([[:digit:]]+)|)");
127 if (!std::regex_match(itemName, sm, expr) ) {
128 ATH_MSG_WARNING(
"Regex reading for item " << itemName <<
" (" << triggerName <<
") failed! Will be ignored!" );
132 ATH_MSG_WARNING(
"Regex failed to capture the right groups for item " << itemName <<
" (" << triggerName <<
") failed! Will be ignored!" );
133 for (
unsigned int ii = 0; ii < sm.size(); ++ii) {
139 std::string algKey = sm[2];
140 std::string metContBaseName =
"HLT_xAOD__TrigMissingETContainer_TrigEFMissingET";
141 if (algKey.empty()) hypos.push_back(std::make_pair(
threshold, metContBaseName) );
142 else if (algKey ==
"mht") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"_mht") );
143 else if (algKey ==
"pufit") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"_topocl_PUC") );
144 else if (algKey ==
"pueta") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"_topocl_PS") );
145 else if (algKey ==
"tc_lcw") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"topocl") );
147 ATH_MSG_DEBUG(
"Container: " << hypos.back().second <<
", Threshold: " << hypos.back().first );
149 if (sm[3] !=
"" && sm[3] !=
"50") {
150 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" );
154 while (!temp.empty());
158 std::function<
bool()> lambda;
159 bool hasRequired =
true;
160 if (hypos.empty()) lambda = [] () {
return false;};
162 for (
const auto& pair : hypos) {
164 auto lambda_hypo = [
this, pair] () {
167 if (cont->
empty())
return false;
168 float ex = cont->
front()->ex() * 0.001;
169 float ey = cont->
front()->ey() * 0.001;
170 float met = std::sqrt(ex*ex + ey*ey);
171 return met > pair.first;
179 lambda = [lambda, lambda_hypo] () {
180 return lambda() && lambda_hypo();
184 lambda = lambda_hypo;
194 m_metTriggerFuncs[triggerName] = lambda;
195 return m_metTriggerFuncs.at(triggerName)();
198 std::vector<std::string> replacementTriggers({
"HLT_xe110_mht_L1XE50",
"HLT_xe100_mht_L1XE50",
"HLT_xe90_mht_L1XE50",
"HLT_xe70_mht"});
199 for (
const std::string& trigName : replacementTriggers) {
201 ATH_MSG_WARNING(
"Trigger " << triggerName <<
" not available and direct emulation impossible! Will use " << trigName <<
" instead!");
202 m_metTriggerFuncs[triggerName] = [
this, trigName] () {
205 return m_metTriggerFuncs.at(triggerName)();
208 ATH_MSG_ERROR(
"Cannot find the trigger in the menu, direct emulation is impossible and no replacement triggers are available! Will return false" );
209 m_metTriggerFuncs.at(triggerName) = [] () {
return false;};
210 return m_metTriggerFuncs.at(triggerName)();
241 dec_trigmatched(*
p) = 0;
243 for(
const auto *
it = i1;
it != i2; ++
it) {
258 dec_trigmatched(*
p) = 0;
270 for(
const auto&
p :
v) {
277 for(
const auto&
p :
v) {
284 for(
const auto&
p : *
v) {
291 for(
const auto&
p : *
v) {
324 static const std::string delOR =
"_OR_";
325 std::vector<std::string> trigchains = {};
326 std::string newtrigExpr = TString(trigExpr).Copy().ReplaceAll(
"||",delOR).Data();
327 newtrigExpr = TString(trigExpr).Copy().ReplaceAll(
" ",
"").Data();
330 while ((
pos = newtrigExpr.find(delOR)) != std::string::npos) {
331 trigchains.push_back(
"HLT_"+newtrigExpr.substr(0,
pos) );
332 newtrigExpr.erase(0,
pos + delOR.length());
334 if(
pos==std::string::npos)
335 trigchains.push_back(
"HLT_"+newtrigExpr);
340 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 {
344 static const std::string del15 =
"_2015_";
345 static const std::string del16 =
"_2016_";
346 static const std::string del17 =
"_2017_";
347 static const std::string del18 =
"_2018_";
348 static const std::string del22 =
"_2022_";
351 std::string token15, token16, token17, token18, token22;
354 if ( (
pos = trigExpr.find(del15)) != std::string::npos) {
355 trigExpr.erase(0,
pos + del15.length());
358 while ((
pos = trigExpr.find(del16)) != std::string::npos) {
359 token15 = trigExpr.substr(0,
pos);
360 token16 = trigExpr.erase(0,
pos + del16.length() + del17.length() - 1);
367 if ( (
pos = trigExpr.find(del22)) != std::string::npos) {
368 trigExpr.erase(0,
pos + del22.length());
373 if(token15.empty()) token15 = trigExpr;
374 if(token16.empty()) token16 = trigExpr;
375 if(token17.empty()) token17 = trigExpr;
376 if(token18.empty()) token18 = trigExpr;
379 if(token22.empty()) token22 = trigExpr;
404 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
405 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
409 std::vector<const xAOD::Electron*> elec_trig;
411 if (!acc_passOR(*
electron))
continue;
412 if (!acc_signal(*
electron))
continue;
416 std::vector<const xAOD::Muon*> muon_trig;
418 if (!acc_passOR(*
muon))
continue;
419 if (!acc_signal(*
muon))
continue;
420 muon_trig.push_back(
muon);
424 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
426 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
428 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
430 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
435 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
438 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
444 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
447 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger SF");
461 if (trigExpr ==
"diLepton") {
463 if (ret != StatusCode::SUCCESS) {
464 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) for systematic var. " << systConfig.
name() );
468 if (trigExpr ==
"multiLepton") {
470 if (ret != StatusCode::SUCCESS) {
471 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) for systematic var. " << systConfig.
name() );
479 if (trigExpr ==
"diLepton") {
481 if (ret != StatusCode::SUCCESS) {
482 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) back to default.");
485 if (trigExpr ==
"multiLepton") {
487 if (ret != StatusCode::SUCCESS) {
488 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) back to default.");
502 if (trigExpr!=
"diPhoton") {
507 std::vector<const xAOD::Photon*> ph_trig;
509 if (!acc_passOR(*
photon))
continue;
510 if (!acc_signal(*
photon))
continue;
511 ph_trig.push_back(
photon);
515 if (ph_trig.size()>1) {
539 if (ret != StatusCode::SUCCESS) {
540 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) for systematic var. " << systConfig.
name() );
548 if (ret != StatusCode::SUCCESS) {
549 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) back to default.");
558 double trig_eff_data(1.);
560 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
561 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
565 std::vector<const xAOD::Electron*> elec_trig;
567 if (!acc_passOR(*
electron))
continue;
568 if (!acc_signal(*
electron))
continue;
572 std::vector<const xAOD::Muon*> muon_trig;
574 if (!acc_passOR(*
muon))
continue;
575 if (!acc_signal(*
muon))
continue;
576 muon_trig.push_back(
muon);
580 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
582 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
584 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
586 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
591 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" &&
matched) {
594 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" &&
matched) {
600 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
603 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger efficiency");
609 if (
isData())
return trig_eff_data;
610 else return trig_eff;
619 double trig_eff_data(1.);
621 if (trigExpr!=
"diPhoton") {
622 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
626 std::vector<const xAOD::Photon*> ph_trig;
628 if (!acc_passOR(*
photon))
continue;
629 if (!acc_signal(*
photon))
continue;
630 ph_trig.push_back(
photon);
634 if (ph_trig.size()>1) {
640 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
643 ATH_MSG_VERBOSE(
"OutOfValidityRange found for diphoton trigger efficiency");
649 if (
isData())
return trig_eff_data;
650 else return trig_eff;