00001 #define COMMON_MAIN_CPP
00002
00003
00004
00005 #include "GaudiKernel/SmartIF.h"
00006 #include "GaudiKernel/Bootstrap.h"
00007 #include "GaudiKernel/IAppMgrUI.h"
00008 #include "GaudiKernel/IProperty.h"
00009 #include <iostream>
00010 #include <fstream>
00011
00012
00013 static const char* rcsid = "$Id: BossMain.cxx,v 1.4 2013/11/21 01:07:52 dengzy Exp $";
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 int main( int argc, char* argv[] ) {
00026
00027
00028
00029 std::cout<<std::endl
00030 << "**************************************************" << std::endl
00031 << " BOSS version: "<<getenv("BES_RELEASE") << std::endl
00032 << "************** BESIII Collaboration **************" << std::endl
00033 << std::endl;
00034
00035 IInterface* iface = Gaudi::createApplicationMgr();
00036 SmartIF<IProperty> propMgr ( iface );
00037 SmartIF<IAppMgrUI> appMgr ( iface );
00038 if( !appMgr.isValid() || !propMgr.isValid() ) {
00039 std::cout << "Fatal error while creating the ApplicationMgr " << std::endl;
00040 return 1;
00041 }
00042
00043
00044 std:: string opts = (argc>1) ? argv[1] : "jobOptions.txt";
00045 std::cout<<"the jobOptions file is : " <<opts<<std::endl;
00046 std::ifstream fin(opts.c_str());
00047 if(fin.peek()==std::ifstream::traits_type::eof())
00048 {
00049 std::cout<<"ERROR! the jobOptions file is empty!"<<std::endl;
00050 exit(1);
00051 }
00052 std::string cont;
00053 std::string temp;
00054 while(!fin.eof())
00055 {
00056 fin>>temp;
00057 cont+=temp;
00058 }
00059 if(cont.size()<10)
00060 {
00061 std::cout<<"Please check your jobOptions."<<std::endl;
00062 exit(1);
00063 }
00064
00065
00066 propMgr->setProperty( "JobOptionsPath", opts );
00067 if( opts.substr( opts.length() - 3, 3 ) == ".py" ) {
00068
00069
00070 propMgr->setProperty( "JobOptionsType", "NONE" );
00071 propMgr->setProperty( "DLLs",
00072 "['BossServices', 'GaudiPython', 'McEventSelector' ,'GaudiSvc']" );
00073 propMgr->setProperty( "ExtSvc",
00074 "[ 'McEventSelector/EventSelector']" );
00075 propMgr->setProperty( "Runable", "PythonScriptingSvc" );
00076 propMgr->setProperty( "EventLoop", "BossEventLoopMgr" );
00077 propMgr->setProperty( "OutStreamType", "BossOutputStream" );
00078 }
00079
00080
00081 return (appMgr->run().isSuccess()) ? 0 : 1;
00082 }