GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Sniffer.cxx
Go to the documentation of this file.
1 // $Id: TGo4Sniffer.cxx 3048 2021-03-12 10:02:24Z linev $
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"
33 #include "TGo4AnalysisClientImp.h"
34 #include "TGo4Log.h"
35 #include "TGo4Parameter.h"
36 #include "TGo4Condition.h"
37 #include "TGo4AnalysisWebStatus.h"
38 #include "TGo4EventElement.h"
39 #include "TGo4Ratemeter.h"
40 #include "TGo4DynamicEntry.h"
41 
42 THttpServer* TGo4Sniffer::gHttpServer = 0;
43 
44 Bool_t TGo4Sniffer::CreateEngine(const char* args)
45 {
46  if (gHttpServer == 0) {
47  gHttpServer = new THttpServer("");
48 
49  gHttpServer->SetSniffer(new TGo4Sniffer("go4_sniffer"));
50 
51  gHttpServer->SetTimer(0); // we disable timer - go4 will call ProcessRequests method itself
52 
53  gHttpServer->AddLocation("go4sys/", TGo4Log::GO4SYS());
54 
55  TBufferJSON::SetFloatFormat("%15.9e");
56  }
57 
58  if (strstr(args, "jsroot:")==args) {
59  gHttpServer->SetJSROOT(args+7);
60  return kTRUE;
61  }
62 
63  return gHttpServer->CreateEngine(args);
64 }
65 
66 
67 TGo4Sniffer::TGo4Sniffer(const char* name) :
68  SniffBaseClass(name),
70  fAnalysisStatus(0),
71  fEventRate(0),
72  fRatemeter(0),
73  fDebugOutput("Log","Analysis log messages", 1000),
74  fStatusMessages("Msg","Analysis status messages", 100),
75  fbPythonBound(kFALSE)
76 {
77  SetReadOnly(kFALSE);
78  SetScanGlobalDir(kFALSE);
79 
80  SetAutoLoadGo4("jq;go4sys/html/go4.js");
81 
83 
84  fAnalysisStatus->SetName("Analysis");
85 
86  RegisterObject("/Status", &fDebugOutput);
87  RegisterObject("/Status", &fStatusMessages);
88 
89  if (!HasProduceMultiMethod()) {
90  // new multi.json method was implemented together with requests pre and post processing
91  SetItemField("/Status/Log", "_hidden", "true");
92  SetItemField("/Status/Msg", "_hidden", "true");
93 
94  CreateItem("/Status/Message", "Last message from analysis");
95  SetItemField("/Status/Message", "_kind","Text");
96  SetItemField("/Status/Message", "value","---");
97 
98  CreateItem("/Status/DebugOutput", "Go4 debug output");
99  SetItemField("/Status/DebugOutput", "_kind","Text");
100  SetItemField("/Status/DebugOutput", "value","---");
101  }
102 
103  fRatemeter = new TGo4Ratemeter();
104  fRatemeter->SetName("Ratemeter");
105  fRatemeter->SetTitle("Analysis rates");
106 
107  fEventRate = new TGraph();
108  fEventRate->SetName("EventsRate");
109  fEventRate->SetTitle("Events processing rate");
110  fEventRate->GetXaxis()->SetTimeDisplay(1);
111  fEventRate->GetXaxis()->SetTimeFormat("%H:%M:%S");
112 
113  RegisterObject("/Status", fEventRate);
114 
115  RegisterObject("/Status", fRatemeter);
116  SetItemField("/Status/Ratemeter", "_hidden", "true");
117  SetItemField("/Status/Ratemeter", "_status", "GO4.DrawAnalysisRatemeter");
118 
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");
122 
123  RegisterCommand("/Control/CmdStart", "this->CmdStart();", "button;go4sys/icons/start.png");
124  SetItemField("/Control/CmdStart", "_title", "Start analysis");
125  SetItemField("/Control/CmdStart", "_hidden", "true");
126 
127  RegisterCommand("/Control/CmdStop", "this->CmdStop();", "button;go4sys/icons/Stop.png");
128  SetItemField("/Control/CmdStop", "_title", "Stop analysis");
129  SetItemField("/Control/CmdStop", "_hidden", "true");
130 
131  RegisterCommand("/Control/CmdClose", "this->CmdClose();", "");
132  SetItemField("/Control/CmdClose", "_title", "Close analysis");
133  SetItemField("/Control/CmdClose", "_hidden", "true");
134 
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");
138 
139  RegisterCommand("/Control/CmdExit", "this->CmdExit();", "");
140  SetItemField("/Control/CmdExit", "_title", "Exit analysis process");
141  SetItemField("/Control/CmdExit", "_hidden", "true");
142 
143  if (HasRestrictMethod()) {
144  // together with Restrict method support of
145  // commands with arguments was introduced
146 
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"); // after execution hierarchy will be reloaded
150  //SetItemField("/Control/CmdOpenFile", "_hidden", "true");
151 
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"); // after execution hierarchy will be reloaded
155  //SetItemField("/Control/CmdCloseFiles", "_hidden", "true");
156 
157  RegisterCommand("/Control/CmdClearObject", "this->CmdClearObject(\"%arg1%\");", "");
158  SetItemField("/Control/CmdClearObject", "_title", "Clear object content");
159  SetItemField("/Control/CmdClearObject", "_hidden", "true");
160 
161  RegisterCommand("/Control/CmdDeleteObject", "this->CmdDeleteObject(\"%arg1%\");", "");
162  SetItemField("/Control/CmdDeleteObject", "_title", "Delete object from analysis");
163  SetItemField("/Control/CmdDeleteObject", "_hidden", "true");
164 
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.");
167  //SetItemField("/Control/CmdExecute", "_hidden", "true");
168  }
169 
170  RegisterObject("/Control", fAnalysisStatus);
171  if (!HasAutoLoadMethod()) {
172  SetItemField("/Control/Analysis", "_prereq", "jq");
173  SetItemField("/Control/Analysis", "_autoload", "go4sys/html/go4.js");
174  }
175  SetItemField("/Control/Analysis", "_icon", "go4sys/icons/control.png");
176  SetItemField("/Control/Analysis", "_not_monitor", "true");
177 
178  RegisterObject("/Control", this);
179  SetItemField("/Control/go4_sniffer", "_hidden", "true");
180 
181  CreateItem("/Control/Terminal", "Analysis terminal");
182  SetItemField("/Control/Terminal", "_icon", "go4sys/icons/analysiswin.png");
183  SetItemField("/Control/Terminal", "_player", "GO4.drawAnalysisTerminal");
184 
185  RestrictGo4("/Control","visible=controller,admin");
186 
187  RestrictGo4("/Control/CmdExit","visible=admin");
188 
189  RestrictGo4("/Conditions", "allow=controller,admin");
190 
191  RestrictGo4("/Parameters", "allow=controller,admin&allow_method=CreateStatus");
192 
193  // set at the end when other items exists
194  if (!HasAutoLoadMethod()) {
195  SetItemField("/", "_prereq", "jq");
196  SetItemField("/", "_autoload", "go4sys/html/go4.js");
197  }
198  SetItemField("/", "_icon", "go4sys/icons/go4logo2_small.png");
199  SetItemField("/", "_title", "GO4 analysis");
200  SetItemField("/", "_analysis_name", TGo4Analysis::Instance()->GetName());
201  if (HasRestrictMethod())
202  SetItemField("/", "_has_restrict", "true");
203 
204  if (HasProduceMultiMethod())
205  SetItemField("/", "_has_produce_multi", "true");
206 
207  if (TGo4Analysis::Instance()!=0)
209 
210  TGo4Log::SetSniffer(this);
211 
212  if (!HasRestrictMethod()) {
213  // this was problem with original ROOT sniffer, it does not construct classes
214  // and class required in exe.bin
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);
220  }
221 }
222 
224 {
225  if (TGo4Analysis::Instance()!=0)
227 
229 }
230 
231 void TGo4Sniffer::ScanRoot(TRootSnifferScanRec& rec)
232 {
233  rec.SetField("_toptitle", "Go4 http server");
234 
235  SniffBaseClass::ScanRoot(rec);
236 
238 
239  if (om==0) return;
240 
241  //TGo4LockGuard mainlock; // JAM now done in top level invocation ProcessEvents
242 
243  TFolder* main = om->GetObjectFolder();
244 
245  TFolder* hist_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetHISTFOLDER()));
246  TFolder* par_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetPARAFOLDER()));
247  TFolder* cond_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetCONDFOLDER()));
248  TFolder* pic_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetPICTFOLDER()));
249  TFolder* tree_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetTREEFOLDER()));
250  TFolder* canv_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetCANVFOLDER()));
251  TFolder* anal_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetANALYSISFOLDER()));
252  TFolder* even_fold = dynamic_cast<TFolder*> (anal_fold->FindObject(TGo4AnalysisObjectManager::GetEVENTFOLDER()));
253  TFolder* user_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetUSRFOLDER()));
254  TFolder* files_fold = dynamic_cast<TFolder*> (main->FindObject("Files"));
255 
256  ScanCollection(rec, hist_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetHISTFOLDER());
257  ScanCollection(rec, par_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetPARAFOLDER());
258  ScanCollection(rec, cond_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetCONDFOLDER());
259  ScanCollection(rec, pic_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetPICTFOLDER());
260  ScanCollection(rec, tree_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetTREEFOLDER());
261  ScanCollection(rec, canv_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetCANVFOLDER());
262  ScanCollection(rec, even_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetEVENTFOLDER());
263  ScanCollection(rec, user_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetUSRFOLDER());
264  if (files_fold)
265  ScanCollection(rec, files_fold->GetListOfFolders(), "Files");
266 }
267 
268 void TGo4Sniffer::ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj)
269 {
270  SniffBaseClass::ScanObjectProperties(rec, obj);
271 
272  if (obj && obj->TestBit(TGo4Status::kGo4CanDelete)) {
273  rec.SetField("_can_delete", "true");
274  }
275 
276  if (obj && obj->TestBit(TGo4Status::kGo4NoReset)) {
277  rec.SetField("_no_reset", "true");
278  }
279 
280  if (obj && obj->InheritsFrom(TGo4Parameter::Class())) {
281  if (!HasAutoLoadMethod()) {
282  rec.SetField("_prereq", "jq");
283  rec.SetField("_autoload", "go4sys/html/go4.js");
284  }
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");
289  return;
290  }
291 
292  if (obj && obj->InheritsFrom(TGo4Condition::Class())) {
293  if (!HasAutoLoadMethod()) {
294  rec.SetField("_prereq", "jq");
295  rec.SetField("_autoload", "go4sys/html/go4.js");
296  }
297  rec.SetField("_icon", "go4sys/icons/condedit.png");
298  return;
299  }
300 
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");
305  return;
306  }
307 }
308 
309 void* TGo4Sniffer::FindInHierarchy(const char *path, TClass **cl, TDataMember **member, Int_t *chld)
310 {
311  if ((path!=0) && (strcmp(path,"Status/Analysis")==0)) {
313  if (cl) *cl = fAnalysisStatus->IsA();
314  return fAnalysisStatus;
315  }
316 
317  return SniffBaseClass::FindInHierarchy(path, cl, member, chld);
318 }
319 
320 
322 {
324  if (an) {
325  an->StartAnalysis();
326  StatusMessage(0, kTRUE, "Resume analysis loop");
327  }
328 
329  return kTRUE;
330 }
331 
333 {
335  if (an) {
336  an->StopAnalysis();
337  StatusMessage(0, kTRUE, "Suspend analysis loop");
338  }
339 
340  return kTRUE;
341 }
342 
343 Bool_t TGo4Sniffer::CmdOpenFile(const char* fname)
344 {
345  Info("CmdOpenFile", "Open ROOT file %s", fname);
346 
348 
349  if (om) {
350  TFolder* main = om->GetObjectFolder();
351 
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);
356  }
357 
358  TFile* f = dynamic_cast<TFile*> (files_fold->FindObject(fname));
359  if (f!=0) { files_fold->Remove(f); delete f; }
360 
361  f = TFile::Open(fname);
362  if (f==0) return kFALSE;
363 
364  files_fold->Add(f);
365  }
366 
367  return kTRUE;
368 }
369 
371 {
372  Info("CmdCloseFiles", "Close all opened files");
374  if (om) {
375  TFolder* main = om->GetObjectFolder();
376  TFolder* files_fold = dynamic_cast<TFolder*> (main->FindObject("Files"));
377  if (files_fold) {
378  files_fold->Clear();
379  main->Remove(files_fold);
380  delete files_fold;
381  }
382  }
383  return kTRUE;
384 }
385 
386 
388 {
390  if (an) {
391  an->ClearObjects("Histograms");
392  an->ClearObjects("Conditions");
393  an->SendMessageToGUI(1, kTRUE, "Clear Histograms and Conditions folder");
394  }
395  return kTRUE;
396 }
397 
399 {
401  TGo4AnalysisClient* cli = an ? an->GetAnalysisClient() : 0;
402 
403  if (cli != 0) {
404  cli->Stop();
405  an->CloseAnalysis();
406  if (an->InitEventClasses())
407  cli->Start();
408  }
409  else if (an) {
410  an->StopAnalysis();
411  an->PostLoop();
412  an->CloseAnalysis();
413  if (an->InitEventClasses()) {
414  an->PreLoop();
415  an->StartAnalysis();
416  }
417  }
418 
419  StatusMessage(0, kTRUE, "Restart analysis loop");
420 
421  return kTRUE;
422 }
423 
425 {
427  TGo4AnalysisClient* cli = an ? an->GetAnalysisClient() : 0;
428 
429  if (cli != 0) {
430  cli->Stop();
431  an->CloseAnalysis();
432  }
433  else if (an) {
434  an->StopAnalysis();
435  an->PostLoop();
436  an->CloseAnalysis();
437  }
438 
439  StatusMessage(0, kTRUE, "Close analysis");
440 
441  return kTRUE;
442 }
443 
444 
446 {
448  TGo4AnalysisClient* cli = an ? an->GetAnalysisClient() : 0;
449 
450  if (cli != 0) {
451  cli->Stop();
452  an->CloseAnalysis();
453  cli->Quit();
454  } else
455  if (an != 0) {
456  an->StopWorking();
457  }
458 
459  StatusMessage(0, kTRUE, "Exit analysis process");
460 
461  return kTRUE;
462 
463 }
464 
465 
466 Bool_t TGo4Sniffer::CmdClearObject(const char* objname)
467 {
469 
470  if(ana==0) {
471  SendStatusMessage(3, kTRUE,"CmdClearObject - analysis missing");
472  return kFALSE;
473  }
474 
475  if ((objname==0) || (*objname==0)) {
476  ana->ClearObjects("Histograms");
477  ana->ClearObjects("Conditions");
478  SendStatusMessage(1, kTRUE, "Histograms and conditions were cleared");
479  return kTRUE;
480  }
481 
482  Bool_t ok = ana->ClearObjects(objname);
483 
484  if(ok) {
485  SendStatusMessage(1, kTRUE, TString::Format("Object %s was cleared.", objname));
486  } else {
487  SendStatusMessage(2, kTRUE, TString::Format("Could not clear object %s", objname));
488  } // if(ob)
489 
490  return ok;
491 }
492 
493 Bool_t TGo4Sniffer::CmdDeleteObject(const char* objname)
494 {
496 
497  if(ana==0) {
498  SendStatusMessage(3, kTRUE,"CmdDeleteObject - missing analysis ");
499  return kFALSE;
500  }
501 
502  if ((objname==0) || (*objname==0)) {
503  SendStatusMessage(1, kTRUE, "Object name in CmdDeleteObject not specified");
504  return kFALSE;
505  }
506 
507  Bool_t ok = ana->DeleteObjects(objname);
508 
509  if(ok) {
510  SendStatusMessage(1, kTRUE, TString::Format("Object %s was deleted", objname));
511  } else {
512  SendStatusMessage(2, kTRUE, TString::Format("Could not delete object %s", objname));
513  } // if(ob)
514 
515  return ok;
516 }
517 
518 
519 Bool_t TGo4Sniffer::CmdExecute(const char* exeline)
520 {
521  if ((exeline==0) || (*exeline==0)) return kFALSE;
523  if(ana==0) {
524  SendStatusMessage(3, kTRUE,"CmdExecute - missing analysis ");
525  return kFALSE;
526  }
527  Int_t errcode=0;
528  ana->ExecuteLine(exeline, &errcode);
529  fflush(stdout);
530  return errcode!=0 ? kFALSE : kTRUE;
531 
532 }
533 
534 
535 
536 void TGo4Sniffer::SetTitle(const char* title)
537 {
538  // Method called by logger with every string, going to output
539 
540  if ((title==0) || (strlen(title)==0)) return;
541 
542  const char* prev = GetItemField("/Status/DebugOutput", "value");
543  TString res;
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);
547 
548  SetItemField("/Status/DebugOutput","value", res);
549 
550  const char *cur = title;
551  while (*cur != 0) {
552  const char* next = strchr(cur, '\n');
553  if (next==0) {
554  fDebugOutput.AddMsg(cur);
555  break;
556  }
557  fDebugOutput.AddMsg(TString(cur, next-cur));
558  cur = next+1;
559  }
560 }
561 
563 {
565 
566  Int_t n = fEventRate->GetN();
567  if (n == 100) {
568  fEventRate->RemovePoint(0);
569  n--;
570  }
571 
572  TTimeStamp tm, tm0;
573  tm0.Set(1995,1,1,0,0,0,0,kTRUE,0);
574  fEventRate->SetPoint(n, tm.AsDouble() - tm0.AsDouble(), r->GetRate());
575  fEventRate->GetXaxis()->SetTimeDisplay(1);
576  fEventRate->GetXaxis()->SetTimeFormat("%H:%M:%S");
577  fEventRate->GetYaxis()->SetTitle("Events/s");
578 }
579 
580 void TGo4Sniffer::StatusMessage(int level, Bool_t printout, const TString &msg)
581 {
582  const char* prev = GetItemField("/Status/Message", "value");
583  TString res;
584  if (prev && (strcmp(prev,"---")!=0)) res = prev;
585  res.Append("\n"); res.Append(msg);
586 
587  SetItemField("/Status/Message","value",res);
588 
589  TDatime now;
590 
591  fStatusMessages.AddMsg(TString::UItoa(now.Convert(kFALSE), 10) + ":" + TString::Itoa(level,10) + ":" + msg);
592 
593  // add status message to the log
594  // if (printout) SetTitle(msg.Data());
595 }
596 
598 {
599  // Method called from the thread, where go4 analysis executed
600 
601  if (gHttpServer) gHttpServer->ProcessRequests();
602 }
603 
604 void TGo4Sniffer::SendStatusMessage(Int_t level, Bool_t printout, const TString& text)
605 {
606  if (printout)
607  TGo4Log::Message(level, text.Data());
608 
609  // to be done
610 }
611 
612 Bool_t TGo4Sniffer::AddAnalysisObject(TObject* obj)
613 {
615  if (!ana) {
616  SendStatusMessage(3, kFALSE, "Analysis not exists to set object");
617  delete obj;
618  return kFALSE;
619  }
620 
621  Bool_t res = ana->AddHistogram(dynamic_cast<TH1*>(obj));
622  if (!res) res = ana->AddAnalysisCondition(dynamic_cast<TGo4Condition*>(obj));
623  if (!res) res = ana->AddDynamicEntry(dynamic_cast<TGo4DynamicEntry*>(obj));
624 
625  if(res) {
626  SendStatusMessage(1, kFALSE, TString::Format("Added new object %s to Go4 folders.", obj->GetName()));
627  } else {
628  SendStatusMessage(3, kFALSE, TString::Format("ERROR on adding new object %s ", obj->GetName()));
629  delete obj;
630  }
631 
632  return kTRUE;
633 }
634 
635 Bool_t TGo4Sniffer::RemoteTreeDraw(const char* histoname,
636  const char* treename,
637  const char* varexpr,
638  const char* cutexpr)
639 {
641  if (ana==0) {
642  SendStatusMessage(3, kTRUE, "No analysis in RemoteTreeDraw");
643  return kFALSE;
644  }
645 
646  if ((histoname==0) || (*histoname==0)) histoname = "hTreeDraw";
647  Bool_t res = ana->AddTreeHistogram(histoname, treename, varexpr, cutexpr);
648  if(res)
649  SendStatusMessage(1,kTRUE, TString::Format("Added Dynamic histogram %s for tree %s.", histoname, treename));
650  else
651  SendStatusMessage(2,kTRUE, TString::Format("Could not add Dynamic histogram %s for tree %s.", histoname, treename));
652 
653  return res;
654 }
655 
656 TObject* TGo4Sniffer::CreateItemStatus(const char* itemname)
657 {
658  TObject *obj = FindTObjectInHierarchy(itemname);
659 
660  TH1* h1 = dynamic_cast<TH1*> (obj);
661 
662  // printf("CreateItemStatus %s h1 = %p\n", itemname, h1);
663 
664  if (h1!=0) return new TGo4HistogramStatus(h1);
665 
666  return 0;
667 }
668 
670 {
671  return IsA()->GetMethodAllAny("Restrict") != 0;
672 }
673 
675 {
676  return IsA()->GetMethodAllAny("ProduceMulti") != 0;
677 }
678 
679 void TGo4Sniffer::RestrictGo4(const char* path, const char* options)
680 {
681  // wrapper for TRootSnifferFull::Restrict, called only when method exists
682 
683  if (!HasRestrictMethod()) return;
684 
685  TString call_args = TString::Format("\"%s\",\"%s\"", path, options);
686 
687  TMethodCall call(IsA(), "Restrict", call_args.Data());
688 
689  call.Execute(this);
690 }
691 
693 {
694  return IsA()->GetMethodAllAny("SetAutoLoad") != 0;
695 }
696 
697 Bool_t TGo4Sniffer::SetAutoLoadGo4(const char* script)
698 {
699  if (!HasAutoLoadMethod()) return kFALSE;
700 
701  TString call_args = TString::Format("\"%s\"", script);
702 
703  TMethodCall call(IsA(), "SetAutoLoad", call_args.Data());
704 
705  call.Execute(this);
706 
707  return kTRUE;
708 }
709 
710 
Bool_t AddTreeHistogram(const char *hisname, const char *treename, const char *varexp, const char *cutexp)
TGo4MsgList fDebugOutput
Definition: TGo4Sniffer.h:45
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)
Bool_t CmdCloseFiles()
TGo4MsgList fStatusMessages
Definition: TGo4Sniffer.h:47
void UpdateStatus(TGo4AnalysisStatus *state)
virtual void StatusMessage(int level, Bool_t printout, const TString &)
Bool_t CmdExecute(const char *exeline)
virtual void CloseAnalysis()
Bool_t CmdRestart()
virtual void ProcessSnifferEvents()
Bool_t CmdExit()
TGo4AnalysisWebStatus * fAnalysisStatus
Definition: TGo4Sniffer.h:39
TRootSniffer SniffBaseClass
Definition: TGo4Sniffer.h:22
void SendMessageToGUI(Int_t level, Bool_t printout, const char *text)
void SetSniffer(TGo4AnalysisSniffer *sniff)
Bool_t HasProduceMultiMethod()
Bool_t CmdStop()
Bool_t RemoteTreeDraw(const char *histoname, const char *treename, const char *varexpr, const char *cutexpr)
TGo4AnalysisClient * GetAnalysisClient() const
Bool_t CmdClose()
virtual void ScanRoot(TRootSnifferScanRec &rec)
int main(int argc, char **argv)
static void SetSniffer(TNamed *sniff)
Definition: TGo4Log.cxx:153
TGo4Sniffer(const char *name)
Definition: TGo4Sniffer.cxx:67
Bool_t AddHistogram(TH1 *his, const char *subfolder=0, Bool_t replace=kTRUE)
virtual void SetTitle(const char *title="")
static THttpServer * gHttpServer
Definition: TGo4Sniffer.h:72
virtual ~TGo4Sniffer()
Double_t GetRate() const
Definition: TGo4Ratemeter.h:50
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,...)
Definition: TGo4Log.cxx:209
Bool_t ClearObjects(const char *name)
Bool_t CmdClear()
TGo4AnalysisObjectManager * ObjectManager() const
virtual void ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj)
virtual Bool_t InitEventClasses()
Bool_t CmdClearObject(const char *objname)
virtual void SendStatusMessage(Int_t level, Bool_t printout, const TString &text)
void AddMsg(const char *msg)
Definition: TGo4MsgList.cxx:50
TObject * CreateItemStatus(const char *itemname)
static Bool_t CreateEngine(const char *name)
Definition: TGo4Sniffer.cxx:44
Long_t ExecuteLine(const char *command, Int_t *errcode=0)
virtual void RatemeterUpdate(TGo4Ratemeter *)
Bool_t SetAutoLoadGo4(const char *script)
Bool_t CmdStart()
TGo4Ratemeter * fRatemeter
Definition: TGo4Sniffer.h:43
static const char * GetANALYSISFOLDER()
Bool_t AddDynamicEntry(TGo4DynamicEntry *entry)
static const char * GO4SYS()
Definition: TGo4Log.cxx:158
Bool_t CmdDeleteObject(const char *objname)
static TGo4Analysis * Instance()
Bool_t AddAnalysisObject(TObject *obj)
TGo4AnalysisWebStatus * CreateWebStatus()
void RestrictGo4(const char *path, const char *options)
TGraph * fEventRate
Definition: TGo4Sniffer.h:41
string msg
Definition: go4init.py:11
Bool_t HasAutoLoadMethod()