ATLAS Offline Software
Loading...
Searching...
No Matches
TrigConfCoolWriter.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TrigConf_TrigConfCoolWriter
6#define TrigConf_TrigConfCoolWriter
7
8#include "CoolApplication/Application.h"
9#include "CoolKernel/DatabaseId.h"
10#include "CoolKernel/Exception.h"
11#include "CoolKernel/IDatabaseSvc.h"
12#include "CoolKernel/IDatabase.h"
13
14#include <string>
15#include <iostream>
16#include <vector>
17#include <map>
18
19namespace TrigConf {
20
21 class ThresholdConfig;
22 class CTPConfig;
23 class Menu;
24 class PIT;
25 class TIP;
26 class CaloInfo;
27 class HLTFrame;
28 class PrescaleSet;
29 class HLTPrescaleSet;
30 class BunchGroupSet;
31 class TriggerItem;
32 class TriggerThreshold;
33 class ThresholdMonitor;
34
35
36 typedef std::pair<unsigned int,unsigned int> RunRange;
37 typedef std::vector<RunRange> RunRangeVec;
38
40 public:
41 ValidityRange(unsigned int run) {
42 // highest bit==1 indicates infinite run range to be set (would not give valid iov anyway)
43 bool infiniteRange = (run & 0x80000000) != 0;
44 if(infiniteRange) {
45 m_range.first = cool::ValidityKeyMin;
46 m_range.second = cool::ValidityKeyMax;
47 } else {
48 m_range.first = run; m_range.first <<= 32;
49 m_range.second = run+1; m_range.second <<= 32;
50 }
51 }
52
53 // from run/lb to end of run
54 ValidityRange(unsigned int run, unsigned int lb) {
55 m_range.first = run; m_range.first <<= 32; m_range.first += lb;
56 m_range.second = run+1; m_range.second <<= 32;
57 }
58
59 ValidityRange(cool::ValidityKey since, cool::ValidityKey until) {
60 m_range.first = since;
61 m_range.second = until;
62 }
63
65 int firstRN = rr.first;
66 int lastRN = rr.second;
67 // highest bit==1 indicates infinite run range to be set (would not give valid iov anyway)
68 bool infiniteRange = (firstRN & 0x80000000) != 0;
69 if(infiniteRange) {
70 m_range.first = cool::ValidityKeyMin;
71 m_range.second = cool::ValidityKeyMax;
72 } else {
73 m_range.first = firstRN; m_range.first <<= 32;
74 m_range.second = lastRN+1; m_range.second <<= 32;
75 }
76 }
77 cool::ValidityKey& since() { return m_range.first; }
78 cool::ValidityKey& until() { return m_range.second; }
79 private:
80 std::pair<cool::ValidityKey,cool::ValidityKey> m_range;
81 };
82
84 class AutoDBOpen {
85 public:
86 AutoDBOpen(TrigConfCoolWriter *writer, bool readOnly);
90 bool m_ro;
91 };
92
93
96 public:
97
103 TrigConfCoolWriter(const std::string& dbId, std::ostream & o = std::cout) :
104 m_dbId(cool::DatabaseId(dbId)),
106 m_ostream(o)
107 {}
108
111
113 void createSchema(int schemaVersion=0);
114
116 void recreateSchema(int schemaVersion=0);
117
122 void printSchema(std::ostream &o);
123
128 void printSchemaVersion(std::ostream &o);
129
130
131 void writeL1Payload( ValidityRange vr, const CTPConfig& ctpConfig);
132
134 const HLTFrame& hltFrame,
135 const std::string& configSource);
136
138 unsigned int mck,
139 std::string& release,
140 std::string& info);
141
142
154 void writeRunPayload( unsigned int runNumber,
155 unsigned int masterConfigKey,
156 unsigned int hltPrescaleKey,
157 const TrigConf::ThresholdConfig & lvl1Thr,
158 const TrigConf::CTPConfig & ctpConfig,
159 const TrigConf::CaloInfo & caloInfo,
160 const TrigConf::HLTFrame & hltFrame,
161 const std::string & configSource);
162 void writeRunPayload( const RunRangeVec& runRanges,
163 unsigned int masterConfigKey,
164 unsigned int hltPrescaleKey,
165 const TrigConf::ThresholdConfig & lvl1Thr,
166 const TrigConf::CTPConfig & ctpConfig,
167 const TrigConf::CaloInfo & caloInfo,
168 const TrigConf::HLTFrame & hltFrame,
169 const std::string & configSource);
170
176 void writeL1MenuPayload( ValidityRange vr, const TrigConf::Menu& lvl1Menu);
177 void writeL1MenuPayload( const RunRangeVec& runRanges, const TrigConf::Menu& lvl1Menu);
178
179 void writeL1CTPCoreInputMapping( ValidityRange vr, const Menu& lvl1Menu);
180
181
187 void writeL1MonPayload( unsigned int runNumber, const TrigConf::Menu * lvl1Menu);
188 void writeL1MonPayload( const RunRangeVec& runRanges, const TrigConf::Menu * lvl1Menu);
189
195 void writeL1BunchGroupLBPayload( const RunRangeVec& runRanges,
196 unsigned int bgKey,
197 const BunchGroupSet& bgs);
199 unsigned int bgKey,
200 const BunchGroupSet& bgs);
201
202
210 const Menu& lvl1Menu,
211 const BunchGroupSet& bgs);
212 void writeL1BunchGroupRunPayload( const RunRangeVec& runRanges,
213 const TrigConf::Menu& lvl1Menu,
214 const TrigConf::BunchGroupSet& bgs);
215
223 void writeHltPrescalePayload( unsigned int runNumber,
224 unsigned int lumiblockNumber,
225 const TrigConf::HLTPrescaleSet & pss);
226 void writeHltPrescalePayload( const RunRangeVec& runRanges,
227 const TrigConf::HLTPrescaleSet & pss);
228 void writeHltPrescalePayload( cool::ValidityKey since,
229 cool::ValidityKey until,
230 const TrigConf::HLTPrescaleSet & pss);
231
232
240 void writeL1PrescalePayload( unsigned int runNumber,
241 unsigned int lumiblockNumber,
242 unsigned int lvl1PrescaleKey,
243 const TrigConf::PrescaleSet & prescale);
244 void writeL1PrescalePayload( const RunRangeVec& runRanges,
245 unsigned int lvl1PrescaleKey,
246 const TrigConf::PrescaleSet & prescale);
247 void writeL1PrescalePayload( cool::ValidityKey since,
248 cool::ValidityKey until,
249 unsigned int lvl1PrescaleKey,
250 const TrigConf::PrescaleSet & prescaleSet);
251
252
253
262 void readRunPayload( unsigned int runNumber,
263 TrigConf::HLTFrame & hltFrame,
264 unsigned int & masterConfigKey,
265 unsigned int & hltPrescaleKey,
266 std::string & configSource );
267
268 void readHLTPayload( unsigned int run,
269 HLTFrame & hltFrame);
270
271 void readL1Payload( unsigned int run,
272 CTPConfig & ctpc);
273
274
281 void readHltPrescalePayload( unsigned int runNumber,
282 unsigned int lumiblockNumber,
284
285
293 void readL1BunchGroupLBPayload( unsigned int runNumber,
294 unsigned int lumiblockNumber,
295 int& bgKey,
297
305 std::pair<std::vector<std::string>, std::map<unsigned int,unsigned char> >
306 readL1BunchGroupRunPayload( unsigned int runNumber);
307
308
316 void readL1PrescalePayload( unsigned int runNumber,
317 unsigned int lumiblockNumber,
318 unsigned int& lvl1PrescaleKey,
319 TrigConf::PrescaleSet & prescale);
320
326 void readL1InputMapPayload( unsigned int runNumber,
327 std::vector<TrigConf::PIT*>& pits,
328 std::vector<TrigConf::TIP*>& tips);
329
336 void readL1MonMapPayload(unsigned int runNumber,
337 std::vector<TrigConf::ThresholdMonitor*>& mons);
338
345 void readL1Items(unsigned int runNumber,
346 std::vector<TrigConf::TriggerItem*>& items);
347
354 void readL1Thresholds(unsigned int runNumber,
355 std::vector<TrigConf::TriggerThreshold*>& thrs);
356
365 void readL1ItemDef(unsigned int runNumber,
366 const std::vector<TrigConf::TriggerItem*>& items,
367 const std::vector<TrigConf::TriggerThreshold*>& thrs);
368
374 void readL1Menu(unsigned int runNumber, CTPConfig & ctpc);
375
376 std::vector<std::string> checkPayloadSize(unsigned int run, unsigned int lb, int displayMode, bool openend, unsigned int lbend);
377
378 void addWriteFolder(const std::string& fname) { m_writeFolderList.push_back( fname ); }
379
380 void setVerbosityLevel(unsigned int level) { m_verbosityLevel = level; }
381 unsigned int verbosityLevel() const { return m_verbosityLevel; }
382
383 bool checkDbConnection(bool readonly);
384
386
388
389 private:
390 friend class AutoDBOpen;
391
394 m_ostream(std::cout)
395 {};
396
399 m_ostream(orig.m_ostream)
400 {};
401
402
405 cool::IDatabaseSvc& databaseService();
406
410 cool::IDatabasePtr openDb( bool readOnly = true );
411
414 bool dbIsOpen();
415
417 void dropDb();
418
420 void closeDb(cool::IDatabasePtr& db);
421 void closeDb(); // to be used
422
424 cool::IDatabasePtr createDb();
425
427 cool::IDatabasePtr recreateDb();
428
429 void rangeInfo(const std::string& content, cool::ValidityKey since, cool::ValidityKey until);
430
432 bool shouldFolderBeUpdated(const std::string & foldername) {
433 if( m_writeFolderList.size()==0 ) return true; // nothing specified --> write everything (default)
434 return std::count(m_writeFolderList.begin(),m_writeFolderList.end(),foldername)>0;
435 }
436
437 // data members
438 // DB connection string: oracle://<server>;schema=<acc_name>;dbname=<db_name>;user=<acc_name>;password=<pwd>
439 cool::DatabaseId m_dbId;
440 cool::IDatabasePtr m_dbPtr;
441 cool::Application m_coolApp;
442
443 std::vector<std::string> m_writeFolderList;
444 std::ostream & m_ostream;
445
447 };
448
449}
450
451#endif
const boost::regex rr(r_r)
AutoDBOpen(TrigConfCoolWriter *writer, bool readOnly)
TrigConfCoolWriter * m_writer
The HLT trigger menu,.
Definition HLTFrame.h:33
HLT chain configuration information.
Reading/Writing of trigger configuration data from/to COOL.
void writeL1BunchGroupRunPayload(ValidityRange vr, const Menu &lvl1Menu, const BunchGroupSet &bgs)
Writing run-wise L1 bunch group names and item to bunch group mapping to COOL.
bool dbIsOpen()
check if db is open
void printSchema(std::ostream &o)
Prints the schema in the COOL database.
void readL1Thresholds(unsigned int runNumber, std::vector< TrigConf::TriggerThreshold * > &thrs)
Read run-wise L1 threshold vector from COOL database.
bool checkDbConnection(bool readonly)
TrigConfCoolWriter()
default constructor
void writeHltPrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, const TrigConf::HLTPrescaleSet &pss)
Writing luminosityblock-wise configuration information the COOL database.
TrigConfCoolWriter(const TrigConfCoolWriter &orig)
copy constructor
void writeL1CTPCoreInputMapping(ValidityRange vr, const Menu &lvl1Menu)
void writeL1MenuPayload(ValidityRange vr, const TrigConf::Menu &lvl1Menu)
Writing L1 run-wise configuration information to the COOL database.
void readL1BunchGroupLBPayload(unsigned int runNumber, unsigned int lumiblockNumber, int &bgKey, TrigConf::BunchGroupSet &bgs)
Reading lb-wise bunch group configuration information from COOL database.
void setVerbosityLevel(unsigned int level)
void writeL1PrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, unsigned int lvl1PrescaleKey, const TrigConf::PrescaleSet &prescale)
Writing luminosityblock-wise configuration information the COOL database.
void readL1InputMapPayload(unsigned int runNumber, std::vector< TrigConf::PIT * > &pits, std::vector< TrigConf::TIP * > &tips)
Read run-wise PIT configuration from COOL database.
bool shouldFolderBeUpdated(const std::string &foldername)
check if foldername is in list of writeable folders
std::pair< std::vector< std::string >, std::map< unsigned int, unsigned char > > readL1BunchGroupRunPayload(unsigned int runNumber)
Reading bunch group configuration information from COOL database.
void readL1Payload(unsigned int run, CTPConfig &ctpc)
void writeHltPrescalePayload(cool::ValidityKey since, cool::ValidityKey until, const TrigConf::HLTPrescaleSet &pss)
void readL1Menu(unsigned int runNumber, CTPConfig &ctpc)
Read L1 menu from COOL database.
cool::IDatabasePtr openDb(bool readOnly=true)
open COOL db connection
void writeL1MonPayload(unsigned int runNumber, const TrigConf::Menu *lvl1Menu)
Writing L1 run-wise monitoring configuration to COOL.
void readHltPrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, TrigConf::HLTPrescaleSet &pss)
Reading luminosityblock-wise configuration information the COOL database.
cool::Application m_coolApp
COOL application.
void rangeInfo(const std::string &content, cool::ValidityKey since, cool::ValidityKey until)
void writeRunPayload(unsigned int runNumber, unsigned int masterConfigKey, unsigned int hltPrescaleKey, const TrigConf::ThresholdConfig &lvl1Thr, const TrigConf::CTPConfig &ctpConfig, const TrigConf::CaloInfo &caloInfo, const TrigConf::HLTFrame &hltFrame, const std::string &configSource)
Writing run-wise configuration information the COOL database.
TrigConfCoolWriter(const std::string &dbId, std::ostream &o=std::cout)
constructor
void recreateSchema(int schemaVersion=0)
Create a new schema in the COOL database with prior deletion of the old one.
cool::IDatabasePtr m_dbPtr
COOL database pointer.
void createSchema(int schemaVersion=0)
Create a new schema in the COOL database.
void printSchemaVersion(std::ostream &o)
Prints the schema in the COOL database.
void dropDb()
delete the COOL database
cool::IDatabaseSvc & databaseService()
get COOL db service
void readL1PrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, unsigned int &lvl1PrescaleKey, TrigConf::PrescaleSet &prescale)
Reading luminosityblock-wise configuration information the COOL database.
unsigned int verbosityLevel() const
void writeHLTPayload(ValidityRange vr, const HLTFrame &hltFrame, const std::string &configSource)
cool::IDatabasePtr recreateDb()
create a new COOL database with prior deletion of the old one
std::ostream & m_ostream
output stream for all messages
std::vector< std::string > m_writeFolderList
list of folders to which writing is restricted
void readRunPayload(unsigned int runNumber, TrigConf::HLTFrame &hltFrame, unsigned int &masterConfigKey, unsigned int &hltPrescaleKey, std::string &configSource)
Reading run-wise configuration information from COOL database.
void readL1Items(unsigned int runNumber, std::vector< TrigConf::TriggerItem * > &items)
Read run-wise L1 item vector from COOL database.
void writeMCKPayload(ValidityRange vr, unsigned int mck, std::string &release, std::string &info)
cool::DatabaseId m_dbId
db connection string
void writeL1Payload(ValidityRange vr, const CTPConfig &ctpConfig)
void readL1MonMapPayload(unsigned int runNumber, std::vector< TrigConf::ThresholdMonitor * > &mons)
Read run-wise LVL1 monitoring configuration from COOL database.
void addWriteFolder(const std::string &fname)
cool::IDatabasePtr createDb()
create a new COOL database
void writeL1BunchGroupLBPayload(const RunRangeVec &runRanges, unsigned int bgKey, const BunchGroupSet &bgs)
Writing LB-wise L1 bunch group definition to the COOL database.
void readHLTPayload(unsigned int run, HLTFrame &hltFrame)
void readL1ItemDef(unsigned int runNumber, const std::vector< TrigConf::TriggerItem * > &items, const std::vector< TrigConf::TriggerThreshold * > &thrs)
Read run-wise L1 item defintions (conditions) from COOL database.
std::vector< std::string > checkPayloadSize(unsigned int run, unsigned int lb, int displayMode, bool openend, unsigned int lbend)
ValidityRange(const RunRange &rr)
cool::ValidityKey & until()
std::pair< cool::ValidityKey, cool::ValidityKey > m_range
cool::ValidityKey & since()
ValidityRange(unsigned int run, unsigned int lb)
ValidityRange(unsigned int run)
ValidityRange(cool::ValidityKey since, cool::ValidityKey until)
static std::string release
Definition computils.h:50
int lb
Definition globals.cxx:23
static std::vector< uint32_t > lbend
Definition iLumiCalc.h:39
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
std::pair< unsigned int, unsigned int > RunRange
std::vector< RunRange > RunRangeVec
Definition run.py:1
STL namespace.