3#include "GaudiKernel/IMessageSvc.h"
4#include "GaudiKernel/ISvcLocator.h"
5#include "GaudiKernel/Bootstrap.h"
6#include "GaudiKernel/Service.h"
7#include "GaudiKernel/StatusCode.h"
8#include "GaudiKernel/Property.h"
9#include "ParserUtils.h"
10#include "JobOptionsSvc.h"
13#define CheckSTATUS(msg) \
14 if ( sc.isFailure() ) { \
15 std::cout << "[JobOptionsMgr] " << msg << std::endl; \
21 sc = Gaudi::Parsers::parse(var, pprop->toString()); \
22 if ( sc.isFailure() ) { \
23 std::cout << "[JobOptionsMgr] Failed to parse " << #var << std::endl; \
33 m_dstFile(
"digi.root"),
34 m_recFile(
"digi.root")
37 StatusCode sc = Gaudi::svcLocator()->service(
"JobOptionsSvc", svc);
38 CheckSTATUS(
"Failed to retrieve the JobOptionsSvc");
39 m_svc =
dynamic_cast<JobOptionsSvc*
>(svc);
41 sc = m_svc->setProperty( StringProperty(
"TYPE",
"FILE") );
42 sc = m_svc->setProperty( StringProperty(
"PATH", optname) );
43 CheckSTATUS(
"Failed to set the property of DistBossServer");
45 sc = m_svc->initialize();
48 const Property* pprop = getProperty(
"ApplicationMgr",
"EvtMax");
49 if ( pprop != NULL ) {
53 if ( (pprop = getProperty(
"RawDataInputSvc",
"InputFiles")) != NULL ) {
57 else if ( (pprop = getProperty(
"BesSim",
"TDSFlag")) != NULL ) {
61 else if ( (pprop = getProperty(
"EventCnvSvc",
"digiRootInputFile")) != NULL ) {
66 std::cout <<
"[JobOptionsMgr] Unknown Job Type!" << std::endl;
70 if ( (pprop = getProperty(
"EventPreSelect",
"WriteDst")) != NULL ) {
74 m_oFileTypes.push_back(3);
75 if ( (pprop = getProperty(
"WriteDst",
"digiRootOutputFile")) != NULL ) {
81 if ( (pprop = getProperty(
"EventPreSelect",
"WriteRec")) != NULL ) {
85 m_oFileTypes.push_back(4);
86 if ( (pprop = getProperty(
"WriteRec",
"digiRootOutputFile")) != NULL ) {
92 if ( (pprop = getProperty(
"NTupleSvc",
"Output")) != NULL ) {
93 m_oFileTypes.push_back(5);
97 if ( (pprop = getProperty(
"THistSvc",
"Output")) != NULL ) {
98 m_oFileTypes.push_back(6);
105 StatusCode sc = m_svc->finalize();
109#define ignorePROPERTY(client, pname) \
110 if ( clients[i] == client && property->name() == pname ) continue
114 Gaudi::Parsers::Catalogue* m_clientCatalogue =
new Gaudi::Parsers::Catalogue;
118 std::vector<std::string> clients = m_svc->getClients();
119 for (
unsigned int i = 0; i < clients.size(); ++i ) {
120 const std::vector<const Property*>* properties = m_svc->getProperties(clients[i]);
121 for (
unsigned int j = 0; j < properties->size(); ++j ) {
122 const Property*
property = properties->at(j);
135 sc = m_clientCatalogue->addProperty(clients[i], property->name(), property->toString());
136 if ( sc.isFailure() ) {
137 m_clientCatalogue->addProperty(clients[i], property->name(),
'"'+property->toString()+
'"');
142 m_clientCatalogue->addProperty(
"DistBoss",
"ServerName",
'"'+svrName+
'"');
143 if ( m_iFileType == 0 ) {
144 m_clientCatalogue->addProperty(
"RawDataInputSvc",
"RunMode",
"3");
152 for (
unsigned int i = 0; i < m_oFileTypes.size(); ++i ) {
153 int type = m_oFileTypes[i];
155 m_clientCatalogue->addProperty(
"WriteDst",
"RunMode",
"3");
157 else if ( type == 4 ) {
158 m_clientCatalogue->addProperty(
"WriteRec",
"RunMode",
"3");
168 std::string client_opt_name = m_optName +
".distboss_client";
169 std::ofstream os(client_opt_name.c_str(), std::ios::out|std::ios::trunc);
171 std::cout <<
"[JobOptionsMgr] Failed to open client_template file!" << std::endl;
175 m_clientCatalogue->fillStream( os );
177 delete m_clientCatalogue;
180const Property* JobOptionsMgr::getProperty(
const std::string& client,
const std::string& name)
182 const Property* pprop = NULL;
184 const std::vector<const Property*>* properties = m_svc->getProperties(client);
185 if ( properties != NULL ) {
186 for (
unsigned int i = 0; i < properties->size(); ++i ) {
187 if ( properties->at(i)->name() == name) {
188 pprop = properties->at(i);
#define ignorePROPERTY(client, pname)
void clientOptsTemplate(const std::string &svrName)
JobOptionsMgr(const std::string &optname)