00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <iostream.h>
00017 #include <string.h>
00018 #include <stdlib.h>
00019 #include "TROOT.h"
00020 #include "TRint.h"
00021 #include "TApplication.h"
00022 #include "TH1.h"
00023 #include "TBrowser.h"
00024 #include "TCanvas.h"
00025 #include "TBenchmark.h"
00026 #include "Go4ProfileTimer/TGo4ProfileTimer.h"
00027 #include "TMeshAnalysis.h"
00028 #include "Go4AnalysisClient/TGo4AnalysisClient.h"
00029 #include "Go4EventServer/Go4EventServer.h"
00030
00031 void usage();
00032
00033 TROOT go4application("GO4","Go4 user analysis");
00034
00035 #define kGUI 2
00036 #define kBatch 1
00037
00038
00039 int main(int argc, char **argv)
00040 {
00041 if(argc < 3) {
00042 usage();
00043 exit(0);
00044 }
00045
00046
00047 TApplication theApp("Go4App", 0, 0);
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 Int_t runningMode;
00064 Int_t maxevents = -1;
00065 Int_t intype=GO4EV_NULL;
00066 Bool_t writeout1=kFALSE;
00067 Bool_t writeout2=kFALSE;
00068 UInt_t iport;
00069 UInt_t sport=6003;
00070 Int_t iarg;
00071 Text_t serv[128];
00072 Text_t out[128];
00073 Text_t anl[128];
00074 Text_t asf[128];
00075 Text_t filetype[8];
00076 Text_t *pc,*tmpname,*outname;
00077 TMeshAnalysis* analysis;
00078
00079
00080
00081
00082
00083 strcpy(filetype,".lmd");
00084 tmpname=argv[2]+strlen(argv[2])-4;
00085 if((pc=strstr(tmpname,".lmd")) != 0)*pc=0;
00086 if((pc=strstr(tmpname,".lml")) != 0){*pc=0;strcpy(filetype,".lml");}
00087 tmpname=argv[2];
00088 if((pc=strstr(argv[2],"@")) != 0) tmpname++;
00089 outname=tmpname;
00090 if((tmpname=strrchr(outname,'/')) != 0) outname=tmpname+1;
00091 strncpy(asf,outname,110);
00092 strcat(asf,"_AS");
00093
00094 if(strcmp(argv[1],"-gui") == 0)
00095 {
00096
00097 runningMode = kGUI;
00098 iport = (argc>4) ? atoi(argv[4]) : 5000;
00099 intype=GO4EV_MBS_FILE;
00100 writeout1=kFALSE;
00101 writeout2=kFALSE;
00102 strcpy(serv,"/GSI/lea/gauss");
00103 strcpy(out,"gauss_MeshRawEvent");
00104 strcpy(anl,"gauss_MeshAnl");
00105 }
00106 else
00107
00108 {
00109 strncpy(out,outname,110);
00110 strcat(out,"_XXXEvent");
00111 strncpy(anl,outname,110);
00112 strcat(anl,"_XXXAnl");
00113 runningMode = kBatch;
00114 strncpy(serv,argv[2],110);
00115 if(strstr(argv[1],"-f")){intype=GO4EV_MBS_FILE;strcat(serv,filetype);}
00116 else if(strstr(argv[1],"-t")) intype=GO4EV_MBS_TRANSPORT;
00117 else if(strstr(argv[1],"-s")) intype=GO4EV_MBS_STREAM;
00118 else if(strstr(argv[1],"-e")) intype=GO4EV_MBS_EVENTSERVER;
00119 else if(strstr(argv[1],"-r")) intype=GO4EV_MBS_REVSERV;
00120 else {
00121 cout << "invalid input type: " << argv[1] << endl;
00122 usage();
00123 exit(0);
00124 }
00125 iarg=3;
00126 if(argc > iarg){
00127 if(strstr(argv[iarg],"-o"))writeout2=kTRUE;
00128 else if(strstr(argv[iarg],"-p")){iarg++; sport=atoi(argv[iarg]);}
00129 else maxevents=atoi(argv[iarg]);
00130 iarg++;
00131 }
00132 if(argc > iarg){
00133 if(strstr(argv[iarg],"-o"))writeout2=kTRUE;
00134 else maxevents=atoi(argv[iarg]);
00135 iarg++;
00136 }
00137 if(argc > iarg)maxevents=atoi(argv[iarg]);
00138 if(maxevents == -1) maxevents = 99999999;
00139 cout << endl << "**** Input " << serv << " (" << argv[1] << ") ";
00140 if(strstr(argv[1],"-r")) cout << "port " << sport;
00141 cout << endl << " output step1: " << out << ".root";
00142 if(writeout1) cout << " enabled"; else cout << " disabled";
00143 cout << endl << " output step2: " << anl << ".root";
00144 if(writeout2) cout << " enabled"; else cout << " disabled";
00145 cout << endl << " process " << maxevents << " events" << endl;
00146 cout << " auto save file: " << asf << ".root" << endl << endl;
00147 }
00148
00149
00150
00151
00152 TGo4Log::Instance();
00153 TGo4Log::SetIgnoreLevel(1);
00154
00155
00156 TGo4Log::OpenLogfile("XXXLogfile.txt","--Logfile for go4 XXX--",kFALSE);
00157 TGo4Log::LogfileEnable(kFALSE);
00158
00159 analysis = new TMeshAnalysis(serv,intype,sport,out,anl,writeout1,writeout2);
00160
00161 analysis->SetAutoSaveFile(asf);
00162 analysis->SetAutoSaveInterval(0);
00163 analysis->SetAutoSave(kFALSE);
00164
00165
00166
00167 if(runningMode == kBatch)
00168 {
00169 cout << "**** Main: starting analysis in batch mode ... " << endl;
00170 analysis->SetAutoSave(kTRUE);
00171 if (analysis->InitEventClasses() )
00172 {
00173 analysis->RunImplicitLoop(maxevents);
00174 delete analysis;
00175 cout << "**** Main: Done!"<<endl;
00176 gApplication->Terminate();
00177 }
00178 else
00179 {
00180 cout << "**** Main: Init event classes failed, aborting!"<<endl;
00181 gApplication->Terminate();
00182 }
00183 }
00184 if(runningMode == kGUI)
00185 {
00186 cout << "**** Main: starting analysis in client mode ..." << endl;
00187
00188 TGo4AnalysisClient* client = new TGo4AnalysisClient(argc,argv,analysis,kFALSE,"","");
00189 cout << "**** Main created AnalysisClient Instance: "<<client->GetName()<<endl;
00190 }
00191
00192 cout << "Run the application loop" << endl;
00193 theApp.Run();
00194 return 0;
00195 }
00196
00197 void usage()
00198 {
00199 cout << endl;
00200 cout << "* GO4 online analysis " << endl;
00201 cout << "* H. Essel, GSI, Darmstadt" << endl;
00202 cout << "* calling: " << endl;
00203 cout << "* MainUserAnalysis -file|-trans|-stream|-evserv|-revserv input [-port #] [-output] [events]" <<endl;
00204 cout << endl;
00205 }
00206
00207