20 #include "THttpServer.h" 21 #include "TBufferJSON.h" 24 #include "TTimeStamp.h" 28 #include "TMethodCall.h" 62 TBufferJSON::SetFloatFormat(
"%15.9e");
65 if (strstr(args,
"jsroot:") == args) {
75 TRootSnifferFull(name),
82 SetScanGlobalDir(kFALSE);
95 SetItemField(
"/Status/Log",
"_hidden",
"true");
96 SetItemField(
"/Status/Msg",
"_hidden",
"true");
98 CreateItem(
"/Status/Message",
"Last message from analysis");
99 SetItemField(
"/Status/Message",
"_kind",
"Text");
100 SetItemField(
"/Status/Message",
"value",
"---");
102 CreateItem(
"/Status/DebugOutput",
"Go4 debug output");
103 SetItemField(
"/Status/DebugOutput",
"_kind",
"Text");
104 SetItemField(
"/Status/DebugOutput",
"value",
"---");
113 fEventRate->SetTitle(
"Events processing rate");
115 fEventRate->GetXaxis()->SetTimeFormat(
"%H:%M:%S");
117 fEventRate->GetHistogram()->SetDirectory(
nullptr);
122 SetItemField(
"/Status/Ratemeter",
"_hidden",
"true");
123 SetItemField(
"/Status/Ratemeter",
"_status",
"GO4.DrawAnalysisRatemeter");
125 RegisterCommand(
"/Control/CmdClear",
"this->CmdClear();",
"button;go4sys/icons/clear.png");
126 SetItemField(
"/Control/CmdClear",
"_title",
"Clear histograms and conditions in analysis");
127 SetItemField(
"/Control/CmdClear",
"_hidden",
"true");
129 RegisterCommand(
"/Control/CmdStart",
"this->CmdStart();",
"button;go4sys/icons/start.png");
130 SetItemField(
"/Control/CmdStart",
"_title",
"Start analysis");
131 SetItemField(
"/Control/CmdStart",
"_hidden",
"true");
133 RegisterCommand(
"/Control/CmdStop",
"this->CmdStop();",
"button;go4sys/icons/Stop.png");
134 SetItemField(
"/Control/CmdStop",
"_title",
"Stop analysis");
135 SetItemField(
"/Control/CmdStop",
"_hidden",
"true");
137 RegisterCommand(
"/Control/CmdClose",
"this->CmdClose();",
"");
138 SetItemField(
"/Control/CmdClose",
"_title",
"Close analysis");
139 SetItemField(
"/Control/CmdClose",
"_hidden",
"true");
141 RegisterCommand(
"/Control/CmdRestart",
"this->CmdRestart();",
"button;go4sys/icons/restart.png");
142 SetItemField(
"/Control/CmdRestart",
"_title",
"Resubmit analysis configuration and start again");
143 SetItemField(
"/Control/CmdRestart",
"_hidden",
"true");
145 RegisterCommand(
"/Control/CmdExit",
"this->CmdExit();",
"");
146 SetItemField(
"/Control/CmdExit",
"_title",
"Exit analysis process");
147 SetItemField(
"/Control/CmdExit",
"_hidden",
"true");
153 RegisterCommand(
"/Control/CmdOpenFile",
"this->CmdOpenFile(\"%arg1%\");",
"button;go4sys/icons/fileopen.png");
154 SetItemField(
"/Control/CmdOpenFile",
"_title",
"Open ROOT file in analysis");
155 SetItemField(
"/Control/CmdOpenFile",
"_hreload",
"true");
158 RegisterCommand(
"/Control/CmdCloseFiles",
"this->CmdCloseFiles();",
"go4sys/icons/fileclose.png");
159 SetItemField(
"/Control/CmdCloseFiles",
"_title",
"Close all opened files");
160 SetItemField(
"/Control/CmdCloseFiles",
"_hreload",
"true");
163 RegisterCommand(
"/Control/CmdClearObject",
"this->CmdClearObject(\"%arg1%\");",
"");
164 SetItemField(
"/Control/CmdClearObject",
"_title",
"Clear object content");
165 SetItemField(
"/Control/CmdClearObject",
"_hidden",
"true");
167 RegisterCommand(
"/Control/CmdDeleteObject",
"this->CmdDeleteObject(\"%arg1%\");",
"");
168 SetItemField(
"/Control/CmdDeleteObject",
"_title",
"Delete object from analysis");
169 SetItemField(
"/Control/CmdDeleteObject",
"_hidden",
"true");
171 RegisterCommand(
"/Control/CmdExecute",
"this->CmdExecute(\"%arg1%\");",
"go4sys/icons/macro_t.png");
172 SetItemField(
"/Control/CmdExecute",
"_title",
"Execute interpreter line in the analysis context. '@' means 'TGo4Analysis::Instance()->' ; A leading '$' invokes python skript.");
178 SetItemField(
"/Control/Analysis",
"_prereq",
"jq");
179 SetItemField(
"/Control/Analysis",
"_autoload",
"go4sys/html/go4.js");
181 SetItemField(
"/Control/Analysis",
"_icon",
"go4sys/icons/control.png");
182 SetItemField(
"/Control/Analysis",
"_not_monitor",
"true");
184 RegisterObject(
"/Control",
this);
185 SetItemField(
"/Control/go4_sniffer",
"_hidden",
"true");
187 CreateItem(
"/Control/Terminal",
"Analysis terminal");
188 SetItemField(
"/Control/Terminal",
"_icon",
"go4sys/icons/analysiswin.png");
189 SetItemField(
"/Control/Terminal",
"_player",
"GO4.drawAnalysisTerminal");
191 RestrictGo4(
"/Control",
"visible=controller,admin");
195 RestrictGo4(
"/Conditions",
"allow=controller,admin");
197 RestrictGo4(
"/Parameters",
"allow=controller,admin&allow_method=CreateStatus");
201 SetItemField(
"/",
"_prereq",
"jq");
202 SetItemField(
"/",
"_autoload",
"go4sys/html/go4.js");
204 SetItemField(
"/",
"_icon",
"go4sys/icons/go4logo2_small.png");
205 SetItemField(
"/",
"_title",
"GO4 analysis");
208 SetItemField(
"/",
"_has_restrict",
"true");
211 SetItemField(
"/",
"_has_produce_multi",
"true");
221 gROOT->GetClass(
"TGo4ParameterStatus", kTRUE, kTRUE);
222 gROOT->GetClass(
"TGo4EventElement", kTRUE, kTRUE);
223 gROOT->GetClass(
"TGo4CompositeEvent", kTRUE, kTRUE);
224 gROOT->GetClass(
"TGo4AnalysisStatus", kTRUE, kTRUE);
225 gROOT->GetClass(
"TGo4AnalysisWebStatus", kTRUE, kTRUE);
239 rec.SetField(
"_toptitle",
"Go4 http server");
241 TRootSnifferFull::ScanRoot(rec);
260 TFolder *files_fold =
dynamic_cast<TFolder *
>(main->FindObject(
"Files"));
271 ScanCollection(rec, files_fold->GetListOfFolders(),
"Files");
276 TRootSnifferFull::ScanObjectProperties(rec, obj);
279 rec.SetField(
"_can_delete",
"true");
283 rec.SetField(
"_no_reset",
"true");
286 if (obj && obj->InheritsFrom(TGo4Parameter::Class())) {
288 rec.SetField(
"_prereq",
"jq");
289 rec.SetField(
"_autoload",
"go4sys/html/go4.js");
291 rec.SetField(
"_drawfunc",
"GO4.drawParameter");
292 rec.SetField(
"_drawscript",
"go4sys/html/pareditor.js");
293 rec.SetField(
"_drawopt",
"editor");
294 rec.SetField(
"_icon",
"go4sys/icons/parameter.png");
298 if (obj && obj->InheritsFrom(TGo4Condition::Class())) {
300 rec.SetField(
"_prereq",
"jq");
301 rec.SetField(
"_autoload",
"go4sys/html/go4.js");
303 rec.SetField(
"_icon",
"go4sys/icons/condedit.png");
307 if (obj && obj->InheritsFrom(TGo4EventElement::Class())) {
308 rec.SetField(
"_more",
"true");
309 rec.SetField(
"_go4event",
"true");
310 rec.SetField(
"_icon",
"go4sys/icons/eventobj.png");
317 if (path && (strcmp(path,
"Status/Analysis") == 0)) {
323 return TRootSnifferFull::FindInHierarchy(path, cl, member, chld);
351 Info(
"CmdOpenFile",
"Open ROOT file %s", fname);
358 TFolder *files_fold =
dynamic_cast<TFolder *
>(main->FindObject(
"Files"));
360 files_fold = main->AddFolder(
"Files",
"ROOT files");
361 files_fold->SetOwner(kTRUE);
364 auto f =
dynamic_cast<TFile *
> (files_fold->FindObject(fname));
365 if (f) { files_fold->Remove(f);
delete f; }
367 f = TFile::Open(fname);
368 if (!f)
return kFALSE;
378 Info(
"CmdCloseFiles",
"Close all opened files");
382 TFolder *files_fold =
dynamic_cast<TFolder *
>(main->FindObject(
"Files"));
385 main->Remove(files_fold);
477 if (!objname || (*objname == 0)) {
489 SendStatusMessage(2, kTRUE, TString::Format(
"Could not clear object %s", objname));
504 if (!objname || (*objname == 0)) {
514 SendStatusMessage(2, kTRUE, TString::Format(
"Could not delete object %s", objname));
523 if (!exeline || (*exeline == 0))
return kFALSE;
532 return errcode != 0 ? kFALSE : kTRUE;
541 if (!title || (strlen(title) == 0))
return;
543 const char *prev = GetItemField(
"/Status/DebugOutput",
"value");
545 if (prev && (strcmp(prev,
"---") != 0)) res = prev;
546 if (res.Length() > 50000) res.Remove(0, res.Length() - 25000);
547 res.Append(
"\n"); res.Append(title);
549 SetItemField(
"/Status/DebugOutput",
"value", res);
551 const char *cur = title;
553 const char *next = strchr(cur,
'\n');
574 tm0.Set(1995,1,1,0,0,0,0,kTRUE,0);
577 fEventRate->GetXaxis()->SetTimeFormat(
"%H:%M:%S");
579 fEventRate->GetHistogram()->SetDirectory(
nullptr);
584 const char *prev = GetItemField(
"/Status/Message",
"value");
586 if (prev && (strcmp(prev,
"---") != 0)) res = prev;
587 res.Append(
"\n"); res.Append(msg);
589 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 || (*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") !=
nullptr;
678 return IsA()->GetMethodAllAny(
"ProduceMulti") !=
nullptr;
687 TString call_args = TString::Format(
"\"%s\",\"%s\"", path, options);
689 TMethodCall call(IsA(),
"Restrict", call_args.Data());
696 return IsA()->GetMethodAllAny(
"SetAutoLoad") !=
nullptr;
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)
TGo4MsgList fStatusMessages
void UpdateStatus(TGo4AnalysisStatus *state)
Bool_t CmdExecute(const char *exeline)
virtual void CloseAnalysis()
static const char * GetHISTFOLDER()
TGo4AnalysisObjectManager * ObjectManager() const
void StatusMessage(int level, Bool_t printout, const TString &) override
TGo4AnalysisWebStatus * fAnalysisStatus
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()
int main(int argc, char **argv)
void SetTitle(const char *title="") override
static void SetSniffer(TNamed *sniff)
TGo4Sniffer(const char *name)
void * FindInHierarchy(const char *path, TClass **cl=nullptr, TDataMember **member=nullptr, Int_t *chld=nullptr) override
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
void ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj) override
void ProcessSnifferEvents() override
static THttpServer * gHttpServer
void RatemeterUpdate(TGo4Ratemeter *) override
Long64_t ExecuteLine(const char *command, Int_t *errcode=nullptr)
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=nullptr)
Bool_t DeleteObjects(const char *name)
static const char * GetPARAFOLDER()
Bool_t ClearObjects(const char *name)
Bool_t AddHistogram(TH1 *his, const char *subfolder=nullptr, Bool_t replace=kTRUE)
static const char * GetPICTFOLDER()
virtual Bool_t InitEventClasses()
void ScanRoot(TRootSnifferScanRec &rec) override
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)
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()
static THttpServer * GetHttpServer()
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()