GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Sniffer.cxx
Go to the documentation of this file.
1 // $Id: TGo4Sniffer.cxx 3487 2022-01-21 13:48:44Z 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  fEventRate->GetYaxis()->SetTitle("Events/s");
113  fEventRate->GetHistogram()->SetDirectory(0);
114 
115  RegisterObject("/Status", fEventRate);
116 
117  RegisterObject("/Status", fRatemeter);
118  SetItemField("/Status/Ratemeter", "_hidden", "true");
119  SetItemField("/Status/Ratemeter", "_status", "GO4.DrawAnalysisRatemeter");
120 
121  RegisterCommand("/Control/CmdClear", "this->CmdClear();", "button;go4sys/icons/clear.png");
122  SetItemField("/Control/CmdClear", "_title", "Clear histograms and conditions in analysis");
123  SetItemField("/Control/CmdClear", "_hidden", "true");
124 
125  RegisterCommand("/Control/CmdStart", "this->CmdStart();", "button;go4sys/icons/start.png");
126  SetItemField("/Control/CmdStart", "_title", "Start analysis");
127  SetItemField("/Control/CmdStart", "_hidden", "true");
128 
129  RegisterCommand("/Control/CmdStop", "this->CmdStop();", "button;go4sys/icons/Stop.png");
130  SetItemField("/Control/CmdStop", "_title", "Stop analysis");
131  SetItemField("/Control/CmdStop", "_hidden", "true");
132 
133  RegisterCommand("/Control/CmdClose", "this->CmdClose();", "");
134  SetItemField("/Control/CmdClose", "_title", "Close analysis");
135  SetItemField("/Control/CmdClose", "_hidden", "true");
136 
137  RegisterCommand("/Control/CmdRestart", "this->CmdRestart();", "button;go4sys/icons/restart.png");
138  SetItemField("/Control/CmdRestart", "_title", "Resubmit analysis configuration and start again");
139  SetItemField("/Control/CmdRestart", "_hidden", "true");
140 
141  RegisterCommand("/Control/CmdExit", "this->CmdExit();", "");
142  SetItemField("/Control/CmdExit", "_title", "Exit analysis process");
143  SetItemField("/Control/CmdExit", "_hidden", "true");
144 
145  if (HasRestrictMethod()) {
146  // together with Restrict method support of
147  // commands with arguments was introduced
148 
149  RegisterCommand("/Control/CmdOpenFile", "this->CmdOpenFile(\"%arg1%\");", "button;go4sys/icons/fileopen.png");
150  SetItemField("/Control/CmdOpenFile", "_title", "Open ROOT file in analysis");
151  SetItemField("/Control/CmdOpenFile", "_hreload", "true"); // after execution hierarchy will be reloaded
152  //SetItemField("/Control/CmdOpenFile", "_hidden", "true");
153 
154  RegisterCommand("/Control/CmdCloseFiles", "this->CmdCloseFiles();", "go4sys/icons/fileclose.png");
155  SetItemField("/Control/CmdCloseFiles", "_title", "Close all opened files");
156  SetItemField("/Control/CmdCloseFiles", "_hreload", "true"); // after execution hierarchy will be reloaded
157  //SetItemField("/Control/CmdCloseFiles", "_hidden", "true");
158 
159  RegisterCommand("/Control/CmdClearObject", "this->CmdClearObject(\"%arg1%\");", "");
160  SetItemField("/Control/CmdClearObject", "_title", "Clear object content");
161  SetItemField("/Control/CmdClearObject", "_hidden", "true");
162 
163  RegisterCommand("/Control/CmdDeleteObject", "this->CmdDeleteObject(\"%arg1%\");", "");
164  SetItemField("/Control/CmdDeleteObject", "_title", "Delete object from analysis");
165  SetItemField("/Control/CmdDeleteObject", "_hidden", "true");
166 
167  RegisterCommand("/Control/CmdExecute", "this->CmdExecute(\"%arg1%\");", "go4sys/icons/macro_t.png");
168  SetItemField("/Control/CmdExecute", "_title", "Execute interpreter line in the analysis context. '@' means 'TGo4Analysis::Instance()->' ; A leading '$' invokes python skript.");
169  //SetItemField("/Control/CmdExecute", "_hidden", "true");
170  }
171 
172  RegisterObject("/Control", fAnalysisStatus);
173  if (!HasAutoLoadMethod()) {
174  SetItemField("/Control/Analysis", "_prereq", "jq");
175  SetItemField("/Control/Analysis", "_autoload", "go4sys/html/go4.js");
176  }
177  SetItemField("/Control/Analysis", "_icon", "go4sys/icons/control.png");
178  SetItemField("/Control/Analysis", "_not_monitor", "true");
179 
180  RegisterObject("/Control", this);
181  SetItemField("/Control/go4_sniffer", "_hidden", "true");
182 
183  CreateItem("/Control/Terminal", "Analysis terminal");
184  SetItemField("/Control/Terminal", "_icon", "go4sys/icons/analysiswin.png");
185  SetItemField("/Control/Terminal", "_player", "GO4.drawAnalysisTerminal");
186 
187  RestrictGo4("/Control","visible=controller,admin");
188 
189  RestrictGo4("/Control/CmdExit","visible=admin");
190 
191  RestrictGo4("/Conditions", "allow=controller,admin");
192 
193  RestrictGo4("/Parameters", "allow=controller,admin&allow_method=CreateStatus");
194 
195  // set at the end when other items exists
196  if (!HasAutoLoadMethod()) {
197  SetItemField("/", "_prereq", "jq");
198  SetItemField("/", "_autoload", "go4sys/html/go4.js");
199  }
200  SetItemField("/", "_icon", "go4sys/icons/go4logo2_small.png");
201  SetItemField("/", "_title", "GO4 analysis");
202  SetItemField("/", "_analysis_name", TGo4Analysis::Instance()->GetName());
203  if (HasRestrictMethod())
204  SetItemField("/", "_has_restrict", "true");
205 
206  if (HasProduceMultiMethod())
207  SetItemField("/", "_has_produce_multi", "true");
208 
209  if (TGo4Analysis::Instance()!=0)
211 
212  TGo4Log::SetSniffer(this);
213 
214  if (!HasRestrictMethod()) {
215  // this was problem with original ROOT sniffer, it does not construct classes
216  // and class required in exe.bin
217  gROOT->GetClass("TGo4ParameterStatus", kTRUE, kTRUE);
218  gROOT->GetClass("TGo4EventElement", kTRUE, kTRUE);
219  gROOT->GetClass("TGo4CompositeEvent", kTRUE, kTRUE);
220  gROOT->GetClass("TGo4AnalysisStatus", kTRUE, kTRUE);
221  gROOT->GetClass("TGo4AnalysisWebStatus", kTRUE, kTRUE);
222  }
223 }
224 
226 {
227  if (TGo4Analysis::Instance()!=0)
229 
231 }
232 
233 void TGo4Sniffer::ScanRoot(TRootSnifferScanRec& rec)
234 {
235  rec.SetField("_toptitle", "Go4 http server");
236 
237  SniffBaseClass::ScanRoot(rec);
238 
240 
241  if (om==0) return;
242 
243  //TGo4LockGuard mainlock; // JAM now done in top level invocation ProcessEvents
244 
245  TFolder* main = om->GetObjectFolder();
246 
247  TFolder* hist_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetHISTFOLDER()));
248  TFolder* par_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetPARAFOLDER()));
249  TFolder* cond_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetCONDFOLDER()));
250  TFolder* pic_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetPICTFOLDER()));
251  TFolder* tree_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetTREEFOLDER()));
252  TFolder* canv_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetCANVFOLDER()));
253  TFolder* anal_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetANALYSISFOLDER()));
254  TFolder* even_fold = dynamic_cast<TFolder*> (anal_fold->FindObject(TGo4AnalysisObjectManager::GetEVENTFOLDER()));
255  TFolder* user_fold = dynamic_cast<TFolder*> (main->FindObject(TGo4AnalysisObjectManager::GetUSRFOLDER()));
256  TFolder* files_fold = dynamic_cast<TFolder*> (main->FindObject("Files"));
257 
258  ScanCollection(rec, hist_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetHISTFOLDER());
259  ScanCollection(rec, par_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetPARAFOLDER());
260  ScanCollection(rec, cond_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetCONDFOLDER());
261  ScanCollection(rec, pic_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetPICTFOLDER());
262  ScanCollection(rec, tree_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetTREEFOLDER());
263  ScanCollection(rec, canv_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetCANVFOLDER());
264  ScanCollection(rec, even_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetEVENTFOLDER());
265  ScanCollection(rec, user_fold->GetListOfFolders(), TGo4AnalysisObjectManager::GetUSRFOLDER());
266  if (files_fold)
267  ScanCollection(rec, files_fold->GetListOfFolders(), "Files");
268 }
269 
270 void TGo4Sniffer::ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj)
271 {
272  SniffBaseClass::ScanObjectProperties(rec, obj);
273 
274  if (obj && obj->TestBit(TGo4Status::kGo4CanDelete)) {
275  rec.SetField("_can_delete", "true");
276  }
277 
278  if (obj && obj->TestBit(TGo4Status::kGo4NoReset)) {
279  rec.SetField("_no_reset", "true");
280  }
281 
282  if (obj && obj->InheritsFrom(TGo4Parameter::Class())) {
283  if (!HasAutoLoadMethod()) {
284  rec.SetField("_prereq", "jq");
285  rec.SetField("_autoload", "go4sys/html/go4.js");
286  }
287  rec.SetField("_drawfunc", "GO4.drawParameter");
288  rec.SetField("_drawscript", "go4sys/html/pareditor.js");
289  rec.SetField("_drawopt", "editor");
290  rec.SetField("_icon", "go4sys/icons/parameter.png");
291  return;
292  }
293 
294  if (obj && obj->InheritsFrom(TGo4Condition::Class())) {
295  if (!HasAutoLoadMethod()) {
296  rec.SetField("_prereq", "jq");
297  rec.SetField("_autoload", "go4sys/html/go4.js");
298  }
299  rec.SetField("_icon", "go4sys/icons/condedit.png");
300  return;
301  }
302 
303  if (obj && obj->InheritsFrom(TGo4EventElement::Class())) {
304  rec.SetField("_more", "true");
305  rec.SetField("_go4event", "true");
306  rec.SetField("_icon", "go4sys/icons/eventobj.png");
307  return;
308  }
309 }
310 
311 void* TGo4Sniffer::FindInHierarchy(const char *path, TClass **cl, TDataMember **member, Int_t *chld)
312 {
313  if ((path!=0) && (strcmp(path,"Status/Analysis")==0)) {
315  if (cl) *cl = fAnalysisStatus->IsA();
316  return fAnalysisStatus;
317  }
318 
319  return SniffBaseClass::FindInHierarchy(path, cl, member, chld);
320 }
321 
322 
324 {
326  if (an) {
327  an->StartAnalysis();
328  StatusMessage(0, kTRUE, "Resume analysis loop");
329  }
330 
331  return kTRUE;
332 }
333 
335 {
337  if (an) {
338  an->StopAnalysis();
339  StatusMessage(0, kTRUE, "Suspend analysis loop");
340  }
341 
342  return kTRUE;
343 }
344 
345 Bool_t TGo4Sniffer::CmdOpenFile(const char* fname)
346 {
347  Info("CmdOpenFile", "Open ROOT file %s", fname);
348 
350 
351  if (om) {
352  TFolder* main = om->GetObjectFolder();
353 
354  TFolder* files_fold = dynamic_cast<TFolder*> (main->FindObject("Files"));
355  if (files_fold == 0) {
356  files_fold = main->AddFolder("Files","ROOT files");
357  files_fold->SetOwner(kTRUE);
358  }
359 
360  TFile* f = dynamic_cast<TFile*> (files_fold->FindObject(fname));
361  if (f!=0) { files_fold->Remove(f); delete f; }
362 
363  f = TFile::Open(fname);
364  if (f==0) return kFALSE;
365 
366  files_fold->Add(f);
367  }
368 
369  return kTRUE;
370 }
371 
373 {
374  Info("CmdCloseFiles", "Close all opened files");
376  if (om) {
377  TFolder* main = om->GetObjectFolder();
378  TFolder* files_fold = dynamic_cast<TFolder*> (main->FindObject("Files"));
379  if (files_fold) {
380  files_fold->Clear();
381  main->Remove(files_fold);
382  delete files_fold;
383  }
384  }
385  return kTRUE;
386 }
387 
388 
390 {
392  if (an) {
393  an->ClearObjects("Histograms");
394  an->ClearObjects("Conditions");
395  an->SendMessageToGUI(1, kTRUE, "Clear Histograms and Conditions folder");
396  }
397  return kTRUE;
398 }
399 
401 {
403  TGo4AnalysisClient* cli = an ? an->GetAnalysisClient() : 0;
404 
405  if (cli != 0) {
406  cli->Stop();
407  an->CloseAnalysis();
408  if (an->InitEventClasses())
409  cli->Start();
410  }
411  else if (an) {
412  an->StopAnalysis();
413  an->PostLoop();
414  an->CloseAnalysis();
415  if (an->InitEventClasses()) {
416  an->PreLoop();
417  an->StartAnalysis();
418  }
419  }
420 
421  StatusMessage(0, kTRUE, "Restart analysis loop");
422 
423  return kTRUE;
424 }
425 
427 {
429  TGo4AnalysisClient* cli = an ? an->GetAnalysisClient() : 0;
430 
431  if (cli != 0) {
432  cli->Stop();
433  an->CloseAnalysis();
434  }
435  else if (an) {
436  an->StopAnalysis();
437  an->PostLoop();
438  an->CloseAnalysis();
439  }
440 
441  StatusMessage(0, kTRUE, "Close analysis");
442 
443  return kTRUE;
444 }
445 
446 
448 {
450  TGo4AnalysisClient* cli = an ? an->GetAnalysisClient() : 0;
451 
452  if (cli != 0) {
453  cli->Stop();
454  an->CloseAnalysis();
455  cli->Quit();
456  } else
457  if (an != 0) {
458  an->StopWorking();
459  }
460 
461  StatusMessage(0, kTRUE, "Exit analysis process");
462 
463  return kTRUE;
464 
465 }
466 
467 
468 Bool_t TGo4Sniffer::CmdClearObject(const char* objname)
469 {
471 
472  if(ana==0) {
473  SendStatusMessage(3, kTRUE,"CmdClearObject - analysis missing");
474  return kFALSE;
475  }
476 
477  if ((objname==0) || (*objname==0)) {
478  ana->ClearObjects("Histograms");
479  ana->ClearObjects("Conditions");
480  SendStatusMessage(1, kTRUE, "Histograms and conditions were cleared");
481  return kTRUE;
482  }
483 
484  Bool_t ok = ana->ClearObjects(objname);
485 
486  if(ok) {
487  SendStatusMessage(1, kTRUE, TString::Format("Object %s was cleared.", objname));
488  } else {
489  SendStatusMessage(2, kTRUE, TString::Format("Could not clear object %s", objname));
490  } // if(ob)
491 
492  return ok;
493 }
494 
495 Bool_t TGo4Sniffer::CmdDeleteObject(const char* objname)
496 {
498 
499  if(ana==0) {
500  SendStatusMessage(3, kTRUE,"CmdDeleteObject - missing analysis ");
501  return kFALSE;
502  }
503 
504  if ((objname==0) || (*objname==0)) {
505  SendStatusMessage(1, kTRUE, "Object name in CmdDeleteObject not specified");
506  return kFALSE;
507  }
508 
509  Bool_t ok = ana->DeleteObjects(objname);
510 
511  if(ok) {
512  SendStatusMessage(1, kTRUE, TString::Format("Object %s was deleted", objname));
513  } else {
514  SendStatusMessage(2, kTRUE, TString::Format("Could not delete object %s", objname));
515  } // if(ob)
516 
517  return ok;
518 }
519 
520 
521 Bool_t TGo4Sniffer::CmdExecute(const char* exeline)
522 {
523  if ((exeline==0) || (*exeline==0)) return kFALSE;
525  if(ana==0) {
526  SendStatusMessage(3, kTRUE,"CmdExecute - missing analysis ");
527  return kFALSE;
528  }
529  Int_t errcode=0;
530  ana->ExecuteLine(exeline, &errcode);
531  fflush(stdout);
532  return errcode!=0 ? kFALSE : kTRUE;
533 
534 }
535 
536 
537 
538 void TGo4Sniffer::SetTitle(const char* title)
539 {
540  // Method called by logger with every string, going to output
541 
542  if ((title==0) || (strlen(title)==0)) return;
543 
544  const char* prev = GetItemField("/Status/DebugOutput", "value");
545  TString res;
546  if (prev && (strcmp(prev,"---")!=0)) res = prev;
547  if (res.Length() > 50000) res.Remove(0, res.Length() - 25000);
548  res.Append("\n"); res.Append(title);
549 
550  SetItemField("/Status/DebugOutput","value", res);
551 
552  const char *cur = title;
553  while (*cur != 0) {
554  const char* next = strchr(cur, '\n');
555  if (next==0) {
556  fDebugOutput.AddMsg(cur);
557  break;
558  }
559  fDebugOutput.AddMsg(TString(cur, next-cur));
560  cur = next+1;
561  }
562 }
563 
565 {
567 
568  Int_t n = fEventRate->GetN();
569  if (n == 100) {
570  fEventRate->RemovePoint(0);
571  n--;
572  }
573 
574  TTimeStamp tm, tm0;
575  tm0.Set(1995,1,1,0,0,0,0,kTRUE,0);
576  fEventRate->SetPoint(n, tm.AsDouble() - tm0.AsDouble(), r->GetRate());
577  fEventRate->GetXaxis()->SetTimeDisplay(1);
578  fEventRate->GetXaxis()->SetTimeFormat("%H:%M:%S");
579  fEventRate->GetYaxis()->SetTitle("Events/s");
580  fEventRate->GetHistogram()->SetDirectory(0);
581 }
582 
583 void TGo4Sniffer::StatusMessage(int level, Bool_t, 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) {
619  SendStatusMessage(3, kFALSE, "Analysis not exists to set object");
620  delete obj;
621  return kFALSE;
622  }
623 
624  Bool_t res = ana->AddHistogram(dynamic_cast<TH1*>(obj));
625  if (!res) res = ana->AddAnalysisCondition(dynamic_cast<TGo4Condition*>(obj));
626  if (!res) res = ana->AddDynamicEntry(dynamic_cast<TGo4DynamicEntry*>(obj));
627 
628  if(res) {
629  SendStatusMessage(1, kFALSE, TString::Format("Added new object %s to Go4 folders.", obj->GetName()));
630  } else {
631  SendStatusMessage(3, kFALSE, TString::Format("ERROR on adding new object %s ", obj->GetName()));
632  delete obj;
633  }
634 
635  return kTRUE;
636 }
637 
638 Bool_t TGo4Sniffer::RemoteTreeDraw(const char* histoname,
639  const char* treename,
640  const char* varexpr,
641  const char* cutexpr)
642 {
644  if (ana==0) {
645  SendStatusMessage(3, kTRUE, "No analysis in RemoteTreeDraw");
646  return kFALSE;
647  }
648 
649  if ((histoname==0) || (*histoname==0)) histoname = "hTreeDraw";
650  Bool_t res = ana->AddTreeHistogram(histoname, treename, varexpr, cutexpr);
651  if(res)
652  SendStatusMessage(1,kTRUE, TString::Format("Added Dynamic histogram %s for tree %s.", histoname, treename));
653  else
654  SendStatusMessage(2,kTRUE, TString::Format("Could not add Dynamic histogram %s for tree %s.", histoname, treename));
655 
656  return res;
657 }
658 
659 TObject* TGo4Sniffer::CreateItemStatus(const char* itemname)
660 {
661  TObject *obj = FindTObjectInHierarchy(itemname);
662 
663  TH1* h1 = dynamic_cast<TH1*> (obj);
664 
665  // printf("CreateItemStatus %s h1 = %p\n", itemname, h1);
666 
667  if (h1!=0) return new TGo4HistogramStatus(h1);
668 
669  return 0;
670 }
671 
673 {
674  return IsA()->GetMethodAllAny("Restrict") != 0;
675 }
676 
678 {
679  return IsA()->GetMethodAllAny("ProduceMulti") != 0;
680 }
681 
682 void TGo4Sniffer::RestrictGo4(const char* path, const char* options)
683 {
684  // wrapper for TRootSnifferFull::Restrict, called only when method exists
685 
686  if (!HasRestrictMethod()) return;
687 
688  TString call_args = TString::Format("\"%s\",\"%s\"", path, options);
689 
690  TMethodCall call(IsA(), "Restrict", call_args.Data());
691 
692  call.Execute(this);
693 }
694 
696 {
697  return IsA()->GetMethodAllAny("SetAutoLoad") != 0;
698 }
699 
700 Bool_t TGo4Sniffer::SetAutoLoadGo4(const char* script)
701 {
702  if (!HasAutoLoadMethod()) return kFALSE;
703 
704  TString call_args = TString::Format("\"%s\"", script);
705 
706  TMethodCall call(IsA(), "SetAutoLoad", call_args.Data());
707 
708  call.Execute(this);
709 
710  return kTRUE;
711 }
712 
713 
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:152
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:207
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:157
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()