17 #include "boost/regex.hpp"
18 #include "boost/range/adaptor/reversed.hpp"
44 m_patterns(triggerNames),
49 std::vector< std::string >
v;
54 return *(cgm().createChainGroup(
v));
79 bool chainRESULT =
false;
80 if (
chain.empty())
return chainRESULT;
82 if (fchain==
nullptr)
return chainRESULT;
92 if (~
condition & TrigDefs::allowResurrectedDecision) {
100 if (
condition & TrigDefs::passedThrough) {
101 if (PASSTHROUGH) {chainRESULT=
true;}
103 if (
condition & TrigDefs::requireDecision) {
104 if (RAW && !PRESCALED) {chainRESULT=
true;}
105 if (
condition & TrigDefs::allowResurrectedDecision ) {
106 if (RAW) {chainRESULT=
true;}
111 if (
condition & TrigDefs::eventAccepted) {
112 if ( (RAW && !PRESCALED) || PASSTHROUGH) {chainRESULT=
true;}
122 <<
" name = " << std::setw(35) << fchain->
getChainName()
123 <<
" result = " << chainRESULT);
131 if (
item.empty())
return r;
132 if (
item.find(
',')!=std::string::npos) {
139 if (fitem==
nullptr) {
144 <<
" vetoed = " << fitem->
isVeto()
145 <<
" name = " << std::setw(35) << fitem->
name());
149 if (
condition & TrigDefs::allowResurrectedDecision)
164 if (cchain==
nullptr){
177 if (
chain.level()==
"EF") {
178 const std::string& nexttwo = getLowerName(
chain.chain_name());
182 }
else if (
chain.level()==
"L2") {
185 }
else if (
chain.level()==
"HLT"){
196 result.reserve(m_confChains.size() + m_confItems.size());
210 if (
condition & TrigDefs::Express_passed) {
211 ATH_MSG_ERROR(
"Incorrect use of Express_passed bit. Please use isPassedBits() and test for TrigDefs::Express_passed in the returned bit-map.");
215 return ( std::any_of(m_confChains.cbegin(), m_confChains.cend(),
217 std::any_of(m_confItems.cbegin(), m_confItems.cend(),
222 unsigned int chainRESULT = 0;
223 if (
chain.empty())
return chainRESULT;
225 if (fchain==
nullptr)
return chainRESULT;
227 if (fchain->
chainPassedRaw()) chainRESULT = chainRESULT | TrigDefs::L2_passedRaw;
228 if (fchain->
isPassedThrough()) chainRESULT = chainRESULT | TrigDefs::L2_passThrough;
229 if (fchain->
isPrescaled()) chainRESULT = chainRESULT | TrigDefs::L2_prescaled;
230 if (fchain->
isResurrected()) chainRESULT = chainRESULT | TrigDefs::L2_resurrected;
232 if (fchain->
chainPassedRaw()) chainRESULT = chainRESULT | TrigDefs::EF_passedRaw;
233 if (fchain->
isPassedThrough()) chainRESULT = chainRESULT | TrigDefs::EF_passThrough;
234 if (fchain->
isPrescaled()) chainRESULT = chainRESULT | TrigDefs::EF_prescaled;
235 if (fchain->
isResurrected()) chainRESULT = chainRESULT | TrigDefs::EF_resurrected;
238 chainRESULT = chainRESULT | TrigDefs::Express_passed;
246 if (
item.empty())
return r;
247 if (
item.find(
',')!=std::string::npos) {
254 if (fitem==
nullptr)
return r;
266 if (navRHK && !navRHK->
empty()) {
270 if (expressTerminusNode) {
276 std::vector<unsigned int>
all;
277 all.reserve(m_confChains.size() + m_confItems.size());
281 unsigned int RESULT = HLTBits(
ch->chain_name(),
ch->level(), passExpress);
283 if (
ch->level()==
"EF") {
284 const std::string& nexttwo = getLowerName(
ch->chain_name());
285 RESULT = RESULT | HLTBits(nexttwo,
"L2", passExpress);
286 RESULT = RESULT |
L1Bits(getLowerName(nexttwo));
288 }
else if (
ch->level()==
"L2") {
289 RESULT = RESULT |
L1Bits(getLowerName(
ch->chain_name()));
291 }
else if (
ch->level()==
"HLT") {
292 RESULT = RESULT |
L1Bits(getLowerName(
ch->chain_name()));
295 all.push_back(RESULT);
307 const std::vector<unsigned int>
all = isPassedBitsForEach();
309 for (
unsigned int r :
all) {
318 const HLT::Chain* fchain = cgm_assert().chain(
ch->chain_name());
319 if (fchain==
nullptr)
continue;
321 errorCode = errorCode > ec ? errorCode : ec;
327 if (
chain==
"")
return 0.;
332 return std::numeric_limits<float>::quiet_NaN();
334 float chainRESULT = fchain->
prescale();
344 if( (
item ==
"L1_MU20,L1_MU21") || (
item ==
"L1_MU21,L1_MU20") )
return true;
349 if( (
item ==
"L1_MU20,L1_MU21") || (
item ==
"L1_MU21,L1_MU20") ) {
351 auto l1mu20 = cgm().config_item(
"L1_MU20");
352 if (l1mu20==
nullptr) {
354 return std::numeric_limits<float>::quiet_NaN();
356 float l1mu20ps = cgm().item_prescale(l1mu20->ctpId());
358 auto l1mu21 = cgm().config_item(
"L1_MU21");
359 if (l1mu21==
nullptr) {
361 return std::numeric_limits<float>::quiet_NaN();
363 float l1mu21ps = cgm().item_prescale(l1mu21->ctpId());
365 if( (l1mu20ps < 1.0) && (l1mu21ps < 1.0) )
return 0.0;
366 if( (l1mu20ps < 1.0) )
return l1mu21ps;
367 if( (l1mu21ps < 1.0) )
return l1mu20ps;
368 if(l1mu20ps == 1.0)
return 1.0;
375 if (
item.empty())
return 0;
377 if(
item.find(
',')==std::string::npos) {
379 if (fitem==
nullptr) {
381 return std::numeric_limits<float>::quiet_NaN();
385 float itemprescale = cgm().item_prescale(fitem->
ctpId());
386 if ( itemprescale < 1) itemprescale = 0;
388 }
else if(isCorrelatedL1items(
item)) {
389 return correlatedL1Prescale(
item);
395 if (fitem==
nullptr) {
397 return std::numeric_limits<float>::quiet_NaN();
399 float itemprescale = cgm().item_prescale(fitem->
ctpId());
400 if ( itemprescale < 1) itemprescale = 0;
401 minprescale = (minprescale&&(minprescale<itemprescale)?minprescale:itemprescale);
415 bool singleTrigger = (m_confChains.size()+m_confItems.size()==1);
419 const std::string& hltChainName =
ch->chain_name();
420 float chainRESULT = HLTPrescale(hltChainName,
condition);
422 if (
condition & TrigDefs::enforceLogicalFlow) {
424 if (
ch->level()==
"EF") {
425 const std::string& hltChainNameL2 = getLowerName(hltChainName);
426 const std::string& l1ItemName = getLowerName(hltChainNameL2);
427 chainRESULT *= HLTPrescale(hltChainNameL2,
condition);
428 chainRESULT *= L1Prescale(l1ItemName,
condition);
429 if(l1ItemName.find(
',')!=std::string::npos) singleTrigger=
false;
431 }
else if (
ch->level()==
"L2") {
432 const std::string& l1ItemName = getLowerName(hltChainName);
433 chainRESULT *= L1Prescale(l1ItemName,
condition);
434 if(l1ItemName.find(
',')!=std::string::npos) singleTrigger=
false;
436 }
else if (
ch->level()==
"HLT") {
437 const std::string& l1ItemName = getLowerName(hltChainName);
438 chainRESULT *= L1Prescale(l1ItemName,
condition);
439 if(l1ItemName.find(
',')!=std::string::npos and !isCorrelatedL1items(l1ItemName) ) singleTrigger=
false;
443 if (singleTrigger)
return chainRESULT;
445 const bool UNPRESCALED = (fabs(chainRESULT-1.0)<1
e-5);
447 if (UNPRESCALED)
return 1.0;
452 const std::string& l1ItemName =
item->name();
453 const float itemRESULT = L1Prescale(l1ItemName,
condition);
454 if(l1ItemName.find(
',')!=std::string::npos) singleTrigger=
false;
456 if (singleTrigger)
return itemRESULT;
458 const bool UNPRESCALED = (itemRESULT==1);
460 if (UNPRESCALED)
return 1.0;
473 std::set< std::string >
streams;
492 v.assign(
ch->groups().begin(),
ch->groups().end() );
502 std::set< std::string >
sig;
505 sig.insert(
s->label());
508 return {
sig.begin(),
sig.end()};
520 std::stack<const TrigConf::TriggerItemNode*> nodes;
524 nodes.push(
item->topNode() );
525 while (!nodes.empty()) {
526 node = nodes.top(); nodes.pop();
529 if (
node->isThreshold()) {
530 if (
node->triggerThreshold()) {
532 if (!
node->triggerThreshold()->
name().empty())
533 s.insert(
node->triggerThreshold()->
name());
534 }
else if (!
node->thresholdName().empty()) {
536 s.insert(
node->thresholdName());
540 nodes.push(childnode);
547 return {
s.begin(),
s.end()};
557 std::set< std::vector< std::string > > tes;
558 std::vector< std::string >
t;
564 t.push_back( te->name());
569 return {tes.begin(), tes.end()};
579 std::set< std::vector< TrigConf::HLTTriggerElement* > > tes;
583 tes.insert(
s->outputTEs());
586 return {tes.begin(), tes.end()};
595 m_confChains.clear();
600 if (!(confChains && confItems) )
return;
604 for(
const std::string&
pat : m_patterns) {
610 if ( boost::regex_match(
ch->chain_name().c_str(),
what, compiled) ) {
611 m_confChains.push_back(
ch);
616 if ( boost::regex_match(
item->name().c_str(),
what, compiled) ) {
617 m_confItems.push_back(
item);
624 for(
const std::string&
what : m_patterns) {
626 bool found_it =
false;
629 if (
ch->chain_name() ==
what) {
630 m_confChains.push_back(
ch);
642 m_confItems.push_back(
item);
653 <<
" but this item or chain could not be found in the menu");
659 m_names.reserve(m_confChains.size() + m_confItems.size());
663 m_prescale = calculatePrescale(TrigDefs::Physics);
671 using namespace Trig;
673 bool allActive(
const std::vector<TriggerElement*>& tes) {
675 if (te->getActiveState() ==
false)
692 if ( previous_sig && previous_sig->
outputTEs().size() !=
sig->outputTEs().size() )
696 std::vector<std::vector<HLT::TriggerElement*> > tes(
sig->outputTEs().size());
707 while (combination.
isValid()) {
711 if (!
allActive(*combination) || last_step) {
739 std::vector< std::vector< HLT::TriggerElement*> > tes;
740 std::vector< std::vector< HLT::TriggerElement*> >
::iterator tesit;
744 std::set< std::string > threshold_names;
745 std::stack<const TrigConf::TriggerItemNode*> nodes;
747 nodes.push(
item->topNode() );
750 while (!nodes.empty()) {
755 if (
node->isThreshold()) {
756 if (
node->triggerThreshold()) {
758 if (!
node->triggerThreshold()->
name().empty())
759 threshold_names.insert(
node->triggerThreshold()->
name());
760 }
else if (!
node->thresholdName().empty()) {
762 threshold_names.insert(
node->thresholdName());
766 nodes.push(childnode);
772 tes.resize(threshold_names.size());
776 for (setstrit = threshold_names.begin(); setstrit != threshold_names.end(); ++setstrit, ++tesit) {
780 appendFeatures(tes,
f);
783 ATH_MSG_DEBUG(
"features: features container size: "<<
f.getCombinations().size());
795 while (combination.
isValid()) {