Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

MainUserAnalysis.cxx

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

Generated on Fri Nov 28 12:59:09 2008 for Go4-v3.04-1 by  doxygen 1.4.2