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
22
28
36
37#include "TrigConfCoolWriter.h"
40
41#include "CoolKernel/DatabaseId.h"
42#include "CoolKernel/Exception.h"
43#include "CoolKernel/IDatabaseSvc.h"
44#include "CoolKernel/IDatabase.h"
45#include "CoolKernel/IFolder.h"
46#include "CoolKernel/IObject.h"
47
48#include "boost/algorithm/string.hpp"
49
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;
237 boost::split(ksv,inpar[0],boost::is_any_of(";"));
238 if(ksv.size()==1) { // defaults to CONDBR2
239 coolInputConnection = "sqlite://;schema="+ksv[0]+";dbname=CONDBR2";
240 } else {
241 coolInputConnection = "sqlite://;schema="+ksv[0]+";dbname=" + ksv[1];
242 }
243 } else if( inpar.size()>=1 && startswith(inpar[0],"COOLONL_TRIGGER") ) {
244 input = COOL;
245 vector<string> ksv;
246 boost::split(ksv,inpar[0],boost::is_any_of("/"));
247 if(ksv.size()==1) {
248 coolInputConnection = ksv[0]+"/CONDBR2";
249 } else {
250 coolInputConnection = ksv[0]+"/" + ksv[1];
251 }
252
253 } else if( inpar.size()==2 ) {
254 input = DB;
255 db = inpar[0];
256 vector<string> ksv;
257 boost::split(ksv,inpar[1],boost::is_any_of(","));
258 for(const string& ks: ksv) {
259 keys.push_back( static_cast<unsigned int>(std::stoul(ks)) );
260 };
261 }
262
263 // parse the output
264 for(const string& o: outpar) {
265 if ( o=="r3json" ) {
266 output |= JSON;
267 } else if ( o=="cool" ) {
268 output |= COOL;
269 } else if ( isUnsignedInteger(o) ) {
270 coolOutputRunNr = static_cast<unsigned int>(std::stoul(o));
271 } else {
272 outBase = o;
273 }
274 }
275
276 if (outBase != "") {
277 if( output & JobConfig::COOL ) {
278 string dbname = "CONDBR2";
279 string outfile = outBase;
280 vector<string> ksv;
281 boost::split(ksv,outBase,boost::is_any_of(";"));
282 if(ksv.size()==2) { // defaults to CONDBR2
283 outfile = ksv[0];
284 dbname = ksv[1];
285 }
286 if (outfile.find("/")==string::npos && outfile.find('.')==string::npos) {
287 outfile="trig_cool_" + outfile + ".db";
288 }
289 coolOutputConnection = "sqlite://;schema="+outfile+";dbname="+dbname;
290 } else {
291 boost::replace_last(l1JsonOutFile, ".json", "_"+outBase+".json");
292 boost::replace_last(bgkJsonOutFile, ".json", "_"+outBase+".json");
293 boost::replace_last(l1PSJsonOutFile, ".json", "_"+outBase+".json");
294 boost::replace_last(hltJsonOutFile, ".json", "_"+outBase+".json");
295 boost::replace_last(hltPSJsonOutFile, ".json", "_"+outBase+".json");
296 }
297 }
298
299}
300
301
303 if(input==UNDEF)
304 return "Use argument '-i' to specify input source and check that the input is specified correctly";
305 if( input == DB ) {
306 if( db == "" )
307 return "No TriggerDB connection string specified";
308 if( keys.size()==0 )
309 return "No configuration key(s) specified";
310 }
311 if( input2 == DB ) {
312 if( db2 == "" )
313 return "No TriggerDB connection string specified for comparison, use option '--db2'";
314 if( keys2.size()==0 )
315 return "No smk specified for comparison, use option '--dbsmk2'";
316 }
317 return "";
318}
319
320
321void
322JobConfig::PrintSetup(std::ostream & log, std::ostream& (*lineend) ( std::ostream& os ) ) {
323 log << "========================================" << lineend;
324 log << "JOB SETUP: " << (input==DB?"DB":"COOL");
325 if(output!=UNDEF)
326 log << " --> " << (output==COOL?"COOL":"JSON");
327 log << lineend;
328 log << "----------" << lineend;
329 log << " Input : ";
330 for(const string& s: inpar) log << s << ", ";
331 log << lineend;
332 if( input2 != UNDEF ) {
333 log << " Input for comparison: ";
334 for(const string& s: inpar2) log << s << ", ";
335 log << lineend;
336 }
337 if( output != UNDEF ) {
338 log << " Output : ";
339 if( output&COOL ) {
341 if(coolOutputRunNr==0) { log << ", infinite IOV"; } else { log << ", run nr " << coolOutputRunNr; }
342 }
343 log << lineend;
344 }
345 if( printlevel>=0)
346 log << " Print menu detail : " << printlevel << lineend;
347 log << "========================================" << lineend;
348
349}
350
351
352int main( int argc, char* argv[] ) {
353
354 /***************************************
355 *
356 * Getting the program parameters
357 *
358 ***************************************/
359 JobConfig gConfig;
360 gConfig.parseProgramOptions(argc, argv);
361 if(gConfig.help) {
362 printhelp(cout, endl);
363 return 0;
364 }
365 if(gConfig.error.size()!=0) {
366 for(const string& e: gConfig.error)
367 cerr << e << endl;
368 printhelp(cout, endl);
369 return 1;
370 }
371
372 ofstream *outf(0), *errf(0);
373 if(gConfig.logFileName != "") {
374 string outfn = gConfig.logFileName+".out";
375 string errfn = gConfig.logFileName+".err";
376 outf = new ofstream(outfn.c_str());
377 errf = new ofstream(errfn.c_str());
378 }
379 ostream& log = (outf==0?cout:*outf);
380 ostream& logerr = (errf==0?cerr:*errf);
381 ostream& (*lineend) ( ostream& os ) = &endl;
382
383 string check = gConfig.CheckForCompleteSetup();
384 if( check != "" ) {
385 logerr << lineend << "===> Error in the option specification: " << check << lineend << lineend;
386 printhelp(log, lineend);
387 if(outf) outf->close();
388 if(errf) errf->close();
389 return 1;
390 }
391
392 gConfig.PrintSetup(log, lineend);
393
394
395 /***************************************
396 *
397 * Reading
398 *
399 ***************************************/
400 CTPConfig* ctpc(0);
401 BunchGroupSet* bgs(nullptr);
402 HLTFrame* hltFrame(0);
403 TXC::L1TopoMenu* l1tm = nullptr;
404 uint smk(0),l1psk(0),hltpsk(0),bgsk(0), mck{0};
405 string release;
406
407
408 /*------------------
409 * from DB
410 *-----------------*/
411 if (gConfig.input == JobConfig::DB) {
412 unique_ptr<StorageMgr> sm(new StorageMgr(gConfig.db, "", "", log));
413
414 // Loading L1 topo
415 //log << "Retrieving Lvl1 Topo configuration" << lineend;
416 l1tm = new TXC::L1TopoMenu();
417 l1tm->setSMK(gConfig.getKey(0));
418 sm->masterTableLoader().setLevel(gConfig.outputlevel);
419 sm->masterTableLoader().load(*l1tm);
420
421 //log << "Retrieving Lvl1 CTP configuration" << lineend;
422 ctpc = new TrigConf::CTPConfig();
423 ctpc->setSMK( gConfig.getKey(0) );
424 ctpc->setPrescaleSetId( gConfig.getKey(1) );
425 ctpc->setBunchGroupSetId( gConfig.getKey(3) );
426 sm->menuLoader().setEnv(IMenuLoader::CTPOnl);
427 ctpc->setLoadCtpFiles(gConfig.fw); // load CTP files ?
428 sm->masterTableLoader().setLevel( gConfig.outputlevel );
429 sm->masterTableLoader().load(*ctpc);
430 ctpc->muCTPi().setSMK( gConfig.getKey(0) );
431 sm->masterTableLoader().load( ctpc->muCTPi() );
432
433 //log << "Retrieving HLT menu configuration and prescale set from the TriggerDB" << lineend;
434 hltFrame = new HLTFrame();
435 hltFrame->setSMK( gConfig.getKey(0) );
436 if( gConfig.getKey(2)>0 )
438 sm->hltFrameLoader().setLevel( gConfig.outputlevel );
439 sm->hltFrameLoader().load( *hltFrame );
440
441 smk = gConfig.getKey(0);
442 l1psk = gConfig.getKey(1);
443 hltpsk = gConfig.getKey(2);
444 bgsk = gConfig.getKey(3);
445
446 // loading attached MCK
447 auto mckloader = new MCKLoader(*sm);
448 mckloader->loadMCKlinkedToSMK(smk, mck);
449 if ( mck != 0 ) {
450 mckloader->loadReleaseLinkedToMCK(mck,release);
451 log << "Loaded MCK " << mck << " (active for SMK " << smk << " and release " << release << ")" << endl;
452 } else {
453 log << "Did not load MCK from DB as MCK is 0 or no MCK is linked";
454 }
455
456 }
457 /*------------------
458 * from COOL
459 *-----------------*/
460 else if (gConfig.input == JobConfig::COOL) {
461 string coolInputConnection = gConfig.coolInputConnection;
462 unsigned int runnumber = gConfig.inpar.size()>1 ? static_cast<unsigned int>(std::stoul(gConfig.inpar[1])) : 1;
463 unsigned int lb = gConfig.inpar.size()>2 ? static_cast<unsigned int>(std::stoul(gConfig.inpar[2])) : 0;
464 log << "TrigConfReadWrite Reading cool : " << coolInputConnection << lineend;
465 log << " run number : " << runnumber << lineend;
466 log << " lb : " << lb << lineend;
467 TrigConfCoolWriter * coolWriter = new TrigConfCoolWriter( coolInputConnection );
468 string configSource("");
469 ctpc = new CTPConfig();
470 coolWriter->readL1Payload( runnumber, *ctpc);
471
472 PrescaleSet ps;
473 coolWriter->readL1PrescalePayload( runnumber, lb, l1psk, ps);
474 ctpc->setPrescaleSet( ps );
475
476 // log << "L1 PSK 0 " << ps.id() << lineend;
477 // log << "L1 PSK 1 " << l1psk << lineend;
478 // log << "L1 PSK 2 " << ctpc->prescaleSet().id() << lineend;
479 // log << "L1 PSK 3 " << ctpc->prescaleSetId() << lineend; <---- does not work
480
481 int bgKey(0);
482 coolWriter->readL1BunchGroupLBPayload( runnumber, lb, bgKey, ctpc->bunchGroupSet() );
483
484 hltFrame = new HLTFrame();
485 coolWriter->readHLTPayload(runnumber, *hltFrame);
486
487 if(lb!=0) {
488 HLTPrescaleSet * pss = new HLTPrescaleSet();
489 coolWriter->readHltPrescalePayload( runnumber, lb, *pss);
490 hltpsk = pss->id();
491 hltFrame->thePrescaleSetCollection().addPrescaleSet( lb, pss );
492 }
493
494 smk = hltFrame->smk();
495 bgsk = bgKey;
496
497 }
498
499 if(gConfig.printlevel>=0) {
500 log << "Loaded this configuration" << lineend;
501 log << " SMK " << smk << lineend;
502 log << " L1 PSK " << l1psk << lineend;
503 log << " HLT PSK " << hltpsk << lineend;
504 log << " BGSK " << bgsk << lineend;
505 if(ctpc) ctpc->print(" ", gConfig.printlevel);
506 if(bgs) bgs->print(" ", gConfig.printlevel);
507 if(hltFrame) hltFrame->print(" ", gConfig.printlevel);
508 }
509
510
511 if (gConfig.input2 != JobConfig::UNDEF) {
512 CTPConfig* ctpc2(0);
513 HLTFrame* hltFrame2(0);
514
515 /*------------------
516 * from DB
517 *-----------------*/
518 if (gConfig.input2 == JobConfig::DB) {
519 TrigConf::StorageMgr *sm = new TrigConf::StorageMgr(gConfig.db2, "", "", log);
520
521 log << "Retrieving Lvl1 CTP configuration for comparison" << lineend;
522 ctpc2 = new TrigConf::CTPConfig();
523 ctpc2->setSMK( gConfig.getKey2(0) );
524 ctpc2->setPrescaleSetId( gConfig.getKey2(1) );
525 ctpc2->setBunchGroupSetId( gConfig.getKey2(3) );
528 sm->masterTableLoader().load(*ctpc2);
529 ctpc2->muCTPi().setSMK( gConfig.getKey2(0) );
530 sm->masterTableLoader().load(ctpc2->muCTPi());
531
532 log << "Retrieving HLT menu configuration and prescale set from the TriggerDB for comparison" << lineend;
533 hltFrame2 = new HLTFrame();
534 hltFrame2->setSMK( gConfig.getKey2(0) );
535 if( gConfig.getKey2(2)>0)
537 sm->hltFrameLoader().load( *hltFrame2 );
538 delete sm;
539 } else if (gConfig.input2 == JobConfig::COOL) {
540 /*------------------
541 * from COOL
542 *-----------------*/
543 }
544
545 if(ctpc && ctpc2) {
546 bool equalMenus = ctpc->equals(ctpc2, "LVL1config_Diff.xml");
547 if(equalMenus) {
548 log << "LVL1 menus are identical." << lineend;
549 } else {
550 log << "LVL1 menus differ. Writing LVL1 menu comparison file LVL1config_Diff.xml" << lineend;
551 }
552 }
553 if(hltFrame && hltFrame2) {
554 bool equalMenus = hltFrame->equals(hltFrame2, "HLTconfig_Diff.xml");
555 if(equalMenus) {
556 log << "HLT menus are identical." << lineend;
557 } else {
558 log << "HLT menus differ. Writing HLT menu comparison file HLTconfig_Diff.xml" << lineend;
559 }
560 }
561
562 }
563
564
565 // ========================================
566 // Writing
567 // ========================================
568 if ( (gConfig.output & JobConfig::JSON) != 0 ) {
569 /*------------------
570 * to JSON
571 *-----------------*/
572 if(ctpc && l1tm) {
573 convertRun2L1MenuToRun3(ctpc, l1tm, gConfig.l1JsonOutFile);
576 }
577 if(hltFrame) {
578 convertRun2HLTMenuToRun3(hltFrame, gConfig.hltJsonOutFile);
580 }
581 }
582
583 if ( (gConfig.output & JobConfig::COOL) != 0 ) {
584 /*------------------
585 * to COOL
586 *-----------------*/
587 log << "TrigConfReadWrite: Writing sqlite cool file : " << gConfig.coolOutputConnection << " with ";
588 if( gConfig.coolOutputRunNr==0 ) { log << "infinite IOV"; } else { log << " runNr " << gConfig.coolOutputRunNr; }
589 log << lineend;
590 TrigConfCoolWriter * coolWriter = new TrigConfCoolWriter( gConfig.coolOutputConnection );
591 string configSource("");
592 string info("");
593 unsigned int runNr = gConfig.coolOutputRunNr;
594 if(runNr == 0) { runNr = 0x80000000; } // infinite range
595
596 if(ctpc) {
597 coolWriter->writeL1Payload(runNr, *ctpc);
598 }
599 try{
600 if(hltFrame) {
601 coolWriter->writeHLTPayload(runNr, *hltFrame, configSource);
602 }
603 }
604 catch(const cool::StorageTypeStringTooLong& e){
605 log << "FATAL: Unable to write data to COOL";
606 return 1;
607 }
608 if(mck) {
609 coolWriter->writeMCKPayload(runNr, mck, release, info);
610 }
611 }
612
613 delete ctpc;
614 delete hltFrame;
615 if(l1tm!=nullptr)
616 delete l1tm;
617
618 if( gConfig.jo ) {
619
620 JobOptionTable jot;
621 unique_ptr<IStorageMgr> sm( new StorageMgr(gConfig.db,"","",log) );
622
623 log << "TrigConfReadWrite: Retrieving JO from the TriggerDB" << lineend;
624 jot.setSMK( gConfig.getKey(0) );
625 jot.setTriggerLevel(0); // L2
626 sm->jobOptionTableLoader().setLevel(gConfig.outputlevel);
627 sm->jobOptionTableLoader().load( jot );
628 if(gConfig.printlevel>0) jot.print();
629 }
630
631}
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
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:223
string hltPSJsonOutFile
string coolInputConnection
std::vector< std::string > outpar
MSGTC::Level outputlevel
Definition CoolFix.cxx:101
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:103
string CheckForCompleteSetup()
void parseProgramOptions(int argc, char *argv[])
string outBase
std::vector< std::string > inpar
string l1PSJsonOutFile
bool help
Definition CoolFix.cxx:99
unsigned int coolOutputRunNr
string l1JsonOutFile
int printlevel
Definition CoolFix.cxx:100
unsigned int output
unsigned int getKey(unsigned int which)