20#include "THttpServer.h"
21#include "TBufferJSON.h"
24#include "TTimeStamp.h"
28#include "TMethodCall.h"
63 TBufferJSON::SetFloatFormat(
"%15.9e");
66 if (strstr(args,
"jsroot:") == args) {
76 TRootSnifferFull(name),
83 SetScanGlobalDir(kFALSE);
85 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,33,0)
102 SetItemField(
"/Status/Log",
"_hidden",
"true");
103 SetItemField(
"/Status/Msg",
"_hidden",
"true");
105 CreateItem(
"/Status/Message",
"Last message from analysis");
106 SetItemField(
"/Status/Message",
"_kind",
"Text");
107 SetItemField(
"/Status/Message",
"value",
"---");
109 CreateItem(
"/Status/DebugOutput",
"Go4 debug output");
110 SetItemField(
"/Status/DebugOutput",
"_kind",
"Text");
111 SetItemField(
"/Status/DebugOutput",
"value",
"---");
120 fEventRate->SetTitle(
"Events processing rate");
122 fEventRate->GetXaxis()->SetTimeFormat(
"%H:%M:%S");
124 fEventRate->GetHistogram()->SetDirectory(
nullptr);
129 SetItemField(
"/Status/Ratemeter",
"_hidden",
"true");
130 SetItemField(
"/Status/Ratemeter",
"_status",
"GO4.DrawAnalysisRatemeter");
132 RegisterCommand(
"/Control/CmdClear",
"this->CmdClear();",
"button;go4sys/icons/clear.png");
133 SetItemField(
"/Control/CmdClear",
"_title",
"Clear histograms and conditions in analysis");
134 SetItemField(
"/Control/CmdClear",
"_hidden",
"true");
136 RegisterCommand(
"/Control/CmdStart",
"this->CmdStart();",
"button;go4sys/icons/start.png");
137 SetItemField(
"/Control/CmdStart",
"_title",
"Start analysis");
138 SetItemField(
"/Control/CmdStart",
"_hidden",
"true");
140 RegisterCommand(
"/Control/CmdStop",
"this->CmdStop();",
"button;go4sys/icons/Stop.png");
141 SetItemField(
"/Control/CmdStop",
"_title",
"Stop analysis");
142 SetItemField(
"/Control/CmdStop",
"_hidden",
"true");
144 RegisterCommand(
"/Control/CmdClose",
"this->CmdClose();",
"");
145 SetItemField(
"/Control/CmdClose",
"_title",
"Close analysis");
146 SetItemField(
"/Control/CmdClose",
"_hidden",
"true");
148 RegisterCommand(
"/Control/CmdRestart",
"this->CmdRestart();",
"button;go4sys/icons/restart.png");
149 SetItemField(
"/Control/CmdRestart",
"_title",
"Resubmit analysis configuration and start again");
150 SetItemField(
"/Control/CmdRestart",
"_hidden",
"true");
152 RegisterCommand(
"/Control/CmdExit",
"this->CmdExit();",
"");
153 SetItemField(
"/Control/CmdExit",
"_title",
"Exit analysis process");
154 SetItemField(
"/Control/CmdExit",
"_hidden",
"true");
160 RegisterCommand(
"/Control/CmdOpenFile",
"this->CmdOpenFile(\"%arg1%\");",
"button;go4sys/icons/fileopen.png");
161 SetItemField(
"/Control/CmdOpenFile",
"_title",
"Open ROOT file in analysis");
162 SetItemField(
"/Control/CmdOpenFile",
"_hreload",
"true");
165 RegisterCommand(
"/Control/CmdCloseFiles",
"this->CmdCloseFiles();",
"go4sys/icons/fileclose.png");
166 SetItemField(
"/Control/CmdCloseFiles",
"_title",
"Close all opened files");
167 SetItemField(
"/Control/CmdCloseFiles",
"_hreload",
"true");
170 RegisterCommand(
"/Control/CmdClearObject",
"this->CmdClearObject(\"%arg1%\");",
"");
171 SetItemField(
"/Control/CmdClearObject",
"_title",
"Clear object content");
172 SetItemField(
"/Control/CmdClearObject",
"_hidden",
"true");
174 RegisterCommand(
"/Control/CmdDeleteObject",
"this->CmdDeleteObject(\"%arg1%\");",
"");
175 SetItemField(
"/Control/CmdDeleteObject",
"_title",
"Delete object from analysis");
176 SetItemField(
"/Control/CmdDeleteObject",
"_hidden",
"true");
178 RegisterCommand(
"/Control/CmdExecute",
"this->CmdExecute(\"%arg1%\");",
"go4sys/icons/macro_t.png");
179 SetItemField(
"/Control/CmdExecute",
"_title",
"Execute interpreter line in the analysis context. '@' means 'TGo4Analysis::Instance()->' ; A leading '$' invokes python skript.");
185 SetItemField(
"/Control/Analysis",
"_autoload",
fAutoLoadArg);
186 SetItemField(
"/Control/Analysis",
"_icon",
"go4sys/icons/control.png");
187 SetItemField(
"/Control/Analysis",
"_not_monitor",
"true");
189 RegisterObject(
"/Control",
this);
190 SetItemField(
"/Control/go4_sniffer",
"_hidden",
"true");
192 CreateItem(
"/Control/Terminal",
"Analysis terminal");
193 SetItemField(
"/Control/Terminal",
"_icon",
"go4sys/icons/analysiswin.png");
194 SetItemField(
"/Control/Terminal",
"_player",
"GO4.drawAnalysisTerminal");
196 RestrictGo4(
"/Control",
"visible=controller,admin");
200 RestrictGo4(
"/Conditions",
"allow=controller,admin");
202 RestrictGo4(
"/Parameters",
"allow=controller,admin&allow_method=CreateStatus");
207 SetItemField(
"/",
"_icon",
"go4sys/icons/go4logo2_small.png");
208 SetItemField(
"/",
"_title",
"GO4 analysis");
211 SetItemField(
"/",
"_has_restrict",
"true");
214 SetItemField(
"/",
"_has_produce_multi",
"true");
224 gROOT->GetClass(
"TGo4ParameterStatus", kTRUE, kTRUE);
225 gROOT->GetClass(
"TGo4EventElement", kTRUE, kTRUE);
226 gROOT->GetClass(
"TGo4CompositeEvent", kTRUE, kTRUE);
227 gROOT->GetClass(
"TGo4AnalysisStatus", kTRUE, kTRUE);
228 gROOT->GetClass(
"TGo4AnalysisWebStatus", kTRUE, kTRUE);
242 rec.SetField(
"_toptitle",
"Go4 http server");
244 TRootSnifferFull::ScanRoot(rec);
263 TFolder *files_fold =
dynamic_cast<TFolder *
>(
main->FindObject(
"Files"));
274 ScanCollection(rec, files_fold->GetListOfFolders(),
"Files");
279 TRootSnifferFull::ScanObjectProperties(rec, obj);
284 rec.SetField(
"_can_delete",
"true");
288 rec.SetField(
"_no_reset",
"true");
291 if (obj->InheritsFrom(TGo4Parameter::Class())) {
294 rec.SetField(
"_drawfunc",
"GO4.drawParameter");
295 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,33,0)
296 rec.SetField(
"_drawscript",
"modules:go4sys/html5/pareditor.mjs");
298 rec.SetField(
"_drawscript",
"go4sys/html/pareditor.js");
300 rec.SetField(
"_drawopt",
"editor");
301 rec.SetField(
"_icon",
"go4sys/icons/parameter.png");
305 if (obj->InheritsFrom(TGo4Condition::Class())) {
308 rec.SetField(
"_icon",
"go4sys/icons/condedit.png");
312 if (obj->InheritsFrom(TGo4EventElement::Class())) {
313 rec.SetField(
"_more",
"true");
314 rec.SetField(
"_go4event",
"true");
315 rec.SetField(
"_icon",
"go4sys/icons/eventobj.png");
319 if (obj->InheritsFrom(TGo4MsgList::Class())) {
322 rec.SetField(
"_make_request",
"GO4.MakeMsgListRequest");
323 rec.SetField(
"_after_request",
"GO4.AfterMsgListRequest");
324 rec.SetField(
"_icon",
"img_text");
332 if (path && (strcmp(path,
"Status/Analysis") == 0)) {
338 return TRootSnifferFull::FindInHierarchy(path, cl, member, chld);
366 Info(
"CmdOpenFile",
"Open ROOT file %s", fname);
373 TFolder *files_fold =
dynamic_cast<TFolder *
>(
main->FindObject(
"Files"));
375 files_fold =
main->AddFolder(
"Files",
"ROOT files");
376 files_fold->SetOwner(kTRUE);
379 auto f =
dynamic_cast<TFile *
> (files_fold->FindObject(fname));
380 if (f) { files_fold->Remove(f);
delete f; }
382 f = TFile::Open(fname);
383 if (!f)
return kFALSE;
393 Info(
"CmdCloseFiles",
"Close all opened files");
397 TFolder *files_fold =
dynamic_cast<TFolder *
>(
main->FindObject(
"Files"));
400 main->Remove(files_fold);
492 if (!objname || (*objname == 0)) {
504 SendStatusMessage(2, kTRUE, TString::Format(
"Could not clear object %s", objname));
519 if (!objname || (*objname == 0)) {
529 SendStatusMessage(2, kTRUE, TString::Format(
"Could not delete object %s", objname));
538 if (!exeline || (*exeline == 0))
return kFALSE;
547 return errcode != 0 ? kFALSE : kTRUE;
556 if (!title || (strlen(title) == 0))
return;
558 const char *prev = GetItemField(
"/Status/DebugOutput",
"value");
560 if (prev && (strcmp(prev,
"---") != 0)) res = prev;
561 if (res.Length() > 50000) res.Remove(0, res.Length() - 25000);
562 res.Append(
"\n"); res.Append(title);
564 SetItemField(
"/Status/DebugOutput",
"value", res);
566 const char *cur = title;
568 const char *next = strchr(cur,
'\n');
589 tm0.Set(1995,1,1,0,0,0,0,kTRUE,0);
592 fEventRate->GetXaxis()->SetTimeFormat(
"%H:%M:%S");
594 fEventRate->GetHistogram()->SetDirectory(
nullptr);
599 const char *prev = GetItemField(
"/Status/Message",
"value");
601 if (prev && (strcmp(prev,
"---") != 0)) res = prev;
602 res.Append(
"\n"); res.Append(msg);
604 SetItemField(
"/Status/Message",
"value",res);
608 fStatusMessages.AddMsg(TString::UItoa(now.Convert(kFALSE), 10) +
":" + TString::Itoa(level,10) +
":" + msg);
638 Bool_t res = ana->
AddHistogram(
dynamic_cast<TH1 *
>(obj));
643 SendStatusMessage(1, kFALSE, TString::Format(
"Added new object %s to Go4 folders.", obj->GetName()));
645 SendStatusMessage(3, kFALSE, TString::Format(
"ERROR on adding new object %s ", obj->GetName()));
653 const char *treename,
663 if (!histoname || (*histoname == 0)) histoname =
"hTreeDraw";
666 SendStatusMessage(1,kTRUE, TString::Format(
"Added Dynamic histogram %s for tree %s.", histoname, treename));
668 SendStatusMessage(2,kTRUE, TString::Format(
"Could not add Dynamic histogram %s for tree %s.", histoname, treename));
675 TObject *obj = FindTObjectInHierarchy(itemname);
677 TH1 *h1 =
dynamic_cast<TH1 *
> (obj);
688 return IsA()->GetMethodAllAny(
"Restrict") !=
nullptr;
693 return IsA()->GetMethodAllAny(
"ProduceMulti") !=
nullptr;
702 TString call_args = TString::Format(
"\"%s\",\"%s\"", path, options);
704 TMethodCall call(IsA(),
"Restrict", call_args.Data());
711 return IsA()->GetMethodAllAny(
"SetAutoLoad") !=
nullptr;
718 TString call_args = TString::Format(
"\"%s\"", script);
720 TMethodCall call(IsA(),
"SetAutoLoad", call_args.Data());
int main(int argc, char **argv)
void Stop() override
General stop method of slave application to be called from remote command; should be re-implemented b...
void Start() override
General start method of slave application to be called from remote command; should be re-implemented ...
void Quit() override
Quit this instance and the owned task; method to be called from command object, may be overridden in ...
This object is responsible for the organization of analysis objects.
static const char * GetTREEFOLDER()
static const char * GetHISTFOLDER()
static const char * GetUSRFOLDER()
TFolder * GetObjectFolder()
Access to top folder of all objects.
static const char * GetPICTFOLDER()
static const char * GetANALYSISFOLDER()
static const char * GetPARAFOLDER()
static const char * GetCANVFOLDER()
static const char * GetEVENTFOLDER()
static const char * GetCONDFOLDER()
The mother of all go4 analysis.
void UpdateStatus(TGo4AnalysisStatus *state)
Create a copy of the analysis internal state.
static TGo4Analysis * Instance()
return analysis instance
TGo4AnalysisObjectManager * ObjectManager() const
Returns pointer on analysis object manager.
virtual void CloseAnalysis()
Finish the analysis run and close all event sources/storages.
Int_t PostLoop()
Method executed once after the main analysis event loop.
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=nullptr)
Puts a new analysis condition object in corresponding list.
virtual Bool_t InitEventClasses()
Initialization of the event class plugins which are delivered from the user defined event factory.
Bool_t AddDynamicEntry(TGo4DynamicEntry *entry)
Set dynamic entry of name "name" to the values specified by external dynamic entry status "state".
TGo4AnalysisWebStatus * CreateWebStatus()
Create a copy of the analysis internal state.
void StartAnalysis()
(Re)Start analysis event loop, works in both batch and gui-controlled mode
Bool_t ClearObjects(const char *name)
Clear (reset) the specified objects.
void StopAnalysis()
Stop analysis event loop, works in both batch and gui-controlled mode.
void SetSniffer(TGo4AnalysisSniffer *sniff)
Set pointer on sniffer object.
Long64_t ExecuteLine(const char *command, Int_t *errcode=nullptr)
Process ROOT command line.
void StopWorking()
Called by interrupt routine for normal exit from program (in batch mode)
Bool_t AddHistogram(TH1 *his, const char *subfolder=nullptr, Bool_t replace=kTRUE)
Add external histogram to go4 histogram directory.
Bool_t AddTreeHistogram(const char *hisname, const char *treename, const char *varexp, const char *cutexp)
Add Histogram into the dynamic list which is linked to a tree.
Bool_t DeleteObjects(const char *name)
Delete object of name, or all objects in folder name, respectively.
Int_t PreLoop()
Method executed once before the main analysis event loop.
TGo4AnalysisClient * GetAnalysisClient() const
Returns pointer on analysis client.
void SendMessageToGUI(Int_t level, Bool_t printout, const char *text)
Send message string in a status object to the gui.
ABC for all entries that can be kept in a dynamic list.
Runtime status of a histogram object.
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Display a message.
static const char * GO4SYS()
Return GO4SYS environment variable or Go4 top directory during compile (if GO4SYS) not set.
static void SetSniffer(TNamed *sniff)
Class containing event counter and ratemeter services.
void ScanRoot(TRootSnifferScanRec &rec) override
static THttpServer * GetHttpServer()
Bool_t AddAnalysisObject(TObject *obj)
TObject * CreateItemStatus(const char *itemname)
void SetTitle(const char *title="") override
Method called by logger with every string, going to output.
static Bool_t CreateEngine(const char *name)
void StatusMessage(int level, Bool_t printout, const TString &) override
Method from analysis sniffer.
Bool_t HasRestrictMethod()
Indicate that Restrict method implemented, also commands with arguments are exists.
void RatemeterUpdate(TGo4Ratemeter *) override
Method from analysis sniffer.
Bool_t CmdClearObject(const char *objname)
Bool_t CmdDeleteObject(const char *objname)
Bool_t SetAutoLoadGo4(const char *script)
Wrapper for new method in TRootSniffer.
void ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj) override
static THttpServer * gHttpServer
Bool_t CmdOpenFile(const char *fname)
Bool_t RemoteTreeDraw(const char *histoname, const char *treename, const char *varexpr, const char *cutexpr)
TGo4Ratemeter * fRatemeter
void * FindInHierarchy(const char *path, TClass **cl=nullptr, TDataMember **member=nullptr, Int_t *chld=nullptr) override
void ProcessSnifferEvents() override
Method called in go4 analysis thread, used to executed server commands.
TGo4Sniffer(const char *name)
TGo4AnalysisWebStatus * fAnalysisStatus
Bool_t HasProduceMultiMethod()
Indicate that sniffer has MultiProcess method implemented, can be used from GUI.
TGo4MsgList fStatusMessages
Bool_t HasAutoLoadMethod()
Indicate if SetAutoLoad method exists.
Bool_t fbPythonBound
if true, python binding of go4 has already been done.
Bool_t CmdExecute(const char *exeline)
void RestrictGo4(const char *path, const char *options)
Wrapper for new method in TRootSniffer.
virtual void SendStatusMessage(Int_t level, Bool_t printout, const TString &text)
Send message to gui - need to be implemented.