21 #include "TClassTable.h"
23 #include "TMethodArg.h"
24 #include "TDataType.h"
27 #include "TObjString.h"
28 #include "Riostream.h"
30 #include "TSysEvtHandler.h"
31 #include "TInterpreter.h"
33 #include "TApplication.h"
44 #define PROCESSLOOPDELAY 20
46 #define TERMCOUNTS 10000
51 std::cerr <<
"Error: " << msg << std::endl;
52 std::cerr <<
"Call 'go4analysis -help' to see list of available arguments" << std::endl;
58 std::cout <<
" -file filename : use file filename (lmd or lml) as MBS event source (short: -f)" << std::endl;
59 std::cout <<
" -transport server : connect to MBS transport server (short: -tr)" << std::endl;
60 std::cout <<
" -stream server : connect to MBS stream server (short: -st)" << std::endl;
61 std::cout <<
" -evserv server : connect to MBS event server (short: -ev)" << std::endl;
62 std::cout <<
" -revserv server [port] : connect to remote event server (short: -rev)" << std::endl;
63 std::cout <<
" -random : use random generator as source (short: -rnd)" << std::endl;
64 std::cout <<
" -user name : create user-defined event source" << std::endl;
65 std::cout <<
" -timeout tm : specify timeout parameter for event source" << std::endl;
66 std::cout <<
" -skip num : skip num first events in mbs event source" << std::endl;
67 std::cout <<
" -mbs-select first last step : select events interval from mbs source " << std::endl;
68 std::cout <<
" first: sequence number of the first event (starts from 0)" << std::endl;
69 std::cout <<
" last: sequence number of the last event" << std::endl;
70 std::cout <<
" step: step over several events, 1 means all events are used" << std::endl;
74 void usage(
const char* subtopic = 0)
76 std::cout << std::endl;
77 std::cout <<
"GO4 analysis runnable " <<
__GO4RELEASE__ << std::endl;
78 std::cout <<
"S. Linev, GSI, Darmstadt" << std::endl;
80 if ((subtopic!=0) && (strlen(subtopic)>0)) {
81 const char* sub = subtopic;
84 if ((strcmp(subtopic,
"sources")==0) || (strcmp(subtopic,
"src")==0) || (strcmp(subtopic,
"src")==0)) {
85 std::cout <<
"These are arguments of go4analysis which allows to specify event source" << std::endl;
89 if ((strcmp(sub,
"print")==0) || (strcmp(sub,
"pr")==0) ||
90 (strcmp(sub,
"type")==0) || (strcmp(sub,
"ty")==0)) {
91 std::cout <<
"Usage of go4analysis -print command." << std::endl;
92 std::cout << std::endl;
93 std::cout <<
" go4analysis -print|-pr|-type|-ty [PROPT] [SOURCE] [MISC]" << std::endl;
94 std::cout << std::endl;
95 std::cout <<
"PROPT: print options, right after -print command" << std::endl;
96 std::cout <<
" hex : print data in hexadecimal format" << std::endl;
97 std::cout <<
" dec : print data in decimal format" << std::endl;
98 std::cout <<
" long : print data in long (4 bytes) form (default)" << std::endl;
99 std::cout <<
" short : print data in short (2 bytes) form" << std::endl;
100 std::cout <<
" sub=N : select subevent id N (default all subevents are shown)" << std::endl;
101 std::cout <<
" fhead : print current lmd file header" << std::endl;
102 std::cout <<
" bhead : print current buffer header" << std::endl;
103 std::cout <<
"SOURCE: event source print options" << std::endl;
105 std::cout <<
"MISC: other options, which may be relevant for \"print\" command" << std::endl;
106 std::cout <<
" -number M : print M events, default is 1 (short: -num)" << std::endl;
107 std::cout <<
" -lib name : load library, may be required for user-defined sources" << std::endl;
108 std::cout <<
" -v : enable verbose mode to see some debug output (default: -v2)" << std::endl;
109 std::cout << std::endl;
110 std::cout <<
" Print event header from MBS stream server" << std::endl;
111 std::cout <<
" go4analysis -stream r4-4 -print " << std::endl;
112 std::cout << std::endl;
113 std::cout <<
" Print event data in hexadecimal form from MBS event server" << std::endl;
114 std::cout <<
" go4analysis -ev r2-1 -pr hex" << std::endl;
115 std::cout << std::endl;
116 std::cout <<
" Print 5 events with subevent id=1 in decimal form from MBS transport server" << std::endl;
117 std::cout <<
" go4analysis -tr r2-2 -num 5 -ty dec sub=1 " << std::endl;
118 std::cout << std::endl;
121 std::cout <<
"No help for topic: \""<< subtopic <<
"\"" << std::endl;
122 std::cout <<
"Available: print, sources" << std::endl;
127 std::cout <<
"calling: " << std::endl;
128 std::cout <<
"" << std::endl;
129 std::cout <<
" go4analysis [RUN] [ANALYSIS] [STEP1] [STEP2] ... [USER]" << std::endl;
130 std::cout <<
"" << std::endl;
131 std::cout <<
"RUN: configuration, relevant for application run mode" << std::endl;
132 std::cout <<
" -lib name : user library to load (default: libGo4UserLibrary)" << std::endl;
133 std::cout <<
" -server [name] : run analysis in server mode, name - optional analysis name" << std::endl;
134 std::cout <<
" -gui name guihost guiport : run analysis in gui mode, used by GUI launch analysis" << std::endl;
136 std::cout <<
" -http [port] : run analysis with web-server running, " << std::endl;
137 std::cout <<
" optionally port can be specified, default 8080" << std::endl;
138 std::cout <<
" -auth [filename] : use authentication file to restrict access to http server " << std::endl;
139 std::cout <<
" file should contain 'controller' and 'admin' accounts for 'go4' domain" << std::endl;
140 std::cout <<
" Could be generated with htdigets utility, by default '$GO4SYS/etc/.htdigest' filename is used" << std::endl;
141 std::cout <<
" -fastcgi port : run analysis with fastcgi server running, "<< std::endl;
142 std::cout <<
" which can deliver data to normal webserver (see mod_proxy_fcgi for Apache)" << std::endl;
143 std::cout <<
" -jsroot location : use JSROOT from other location like https://root.cern.ch/js/latest/" << std::endl;
145 std::cout <<
" -dabc master_host:port : run analysis with optional connection to dabc application, "<< std::endl;
146 std::cout <<
" which could receive objects from running analysis" << std::endl;
149 std::cout <<
" -run : run analysis in server mode (default only run if source specified)" << std::endl;
150 std::cout <<
" -norun : exclude automatical run" << std::endl;
151 std::cout <<
" -number NUMBER : process NUMBER events in batch mode" << std::endl;
152 std::cout <<
" -hserver [name [passwd]] : start histogram server with optional name and password" << std::endl;
153 std::cout <<
" -log [filename] : enable log output into filename (default:go4logfile.txt)" << std::endl;
154 std::cout <<
" -v -v0 -v1 -v2 -v3 : change log output verbosity (0 - maximum, 1 - info, 2 - warn, 3 - errors)" << std::endl;
155 std::cout <<
" -gdebug [lvl] : set ROOT gDebug value, default 1" << std::endl;
156 std::cout <<
" -rate : display rate information during run" << std::endl;
157 std::cout <<
" -print [sub=N] [hex|dec] : print events, see -help print for more info" << std::endl;
158 std::cout <<
" -help [topic] : show this help or for selected topic" << std::endl;
159 std::cout <<
" -graphics : enable graphics in the analysis" << std::endl;
160 std::cout <<
"" << std::endl;
161 std::cout <<
"ANALYSIS: common analysis configurations" << std::endl;
162 std::cout <<
" -name name : specify analysis instance name" << std::endl;
163 std::cout <<
" -asf [filename] : enable store autosave file and set autosave filename (default <Name>ASF.root)" << std::endl;
164 std::cout <<
" -enable-asf [interval] : enable store of autosave file, optionally interval in seconds" << std::endl;
165 std::cout <<
" -disable-asf : disable usage of asf" << std::endl;
166 std::cout <<
" -prefs [filename] : load preferences (analysis configuration) from specified file (default Go4AnalysisPrefs.root)" << std::endl;
167 std::cout <<
" -no-prefs : disable preferences loading" << std::endl;
168 std::cout <<
" -maxtreesize value : define maximum tree size, value can be: 2g, 1900m, 1900000000" << std::endl;
169 std::cout <<
"" << std::endl;
170 std::cout <<
"STEP: individual step configurations" << std::endl;
171 std::cout <<
" -step name : select step by it's name, if not found, first step will be used" << std::endl;
172 std::cout <<
" -step number : select step by it's number (first step has number 0)" << std::endl;
173 std::cout <<
" -enable-step : enable step processing" << std::endl;
174 std::cout <<
" -disable-step : disable step processing" << std::endl;
175 std::cout <<
" -file filename : use file filename (lmd or lml) as MBS event source" << std::endl;
176 std::cout <<
" -transport server : connect to MBS transport server" << std::endl;
177 std::cout <<
" -stream server : connect to MBS stream server" << std::endl;
178 std::cout <<
" -evserv server : connect to MBS event server" << std::endl;
179 std::cout <<
" -revserv server [port] : connect to remote event server" << std::endl;
180 std::cout <<
" -port number : select custom port number for event source" << std::endl;
181 std::cout <<
" -retry number : select number of retries when connection to source was lost" << std::endl;
182 std::cout <<
" -random : use random generator as source" << std::endl;
183 std::cout <<
" -user name : create user-defined event source" << std::endl;
184 std::cout <<
" -source filename : read step input from the root file" << std::endl;
185 std::cout <<
" -skip num : skip num first events in mbs event source" << std::endl;
186 std::cout <<
" -mbs-select first last step : select events interval from mbs source" << std::endl;
187 std::cout <<
" -timeout tm : specify timeout parameter for event source" << std::endl;
188 std::cout <<
" -enable-source : enable step source" << std::endl;
189 std::cout <<
" -disable-source : disable step source" << std::endl;
190 std::cout <<
" -store filename [split buffersize compression] : write step output into the root file" << std::endl;
191 std::cout <<
" -overwrite-store : overwrite file, when store output" << std::endl;
192 std::cout <<
" -append-store : append to file, when store output" << std::endl;
193 std::cout <<
" -backstore name : create backstore for online tree draw" << std::endl;
194 std::cout <<
" -enable-store : enable step store" << std::endl;
195 std::cout <<
" -disable-store : disable step store" << std::endl;
196 std::cout <<
" -enable-errstop : enable stop-on-error mode" << std::endl;
197 std::cout <<
" -disable-errstop : disable stop-on-error mode" << std::endl;
198 std::cout <<
" -inpevt-class name : (re)define class name of input event" << std::endl;
199 std::cout <<
" -outevt-class name : (re)define class name of output event" << std::endl;
200 std::cout << std::endl;
201 std::cout <<
"USER: user-defined arguments" << std::endl;
202 std::cout <<
" -args [userargs] : create user analysis with constructor (int argc, char** argv) signature" << std::endl;
203 std::cout <<
" all following arguments will be provided as array of strings, first argument - analysis name" << std::endl;
204 std::cout << std::endl;
225 if (mbs) mbs->
PrintMbsEvent(fSubId, fLong, fHex, fData, fBufHead, fFileHead);
251 int FindArg(
int argc,
char **argv,
const char* argname)
253 if ((argname==0) || (strlen(argname)==0))
return -1;
254 for (
int n=0;n<argc;n++)
255 if (strcmp(argv[n], argname)==0)
return n;
259 const char*
GetArgValue(
int argc,
char **argv,
const char* argname,
int* pos = 0,
bool incomplete =
false)
261 int n = pos ? *pos : 0;
264 if (strcmp(argv[n], argname)==0) {
265 if ((n+1<argc) && (argv[n+1][0]!=
'-')) {
284 TList* lst =
new TList;
285 lst->SetOwner(kTRUE);
287 if (prev!=0)
TGo4Log::Debug(
"Search user classes in loaded library");
289 while ((name = TClassTable::Next()) != 0) {
290 if (prev && prev->FindObject(name))
continue;
292 TNamed* obj =
new TNamed(name, name);
305 TObjArray evnt_classes;
307 TClass *proc_cl(0), *an_cl(0), *evsrc_cl(0);
309 while ((obj = iter()) != 0) {
310 TClass* cl = TClass::GetClass(obj->GetName());
314 if (cl->InheritsFrom(TGo4EventProcessor::Class())) {
316 if ((cl!=TGo4EventProcessor::Class()) && ((proc_cl==0) || cl->InheritsFrom(proc_cl))) proc_cl = cl;
318 if (cl->InheritsFrom(TGo4EventSource::Class())) {
319 if ((cl!=TGo4EventSource::Class()) && (evsrc_cl==0)) evsrc_cl = cl;
321 if (cl->InheritsFrom(TGo4EventElement::Class())) {
322 if (cl!=TGo4EventElement::Class()) evnt_classes.Add(cl);
324 if (cl->InheritsFrom(TGo4Analysis::Class())) {
325 if ((cl!=TGo4Analysis::Class()) && (an_cl==0)) an_cl = cl;
335 TGo4Log::Info(
"Find user analysis class %s", an_cl->GetName());
337 TMethod* meth = an_cl->GetMethodWithPrototype(an_cl->GetName(),
"int,char**");
339 TGo4Log::Info(
"!!! Find constructor with prototype %s::%s(int, char**)", an_cl->GetName(), an_cl->GetName());
341 if ((user_argc>0) && (user_argv!=0))
342 user_argv[0] = (
char*) name;
345 user_argv = (
char**) &name;
349 TString cmd = TString::Format(
"new %s(%d, (char**)0x%x)", an_cl->GetName(), user_argc, user_argv);
351 TString cmd = TString::Format(
"new %s(%d, (char**)%p)", an_cl->GetName(), user_argc, user_argv);
359 if ((analysis!=0) && (err==0))
return analysis;
361 TGo4Log::Error(
"Cannot create analysis class %s instance with (int, char**) prototype", an_cl->GetName());
362 TGo4Log::Error(
"Implement correct analysis constructor with such signature in user library");
367 meth = an_cl->GetMethodWithPrototype(an_cl->GetName(),
"const char*");
369 TGo4Log::Info(
"!!! Find constructor with prototype %s::%s(const char*)", an_cl->GetName(), an_cl->GetName());
371 TString cmd = TString::Format(
"new %s(\"%s\")", an_cl->GetName(), name);
378 if ((analysis!=0) && (err==0))
return analysis;
380 TGo4Log::Error(
"Cannot create analysis class %s instance with (const char*) prototype", an_cl->GetName());
381 TGo4Log::Error(
"Implement correct analysis constructor with such signature in user library");
386 TIter iter(an_cl->GetListOfMethods());
387 while ((meth = (TMethod*) iter()) != 0) {
388 if (strcmp(meth->GetName(), an_cl->GetName()) != 0)
continue;
389 if (meth->GetListOfMethodArgs()->GetSize()==0)
continue;
394 TGo4Log::Error(
"Cannot find non-default constructor for class %s", an_cl->GetName());
395 TGo4Log::Error(
"Implement analysis constructor with (const char*) or (int,char**) signature");
396 TGo4Log::Error(
"Or define TGo4Analysis* CreateUserAnalysis(const char*) function in user library");
400 TGo4Log::Info(
"Find constructor with %d arguments", meth->GetListOfMethodArgs()->GetSize());
402 TMethodArg *argument = 0;
403 TIter next(meth->GetListOfMethodArgs());
405 TString cmd = TString::Format(
"new %s(", an_cl->GetName());
409 while ((argument = (TMethodArg *) next())) {
411 if (counter>0) cmd+=
", ";
414 TDataType *datatype = gROOT->GetType(argument->GetTypeName());
416 TString basictype = (datatype==0) ?
"int" : datatype->GetTypeName();
418 TGo4Log::Debug(
"Argument %s type %s basictype %s", argument->GetName(), argument->GetTitle(), basictype.Data());
420 TString argDflt = argument->GetDefault() ? argument->GetDefault() :
"";
421 if (argDflt.Length()>0) {
426 bool isptr = strchr(argument->GetTitle(),
'*') != 0;
428 if ((datatype==0) && !isptr) {
429 TGo4Log::Error(
"Cannot specify any value for argument %s of class %s constructor", argument->GetName(), an_cl->GetName());
430 TGo4Log::Error(
"Add CreateUserAnalysis(const char*) function in user library");
435 if ((basictype ==
"char") || (basictype=
"Text_t")) cmd+=
"\"\"";
438 if ((counter==2) && (basictype==
"int")) {
439 TGo4Log::Info(
"Special treatment for second integer argument, suppose MBS input type");
442 if (basictype==
"bool") {
454 if ((analysis!=0) && (err==0))
return analysis;
456 TGo4Log::Error(
"Cannot create analysis class %s instance", an_cl->GetName());
457 TGo4Log::Error(
"Add CreateUserAnalysis(const char*) function in user library");
462 TClass *outev_cl(0), *inpev_cl(0);
464 const char* inp_evnt_classname =
GetArgValue(user_argc, user_argv,
"-inpevt-class");
465 const char* out_evnt_classname =
GetArgValue(user_argc, user_argv,
"-outevt-class");
467 if (inp_evnt_classname!=0) {
468 inpev_cl = gROOT->GetClass(inp_evnt_classname);
474 if (!inpev_cl->InheritsFrom(TGo4EventElement::Class())) {
475 TGo4Log::Error(
"Class %s cannot be used as input event", inp_evnt_classname);
479 evnt_classes.Remove(inpev_cl);
480 evnt_classes.Compress();
483 if (out_evnt_classname!=0) {
484 outev_cl = gROOT->GetClass(out_evnt_classname);
490 if (!outev_cl->InheritsFrom(TGo4EventElement::Class())) {
491 TGo4Log::Error(
"Class %s cannot be used as output event", out_evnt_classname);
495 evnt_classes.Remove(outev_cl);
496 evnt_classes.Compress();
501 if ((evsrc_cl!=0) && (inpev_cl==0) && (evnt_classes.GetLast() >= 0)) {
506 for (
int n=0; n<=evnt_classes.GetLast(); n++) {
507 TClass* cl = (TClass*) evnt_classes.At(n);
511 if (inpev_cl!=0) { inpev_cl = 0;
break; }
520 evnt_classes.Remove(inpev_cl);
521 evnt_classes.Compress();
527 for (
int n=0; n<=evnt_classes.GetLast(); n++) {
528 TClass* cl = (TClass*) evnt_classes.At(n);
529 if ((outev_cl==0) || cl->InheritsFrom(outev_cl)) outev_cl = cl;
533 TGo4Log::Info(
"Create default analysis with print-processor class");
536 if (proc_cl==0)
return 0;
537 TGo4Log::Info(
"Create default analysis with processor class %s", proc_cl->GetName());
539 TGo4Log::Info(
"Use class %s as output event", outev_cl->GetName());
544 TGo4Log::Info(
"Use class %s as input event", inpev_cl->GetName());
547 analysis->SetAnalysisName(name);
573 step->SetSourceEnabled(kTRUE);
574 step->SetStoreEnabled(kFALSE);
575 step->SetProcessEnabled(kTRUE);
576 step->SetErrorStopEnabled(kTRUE);
580 analysis->AddAnalysisStep(step);
586 int main(
int argc,
char **argv)
589 std::cerr <<
"Please check your system configuration and restart analysis again" << std::endl;
593 if (argc==1)
usage();
595 int phelp =
FindArg(argc, argv,
"-help");
596 if (phelp < 0) phelp =
FindArg(argc, argv,
"-h") > 0;
598 usage(phelp < argc-1 ? argv[phelp+1] : 0);
602 char** user_argv = 0;
604 int userargspos =
FindArg(argc, argv,
"-args");
605 if (userargspos<0) userargspos =
FindArg(argc, argv,
"-x");
607 user_argc = argc - userargspos;
608 user_argv = argv + userargspos;
613 bool doprint = (
FindArg(argc, argv,
"-print") > 0) || (
FindArg(argc, argv,
"-type") > 0) ||
614 (
FindArg(argc, argv,
"-pr") > 0) || (
FindArg(argc, argv,
"-ty") > 0);
617 const char* logfile =
GetArgValue(argc, argv,
"-log", 0,
true);
626 TString info =
"go4analysis";
627 for (
int n=1;n<argc;n++) { info +=
" "; info += argv[n]; }
645 gInterpreter->SetProcessLineLock(kFALSE);
650 if (go4inc.Length()>0)
651 gInterpreter->AddIncludePath(go4inc.Data());
653 const char *extra_incl = gSystem->Getenv(
"GO4EXTRAINCLUDE");
654 if (extra_incl && *extra_incl)
655 gInterpreter->AddIncludePath(extra_incl);
657 const char* analysis_name =
GetArgValue(argc, argv,
"-server");
658 if (analysis_name==0) analysis_name =
GetArgValue(argc, argv,
"-gui");
659 if (analysis_name==0) analysis_name =
GetArgValue(argc, argv,
"-name");
660 if (analysis_name==0) analysis_name =
"Go4Analysis";
665 bool isanylib =
false;
666 const char* libname = 0;
667 while ((libname =
GetArgValue(argc, argv,
"-lib", &argpos))!=0) {
669 if (gSystem->Load(libname)<0)
return -1;
674 if (!isanylib && (!doprint ||
GetArgValue(argc, argv,
"-user"))) {
675 libname =
"libGo4UserAnalysis";
677 if (gSystem->Load(libname)<0)
return -1;
685 if (crfunc) analysis = crfunc(analysis_name);
689 std::cerr <<
"!!! Analysis instance cannot be created" << std::endl;
690 std::cerr <<
"!!! PLEASE check your analysis library " << libname << std::endl;
691 std::cerr <<
"!!! One requires user subclass for TGo4Analysis class in user library" << std::endl;
692 std::cerr <<
"!!! Alternatively, CreateUserAnalysis(const char*) function can be implemented" << std::endl;
693 std::cerr <<
"!!! See Go4ExampleSimple, Go4Example1Step or Go4Example2Step for details" << std::endl;
697 delete lst0; lst0 = 0;
698 delete lst1; lst1 = 0;
702 std::cerr <<
"No active step in analysis found" << std::endl;
710 gROOT->SetBatch(kTRUE);
713 http_args.SetOwner(kTRUE);
715 const char* auth_domain =
"go4";
717 Bool_t batchMode(kTRUE);
718 Bool_t servermode(kFALSE);
719 Bool_t httpmode(kFALSE);
720 Bool_t hserver(kFALSE);
721 Bool_t loadprefs(kTRUE);
722 Bool_t showrate(kFALSE);
723 Double_t process_interv(-1.);
724 const char* hname =
"";
725 const char* hpasswd =
"";
726 const char* hostname =
"localhost";
742 while (narg < argc) {
743 if (strcmp(argv[narg],
"-server")==0) {
748 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-')) narg++;
750 if(strcmp(argv[narg],
"-gui") == 0) {
752 if (argc <= narg + 3)
showerror(
"Not all -gui arguments specified");
755 hostname = argv[narg++];
756 iport = atoi(argv[narg++]);
759 if (strcmp(argv[narg],
"-http")==0) {
762 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-'))
763 http_args.Add(
new TObjString(Form(
"http:%s?top=Go4", argv[narg++])));
765 http_args.Add(
new TObjString(
"http:8080?top=Go4"));
767 if (strcmp(argv[narg],
"-fastcgi")==0) {
770 if (narg >= argc)
showerror(
"fastcgi options not specified");
771 http_args.Add(
new TObjString(Form(
"fastcgi:%s?top=Go4", argv[narg++])));
773 if (strcmp(argv[narg],
"-jsroot")==0) {
775 if (narg >= argc)
showerror(
"jsroot location not specified");
776 http_args.Add(
new TObjString(Form(
"jsroot:%s", argv[narg++])));
778 if (strcmp(argv[narg],
"-auth")==0) {
780 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-'))
781 auth_file = argv[narg++];
785 if (strcmp(argv[narg],
"-domain")==0) {
787 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-'))
788 auth_domain = argv[narg++];
793 if (strcmp(argv[narg],
"-dabc")==0) {
795 if (narg >= argc)
showerror(
"Master dabc node not specified");
796 const char* hostname = gSystem->HostName();
797 if ((hostname==0) || (*hostname==0)) hostname =
"localhost";
798 http_args.Add(
new TObjString(Form(
"dabc:%s?top=Go4/%s_pid%d", argv[narg++],hostname,gSystem->GetPid())));
802 if(strcmp(argv[narg],
"-lib") == 0) {
804 if (++narg >= argc)
showerror(
"library name not specified");
807 if(strcmp(argv[narg],
"-name") == 0) {
809 if (++narg >= argc)
showerror(
"analysis name not specified");
812 if (strcmp(argv[narg],
"-step")==0) {
814 const char* step_name = argv[narg++];
817 if (sscanf(step_name,
"%d", &step_number)==1)
820 if (step==0)
showerror(
"step not found");
824 if(strcmp(argv[narg],
"-enable-step")==0) {
828 if(strcmp(argv[narg],
"-disable-step")==0) {
832 if ((strcmp(argv[narg],
"-file")==0) || (strcmp(argv[narg],
"-f")==0)) {
836 while ((narg<argc) && (argv[narg][0]!=
'-'))
842 showerror(
"LMD/LML file name not specified");
844 if (strcmp(argv[narg],
"-source")==0) {
851 showerror(
"Input file name not specified");
853 if ((strcmp(argv[narg],
"-transport")==0) || (strcmp(argv[narg],
"-tr")==0)) {
860 showerror(
"MBS Transport server name not specified");
862 if ((strcmp(argv[narg],
"-stream")==0) || (strcmp(argv[narg],
"-st")==0)) {
869 showerror(
"MBS Stream server name not specified");
871 if ((strcmp(argv[narg],
"-evserv")==0) || (strcmp(argv[narg],
"-ev")==0)) {
878 showerror(
"MBS Event server name not specified");
880 if ((strcmp(argv[narg],
"-random")==0) || (strcmp(argv[narg],
"-rnd")==0)) {
887 if (strcmp(argv[narg],
"-user")==0) {
894 showerror(
"MBS Event server name not specified");
896 if ((strcmp(argv[narg],
"-revserv")==0) || (strcmp(argv[narg],
"-rev")==0)) {
898 const char* serv_name = argv[narg++];
900 if ((narg < argc) && (argv[narg][0] !=
'-'))
901 serv_port = atoi(argv[narg++]);
907 showerror(
"Remote event server name or port are not specified");
909 if (strcmp(argv[narg],
"-skip")==0) {
912 if (param==0)
showerror(
"only in MBS source events can be skipped");
913 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-')) {
915 if (sscanf(argv[narg],
"%u",&value)!=1)
916 showerror(Form(
"Value error %s", argv[narg]));
921 if (strcmp(argv[narg],
"-port")==0) {
924 if ((narg < argc) && (argv[narg][0]!=
'-')) {
925 if (sscanf(argv[narg],
"%d",&port)!=1)
926 showerror(Form(
"Value error %s", argv[narg]));
930 if (param) param->
SetPort(port);
935 if (strcmp(argv[narg],
"-retry")==0) {
938 if ((narg < argc) && (argv[narg][0]!=
'-')) {
939 if (sscanf(argv[narg],
"%d",&nretry)!=1)
940 showerror(Form(
"Value error %s", argv[narg]));
946 if (strcmp(argv[narg],
"-mbs-select")==0) {
949 if (param==0)
showerror(
"only in MBS source events can be selected");
951 while ((cnt<3) && (narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-')) {
953 if ((cnt==1) && (strcmp(argv[narg],
"all")==0)) value = 0;
else
954 if (sscanf(argv[narg],
"%u",&value)!=1)
955 showerror(Form(
"Value error %s", argv[narg]));
962 if(strcmp(argv[narg],
"-store")==0) {
963 if (++narg >= argc)
showerror(
"Store name not specified");
965 const char* sourcename = argv[narg++];
967 int buffersize = 64000;
971 while ((cnt<3) && (narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-')) {
973 if (sscanf(argv[narg],
"%d",&value)!=1)
974 showerror(Form(
"Value error %s", argv[narg]));
975 if (cnt==0) splitlevel = value;
else
976 if (cnt==1) buffersize = value;
else
977 if (cnt==2) compression = value;
985 if (strcmp(argv[narg],
"-timeout")==0) {
986 if (++narg >= argc)
showerror(
"Timeout value not specified");
989 if (sscanf(argv[narg],
"%d",&value)!=1)
990 showerror(Form(
"Timeout value error %s", argv[narg]));
994 if (strcmp(argv[narg],
"-overwrite-store")==0) {
998 else showerror(
"No file-store parameter available");
1000 if (strcmp(argv[narg],
"-append-store")==0) {
1004 else showerror(
"No file-store parameter available");
1006 if(strcmp(argv[narg],
"-backstore")==0) {
1007 if (++narg < argc) {
1012 showerror(
"Backstore name not specified");
1014 if ((strcmp(argv[narg],
"-events")==0) || (strcmp(argv[narg],
"-number")==0) || (strcmp(argv[narg],
"-num")==0)) {
1015 if (++narg < argc) {
1016 if (sscanf(argv[narg++],
"%ld",&maxevents)!=1) maxevents = -1;
1018 showerror(
"number of events to process not specified");
1020 if (strcmp(argv[narg],
"-asf")==0) {
1023 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-'))
1026 if (strcmp(argv[narg],
"-enable-asf")==0) {
1029 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-'))
1032 if (strcmp(argv[narg],
"-disable-asf")==0) {
1036 if (strcmp(argv[narg],
"-prefs")==0) {
1038 const char* fname = 0;
1039 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-'))
1040 fname = argv[narg++];
1044 if (strcmp(argv[narg],
"-no-prefs")==0) {
1048 if(strcmp(argv[narg],
"-log")==0) {
1050 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-')) narg++;
1052 if(strcmp(argv[narg],
"-gdebug")==0) {
1054 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-'))
1055 gDebug = TString(argv[narg++]).Atoi();
1059 if((strcmp(argv[narg],
"-v")==0) || (strcmp(argv[narg],
"-v0")==0) || (strcmp(argv[narg],
"-v1")==0) || (strcmp(argv[narg],
"-v2")==0) || (strcmp(argv[narg],
"-v3")==0)) {
1062 if((strcmp(argv[narg],
"-graphics")==0) || (strcmp(argv[narg],
"-gr")==0)) {
1064 gROOT->SetBatch(kFALSE);
1065 process_interv = 0.1;
1066 new TApplication(
"Go4App", &app_argc, argv);
1067 TStyle::BuildStyles();
1070 if(strcmp(argv[narg],
"-run")==0) {
1074 if(strcmp(argv[narg],
"-norun")==0) {
1078 if(strcmp(argv[narg],
"-maxtreesize")==0) {
1080 long long maxtreesize = 1900000000;
1081 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-')) {
1083 strncpy(sbuf, argv[narg],
sizeof(sbuf));
1084 long long mult(1), val(1);
1085 int len = strlen(sbuf);
1086 if ((sbuf[len-1]==
'g') || (sbuf[len-1]==
'G')) { mult = 1000000000; sbuf[len-1] = 0; }
else
1087 if ((sbuf[len-1]==
'm') || (sbuf[len-1]==
'M')) { mult = 1000000; sbuf[len-1] = 0; }
else
1088 if ((sbuf[len-1]==
'k') || (sbuf[len-1]==
'K')) { mult = 1000; sbuf[len-1] = 0; }
1089 if (sscanf(sbuf,
"%lld", &val)==1) maxtreesize = val*mult;
1092 TGo4Log::Info(
"Set tree file size limit to %lld bytes", maxtreesize);
1095 if ((strcmp(argv[narg],
"-print")==0) || (strcmp(argv[narg],
"-type")==0) || (strcmp(argv[narg],
"-ty")==0) || (strcmp(argv[narg],
"-pr")==0)) {
1097 while ((narg<argc) && (argv[narg][0]!=
'-')) {
1098 if (strncmp(argv[narg],
"sub=",4)==0) {
1101 if (strcmp(argv[narg],
"hex")==0) {
1105 if (strcmp(argv[narg],
"dec")==0) {
1109 if (strcmp(argv[narg],
"long")==0) {
1113 if (strcmp(argv[narg],
"short")==0) {
1117 if (strcmp(argv[narg],
"data")==0) {
1120 if (strcmp(argv[narg],
"nodata")==0) {
1123 if (strcmp(argv[narg],
"fhead")==0) {
1126 if (strcmp(argv[narg],
"bhead")==0) {
1132 if(strcmp(argv[narg],
"-enable-store")==0) {
1136 if(strcmp(argv[narg],
"-disable-store")==0) {
1140 if(strcmp(argv[narg],
"-enable-source")==0) {
1144 if(strcmp(argv[narg],
"-disable-source")==0) {
1148 if(strcmp(argv[narg],
"-disable-errstop")==0) {
1152 if(strcmp(argv[narg],
"-enable-errstop")==0) {
1156 if(strcmp(argv[narg],
"-rate")==0) {
1160 if(strcmp(argv[narg],
"-norate")==0) {
1164 if(strcmp(argv[narg],
"-inpevt-class")==0) {
1168 if (narg < argc) narg++;
1170 if(strcmp(argv[narg],
"-outevt-class")==0) {
1174 if (narg < argc) narg++;
1176 if(strcmp(argv[narg],
"-hserver")==0) {
1179 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-'))
1180 hname = argv[narg++];
1181 if ((narg < argc) && (strlen(argv[narg]) > 0) && (argv[narg][0]!=
'-'))
1182 hpasswd = argv[narg++];
1184 showerror(Form(
"Unknown argument %d %s", narg, argv[narg]));
1188 if (http_args.GetLast()>=0) {
1189 if (gSystem->Load(
"libGo4Http")!=0)
1190 showerror(
"Fail to load libGo4Http.so library");
1197 for (Int_t n=0;n<=http_args.GetLast();n++) {
1198 TString engine = http_args[n]->GetName();
1199 if ((engine.Index(
"http:")==0) && (auth_file.Length()>0))
1200 engine.Append(TString::Format(
"&auth_file=%s&auth_domain=%s", auth_file.Data(), auth_domain));
1202 cmd.Form(
"TGo4Sniffer::CreateEngine(\"%s\");", engine.Data());
1203 res = gROOT->ProcessLineFast(cmd.Data(), &err);
1204 if ((res<=0) || (err!=0)) {
1205 printf(
"Fail to start %s", engine.Data());
1210 process_interv = 0.1;
1216 TGo4Log::Info(
"Main: starting analysis in batch mode ... ");
1218 Bool_t enter_loop = kTRUE;
1219 if ((canrun>=0) || autorun) {
1223 enter_loop = kFALSE;
1230 analysis->
RunImplicitLoop(maxevents, showrate, process_interv, httpmode);
1235 if (hostname==0) hostname =
"localhost";
1237 if(servermode)
TGo4Log::Info(
"Main: starting analysis in server mode ...");
1238 else TGo4Log::Info(
"Main: starting analysis in slave mode ...");
1240 if (canrun<0) autorun =
false;
1242 TGo4AnalysisClient* client =
new TGo4AnalysisClient(
"UserClient", analysis, hostname, iport, hserver, hname, hpasswd, servermode, autorun, kFALSE, loadprefs, showrate);
1248 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,25,2)
1250 gSystem->AddFileHandler(
new TFileHandler(0, TFileHandler::kRead));
1268 gSystem->ProcessEvents();
1271 if(termcounter == 0) {
1275 if (termcounter>0) {
1277 if (termcounter == 0) {
void SetStartEvent(UInt_t firstindex)
static TGo4Log * Instance()
virtual Bool_t BuildEvent(TGo4EventElement *dest)
void SetRetryCnt(Int_t cnt)
Bool_t LoadStatus(const char *filename=0)
void SetStopEvent(UInt_t lastindex)
TGo4Analysis *( UserCreateFunc)(const char *name)
static Bool_t CheckVersion(Int_t version)
static void SetMaxTreeSize(Long64_t sz)
virtual Bool_t CheckEventClass(TClass *cl)
void DefUserEventSource(const char *Sclass)
void SetEventStore(TGo4EventStoreParameter *kind)
static void WriteLogfile(const char *text, Bool_t withtime=kTRUE)
void DefEventProcessor(const char *Pname, const char *Pclass)
TList * GetClassesList(TList *prev=0)
static void CloseLogfile()
static const char * GetDefaultLogname()
static void SetIgnoreLevel(Int_t level)
TGo4PrintFactory(const char *name)
TGo4EventProcessor * CreateEventProcessor(TGo4EventProcessorParameter *par)
static void OpenLogfile(const char *name=0, const char *headercomment=0, Bool_t appendmode=kFALSE)
virtual void PrintEvent()
int main(int argc, char **argv)
TGo4AnalysisStep * GetAnalysisStep(const char *name)
void SetSourceEnabled(Bool_t on=kTRUE)
void SetOverwriteMode(Bool_t over=kTRUE)
Int_t RunImplicitLoop(Int_t times, Bool_t showrate=kFALSE, Double_t process_event_interval=-1., Bool_t iswebserver=kFALSE)
static const char * GO4INCPATH()
TGo4EventStoreParameter * GetEventStore() const
void SetAutoSave(Bool_t on=kTRUE)
static void EnableRedirection()
void SetTimeout(Int_t out)
int FindArg(int argc, char **argv, const char *argname)
void DefOutputEvent(const char *Oname, const char *Oclass)
void SetEventInterval(UInt_t skipinterval)
const char * GetName() const
#define __GO4BUILDVERSION__
void PrintMbsEvent(Int_t subid=-1, Bool_t longw=kTRUE, Bool_t hexw=kTRUE, Bool_t dataw=kTRUE, Bool_t bufhead=kFALSE, Bool_t filhead=kFALSE)
void showerror(const char *msg)
void SetStoreEnabled(Bool_t on=kTRUE)
TGo4EventSourceParameter * GetEventSource() const
void AddMoreFile(const char *more)
const char * GetArgValue(int argc, char **argv, const char *argname, int *pos=0, bool incomplete=false)
TGo4EventElement * GetInputEvent()
virtual Bool_t InitEventClasses()
void usage(const char *subtopic=0)
void SetProcessEnabled(Bool_t on=kTRUE)
void SetEventSource(TGo4EventSourceParameter *kind)
void SetAutoSaveFile(const char *filename=0, Bool_t overwrite=kFALSE, Int_t compression=5)
TGo4AnalysisStep * GetAnalysisStepNum(Int_t number)
static TString subGO4SYS(const char *subdir)
void SetErrorStopEnabled(Bool_t on)
TGo4PrintProcessor(const char *name)
void DefInputEvent(const char *Iname, const char *Iclass)
static void SetRunningMode(int mode)
static TGo4Analysis * Instance()
static void Error(const char *text,...)
static void Info(const char *text,...)
TGo4Analysis * CreateDefaultAnalysis(TList *lst, const char *name, int user_argc, char **user_argv, bool doprint)
void SetAutoSaveInterval(Int_t interval=0)
static void Debug(const char *text,...)
static void LogfileEnable(Bool_t on=kTRUE)