ATLAS Offline Software
TrigConfChain.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // C/C++
6 #include <algorithm>
7 #include <sstream>
8 
12 
13 
14 //--------------------------------------------------------------------------------------
16  int counter)
17 {
18  // 16 bit word for encoded chain level and counter
19  uint16_t word = 0x0;
20 
21  if(level < 1 || level > 2) {
22  REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "Trig::getEncoded") << "Bad level";
23  return word;
24  }
25  if(counter < 0 || counter >= 16384) {
26  REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "Trig::getEncoded") << "Bad counter";
27  return word;
28  }
29 
30  word |= level << Bits::shiftLevel;
31  word |= counter;
32 
33  return word;
34 }
35 
36 //--------------------------------------------------------------------------------------
37 uint16_t Trig::getEncodedId(const std::string &level, int counter)
38 {
39  if(level == "L1") return Trig::getEncodedId(1, counter);
40  if(level == "HLT") return Trig::getEncodedId(2, counter);
41 
42  return 0;
43 }
44 
45 //--------------------------------------------------------------------------------------
47  :m_chain_name(""),
48  m_lower_name(""),
49  m_chain_id(0),
50  m_lower_id(0),
51  m_chain_counter(0),
52  m_lower_counter(0),
53  m_level(0),
54  m_prescale(0.0),
55  m_pass_through(0.0)
56 {
57 }
58 
59 //--------------------------------------------------------------------------------------
60 TrigConfChain::TrigConfChain(const std::string &chain_name,
61  int chain_counter,
62  unsigned int chain_id,
63  const std::string &level,
64  const std::string &lower_chain_name,
65  int lower_chain_counter,
66  unsigned int lower_chain_id,
67  float prescale,
68  float pass_through)
69  :m_chain_name(chain_name),
70  m_lower_name(lower_chain_name),
71  m_chain_id(chain_id),
72  m_lower_id(lower_chain_id),
73  m_chain_counter(0),
74  m_lower_counter(0),
75  m_level(0),
76  m_prescale(prescale),
77  m_pass_through(pass_through)
78 {
79  // Set counters
80  if(0 <= chain_counter && chain_counter < 16384) {
81  m_chain_counter = static_cast<unsigned int>(chain_counter);
82  }
83  else {
84  REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigConfChain") << "Bad chain counter";
85  }
86 
87  if(0 <= lower_chain_counter && lower_chain_counter < 16384) {
88  m_lower_counter = static_cast<unsigned int>(lower_chain_counter);
89  }
90 
91  // Set trigger level as integer
92  if (level == "L1") m_level = 1;
93  else if(level == "HLT") m_level = 2;
94  else {
95  REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigConfChain")
96  << "TrigConfChain ctor error! " << chain_name << ": bad level " << level;
97  }
98 }
99 
100 //--------------------------------------------------------------------------------------
101 TrigConfChain::TrigConfChain(const std::string &chain_name,
102  int chain_counter,
103  unsigned int chain_id,
104  float prescale)
105  :m_chain_name(chain_name),
106  m_lower_name(""),
107  m_chain_id(chain_id),
108  m_lower_id(0),
109  m_chain_counter(0),
110  m_lower_counter(0),
111  m_level(1),
112  m_prescale(prescale),
113  m_pass_through(0.0)
114 {
115  // Set counters
116  if(0 <= chain_counter && chain_counter < 16384) {
117  m_chain_counter = static_cast<unsigned int>(chain_counter);
118  }
119  else {
120  REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigConfChain") << "Bad chain counter";
121  }
122 }
123 
124 //--------------------------------------------------------------------------------------
125 void TrigConfChain::addStream(const std::string &name, float prescale)
126 {
127  //
128  // Save stream name and prescale
129  //
130  m_stream_name.push_back(name);
131  m_stream_prescale.push_back(prescale);
132 }
133 
134 //--------------------------------------------------------------------------------------
136 {
137  //
138  // Clear strings in this class and all vector classes
139  //
140  m_chain_name.clear();
141  m_lower_name.clear();
142  m_stream_name.clear();
143  m_stream_prescale.clear(); // prescale vector is meaningless without stream names
144  m_group.clear();
145  m_ebhypo_names.clear();
146 
147  for(unsigned int i = 0; i < m_signature.size(); ++i) m_signature[i].clearStrings();
148 }
149 
150 //--------------------------------------------------------------------------------------
152 {
153  //
154  // Return level id
155  //
156  if(m_level < 1 || m_level > 2) {
157  return 0;
158  }
159 
161 }
162 
163 //--------------------------------------------------------------------------------------
165 {
166  //
167  // Get lower chain encoded id
168  //
169  if(m_level == 2) {
171  }
172 
173  return 0;
174 }
175 
176 //--------------------------------------------------------------------------------------
177 const std::string TrigConfChain::getLevel() const
178 {
179  //
180  // Get trigger level as integer
181  //
182  if (m_level == 1) return "L1";
183  else if(m_level == 2) return "HLT";
184 
185  return "L0";
186 }
187 
188 //--------------------------------------------------------------------------------------
189 float TrigConfChain::getSignaturePrescale(const std::string &name) const
190 {
191  //
192  // Find stream prescale
193  //
194  if(m_stream_prescale.size() != m_stream_name.size()) {
195  REPORT_MESSAGE_WITH_CONTEXT(MSG::ERROR, "TrigConfChain") << "getSignaturePrescale - logic error!";
196  return 0.0;
197  }
198 
199  for(unsigned int i = 0; m_stream_name.size(); ++i) {
200  if(m_stream_name[i] == name) return m_stream_prescale[i];
201  }
202 
203  return 0.0;
204 }
205 
206 //--------------------------------------------------------------------------------------
207 bool TrigConfChain::matchOutputTE(const uint32_t te_id) const
208 {
209  //
210  // Match sequence to chain using signatures
211  //
212  for(std::vector<TrigConfSig>::const_iterator it = m_signature.begin();
213  it != m_signature.end(); ++it) {
214  if(it -> matchOutputTE(te_id)) {
215  return true;
216  }
217  }
218 
219  return false;
220 }
221 
222 //--------------------------------------------------------------------------------------
223 void TrigConfChain::print(std::ostream &os) const
224 {
225  os << str(*this) << std::endl;
226 }
227 
228 //--------------------------------------------------------------------------------------
229 std::string str(const TrigConfChain &o)
230 {
231  std::stringstream s;
232 
233  s << "TrigConfChain: "
234  << o.getLevel() << " " << o.getName()
235  << " PS=" << o.getPS() << " PT=" << o.getPT()
236  << " lower chain=" << o.getLowerName() << std::endl;
237 
238  s << " signatures: ";
239  for(unsigned int i = 0; i < o.getSignature().size(); ++i) {
240  s << str(o.getSignature()[i]) << " ";
241  }
242  s << std::endl;
243 
244  s << " streams: ";
245  for(unsigned int i = 0; i < o.getStream().size(); ++i) {
246  s << o.getStream()[i] << " ";
247  }
248  s << std::endl;
249 
250  s << " groups: ";
251  for(unsigned int i = 0; i < o.getGroup().size(); ++i) {
252  s << o.getGroup()[i] << " ";
253  }
254  s << std::endl;
255 
256  return s.str();
257 }
TrigConfChain::m_lower_counter
uint16_t m_lower_counter
Definition: TrigConfChain.h:119
TrigConfChain::m_level
uint8_t m_level
Definition: TrigConfChain.h:120
TrigConfChain::getGroup
const std::vector< std::string > & getGroup() const
Definition: TrigConfChain.h:95
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
TrigConfChain::getEncodedId
uint16_t getEncodedId() const
Definition: TrigConfChain.cxx:151
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TrigConfChain::getLowerEncodedId
uint16_t getLowerEncodedId() const
Definition: TrigConfChain.cxx:164
TrigConfChain::clearStrings
void clearStrings()
Definition: TrigConfChain.cxx:135
TrigConfChain::getName
const std::string & getName() const
Definition: TrigConfChain.h:72
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TrigConfChain::m_ebhypo_names
std::vector< std::string > m_ebhypo_names
Definition: TrigConfChain.h:129
TrigConfChain::getLevel
const std::string getLevel() const
Definition: TrigConfChain.cxx:177
TrigConfChain::matchOutputTE
bool matchOutputTE(uint32_t te_id) const
Definition: TrigConfChain.cxx:207
TrigConfChain::getPS
float getPS() const
Definition: TrigConfChain.h:88
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
TrigConfChain::getSignature
const std::vector< TrigConfSig > & getSignature() const
Definition: TrigConfChain.h:93
TrigConfChain::m_chain_name
std::string m_chain_name
Definition: TrigConfChain.h:114
TrigMonSeq.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TrigConfChain::m_chain_counter
uint16_t m_chain_counter
Definition: TrigConfChain.h:118
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
TrigConfChain
Definition: TrigConfChain.h:32
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigConfChain.h
TrigConfChain::m_stream_prescale
std::vector< float > m_stream_prescale
Definition: TrigConfChain.h:125
TrigConfChain::getPT
float getPT() const
Definition: TrigConfChain.h:90
TrigConfChain::m_group
std::vector< std::string > m_group
Definition: TrigConfChain.h:128
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
TrigConfChain::m_lower_name
std::string m_lower_name
Definition: TrigConfChain.h:115
TrigConfChain::print
void print(std::ostream &os=std::cout) const
Definition: TrigConfChain.cxx:223
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:345
TrigConfChain::m_stream_name
std::vector< std::string > m_stream_name
Definition: TrigConfChain.h:127
TrigConfChain::getCounter
uint16_t getCounter() const
Definition: TrigConfChain.h:77
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
errorcheck.h
Helpers for checking error return status codes and reporting errors.
TrigConfChain::m_signature
std::vector< TrigConfSig > m_signature
Definition: TrigConfChain.h:126
Trig::Bits::shiftLevel
const uint16_t shiftLevel
Definition: TrigConfChain.h:151
TrigConfChain::addStream
void addStream(const std::string &name, float prescale)
Definition: TrigConfChain.cxx:125
str
std::string str(const TrigConfChain &o)
Definition: TrigConfChain.cxx:229
TrigConfChain::getStream
const std::vector< std::string > & getStream() const
Definition: TrigConfChain.h:94
TrigConfChain::getLowerName
const std::string & getLowerName() const
Definition: TrigConfChain.h:74
TrigConfChain::getSignaturePrescale
float getSignaturePrescale(const std::string &name) const
Definition: TrigConfChain.cxx:189
test_pyathena.counter
counter
Definition: test_pyathena.py:15
Trig::getEncodedId
uint16_t getEncodedId(int level, int counter)
Definition: TrigConfChain.cxx:15
TrigConfChain::getLowerCounter
uint16_t getLowerCounter() const
Definition: TrigConfChain.h:80
TrigConfChain::TrigConfChain
TrigConfChain()
Definition: TrigConfChain.cxx:46
TrigConfChain::getLevelId
unsigned int getLevelId() const
Definition: TrigConfChain.h:84