ATLAS Offline Software
Functions
genCLIDDB.cxx File Reference
#include <iostream>
#include <string>
#include "GaudiKernel/IClassManager.h"
#include "GaudiKernel/IProperty.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/SmartIF.h"
#include "GaudiKernel/IAppMgrUI.h"
#include "GaudiKernel/IClassIDSvc.h"
#include "GaudiKernel/Bootstrap.h"
#include "AthenaKernel/errorcheck.h"
#include <boost/program_options.hpp>

Go to the source code of this file.

Functions

int doBanner ()
 
int inputError (const std::string &errDescr, const po::options_description &optDescr)
 
IAppMgrUI * initGaudi (const std::string &options, bool verbose, ISvcLocator *&svcLocator)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ doBanner()

int doBanner ( )

Definition at line 23 of file genCLIDDB.cxx.

23 { return 0; }

◆ initGaudi()

IAppMgrUI* initGaudi ( const std::string &  options,
bool  verbose,
ISvcLocator *&  svcLocator 
)

Definition at line 31 of file genCLIDDB.cxx.

31  {
32  IAppMgrUI* theApp = Gaudi::createApplicationMgr();
33  SmartIF<IProperty> propMgr(theApp);
34  if(strlen(options.c_str())) {
35  CHECK_WITH_CONTEXT( propMgr->setProperty("JobOptionsPath", options), "initGaudi", nullptr );
36  } else {
37  //no joboptions given
38  CHECK_WITH_CONTEXT( propMgr->setProperty("JobOptionsType", "NONE"), "initGaudi", nullptr );
39  }
40  if (!verbose) {
41  CHECK_WITH_CONTEXT( propMgr->setProperty("OutputLevel", MSG::WARNING), "initGaudi", nullptr );
42  }
43  CHECK_WITH_CONTEXT( theApp->configure(), "initGaudi", nullptr );
44  CHECK_WITH_CONTEXT( theApp->initialize(), "initGaudi", nullptr );
45  svcLocator = Gaudi::svcLocator();
46  return theApp;
47 
48 }

◆ inputError()

int inputError ( const std::string &  errDescr,
const po::options_description &  optDescr 
)

Definition at line 25 of file genCLIDDB.cxx.

25  {
26  std::cerr << errDescr << "\n" << optDescr << std::endl;
27  return 1;
28 }

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 50 of file genCLIDDB.cxx.

50  {
51  // Declare the supported options.
52 
53  const std::string appName("genCLIDDB");
54  po::options_description desc(appName + " allowed options");
55  desc.add_options()
56  ("help,h", "produce help message")
57  ("package,p", po::value<std::string>(), "package we want to load clids from")
58  ("input,i", po::value<std::string>(), "optional path to input clid db file")
59  ("output,o", po::value<std::string>(), "optional path to resulting clid db file")
60  ("jobopts,j", po::value<std::string>(), "name of optional job options txt file, located at ../share/jobopts")
61  ("verbose,v", po::value<bool>()->implicit_value(true), "verbose output")
62  ;
63  std::string packageName("ALL");
64  std::string inputCLIDDB;
65  std::string outFileName;
66 
67  po::variables_map vm;
68  try {
69  po::store(po::parse_command_line(argc, argv, desc), vm);
70  po::notify(vm);
71  } catch (const std::exception& e) {
72  return inputError(e.what(), desc);
73  }
74 
75  if (vm.count("help")) {
76  std::cout << desc << std::endl;
77  return 0;
78  }
79 
80  if (vm.count("package")) {
81  packageName = vm["package"].as<std::string>();
82  } else {
83  return inputError("Please specify a package using option --package.\n", desc);
84  }
85 
86  if (vm.count("output")) {
87  outFileName = vm["output"].as<std::string>();
88  } else {
89  outFileName = packageName + "_clid.db";
90  }
91 
92  bool verbose = vm.count("verbose") && vm["verbose"].as<bool>();
93 
94  // Initialize Gaudi
95  ISvcLocator* pSvcLoc(nullptr);
96  std::string jobopts("CLIDComps/minimalPrintout.opts");
97  if (vm.count("jobopts")) {
98  jobopts = vm["jobopts"].as<std::string>();
99  }
100  if (!initGaudi(jobopts, verbose, pSvcLoc)) {
101  std::cerr << "cannot initialize Gaudi" << std::endl;
102  return 2;
103  }
104 
105  // Now we can use the MessagesSvc
106  SmartIF<IMessageSvc> msgSvc(pSvcLoc);
107  CHECK_WITH_CONTEXT( msgSvc.isValid(), appName, 2 );
108 
109  MsgStream log(msgSvc, appName);
110  if (!verbose) {
111  log.setLevel(MSG::WARNING);
112  }
113 
114  SmartIF<IClassManager> pICM(pSvcLoc);
115  CHECK_WITH_CONTEXT( pICM.isValid(), appName, 2 );
116 
117  SmartIF<IClassIDSvc> pClassIDSvc(pSvcLoc->service("ClassIDSvc"));
118  CHECK_WITH_CONTEXT( pClassIDSvc.isValid(), appName, 2 );
119 
120  SmartIF<IProperty> pCLIDSvcProp(pClassIDSvc);
121  CHECK_WITH_CONTEXT( pCLIDSvcProp.isValid(), appName, 2 );
122 
123  log << MSG::INFO << "Writing clid.db for package "
124  << vm["package"].as<std::string>() << " to " << outFileName << "." << endmsg;
125 
126  // Set properties on CLIDSvc
127  std::string dbfiles("{}");
128  if (vm.count("input")) {
129  log << MSG::INFO << "Reading clid.db from " << vm["input"].as<std::string>() << "." << endmsg;
130  dbfiles = "{\"" + vm["input"].as<std::string>() + "\"}";
131  }
132  CHECK_WITH_CONTEXT( pCLIDSvcProp->setProperty("CLIDDBFiles", dbfiles), appName, 2 );
133  CHECK_WITH_CONTEXT( pCLIDSvcProp->setProperty("OutputFileName", outFileName), appName, 2 );
134 
135  // Load the module
136  CHECK_WITH_CONTEXT( pICM->loadModule(packageName), appName, 2 );
137 
138  //fill clid db
139  CHECK_WITH_CONTEXT( pClassIDSvc->reinitialize(), appName, 2 );
140 
141  //write out merged clid db on service finalize
142  return (pClassIDSvc->finalize()).isSuccess() ? 0 : -1;
143 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SGTest::store
TestStore store
Definition: TestStore.cxx:23
initGaudi
IAppMgrUI * initGaudi(const std::string &options, bool verbose, ISvcLocator *&svcLocator)
Definition: genCLIDDB.cxx:31
CHECK_WITH_CONTEXT
#define CHECK_WITH_CONTEXT(...)
Evaluate an expression and check for errors, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:396
inputError
int inputError(const std::string &errDescr, const po::options_description &optDescr)
Definition: genCLIDDB.cxx:25
DumpGeoConfig.outFileName
string outFileName
Definition: DumpGeoConfig.py:252
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
calibdata.exception
exception
Definition: calibdata.py:496
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:379
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
beamspotman.jobopts
jobopts
Definition: beamspotman.py:1106
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
python.AppMgr.theApp
theApp
Definition: AppMgr.py:771