ATLAS Offline Software
Loading...
Searching...
No Matches
ReadWrite.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6//
7// NAME: TrigConfReadWrite.cxx
8// PACKAGE: TrigConfStorage
9//
10// AUTHOR: J.Stelzer (CERN) Joerg.Stelzer@cern.ch
11// CREATED: 17 Mar 2013
12//
13// PURPOSE:
14//
15// This standalone application is designed to read and write the
16// trigger configuration (L1+HLT) from DB,COOL and to COOL
17// for test purposes
18//
20
23
29
37
38#include "TrigConfCoolWriter.h"
41
42#include "CoolKernel/DatabaseId.h"
43#include "CoolKernel/Exception.h"
44#include "CoolKernel/IDatabaseSvc.h"
45#include "CoolKernel/IDatabase.h"
46#include "CoolKernel/IFolder.h"
47#include "CoolKernel/IObject.h"
48
49#include "boost/algorithm/string.hpp"
50
51#include <iostream>
52#include <fstream>
53#include <string>
54#include <memory>
55#include <ctime>
56#include <map>
57#include <vector>
58#include <sys/stat.h>
59
60using namespace std;
61using namespace TrigConf;
62
63void printhelp(std::ostream & o, std::ostream& (*lineend) ( std::ostream& os )) {
64 o << "================================================================================\n";
65 o << "The program needs to be run with the following specifications:\n" << lineend;
66 o << "TrigConfReadWrite <options>\n";
67 o << "\n";
68 o << "[Global options]\n";
69 o << " -i|--input input [input [input]] ... source of configuration, format see below (mandatory)\n";
70 o << " -2|--comp input [input [input]] ... source of a second configuration for comparison\n";
71 o << " -o|--output r3json|cool [output[;cooldb]] [run] ... output format, name (for cool optional run number)\n";
72 o << " ... absolute output file name must contain '/', cooldb can be appended COMP200|OFLP200\n";
73 o << " -v|--loglevel <string> ... log level [NIL, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS]\n";
74 o << " -l|--log <string> ... name of a log file\n";
75 o << " --jo ... read and write job options where possible\n";
76 o << " --fw ... read ctp firmware\n";
77 o << " -p|--print <int> ... print configuration with detail 0...5 (default 1)\n";
78 o << " -h|--help ... this output\n";
79 o << " --nomerge ... internally don't merge L2 and EF (by default merge is enabled)\n";
80 o << "\n\n";
81 o << "Input can be specified the following\n";
82 o << " -i <TRIGDB_ALIAS>|<TRIGDB_connection> smk[,l1psk,hltpsk,bgsk] ... to read the menu from a trigger db via alias or explicit connection specification (ORACLE or SQlite)\n";
83 o << " -i <COOLDB_ALIAS>|<COOLDB_connection>|cool.db run[,lb] ... to read the menu from COOL for a certain run and possibly LB [file names must end with '.db']\n";
84 o << "\n";
85 o << "The cool dbconnection can be specified as one of the following\n";
86 o << " - via alias : COOLONL_TRIGGER (use COOLONL_TRIGGER/COMP200 for Run 1 data)";
87 o << " - from sqlite : cool.db (use cool.db;COMP200 for Run 1 data)";
88 o << "\n";
89 o << "\n";
90 o << "Input for comparison can be specified the same way, using the '-2' or '--comp' option\n";
91 o << "\n";
92 o << "\n";
93 o << "Output formats can be json or cool. In case a second input is specified for comparison, the output will be on screen or an xml file with the differences\n";
94 o << " -o r3json [<test>] ... will produce Run 3 config files L1PrescalesSet[_<test>].json, BunchGroupSet[_<test>].json, L1Menu[_<test>].json, HLTPrescalesSet[_<test>].json, and HLTMenu[_<test>].json\n";
95 o << " -o cool ... will produce trig_cool.db with cool db instance CONDBR2 and infinite IOV\n";
96 o << " -o cool 200000 ... will produce trig_cool.db with cool db instance CONDBR2 and run number 200000\n";
97 o << " -o cool test [200000] ... will produce trig_cool_test.db with cool db instance CONDBR2 [and run number 200000]\n";
98 o << " -o cool ../test.db [200000] ... will produce ../test.db with cool db instance CONDBR2 [and run number 200000]\n";
99 o << " -o cool 'test;COMP200' [200000] ... will produce Menu_test.db with cool db instance COMP200 [and run number 200000]\n";
100 o << "\n";
101 o << "================================================================================\n";
102}
103
104struct JobConfig {
105 enum Format { UNDEF=0x00, DB=0x01, COOL=0x02, XML=0x04, JSON=0x08 };
106 enum ETriggerLevel { LVL1 = 0, HLT = 1, NONE = 2 };
107
108 std::vector<std::string> inpar, inpar2, outpar;
109
112 unsigned int output {UNDEF};
113 string db{""}, db2{""};
114 vector<unsigned int> keys, keys2; // smk[,l1key[,hltkey[,bgkey]]]
115 string outBase {""};
116
117 string l1JsonOutFile {"L1Menu.json"};
118 string bgkJsonOutFile {"BunchGroupSet.json"};
119 string l1PSJsonOutFile { "L1PrescalesSet.json" };
120 string hltJsonOutFile { "HLTMenu.json" };
121 string hltPSJsonOutFile { "HLTPrescalesSet.json" };
122
123 string coolInputConnection { "" };
124 string coolOutputConnection { "" };
125 unsigned int coolOutputRunNr { 0 };
126
127 // other
128 bool help {false};
129 int printlevel {1};
131 bool jo {false};
132 bool fw {false};
133 string logFileName {""};
134 bool merge = { true };
135 vector<string> error;
136
137
138 string CheckForCompleteSetup();
139
140 void PrintSetup(std::ostream & log, std::ostream& (*lineend) ( std::ostream& os ));
141
142 void parseProgramOptions(int argc, char* argv[]);
143
144 unsigned int getKey(unsigned int which) { return keys.size()>which?keys[which]:0; }
145
146 unsigned int getKey2(unsigned int which) { return keys2.size()>which?keys2[which]:0; }
147
148};
149
150
151namespace {
152 bool startswith(const std::string& str, const std::string& sub) {
153 if(str.size()<sub.size())
154 return false;
155 return (str.compare(0,sub.size(),sub) == 0);
156 }
157
158 bool isUnsignedInteger(const std::string& str) {
159 for(const char c : str)
160 if(c<'0' || c>'9') return false;
161 return true;
162 }
163}
164
165
166void
167JobConfig::parseProgramOptions(int argc, char* argv[]) {
168 std::string currentPar("");
169 std::string listofUnknownParameters = "";
170 for(int i=1; i<argc; i++) {
171 string currInput(argv[i]);
172 int fchar = currInput.find_first_not_of('-');
173 string stripped = currInput.substr(fchar);
174 bool isParam = (fchar!=0); // string starts with a '-', so it is a parameter name
175
176 if(isParam)
177 if( ! (stripped == "i" || stripped == "input" ||
178 stripped == "2" || stripped == "comp" ||
179 stripped == "o" || stripped == "output" ||
180 stripped == "l" || stripped == "log" ||
181 stripped == "p" || stripped == "print" ||
182 stripped == "jo" ||
183 stripped == "fw" ||
184 stripped == "nomerge" ||
185 stripped == "v" || stripped == "loglevel") ) {
186 listofUnknownParameters += " " + currInput;
187 continue;
188 }
189
190 if(isParam) {
191 currentPar = "";
192 if(stripped == "h" || stripped == "help" ) { help = true; continue; }
193 if(stripped == "jo") { jo = true; continue; }
194 if(stripped == "fw") { fw = true; continue; }
195 if(stripped == "nomerge") { merge = false; continue; }
196 currentPar = std::move(stripped);
197 } else {
198 if(currentPar == "i" || currentPar == "input") { inpar.push_back(std::move(stripped)); continue; }
199 if(currentPar == "2" || currentPar == "comp") { inpar2.push_back(std::move(stripped)); continue; }
200 if(currentPar == "o" || currentPar == "output") {
201 if(outpar.size()==0 && stripped != "r3json" && stripped != "cool") {
202 error.push_back("Unknown output type: " + stripped + ". Must be either json or cool, optionally followed by a base string for the output file name");
203 } else {
204 outpar.push_back(std::move(stripped));
205 }
206 continue; }
207 if(currentPar == "l" || currentPar == "log") { logFileName = std::move(stripped); continue; }
208 if(currentPar == "p" || currentPar == "print") { printlevel = std::stoi(stripped); currentPar=""; continue; }
209 if(currentPar == "v" || currentPar == "loglevel") {
210 if("NIL" == stripped ) { outputlevel = MSGTC::NIL; }
211 else if("VERBOSE" == stripped ) { outputlevel = MSGTC::VERBOSE; }
212 else if("DEBUG" == stripped ) { outputlevel = MSGTC::DEBUG; }
213 else if("INFO" == stripped ) { outputlevel = MSGTC::INFO; }
214 else if("WARNING" == stripped ) { outputlevel = MSGTC::WARNING; }
215 else if("ERROR" == stripped ) { outputlevel = MSGTC::ERROR; }
216 else if("FATAL" == stripped ) { outputlevel = MSGTC::FATAL; }
217 else if("ALWAYS" == stripped ) { outputlevel = MSGTC::ALWAYS; }
218 else {
219 error.push_back("Unknown output level: " + stripped + ". Must be one of NIL, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS");
220 }
221 continue;
222 }
223 }
224 }
225 if(listofUnknownParameters!="")
226 error.push_back("Unknown parameter(s): " + listofUnknownParameters);
227
228 if(inpar.size()==0)
229 error.push_back("No input specified, use '-i' option");
230
231
232 // parse the input
233 if( inpar.size()>=1 && inpar[0].find(".db") != string::npos ) {
234 // sqlite file
235 input = COOL;
236 vector<string> ksv = CxxUtils::tokenize(inpar[0], ';');
237 if(ksv.size()==1) { // defaults to CONDBR2
238 coolInputConnection = "sqlite://;schema="+ksv[0]+";dbname=CONDBR2";
239 } else {
240 coolInputConnection = "sqlite://;schema="+ksv[0]+";dbname=" + ksv[1];
241 }
242 } else if( inpar.size()>=1 && startswith(inpar[0],"COOLONL_TRIGGER") ) {
243 input = COOL;
244 vector<string> ksv = CxxUtils::tokenize(inpar[0], '/');
245 if(ksv.size()==1) {
246 coolInputConnection = ksv[0]+"/CONDBR2";
247 } else {
248 coolInputConnection = ksv[0]+"/" + ksv[1];
249 }
250
251 } else if( inpar.size()==2 ) {
252 input = DB;
253 db = inpar[0];
254 vector<string> ksv = CxxUtils::tokenize(inpar[1], ',');
255 for(const string& ks: ksv) {
256 keys.push_back( static_cast<unsigned int>(std::stoul(ks)) );
257 };
258 }
259
260 // parse the output
261 for(const string& o: outpar) {
262 if ( o=="r3json" ) {
263 output |= JSON;
264 } else if ( o=="cool" ) {
265 output |= COOL;
266 } else if ( isUnsignedInteger(o) ) {
267 coolOutputRunNr = static_cast<unsigned int>(std::stoul(o));
268 } else {
269 outBase = o;
270 }
271 }
272
273 if (outBase != "") {
274 if( output & JobConfig::COOL ) {
275 string dbname = "CONDBR2";
276 string outfile = outBase;
277 vector<string> ksv = CxxUtils::tokenize(outBase, ';');
278 if(ksv.size()==2) { // defaults to CONDBR2
279 outfile = ksv[0];
280 dbname = ksv[1];
281 }
282 if (outfile.find("/")==string::npos && outfile.find('.')==string::npos) {
283 outfile="trig_cool_" + outfile + ".db";
284 }
285 coolOutputConnection = "sqlite://;schema="+outfile+";dbname="+dbname;
286 } else {
287 boost::replace_last(l1JsonOutFile, ".json", "_"+outBase+".json");
288 boost::replace_last(bgkJsonOutFile, ".json", "_"+outBase+".json");
289 boost::replace_last(l1PSJsonOutFile, ".json", "_"+outBase+".json");
290 boost::replace_last(hltJsonOutFile, ".json", "_"+outBase+".json");
291 boost::replace_last(hltPSJsonOutFile, ".json", "_"+outBase+".json");
292 }
293 }
294
295}
296
297
299 if(input==UNDEF)
300 return "Use argument '-i' to specify input source and check that the input is specified correctly";
301 if( input == DB ) {
302 if( db == "" )
303 return "No TriggerDB connection string specified";
304 if( keys.size()==0 )
305 return "No configuration key(s) specified";
306 }
307 if( input2 == DB ) {
308 if( db2 == "" )
309 return "No TriggerDB connection string specified for comparison, use option '--db2'";
310 if( keys2.size()==0 )
311 return "No smk specified for comparison, use option '--dbsmk2'";
312 }
313 return "";
314}
315
316
317void
318JobConfig::PrintSetup(std::ostream & log, std::ostream& (*lineend) ( std::ostream& os ) ) {
319 log << "========================================" << lineend;
320 log << "JOB SETUP: " << (input==DB?"DB":"COOL");
321 if(output!=UNDEF)
322 log << " --> " << (output==COOL?"COOL":"JSON");
323 log << lineend;
324 log << "----------" << lineend;
325 log << " Input : ";
326 for(const string& s: inpar) log << s << ", ";
327 log << lineend;
328 if( input2 != UNDEF ) {
329 log << " Input for comparison: ";
330 for(const string& s: inpar2) log << s << ", ";
331 log << lineend;
332 }
333 if( output != UNDEF ) {
334 log << " Output : ";
335 if( output&COOL ) {
337 if(coolOutputRunNr==0) { log << ", infinite IOV"; } else { log << ", run nr " << coolOutputRunNr; }
338 }
339 log << lineend;
340 }
341 if( printlevel>=0)
342 log << " Print menu detail : " << printlevel << lineend;
343 log << "========================================" << lineend;
344
345}
346
347
348int main( int argc, char* argv[] ) {
349
350 /***************************************
351 *
352 * Getting the program parameters
353 *
354 ***************************************/
355 JobConfig gConfig;
356 gConfig.parseProgramOptions(argc, argv);
357 if(gConfig.help) {
358 printhelp(cout, endl);
359 return 0;
360 }
361 if(gConfig.error.size()!=0) {
362 for(const string& e: gConfig.error)
363 cerr << e << endl;
364 printhelp(cout, endl);
365 return 1;
366 }
367
368 ofstream *outf(0), *errf(0);
369 if(gConfig.logFileName != "") {
370 string outfn = gConfig.logFileName+".out";
371 string errfn = gConfig.logFileName+".err";
372 outf = new ofstream(outfn.c_str());
373 errf = new ofstream(errfn.c_str());
374 }
375 ostream& log = (outf==0?cout:*outf);
376 ostream& logerr = (errf==0?cerr:*errf);
377 ostream& (*lineend) ( ostream& os ) = &endl;
378
379 string check = gConfig.CheckForCompleteSetup();
380 if( check != "" ) {
381 logerr << lineend << "===> Error in the option specification: " << check << lineend << lineend;
382 printhelp(log, lineend);
383 if(outf) outf->close();
384 if(errf) errf->close();
385 return 1;
386 }
387
388 gConfig.PrintSetup(log, lineend);
389
390
391 /***************************************
392 *
393 * Reading
394 *
395 ***************************************/
396 CTPConfig* ctpc(0);
397 BunchGroupSet* bgs(nullptr);
398 HLTFrame* hltFrame(0);
399 TXC::L1TopoMenu* l1tm = nullptr;
400 uint smk(0),l1psk(0),hltpsk(0),bgsk(0), mck{0};
401 string release;
402
403
404 /*------------------
405 * from DB
406 *-----------------*/
407 if (gConfig.input == JobConfig::DB) {
408 unique_ptr<StorageMgr> sm(new StorageMgr(gConfig.db, "", "", log));
409
410 // Loading L1 topo
411 //log << "Retrieving Lvl1 Topo configuration" << lineend;
412 l1tm = new TXC::L1TopoMenu();
413 l1tm->setSMK(gConfig.getKey(0));
414 sm->masterTableLoader().setLevel(gConfig.outputlevel);
415 sm->masterTableLoader().load(*l1tm);
416
417 //log << "Retrieving Lvl1 CTP configuration" << lineend;
418 ctpc = new TrigConf::CTPConfig();
419 ctpc->setSMK( gConfig.getKey(0) );
420 ctpc->setPrescaleSetId( gConfig.getKey(1) );
421 ctpc->setBunchGroupSetId( gConfig.getKey(3) );
422 sm->menuLoader().setEnv(IMenuLoader::CTPOnl);
423 ctpc->setLoadCtpFiles(gConfig.fw); // load CTP files ?
424 sm->masterTableLoader().setLevel( gConfig.outputlevel );
425 sm->masterTableLoader().load(*ctpc);
426 ctpc->muCTPi().setSMK( gConfig.getKey(0) );
427 sm->masterTableLoader().load( ctpc->muCTPi() );
428
429 //log << "Retrieving HLT menu configuration and prescale set from the TriggerDB" << lineend;
430 hltFrame = new HLTFrame();
431 hltFrame->setSMK( gConfig.getKey(0) );
432 if( gConfig.getKey(2)>0 )
434 sm->hltFrameLoader().setLevel( gConfig.outputlevel );
435 sm->hltFrameLoader().load( *hltFrame );
436
437 smk = gConfig.getKey(0);
438 l1psk = gConfig.getKey(1);
439 hltpsk = gConfig.getKey(2);
440 bgsk = gConfig.getKey(3);
441
442 // loading attached MCK
443 auto mckloader = new MCKLoader(*sm);
444 mckloader->loadMCKlinkedToSMK(smk, mck);
445 if ( mck != 0 ) {
446 mckloader->loadReleaseLinkedToMCK(mck,release);
447 log << "Loaded MCK " << mck << " (active for SMK " << smk << " and release " << release << ")" << endl;
448 } else {
449 log << "Did not load MCK from DB as MCK is 0 or no MCK is linked";
450 }
451
452 }
453 /*------------------
454 * from COOL
455 *-----------------*/
456 else if (gConfig.input == JobConfig::COOL) {
457 string coolInputConnection = gConfig.coolInputConnection;
458 unsigned int runnumber = gConfig.inpar.size()>1 ? static_cast<unsigned int>(std::stoul(gConfig.inpar[1])) : 1;
459 unsigned int lb = gConfig.inpar.size()>2 ? static_cast<unsigned int>(std::stoul(gConfig.inpar[2])) : 0;
460 log << "TrigConfReadWrite Reading cool : " << coolInputConnection << lineend;
461 log << " run number : " << runnumber << lineend;
462 log << " lb : " << lb << lineend;
463 TrigConfCoolWriter * coolWriter = new TrigConfCoolWriter( coolInputConnection );
464 string configSource("");
465 ctpc = new CTPConfig();
466 coolWriter->readL1Payload( runnumber, *ctpc);
467
468 PrescaleSet ps;
469 coolWriter->readL1PrescalePayload( runnumber, lb, l1psk, ps);
470 ctpc->setPrescaleSet( ps );
471
472 // log << "L1 PSK 0 " << ps.id() << lineend;
473 // log << "L1 PSK 1 " << l1psk << lineend;
474 // log << "L1 PSK 2 " << ctpc->prescaleSet().id() << lineend;
475 // log << "L1 PSK 3 " << ctpc->prescaleSetId() << lineend; <---- does not work
476
477 int bgKey(0);
478 coolWriter->readL1BunchGroupLBPayload( runnumber, lb, bgKey, ctpc->bunchGroupSet() );
479
480 hltFrame = new HLTFrame();
481 coolWriter->readHLTPayload(runnumber, *hltFrame);
482
483 if(lb!=0) {
484 HLTPrescaleSet * pss = new HLTPrescaleSet();
485 coolWriter->readHltPrescalePayload( runnumber, lb, *pss);
486 hltpsk = pss->id();
487 hltFrame->thePrescaleSetCollection().addPrescaleSet( lb, pss );
488 }
489
490 smk = hltFrame->smk();
491 bgsk = bgKey;
492
493 }
494
495 if(gConfig.printlevel>=0) {
496 log << "Loaded this configuration" << lineend;
497 log << " SMK " << smk << lineend;
498 log << " L1 PSK " << l1psk << lineend;
499 log << " HLT PSK " << hltpsk << lineend;
500 log << " BGSK " << bgsk << lineend;
501 if(ctpc) ctpc->print(" ", gConfig.printlevel);
502 if(bgs) bgs->print(" ", gConfig.printlevel);
503 if(hltFrame) hltFrame->print(" ", gConfig.printlevel);
504 }
505
506
507 if (gConfig.input2 != JobConfig::UNDEF) {
508 CTPConfig* ctpc2(0);
509 HLTFrame* hltFrame2(0);
510
511 /*------------------
512 * from DB
513 *-----------------*/
514 if (gConfig.input2 == JobConfig::DB) {
515 TrigConf::StorageMgr *sm = new TrigConf::StorageMgr(gConfig.db2, "", "", log);
516
517 log << "Retrieving Lvl1 CTP configuration for comparison" << lineend;
518 ctpc2 = new TrigConf::CTPConfig();
519 ctpc2->setSMK( gConfig.getKey2(0) );
520 ctpc2->setPrescaleSetId( gConfig.getKey2(1) );
521 ctpc2->setBunchGroupSetId( gConfig.getKey2(3) );
524 sm->masterTableLoader().load(*ctpc2);
525 ctpc2->muCTPi().setSMK( gConfig.getKey2(0) );
526 sm->masterTableLoader().load(ctpc2->muCTPi());
527
528 log << "Retrieving HLT menu configuration and prescale set from the TriggerDB for comparison" << lineend;
529 hltFrame2 = new HLTFrame();
530 hltFrame2->setSMK( gConfig.getKey2(0) );
531 if( gConfig.getKey2(2)>0)
533 sm->hltFrameLoader().load( *hltFrame2 );
534 delete sm;
535 } else if (gConfig.input2 == JobConfig::COOL) {
536 /*------------------
537 * from COOL
538 *-----------------*/
539 }
540
541 if(ctpc && ctpc2) {
542 bool equalMenus = ctpc->equals(ctpc2, "LVL1config_Diff.xml");
543 if(equalMenus) {
544 log << "LVL1 menus are identical." << lineend;
545 } else {
546 log << "LVL1 menus differ. Writing LVL1 menu comparison file LVL1config_Diff.xml" << lineend;
547 }
548 }
549 if(hltFrame && hltFrame2) {
550 bool equalMenus = hltFrame->equals(hltFrame2, "HLTconfig_Diff.xml");
551 if(equalMenus) {
552 log << "HLT menus are identical." << lineend;
553 } else {
554 log << "HLT menus differ. Writing HLT menu comparison file HLTconfig_Diff.xml" << lineend;
555 }
556 }
557
558 }
559
560
561 // ========================================
562 // Writing
563 // ========================================
564 if ( (gConfig.output & JobConfig::JSON) != 0 ) {
565 /*------------------
566 * to JSON
567 *-----------------*/
568 if(ctpc && l1tm) {
569 convertRun2L1MenuToRun3(ctpc, l1tm, gConfig.l1JsonOutFile);
572 }
573 if(hltFrame) {
574 convertRun2HLTMenuToRun3(hltFrame, gConfig.hltJsonOutFile);
576 }
577 }
578
579 if ( (gConfig.output & JobConfig::COOL) != 0 ) {
580 /*------------------
581 * to COOL
582 *-----------------*/
583 log << "TrigConfReadWrite: Writing sqlite cool file : " << gConfig.coolOutputConnection << " with ";
584 if( gConfig.coolOutputRunNr==0 ) { log << "infinite IOV"; } else { log << " runNr " << gConfig.coolOutputRunNr; }
585 log << lineend;
586 TrigConfCoolWriter * coolWriter = new TrigConfCoolWriter( gConfig.coolOutputConnection );
587 string configSource("");
588 string info("");
589 unsigned int runNr = gConfig.coolOutputRunNr;
590 if(runNr == 0) { runNr = 0x80000000; } // infinite range
591
592 if(ctpc) {
593 coolWriter->writeL1Payload(runNr, *ctpc);
594 }
595 try{
596 if(hltFrame) {
597 coolWriter->writeHLTPayload(runNr, *hltFrame, configSource);
598 }
599 }
600 catch(const cool::StorageTypeStringTooLong& e){
601 log << "FATAL: Unable to write data to COOL";
602 return 1;
603 }
604 if(mck) {
605 coolWriter->writeMCKPayload(runNr, mck, release, info);
606 }
607 }
608
609 delete ctpc;
610 delete hltFrame;
611 if(l1tm!=nullptr)
612 delete l1tm;
613
614 if( gConfig.jo ) {
615
616 JobOptionTable jot;
617 unique_ptr<IStorageMgr> sm( new StorageMgr(gConfig.db,"","",log) );
618
619 log << "TrigConfReadWrite: Retrieving JO from the TriggerDB" << lineend;
620 jot.setSMK( gConfig.getKey(0) );
621 jot.setTriggerLevel(0); // L2
622 sm->jobOptionTableLoader().setLevel(gConfig.outputlevel);
623 sm->jobOptionTableLoader().load( jot );
624 if(gConfig.printlevel>0) jot.print();
625 }
626
627}
unsigned int uint
void printhelp(std::ostream &o, std::ostream &(*lineend)(std::ostream &os))
Definition ReadWrite.cxx:63
void convertRun2HLTMenuToRun3(const TrigConf::HLTFrame *frame, const std::string &filename)
void convertRun2HLTPrescalesToRun3(const TrigConf::HLTFrame *frame, const std::string &filename)
void convertRun2L1MenuToRun3(const TrigConf::CTPConfig *ctpConfig, const TXC::L1TopoMenu *topoMenu, const std::string &filename, bool writeTmpFile)
Conversion of L1 menu.
void convertRun2L1PrescalesToRun3(const TrigConf::CTPConfig *ctpConfig, const std::string &filename, bool writeTmpFile)
Conversion of L1 prescales set.
void convertRun2BunchGroupsToRun3(const TrigConf::CTPConfig *ctpConfig, const std::string &filename, bool writeTmpFile)
Run 2 to Run 3 bunchgroup converter.
MsgStream for TrigConf classes.
void setSMK(const unsigned int &smk)
Definition L1TopoMenu.h:63
virtual void print(const std::string &indent="", unsigned int detail=1) const override
void setPrescaleSetId(int id)
Definition CTPConfig.h:68
void setPrescaleSet(const PrescaleSet &pss)
Definition CTPConfig.cxx:49
const BunchGroupSet & bunchGroupSet() const
Definition CTPConfig.h:41
virtual void print(const std::string &indent="", unsigned int detail=1) const override
Definition CTPConfig.cxx:91
const Muctpi & muCTPi() const
Definition CTPConfig.h:47
void setLoadCtpFiles(bool flag=true)
Definition CTPConfig.h:81
void setBunchGroupSetId(int id)
Definition CTPConfig.h:69
bool equals(const CTPConfig *other, const std::string &filename) const
Definition CTPConfig.cxx:59
The HLT trigger menu,.
Definition HLTFrame.h:33
HLTPrescaleSetCollection & thePrescaleSetCollection()
Definition HLTFrame.h:46
void print(const std::string &indent="", unsigned int detail=1) const override
print method
Definition HLTFrame.cxx:86
bool equals(const HLTFrame *other, const std::string &filename) const
Definition HLTFrame.cxx:43
void addPrescaleSet(unsigned int lumiblock, HLTPrescaleSet *pss)
Add prescale set for this lumiblock number.
HLT chain configuration information.
virtual bool load(HLTFrame &data)=0
virtual void setLevel(MSGTC::Level lvl)=0
Load the configuration data from the configuration source.
virtual bool load(ThresholdConfig &thrcfg)=0
Load the LVL1 trigger thresholds from the configuration source.
virtual void setEnv(ENV env)=0
table to hold the complete list of JobOption entries for a single configuration, from which the JobOp...
void print(const std::string &indent="", unsigned int detail=1) const override
print method
void setTriggerLevel(int level)
setter of the trigger level
Database Storage Manager, controls the database session and the different loader classes for DB acces...
Definition StorageMgr.h:23
virtual IMenuLoader & menuLoader() override
virtual IHLTFrameLoader & hltFrameLoader() override
virtual IMasterTableLoader & masterTableLoader() override
Reading/Writing of trigger configuration data from/to COOL.
void readL1BunchGroupLBPayload(unsigned int runNumber, unsigned int lumiblockNumber, int &bgKey, TrigConf::BunchGroupSet &bgs)
Reading lb-wise bunch group configuration information from COOL database.
void readL1Payload(unsigned int run, CTPConfig &ctpc)
void readHltPrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, TrigConf::HLTPrescaleSet &pss)
Reading luminosityblock-wise configuration information the COOL database.
void readL1PrescalePayload(unsigned int runNumber, unsigned int lumiblockNumber, unsigned int &lvl1PrescaleKey, TrigConf::PrescaleSet &prescale)
Reading luminosityblock-wise configuration information the COOL database.
void writeHLTPayload(ValidityRange vr, const HLTFrame &hltFrame, const std::string &configSource)
void writeMCKPayload(ValidityRange vr, unsigned int mck, std::string &release, std::string &info)
void writeL1Payload(ValidityRange vr, const CTPConfig &ctpConfig)
void readHLTPayload(unsigned int run, HLTFrame &hltFrame)
unsigned int id() const
unsigned int smk() const
static std::string release
Definition computils.h:50
int lb
Definition globals.cxx:23
int main()
Definition hello.cxx:18
static std::vector< uint32_t > runnumber
Definition iLumiCalc.h:37
std::vector< std::string > tokenize(std::string_view the_str, std::string_view delimiters)
Splits the string into smaller substrings.
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Forward iterator to traverse the main components of the trigger configuration.
Definition Config.h:22
Definition merge.py:1
STL namespace.
string bgkJsonOutFile
unsigned int getKey2(unsigned int which)
vector< unsigned int > keys2
Format input
Format input2
void PrintSetup()
Definition CoolFix.cxx:222
string hltPSJsonOutFile
string coolInputConnection
std::vector< std::string > outpar
MSGTC::Level outputlevel
Definition CoolFix.cxx:100
vector< unsigned int > keys
string db2
std::vector< std::string > inpar2
string coolOutputConnection
string db
string logFileName
string hltJsonOutFile
vector< string > error
Definition CoolFix.cxx:102
string CheckForCompleteSetup()
void parseProgramOptions(int argc, char *argv[])
string outBase
std::vector< std::string > inpar
string l1PSJsonOutFile
bool help
Definition CoolFix.cxx:98
unsigned int coolOutputRunNr
string l1JsonOutFile
int printlevel
Definition CoolFix.cxx:99
unsigned int output
unsigned int getKey(unsigned int which)