20#ifndef XAOD_STANDALONE
48 else if(year == 2016 && rn >= 296939 && rn <= 302872 )
return IsMETTrigPassed(
"HLT_xe90_mht_L1XE50",j400_OR);
49 else if(year == 2016 && rn >= 302919 && rn <= 303892 )
return IsMETTrigPassed(
"HLT_xe100_mht_L1XE50",j400_OR);
50 else if(year == 2016 && rn >= 303943)
return IsMETTrigPassed(
"HLT_xe110_mht_L1XE50",j400_OR);
51 else if(year == 2017 && rn >= 325713 && rn <= 331975 )
return IsMETTrigPassed(
"HLT_xe110_pufit_L1XE55",
false,
"L1_XE55");
52 else if(year == 2017 && rn >= 332303 )
return IsMETTrigPassed(
"HLT_xe110_pufit_L1XE50",
false);
53 else if(year == 2018 && rn >= 348885 && rn <= 350013 )
return IsMETTrigPassed(
"HLT_xe110_pufit_xe70_L1XE50",
false);
54 else if(year == 2018 && rn >= 350067 )
return IsMETTrigPassed(
"HLT_xe110_pufit_xe65_L1XE50",
false);
55 else if(year == 2022)
return IsMETTrigPassed(
"HLT_xe65_cell_xe90_pfopufit_L1XE50",
false);
56 else if(year == 2023)
return IsMETTrigPassed(
"HLT_xe65_cell_xe90_pfopufit_L1XE50",
false);
57 else if(year == 2024)
return IsMETTrigPassed(
"HLT_xe65_cell_xe105_nn_L1jXE100",
false,
"L1_jXE100");
68 bool HLT_noalg_L1J400 =
m_trigDecTool->isPassed(
"HLT_noalg_L1J400");
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() ) {
89 return m_checkedTriggers[triggerName] = cg->getListOfTriggers().size() != 0;
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] () {
164 if (
evtStore()->retrieve(cont, pair.second) ) {
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)();
241 for(
const auto *it = i1; it != i2; ++it) {
251 this->
TrigMatch(p, items.begin(), items.end());
258 for(
const auto& item: items) {
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;
447 std::vector<const xAOD::Muon*> muon_trig;
451 muon_trig.push_back(
muon);
454 bool matched =
false;
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;
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;
603 std::vector<const xAOD::Muon*> muon_trig;
607 muon_trig.push_back(
muon);
610 bool matched =
false;
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;
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;
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
ServiceHandle< StoreGateSvc > & evtStore()
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ OutOfValidityRange
Input object is out of validity range.
@ Ok
The correction was done successfully.
Class to wrap a set of SystematicVariations.
std::string name() const
returns: the systematics joined into a single string.
const T * front() const
Access the first element in the collection as an rvalue.
bool empty() const noexcept
Returns true if the collection is empty.
Helper class to provide type-safe access to aux data.
asg::AnaToolHandle< Trig::TrigDecisionTool > m_trigDecTool
asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > m_trigGlobalEffCorrTool_multiLep
bool IsMETTrigPassed(unsigned int runnumber=0, bool j400_OR=false) const override final
asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > m_trigGlobalEffCorrTool_diPhoton
bool isData() const override final
unsigned int GetRunNumber() const override final
void GetTriggerTokens(std::string, std::vector< std::string > &, std::vector< std::string > &, std::vector< std::string > &, std::vector< std::string > &, std::vector< std::string > &, std::vector< std::string > &, std::vector< std::string > &) const
asg::AnaToolHandle< Trig::IMatchingTool > m_trigMatchingTool
const Trig::ChainGroup * GetTrigChainGroup(const std::string &) const override final
float GetTrigPrescale(const std::string &) const override final
int treatAsYear(const int runNumber=-1) const override final
std::vector< std::string > GetTriggerOR(const std::string &trigExpr) const
CP::SystematicSet m_currentSyst
bool IsTrigPassed(const std::string &, unsigned int condition=TrigDefs::Physics) const override final
double GetTriggerGlobalEfficiency(const xAOD::ElectronContainer &electrons, const xAOD::MuonContainer &muons, const std::string &trigExpr="diLepton") override final
bool IsTrigMatched(const xAOD::IParticle *part, const std::string &tr_item) override final
double GetTriggerGlobalEfficiencySF(const xAOD::ElectronContainer &electrons, const xAOD::MuonContainer &muons, const std::string &trigExpr="diLepton") override final
std::mutex m_triggerCacheMutex
Trig::FeatureContainer GetTriggerFeatures(const std::string &chainName="EF_.*", unsigned int condition=TrigDefs::Physics) const
asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > m_trigGlobalEffCorrTool_diLep
bool emulateHLT(const std::string &triggerName) const
double GetTriggerGlobalEfficiencySFsys(const xAOD::ElectronContainer &electrons, const xAOD::MuonContainer &muons, const CP::SystematicSet &systConfig, const std::string &trigExpr="diLepton") override final
bool isTrigInTDT(std::scoped_lock< std::mutex > &lock, const std::string &triggerName) const
void TrigMatch(const xAOD::IParticle *p, std::initializer_list< std::string >::iterator, std::initializer_list< std::string >::iterator) override final
Class providing the definition of the 4-vector interface.
float ex() const
Get the x component of the missing energy.
float ey() const
Get the y component of the missing energy.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
static std::vector< uint32_t > runnumber
static const SG::ConstAccessor< char > acc_signal("signal")
static const SG::Decorator< char > dec_trigmatched("trigmatched")
static const SG::ConstAccessor< char > acc_passOR("passOR")
helper namespace for calculating deltaR for unknown object types
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
TrigMissingETContainer_v1 TrigMissingETContainer
DataVector of TrigMissingET - the current version.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Muon_v1 Muon
Reference the current persistent version:
Photon_v1 Photon
Definition of the current "egamma version".
setBGCode setTAP setLVL2ErrorBits bool
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
Electron_v1 Electron
Definition of the current "egamma version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.