20 #include "THttpServer.h"
21 #include "TBufferJSON.h"
24 #include "TTimeStamp.h"
28 #include "TMethodCall.h"
55 TBufferJSON::SetFloatFormat(
"%15.9e");
58 if (strstr(args,
"jsroot:")==args) {
73 fDebugOutput(
"Log",
"Analysis log messages", 1000),
74 fStatusMessages(
"Msg",
"Analysis status messages", 100),
78 SetScanGlobalDir(kFALSE);
91 SetItemField(
"/Status/Log",
"_hidden",
"true");
92 SetItemField(
"/Status/Msg",
"_hidden",
"true");
94 CreateItem(
"/Status/Message",
"Last message from analysis");
95 SetItemField(
"/Status/Message",
"_kind",
"Text");
96 SetItemField(
"/Status/Message",
"value",
"---");
98 CreateItem(
"/Status/DebugOutput",
"Go4 debug output");
99 SetItemField(
"/Status/DebugOutput",
"_kind",
"Text");
100 SetItemField(
"/Status/DebugOutput",
"value",
"---");
109 fEventRate->SetTitle(
"Events processing rate");
111 fEventRate->GetXaxis()->SetTimeFormat(
"%H:%M:%S");
118 SetItemField(
"/Status/Ratemeter",
"_hidden",
"true");
119 SetItemField(
"/Status/Ratemeter",
"_status",
"GO4.DrawAnalysisRatemeter");
121 RegisterCommand(
"/Control/CmdClear",
"this->CmdClear();",
"button;go4sys/icons/clear.png");
122 SetItemField(
"/Control/CmdClear",
"_title",
"Clear histograms and conditions in analysis");
123 SetItemField(
"/Control/CmdClear",
"_hidden",
"true");
125 RegisterCommand(
"/Control/CmdStart",
"this->CmdStart();",
"button;go4sys/icons/start.png");
126 SetItemField(
"/Control/CmdStart",
"_title",
"Start analysis");
127 SetItemField(
"/Control/CmdStart",
"_hidden",
"true");
129 RegisterCommand(
"/Control/CmdStop",
"this->CmdStop();",
"button;go4sys/icons/Stop.png");
130 SetItemField(
"/Control/CmdStop",
"_title",
"Stop analysis");
131 SetItemField(
"/Control/CmdStop",
"_hidden",
"true");
133 RegisterCommand(
"/Control/CmdClose",
"this->CmdClose();",
"");
134 SetItemField(
"/Control/CmdClose",
"_title",
"Close analysis");
135 SetItemField(
"/Control/CmdClose",
"_hidden",
"true");
137 RegisterCommand(
"/Control/CmdRestart",
"this->CmdRestart();",
"button;go4sys/icons/restart.png");
138 SetItemField(
"/Control/CmdRestart",
"_title",
"Resubmit analysis configuration and start again");
139 SetItemField(
"/Control/CmdRestart",
"_hidden",
"true");
141 RegisterCommand(
"/Control/CmdExit",
"this->CmdExit();",
"");
142 SetItemField(
"/Control/CmdExit",
"_title",
"Exit analysis process");
143 SetItemField(
"/Control/CmdExit",
"_hidden",
"true");
149 RegisterCommand(
"/Control/CmdOpenFile",
"this->CmdOpenFile(\"%arg1%\");",
"button;go4sys/icons/fileopen.png");
150 SetItemField(
"/Control/CmdOpenFile",
"_title",
"Open ROOT file in analysis");
151 SetItemField(
"/Control/CmdOpenFile",
"_hreload",
"true");
154 RegisterCommand(
"/Control/CmdCloseFiles",
"this->CmdCloseFiles();",
"go4sys/icons/fileclose.png");
155 SetItemField(
"/Control/CmdCloseFiles",
"_title",
"Close all opened files");
156 SetItemField(
"/Control/CmdCloseFiles",
"_hreload",
"true");
159 RegisterCommand(
"/Control/CmdClearObject",
"this->CmdClearObject(\"%arg1%\");",
"");
160 SetItemField(
"/Control/CmdClearObject",
"_title",
"Clear object content");
161 SetItemField(
"/Control/CmdClearObject",
"_hidden",
"true");
163 RegisterCommand(
"/Control/CmdDeleteObject",
"this->CmdDeleteObject(\"%arg1%\");",
"");
164 SetItemField(
"/Control/CmdDeleteObject",
"_title",
"Delete object from analysis");
165 SetItemField(
"/Control/CmdDeleteObject",
"_hidden",
"true");
167 RegisterCommand(
"/Control/CmdExecute",
"this->CmdExecute(\"%arg1%\");",
"go4sys/icons/macro_t.png");
168 SetItemField(
"/Control/CmdExecute",
"_title",
"Execute interpreter line in the analysis context. '@' means 'TGo4Analysis::Instance()->' ; A leading '$' invokes python skript.");
174 SetItemField(
"/Control/Analysis",
"_prereq",
"jq");
175 SetItemField(
"/Control/Analysis",
"_autoload",
"go4sys/html/go4.js");
177 SetItemField(
"/Control/Analysis",
"_icon",
"go4sys/icons/control.png");
178 SetItemField(
"/Control/Analysis",
"_not_monitor",
"true");
180 RegisterObject(
"/Control",
this);
181 SetItemField(
"/Control/go4_sniffer",
"_hidden",
"true");
183 CreateItem(
"/Control/Terminal",
"Analysis terminal");
184 SetItemField(
"/Control/Terminal",
"_icon",
"go4sys/icons/analysiswin.png");
185 SetItemField(
"/Control/Terminal",
"_player",
"GO4.drawAnalysisTerminal");
187 RestrictGo4(
"/Control",
"visible=controller,admin");
191 RestrictGo4(
"/Conditions",
"allow=controller,admin");
193 RestrictGo4(
"/Parameters",
"allow=controller,admin&allow_method=CreateStatus");
197 SetItemField(
"/",
"_prereq",
"jq");
198 SetItemField(
"/",
"_autoload",
"go4sys/html/go4.js");
200 SetItemField(
"/",
"_icon",
"go4sys/icons/go4logo2_small.png");
201 SetItemField(
"/",
"_title",
"GO4 analysis");
204 SetItemField(
"/",
"_has_restrict",
"true");
207 SetItemField(
"/",
"_has_produce_multi",
"true");
217 gROOT->GetClass(
"TGo4ParameterStatus", kTRUE, kTRUE);
218 gROOT->GetClass(
"TGo4EventElement", kTRUE, kTRUE);
219 gROOT->GetClass(
"TGo4CompositeEvent", kTRUE, kTRUE);
220 gROOT->GetClass(
"TGo4AnalysisStatus", kTRUE, kTRUE);
221 gROOT->GetClass(
"TGo4AnalysisWebStatus", kTRUE, kTRUE);
235 rec.SetField(
"_toptitle",
"Go4 http server");
237 SniffBaseClass::ScanRoot(rec);
256 TFolder* files_fold =
dynamic_cast<TFolder*
> (main->FindObject(
"Files"));
267 ScanCollection(rec, files_fold->GetListOfFolders(),
"Files");
272 SniffBaseClass::ScanObjectProperties(rec, obj);
275 rec.SetField(
"_can_delete",
"true");
279 rec.SetField(
"_no_reset",
"true");
282 if (obj && obj->InheritsFrom(TGo4Parameter::Class())) {
284 rec.SetField(
"_prereq",
"jq");
285 rec.SetField(
"_autoload",
"go4sys/html/go4.js");
287 rec.SetField(
"_drawfunc",
"GO4.drawParameter");
288 rec.SetField(
"_drawscript",
"go4sys/html/pareditor.js");
289 rec.SetField(
"_drawopt",
"editor");
290 rec.SetField(
"_icon",
"go4sys/icons/parameter.png");
294 if (obj && obj->InheritsFrom(TGo4Condition::Class())) {
296 rec.SetField(
"_prereq",
"jq");
297 rec.SetField(
"_autoload",
"go4sys/html/go4.js");
299 rec.SetField(
"_icon",
"go4sys/icons/condedit.png");
303 if (obj && obj->InheritsFrom(TGo4EventElement::Class())) {
304 rec.SetField(
"_more",
"true");
305 rec.SetField(
"_go4event",
"true");
306 rec.SetField(
"_icon",
"go4sys/icons/eventobj.png");
313 if ((path!=0) && (strcmp(path,
"Status/Analysis")==0)) {
319 return SniffBaseClass::FindInHierarchy(path, cl, member, chld);
347 Info(
"CmdOpenFile",
"Open ROOT file %s", fname);
354 TFolder* files_fold =
dynamic_cast<TFolder*
> (main->FindObject(
"Files"));
355 if (files_fold == 0) {
356 files_fold = main->AddFolder(
"Files",
"ROOT files");
357 files_fold->SetOwner(kTRUE);
360 TFile* f =
dynamic_cast<TFile*
> (files_fold->FindObject(fname));
361 if (f!=0) { files_fold->Remove(f);
delete f; }
363 f = TFile::Open(fname);
364 if (f==0)
return kFALSE;
374 Info(
"CmdCloseFiles",
"Close all opened files");
378 TFolder* files_fold =
dynamic_cast<TFolder*
> (main->FindObject(
"Files"));
381 main->Remove(files_fold);
477 if ((objname==0) || (*objname==0)) {
489 SendStatusMessage(2, kTRUE, TString::Format(
"Could not clear object %s", objname));
504 if ((objname==0) || (*objname==0)) {
514 SendStatusMessage(2, kTRUE, TString::Format(
"Could not delete object %s", objname));
523 if ((exeline==0) || (*exeline==0))
return kFALSE;
532 return errcode!=0 ? kFALSE : kTRUE;
542 if ((title==0) || (strlen(title)==0))
return;
544 const char* prev = GetItemField(
"/Status/DebugOutput",
"value");
546 if (prev && (strcmp(prev,
"---")!=0)) res = prev;
547 if (res.Length() > 50000) res.Remove(0, res.Length() - 25000);
548 res.Append(
"\n"); res.Append(title);
550 SetItemField(
"/Status/DebugOutput",
"value", res);
552 const char *cur = title;
554 const char* next = strchr(cur,
'\n');
575 tm0.Set(1995,1,1,0,0,0,0,kTRUE,0);
578 fEventRate->GetXaxis()->SetTimeFormat(
"%H:%M:%S");
585 const char* prev = GetItemField(
"/Status/Message",
"value");
587 if (prev && (strcmp(prev,
"---")!=0)) res = prev;
588 res.Append(
"\n"); res.Append(msg);
590 SetItemField(
"/Status/Message",
"value",res);
624 Bool_t res = ana->
AddHistogram(dynamic_cast<TH1*>(obj));
626 if (!res) res = ana->
AddDynamicEntry(dynamic_cast<TGo4DynamicEntry*>(obj));
629 SendStatusMessage(1, kFALSE, TString::Format(
"Added new object %s to Go4 folders.", obj->GetName()));
631 SendStatusMessage(3, kFALSE, TString::Format(
"ERROR on adding new object %s ", obj->GetName()));
639 const char* treename,
649 if ((histoname==0) || (*histoname==0)) histoname =
"hTreeDraw";
652 SendStatusMessage(1,kTRUE, TString::Format(
"Added Dynamic histogram %s for tree %s.", histoname, treename));
654 SendStatusMessage(2,kTRUE, TString::Format(
"Could not add Dynamic histogram %s for tree %s.", histoname, treename));
661 TObject *obj = FindTObjectInHierarchy(itemname);
663 TH1* h1 =
dynamic_cast<TH1*
> (obj);
674 return IsA()->GetMethodAllAny(
"Restrict") != 0;
679 return IsA()->GetMethodAllAny(
"ProduceMulti") != 0;
688 TString call_args = TString::Format(
"\"%s\",\"%s\"", path, options);
690 TMethodCall call(IsA(),
"Restrict", call_args.Data());
697 return IsA()->GetMethodAllAny(
"SetAutoLoad") != 0;
704 TString call_args = TString::Format(
"\"%s\"", script);
706 TMethodCall call(IsA(),
"SetAutoLoad", call_args.Data());
Bool_t AddTreeHistogram(const char *hisname, const char *treename, const char *varexp, const char *cutexp)
Bool_t HasRestrictMethod()
Bool_t CmdOpenFile(const char *fname)
void UpdateFrom(const TGo4Ratemeter *r)
virtual void * FindInHierarchy(const char *path, TClass **cl=0, TDataMember **member=0, Int_t *chld=0)
TGo4MsgList fStatusMessages
void UpdateStatus(TGo4AnalysisStatus *state)
virtual void StatusMessage(int level, Bool_t printout, const TString &)
Bool_t CmdExecute(const char *exeline)
virtual void CloseAnalysis()
virtual void ProcessSnifferEvents()
static const char * GetHISTFOLDER()
TGo4AnalysisWebStatus * fAnalysisStatus
TRootSniffer SniffBaseClass
void SendMessageToGUI(Int_t level, Bool_t printout, const char *text)
static const char * GetCONDFOLDER()
void SetSniffer(TGo4AnalysisSniffer *sniff)
Bool_t HasProduceMultiMethod()
Bool_t RemoteTreeDraw(const char *histoname, const char *treename, const char *varexpr, const char *cutexpr)
static const char * GetCANVFOLDER()
TGo4AnalysisClient * GetAnalysisClient() const
static const char * GetUSRFOLDER()
virtual void ScanRoot(TRootSnifferScanRec &rec)
int main(int argc, char **argv)
static void SetSniffer(TNamed *sniff)
TGo4Sniffer(const char *name)
Bool_t AddHistogram(TH1 *his, const char *subfolder=0, Bool_t replace=kTRUE)
virtual void SetTitle(const char *title="")
static THttpServer * gHttpServer
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=0)
Bool_t DeleteObjects(const char *name)
static const char * GetPARAFOLDER()
static const char * Message(Int_t prio, const char *text,...)
Bool_t ClearObjects(const char *name)
static const char * GetPICTFOLDER()
TGo4AnalysisObjectManager * ObjectManager() const
virtual void ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj)
virtual Bool_t InitEventClasses()
TFolder * GetObjectFolder()
Bool_t CmdClearObject(const char *objname)
virtual void SendStatusMessage(Int_t level, Bool_t printout, const TString &text)
void AddMsg(const char *msg)
TObject * CreateItemStatus(const char *itemname)
static Bool_t CreateEngine(const char *name)
Long_t ExecuteLine(const char *command, Int_t *errcode=0)
virtual void RatemeterUpdate(TGo4Ratemeter *)
Bool_t SetAutoLoadGo4(const char *script)
TGo4Ratemeter * fRatemeter
static const char * GetEVENTFOLDER()
static const char * GetANALYSISFOLDER()
Bool_t AddDynamicEntry(TGo4DynamicEntry *entry)
static const char * GO4SYS()
Bool_t CmdDeleteObject(const char *objname)
static TGo4Analysis * Instance()
Bool_t AddAnalysisObject(TObject *obj)
TGo4AnalysisWebStatus * CreateWebStatus()
static const char * GetTREEFOLDER()
void RestrictGo4(const char *path, const char *options)
Bool_t HasAutoLoadMethod()