BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
JobOptionsMgr Class Reference

#include <JobOptionsMgr.h>

Public Member Functions

 JobOptionsMgr (const std::string &optname)
 
virtual ~JobOptionsMgr ()
 
const std::string & optName ()
 
int inputType ()
 
int evtMax ()
 
const std::vector< std::string > & inputFiles ()
 
const std::vector< int > & outputTypes ()
 
const std::string & dstFile ()
 
const std::string & recFile ()
 
const std::vector< std::string > & tupleOpts ()
 
const std::vector< std::string > & histOpts ()
 
void clientOptsTemplate (const std::string &svrName)
 

Detailed Description

Definition at line 11 of file JobOptionsMgr.h.

Constructor & Destructor Documentation

◆ JobOptionsMgr()

JobOptionsMgr::JobOptionsMgr ( const std::string &  optname)

Definition at line 29 of file JobOptionsMgr.cxx.

30 : m_optName(optname),
31 m_iFileType(-1),
32 m_evtMax(10),
33 m_dstFile("digi.root"),
34 m_recFile("digi.root")
35{
36 IService* svc;
37 StatusCode sc = Gaudi::svcLocator()->service("JobOptionsSvc", svc);
38 CheckSTATUS("Failed to retrieve the JobOptionsSvc");
39 m_svc = dynamic_cast<JobOptionsSvc*>(svc);
40
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");
44
45 sc = m_svc->initialize();
46 CheckSTATUS("Failed to initialize JobOptionsSvc");
47
48 const Property* pprop = getProperty("ApplicationMgr", "EvtMax");
49 if ( pprop != NULL ) {
50 MyPARSE( m_evtMax );
51 }
52
53 if ( (pprop = getProperty("RawDataInputSvc", "InputFiles")) != NULL ) {
54 m_iFileType = 0;
55 MyPARSE( m_inputFiles );
56 }
57 else if ( (pprop = getProperty("BesSim", "TDSFlag")) != NULL ) {
58 m_iFileType = 1;
59 // to be continued ...
60 }
61 else if ( (pprop = getProperty("EventCnvSvc", "digiRootInputFile")) != NULL ) {
62 m_iFileType = 2;
63 MyPARSE( m_inputFiles );
64 }
65 else {
66 std::cout << "[JobOptionsMgr] Unknown Job Type!" << std::endl;
67 exit(1);
68 }
69
70 if ( (pprop = getProperty("EventPreSelect","WriteDst")) != NULL ) {
71 bool status;
72 MyPARSE(status);
73 if ( status ) {
74 m_oFileTypes.push_back(3);
75 if ( (pprop = getProperty("WriteDst", "digiRootOutputFile")) != NULL ) {
76 MyPARSE( m_dstFile );
77 }
78 }
79 }
80
81 if ( (pprop = getProperty("EventPreSelect","WriteRec")) != NULL ) {
82 bool status;
83 MyPARSE(status);
84 if ( status ) {
85 m_oFileTypes.push_back(4);
86 if ( (pprop = getProperty("WriteRec", "digiRootOutputFile")) != NULL ) {
87 MyPARSE( m_recFile );
88 }
89 }
90 }
91
92 if ( (pprop = getProperty("NTupleSvc", "Output")) != NULL ) {
93 m_oFileTypes.push_back(5);
94 MyPARSE( m_tupleOpts );
95 }
96
97 if ( (pprop = getProperty("THistSvc", "Output")) != NULL ) {
98 m_oFileTypes.push_back(6);
99 MyPARSE( m_histOpts);
100 }
101}
#define CheckSTATUS(msg)
#define MyPARSE(var)

Referenced by JobOptionsMgr().

◆ ~JobOptionsMgr()

JobOptionsMgr::~JobOptionsMgr ( )
virtual

Definition at line 103 of file JobOptionsMgr.cxx.

104{
105 StatusCode sc = m_svc->finalize();
106 CheckSTATUS("Failed to finalize JobOptionsSvc!");
107}

Member Function Documentation

◆ clientOptsTemplate()

void JobOptionsMgr::clientOptsTemplate ( const std::string &  svrName)

Definition at line 112 of file JobOptionsMgr.cxx.

