10 namespace MURoIThresholdsToolParams {
16 const std::string&
name,
33 return StatusCode::SUCCESS;
38 ATH_MSG_DEBUG(
"==========================================" );
39 ATH_MSG_DEBUG(
"Start for Phase1 TrigThresholdDecisionTool" );
40 ATH_MSG_DEBUG(
"==========================================" );
49 return StatusCode::SUCCESS;
54 std::lock_guard guard{m_mutex};
55 if (m_isInitialized) {
56 return StatusCode::SUCCESS;
59 m_parsed_flags.clear();
60 m_tgcFlag_decisions.clear();
61 m_rpcFlag_decisions.clear();
64 std::optional<ThrVecRef> menuThresholds = getMenuThresholds(l1Menu);
67 for (
const std::shared_ptr<TrigConf::L1Threshold>& thrBase : menuThresholds.value().get()) {
92 m_isInitialized =
true;
93 return StatusCode::SUCCESS;
98 const ThrVec& menuThresholds,
104 const ThrVec& menuThresholds,
109 throw std::runtime_error(
"Error configuring the TrigThresholdDecisionTool from metadata!");
119 else roiTool = &(*m_tgcTool);
125 unsigned roi, sectorID;
139 bool F=
false, C=
false,
H=
false, M=
false;
152 for (
const std::shared_ptr<TrigConf::L1Threshold>& thrBase : menuThresholds) {
158 if (thr->region().find(
"ALL") == std::string::npos &&
159 thr->region().find(
"BA") == std::string::npos)
continue;
163 if (
isExcludedRPCROI(muThrExtraInfo, thr->rpcExclROIList(), roi, sectorID, isSideC))
continue;
165 if (ptword >= thr->idxBarrel()) {
175 if (thr->region().find(
"ALL") == std::string::npos &&
176 thr->region().find(
"EC") == std::string::npos)
continue;
178 if (ptword >= thr->idxEndcap()) {
185 if (thr->region().find(
"ALL") == std::string::npos &&
186 thr->region().find(
"FW") == std::string::npos)
continue;
188 if (ptword >= thr->idxForward()) {
199 thresholdsPattern |= (1
ull << thr->mapping());
204 return thresholdsPattern;
207 std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>,
bool> >
209 const EventContext& eventContext)
const {
214 if (!m_isInitialized){
216 throw std::runtime_error(
"Error configuring the TrigThresholdDecisionTool from metadata!");
222 l1Menu = l1MenuHandle.
cptr();
225 std::optional<ThrVecRef> menuThresholds = getMenuThresholds(*l1Menu);
226 std::optional<ExtraInfoRef> menuExtraInfo = getMenuThresholdExtraInfo(*l1Menu);
231 std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>,
bool> >
233 const ThrVec& menuThresholds,
238 throw std::runtime_error(
"Error configuring the TrigThresholdDecisionTool from metadata!");
245 std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>,
bool> > threshold_decisions;
246 threshold_decisions.resize(menuThresholds.size());
247 for (
const std::shared_ptr<TrigConf::L1Threshold>& thr : menuThresholds) {
248 const bool decision =
pattern & (1 << thr->mapping());
249 threshold_decisions[thr->mapping()] = std::make_pair(thr, decision);
251 return threshold_decisions;
259 throw std::runtime_error(
"Error configuring the TrigThresholdDecisionTool from metadata!");
264 std::string thrName=
"";
267 for (
unsigned idec=0;idec<
decisions.size();++idec) {
269 std::shared_ptr<TrigConf::L1Threshold_MU> thr = std::static_pointer_cast<TrigConf::L1Threshold_MU>(
decisions[idec].
first);
270 if(std::abs(eta)<1.05){
276 if (thrValTmp > thrVal)
279 thrName = thr->
name();
282 return std::make_pair(thrName, thrVal);
286 const std::string& rpcExclROIList,
288 const unsigned sectorID,
289 const bool isSideC)
const {
290 if (rpcExclROIList !=
"")
292 const std::map<std::string, std::vector<unsigned int> >& exclList = menuExtraInfo.
exclusionList(rpcExclROIList);
293 if (exclList.size() != 0)
296 std::stringstream sectorName;
298 int sectorNumber=sectorID;
299 if (isSideC) sectorNumber += 32;
300 if (sectorNumber < 10) sectorName <<
"0";
301 sectorName << sectorNumber;
304 auto exclROIs = exclList.find(sectorName.str());
305 if (exclROIs != exclList.end())
307 for (
auto roi_itr=exclROIs->second.begin();roi_itr!=exclROIs->second.end();roi_itr++)
309 if (*roi_itr == roi)
return true;
322 auto previous_decisions = m_tgcFlag_decisions.find(tgcFlags);
323 if (previous_decisions == m_tgcFlag_decisions.end())
return false;
325 auto previous_decision_itr = previous_decisions->second.find(decision);
326 if (previous_decision_itr != previous_decisions->second.end())
return previous_decision_itr->pass;
334 auto previous_decisions = &m_tgcFlag_decisions[tgcFlags];
335 auto previous_decision_itr = previous_decisions->find(decision);
336 if (previous_decision_itr != previous_decisions->end())
return;
337 else if (tgcFlags ==
"") {
339 previous_decisions->insert(decision);
345 bool passedFlags =
false;
346 const std::vector<std::vector<std::string> >* vec_flags = &m_parsed_flags[tgcFlags];
347 for (
auto or_itr = vec_flags->begin();or_itr!=vec_flags->end();or_itr++)
350 bool passedAnd =
true;
351 for (
auto and_itr = or_itr->begin();and_itr!=or_itr->end();and_itr++)
353 if (*and_itr ==
"F") passedAnd = passedAnd &&
F;
354 else if (*and_itr ==
"C") passedAnd = passedAnd && C;
355 else if (*and_itr ==
"H") passedAnd = passedAnd &&
H;
357 passedFlags = passedFlags || passedAnd;
360 decision.
pass = passedFlags;
361 previous_decisions->insert(decision);
369 auto previous_decisions = m_rpcFlag_decisions.find(rpcFlags);
370 if (previous_decisions == m_rpcFlag_decisions.end())
return false;
372 auto previous_decision_itr = previous_decisions->second.find(decision);
373 if (previous_decision_itr != previous_decisions->second.end())
return previous_decision_itr->pass;
381 auto previous_decisions = &m_rpcFlag_decisions[rpcFlags];
382 auto previous_decision_itr = previous_decisions->find(decision);
383 if (previous_decision_itr != previous_decisions->end())
return;
384 else if (rpcFlags ==
"") {
386 previous_decisions->insert(decision);
392 bool passedFlags =
false;
393 const std::vector<std::vector<std::string> >* vec_flags = &m_parsed_flags[rpcFlags];
394 for (
auto or_itr = vec_flags->begin();or_itr!=vec_flags->end();or_itr++)
397 bool passedAnd =
true;
398 for (
auto and_itr = or_itr->begin();and_itr!=or_itr->end();and_itr++)
400 if (*and_itr ==
"M") passedAnd = passedAnd && M;
402 passedFlags = passedFlags || passedAnd;
405 decision.
pass = passedFlags;
406 previous_decisions->insert(decision);
414 if (m_parsed_flags.find(
flags) == m_parsed_flags.end())
417 std::vector<std::vector<std::string> > vec_flags;
418 for (
unsigned ior=0;ior<vec_ors.size();ior++)
420 vec_flags.push_back(
parseString(vec_ors[ior],
"&"));
422 m_parsed_flags[
flags] = std::move(vec_flags);
428 std::vector<std::string>
parsed;
432 if (
str.find(
sep) == std::string::npos)
440 if (
str.find(
sep,
pos) == std::string::npos)
445 std::string sub =
str.substr(
pos, newPos-
pos);
454 std::string shapedFlags =
flags;
455 shapedFlags.erase(std::remove_if(shapedFlags.begin(),shapedFlags.end(),::isspace),shapedFlags.end());
456 std::vector<std::string> vec_ors =
parseString(shapedFlags,
"|");
457 std::set<std::string> set_ors;
458 for(
const auto& ors : vec_ors){
459 std::vector<std::string> vec_ands =
parseString(ors,
"&");
460 std::set<std::string> set_ands;
461 for(
const auto& ands : vec_ands){
462 set_ands.insert(ands);
465 for(
const auto& ands : set_ands){
469 std::string bb =
aa.substr(0,
aa.size()-1);
473 for(
const auto& ors : set_ors){
477 std::string bb =
aa.substr(0,
aa.size()-1);