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