#include "Riostream.h" #include #include #include "TROOT.h" #include "TApplication.h" #include "Go4EventServerTypes.h" #include "TXXXAnalysis.h" #include "TGo4AnalysisClient.h" void usage() { cout << endl; cout << "* GO4 online analysis " << endl; cout << "* H. Essel, GSI, Darmstadt" << endl; cout << "* calling: " << endl; cout << "* MainUserAnalysis -file|-trans|-stream|-evserv|-revserv input [-port #] [-output] [events]" <4) ? atoi(argv[4]) : 5000; // port of GUI server intype=GO4EV_MBS_FILE; writeout=kFALSE; // no output strcpy(serv,"/GSI/lea/gauss"); // default input file strcpy(out,"gauss_XXXEvent"); } else // set up arguments for batch mode { runningMode = kBatch; strncpy(serv,argv[2],110); // input (file with full path) if(strstr(argv[1],"-f")){intype=GO4EV_MBS_FILE;strcat(serv,filetype);} else if(strstr(argv[1],"-t")) intype=GO4EV_MBS_TRANSPORT; else if(strstr(argv[1],"-s")) intype=GO4EV_MBS_STREAM; else if(strstr(argv[1],"-e")) intype=GO4EV_MBS_EVENTSERVER; else if(strstr(argv[1],"-r")) intype=GO4EV_MBS_REVSERV; else { cout << "invalid input type: " << argv[1] << endl; usage(); // print usage exit(0); } iarg=3; if(argc > iarg){ if(strstr(argv[iarg],"-o"))writeout=kTRUE; else if(strstr(argv[iarg],"-p")){iarg++; sport=atoi(argv[iarg]);} else maxevents=atoi(argv[iarg]); iarg++; } if(argc > iarg){ if(strstr(argv[iarg],"-o"))writeout=kTRUE; else maxevents=atoi(argv[iarg]); iarg++; } if(argc > iarg)maxevents=atoi(argv[iarg]); if(maxevents == -1) maxevents = 99999999; cout << endl << "**** Input " << serv << " (" << argv[1] << ") "; if(strstr(argv[1],"-r")) cout << "port " << sport; cout << endl << " output " << out << ".root"; if(writeout) cout << " enabled"; else cout << " disabled"; cout << endl << " process " << maxevents << " events" << endl; cout << " auto save file: " << asf << ".root" << endl << endl; } // Now setup the analysis itself // arguments could be adjusted for other needs TXXXAnalysis* analysis = new TXXXAnalysis(serv,intype,sport,out,writeout); analysis->SetAutoSaveFile(asf); // optional analysis->SetAutoSaveInterval(0); // after n seconds , 0 = at termination of event loop analysis->SetAutoSave(kFALSE); // optional // ===================== End analysis setup ================================ if(runningMode == kBatch) { cout << "**** Main: starting analysis in batch mode ... " << endl; analysis->SetAutoSave(kTRUE); // optional enable auto-save if (analysis->InitEventClasses() ) { analysis->RunImplicitLoop(maxevents); delete analysis; cout << "**** Main: Done!"<Terminate(); } else { cout << "**** Main: Init event classes failed, aborting!"<Terminate(); } } if(runningMode == kGUI) { cout << "**** Main: starting analysis in client mode ..." << endl; // to start histogram server: kTRUE,"base","password" TGo4AnalysisClient* client = new TGo4AnalysisClient(argc,argv,analysis,kFALSE,"",""); cout << "**** Main created AnalysisClient Instance: "<GetName()<