19 const std::string&
name,
20 const IInterface* parent)
36 return StatusCode::SUCCESS;
41 ATH_MSG_DEBUG(
"==========================================" );
42 ATH_MSG_DEBUG(
"Start for Phase1 TrigThresholdDecisionTool" );
43 ATH_MSG_DEBUG(
"==========================================" );
52 return StatusCode::SUCCESS;
57 std::lock_guard guard{m_mutex};
58 if (m_isInitialized) {
59 return StatusCode::SUCCESS;
64 m_tgcFlag_decisions.clear();
65 m_rpcFlag_decisions.clear();
68 std::optional<ThrVecRef> menuThresholds = getMenuThresholds(l1Menu);
71 for (
const std::shared_ptr<TrigConf::L1Threshold>& thrBase : menuThresholds.value().get()) {
79 for (
unsigned flags=0;flags<8;flags++) {
91 for (
unsigned flags=0;flags<2;flags++){
96 m_isInitialized =
true;
97 return StatusCode::SUCCESS;
102 const ThrVec& menuThresholds,
108 const ThrVec& menuThresholds,
113 throw std::runtime_error(
"Error configuring the TrigThresholdDecisionTool from metadata!");
117 uint64_t thresholdsPattern = 0;
123 else roiTool = &(*m_tgcTool);
129 unsigned roi, sectorID;
143 bool F=
false,
C=
false,
H=
false, M=
false;
156 for (
const std::shared_ptr<TrigConf::L1Threshold>& thrBase : menuThresholds) {
162 if (thr->region().find(
"ALL") == std::string::npos &&
163 thr->region().find(
"BA") == std::string::npos)
continue;
167 if (
isExcludedRPCROI(muThrExtraInfo, thr->rpcExclROIList(), roi, sectorID, isSideC))
continue;
169 if (ptword >= thr->idxBarrel()) {
179 if (thr->region().find(
"ALL") == std::string::npos &&
180 thr->region().find(
"EC") == std::string::npos)
continue;
182 if (ptword >= thr->idxEndcap()) {
189 if (thr->region().find(
"ALL") == std::string::npos &&
190 thr->region().find(
"FW") == std::string::npos)
continue;
192 if (ptword >= thr->idxForward()) {
203 thresholdsPattern |= (1ull << thr->mapping());
208 return thresholdsPattern;
211 std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>,
bool> >
213 const EventContext& eventContext)
const {
218 if (!m_isInitialized){
220 throw std::runtime_error(
"Error configuring the TrigThresholdDecisionTool from metadata!");
226 l1Menu = l1MenuHandle.
cptr();
229 std::optional<ThrVecRef> menuThresholds = getMenuThresholds(*l1Menu);
230 std::optional<ExtraInfoRef> menuExtraInfo = getMenuThresholdExtraInfo(*l1Menu);
235 std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>,
bool> >
237 const ThrVec& menuThresholds,
242 throw std::runtime_error(
"Error configuring the TrigThresholdDecisionTool from metadata!");
246 const uint64_t pattern =
getPattern(dataWord, menuThresholds, menuExtraInfo);
249 std::vector<std::pair<std::shared_ptr<TrigConf::L1Threshold>,
bool> > threshold_decisions;
250 threshold_decisions.resize(menuThresholds.size());
251 for (
const std::shared_ptr<TrigConf::L1Threshold>& thr : menuThresholds) {
252 const bool decision = pattern & (1 << thr->mapping());
253 threshold_decisions[thr->mapping()] = std::make_pair(thr, decision);
255 return threshold_decisions;
263 throw std::runtime_error(
"Error configuring the TrigThresholdDecisionTool from metadata!");
268 std::string thrName=
"";
271 for (
unsigned idec=0;idec<decisions.size();++idec) {
272 if (!decisions[idec].second)
continue;
274 if(std::abs(
eta)<1.05){
275 thrValTmp = thr->ptBarrel();
278 thrValTmp = thr->ptEndcap();
280 if (thrValTmp > thrVal)
283 thrName = thr->name();
286 return std::make_pair(thrName, thrVal);
290 const std::string& rpcExclROIList,
292 const unsigned sectorID,
293 const bool isSideC)
const {
294 if (rpcExclROIList !=
"")
296 const std::map<std::string, std::vector<unsigned int> >& exclList = menuExtraInfo.
exclusionList(rpcExclROIList);
297 if (exclList.size() != 0)
300 std::string sectorName(
"B");
302 int sectorNumber=sectorID;
303 if (isSideC) sectorNumber += 32;
304 if (sectorNumber < 10) sectorName +=
'0';
305 sectorName += std::to_string(sectorNumber);
308 auto exclROIs = exclList.find(sectorName);
309 if (exclROIs != exclList.end())
311 for (
auto roi_itr=exclROIs->second.begin();roi_itr!=exclROIs->second.end();roi_itr++)
313 if (*roi_itr == roi)
return true;
326 auto previous_decisions = m_tgcFlag_decisions.find(tgcFlags);
327 if (previous_decisions == m_tgcFlag_decisions.end())
return false;
329 auto previous_decision_itr = previous_decisions->second.find(decision);
330 if (previous_decision_itr != previous_decisions->second.end())
return previous_decision_itr->pass;
338 auto previous_decisions = &m_tgcFlag_decisions[tgcFlags];
339 auto previous_decision_itr = previous_decisions->find(decision);
340 if (previous_decision_itr != previous_decisions->end())
return;
341 else if (tgcFlags ==
"") {
343 previous_decisions->insert(decision);
349 bool passedFlags =
false;
350 const auto* vec_flags = &parsed_flags.at(tgcFlags);
351 for (
auto or_itr = vec_flags->begin();or_itr!=vec_flags->end();or_itr++)
354 bool passedAnd =
true;
355 for (
auto and_itr = or_itr->begin();and_itr!=or_itr->end();and_itr++)
357 if (*and_itr ==
"F") passedAnd = passedAnd &&
F;
358 else if (*and_itr ==
"C") passedAnd = passedAnd &&
C;
359 else if (*and_itr ==
"H") passedAnd = passedAnd &&
H;
361 passedFlags = passedFlags || passedAnd;
364 decision.
pass = passedFlags;
365 previous_decisions->insert(decision);
373 auto previous_decisions = m_rpcFlag_decisions.find(rpcFlags);
374 if (previous_decisions == m_rpcFlag_decisions.end())
return false;
376 auto previous_decision_itr = previous_decisions->second.find(decision);
377 if (previous_decision_itr != previous_decisions->second.end())
return previous_decision_itr->pass;
385 auto previous_decisions = &m_rpcFlag_decisions[rpcFlags];
386 auto previous_decision_itr = previous_decisions->find(decision);
387 if (previous_decision_itr != previous_decisions->end())
return;
388 else if (rpcFlags ==
"") {
390 previous_decisions->insert(decision);
396 bool passedFlags =
false;
397 const auto* vec_flags = &parsed_flags.at(rpcFlags);
398 for (
auto or_itr = vec_flags->begin();or_itr!=vec_flags->end();or_itr++)
401 bool passedAnd =
true;
402 for (
auto and_itr = or_itr->begin();and_itr!=or_itr->end();and_itr++)
404 if (*and_itr ==
"M") passedAnd = passedAnd && M;
406 passedFlags = passedFlags || passedAnd;
409 decision.
pass = passedFlags;
410 previous_decisions->insert(decision);
421 auto [it, inserted] = parsed_flags.try_emplace(flags);
426 std::string_view stable_key = it->first;
428 std::vector<std::vector<std::string_view> > vec_flags;
429 for (
unsigned ior=0;ior<vec_ors.size();ior++)
433 it->second = std::move(vec_flags);
439 std::string shapedFlags = flags;
440 shapedFlags.erase(
std::remove_if(shapedFlags.begin(), shapedFlags.end(),
441 [](
unsigned char c) { return std::isspace(c); }), shapedFlags.end());
443 std::set<std::string> set_ors;
444 for(
const auto& ors : vec_ors){
446 std::set<std::string_view> set_ands;
447 for(
const auto& ands : vec_ands){
448 set_ands.insert(ands);
451 for(
const auto& ands : set_ands){
455 if(!aa.empty()) aa.pop_back();
456 set_ors.insert(std::move(aa));
459 for(
const auto& ors : set_ors){
463 if(!aa.empty()) aa.pop_back();
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
uint32_t roiWord() const
The "raw" RoI word describing the muon candidate.
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.