13 #include "GaudiKernel/Bootstrap.h"
14 #include "GaudiKernel/IProperty.h"
15 #include "GaudiKernel/ISvcManager.h"
16 #include "GaudiKernel/ISvcLocator.h"
17 #include "GaudiKernel/IAppMgrUI.h"
18 #include "GaudiKernel/SmartIF.h"
19 #include "GaudiKernel/ModuleIncident.h"
28 bool initGaudi(
const std::string& jobOptsFile, ISvcLocator*& pSvcLoc) {
29 string jobOptsPath = jobOptsFile;
30 if (
access (jobOptsPath.c_str(), R_OK) != 0)
31 jobOptsPath =
"../share/"+jobOptsFile;
32 if (
access (jobOptsPath.c_str(), R_OK) != 0) {
33 const char* jopath =
getenv (
"JOBOPTSEARCHPATH");
35 char* savepath =
new char[strlen(jopath)+1];
36 strcpy (savepath, jopath);
37 char* saveptr =
nullptr;
39 while (
char* tok = strtok_r (
str,
":", &saveptr)) {
41 jobOptsPath = std::string(tok) +
"/" + jobOptsFile;
42 if (
access (jobOptsPath.c_str(), R_OK) == 0) {
51 if (jobOptsPath.empty()) {
52 cout <<
"\n\nCannot find job opts " << jobOptsFile << endl;
55 cout <<
"\n\nInitializing Gaudi ApplicationMgr using job opts " << jobOptsPath << endl;
59 IInterface* iface = Gaudi::createApplicationMgr();
61 cout <<
"Fatal error while creating the ApplicationMgr " << endl;
65 SmartIF<ISvcManager>
svcMgr(iface);
66 SmartIF<IAppMgrUI> appMgr(iface);
67 SmartIF<IProperty> propMgr(iface);
68 SmartIF<ISvcLocator> svcLoc(iface);
69 if(!svcLoc.isValid() || !appMgr.isValid() || !
svcMgr.isValid() || !propMgr.isValid()) {
70 cout <<
"Fatal error while creating the AppMgr smart if " << endl;
74 pSvcLoc = svcLoc.pRef();
76 propMgr->setProperty(
"EvtSel",
"NONE" ).
77 orThrow(
"Cannnot set EvtSel property",
"initGaudi");
78 if (jobOptsFile.empty()) {
79 propMgr->setProperty(
"JobOptionsType",
"NONE" ).
80 orThrow(
"Cannnot set JobOptionsType property",
"initGaudi");
82 propMgr->setProperty(
"JobOptionsType",
"FILE" ).
83 orThrow(
"Cannnot set JobOptionsType property",
"initGaudi");
84 propMgr->setProperty(
"JobOptionsPath", jobOptsPath ).
85 orThrow(
"Cannnot set JobOptionsPath property",
"initGaudi");
88 if ((appMgr->configure()).isSuccess() &&
89 (appMgr->initialize()).isSuccess()) {
90 cout<<
"ApplicationMgr Ready"<<endl;
93 cout <<
"Fatal error while initializing the AppMgr" << endl;
114 ModuleLoadedIncident inc2 (
"",
"");