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 "TBenchmark.h"
00024 #include "Go4ProfileTimer/TGo4ProfileTimer.h"
00025 #include "TYYYAnalysis.h"
00026 #include "Go4AnalysisClient/TGo4AnalysisClient.h"
00027
00028 void usage();
00029
00030 TROOT go4application("The GO4","This is the Go4");
00031
00032 #define kGUI 2
00033 #define kBatch 1
00034
00035
00036
00037
00038 int main(int argc, char **argv)
00039 {
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 const Text_t* inputsuffix=".scf";
00052
00053 printf("\n%s started with args:\n",argv[0]);
00054 for(int i=1;i<argc;i++)printf("%d: %s\n",i,argv[i]);
00055
00056 if(argc < 2) {
00057 usage();
00058 exit(0);
00059 }
00060 Int_t runningMode = kGUI;
00061 if(strcmp(argv[1],"-gui") != 0) runningMode = kBatch;
00062
00063
00064 TApplication theApp("App", 0, 0);
00065
00066
00067 TGo4Log::Instance();
00068 TGo4Log::SetIgnoreLevel(1);
00069
00070
00071 TGo4Log::OpenLogfile("go4YYYlog.txt","--Logfile for go4 YYY --",kFALSE);
00072 TGo4Log::LogfileEnable(kFALSE);
00073
00074
00075
00076
00077
00078
00079
00080
00081 Int_t maxevents = -1;
00082 Int_t len;
00083 unsigned int iport;
00084 Text_t input[128];
00085 if(runningMode == kGUI){
00086 len = strlen(argv[2]);
00087 strncpy(input,argv[2],110);
00088 iport = (argc>4) ? atoi(argv[4]) : 5000;
00089 }
00090 else{
00091 len = strlen(argv[1]);
00092 strncpy(input,argv[1],110);
00093 if(argc > 2) maxevents=atoi(argv[2]);
00094 }
00095 if(maxevents == -1) maxevents = 99999999;
00096
00097
00098 Text_t lmd[len+5];
00099 Text_t asf[len+5];
00100 Text_t raw[len+5];
00101 Text_t anl[len+5];
00102
00103 char *pc;
00104 if((pc=strstr(input,".lmd")) != 0)*pc=0;
00105
00106
00107 Text_t* lastname=input;
00108 Text_t* outname=lastname;
00109 lastname=strstr(outname,"/");
00110 while(lastname!=0)
00111 {
00112 outname=lastname+1;
00113 lastname=strstr(outname,"/");
00114 }
00115 strncpy(lmd,input,len+4);
00116 strncpy(asf,outname,len+4);
00117 strncpy(raw,outname,len+4);
00118 strncpy(anl,outname,len+4);
00119 strcat(lmd,inputsuffix);
00120 strcat(asf,"_ASF");
00121 strcat(raw,"_UPA");
00122 strcat(anl,"_ANL");
00123 printf("Files used: \nFile input: %s\nAutosave: %s\nUnpacked: %s\nAnalyzed: %s\n",
00124 lmd,asf,raw,anl);
00125
00126
00127 TYYYAnalysis*
00128 analysis = new TYYYAnalysis(lmd,raw,anl);
00129
00130
00131
00132 analysis->SetAutoSaveFile(asf);
00133 analysis->SetAutoSaveInterval(0);
00134
00135
00136
00137
00138
00139
00140
00141 if(runningMode == kBatch)
00142 {
00143 cout << "* starting analysis in batch mode ... " << endl;
00144 if (analysis->InitEventClasses() )
00145 {
00146
00147
00148 analysis->RunImplicitLoop(maxevents);
00149
00150
00151
00152 delete analysis;
00153 cout << "\t Done!"<<endl;
00154 gApplication->Terminate();
00155 }
00156 else
00157 {
00158 cout << "Init event classes failed, aborting!"<<endl;
00159 gApplication->Terminate();
00160 }
00161 }
00162
00163 if(runningMode == kGUI)
00164 {
00165 cout << "* starting analysis in client mode ..." << endl;
00166 TGo4AnalysisClient* client = new TGo4AnalysisClient(argc,argv,analysis,
00167 kTRUE,"YYY","demo");
00168 cout << "Created AnalysisClient Instance: "<<client->GetName()<<endl;
00169 }
00170 theApp.Run();
00171 return 0;
00172 }
00173
00174 void usage()
00175 {
00176 cout << endl;
00177 cout << " ************************************************" << endl;
00178 cout << "* GO4 YYY analysis with user input example *" << endl;
00179 cout << "* H. Essel, J.Adamczewski , GSI, Darmstadt *" << endl;
00180 cout << "* usage: MainUserAnalysis file [events] *" <<endl;
00181 cout << " ************************************************" << endl;
00182 }
00183
00184
00185
00186
00187
00188