19 #include "THttpServer.h"
20 #include "TBufferJSON.h"
25 #include "TTimeStamp.h"
29 #include "TMethodCall.h"
58 TBufferJSON::SetFloatFormat(
"%15.9e");
61 if (strstr(args,
"jsroot:")==args) {
76 fDebugOutput(
"Log",
"Analysis log messages", 1000),
77 fStatusMessages(
"Msg",
"Analysis status messages", 100),
81 SetScanGlobalDir(kFALSE);
94 SetItemField(
"/Status/Log",
"_hidden",
"true");
95 SetItemField(
"/Status/Msg",
"_hidden",
"true");
97 CreateItem(
"/Status/Message",
"Last message from analysis");
98 SetItemField(
"/Status/Message",
"_kind",
"Text");
99 SetItemField(
"/Status/Message",
"value",
"---");
101 CreateItem(
"/Status/DebugOutput",
"Go4 debug output");
102 SetItemField(
"/Status/DebugOutput",
"_kind",
"Text");
103 SetItemField(
"/Status/DebugOutput",
"value",
"---");
112 fEventRate->SetTitle(
"Events processing rate");
114 fEventRate->GetXaxis()->SetTimeFormat(
"%H:%M:%S");
119 SetItemField(
"/Status/Ratemeter",
"_hidden",
"true");
120 SetItemField(
"/Status/Ratemeter",
"_status",
"GO4.DrawAnalysisRatemeter");
122 RegisterCommand(
"/Control/CmdClear",
"this->CmdClear();",
"button;go4sys/icons/clear.png");
123 SetItemField(
"/Control/CmdClear",
"_title",
"Clear histograms and conditions in analysis");
124 SetItemField(
"/Control/CmdClear",
"_hidden",
"true");
126 RegisterCommand(
"/Control/CmdStart",
"this->CmdStart();",
"button;go4sys/icons/start.png");
127 SetItemField(
"/Control/CmdStart",
"_title",
"Start analysis");
128 SetItemField(
"/Control/CmdStart",
"_hidden",
"true");
130 RegisterCommand(
"/Control/CmdStop",
"this->CmdStop();",
"button;go4sys/icons/Stop.png");
131 SetItemField(
"/Control/CmdStop",
"_title",
"Stop analysis");
132 SetItemField(
"/Control/CmdStop",
"_hidden",
"true");
134 RegisterCommand(
"/Control/CmdClose",
"this->CmdClose();",
"");
135 SetItemField(
"/Control/CmdClose",
"_title",
"Close analysis");
136 SetItemField(
"/Control/CmdClose",
"_hidden",
"true");
138 RegisterCommand(
"/Control/CmdRestart",
"this->CmdRestart();",
"button;go4sys/icons/restart.png");
139 SetItemField(
"/Control/CmdRestart",
"_title",
"Resubmit analysis configuration and start again");
140 SetItemField(
"/Control/CmdRestart",
"_hidden",
"true");
142 RegisterCommand(
"/Control/CmdExit",
"this->CmdExit();",
"");
143 SetItemField(
"/Control/CmdExit",
"_title",
"Exit analysis process");
144 SetItemField(
"/Control/CmdExit",
"_hidden",
"true");
150 RegisterCommand(
"/Control/CmdOpenFile",
"this->CmdOpenFile(\"%arg1%\");",
"button;go4sys/icons/fileopen.png");
151 SetItemField(
"/Control/CmdOpenFile",
"_title",
"Open ROOT file in analysis");
152 SetItemField(
"/Control/CmdOpenFile",
"_hreload",
"true");
155 RegisterCommand(
"/Control/CmdCloseFiles",
"this->CmdCloseFiles();",
"go4sys/icons/fileclose.png");
156 SetItemField(
"/Control/CmdCloseFiles",
"_title",
"Close all opened files");
157 SetItemField(
"/Control/CmdCloseFiles",
"_hreload",
"true");
160 RegisterCommand(
"/Control/CmdClearObject",
"this->CmdClearObject(\"%arg1%\");",
"");
161 SetItemField(
"/Control/CmdClearObject",
"_title",
"Clear object content");
162 SetItemField(
"/Control/CmdClearObject",
"_hidden",
"true");
164 RegisterCommand(
"/Control/CmdDeleteObject",
"this->CmdDeleteObject(\"%arg1%\");",
"");
165 SetItemField(
"/Control/CmdDeleteObject",
"_title",
"Delete object from analysis");
166 SetItemField(
"/Control/CmdDeleteObject",
"_hidden",
"true");
168 RegisterCommand(
"/Control/CmdExecute",
"this->CmdExecute(\"%arg1%\");",
"go4sys/icons/macro_t.png");
169 SetItemField(
"/Control/CmdExecute",
"_title",
"Execute interpreter line in the analysis context. '@' means 'TGo4Analysis::Instance()->' ; A leading '$' invokes python skript.");
175 SetItemField(
"/Control/Analysis",
"_prereq",
"jq");
176 SetItemField(
"/Control/Analysis",
"_autoload",
"go4sys/html/go4.js");
178 SetItemField(
"/Control/Analysis",
"_icon",
"go4sys/icons/control.png");
179 SetItemField(
"/Control/Analysis",
"_not_monitor",
"true");
181 RegisterObject(
"/Control",
this);
182 SetItemField(
"/Control/go4_sniffer",
"_hidden",
"true");
184 CreateItem(
"/Control/Terminal",
"Analysis terminal");
185 SetItemField(
"/Control/Terminal",
"_icon",
"go4sys/icons/analysiswin.png");
186 SetItemField(
"/Control/Terminal",
"_player",
"GO4.drawAnalysisTerminal");
188 RestrictGo4(
"/Control",
"visible=controller,admin");
192 RestrictGo4(
"/Conditions",
"allow=controller,admin");
194 RestrictGo4(
"/Parameters",
"allow=controller,admin&allow_method=CreateStatus");
198 SetItemField(
"/",
"_prereq",
"jq");
199 SetItemField(
"/",
"_autoload",
"go4sys/html/go4.js");
201 SetItemField(
"/",
"_icon",
"go4sys/icons/go4logo2_small.png");
202 SetItemField(
"/",
"_title",
"GO4 analysis");
205 SetItemField(
"/",
"_has_restrict",
"true");
208 SetItemField(
"/",
"_has_produce_multi",
"true");
218 gROOT->GetClass(
"TGo4ParameterStatus", kTRUE, kTRUE);
219 gROOT->GetClass(
"TGo4EventElement", kTRUE, kTRUE);
220 gROOT->GetClass(
"TGo4CompositeEvent", kTRUE, kTRUE);
221 gROOT->GetClass(
"TGo4AnalysisStatus", kTRUE, kTRUE);
222 gROOT->GetClass(
"TGo4AnalysisWebStatus", kTRUE, kTRUE);
236 rec.SetField(
"_toptitle",
"Go4 http server");
238 SniffBaseClass::ScanRoot(rec);
257 TFolder* files_fold =
dynamic_cast<TFolder*
> (main->FindObject(
"Files"));
268 ScanCollection(rec, files_fold->GetListOfFolders(),
"Files");
273 SniffBaseClass::ScanObjectProperties(rec, obj);
276 rec.SetField(
"_can_delete",
"true");
280 rec.SetField(
"_no_reset",
"true");
283 if (obj && obj->InheritsFrom(TGo4Parameter::Class())) {
285 rec.SetField(
"_prereq",
"jq");
286 rec.SetField(
"_autoload",
"go4sys/html/go4.js");
288 rec.SetField(
"_drawfunc",
"GO4.drawParameter");
289 rec.SetField(
"_drawscript",
"go4sys/html/pareditor.js");
290 rec.SetField(
"_drawopt",
"editor");
291 rec.SetField(
"_icon",
"go4sys/icons/parameter.png");
295 if (obj && obj->InheritsFrom(TGo4Condition::Class())) {
297 rec.SetField(
"_prereq",
"jq");
298 rec.SetField(
"_autoload",
"go4sys/html/go4.js");
300 rec.SetField(
"_icon",
"go4sys/icons/condedit.png");
304 if (obj && obj->InheritsFrom(TGo4EventElement::Class())) {
305 rec.SetField(
"_more",
"true");
306 rec.SetField(
"_go4event",
"true");
307 rec.SetField(
"_icon",
"go4sys/icons/eventobj.png");
314 if ((path!=0) && (strcmp(path,
"Status/Analysis")==0)) {
320 return SniffBaseClass::FindInHierarchy(path, cl, member, chld);
348 Info(
"CmdOpenFile",
"Open ROOT file %s", fname);
355 TFolder* files_fold =
dynamic_cast<TFolder*
> (main->FindObject(
"Files"));
356 if (files_fold == 0) {
357 files_fold = main->AddFolder(
"Files",
"ROOT files");
358 files_fold->SetOwner(kTRUE);
361 TFile* f =
dynamic_cast<TFile*
> (files_fold->FindObject(fname));
362 if (f!=0) { files_fold->Remove(f);
delete f; }
364 f = TFile::Open(fname);
365 if (f==0)
return kFALSE;
375 Info(
"CmdCloseFiles",
"Close all opened files");
379 TFolder* files_fold =
dynamic_cast<TFolder*
> (main->FindObject(
"Files"));
382 main->Remove(files_fold);
478 if ((objname==0) || (*objname==0)) {
490 SendStatusMessage(2, kTRUE, TString::Format(
"Could not clear object %s", objname));
505 if ((objname==0) || (*objname==0)) {
515 SendStatusMessage(2, kTRUE, TString::Format(
"Could not delete object %s", objname));
524 if ((exeline==0) || (*exeline==0))
return kFALSE;
533 return errcode!=0 ? kFALSE : kTRUE;
543 if ((title==0) || (strlen(title)==0))
return;
545 const char* prev = GetItemField(
"/Status/DebugOutput",
"value");
547 if (prev && (strcmp(prev,
"---")!=0)) res = prev;
548 if (res.Length() > 50000) res.Remove(0, res.Length() - 25000);
549 res.Append(
"\n"); res.Append(title);
551 SetItemField(
"/Status/DebugOutput",
"value", res);
553 const char *cur = title;
555 const char* next = strchr(cur,
'\n');
576 tm0.Set(1995,1,1,0,0,0,0,kTRUE,0);
579 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);
623 Bool_t res = ana->
AddHistogram(dynamic_cast<TH1*>(obj));
625 if (!res) res = ana->
AddDynamicEntry(dynamic_cast<TGo4DynamicEntry*>(obj));
628 SendStatusMessage(1, kFALSE, TString::Format(
"Added new object %s to Go4 folders.", obj->GetName()));
630 SendStatusMessage(3, kFALSE, TString::Format(
"ERROR on adding new object %s ", obj->GetName()));
638 const char* treename,
648 if ((histoname==0) || (*histoname==0)) histoname =
"hTreeDraw";
651 SendStatusMessage(1,kTRUE, TString::Format(
"Added Dynamic histogram %s for tree %s.", histoname, treename));
653 SendStatusMessage(2,kTRUE, TString::Format(
"Could not add Dynamic histogram %s for tree %s.", histoname, treename));
660 TObject *obj = FindTObjectInHierarchy(itemname);
662 TH1* h1 =
dynamic_cast<TH1*
> (obj);
673 return IsA()->GetMethodAllAny(
"Restrict") != 0;
678 return IsA()->GetMethodAllAny(
"ProduceMulti") != 0;
687 TString call_args = TString::Format(
"\"%s\",\"%s\"", path, options);
689 TMethodCall call(IsA(),
"Restrict", call_args.Data());
696 return IsA()->GetMethodAllAny(
"SetAutoLoad") != 0;
703 TString call_args = TString::Format(
"\"%s\"", script);
705 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()
TGo4AnalysisWebStatus * fAnalysisStatus
TRootSniffer SniffBaseClass
void SendMessageToGUI(Int_t level, Bool_t printout, const char *text)
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 * fgcPARAFOLDER
TGo4AnalysisClient * GetAnalysisClient() const
static const char * fgcCONDFOLDER
virtual void ScanRoot(TRootSnifferScanRec &rec)
int main(int argc, char **argv)
static void SetSniffer(TNamed *sniff)
TGo4Sniffer(const char *name)
static const char * fgcTREEFOLDER
Bool_t AddHistogram(TH1 *his, const char *subfolder=0, Bool_t replace=kTRUE)
virtual void SetTitle(const char *title="")
static THttpServer * gHttpServer
static const char * fgcUSRFOLDER
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=0)
Bool_t DeleteObjects(const char *name)
static const char * Message(Int_t prio, const char *text,...)
Bool_t ClearObjects(const char *name)
TGo4AnalysisObjectManager * ObjectManager() const
virtual void ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj)
static const char * fgcEVENTFOLDER
static const char * fgcHISTFOLDER
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
Bool_t AddDynamicEntry(TGo4DynamicEntry *entry)
static const char * fgcANALYSISFOLDER
static const char * GO4SYS()
static const char * fgcCANVFOLDER
Bool_t CmdDeleteObject(const char *objname)
static TGo4Analysis * Instance()
Bool_t AddAnalysisObject(TObject *obj)
TGo4AnalysisWebStatus * CreateWebStatus()
void RestrictGo4(const char *path, const char *options)
static const char * fgcPICTFOLDER
Bool_t HasAutoLoadMethod()