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