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  if (!msgSvc.isValid()) {
108  std::cerr << "cannot retrieve MessageSvc" << std::endl;
109  return 2;
110  }
111  MsgStream log(msgSvc, appName);
112  if (!verbose) {
113  log.setLevel(MSG::WARNING);
114  }
115 
116  SmartIF<IClassManager> pICM(pSvcLoc);
117  if (!pICM.isValid()) {
118  log << MSG::ERROR << "cannot retrieve ClassManager" << endmsg;
119  return 2;
120  }
121 
122  IClassIDSvc* pClassIDSvc(nullptr);
123  CHECK_WITH_CONTEXT( pSvcLoc->service("ClassIDSvc", pClassIDSvc, true), appName, 2 );
124 
125  SmartIF<IProperty> pCLIDSvcProp(pClassIDSvc);
126  if (!pCLIDSvcProp.isValid()) {
127  log << MSG::ERROR << "cannot retrieve ClassIDSvc" << std::endl;
128  return 2;
129  }
130 
131  log << MSG::INFO << "Writing clid.db for package "
132  << vm["package"].as<std::string>() << " to " << outFileName << "." << endmsg;
133 
134  // Set properties on CLIDSvc
135  std::string dbfiles("{}");
136  if (vm.count("input")) {
137  log << MSG::INFO << "Reading clid.db from " << vm["input"].as<std::string>() << "." << endmsg;
138  dbfiles = "{\"" + vm["input"].as<std::string>() + "\"}";
139  }
140  CHECK_WITH_CONTEXT( pCLIDSvcProp->setProperty("CLIDDBFiles", dbfiles), appName, 2 );
141  CHECK_WITH_CONTEXT( pCLIDSvcProp->setProperty("OutputFileName", outFileName), appName, 2 );
142 
143  // Load the module
144  CHECK_WITH_CONTEXT( pICM->loadModule(packageName), appName, 2 );
145 
146  //fill clid db
147  CHECK_WITH_CONTEXT( pClassIDSvc->reinitialize(), appName, 2 );
148 
149  //write out merged clid db on service finalize
150  return (pClassIDSvc->finalize()).isSuccess() ? 0 : -1;
151 }
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
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
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
DumpGeoConfig.outFileName
string outFileName
Definition: DumpGeoConfig.py:238
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
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
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
python.AppMgr.theApp
theApp
Definition: AppMgr.py:764