ATLAS Offline Software
Loading...
Searching...
No Matches
HLTPrescaleSet.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <iomanip>
6#include <iostream>
7
12
13using namespace std;
14using namespace TrigConf;
15
20
22TrigConf::HLTPrescaleSet::setPrescale(const HLTPrescale& sc, unsigned int chain_counter, HLTLevel level) {
23 ScalingMap_t& map = m_scalers[static_cast<unsigned int>(level)];
24 ScalingMap_t::iterator s = map.find(chain_counter);
25 if(s==map.end()) {
26 s = map.insert(ScalingMap_t::value_type(chain_counter, sc)).first;
27 } else {
28 s->second = sc;
29 }
30 return s->second;
31}
32
33
34bool
36 const ScalingMap_t& map_for_level = m_scalers[static_cast<unsigned int>(level)];
37 return !map_for_level.empty() && map_for_level.count(counter)>0;
38}
39
40
42TrigConf::HLTPrescaleSet::getPrescale(unsigned int chain_counter, HLTLevel level) const {
43 const ScalingMap_t& map = m_scalers[static_cast<unsigned int>(level)];
44 ScalingMap_t::const_iterator s = map.find(chain_counter);
45 if(s==map.end()) {
46 cerr << "HLTPrescaleSet::getPrescale: chain counter " << chain_counter << " in level " << level << " has no prescales" << endl;
47 throw std::runtime_error("HLTPrescaleSet::getPrescale: chain has no prescales defined");
48 }
49 return s->second;
50}
51
53TrigConf::HLTPrescaleSet::thePrescale(unsigned int chain_counter, HLTLevel level) {
54 ScalingMap_t& map = m_scalers[static_cast<unsigned int>(level)];
55 ScalingMap_t::iterator s = map.find(chain_counter);
56 if(s==map.end())
57 s = map.insert(ScalingMap_t::value_type(chain_counter, HLTPrescale())).first;
58
59 return s->second;
60}
61
62
63//________________________________________________________________________________
64void
65TrigConf::HLTPrescaleSet::setIOV(uint32_t start_run, uint32_t start_lb, uint32_t end_run, uint32_t end_lb ) {
66 m_iovstart = start_run; m_iovstart <<= 32; m_iovstart += start_lb;
67 m_iovend = end_run; m_iovend <<= 32; m_iovend += end_lb;
68}
69
70//________________________________________________________________________________
71void
72TrigConf::HLTPrescaleSet::setIOV(uint64_t start, uint64_t end ) {
73 m_iovstart = start;
74 m_iovend = end;
75}
76
77//________________________________________________________________________________
78// note that end_run/end_lb specifies the first lb for which the HLT PSS is not valid anymore (COOL design)
79void
80TrigConf::HLTPrescaleSet::getIOV(uint32_t& start_run, uint32_t& start_lb, uint32_t& end_run, uint32_t& end_lb ) const {
81 start_lb = m_iovstart & 0xFFFFFFFF;
82 start_run = m_iovstart>>32;
83 end_lb = m_iovend & 0xFFFFFFFF;
84 end_run = m_iovend>>32;
85}
86
87//________________________________________________________________________________
88bool
89TrigConf::HLTPrescaleSet::isValid(uint32_t run, uint32_t lb ) const {
90 unsigned long long iovtime = run;
91 iovtime <<= 32;
92 iovtime += lb;
93
94 return iovtime >= m_iovstart && iovtime<m_iovend; // m_iovend is not part of the IOV
95}
96
97//________________________________________________________________________________
98void
100 for(unsigned int i = 0; i<3; ++i )
101 m_scalers[i].clear();
102}
103
104//________________________________________________________________________________
105void TrigConf::HLTPrescaleSet::print(const std::string& indent, unsigned int detail) const {
106 if(detail>=1) {
107 cout << indent << "HLTPrescaleSet "; printNameIdV();
108 cout << indent << " L2 scalers " << size(L2) << endl
109 << indent << " EF scalers " << size(EF) << endl
110 << indent << " HLT scalers " << size(HLT) << endl;
111 if(detail>=3) {
112 cout.unsetf(ios_base::floatfield);
113 for(unsigned int i=L2; i<=HLT; i++) {
114 HLTLevel level = HLTLevel(i);
115 if(size(level)==0) continue;
116 if(level!=HLT)
117 cout << indent << " " << (level==L2?"L2":"EF") << " prescales:" << endl;
118
119 const ScalingMap_t& map = m_scalers[static_cast<unsigned int>(level)];
120
121 for(uint cc=0; cc<8192;cc++) {
122 auto s_iter = map.find(cc);
123 if(s_iter==map.end()) continue;
124 const HLTPrescale& s = s_iter->second;
125 cout << indent << " Chain counter: " << setw(4) << cc
126 << ", prescale: " << setw(4) << s.prescale()
127 << ", pass-through: " << setw(4) << s.pass_through();
128 if( s.getRerunPrescales().size()>0 ) {
129 cout << ", rerun prescales: ";
130 for( HLTPrescale::PrescaleMap_t::value_type ps: s.getRerunPrescales())
131 cout << ps.first << ": " << ps.second << ", ";
132 }
133 if( s.getStreamPrescales().size()>0 ) {
134 cout << ", stream prescales: ";
135 for( HLTPrescale::PrescaleMap_t::value_type str_ps: s.getStreamPrescales())
136 cout << str_ps.first << ": " << str_ps.second << ", ";
137 }
138 cout << endl;
139 }
140 }
141 }
142 }
143}
144
145
146//________________________________________________________________________________
147std::ostream&
148TrigConf::operator<<(std::ostream & o, const TrigConf::HLTPrescaleSet & c) {
149 o << "HLTPrescaleSet " << c.name();
150 if(c.id()>0 || c.version()>0) o << " (id=" << c.id() << "/v=" << c.version() << ")";
151 o << endl;
152 if(c.comment()!="") o << "Comment : " << c.comment() << endl;
153
154 for(unsigned int i = TrigConf::L2; i <= TrigConf::HLT; i++) {
156 if(c.size(level)==0) continue;
157 o << (level==TrigConf::L2?"L2":"EF") << " prescales:" << endl;
158 for(const TrigConf::HLTPrescaleSet::ScalingMap_t::value_type& sc: c.getPrescales(level)) {
159 o << "Chain counter: " << setw(4) << sc.first
160 << ", prescale: " << setw(4) << sc.second.prescale()
161 << ", pass-through: " << setw(4) << sc.second.pass_through()
162 << endl;
163 }
164 }
165 o << "---------------------------------------------------------- " << endl;
166 return o;
167}
168
170 stringstream s;
171 s << *this;
172 return s.str();
173}
unsigned int uint
static Double_t sc
HLT chain configuration information.
void print(const std::string &indent="", unsigned int detail=1) const override
print the prescale set
size_t size(HLTLevel level=HLT) const
std::array< ScalingMap_t, 3 > m_scalers
void setIOV(uint32_t start_run, uint32_t start_lb, uint32_t end_run, uint32_t end_lb)
sets the IOV of the prescale set
HLTPrescaleSet()
default constructor
void getIOV(uint32_t &start_run, uint32_t &start_lb, uint32_t &end_run, uint32_t &end_lb) const
gets the IOV of the prescale set
bool isValid(uint32_t run, uint32_t lb) const
checks if run/lb are in the current IOV
std::string __str__() const override
bool hasPrescale(unsigned int counter, TrigConf::HLTLevel level=HLT) const
HLTPrescale & thePrescale(unsigned int chain_counter, HLTLevel level)
HLTPrescale & setPrescale(const HLTPrescale &sc, unsigned int chain_counter, HLTLevel level=HLT)
const HLTPrescale & getPrescale(unsigned int chain_counter, HLTLevel level=HLT) const
std::unordered_map< unsigned int, HLTPrescale > ScalingMap_t
std::ostream & indent(std::ostream &o, int lvl, int size) const
void printNameIdV(const std::string &indent="") const
int lb
Definition globals.cxx:23
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
std::ostream & operator<<(std::ostream &os, const TrigConf::IsolationLegacy &iso)
Definition run.py:1
STL namespace.