17#include "boost/regex.hpp"
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;
101 if (PASSTHROUGH) {chainRESULT=
true;}
104 if (RAW && !PRESCALED) {chainRESULT=
true;}
106 if (RAW) {chainRESULT=
true;}
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) {
134 if(
L1Result(item,condition))
return true;
139 if (fitem==
nullptr) {
144 <<
" vetoed = " << fitem->
isVeto()
145 <<
" name = " << std::setw(35) << fitem->
name());
164 if (cchain==
nullptr){
165 ATH_MSG_WARNING(
" Lower chain name used by: " << name <<
" is not in the configuration ");
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"){
211 ATH_MSG_ERROR(
"Incorrect use of Express_passed bit. Please use isPassedBits() and test for TrigDefs::Express_passed in the returned bit-map.");
222 unsigned int chainRESULT = 0;
223 if (chain.empty())
return chainRESULT;
225 if (fchain==
nullptr)
return chainRESULT;
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;
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);
288 }
else if (ch->level()==
"L2") {
291 }
else if (ch->level()==
"HLT") {
295 all.push_back(RESULT);
299 all.push_back(
L1Bits(item->name()) );
309 for (
unsigned int r : all) {
319 if (fchain==
nullptr)
continue;
321 errorCode = errorCode > ec ? errorCode : ec;
327 if (chain==
"")
return 0.;
331 ATH_MSG_WARNING(
"Configuration for the chain: " << chain <<
" not known");
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) {
380 ATH_MSG_WARNING(
"Configuration for the item: " << item <<
" not known");
381 return std::numeric_limits<float>::quiet_NaN();
385 float itemprescale =
cgm().item_prescale(fitem->
ctpId());
386 if ( itemprescale < 1) itemprescale = 0;
395 if (fitem==
nullptr) {
396 ATH_MSG_WARNING(
"Configuration for the item: " << item <<
" not known");
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);
419 const std::string& hltChainName = ch->chain_name();
420 float chainRESULT =
HLTPrescale(hltChainName,condition);
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)<1e-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;
476 streams.insert(s->stream());
479 return {streams.begin(), streams.end()};
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()};
600 if (!(confChains && confItems) )
return;
606 boost::regex compiled(pat);
610 if ( boost::regex_match(ch->chain_name().c_str(), what, compiled) ) {
616 if ( boost::regex_match( item->name().c_str(), what, compiled) ) {
626 bool found_it =
false;
629 if (ch->chain_name() == what) {
641 if (item->name() == what) {
652 ATH_MSG_WARNING(
"Explicitly requested '" << what <<
"' be added to a ChainGroup"
653 <<
" but this item or chain could not be found in the menu");
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) {
725const Trig::FeatureContainer
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());
774 std::set< std::string >::iterator setstrit;
776 for (setstrit = threshold_names.begin(); setstrit != threshold_names.end(); ++setstrit, ++tesit) {
783 ATH_MSG_DEBUG(
"features: features container size: "<< f.getCombinations().size());
795 while (combination.
isValid()) {
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Helpers for treating a class enum as a bitmask.
This class represents one chain of signatures, i.e.
const TrigConf::HLTChain * getConfigChain() const
get underlying ConfigChain
HLT::ErrorCode getErrorCode() const
return this Chain's most severe error code (from execution)
unsigned int getChainCounter() const
return the unique identifier of this Chain (uint)
int getChainStep() const
return the current step of execution
bool isPassedThrough() const
is chain passed through ?
bool isPrescaled() const
is chain prescaled ?
const std::string & getChainName() const
return the Chain name (string)
bool isResurrected() const
is chain resurrected ?
bool chainPassedRaw() const
Iterator used to loop over multi-particle combinations.
bool isValid() const
Validity check for the iterator.
The definition of error codes in HLT.
TrigCompositeUtils::DecisionID numeric() const
numeric ID
void getAllOfType(const te_id_type id, std::vector< TriggerElement * > &output, const bool activeOnly=true) const
The query returning a collection of all TriggerElements if name is given.
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
bool isPassedAfterPrescale() const
bool isPassedBeforePrescale() const
const std::string & name() const
bool isPassedAfterVeto() const
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
bool empty() const
Test if the key is blank.
list of all HLT chains in a trigger menu
HLT chain configuration information.
const std::string & lower_chain_name() const
const std::string & level() const
HLT signature configuration information.
std::vector< HLTTriggerElement * > & outputTEs()
accessor to the list of trigger elements
HLT stream configuration information.
HLT trigger element configuration information.
static HLTHash string2hash(const std::string &, const std::string &category="TE")
hash function translating TE names into identifiers
bool assert_decision() const
checks if new event arrived with the decision Need to use before any call to CacheGlobalMemory.
const HLT::TrigNavStructure * navigation() const
float correlatedL1Prescale(const std::string &item) const
const std::vector< std::string > & patterns() const
std::vector< std::string > getListOfStreams() const
std::vector< std::string > getListOfThresholds() const
const Trig::CacheGlobalMemory & cgm() const
const FeatureContainer features(unsigned int condition=TrigDefs::Physics) const
returns all features related to given chain group of HLT chains or L1 items Note: This does not yet w...
std::vector< std::string > getListOfGroups() const
HLT::ErrorCode error() const
returns most severe error in the chains composing that chain group for L1 it is just OK If there is s...
unsigned int isPassedBits() const
returns bits (OR ed) of the chain group Meaning of the returned bits can be understood by using masks...
std::vector< bool > isPassedForEach(unsigned int condition=TrigDefs::Physics) const
return vector with isPassed decision for each chain
bool isCorrelatedL1items(const std::string &item) const
ChainGroup(const std::vector< std::string > &triggerNames, Trig::CacheGlobalMemory &parent)
void addAlias(const std::string &alias)
adds alias (sort understandabel name) to the group
std::vector< std::string > m_names
names of trigger derived from patterns & current configuration
void update(const TrigConf::HLTChainList *confChains, const TrigConf::ItemContainer *confItems, TrigDefs::Group prop=TrigDefs::Group::Default)
float HLTPrescale(const std::string &chain, unsigned int condition) const
float getPrescale(unsigned int condition=TrigDefs::Physics) const
returns prescale factor for chain group with single chain in returns real prescale factor for real ch...
const Trig::ChainGroup & operator+(const Trig::ChainGroup &rhs)
bool L1Result(const std::string &item, unsigned int condition) const
unsigned int L1Bits(const std::string &item) const
bool operator!=(const Trig::ChainGroup &rhs)
float calculatePrescale(unsigned int condition=TrigDefs::Physics)
std::vector< const TrigConf::HLTChain * > m_confChains
unsigned int HLTBits(const std::string &chain, const std::string &level, const TrigCompositeUtils::DecisionIDContainer &passExpress) const
const std::vector< std::string > & names() const
names of triggers within chain group
std::vector< std::vector< std::string > > getListOfTriggerElements() const
std::vector< std::string > m_patterns
patterns with which the CG was constructed
bool isPassed(unsigned int condition=TrigDefs::Physics) const
tells if chain group passed
Trig::CacheGlobalMemory & m_cgm
void appendFeatures(std::vector< std::vector< HLT::TriggerElement * > > &tes, FeatureContainer &fc) const
float L1Prescale(const std::string &item, unsigned int condition) const
std::vector< unsigned int > isPassedBitsForEach() const
return result of isPassedBits for each chain in the group
const Trig::CacheGlobalMemory & cgm_assert() const
bool operator==(const Trig::ChainGroup &rhs)
std::vector< std::string > getListOfSignatures() const
std::string getLowerName(const std::string &EFname) const
std::vector< std::vector< TrigConf::HLTTriggerElement * > > getHLTTriggerElements() const
bool HLTResult(const std::string &chain, unsigned int condition) const
std::vector< const TrigConf::TriggerItem * > m_confItems
std::vector< std::string > getListOfTriggers() const
is a connector between chains and object It store single combination of trigger elements.
void addWithChecking(const Combination &newComb)
add new combination to the container checking for overlap
static asg::AsgTool *s_logger ATLAS_THREAD_SAFE
void name(const std::string &n)
std::vector< std::string > patterns
void collectCombinations(const TrigConf::HLTChain *conf, const CacheGlobalMemory &cgm, FeatureContainer &fc, unsigned int condition)
bool allActive(const std::vector< TriggerElement * > &tes)
constexpr std::enable_if_t< is_bitmask_v< E >, bool > test(E lhs, E rhs)
Convenience function to test bits in a class enum bitmask.
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
static const ErrorCode OK(Action::CONTINUE)
xAOD::TrigComposite Decision
const Decision * getExpressTerminusNode(const DecisionContainer &container)
Returns the express-accept navigation node from a collection or nullptr if missing.
std::set< DecisionID > DecisionIDContainer
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
boost::multi_index::multi_index_container< TriggerItem *, boost::multi_index::indexed_by< boost::multi_index::random_access<>, boost::multi_index::ordered_unique< boost::multi_index::identity< TriggerItem > >, boost::multi_index::ordered_unique< boost::multi_index::tag< tag_ctpid >, boost::multi_index::const_mem_fun< TriggerItem, int, &TriggerItem::ctpId > >, boost::multi_index::hashed_unique< boost::multi_index::tag< tag_name_hash >, boost::multi_index::const_mem_fun< TrigConfData, const std::string &, &TrigConfData::name > > > > ItemContainer
static const unsigned int L1_isPassedBeforePrescale
static const unsigned int L1_isPassedAfterPrescale
static const unsigned int L2_passedRaw
static const unsigned int allowResurrectedDecision
static const unsigned int requireDecision
static const unsigned int L2_passThrough
static const unsigned int EF_prescaled
static const unsigned int L2_prescaled
Group
Properties of a chain group.
@ NoRegex
Do not use regular expressions.
static const unsigned int EF_passedRaw
static const unsigned int L1_isPassedAfterVeto
static const unsigned int Express_passed
static const unsigned int Physics
static const unsigned int enforceLogicalFlow
static const unsigned int EF_resurrected
static const unsigned int L2_resurrected
static const unsigned int EF_passThrough
static const unsigned int passedThrough
static const unsigned int eventAccepted
The common trigger namespace for trigger analysis tools.
std::vector< std::string > convertStringToVector(const std::string &triggerNames)
makes a split of list of chains into the vector of chains
std::vector< std::string > keyWrap(const std::vector< std::string > &triggerNames)
normalizes the list of triggers (patterns) by sorting and uniquing them