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