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");
116 SetItemField(
"/Status/Ratemeter",
"_hidden",
"true");
117 SetItemField(
"/Status/Ratemeter",
"_status",
"GO4.DrawAnalysisRatemeter");
119 RegisterCommand(
"/Control/CmdClear",
"this->CmdClear();",
"button;go4sys/icons/clear.png");
120 SetItemField(
"/Control/CmdClear",
"_title",
"Clear histograms and conditions in analysis");
121 SetItemField(
"/Control/CmdClear",
"_hidden",
"true");
123 RegisterCommand(
"/Control/CmdStart",
"this->CmdStart();",
"button;go4sys/icons/start.png");
124 SetItemField(
"/Control/CmdStart",
"_title",
"Start analysis");
125 SetItemField(
"/Control/CmdStart",
"_hidden",
"true");
127 RegisterCommand(
"/Control/CmdStop",
"this->CmdStop();",
"button;go4sys/icons/Stop.png");
128 SetItemField(
"/Control/CmdStop",
"_title",
"Stop analysis");
129 SetItemField(
"/Control/CmdStop",
"_hidden",
"true");
131 RegisterCommand(
"/Control/CmdClose",
"this->CmdClose();",
"");
132 SetItemField(
"/Control/CmdClose",
"_title",
"Close analysis");
133 SetItemField(
"/Control/CmdClose",
"_hidden",
"true");
135 RegisterCommand(
"/Control/CmdRestart",
"this->CmdRestart();",
"button;go4sys/icons/restart.png");
136 SetItemField(
"/Control/CmdRestart",
"_title",
"Resubmit analysis configuration and start again");
137 SetItemField(
"/Control/CmdRestart",
"_hidden",
"true");
139 RegisterCommand(
"/Control/CmdExit",
"this->CmdExit();",
"");
140 SetItemField(
"/Control/CmdExit",
"_title",
"Exit analysis process");
141 SetItemField(
"/Control/CmdExit",
"_hidden",
"true");
147 RegisterCommand(
"/Control/CmdOpenFile",
"this->CmdOpenFile(\"%arg1%\");",
"button;go4sys/icons/fileopen.png");
148 SetItemField(
"/Control/CmdOpenFile",
"_title",
"Open ROOT file in analysis");
149 SetItemField(
"/Control/CmdOpenFile",
"_hreload",
"true");
152 RegisterCommand(
"/Control/CmdCloseFiles",
"this->CmdCloseFiles();",
"go4sys/icons/fileclose.png");
153 SetItemField(
"/Control/CmdCloseFiles",
"_title",
"Close all opened files");
154 SetItemField(
"/Control/CmdCloseFiles",
"_hreload",
"true");
157 RegisterCommand(
"/Control/CmdClearObject",
"this->CmdClearObject(\"%arg1%\");",
"");
158 SetItemField(
"/Control/CmdClearObject",
"_title",
"Clear object content");
159 SetItemField(
"/Control/CmdClearObject",
"_hidden",
"true");
161 RegisterCommand(
"/Control/CmdDeleteObject",
"this->CmdDeleteObject(\"%arg1%\");",
"");
162 SetItemField(
"/Control/CmdDeleteObject",
"_title",
"Delete object from analysis");
163 SetItemField(
"/Control/CmdDeleteObject",
"_hidden",
"true");
165 RegisterCommand(
"/Control/CmdExecute",
"this->CmdExecute(\"%arg1%\");",
"go4sys/icons/macro_t.png");
166 SetItemField(
"/Control/CmdExecute",
"_title",
"Execute interpreter line in the analysis context. '@' means 'TGo4Analysis::Instance()->' ; A leading '$' invokes python skript.");
172 SetItemField(
"/Control/Analysis",
"_prereq",
"jq");
173 SetItemField(
"/Control/Analysis",
"_autoload",
"go4sys/html/go4.js");
175 SetItemField(
"/Control/Analysis",
"_icon",
"go4sys/icons/control.png");
176 SetItemField(
"/Control/Analysis",
"_not_monitor",
"true");
178 RegisterObject(
"/Control",
this);
179 SetItemField(
"/Control/go4_sniffer",
"_hidden",
"true");
181 CreateItem(
"/Control/Terminal",
"Analysis terminal");
182 SetItemField(
"/Control/Terminal",
"_icon",
"go4sys/icons/analysiswin.png");
183 SetItemField(
"/Control/Terminal",
"_player",
"GO4.drawAnalysisTerminal");
185 RestrictGo4(
"/Control",
"visible=controller,admin");
189 RestrictGo4(
"/Conditions",
"allow=controller,admin");
191 RestrictGo4(
"/Parameters",
"allow=controller,admin&allow_method=CreateStatus");
195 SetItemField(
"/",
"_prereq",
"jq");
196 SetItemField(
"/",
"_autoload",
"go4sys/html/go4.js");
198 SetItemField(
"/",
"_icon",
"go4sys/icons/go4logo2_small.png");
199 SetItemField(
"/",
"_title",
"GO4 analysis");
202 SetItemField(
"/",
"_has_restrict",
"true");
205 SetItemField(
"/",
"_has_produce_multi",
"true");
215 gROOT->GetClass(
"TGo4ParameterStatus", kTRUE, kTRUE);
216 gROOT->GetClass(
"TGo4EventElement", kTRUE, kTRUE);
217 gROOT->GetClass(
"TGo4CompositeEvent", kTRUE, kTRUE);
218 gROOT->GetClass(
"TGo4AnalysisStatus", kTRUE, kTRUE);
219 gROOT->GetClass(
"TGo4AnalysisWebStatus", kTRUE, kTRUE);
233 rec.SetField(
"_toptitle",
"Go4 http server");
235 SniffBaseClass::ScanRoot(rec);
254 TFolder* files_fold =
dynamic_cast<TFolder*
> (main->FindObject(
"Files"));
265 ScanCollection(rec, files_fold->GetListOfFolders(),
"Files");
270 SniffBaseClass::ScanObjectProperties(rec, obj);
273 rec.SetField(
"_can_delete",
"true");
277 rec.SetField(
"_no_reset",
"true");
280 if (obj && obj->InheritsFrom(TGo4Parameter::Class())) {
282 rec.SetField(
"_prereq",
"jq");
283 rec.SetField(
"_autoload",
"go4sys/html/go4.js");
285 rec.SetField(
"_drawfunc",
"GO4.drawParameter");
286 rec.SetField(
"_drawscript",
"go4sys/html/pareditor.js");
287 rec.SetField(
"_drawopt",
"editor");
288 rec.SetField(
"_icon",
"go4sys/icons/parameter.png");
292 if (obj && obj->InheritsFrom(TGo4Condition::Class())) {
294 rec.SetField(
"_prereq",
"jq");
295 rec.SetField(
"_autoload",
"go4sys/html/go4.js");
297 rec.SetField(
"_icon",
"go4sys/icons/condedit.png");
301 if (obj && obj->InheritsFrom(TGo4EventElement::Class())) {
302 rec.SetField(
"_more",
"true");
303 rec.SetField(
"_go4event",
"true");
304 rec.SetField(
"_icon",
"go4sys/icons/eventobj.png");
311 if ((path!=0) && (strcmp(path,
"Status/Analysis")==0)) {
317 return SniffBaseClass::FindInHierarchy(path, cl, member, chld);
345 Info(
"CmdOpenFile",
"Open ROOT file %s", fname);
352 TFolder* files_fold =
dynamic_cast<TFolder*
> (main->FindObject(
"Files"));
353 if (files_fold == 0) {
354 files_fold = main->AddFolder(
"Files",
"ROOT files");
355 files_fold->SetOwner(kTRUE);
358 TFile* f =
dynamic_cast<TFile*
> (files_fold->FindObject(fname));
359 if (f!=0) { files_fold->Remove(f);
delete f; }
361 f = TFile::Open(fname);
362 if (f==0)
return kFALSE;
372 Info(
"CmdCloseFiles",
"Close all opened files");
376 TFolder* files_fold =
dynamic_cast<TFolder*
> (main->FindObject(
"Files"));
379 main->Remove(files_fold);
475 if ((objname==0) || (*objname==0)) {
487 SendStatusMessage(2, kTRUE, TString::Format(
"Could not clear object %s", objname));
502 if ((objname==0) || (*objname==0)) {
512 SendStatusMessage(2, kTRUE, TString::Format(
"Could not delete object %s", objname));
521 if ((exeline==0) || (*exeline==0))
return kFALSE;
530 return errcode!=0 ? kFALSE : kTRUE;
540 if ((title==0) || (strlen(title)==0))
return;
542 const char* prev = GetItemField(
"/Status/DebugOutput",
"value");
544 if (prev && (strcmp(prev,
"---")!=0)) res = prev;
545 if (res.Length() > 50000) res.Remove(0, res.Length() - 25000);
546 res.Append(
"\n"); res.Append(title);
548 SetItemField(
"/Status/DebugOutput",
"value", res);
550 const char *cur = title;
552 const char* next = strchr(cur,
'\n');
573 tm0.Set(1995,1,1,0,0,0,0,kTRUE,0);
576 fEventRate->GetXaxis()->SetTimeFormat(
"%H:%M:%S");
582 const char* prev = GetItemField(
"/Status/Message",
"value");
584 if (prev && (strcmp(prev,
"---")!=0)) res = prev;
585 res.Append(
"\n"); res.Append(msg);
587 SetItemField(
"/Status/Message",
"value",res);
621 Bool_t res = ana->
AddHistogram(dynamic_cast<TH1*>(obj));
623 if (!res) res = ana->
AddDynamicEntry(dynamic_cast<TGo4DynamicEntry*>(obj));
626 SendStatusMessage(1, kFALSE, TString::Format(
"Added new object %s to Go4 folders.", obj->GetName()));
628 SendStatusMessage(3, kFALSE, TString::Format(
"ERROR on adding new object %s ", obj->GetName()));
636 const char* treename,
646 if ((histoname==0) || (*histoname==0)) histoname =
"hTreeDraw";
649 SendStatusMessage(1,kTRUE, TString::Format(
"Added Dynamic histogram %s for tree %s.", histoname, treename));
651 SendStatusMessage(2,kTRUE, TString::Format(
"Could not add Dynamic histogram %s for tree %s.", histoname, treename));
658 TObject *obj = FindTObjectInHierarchy(itemname);
660 TH1* h1 =
dynamic_cast<TH1*
> (obj);
671 return IsA()->GetMethodAllAny(
"Restrict") != 0;
676 return IsA()->GetMethodAllAny(
"ProduceMulti") != 0;
685 TString call_args = TString::Format(
"\"%s\",\"%s\"", path, options);
687 TMethodCall call(IsA(),
"Restrict", call_args.Data());
694 return IsA()->GetMethodAllAny(
"SetAutoLoad") != 0;
701 TString call_args = TString::Format(
"\"%s\"", script);
703 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()