Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4ExampleUserSource/MainUserAnalysis.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
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(); // print announcement
00029 
00030 TROOT go4application("The GO4","This is the Go4");
00031 
00032 #define kGUI   2
00033 #define kBatch 1
00034 
00035 
00036 
00037 //================== YYY analysis main program ============================
00038 int main(int argc, char **argv)
00039 {
00040 // argv[0] program
00041 // argv[1] "-gui" when started by GUI.
00042 //         In this case the following args are:
00043 // argv[2] analysis name as specified in GUI
00044 // argv[3] hostname of GUI
00045 // argv[4] connector port of GUI
00046 //         if not GUI the args are:
00047 // argv[1] LMD filename
00048 // argv[2] optional number of events
00049 
00050 // define here the standard suffix of your data:
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(); // no argument: print usage
00058   exit(0);
00059 }
00060 Int_t runningMode = kGUI;    // runningMode of analysis, kGUI or kBatch
00061 if(strcmp(argv[1],"-gui") != 0) runningMode = kBatch; // no GUI
00062 // Now we know the running mode
00063 
00064 TApplication theApp("App", 0, 0); // init root application loop
00065 
00066 // set some output verbosity:
00067    TGo4Log::Instance(); // init logger object
00068    TGo4Log::SetIgnoreLevel(1); // set this to 1 to suppress detailed debug output
00069                                // set this to 2 to get warnings and errors only
00070                                // set this to 3 to get errors only
00071    TGo4Log::OpenLogfile("go4YYYlog.txt","--Logfile for go4 YYY --",kFALSE);
00072    TGo4Log::LogfileEnable(kFALSE); // will enable or disable logging all messages to file
00073 
00074 
00075 //================= Begin  YYY analysis ==================================
00076 // Prepare the YYY analysis
00077 // In batch mode the arguments are
00078 // argv[1] filename
00079 // argv[2] optional number of events or -1
00080 
00081 Int_t maxevents = -1; // number of events (batch mode)
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); // analysis name
00088     iport = (argc>4) ? atoi(argv[4]) : 5000; // port of GUI server
00089 }
00090 else{
00091     len = strlen(argv[1]);
00092     strncpy(input,argv[1],110); // input file name
00093     if(argc > 2) maxevents=atoi(argv[2]);
00094 }
00095 if(maxevents == -1) maxevents = 99999999;
00096 
00097 // we construct filenames
00098 Text_t lmd[len+5]; // input GSI listmode
00099 Text_t asf[len+5]; // root autosave file
00100 Text_t raw[len+5]; // root unpacked events
00101 Text_t anl[len+5]; // root analyzed events
00102 
00103 char *pc;
00104 if((pc=strstr(input,".lmd")) != 0)*pc=0;
00105 // strip any path information from input file name:
00106 // outname is name without path
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); // input file with full path
00116 strncpy(asf,outname,len+4);
00117 strncpy(raw,outname,len+4);
00118 strncpy(anl,outname,len+4);
00119 strcat(lmd,inputsuffix); // input with user suffix
00120 strcat(asf,"_ASF"); // root autosave file
00121 strcat(raw,"_UPA"); // root unpacked events
00122 strcat(anl,"_ANL"); // root analyzed events
00123 printf("Files used: \nFile input: %s\nAutosave:   %s\nUnpacked:   %s\nAnalyzed: %s\n",
00124        lmd,asf,raw,anl);
00125 
00126 // Now setup the YYY analysis itself
00127 TYYYAnalysis*
00128 analysis = new TYYYAnalysis(lmd,raw,anl);
00129 // Enable autosave. Autosave is done when analysis loop is stopped
00130 // or intervall os over.
00131 //analysis->SetAutoSave(kFALSE);         // no autosave
00132 analysis->SetAutoSaveFile(asf);        // optional
00133 analysis->SetAutoSaveInterval(0); // events , 0 = termination of event loop
00134 
00135 // ===================== End YYY analysis ================================
00136 // At this point the analysis is set up
00137 
00138 //TBenchmark bench;         // optional
00139 //TGo4ProfileTimer prtimer; // optional
00140 
00141  if(runningMode == kBatch)
00142    {
00143      cout << "*  starting analysis in batch mode ...  " << endl;
00144      if (analysis->InitEventClasses() )
00145        {
00146     // bench.Start("Go4EventServer"); // optional
00147     // prtimer.Start();               // optional
00148     analysis->RunImplicitLoop(maxevents);
00149     // prtimer.Stop();                // optional
00150     // prtimer.Resume();              // optional
00151     // bench.Show("Go4EventServer");  // optional
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 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:54 2005 for Go4-v2.10-5 by doxygen1.2.15