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