18 #include <unordered_set>
24 if(ch1!=0 && ch2!=0) {
return *ch1 < *ch2; }
25 else {
return ch1==0; }
34 m_lower_chain_name(
""),
35 m_lower_chain_counter(0),
36 m_lower_chain_hash_id(0),
44 const string& lower_chain_name,
45 int lower_chain_counter,
46 vector<HLTSignature*>&& signatureList ) :
48 m_chain_counter ( chain_counter),
49 m_chain_version ( chain_version),
51 m_lower_chain_name ( lower_chain_name ),
52 m_lower_chain_counter( lower_chain_counter ),
53 m_EB_after_step (-1 ),
54 m_HLTSignatureList ( std::move(signatureList) )
67 m_chain_hash_id ( o.m_chain_hash_id ),
68 m_chain_counter ( o.m_chain_counter ),
69 m_chain_version ( o.m_chain_version ),
70 m_level ( o.m_level ),
71 m_lower_chain_name ( o.m_lower_chain_name ),
72 m_lower_chain_counter ( o.m_lower_chain_counter ),
73 m_lower_chain_counters( o.m_lower_chain_counters ),
74 m_EB_after_step ( o.m_EB_after_step ),
75 m_prescales ( o.m_prescales ),
76 m_groups ( o.m_groups )
105 return m_lower_chain_name.find(
',')!=std::string::npos;
109 const std::vector<int>&
111 return m_lower_chain_counters;
116 std::vector<std::string>
125 vector<unsigned int>
ids;
126 vector<std::string>
names =
parse(m_lower_chain_name);
127 for (
unsigned i =
names.size();
i-- ; ) {
146 m_HLTTriggerTypeList = trigList;
155 m_lower_chain_name = lower_chain_name;
162 m_HLTSignatureList = sigList;
163 createSignatureLabels();
177 sig->set_signature_counter(
sig->signature_counter() + shift );
184 std::stringstream
os;
185 os << chain_name() <<
"_" << signature->signature_counter();
186 signature->set_label(
os.str() );
197 const string &
s(
stream->name());
198 if(
auto p =
s.find(
'.'); (
p != string::npos) &&
226 cerr <<
"TrigConf::HLTChain WARNING Can not set prescale for stream '" +
streamName +
"' since chain '" +
name() +
"' does not write to that stream. Available are" << endl;
227 for(
auto stream : m_streams) {
228 cout <<
" Available are " <<
stream->name() << endl;
239 if(m_streams_map.find(
stream->name()) != m_streams_map.end())
240 throw runtime_error(
string(
"Can not add stream '")+
stream->name() +
"' to chain '" +
name() +
"', since it exists already.");
242 m_streams_orig.push_back(
stream);
244 m_streams.push_back(
cp);
245 m_streams_map.insert(std::pair<std::string, HLTStreamTag*>(
cp->name(),
cp));
248 std::pair<bool, float> sps =
prescales().getStreamPrescale(
cp->name());
250 cp->set_prescale(sps.second);
258 std::unordered_set<HLTStreamTag *> deleted;
260 if (deleted.insert(
s).second)
263 if (deleted.insert(
s).second)
265 for (
auto &
p : m_streams_map)
266 if (deleted.insert(
p.second).second)
268 m_streams_orig.clear();
270 m_streams_map.clear();
273 std::pair<bool, float>
275 std::unordered_map<std::string, HLTStreamTag*>::const_iterator
i = m_streams_map.find(
streamName);
276 bool found = (
i!=m_streams_map.cend());
277 float ps =
found ?
i->second->prescale() : 0;
278 return std::make_pair(
found,ps);
282 string orderLowerChainNames(
const string& vstr) {
283 if(vstr.find(
',')==string::npos)
return vstr;
284 string vstr_loc = vstr;
285 vstr_loc.erase(
remove(vstr_loc.begin(),vstr_loc.end(),
' '), vstr_loc.end());
286 vector<string> splstr =
split(vstr_loc,
"," );
287 sort(splstr.begin(),splstr.end());
289 for(
const string&
s : splstr)
300 ds->check(
"lower_chain_name", orderLowerChainNames(lower_chain_name()), orderLowerChainNames(o->
lower_chain_name()) );
322 xmlfile <<
" <CHAIN chain_counter=\"" << chain_counter() <<
"\" "
323 <<
"chain_name=\"" <<
name() <<
"\" "
324 <<
"level=\"" << m_level <<
"\" "
325 <<
"lower_chain_name=\"" << m_lower_chain_name <<
"\" "
326 <<
"pass_through=\"" <<
prescales().pass_through() <<
"\" "
327 <<
"prescale=\"" <<
prescales().prescale() <<
"\">"
330 xmlfile <<
" <PRESCALES"
331 <<
" chain_counter=\"" << chain_counter() <<
"\""
332 <<
" level=\"" << m_level <<
"\""
333 <<
" prescale=\"" <<
prescales().prescale() <<
"\""
334 <<
" pass_through=\"" <<
prescales().pass_through() <<
"\"";
336 xmlfile <<
"/>" << endl;
338 xmlfile <<
">" << endl;
340 xmlfile <<
" <RERUN_PRESCALES target=\"" << rerun_ps.first <<
"\" prescale=\"" << rerun_ps.second <<
"\"/>" << endl;
341 xmlfile <<
" </PRESCALES>" << endl;
344 xmlfile <<
" <TRIGGERTYPE_LIST/>" << endl;
346 xmlfile <<
" <STREAMTAG_LIST>" << endl;
348 streamTag->writeXML(xmlfile);
349 xmlfile <<
" </STREAMTAG_LIST>" << endl;
351 xmlfile <<
" <GROUP_LIST>" << endl;
352 for (
const string&
group : m_groups)
353 xmlfile <<
" <GROUP name=\"" <<
group <<
"\"/>" << endl;
354 xmlfile <<
" </GROUP_LIST>" << endl;
356 xmlfile <<
" <SIGNATURE_LIST>" << endl;
358 signature->writeXML(xmlfile);
359 xmlfile <<
" </SIGNATURE_LIST>" << endl;
361 xmlfile <<
" </CHAIN>" << endl;
369 int dp = cout.precision();
370 cout.unsetf(ios_base::floatfield);
374 cout <<
indent <<
"HLTChain chainid = " << chain_counter() <<
" ";
377 cout <<
" | counter: " << chain_counter();
379 cout <<
" | " <<
level()
380 <<
" | lower chain: " << lower_chain_name()
381 <<
" | lower chain counter: " << lower_chain_counter();
383 cout <<
" | CTP input: " << lower_chain_name()
384 <<
" | lower chain counter: " << lower_chain_counter();
386 cout <<
" | prescale: " << prescale()
387 <<
" | pass through: " << pass_through();
389 cout <<
" | rerun: " <<
prescales().getRerunPrescales().size() <<
" [ ";
391 cout << rrps.first <<
":" << rrps.second <<
" ";
392 cout <<
"]" << std::endl;
396 cout <<
indent <<
" Groups : " <<
groups().size() <<
" [ ";
398 cout <<
"]" << std::endl;
400 cout <<
indent <<
" Trigger type bits : " << triggerTypeList().size() <<
" [ ";
402 cout <<
"]" << std::endl;
407 cout <<
indent <<
" Steps : " << signatureList().size() << endl;
409 cout <<
indent <<
"---------------------------------------------------------- " << endl;
420 int dp = o.precision();
421 o <<
"- -- HLTChain printout ------------------------------------- " << endl;
422 o <<
"- -- name='" <<
c.name()
423 <<
"' [v " <<
c.m_chain_version <<
"]"
424 <<
" | counter: " <<
c.m_chain_counter
425 <<
" | level: " <<
c.m_level
426 <<
" | lower_chain_name: " <<
c.m_lower_chain_name
427 <<
" | lower_chain_counter: " <<
c.m_lower_chain_counter;
428 if (
c.m_level ==
"HLT") o <<
" | EB_after_step: " <<
c.m_EB_after_step;
431 o.setf(std::ios::fixed, std::ios::floatfield);
432 o <<
" | prescale: " <<
c.prescale()
433 <<
" | pass_through: " <<
c.pass_through();
434 o <<
" | rerun: " <<
c.prescales().getRerunPrescales().size() <<
" [ ";
439 set<std::string>::const_iterator
group =
c.m_groups.begin();
440 o <<
"- -- Chain groups : " <<
c.m_groups.size() <<
" [ ";
442 o <<
"]" << std::endl;
444 vector<TrigConf::HLTTriggerType*>::const_iterator
triggerType =
c.m_HLTTriggerTypeList.begin();
445 o <<
"- -- Trigger type bits : " <<
c.m_HLTTriggerTypeList.size() <<
" [ ";
447 o <<
"]" << std::endl;
450 vector<TrigConf::HLTStreamTag*>::const_iterator streamTag =
c.m_streams.begin();
451 o <<
"- -- Trigger streams : " <<
c.m_streams.size() << std::endl;
452 for (; streamTag !=
c.m_streams.end(); ++streamTag) o << *(*streamTag);
454 vector<TrigConf::HLTSignature*>::const_iterator signature =
c.m_HLTSignatureList.begin();
455 for (; signature !=
c.m_HLTSignatureList.end(); ++signature) o << *(*signature);
456 o <<
"- ---------------------------------------------------------- " << endl;