ATLAS Offline Software
Loading...
Searching...
No Matches
HLTChainList.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
10
13#include "TrigConfL1Data/Menu.h"
14
16
17#include <iostream>
18#include <algorithm>
19#include <iterator>
20
21using namespace std;
23
26
27
28TrigConf::HLTChainList::HLTChainList( const vector<HLTChain*>& chainList ) {
29 copy(chainList.begin(), chainList.end(), std::inserter(*this, begin()));
30}
31
32
36
38 for(HLTChain* ch : *this) {
39 delete ch;
40 }
41 HLTChainContainer::clear();
42}
43
44bool
46 pair<iterator, bool> ins = insert(chain);
47 if(!ins.second)
48 throw runtime_error("Can't insert chain '" + chain->name() + "', because a uniqueness constraint is violated");
49 return ins.second;
50}
51
52
53
55TrigConf::HLTChainList::chain( const std::string& name ) const {
56 const index<name_hash>::type& byname = get<name_hash>();
58 if(ch == byname.end()) return 0;
59 return *ch;
60}
61
62
64TrigConf::HLTChainList::chain( unsigned int chaincounter, HLTLevel level ) const {
65 const index<counter>::type& bycounter = get<counter>();
66 index<counter>::type::const_iterator ch = bycounter.find(boost::make_tuple(chaincounter,level));
67 if(ch == bycounter.end()) return 0;
68 return *ch;
69}
70
71
72void
74 for(HLTChain *ch: *this) {
75 if(ch->level_enum() == HLTLevel::HLT ) {
76 // merged menu
77 if (pss->hasPrescale( ch->chain_counter(), HLTLevel::HLT ) ) {
78 // merged prescales (Run 2)
79 const HLTPrescale& sc = pss->getPrescale( ch->chain_counter(), HLTLevel::HLT );
80 ch->set_prescales( sc );
81 } else {
82 // prescale set has not been merged yet (LS 1)
83 if(ch->mergeCounter.l2==0 && ch->mergeCounter.ef==0) {
84 throw runtime_error("Merged HLT chain has no info about L2 or EF counter");
85 } else if(ch->mergeCounter.l2==0) {
86 const HLTPrescale& efps = pss->getPrescale( ch->mergeCounter.ef, HLTLevel::EF );
87 ch->set_prescales( efps );
88 } else if(ch->mergeCounter.ef==0) {
89 const HLTPrescale& l2ps = pss->getPrescale( ch->mergeCounter.ef, HLTLevel::L2 );
90 ch->set_prescales( l2ps );
91 } else {
92 const HLTPrescale& l2ps = pss->getPrescale( ch->mergeCounter.l2, HLTLevel::L2 );
93 const HLTPrescale& efps = pss->getPrescale( ch->mergeCounter.ef, HLTLevel::EF );
94 HLTTEUtils::mergeL2EFPrescales( ch, l2ps, efps);
95 }
96 }
97 } else {
98 // menu not merged
99 const HLTPrescale& sc = pss->getPrescale( ch->chain_counter(), str2lvl(ch->level()) );
100 ch->set_prescales( sc );
101 }
102 }
103}
104
105
108 HLTPrescaleSet* pss = new HLTPrescaleSet();
109 for(HLTChain *ch : *this)
110 pss->setPrescale(ch->prescales(), ch->chain_counter(), ch->level_enum());
111 return pss;
112}
113
114
115
116//________________________________________________________________________________
117void
119 if(ctpcfg==0)
120 throw runtime_error("setL2LowerChainCounter: no CTPConfig object available");
121
122 const TrigConf::Menu& menu = ctpcfg->menu();
123
124 std::map<std::string,int> ctpFromName;
125 for(const TriggerItem* item : menu.itemVector())
126 ctpFromName[item->name()] = item->ctpId();
127
128 for(HLTChain* ch : *this) {
129 if(ch->level() == "EF") continue;
130 std::string low_chain_names = ch->lower_chain_name();
131 std::erase(low_chain_names,' ');
132 vector<string> low_chain_names_V = tokenize(low_chain_names,",");
133 std::vector<int> lccs;
134 for(const std::string& lowerChainName : low_chain_names_V)
135 lccs.push_back(ctpFromName[lowerChainName]);
136 ch->set_lower_chain_counter(low_chain_names_V.size()==1 ? lccs[0] : -1);
137 ch->set_lower_chain_counters(lccs);
138 }
139}
140
141
142// fill the lower chain counter for all EF chains
143void
145 for(HLTChain *ch : *this) {
146 if(ch->level()!="EF" || ch->lower_chain_name()=="") continue;
147 HLTChain * l2ch = chain(ch->lower_chain_name());
148 if(l2ch==0) {
149 cerr << "ERROR: Did not find lower chain name '" << ch->lower_chain_name() << "' for chain '" << ch->chain_name() << "'" << endl;
150 continue;
151 }
152 ch->set_lower_chain_counter( l2ch->chain_counter() );
153 }
154}
155
158 DiffStruct * ds = new DiffStruct("CHAIN_LIST");
159 for(HLTChain* ch : *this) {
160 HLTChain *o_ch = o->chain(ch->name());
161 if(o_ch) {
162 ds->addSub( ch->compareTo(o_ch) );
163 } else {
164 ds->addLeftOnlySub( "CHAIN", ch->name() );
165 }
166 }
167 for(HLTChain* o_ch : *o) {
168 const HLTChain *ch = chain(o_ch->name());
169 if(!ch)
170 ds->addRightOnlySub( "CHAIN", o_ch->name() );
171 }
172 if(ds->empty()) {
173 delete ds; ds=0;
174 }
175 return ds;
176}
177
178
179void
180TrigConf::HLTChainList::print(const std::string& indent, unsigned int detail) const {
181 if(detail>=1) {
182 cout << indent << "HLTChainList has " << size() << " chains" << endl;
183 if(detail>=2) {
184 for(HLTChain* ch : *this)
185 ch->print(indent + " ", detail);
186 cout << indent << "- ---------------------------------------------------------- " << endl;
187 }
188 }
189}
190
191
192std::ostream &
193TrigConf::operator<<(std::ostream & o, const TrigConf::HLTChainList & cl) {
194 o << "- -- HLTChainList [" << cl.size() << " chains] -------------------------------- " << std::endl;
195 for(TrigConf::HLTChain* ch : cl)
196 o << *ch;
197 o << "- ---------------------------------------------------------- " << std::endl;
198 return o;
199}
200
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
static Double_t sc
size_t size() const
Number of registered mappings.
void clear()
Empty the pool.
const Menu & menu() const
Definition CTPConfig.h:39
list of all HLT chains in a trigger menu
bool addHLTChain(HLTChain *ch)
adds an HLTChain to the menu
void setL2LowerChainCounter(const CTPConfig *ctpcfg)
HLTChain * chain(const std::string &chainname) const
access the chain by name returns null-pointer if chain not found
HLTChainList()
default constructor
void applyPrescaleSet(const HLTPrescaleSet *pss)
set prescales of all chains
void print(const std::string &indent="", unsigned int detail=1) const
accessors to list of chains, for backward compatibility, use HLTChainList directly
~HLTChainList()
default destructor
DiffStruct * compareTo(const HLTChainList *o) const
HLTPrescaleSet * extractPrescaleSet() const
extract prescales from all chains
HLT chain configuration information.
HLT chain configuration information.
bool hasPrescale(unsigned int counter, TrigConf::HLTLevel level=HLT) const
HLTPrescale & setPrescale(const HLTPrescale &sc, unsigned int chain_counter, HLTLevel level=HLT)
const HLTPrescale & getPrescale(unsigned int chain_counter, HLTLevel level=HLT) const
static void mergeL2EFPrescales(TrigConf::HLTChain *hltchain, const TrigConf::HLTPrescale &l2ps, const TrigConf::HLTPrescale &efps)
make the sidebar many part of the config
Definition hcg.cxx:554
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
HLTLevel str2lvl(const std::string &level)
Definition HLTLevel.h:14
std::ostream & operator<<(std::ostream &os, const TrigConf::IsolationLegacy &iso)
Definition index.py:1
STL namespace.