GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4Sniffer.cxx
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
14#include "TGo4Sniffer.h"
15
16#include <cstring>
17
18#include "TClass.h"
19#include "TFolder.h"
20#include "THttpServer.h"
21#include "TBufferJSON.h"
22#include "TGraph.h"
23#include "TDatime.h"
24#include "TTimeStamp.h"
25#include "TROOT.h"
26#include "TH1F.h"
27#include "TFile.h"
28#include "TMethodCall.h"
29#include "TGo4HistogramStatus.h"
30
31#include "TGo4AnalysisImp.h"
34#include "TGo4Log.h"
35#include "TGo4Parameter.h"
36#include "TGo4Condition.h"
38#include "TGo4EventElement.h"
39#include "TGo4Ratemeter.h"
40#include "TGo4DynamicEntry.h"
41#include "TGo4MsgList.h"
42
43THttpServer *TGo4Sniffer::gHttpServer = nullptr;
44
46{
47 return gHttpServer;
48}
49
50
51
52Bool_t TGo4Sniffer::CreateEngine(const char *args)
53{
54 if (!gHttpServer) {
55 gHttpServer = new THttpServer("");
56
57 gHttpServer->SetSniffer(new TGo4Sniffer("go4_sniffer"));
58
59 gHttpServer->SetTimer(0); // we disable timer - go4 will call ProcessRequests method itself
60
61 gHttpServer->AddLocation("go4sys/", TGo4Log::GO4SYS());
62
63 TBufferJSON::SetFloatFormat("%15.9e");
64 }
65
66 if (strstr(args, "jsroot:") == args) {
67 gHttpServer->SetJSROOT(args+7);
68 return kTRUE;
69 }
70
71 return gHttpServer->CreateEngine(args);
72}
73
74
75TGo4Sniffer::TGo4Sniffer(const char *name) :
76 TRootSnifferFull(name),
78 fDebugOutput("Log","Analysis log messages", 1000),
79 fStatusMessages("Msg","Analysis status messages", 100),
80 fbPythonBound(kFALSE)
81{
82 SetReadOnly(kFALSE);
83 SetScanGlobalDir(kFALSE);
84
85 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,33,0)
86 fAutoLoadArg = "go4sys/html5/go4.mjs";
87 #else
88 fAutoLoadArg = "jq;go4sys/html/go4.js";
89 #endif
90
92
94
95 fAnalysisStatus->SetName("Analysis");
96
97 RegisterObject("/Status", &fDebugOutput);
98 RegisterObject("/Status", &fStatusMessages);
99
100 if (!HasProduceMultiMethod()) {
101 // new multi.json method was implemented together with requests pre and post processing
102 SetItemField("/Status/Log", "_hidden", "true");
103 SetItemField("/Status/Msg", "_hidden", "true");
104
105 CreateItem("/Status/Message", "Last message from analysis");
106 SetItemField("/Status/Message", "_kind","Text");
107 SetItemField("/Status/Message", "value","---");
108
109 CreateItem("/Status/DebugOutput", "Go4 debug output");
110 SetItemField("/Status/DebugOutput", "_kind","Text");
111 SetItemField("/Status/DebugOutput", "value","---");
112 }
113
115 fRatemeter->SetName("Ratemeter");
116 fRatemeter->SetTitle("Analysis rates");
117
118 fEventRate = new TGraph();
119 fEventRate->SetName("EventsRate");
120 fEventRate->SetTitle("Events processing rate");
121 fEventRate->GetXaxis()->SetTimeDisplay(1);
122 fEventRate->GetXaxis()->SetTimeFormat("%H:%M:%S");
123 fEventRate->GetYaxis()->SetTitle("Events/s");
124 fEventRate->GetHistogram()->SetDirectory(nullptr);
125
126 RegisterObject("/Status", fEventRate);
127
128 RegisterObject("/Status", fRatemeter);
129 SetItemField("/Status/Ratemeter", "_hidden", "true");
130 SetItemField("/Status/Ratemeter", "_status", "GO4.DrawAnalysisRatemeter");
131
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");
135
136 RegisterCommand("/Control/CmdStart", "this->CmdStart();", "button;go4sys/icons/start.png");
137 SetItemField("/Control/CmdStart", "_title", "Start analysis");
138 SetItemField("/Control/CmdStart", "_hidden", "true");
139
140 RegisterCommand("/Control/CmdStop", "this->CmdStop();", "button;go4sys/icons/Stop.png");
141 SetItemField("/Control/CmdStop", "_title", "Stop analysis");
142 SetItemField("/Control/CmdStop", "_hidden", "true");
143
144 RegisterCommand("/Control/CmdClose", "this->CmdClose();", "");
145 SetItemField("/Control/CmdClose", "_title", "Close analysis");
146 SetItemField("/Control/CmdClose", "_hidden", "true");
147
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");
151
152 RegisterCommand("/Control/CmdExit", "this->CmdExit();", "");
153 SetItemField("/Control/CmdExit", "_title", "Exit analysis process");
154 SetItemField("/Control/CmdExit", "_hidden", "true");
155
156 if (HasRestrictMethod()) {
157 // together with Restrict method support of
158 // commands with arguments was introduced
159
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"); // after execution hierarchy will be reloaded
163 //SetItemField("/Control/CmdOpenFile", "_hidden", "true");
164
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"); // after execution hierarchy will be reloaded
168 //SetItemField("/Control/CmdCloseFiles", "_hidden", "true");
169
170 RegisterCommand("/Control/CmdClearObject", "this->CmdClearObject(\"%arg1%\");", "");
171 SetItemField("/Control/CmdClearObject", "_title", "Clear object content");
172 SetItemField("/Control/CmdClearObject", "_hidden", "true");
173
174 RegisterCommand("/Control/CmdDeleteObject", "this->CmdDeleteObject(\"%arg1%\");", "");
175 SetItemField("/Control/CmdDeleteObject", "_title", "Delete object from analysis");
176 SetItemField("/Control/CmdDeleteObject", "_hidden", "true");
177
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.");
180 //SetItemField("/Control/CmdExecute", "_hidden", "true");
181 }
182
183 RegisterObject("/Control", fAnalysisStatus);
184 if (!HasAutoLoadMethod())
185 SetItemField("/Control/Analysis", "_autoload", fAutoLoadArg);
186 SetItemField("/Control/Analysis", "_icon", "go4sys/icons/control.png");
187 SetItemField("/Control/Analysis", "_not_monitor", "true");
188
189 RegisterObject("/Control", this);
190 SetItemField("/Control/go4_sniffer", "_hidden", "true");
191
192 CreateItem("/Control/Terminal", "Analysis terminal");
193 SetItemField("/Control/Terminal", "_icon", "go4sys/icons/analysiswin.png");
194 SetItemField("/Control/Terminal", "_player", "GO4.drawAnalysisTerminal");
195
196 RestrictGo4("/Control","visible=controller,admin");
197
198 RestrictGo4("/Control/CmdExit","visible=admin");
199
200 RestrictGo4("/Conditions", "allow=controller,admin");
201
202 RestrictGo4("/Parameters", "allow=controller,admin&allow_method=CreateStatus");
203
204 // set at the end when other items exists
205 if (!HasAutoLoadMethod())
206 SetItemField("/", "_autoload", fAutoLoadArg);
207 SetItemField("/", "_icon", "go4sys/icons/go4logo2_small.png");
208 SetItemField("/", "_title", "GO4 analysis");
209 SetItemField("/", "_analysis_name", TGo4Analysis::Instance()->GetName());
210 if (HasRestrictMethod())
211 SetItemField("/", "_has_restrict", "true");
212
214 SetItemField("/", "_has_produce_multi", "true");
215
218
220
221 if (!HasRestrictMethod()) {
222 // this was problem with original ROOT sniffer, it does not construct classes
223 // and class required in exe.bin
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);
229 }
230}
231
239
240void TGo4Sniffer::ScanRoot(TRootSnifferScanRec& rec)
241{
242 rec.SetField("_toptitle", "Go4 http server");
243
244 TRootSnifferFull::ScanRoot(rec);
245
247
248 if (!om) return;
249
250 //TGo4LockGuard mainlock; // JAM now done in top level invocation ProcessEvents
251
252 TFolder *main = om->GetObjectFolder();
253
254 TFolder *hist_fold = dynamic_cast<TFolder *>(main->FindObject(TGo4AnalysisObjectManager::GetHISTFOLDER()));
255 TFolder *par_fold = dynamic_cast<TFolder *>(main->FindObject(TGo4AnalysisObjectManager::GetPARAFOLDER()));
256 TFolder *cond_fold = dynamic_cast<TFolder *>(main->FindObject(TGo4AnalysisObjectManager::GetCONDFOLDER()));
257 TFolder *pic_fold = dynamic_cast<TFolder *>(main->FindObject(TGo4AnalysisObjectManager::GetPICTFOLDER()));
258 TFolder *tree_fold = dynamic_cast<TFolder *>(main->FindObject(TGo4AnalysisObjectManager::GetTREEFOLDER()));
259 TFolder *canv_fold = dynamic_cast<TFolder *>(main->FindObject(TGo4AnalysisObjectManager::GetCANVFOLDER()));
260 TFolder *anal_fold = dynamic_cast<TFolder *>(main->FindObject(TGo4AnalysisObjectManager::GetANALYSISFOLDER()));
261 TFolder *even_fold = dynamic_cast<TFolder *>(anal_fold->FindObject(TGo4AnalysisObjectManager::GetEVENTFOLDER()));
262 TFolder *user_fold = dynamic_cast<TFolder *>(main->FindObject(TGo4AnalysisObjectManager::GetUSRFOLDER()));
263 TFolder *files_fold = dynamic_cast<TFolder *>(main->FindObject("Files"));
264
265 ScanCollection(rec, hist_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetHISTFOLDER());
266 ScanCollection(rec, par_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetPARAFOLDER());
267 ScanCollection(rec, cond_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetCONDFOLDER());
268 ScanCollection(rec, pic_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetPICTFOLDER());
269 ScanCollection(rec, tree_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetTREEFOLDER());
270 ScanCollection(rec, canv_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetCANVFOLDER());
271 ScanCollection(rec, even_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetEVENTFOLDER());
272 ScanCollection(rec, user_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetUSRFOLDER());
273 if (files_fold)
274 ScanCollection(rec, files_fold->GetListOfFolders(), "Files");
275}
276
277void TGo4Sniffer::ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj)
278{
279 TRootSnifferFull::ScanObjectProperties(rec, obj);
280 if (!obj)
281 return;
282
283 if (obj->TestBit(TGo4Status::kGo4CanDelete)) {
284 rec.SetField("_can_delete", "true");
285 }
286
287 if (obj->TestBit(TGo4Status::kGo4NoReset)) {
288 rec.SetField("_no_reset", "true");
289 }
290
291 if (obj->InheritsFrom(TGo4Parameter::Class())) {
292 if (!HasAutoLoadMethod())
293 rec.SetField("_autoload", fAutoLoadArg);
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");
297 #else
298 rec.SetField("_drawscript", "go4sys/html/pareditor.js");
299 #endif
300 rec.SetField("_drawopt", "editor");
301 rec.SetField("_icon", "go4sys/icons/parameter.png");
302 return;
303 }
304
305 if (obj->InheritsFrom(TGo4Condition::Class())) {
306 if (!HasAutoLoadMethod())
307 rec.SetField("_autoload", fAutoLoadArg);
308 rec.SetField("_icon", "go4sys/icons/condedit.png");
309 return;
310 }
311
312 if (obj->InheritsFrom(TGo4EventElement::Class())) {
313 rec.SetField("_more", "true");
314 rec.SetField("_go4event", "true");
315 rec.SetField("_icon", "go4sys/icons/eventobj.png");
316 return;
317 }
318
319 if (obj->InheritsFrom(TGo4MsgList::Class())) {
320 if (!HasAutoLoadMethod())
321 rec.SetField("_autoload", fAutoLoadArg);
322 rec.SetField("_make_request", "GO4.MakeMsgListRequest");
323 rec.SetField("_after_request", "GO4.AfterMsgListRequest");
324 rec.SetField("_icon", "img_text");
325 return;
326 }
327
328}
329
330void *TGo4Sniffer::FindInHierarchy(const char *path, TClass **cl, TDataMember **member, Int_t *chld)
331{
332 if (path && (strcmp(path,"Status/Analysis") == 0)) {
334 if (cl) *cl = fAnalysisStatus->IsA();
335 return fAnalysisStatus;
336 }
337
338 return TRootSnifferFull::FindInHierarchy(path, cl, member, chld);
339}
340
341
343{
345 if (an) {
346 an->StartAnalysis();
347 StatusMessage(0, kTRUE, "Resume analysis loop");
348 }
349
350 return kTRUE;
351}
352
354{
356 if (an) {
357 an->StopAnalysis();
358 StatusMessage(0, kTRUE, "Suspend analysis loop");
359 }
360
361 return kTRUE;
362}
363
364Bool_t TGo4Sniffer::CmdOpenFile(const char *fname)
365{
366 Info("CmdOpenFile", "Open ROOT file %s", fname);
367
369
370 if (om) {
371 TFolder *main = om->GetObjectFolder();
372
373 TFolder *files_fold = dynamic_cast<TFolder *>(main->FindObject("Files"));
374 if (!files_fold) {
375 files_fold = main->AddFolder("Files","ROOT files");
376 files_fold->SetOwner(kTRUE);
377 }
378
379 auto f = dynamic_cast<TFile *> (files_fold->FindObject(fname));
380 if (f) { files_fold->Remove(f); delete f; }
381
382 f = TFile::Open(fname);
383 if (!f) return kFALSE;
384
385 files_fold->Add(f);
386 }
387
388 return kTRUE;
389}
390
392{
393 Info("CmdCloseFiles", "Close all opened files");
395 if (om) {
396 TFolder *main = om->GetObjectFolder();
397 TFolder *files_fold = dynamic_cast<TFolder *>(main->FindObject("Files"));
398 if (files_fold) {
399 files_fold->Clear();
400 main->Remove(files_fold);
401 delete files_fold;
402 }
403 }
404 return kTRUE;
405}
406
407
409{
411 if (an) {
412 an->ClearObjects("Histograms");
413 an->ClearObjects("Conditions");
414 an->SendMessageToGUI(1, kTRUE, "Clear Histograms and Conditions folder");
415 }
416 return kTRUE;
417}
418
420{
422 TGo4AnalysisClient *cli = an ? an->GetAnalysisClient() : nullptr;
423
424 if (cli) {
425 cli->Stop();
426 an->CloseAnalysis();
427 if (an->InitEventClasses())
428 cli->Start();
429 } else if (an) {
430 an->StopAnalysis();
431 an->PostLoop();
432 an->CloseAnalysis();
433 if (an->InitEventClasses()) {
434 an->PreLoop();
435 an->StartAnalysis();
436 }
437 }
438
439 StatusMessage(0, kTRUE, "Restart analysis loop");
440
441 return kTRUE;
442}
443
445{
447 TGo4AnalysisClient *cli = an ? an->GetAnalysisClient() : nullptr;
448
449 if (cli) {
450 cli->Stop();
451 an->CloseAnalysis();
452 } else if (an) {
453 an->StopAnalysis();
454 an->PostLoop();
455 an->CloseAnalysis();
456 }
457
458 StatusMessage(0, kTRUE, "Close analysis");
459
460 return kTRUE;
461}
462
463
465{
467 TGo4AnalysisClient *cli = an ? an->GetAnalysisClient() : nullptr;
468
469 if (cli) {
470 cli->Stop();
471 an->CloseAnalysis();
472 cli->Quit();
473 } else if (an) {
474 an->StopWorking();
475 }
476
477 StatusMessage(0, kTRUE, "Exit analysis process");
478
479 return kTRUE;
480}
481
482
483Bool_t TGo4Sniffer::CmdClearObject(const char *objname)
484{
486
487 if(!ana) {
488 SendStatusMessage(3, kTRUE,"CmdClearObject - analysis missing");
489 return kFALSE;
490 }
491
492 if (!objname || (*objname == 0)) {
493 ana->ClearObjects("Histograms");
494 ana->ClearObjects("Conditions");
495 SendStatusMessage(1, kTRUE, "Histograms and conditions were cleared");
496 return kTRUE;
497 }
498
499 Bool_t ok = ana->ClearObjects(objname);
500
501 if(ok) {
502 SendStatusMessage(1, kTRUE, TString::Format("Object %s was cleared.", objname));
503 } else {
504 SendStatusMessage(2, kTRUE, TString::Format("Could not clear object %s", objname));
505 } // if(ob)
506
507 return ok;
508}
509
510Bool_t TGo4Sniffer::CmdDeleteObject(const char *objname)
511{
513
514 if(!ana) {
515 SendStatusMessage(3, kTRUE,"CmdDeleteObject - missing analysis ");
516 return kFALSE;
517 }
518
519 if (!objname || (*objname == 0)) {
520 SendStatusMessage(1, kTRUE, "Object name in CmdDeleteObject not specified");
521 return kFALSE;
522 }
523
524 Bool_t ok = ana->DeleteObjects(objname);
525
526 if(ok) {
527 SendStatusMessage(1, kTRUE, TString::Format("Object %s was deleted", objname));
528 } else {
529 SendStatusMessage(2, kTRUE, TString::Format("Could not delete object %s", objname));
530 } // if(ob)
531
532 return ok;
533}
534
535
536Bool_t TGo4Sniffer::CmdExecute(const char *exeline)
537{
538 if (!exeline || (*exeline == 0)) return kFALSE;
540 if (!ana) {
541 SendStatusMessage(3, kTRUE, "CmdExecute - missing analysis ");
542 return kFALSE;
543 }
544 Int_t errcode = 0;
545 ana->ExecuteLine(exeline, &errcode);
546 fflush(stdout);
547 return errcode != 0 ? kFALSE : kTRUE;
548}
549
550
551
552void TGo4Sniffer::SetTitle(const char *title)
553{
554 // Method called by logger with every string, going to output
555
556 if (!title || (strlen(title) == 0)) return;
557
558 const char *prev = GetItemField("/Status/DebugOutput", "value");
559 TString res;
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);
563
564 SetItemField("/Status/DebugOutput","value", res);
565
566 const char *cur = title;
567 while (*cur != 0) {
568 const char *next = strchr(cur, '\n');
569 if (!next) {
570 fDebugOutput.AddMsg(cur);
571 break;
572 }
573 fDebugOutput.AddMsg(TString(cur, next-cur));
574 cur = next+1;
575 }
576}
577
579{
580 fRatemeter->UpdateFrom(r);
581
582 Int_t n = fEventRate->GetN();
583 if (n == 100) {
584 fEventRate->RemovePoint(0);
585 n--;
586 }
587
588 TTimeStamp tm, tm0;
589 tm0.Set(1995,1,1,0,0,0,0,kTRUE,0);
590 fEventRate->SetPoint(n, tm.AsDouble() - tm0.AsDouble(), r->GetRate());
591 fEventRate->GetXaxis()->SetTimeDisplay(1);
592 fEventRate->GetXaxis()->SetTimeFormat("%H:%M:%S");
593 fEventRate->GetYaxis()->SetTitle("Events/s");
594 fEventRate->GetHistogram()->SetDirectory(nullptr);
595}
596
597void TGo4Sniffer::StatusMessage(int level, Bool_t, const TString &msg)
598{
599 const char *prev = GetItemField("/Status/Message", "value");
600 TString res;
601 if (prev && (strcmp(prev,"---") != 0)) res = prev;
602 res.Append("\n"); res.Append(msg);
603
604 SetItemField("/Status/Message","value",res);
605
606 TDatime now;
607
608 fStatusMessages.AddMsg(TString::UItoa(now.Convert(kFALSE), 10) + ":" + TString::Itoa(level,10) + ":" + msg);
609
610 // add status message to the log
611 // if (printout) SetTitle(msg.Data());
612}
613
615{
616 // Method called from the thread, where go4 analysis executed
617
618 if (gHttpServer) gHttpServer->ProcessRequests();
619}
620
621void TGo4Sniffer::SendStatusMessage(Int_t level, Bool_t printout, const TString &text)
622{
623 if (printout)
624 TGo4Log::Message(level, "%s", text.Data());
625
626 // to be done
627}
628
630{
632 if (!ana) {
633 SendStatusMessage(3, kFALSE, "Analysis not exists to set object");
634 delete obj;
635 return kFALSE;
636 }
637
638 Bool_t res = ana->AddHistogram(dynamic_cast<TH1 *>(obj));
639 if (!res) res = ana->AddAnalysisCondition(dynamic_cast<TGo4Condition *>(obj));
640 if (!res) res = ana->AddDynamicEntry(dynamic_cast<TGo4DynamicEntry *>(obj));
641
642 if(res) {
643 SendStatusMessage(1, kFALSE, TString::Format("Added new object %s to Go4 folders.", obj->GetName()));
644 } else {
645 SendStatusMessage(3, kFALSE, TString::Format("ERROR on adding new object %s ", obj->GetName()));
646 delete obj;
647 }
648
649 return kTRUE;
650}
651
652Bool_t TGo4Sniffer::RemoteTreeDraw(const char *histoname,
653 const char *treename,
654 const char *varexpr,
655 const char *cutexpr)
656{
658 if (!ana) {
659 SendStatusMessage(3, kTRUE, "No analysis in RemoteTreeDraw");
660 return kFALSE;
661 }
662
663 if (!histoname || (*histoname == 0)) histoname = "hTreeDraw";
664 Bool_t res = ana->AddTreeHistogram(histoname, treename, varexpr, cutexpr);
665 if(res)
666 SendStatusMessage(1,kTRUE, TString::Format("Added Dynamic histogram %s for tree %s.", histoname, treename));
667 else
668 SendStatusMessage(2,kTRUE, TString::Format("Could not add Dynamic histogram %s for tree %s.", histoname, treename));
669
670 return res;
671}
672
673TObject *TGo4Sniffer::CreateItemStatus(const char *itemname)
674{
675 TObject *obj = FindTObjectInHierarchy(itemname);
676
677 TH1 *h1 = dynamic_cast<TH1 *> (obj);
678
679 // printf("CreateItemStatus %s h1 = %p\n", itemname, h1);
680
681 if (h1) return new TGo4HistogramStatus(h1);
682
683 return nullptr;
684}
685
687{
688 return IsA()->GetMethodAllAny("Restrict") != nullptr;
689}
690
692{
693 return IsA()->GetMethodAllAny("ProduceMulti") != nullptr;
694}
695
696void TGo4Sniffer::RestrictGo4(const char *path, const char *options)
697{
698 // wrapper for TRootSnifferFull::Restrict, called only when method exists
699
700 if (!HasRestrictMethod()) return;
701
702 TString call_args = TString::Format("\"%s\",\"%s\"", path, options);
703
704 TMethodCall call(IsA(), "Restrict", call_args.Data());
705
706 call.Execute(this);
707}
708
710{
711 return IsA()->GetMethodAllAny("SetAutoLoad") != nullptr;
712}
713
714Bool_t TGo4Sniffer::SetAutoLoadGo4(const char *script)
715{
716 if (!HasAutoLoadMethod()) return kFALSE;
717
718 TString call_args = TString::Format("\"%s\"", script);
719
720 TMethodCall call(IsA(), "SetAutoLoad", call_args.Data());
721
722 call.Execute(this);
723
724 return kTRUE;
725}
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.
TFolder * GetObjectFolder()
Access to top folder of all objects.
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.
Go4 condition class.
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.
Definition TGo4Log.cxx:206
static const char * GO4SYS()
Return GO4SYS environment variable or Go4 top directory during compile (if GO4SYS) not set.
Definition TGo4Log.cxx:156
static void SetSniffer(TNamed *sniff)
Definition TGo4Log.cxx:151
Class containing event counter and ratemeter services.
Double_t GetRate() const
void ScanRoot(TRootSnifferScanRec &rec) override
static THttpServer * GetHttpServer()
Bool_t CmdStop()
Bool_t AddAnalysisObject(TObject *obj)
Bool_t CmdExit()
TObject * CreateItemStatus(const char *itemname)
TGraph * fEventRate
Definition TGo4Sniffer.h:33
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)
TGo4MsgList fDebugOutput
Definition TGo4Sniffer.h:37
Bool_t SetAutoLoadGo4(const char *script)
Wrapper for new method in TRootSniffer.
void ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj) override
Bool_t CmdCloseFiles()
TString fAutoLoadArg
Definition TGo4Sniffer.h:44
static THttpServer * gHttpServer
Definition TGo4Sniffer.h:66
Bool_t CmdOpenFile(const char *fname)
Bool_t RemoteTreeDraw(const char *histoname, const char *treename, const char *varexpr, const char *cutexpr)
TGo4Ratemeter * fRatemeter
Definition TGo4Sniffer.h:35
void * FindInHierarchy(const char *path, TClass **cl=nullptr, TDataMember **member=nullptr, Int_t *chld=nullptr) override
Bool_t CmdRestart()
void ProcessSnifferEvents() override
Method called in go4 analysis thread, used to executed server commands.
Bool_t CmdStart()
TGo4Sniffer(const char *name)
TGo4AnalysisWebStatus * fAnalysisStatus
Definition TGo4Sniffer.h:31
Bool_t HasProduceMultiMethod()
Indicate that sniffer has MultiProcess method implemented, can be used from GUI.
TGo4MsgList fStatusMessages
Definition TGo4Sniffer.h:39
Bool_t HasAutoLoadMethod()
Indicate if SetAutoLoad method exists.
virtual ~TGo4Sniffer()
Bool_t CmdClear()
Bool_t fbPythonBound
if true, python binding of go4 has already been done.
Definition TGo4Sniffer.h:42
Bool_t CmdClose()
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.