20#ifndef XAOD_STANDALONE
42 else if(year == 2016 && rn >= 296939 && rn <= 302872 )
return IsMETTrigPassed(
"HLT_xe90_mht_L1XE50",j400_OR);
43 else if(year == 2016 && rn >= 302919 && rn <= 303892 )
return IsMETTrigPassed(
"HLT_xe100_mht_L1XE50",j400_OR);
44 else if(year == 2016 && rn >= 303943)
return IsMETTrigPassed(
"HLT_xe110_mht_L1XE50",j400_OR);
46 else if(year == 2017 && rn >= 325713 && rn <= 331975 )
return IsTrigPassed(
"HLT_xe110_pufit_L1XE55");
47 else if(year == 2017 && rn >= 332303 )
return IsTrigPassed(
"HLT_xe110_pufit_L1XE50");
48 else if(year == 2018 && rn >= 348885 && rn <= 350013 )
return IsTrigPassed(
"HLT_xe110_pufit_xe70_L1XE50");
49 else if(year == 2018 && rn >= 350067 )
return IsTrigPassed(
"HLT_xe110_pufit_xe65_L1XE50");
50 else if(year == 2022 || year == 2023)
return IsTrigPassed(
"HLT_xe65_cell_xe90_pfopufit_L1XE50");
51 else if(year == 2024 || year == 2025 || year == 2026)
return IsTrigPassed(
"HLT_xe65_cell_xe105_nn_L1jXE100");
62 bool HLT_noalg_L1J400 =
m_trigDecTool->isPassed(
"HLT_noalg_L1J400");
63 if (!L1_pass && j400_OR && HLT_noalg_L1J400) {
78 const std::string& triggerName)
const
80 auto mapItr = m_checkedTriggers.find(triggerName);
81 if ( mapItr == m_checkedTriggers.end() ) {
83 return m_checkedTriggers[triggerName] = cg->getListOfTriggers().size() != 0;
86 return mapItr->second;
94 auto funcItr = m_metTriggerFuncs.find(triggerName);
95 if (funcItr != m_metTriggerFuncs.end() )
96 return funcItr->second();
99 if (triggerName.substr(0,6) !=
"HLT_xe") {
100 ATH_MSG_ERROR(
"Requested trigger " << triggerName <<
" isn't a MET trigger! (HLT MET items should begin with 'HLT_xe'). Will return false." );
105 std::vector<std::pair<int, std::string> > hypos;
106 std::string temp(triggerName);
109 auto pos = temp.find(
"_AND_");
110 std::string itemName = temp.substr(0, pos);
112 if (pos == std::string::npos)
115 temp = temp.substr(pos + 5);
117 std::regex expr(
"HLT_xe([[:digit:]]+)_?(mht|pufit|pueta|tc_lcw|)_?(?:L1XE([[:digit:]]+)|)");
119 if (!std::regex_match(itemName, sm, expr) ) {
120 ATH_MSG_WARNING(
"Regex reading for item " << itemName <<
" (" << triggerName <<
") failed! Will be ignored!" );
124 ATH_MSG_WARNING(
"Regex failed to capture the right groups for item " << itemName <<
" (" << triggerName <<
") failed! Will be ignored!" );
125 for (
unsigned int ii = 0; ii < sm.size(); ++ii) {
131 std::string algKey = sm[2];
132 std::string metContBaseName =
"HLT_xAOD__TrigMissingETContainer_TrigEFMissingET";
133 if (algKey.empty()) hypos.push_back(std::make_pair(
threshold, metContBaseName) );
134 else if (algKey ==
"mht") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"_mht") );
135 else if (algKey ==
"pufit") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"_topocl_PUC") );
136 else if (algKey ==
"pueta") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"_topocl_PS") );
137 else if (algKey ==
"tc_lcw") hypos.push_back(std::make_pair(
threshold, metContBaseName+
"topocl") );
139 ATH_MSG_DEBUG(
"Container: " << hypos.back().second <<
", Threshold: " << hypos.back().first );
141 if (sm[3] !=
"" && sm[3] !=
"50") {
142 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" );
146 while (!temp.empty());
150 std::function<
bool()> lambda;
151 bool hasRequired =
true;
152 if (hypos.empty()) lambda = [] () {
return false;};
154 for (
const auto& pair : hypos) {
156 auto lambda_hypo = [
this, pair] () {
158 if (
evtStore()->retrieve(cont, pair.second) ) {
159 if (cont->
empty())
return false;
160 float ex = cont->
front()->
ex() * 0.001;
161 float ey = cont->
front()->
ey() * 0.001;
162 float met = std::sqrt(ex*ex + ey*ey);
163 return met > pair.first;
171 lambda = [lambda, lambda_hypo] () {
172 return lambda() && lambda_hypo();
176 lambda = lambda_hypo;
186 m_metTriggerFuncs[triggerName] = lambda;
187 return m_metTriggerFuncs.at(triggerName)();
190 std::vector<std::string> replacementTriggers({
"HLT_xe110_mht_L1XE50",
"HLT_xe100_mht_L1XE50",
"HLT_xe90_mht_L1XE50",
"HLT_xe70_mht"});
191 for (
const std::string& trigName : replacementTriggers) {
193 ATH_MSG_WARNING(
"Trigger " << triggerName <<
" not available and direct emulation impossible! Will use " << trigName <<
" instead!");
194 m_metTriggerFuncs[triggerName] = [
this, trigName] () {
197 return m_metTriggerFuncs.at(triggerName)();
200 ATH_MSG_ERROR(
"Cannot find the trigger in the menu, direct emulation is impossible and no replacement triggers are available! Will return false" );
201 m_metTriggerFuncs.at(triggerName) = [] () {
return false;};
202 return m_metTriggerFuncs.at(triggerName)();
235 for(
const auto *it = i1; it != i2; ++it) {
245 this->
TrigMatch(p, items.begin(), items.end());
252 for(
const auto& item: items) {
253 auto result =
static_cast<int>(this->
IsTrigMatched(p, item));
262 for(
const auto& p : v) {
269 for(
const auto& p : v) {
276 for(
const auto p : *v) {
283 for(
const auto p : *v) {
316 static const std::string delOR =
"_OR_";
317 std::vector<std::string> trigchains = {};
318 std::string newtrigExpr = TString(trigExpr).Copy().ReplaceAll(
"||",delOR).Data();
319 newtrigExpr = TString(trigExpr).Copy().ReplaceAll(
" ",
"").Data();
322 while ((pos = newtrigExpr.find(delOR)) != std::string::npos) {
323 trigchains.push_back(
"HLT_"+newtrigExpr.substr(0, pos) );
324 newtrigExpr.erase(0, pos + delOR.length());
326 if(pos==std::string::npos)
327 trigchains.push_back(
"HLT_"+newtrigExpr);
332 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 {
336 static const std::string del15 =
"_2015_";
337 static const std::string del16 =
"_2016_";
338 static const std::string del17 =
"_2017_";
341 std::string token15, token16, token17, token18, token22, token23, token24;
344 if ( (pos = trigExpr.find(del15)) != std::string::npos) {
345 trigExpr.erase(0, pos + del15.length());
348 while ((pos = trigExpr.find(del16)) != std::string::npos) {
349 token15 = trigExpr.substr(0, pos);
350 token16 = trigExpr.erase(0, pos + del16.length() + del17.length() - 1);
358 size_t p22 = trigExpr.find(
"2022");
359 size_t p23 = trigExpr.find(
"2023");
360 size_t p24 = trigExpr.find(
"2024");
362 auto next_pos = [&](
size_t self) {
363 size_t next = std::string::npos;
366 if (p23 > self && p23 < next) next = p23;
367 if (p24 > self && p24 < next) next = p24;
369 else if (self == p23) {
370 if (p22 > self && p22 < next) next = p22;
371 if (p24 > self && p24 < next) next = p24;
373 else if (self == p24) {
374 if (p22 > self && p22 < next) next = p22;
375 if (p23 > self && p23 < next) next = p23;
382 if (p22 != std::string::npos) {
size_t end = next_pos(p22); token22 = trigExpr.substr(p22, end - p22);}
383 if (p23 != std::string::npos) {
size_t end = next_pos(p23); token23 = trigExpr.substr(p23, end - p23);}
384 if (p24 != std::string::npos) {
size_t end = next_pos(p24); token24 = trigExpr.substr(p24, end - p24);}
387 std::string* toks[] = { &token22, &token23, &token24 };
388 for (
auto t : toks) {
389 while (!t->empty() && t->back() ==
'_') t->pop_back();
394 if(token15.empty()) token15 = trigExpr;
395 if(token16.empty()) token16 = trigExpr;
396 if(token17.empty()) token17 = trigExpr;
397 if(token18.empty()) token18 = trigExpr;
400 if(token22.empty()) token22 = trigExpr;
401 if(token23.empty()) token23 = trigExpr;
402 if(token24.empty()) token24 = trigExpr;
429 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
430 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
434 std::vector<const xAOD::Electron*> elec_trig;
441 std::vector<const xAOD::Muon*> muon_trig;
445 muon_trig.push_back(
muon);
448 bool matched =
false;
449 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
451 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
453 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
455 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
460 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" && matched) {
463 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" && matched) {
469 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger SF");
472 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger SF");
486 if (trigExpr ==
"diLepton") {
488 if (ret != StatusCode::SUCCESS) {
489 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) for systematic var. " << systConfig.
name() );
493 if (trigExpr ==
"multiLepton") {
495 if (ret != StatusCode::SUCCESS) {
496 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) for systematic var. " << systConfig.
name() );
504 if (trigExpr ==
"diLepton") {
506 if (ret != StatusCode::SUCCESS) {
507 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (dilepton trigger) back to default.");
510 if (trigExpr ==
"multiLepton") {
512 if (ret != StatusCode::SUCCESS) {
513 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (multi-lepton trigger) back to default.");
527 if (trigExpr!=
"diPhoton") {
532 std::vector<const xAOD::Photon*> ph_trig;
536 ph_trig.push_back(
photon);
540 if (ph_trig.size()>1) {
564 if (ret != StatusCode::SUCCESS) {
565 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) for systematic var. " << systConfig.
name() );
573 if (ret != StatusCode::SUCCESS) {
574 ATH_MSG_ERROR(
"Cannot configure TrigGlobalEfficiencyCorrectionTool (diphoton trigger) back to default.");
583 double trig_eff_data(1.);
585 if (trigExpr!=
"multiLepton" && trigExpr!=
"diLepton") {
586 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
590 std::vector<const xAOD::Electron*> elec_trig;
597 std::vector<const xAOD::Muon*> muon_trig;
601 muon_trig.push_back(
muon);
604 bool matched =
false;
605 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton") {
607 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
609 }
else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton") {
611 ATH_MSG_ERROR (
"trigGlobEffCorrTool::Trigger matching could not be checked, interrupting execution.");
616 if ((elec_trig.size()+muon_trig.size())>1 && trigExpr==
"diLepton" && matched) {
619 else if ((elec_trig.size()+muon_trig.size())>2 && trigExpr==
"multiLepton" && matched) {
625 ATH_MSG_ERROR(
"Failed to retrieve multi-lepton trigger efficiency");
628 ATH_MSG_VERBOSE(
"OutOfValidityRange found for multi-lepton trigger efficiency");
634 if (
isData())
return trig_eff_data;
635 else return trig_eff;
644 double trig_eff_data(1.);
646 if (trigExpr!=
"diPhoton") {
647 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
651 std::vector<const xAOD::Photon*> ph_trig;
655 ph_trig.push_back(
photon);
659 if (ph_trig.size()>1) {
665 ATH_MSG_ERROR(
"Failed to retrieve diphoton trigger efficiency");
668 ATH_MSG_VERBOSE(
"OutOfValidityRange found for diphoton trigger efficiency");
674 if (
isData())
return trig_eff_data;
675 else return trig_eff;
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
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.
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
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
static const SG::Decorator< char > dec_trigmatched("trigmatched")
static const SG::ConstAccessor< char > acc_signal("signal")
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.