113{
114 //Gaudi::Parsers::Catalogue* m_clientCatalogue = new Gaudi::Parsers::Catalogue;
115 SvcCatalog* m_clientCatalogue = new SvcCatalog;
116
117 StatusCode sc;
118
119 std::vector<std::string> clients = m_svc->getClients();
120 for ( unsigned int i = 0; i < clients.size(); ++i ) {
121 const std::vector<const Property*>* properties = m_svc->getProperties(clients[i]);
122 for ( unsigned int j = 0; j < properties->size(); ++j ) {
123 const Property* property = properties->at(j);
124
125 ignorePROPERTY("ApplicationMgr", "EvtMax");
126
127 ignorePROPERTY("RawDataInputSvc", "InputFiles");
128 //ignorePROPERTY("BesRndmGenSvc", "RndmSeed"); //placeholder for simulation
129 ignorePROPERTY("EventCnvSvc", "digiRootInputFile");
130
131 ignorePROPERTY("WriteDst", "digiRootOutputFile");
132 ignorePROPERTY("WriteRec", "digiRootOutputFile");
133 //ignorePROPERTY("NTupleSvc", "Output"); //placeholder for NTupleSvc
134 //ignorePROPERTY("THistSvc", "Output"); //placeholder for THistSvc
135
136 StringProperty* tmp= new StringProperty(property->name(), property->toString());
137 sc = m_clientCatalogue->addProperty(clients[i], tmp);
138 if ( sc.isFailure() ) {
139 StringProperty* tmp2 = new StringProperty(property->name(), '"'+property->toString()+'"');
140 m_clientCatalogue->addProperty(clients[i], tmp2);
141 }
142 }
143 }
144
145 StringProperty* tmpservername = new StringProperty("ServerName", '"'+svrName+'"');
146 m_clientCatalogue->addProperty("DistBoss", tmpservername);
147 if ( m_iFileType == 0 ) {
148 StringProperty* tmprunmode = new StringProperty("RunMode", "3");
149 m_clientCatalogue->addProperty("RawDataInputSvc", tmprunmode);
150 }
151 //else if ( m_iFileType == 1 ) { //placeholder for simulation
152 // m_clientCatalogue->addProperty("BesRndmGenSvc", "RunMode", "3");
153 //}
154 //else if ( m_iFileType == 2 ) {
155 // m_clientCatalogue->addProperty("EventCnvSvc", "RunMode", "3");
156 //}
157 for ( unsigned int i = 0; i < m_oFileTypes.size(); ++i ) {
158 int type = m_oFileTypes[i];
159 if ( type == 3 ) {
160 m_clientCatalogue->addProperty("WriteDst", new StringProperty("RunMode", "3"));
161 }
162 else if ( type == 4 ) {
163 m_clientCatalogue->addProperty("WriteRec", new StringProperty("RunMode", "3"));
164 }
165 //else if ( type == 5 ) {
166 // m_clientCatalogue->addProperty("NTupleSvc", "RunMode", "3");
167 //}
168 //else if ( type == 6 ) {
169 // m_clientCatalogue->addProperty("THistSvc", "RunMode", "3");
170 //}
171 }
172
173 std::string client_opt_name = m_optName + ".distboss_client";
174 std::ofstream os(client_opt_name.c_str(), std::ios::out|std::ios::trunc);
175 if ( ! os ) {
176 std::cout << "[JobOptionsMgr] Failed to open client_template file!" << std::endl;
177 exit(1);
178 }
179
180 m_clientCatalogue->fillStream( os );
181
182 delete m_clientCatalogue;
183}
#define ignorePROPERTY(client, pname)

Referenced by DistBossServer::DistBossServer().

◆ dstFile()

const std::string & JobOptionsMgr::dstFile ( )
inline

Definition at line 25 of file JobOptionsMgr.h.

25{ return m_dstFile; }

Referenced by DistBossServer::DistBossServer().

◆ evtMax()

int JobOptionsMgr::evtMax ( )
inline

Definition at line 21 of file JobOptionsMgr.h.

21{ return m_evtMax; }

Referenced by DistBossServer::DistBossServer().

◆ histOpts()

const std::vector< std::string > & JobOptionsMgr::histOpts ( )
inline

Definition at line 28 of file JobOptionsMgr.h.

28{ return m_histOpts; }

◆ inputFiles()

const std::vector< std::string > & JobOptionsMgr::inputFiles ( )
inline

Definition at line 22 of file JobOptionsMgr.h.

22{ return m_inputFiles; }

Referenced by DistBossServer::DistBossServer().

◆ inputType()

int JobOptionsMgr::inputType ( )
inline

Definition at line 20 of file JobOptionsMgr.h.

20{ return m_iFileType; }

Referenced by DistBossServer::DistBossServer().

◆ optName()

const std::string & JobOptionsMgr::optName ( )
inline

Definition at line 18 of file JobOptionsMgr.h.

18{ return m_optName; }

◆ outputTypes()

const std::vector< int > & JobOptionsMgr::outputTypes ( )
inline

Definition at line 24 of file JobOptionsMgr.h.

24{ return m_oFileTypes; }

Referenced by DistBossServer::DistBossServer().

◆ recFile()

const std::string & JobOptionsMgr::recFile ( )
inline

Definition at line 26 of file JobOptionsMgr.h.

26{ return m_recFile; }

Referenced by DistBossServer::DistBossServer().

◆ tupleOpts()

const std::vector< std::string > & JobOptionsMgr::tupleOpts ( )
inline

Definition at line 27 of file JobOptionsMgr.h.

27{ return m_tupleOpts; }

The documentation for this class was generated from the following files: