GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4AnalysisImp.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 "TGo4AnalysisImp.h"
15 
16 #include <stdexcept>
17 #include <cstdio>
18 #include <cstdlib>
19 #include <cstring>
20 #include <iostream>
21 #include <vector>
22 #include <fstream>
23 #include <iterator>
24 
25 #include "TSystem.h"
26 #include "TInterpreter.h"
27 #include "TApplication.h"
28 #include "TH1.h"
29 #include "TH2.h"
30 #include "TGraph.h"
31 
32 #include "TTree.h"
33 #include "TFile.h"
34 #include "TKey.h"
35 #include "TThread.h"
36 #include "TMutex.h"
37 #include "TROOT.h"
38 #include "TCutG.h"
39 #include "TStopwatch.h"
40 #include "TTimeStamp.h"
41 
42 #include "TGo4Log.h"
43 #include "TGo4LockGuard.h"
44 #include "TGo4CommandInvoker.h"
45 #include "TGo4Ratemeter.h"
47 #include "TGo4UserException.h"
48 #include "TGo4WinCond.h"
49 #include "TGo4PolyCond.h"
50 #include "TGo4ShapedCond.h"
51 #include "TGo4ListCond.h"
52 #include "TGo4RollingGraph.h"
53 
54 #include "TGo4Version.h"
58 #include "TGo4AnalysisStatus.h"
59 #include "TGo4AnalysisWebStatus.h"
60 #include "TGo4AnalysisStep.h"
61 #include "TGo4AnalysisClientImp.h"
62 #include "TGo4AnalysisSniffer.h"
64 #include "TGo4Condition.h"
65 #include "TGo4Parameter.h"
66 #include "TGo4ObjEnvelope.h"
67 #include "TGo4EventElement.h"
68 #include "TGo4EventProcessor.h"
71 #include "TGo4EventEndException.h"
74 
75 class TGo4InterruptHandler : public TSignalHandler {
76 public:
77  TGo4InterruptHandler() : TSignalHandler(kSigInterrupt, kFALSE) {}
78 
79  Bool_t Notify() override
80  {
83 
84  return kTRUE;
85  }
86 };
87 
88 #ifdef _MSC_VER
89 
90 namespace {
91  void InstallGo4CtrlCHandler(bool on);
92 }
93 
94 #endif
95 
96 
97 // _________________________________________________________________________________
98 
100 Bool_t TGo4Analysis::fbExists = kFALSE;
102 const Int_t TGo4Analysis::fgiAUTOSAVECOUNTS = 500;
103 const Int_t TGo4Analysis::fgiDYNLISTINTERVAL = 1000;
104 const Int_t TGo4Analysis::fgiMACROSTARTPOLL = 1000; //polling time for macro in WaitForStart
105 const char *TGo4Analysis::fgcDEFAULTFILENAME = "Go4AutoSave.root";
106 const char *TGo4Analysis::fgcDEFAULTSTATUSFILENAME = "Go4AnalysisPrefs.root";
107 const char *TGo4Analysis::fgcDEFAULTFILESUF = ".root";
108 
109 const char TGo4Analysis::fgcPYPROMPT = '$';
110 const char *TGo4Analysis::fgcPYINIT = "python/go4init.py";
111 
113 {
114  GO4TRACE((14,"TGo4Analysis::Instance()",__LINE__, __FILE__));
115  if(!fxInstance) {
116  fxInstance = new TGo4Analysis;
117  fbExists = kTRUE;
118  }
119  return fxInstance;
120 }
121 
123 {
124  return fbExists;
125 }
126 
128 {
129  return fiRunningMode == 0;
130 }
131 
133 {
134  return fiRunningMode == 1;
135 }
136 
138 {
139  return fiRunningMode == 2;
140 }
141 
143 {
144  fiRunningMode = mode;
145 }
146 
147 TGo4Analysis::TGo4Analysis(const char *name) :
148  TObject(),TGo4CommandReceiver(),
149  fbInitIsDone(kFALSE),
150  fbAutoSaveOn(kTRUE),
151  fxAnalysisSlave(nullptr),
152  fxStepManager(nullptr),
153  fxObjectManager(nullptr),
154  fiAutoSaveCount(0),
155  fiAutoSaveInterval(TGo4Analysis::fgiAUTOSAVECOUNTS),
156  fiAutoSaveCompression(5),
157  fxAutoFile(nullptr),
158  fbAutoSaveOverwrite(kFALSE),
159  fbNewInputFile(kFALSE),
160  fxCurrentInputFileName(),
161  fbAutoSaveFileChange(kFALSE),
162  fxSampleEvent(nullptr),
163  fxObjectNames(nullptr),
164  fxDoWorkingFlag(flagInit),
165  fxInterruptHandler(nullptr),
166  fAnalysisName(),
167  fBatchLoopCount(-1),
168  fServerAdminPass(),
169  fServerCtrlPass(),
170  fServerObserverPass(),
171  fbMakeWithAutosave(kTRUE),
172  fbObjMade(kFALSE),
173  fbPythonBound(kFALSE),
174  fNumCtrlC(0),
175  fSniffer(nullptr),
176  fxRate(nullptr)
177 {
178  GO4TRACE((15,"TGo4Analysis::TGo4Analysis(const char *)",__LINE__, __FILE__));
179 
180  if (name) SetAnalysisName(name);
181 
182  Constructor();
183 }
184 
185 
186 TGo4Analysis::TGo4Analysis(int argc, char **argv) :
187  TObject(),TGo4CommandReceiver(),
188  fbInitIsDone(kFALSE),
189  fbAutoSaveOn(kTRUE),
190  fxAnalysisSlave(nullptr),
191  fxStepManager(nullptr),
192  fxObjectManager(nullptr),
193  fiAutoSaveCount(0),
196  fxAutoFile(nullptr),
197  fbAutoSaveOverwrite(kFALSE),
198  fbNewInputFile(kFALSE),
200  fbAutoSaveFileChange(kFALSE),
201  fxSampleEvent(nullptr),
202  fxObjectNames(nullptr),
204  fxInterruptHandler(nullptr),
205  fAnalysisName(),
206  fBatchLoopCount(-1),
208  fServerCtrlPass(),
210  fbMakeWithAutosave(kTRUE),
211  fbObjMade(kFALSE),
212  fbPythonBound(kFALSE),
213  fNumCtrlC(0),
214  fSniffer(nullptr),
215  fxRate(nullptr)
216 {
217  GO4TRACE((15,"TGo4Analysis::TGo4Analysis(const char *)",__LINE__, __FILE__));
218 
219  if ((argc > 0) && argv[0]) SetAnalysisName(argv[0]);
220 
221  Constructor();
222 }
223 
225 {
227  // wrong version number between framework and user executable
228  Message(-1,"!!!! Analysis Base class:\n\t User Analysis was built with wrong \t\tGo4 Buildversion %d !!!!!",
229  TGo4Version::Instance()->GetBuildVersion());
230  Message(-1,"\t Please rebuild your analysis with current \tGo4 Buildversion %d ", __GO4BUILDVERSION__);
231  Message(-1,"\t >>make clean all<<");
232  Message(-1,"Aborting in 20 s...");
233  gSystem->Sleep(20000);
234  exit(-1);
235  } else {
236  // may not disable output of version number:
237  Message(-1,"Welcome to Go4 Analysis Framework Release %s (build %d) !", __GO4RELEASE__, __GO4BUILDVERSION__);
238  }
239 
240  if(!fxInstance) {
241  gROOT->SetBatch(kTRUE);
242  fxStepManager = new TGo4AnalysisStepManager("Go4 Analysis Step Manager");
243  fxObjectManager = new TGo4AnalysisObjectManager("Go4 Central Object Manager");
245  fxAutoSaveMutex = new TMutex(kTRUE);
246  fxAutoSaveClock = new TStopwatch;
247  fxAutoSaveClock->Stop();
249  if (fAnalysisName.Length()>0) fxAutoFileName = TString::Format("%sASF.root", fAnalysisName.Data());
251  fxDefaultTestFileName=TString::Format("%s/data/test.lmd",getenv("GO4SYS"));
252 
253  TGo4CommandInvoker::Instance(); // make sure we have an invoker instance!
255  TGo4CommandInvoker::Register("Analysis",this); // register as command receiver at the global invoker
256  fxInstance = this; // for ctor usage from derived user subclass
257  fbExists = kTRUE;
258 
260  fxInterruptHandler->Add();
261 
262 #ifdef _MSC_VER
263  InstallGo4CtrlCHandler(true);
264 #endif
265 
266  } else {
267  // instance already there
268  Message(2,"Analysis BaseClass ctor -- analysis singleton already exists !!!");
269  }
270  // settings for macro execution
271  TInterpreter* theI = gROOT->GetInterpreter();
272  theI->SetProcessLineLock(kTRUE); // mandatory for ROOT > 6.12
273 
274  gROOT->ProcessLineSync("TGo4Analysis *go4 = TGo4Analysis::Instance();");
275  gROOT->ProcessLineSync(TString::Format(".x %s", TGo4Log::subGO4SYS("macros/anamacroinit.C").Data()).Data());
276 }
277 
278 
280 {
281 
282 #ifdef _MSC_VER
283  InstallGo4CtrlCHandler(false);
284 #endif
285 
286  if (fxInterruptHandler) {
287  delete fxInterruptHandler;
288  fxInterruptHandler = nullptr;
289  }
290 
291  GO4TRACE((15,"TGo4Analysis::~TGo4Analysis()",__LINE__, __FILE__));
292  CloseAnalysis();
294  delete fxStepManager;
295  delete fxObjectManager;
296  delete fxObjectNames;
297  delete fxAutoSaveClock;
298  delete fxSampleEvent;
300  fxInstance = nullptr; // reset static singleton instance pointer
301  gROOT->ProcessLineSync(TString::Format(".x %s", TGo4Log::subGO4SYS("macros/anamacroclose.C").Data()).Data());
302 }
303 
304 
306 {
307  switch(fNumCtrlC++) {
308  case 0:
309  StopWorking(); // for batch mode and server mode
310  ShutdownServer(); // only for server mode
311  break;
312  case 1:
313  // if shutdown should hang, we do second try closing the files directly
314  CloseAnalysis();
317  if (gApplication) gApplication->Terminate();
318  break;
319  case 2:
320  default:
321  exit(1); // the hard way if nothing helps
322  break;
323  }
324 }
325 
326 
328 // Initialization and analysis defining methods:
329 
331 {
332  GO4TRACE((14,"TGo4Analysis::InitEventClasses()",__LINE__, __FILE__));
333  //
334  Bool_t rev = kTRUE;
335  if(!fbInitIsDone) {
336  try {
337  TGo4Log::Debug("Analysis -- Initializing EventClasses...");
338  LoadObjects(); // always use autosave file to get last objects list
340  UpdateNamesList();
341  TGo4Log::Info("Analysis -- Initializing EventClasses done.");
342  fbInitIsDone = kTRUE;
343  if (!fxAnalysisSlave) {
346  else if (fxDoWorkingFlag == flagInit)
348  }
349 
350  } catch(TGo4EventErrorException& ex) {
351  Message(ex.GetPriority(), "%s", ex.GetErrMess());
352  rev = kFALSE;
353  }
354  } else
355  TGo4Log::Info("Analysis BaseClass -- EventClasses were already initialized.");
356  return rev;
357 }
358 
360 // main event cycle methods:
361 
363 {
364  GO4TRACE((11,"TGo4Analysis::MainCycle()",__LINE__, __FILE__));
365  if(!fbInitIsDone)
366  throw TGo4UserException(3,"Analysis not yet initialized");
367 
368  {
369  TGo4LockGuard mainlock; // protect analysis, but not status buffer
370 
372 
373  UserEventFunc();
374 
376 
377  if (fbAutoSaveOn && (fiAutoSaveInterval != 0)) {
378  fiAutoSaveCount++;
379  Double_t rt = fxAutoSaveClock->RealTime();
380  if (rt > (Double_t) fiAutoSaveInterval) {
381  Message(0, "Analysis: Main Cycle Autosaving after %.2f s (%d events).",rt,fiAutoSaveCount);
382  AutoSave();
383  fiAutoSaveCount = 0;
384  fxAutoSaveClock->Start(kTRUE);
385  } else
386  fxAutoSaveClock->Continue();
387  }
388 
389  SetNewInputFile(kFALSE); // reset flag of new input file
390 
391  } //TGo4LockGuard main;
392 
393  if(fxAnalysisSlave) {
395  // note: creation of status buffer uses mainlock internally now
396  // status mutex required to be outside main mutex always JA
399  }
400 
401  return 0;
402 }
403 
405 {
406  GO4TRACE((11,"TGo4Analysis::UserEventFunc()",__LINE__, __FILE__));
407  return 0;
408 }
409 
411 {
413 }
414 
416 {
417  GO4TRACE((11,"TGo4Analysis::Process()",__LINE__, __FILE__));
418  Int_t rev = 0;
419 
420  try
421  {
422  ProcessEvents();
423 
424  if(fxAnalysisSlave)
425  {
426  gSystem->ProcessEvents(); // ensure cintlocktimer to give mainlock back
427  //if(!IsRunning()) TGo4Thread::Sleep(200);
428  //TGo4Thread::Sleep(50); // give other threads time to operate
429  }
430  {
431  //TGo4LockGuard mainlock; // moved to MainCycle
432  if(!IsRunning())
433  {
434  rev=-1;
435  }
436  //return -1;
437  else
438  {
439  TDirectory *savdir = gDirectory;
440  gROOT->cd(); // necessary for dynamic list scope
441  MainCycle();
442  savdir->cd();
443  }
444  }
445 
446  }
448  // begin catch block
449  catch(TGo4EventTimeoutException& ex)
450  {
451  {
452  TGo4LockGuard global;
453  ex.Handle(); // display exception on terminal in case of debug
454  }
456  {
457  // only display message if debug output enabled
458  Message(2,"Analysis %s TIMEOUT for eventsource %s:%s.",
459  GetName(), ex.GetSourceClass(), ex.GetSourceName());
460  }
461  //return 0;
462  }
463  catch(TGo4EventEndException& ex)
464  {
465  Message(2,"End of event source %s: name:%s - msg:%s",
466  ex.GetSourceClass(), ex.GetSourceName(), ex.GetErrMess());
467  if(IsErrorStopEnabled()) {
469  //return -1;
470  rev=-1;
471  }
472  //return 0;
473  }
474  catch(TGo4EventErrorException& ex)
475  {
476  //ex.Handle();
477  Int_t prio=ex.GetPriority();
478  if(prio == 0)
479  {
480  // SL:12.2011 even erre display can be skipped, continue without stop
481  // Message(1,"Event source %s: %s - %s",
482  // ex.GetSourceClass(), ex.GetSourceName(),ex.GetErrMess());
483  }
484  else
485  {
486  Message(3,"Analysis %s ERROR: %s from event source %s:\n %s",
487  GetName(),ex.GetErrMess(),
488  ex.GetSourceClass(), ex.GetSourceName());
489  if(IsErrorStopEnabled())
490  {
492  //return -1;
493  rev=-1;
494  }
495  }
496  //return 0;
497  }
498  catch(TGo4EventSourceException& ex)
499  {
500  Message(3,"Event source throws exception: %s",ex.GetErrMess());
501  if(IsErrorStopEnabled()) {
503  rev=-1;
504  }
505  //return 0;
506  }
507 
508  catch(TGo4EventStoreException& ex)
509  {
510  Message(3,"Event store throws exception: %s",ex.GetErrMess());
511  if(IsErrorStopEnabled()) {
513  rev=-1;
514  }
515  //return 0;
516  }
517 
518  catch(TGo4DynamicListException& ex)
519  {
520  {
521  TGo4LockGuard global;
522  ex.Handle();
523  }
524  Message(3,"Analysis %s ERROR: %s from dynamic list entry %s:%s",
525  GetName(),ex.GetStatusMessage(),
526  ex.GetEntryName(), ex.GetEntryClass());
527  if(IsErrorStopEnabled())
528  {
530  //return -1;
531  rev=-1;
532  }
533  //return 0;
534  }
535 
536  catch(TGo4AnalysisStepException& ex)
537  {
538  TGo4LockGuard global;
539  ex.Handle();
540  Message(3,"Analysis %s ERROR: %s in Analysis Step %s",
541  GetName(), ex.GetStatusMessage(), ex.GetStepName());
542  if(IsErrorStopEnabled())
543  {
545  //return -1;
546  rev=-1;
547  }
548  //return 0;
549  }
550 
551  catch(TGo4UserException& ex)
552  {
553  // { TGo4LockGuard global; ex.Handle(); }
554 
555  if(strlen(ex.GetMessage()) != 0)
556  Message(ex.GetPriority(), "%s", ex.GetMessage());
557  if(IsErrorStopEnabled() && (ex.GetPriority() > 2)) {
558  if(fxAnalysisSlave) fxAnalysisSlave->Stop(); // only stop for errors, warnings and infos continue loop!
559  //return -1;
560  rev=-1;
561 
562  }
563  //return 0;
564  }
565 
566  catch(std::exception& ex) // treat standard library exceptions
567  {
568  Message(3,"Analysis %s got standard exception %s", GetName(), ex.what());
569  if(IsErrorStopEnabled()) {
571  //return -1;
572  rev=-1;
573  }
574  //return 0;
575  }
576  // end catch block
578 
579  return rev;
580 }
581 
582 Int_t TGo4Analysis::RunImplicitLoop(Int_t times, Bool_t showrate, Double_t process_event_interval, Bool_t iswebserver)
583 {
584  GO4TRACE((11,"TGo4Analysis::RunImplicitLoop(Int_t)",__LINE__, __FILE__));
585  Int_t cnt = 0; // number of actually processed events
586  Int_t nextcnt = 0; // number of actually processed events
587  if (process_event_interval>1.) process_event_interval = 1.;
588 
589  if (times < 0) times = fBatchLoopCount;
590 
591  fxRate = new TGo4Ratemeter();
592  Bool_t userate = showrate || (process_event_interval > 0.);
593  Bool_t process_events = kFALSE;
594  if (userate)
595  fxRate->SetUpdateInterval(process_event_interval > 0. ? process_event_interval : 1.);
596  if (showrate) fxRate->Reset();
597 
598  TTimeStamp last_update;
599 
600  try
601  {
602  if (times > 0)
603  Message(1, "Analysis loop for %d cycles is starting...", times);
604  else
605  Message(1, "Analysis loop is starting...");
606 
607  while (fxDoWorkingFlag != flagStop) {
608 
609  if ((times > 0) && (cnt >= times)) {
610  if (!iswebserver)
611  break;
612  if (fxDoWorkingFlag == flagRunning) {
613  PostLoop();
615  }
616  }
617 
618  if (userate && fxRate->Update(nextcnt)) {
619 
620  process_events = kTRUE;
621 
622  bool need_update = false;
623  TTimeStamp now;
624  if ((now.AsDouble() - last_update.AsDouble()) >= 1.) {
625  last_update = now; need_update = true;
626  }
627 
628  if (need_update) {
630 
631  TDatime dt;
632  fxRate->SetDateTime(dt.AsSQLString());
633 
634  TGo4AnalysisStep *firststep = GetAnalysisStep(nullptr);
635  if(firststep)
637  else
638  fxRate->SetCurrentSource("- No event source -");
639 
640  if (showrate)
642 
643  if (fSniffer)
645  }
646  }
647 
648  nextcnt = 0;
649 
650  try
651  {
652  if (process_events) {
653  // put events processing in exception-handling area
654  process_events = kFALSE;
655  gSystem->ProcessEvents();
656  ProcessEvents();
657  }
658 
659  if (fxDoWorkingFlag == flagRunning) {
660  MainCycle();
661  cnt++; // account completely executed cycles
662  nextcnt = 1; // we process one event
663  } else {
664  gSystem->Sleep(100);
665  }
666 
667  }
668  catch(TGo4UserException& ex)
669  {
670  if(ex.GetPriority()>2)
671  {
672  PostLoop();
673  if(iswebserver)
674  {
675  fxDoWorkingFlag = flagPause; // errors: stop event loop
676  ex.Handle();
677  }
678  else
679  {
680  throw; // return to shell if not remotely controlled
681  }
682  }
683  else
684  {
685  ex.Handle(); // warnings and infos: continue loop after display message
686  }
687  }
688  catch(TGo4EventEndException& ex)
689  {
690  Message(1,"End of event source %s: name:%s msg:%s",ex.GetSourceClass(), ex.GetSourceName(),ex.GetErrMess());
691  PostLoop();
692  if(iswebserver)
693  {
694  fxDoWorkingFlag = flagPause; // errors: stop event loop
695  ex.Handle();
696  }
697  else
698  {
699  throw; // return to shell if not remotely controlled
700  }
701  }
702 
703  catch(TGo4EventErrorException& ex)
704  {
705  if(ex.GetPriority()>0)
706  {
707  Message(ex.GetPriority(),"%s",ex.GetErrMess());
708  PostLoop();
709  if(iswebserver)
710  {
711  fxDoWorkingFlag = flagPause;// errors: stop event loop
712  ex.Handle();
713  }
714  else
715  {
716  throw; // return to shell if not remotely controlled
717  }
718  }
719  else
720  {
721  // SL:12.2011 even error display can be skipped, continue without stop
722  // Message(1,"Eventsource %s:%s %s",ex.GetSourceClass(),
723  // ex.GetSourceName(),ex.GetErrMess());
724  ex.Handle(); // infos: continue loop after display message
725  }
726  }
727 
728  catch(TGo4EventTimeoutException& ex)
729  {
730  ex.Handle(); // just show timeout message, continue event loop
731  }
732  catch (TGo4EventSourceException& ex)
733  {
734  Message(3, "%s", ex.GetErrMess());
735  PostLoop();
736  if (iswebserver) {
737  fxDoWorkingFlag = flagPause; // errors: stop event loop
738  ex.Handle();
739  }
740  else
741  {
742  throw; // return to shell if not remotely controlled
743  }
744  }
745  catch (TGo4EventStoreException& ex)
746  {
747  Message(3, "%s", ex.GetErrMess());
748  PostLoop();
749  if (iswebserver)
750  {
751  fxDoWorkingFlag = flagPause; // errors: stop event loop
752  ex.Handle();
753  }
754  else
755  {
756  throw; // return to shell if not remotely controlled
757  }
758  }
759  catch(...)
760  {
761  PostLoop(); // make sure that postloop is executed for all exceptions
762  if(iswebserver)
763  {
765  Message(1, "!!! Unexpected exception in %d cycle !!!", cnt);
766  }
767  else
768  {
769  throw;
770  }
771  }
773  }// while loop
774 
775  Message(1, "Analysis implicit Loop has finished after %d cycles.", cnt);
776 
777  // postloop only if analysis not yet closed
779  PostLoop();
780  } // try
781 
782  catch(TGo4Exception &ex) {
783  Message(1, "%s appeared in %d cycle.", ex.What(), cnt);
784  ex.Handle();
785  }
786  catch(std::exception &ex) { // treat standard library exceptions
787  Message(1, "standard exception %s appeared in %d cycle.", ex.what(), cnt);
788  }
789  catch(...) {
790  Message(1, "!!! Unexpected exception in %d cycle !!!", cnt);
791  }
792 
793  if (showrate) {
794  printf("\n"); fflush(stdout);
795  }
796  delete fxRate;
797  fxRate = nullptr;
799  return cnt;
800 }
801 
803 // dynamic list stuff:
804 
805 Bool_t TGo4Analysis::RemoveDynamicEntry(const char *entryname, const char *listname)
806 {
807  GO4TRACE((11,"TGo4Analysis::RemoveDynamicEntry(const char *, const char *)",__LINE__, __FILE__));
808  Bool_t rev=fxObjectManager->RemoveDynamicEntry(entryname);
809  if(rev) UpdateNamesList();
810  return rev;
811 }
812 
814 // status related methods:
815 
817 {
818  GO4TRACE((11,"TGo4Analysis::UpdateStatus(TGo4AnalysisStatus*)",__LINE__, __FILE__));
819  fxStepManager->UpdateStatus(state);
820  if(state) {
825  state->SetAutoSaveOn(fbAutoSaveOn);
826  state->SetConfigFileName(fxConfigFilename.Data());
827  }
828 }
829 
831 {
832  GO4TRACE((11,"TGo4Analysis::SetStatus(TGo4AnalysisStatus*)",__LINE__, __FILE__));
833  if(state) {
834  // first we close down existing analysis:
835  CloseAnalysis();
837  SetAutoSave(state->IsAutoSaveOn());
839  state->IsAutoSaveOverwrite(),
840  state->GetAutoSaveCompression());
841  fxStepManager->SetStatus(state);
842  }
843 }
844 
845 
846 Bool_t TGo4Analysis::LoadStatus(const char *filename)
847 {
848  GO4TRACE((11,"TGo4Analysis::LoadStatus(const char *)",__LINE__, __FILE__));
849  //
850  Bool_t rev = kFALSE;
851  TString fname = filename ? filename : fgcDEFAULTSTATUSFILENAME;
852 
853  // file suffix if not given by user
854  if(!fname.Contains(fgcDEFAULTFILESUF)) fname.Append(fgcDEFAULTFILESUF);
855 
856  TFile *statusfile = TFile::Open(fname.Data(), "READ");
857  if(statusfile && statusfile->IsOpen()) {
858  TGo4AnalysisStatus *state=
859  dynamic_cast<TGo4AnalysisStatus*>(statusfile->Get(GetName()));
860  if (!state) {
861  TIter iter(statusfile->GetListOfKeys());
862  TKey *key = nullptr;
863  while ((key = (TKey *)iter()) != nullptr) {
864  if (strcmp(key->GetClassName(),"TGo4AnalysisStatus") == 0) break;
865  }
866 
867  if (key) state = dynamic_cast<TGo4AnalysisStatus *>(statusfile->Get(key->GetName()));
868  }
869 
870  // name of status object is name of analysis itself
871  if(state) {
872  Message(1,"Analysis %s: Found status object %s in file %s",
873  GetName(), state->GetName(), fname.Data());
874  SetStatus(state);
875  fxConfigFilename = fname; // remember last configuration file name
876  Message(0,"Analysis: New analysis state is set.");
877  rev = kTRUE;
878  } else {
879  Message(3,"Analysis LoadStatus: Could not find status %s in file %s", GetName(), fname.Data());
880  rev = kFALSE;
881  } // if(state)
882  } else {
883  Message(3,"Analysis LoadStatus: Failed to open file %s", fname.Data());
884  rev = kFALSE;
885  } // if(statusfile && statusfile->IsOpen())
886 
887  delete statusfile;
888 
889  return rev;
890 }
891 
892 Bool_t TGo4Analysis::SaveStatus(const char *filename)
893 {
894  GO4TRACE((11,"TGo4Analysis::SaveStatus(const char *)",__LINE__, __FILE__));
895  Bool_t rev = kFALSE;
896  char buffer[1024];
897  memset(buffer, 0, sizeof(buffer));
898  if(filename)
899  strncpy(buffer, filename, sizeof(buffer)-10);
900  else
901  strncpy(buffer,fgcDEFAULTSTATUSFILENAME, sizeof(buffer)-10);
902  if(!strstr(buffer, fgcDEFAULTFILESUF))
903  strncat(buffer, fgcDEFAULTFILESUF, sizeof(buffer)-10); // file suffix if not given by user
904  auto statusfile = TFile::Open(buffer,"RECREATE");
905  if(statusfile && statusfile->IsOpen()) {
906  fxConfigFilename=buffer; // remember name of status
907  statusfile->cd();
908  TGo4AnalysisStatus *state = CreateStatus();
909  if(state) {
910  state->Write();
911  delete state;
912  delete statusfile;
913  rev = kTRUE;
914  Message(-1,"Analysis SaveStatus: Saved Analysis settings to file %s", buffer);
915  } else {
916  Message(3,"Analysis SaveStatus: FAILED to create status object !!!");
917  rev = kFALSE;
918  }
919  } else {
920  Message(3,"Analysis SaveStatus: Failed to open file %s ",
921  buffer);
922  rev = kFALSE;
923  } // if(statusfile && statusfile->IsOpen())
924  return rev;
925 }
926 
928 {
929  GO4TRACE((11,"TGo4Analysis::CreateStatus()",__LINE__, __FILE__));
930  TDirectory *filsav = gDirectory;
931  gROOT->cd();
933  UpdateStatus(state);
934  filsav->cd();
935  return state;
936 }
937 
939 {
940  GO4TRACE((11,"TGo4Analysis::CreateWebStatus()",__LINE__, __FILE__));
941  TDirectory *filsav = gDirectory;
942  gROOT->cd();
944  UpdateStatus(state);
945  filsav->cd();
946  return state;
947 }
948 
949 void TGo4Analysis::Print(Option_t *) const
950 {
951  TGo4Analysis *localthis = const_cast<TGo4Analysis*>(this);
952  TGo4AnalysisStatus *state = localthis->CreateStatus();
953  state->Print();
954  delete state;
955 }
956 
958 {
959  GO4TRACE((11,"TGo4Analysis::CreateSingleEventTree(TGo4EventElement *)",__LINE__, __FILE__));
960 
961  return event ? event->CreateSampleTree(&fxSampleEvent) : nullptr;
962 }
963 
964 TTree *TGo4Analysis::CreateSingleEventTree(const char *name, Bool_t isoutput)
965 {
966  GO4TRACE((11,"TGo4Analysis::CreateSingleEventTree(const char *, Bool_t)",__LINE__, __FILE__));
967  //
968  TGo4EventElement *event = nullptr;
969  if(isoutput) event = GetOutputEvent(name);
970  else event = GetInputEvent(name);
971  if(!event) event = GetEventStructure(name);
972 
973  return CreateSingleEventTree(event);
974 }
975 
977 {
978  GO4TRACE((14,"TGo4Analysis::CloseAnalysis()",__LINE__, __FILE__));
979  //
980  if(fbInitIsDone) {
981  AutoSave();
984  fbInitIsDone = kFALSE;
986  }
987 }
988 
990 {
991  GO4TRACE((11,"TGo4Analysis:PreLoop()",__LINE__, __FILE__));
992  TGo4LockGuard autoguard(fxAutoSaveMutex);
993  // avoid conflict with possible user object modifications during startup autosave!
994  fiAutoSaveCount = 0;
995  Int_t rev = UserPreLoop();
996  for (Int_t num = 0; num < fxStepManager->GetNumberOfAnalysisSteps(); num++) {
998  TGo4EventProcessor *proc = step ? step->GetEventProcessor() : nullptr;
999  if (proc) proc->UserPreLoop();
1000  }
1001 
1002  fxAutoSaveClock->Start(kTRUE);
1003  return rev;
1004 }
1005 
1007 {
1008  GO4TRACE((11,"TGo4Analysis::PostLoop()",__LINE__, __FILE__));
1009  TGo4LockGuard autoguard(fxAutoSaveMutex);
1010  Int_t rev = 0;
1012  // TTree *mytree = CreateSingleEventTree("Unpack");
1013  // auto myfile = TFile::Open("eventsample.root","RECREATE");
1014  // mytree->SetDirectory(myfile);
1015  // mytree->Write();
1016  // delete myfile;
1017  // std::cout <<"___________Wrote eventsample to file eventsample.root" << std::endl;
1019  if(fbInitIsDone) {
1020  for (Int_t num = 0; num < fxStepManager->GetNumberOfAnalysisSteps(); num++) {
1022  TGo4EventProcessor *proc = step ? step->GetEventProcessor() : nullptr;
1023  if (proc) proc->UserPostLoop();
1024  }
1025 
1026  rev = UserPostLoop(); // do not call userpostloop after error in initialization
1027  }
1028  return rev;
1029 }
1030 
1032 {
1033  GO4TRACE((11,"TGo4Analysis::UserPreLoop()",__LINE__, __FILE__));
1034  //
1035  Message(0,"Analysis BaseClass -- executing default User Preloop");
1036  return 0;
1037 }
1038 
1040 {
1041  GO4TRACE((11,"TGo4Analysis::UserPostLoop()",__LINE__, __FILE__));
1042  //
1043  Message(0,"Analysis BaseClass -- executing default User Postloop");
1044  return 0;
1045 }
1046 
1047 void TGo4Analysis::SetAutoSaveFile(const char *filename, Bool_t overwrite, Int_t compression)
1048 {
1049 // if(!fbAutoSaveOn) return; // do not set autosave file if disabled!
1050  //TGo4LockGuard autoguard(fxAutoSaveMutex);
1051  TString buffer;
1052  if(filename) buffer = filename;
1053  else buffer = fgcDEFAULTFILENAME;
1054  if(!buffer.Contains(fgcDEFAULTFILESUF))
1055  buffer.Append(fgcDEFAULTFILESUF); // file suffix if not given by user
1056  // new: just set parameters, do not open file here:
1057  fxAutoFileName = buffer;
1058  fbAutoSaveOverwrite = overwrite;
1059  fiAutoSaveCompression = compression;
1060 }
1061 
1063 {
1064  return fxAutoFileName.Length() > 0;
1065 }
1066 
1068 {
1069  GO4TRACE((12,"TGo4Analysis::LockAutoSave()",__LINE__, __FILE__));
1070  Int_t rev = -1;
1071  if (TThread::Exists()>0 && fxAutoSaveMutex)
1072  rev = fxAutoSaveMutex->Lock();
1073  return rev;
1074 }
1075 
1077 {
1078  GO4TRACE((12,"TGo4Analysis::UnLockAutoSave()",__LINE__, __FILE__));
1079  Int_t rev = -1;
1080  if (TThread::Exists()>0 && fxAutoSaveMutex)
1081  rev = fxAutoSaveMutex->UnLock();
1082 
1083  return rev;
1084 }
1085 
1087 {
1088  GO4TRACE((12,"TGo4Analysis::AutoSave()",__LINE__, __FILE__));
1089 
1090  if(!fbAutoSaveOn) return;
1091  TGo4LockGuard autoguard(fxAutoSaveMutex);
1092  Message(0,"Analysis -- AutoSaving....");
1093  //UpdateNamesList();
1095  OpenAutoSaveFile(true);
1098  Message(0,"Analysis -- AutoSave done.");
1099 }
1100 
1101 void TGo4Analysis::OpenAutoSaveFile(bool for_writing)
1102 {
1103  if(!fbAutoSaveOn) return;
1104  TGo4LockGuard autoguard(fxAutoSaveMutex);
1105  gROOT->cd();
1106  if (for_writing) {
1107  delete fxAutoFile;
1108  fxAutoFile = TFile::Open(fxAutoFileName.Data() ,"RECREATE");
1109  if (!fxAutoFile)
1110  Message(3,"Fail to open AutoSave file %s", fxAutoFileName.Data());
1111  else
1112  Message(-1,"Opening AutoSave file %s with RECREATE mode",fxAutoFileName.Data());
1113  if (fxAutoFile) fxAutoFile->SetCompressionLevel(fiAutoSaveCompression);
1114  } else {
1115  if(!fxAutoFile) {
1116  if (!gSystem->AccessPathName(fxAutoFileName.Data()))
1117  fxAutoFile = TFile::Open(fxAutoFileName.Data(), "READ");
1118  if (!fxAutoFile)
1119  Message(3,"Fail to open AutoSave file %s", fxAutoFileName.Data());
1120  else
1121  Message(-1,"Opening AutoSave file %s with READ mode",fxAutoFileName.Data());
1122 
1123  } else {
1124  Message(-1,"Reusing AutoSave file %s with READ mode",fxAutoFileName.Data());
1125  }
1126  } // if(fbAutoSaveOverwrite)
1127 
1128  gROOT->cd();
1129 }
1130 
1131 
1133 {
1134  if(fxAutoFile) {
1135  TGo4LockGuard autoguard(fxAutoSaveMutex);
1136  delete fxAutoFile;
1137  fxAutoFile = nullptr;
1138  Message(-1,"AutoSave file %s was closed.",fxAutoFileName.Data());
1139  }
1140 }
1141 
1142 
1144 {
1145  GO4TRACE((11,"TGo4Analysis::UpdateNamesList()",__LINE__, __FILE__));
1146  // first try: update all
1147  delete fxObjectNames;
1149  Message(0,"Analysis BaseClass -- Nameslist updated.");
1150 }
1151 
1152 
1153 Bool_t TGo4Analysis::LoadObjects(const char *filename)
1154 {
1155  TGo4LockGuard autoguard(fxAutoSaveMutex);
1156  if(filename) fxAutoFileName = filename;
1157 
1158  if(!fbAutoSaveOn) {
1159  TGo4Log::Info("Analysis LoadObjects: AUTOSAVE file is DISABLED, did NOT read objects back from file %s", fxAutoFileName.Data());
1160  return kFALSE;
1161  }
1162 
1163  if (fbAutoSaveOverwrite) {
1164  TGo4Log::Info("Analysis LoadObjects: AUTOSAVE is in overwrite mode - no objects will be loaded from %s", fxAutoFileName.Data());
1165  return kTRUE;
1166  }
1167 
1168  Bool_t rev = kTRUE;
1169  OpenAutoSaveFile(false);
1170  if(fxAutoFile && fxAutoFile->IsOpen()) {
1171  TGo4Log::Info("Analysis LoadObjects: Loading from autosave file %s ", fxAutoFile->GetName());
1173  } else {
1174  TGo4Log::Info("Analysis LoadObjects: Failed to load from file %s", fxAutoFileName.Data());
1175  rev = kFALSE;
1176  }
1178  gROOT->cd();
1179  return rev;
1180 }
1181 
1182 void TGo4Analysis::Message(Int_t prio, const char *text,...)
1183 {
1184  char txtbuf[TGo4Log::fguMESLEN];
1185  va_list args;
1186  va_start(args, text);
1187  vsnprintf(txtbuf, TGo4Log::fguMESLEN, text, args);
1188  va_end(args);
1189  SendMessageToGUI(prio, kTRUE, txtbuf);
1190 }
1191 
1192 void TGo4Analysis::SendMessageToGUI(Int_t level, Bool_t printout, const char *text)
1193 {
1194  if(fxAnalysisSlave) {
1195  // gui mode: send Text via status channel - also sniffer will be informed
1196  fxAnalysisSlave->SendStatusMessage(level, printout, text);
1197  } else {
1198  // batch mode: no gui connection, handle local printout
1199  Bool_t previousmode = TGo4Log::IsOutputEnabled();
1200  TGo4Log::OutputEnable(printout); // override the messaging state
1201  TGo4Log::Message(level, "%s", text);
1202  TGo4Log::OutputEnable(previousmode);
1203 
1204  if (fSniffer) fSniffer->StatusMessage(level, printout, text);
1205  } // if (fxAnalysisSlave)
1206 
1207 }
1208 
1210 {
1211  if (!ob) return;
1212 
1213  if(!fxAnalysisSlave) {
1214  Message(2,"Could not send object %s to GUI in batch mode.", ob->GetName());
1215  return;
1216  }
1217 
1218  TString pathname;
1219 
1220  if (ObjectManager()->FindObjectPathName(ob, pathname)) {
1221  TGo4ObjEnvelope* envelope = new TGo4ObjEnvelope(ob, ob->GetName(), pathname.Data());
1222  fxAnalysisSlave->SendObject(envelope);
1223  delete envelope;
1224  return;
1225  }
1226 
1227  fxAnalysisSlave->SendObject(dynamic_cast<TNamed*>(ob));
1228 }
1229 
1231 {
1232  if(fxAnalysisSlave)
1233  return fxAnalysisSlave->MainIsRunning();
1234 
1235  return TGo4Analysis::fbExists; // should be kTRUE
1236 }
1237 
1239 {
1240  if(!fxAnalysisSlave) return;
1241  if(on)
1243  else
1244  fxAnalysisSlave->Stop();
1245 }
1246 
1248 {
1249  Int_t cycles = 0;
1250  while(!IsRunning()) {
1251  gSystem->Sleep(fgiMACROSTARTPOLL);
1252  cycles++;
1253  Bool_t sysret = gSystem->ProcessEvents();
1254  if (sysret || (fxDoWorkingFlag == flagStop)) {
1255  cycles=-1;
1256  break;
1257  // allows cint canvas menu "Interrupt" to get us out of here!
1258  // additionally, without ProcessEvents no connect/disconnect of Go4
1259  // would be possible from this wait loop
1260  }
1261  }
1262  return cycles;
1263 }
1264 
1265 void TGo4Analysis::StartObjectServer(const char *basename, const char *passwd)
1266 {
1267  if(fxAnalysisSlave) {
1268  Message(1,"Start object server not yet enabled.");
1269  //fxAnalysisSlave->StartObjectServer(basename,passwd);
1270  } else {
1271  Message(2,"Could not start object server in batch mode.");
1272  }
1273 }
1274 
1276 {
1277  if(fxAnalysisSlave) {
1278  //fxAnalysisSlave->StopObjectServer();
1279  Message(1,"Stop object server not yet enabled.");
1280  } else {
1281  Message(2,"Could not stop object server in batch mode.");
1282  }
1283 }
1284 
1286 {
1287  // this method to be called from ctrl-c signal handler of analysis server
1288  if(fxAnalysisSlave) {
1289  TGo4Log::Message(1,"Analysis server is initiating shutdown after ctrl-c, please wait!!\n");
1290  fxAnalysisSlave->SubmitShutdown(); // shutdown will be performed in local command thread
1291  }
1292 
1293 }
1294 
1296 // Show event in specified step
1297 
1298 void TGo4Analysis::ShowEvent(const char *stepname, Bool_t isoutput)
1299 {
1300  TTree *sevtree = CreateSingleEventTree(stepname,isoutput);
1301  if(sevtree) {
1302  if(isoutput)
1303  Message(1, "Showing Output Event %s of step %s", sevtree->GetName(), stepname);
1304  else
1305  Message(1, "Showing Input Event %s of step %s", sevtree->GetName(), stepname);
1306  sevtree->Show(0);
1307  std::cout << std::endl;
1308  delete sevtree;
1309  }
1310 }
1311 
1313 // Methods that forward to object manager:
1314 
1315 Bool_t TGo4Analysis::AddDynamicHistogram(const char *name,
1316  const char *histo,
1317  const char *hevx, const char *hmemx,
1318  const char *hevy, const char *hmemy,
1319  const char *hevz, const char *hmemz,
1320  const char *condition,
1321  const char *cevx, const char *cmemx,
1322  const char *cevy, const char *cmemy)
1323 {
1324  return fxObjectManager->AddDynamicHistogram(name,
1325  histo, hevx, hmemx, hevy, hmemy, hevz, hmemz,
1326  condition, cevx, cmemx, cevy, cmemy);
1327 }
1328 
1329 Bool_t TGo4Analysis::AddTreeHistogram(const char *hisname, const char *treename, const char *varexp, const char *cutexp)
1330 {
1331  Bool_t rev=fxObjectManager->AddTreeHistogram(hisname,treename,varexp,cutexp);
1332  if(rev) UpdateNamesList();
1333  return rev;
1334 }
1335 
1337 {
1338  return fxObjectManager->AddEventProcessor(pro);
1339 }
1340 
1342 {
1343  return fxObjectManager->AddEventSource(source);
1344 }
1345 
1347 {
1348  return fxObjectManager->AddEventStore(store);
1349 }
1350 
1352 {
1353  return fxObjectManager->AddEventStructure(ev);
1354 }
1355 
1356 Bool_t TGo4Analysis::AddHistogram(TH1 *his, const char *subfolder, Bool_t replace)
1357 {
1358  return fxObjectManager->AddHistogram(his, subfolder, replace);
1359 }
1360 
1361 Bool_t TGo4Analysis::AddObject(TNamed *anything, const char *subfolder, Bool_t replace)
1362 {
1363  return fxObjectManager->AddObject(anything, subfolder, replace);
1364 }
1365 
1366 Bool_t TGo4Analysis::AddParameter(TGo4Parameter *par, const char *subfolder)
1367 {
1368  return fxObjectManager->AddParameter(par,subfolder);
1369 }
1370 
1371 Bool_t TGo4Analysis::AddPicture(TGo4Picture *pic, const char *subfolder)
1372 {
1373  return fxObjectManager->AddPicture(pic,subfolder);
1374 }
1375 
1376 Bool_t TGo4Analysis::AddCanvas(TCanvas *can, const char *subfolder)
1377 {
1378  return fxObjectManager->AddCanvas(can,subfolder);
1379 }
1380 
1381 Bool_t TGo4Analysis::AddTree(TTree *tree, const char *subfolder)
1382 {
1383  if(tree) tree->ResetBit(TGo4Status::kGo4BackStoreReset);
1384  return fxObjectManager->AddTree(tree, subfolder);
1385 }
1386 
1387 Bool_t TGo4Analysis::AddAnalysisCondition(TGo4Condition *con, const char *subfolder)
1388 {
1389  return fxObjectManager->AddAnalysisCondition(con,subfolder);
1390 }
1391 
1392 TGo4Condition *TGo4Analysis::GetAnalysisCondition(const char *name, const char *cond_cl)
1393 {
1394  return fxObjectManager->GetAnalysisCondition(name, cond_cl);
1395 }
1396 
1398 {
1399  return fxStepManager->GetAnalysisStep(name);
1400 }
1401 
1403 {
1404  return fxStepManager->GetAnalysisStepNum(number);
1405 }
1406 
1408 {
1410 }
1411 
1413 {
1414  return fxObjectManager->GetEventStructure(name);
1415 }
1416 
1417 TH1 *TGo4Analysis::GetHistogram(const char *name)
1418 {
1419  return fxObjectManager->GetHistogram(name);
1420 }
1421 
1422 TNamed *TGo4Analysis::GetObject(const char *name, const char *folder)
1423 {
1424  return fxObjectManager->GetObject(name,folder);
1425 }
1426 
1427 TGo4Parameter *TGo4Analysis::GetParameter(const char *name, const char *par_class)
1428 {
1429  return fxObjectManager->GetParameter(name, par_class);
1430 }
1431 
1433 {
1434  return fxObjectManager->GetPicture(name);
1435 }
1436 
1437 TCanvas *TGo4Analysis::GetCanvas(const char *name)
1438 {
1439  return fxObjectManager->GetCanvas(name);
1440 }
1441 
1442 TTree *TGo4Analysis::GetTree(const char *name)
1443 {
1444  return fxObjectManager->GetTree(name);
1445 }
1446 
1448 {
1449  return fxObjectManager->CreateNamesList();
1450 }
1451 
1453 {
1454  return fxObjectManager->GetObjectFolder();
1455 }
1456 
1457 TGo4ObjectStatus *TGo4Analysis::CreateObjectStatus(const char *name, const char *folder)
1458 {
1459  return fxObjectManager->CreateObjectStatus(name,folder);
1460 }
1461 
1463 {
1464  return fxObjectManager->CreateTreeStructure(treename);
1465 }
1466 
1468 {
1469  return fxObjectManager->RemoveEventSource(source);
1470 }
1471 
1473 {
1474  return fxObjectManager->RemoveEventStore(store);
1475 }
1476 
1478 {
1480 }
1481 
1482 Bool_t TGo4Analysis::RemoveHistogram(const char *name, Bool_t del)
1483 {
1484  return fxObjectManager->RemoveHistogram(name,del);
1485 }
1486 
1487 Bool_t TGo4Analysis::RemoveObject(const char *name, Bool_t del)
1488 {
1489  return fxObjectManager->RemoveObject(name,del);
1490 }
1491 
1492 Bool_t TGo4Analysis::RemoveParameter(const char *name)
1493 {
1494  return fxObjectManager->RemoveParameter(name);
1495 }
1496 
1497 Bool_t TGo4Analysis::RemovePicture(const char *name)
1498 {
1499  return fxObjectManager->RemovePicture(name);
1500 }
1501 
1502 Bool_t TGo4Analysis::RemoveCanvas(const char *name)
1503 {
1504  return fxObjectManager->RemoveCanvas(name);
1505 }
1506 
1507 Bool_t TGo4Analysis::RemoveTree(TTree *tree, const char *stepname)
1508 {
1509  return fxObjectManager->RemoveTree(tree, stepname);
1510 }
1511 
1513 {
1515 }
1516 
1518 {
1520 }
1521 
1522 Bool_t TGo4Analysis::DeleteObjects(const char *name)
1523 {
1524  return fxObjectManager->DeleteObjects(name);
1525 }
1526 
1527 Bool_t TGo4Analysis::ClearObjects(const char *name)
1528 {
1529  return fxObjectManager->ClearObjects(name);
1530 }
1531 
1532 Bool_t TGo4Analysis::ProtectObjects(const char *name, const Option_t *flags)
1533 {
1534  return fxObjectManager->ProtectObjects(name, flags);
1535 }
1536 
1537 Bool_t TGo4Analysis::ResetBackStores(Bool_t clearflag)
1538 {
1539  return fxObjectManager->ResetBackStores(clearflag);
1540 }
1541 
1542 Bool_t TGo4Analysis::SetAnalysisCondition(const char *name, TGo4Condition *con, Bool_t counter)
1543 {
1544  return fxObjectManager->SetAnalysisCondition(name, con, counter);
1545 }
1546 
1547 Bool_t TGo4Analysis::SetParameter(const char *name, TGo4Parameter *par)
1548 {
1549  return fxObjectManager->SetParameter(name, par);
1550 }
1551 
1553 {
1554  return fxObjectManager->SetParameterStatus(name, par);
1555 }
1556 
1557 Bool_t TGo4Analysis::SetPicture(const char *name, TGo4Picture *pic)
1558 {
1559  return fxObjectManager->SetPicture(name, pic);
1560 }
1561 
1563 {
1565 }
1566 
1567 void TGo4Analysis::PrintConditions(const char *expression)
1568 {
1569  fxObjectManager->PrintConditions(expression);
1570 }
1571 
1572 void TGo4Analysis::PrintHistograms(const char *expression)
1573 {
1574  fxObjectManager->PrintHistograms(expression);
1575 }
1576 
1577 void TGo4Analysis::PrintParameters(const char *expression)
1578 {
1579  fxObjectManager->PrintParameters(expression);
1580 }
1581 
1583 {
1585 }
1586 
1587 TObject *TGo4Analysis::NextMatchingObject(const char *expr, const char *folder, Bool_t reset)
1588 {
1589  return fxObjectManager->NextMatchingObject(expr,folder,reset);
1590 }
1591 
1593 // Methods that forward to stepmanager:
1594 
1596 {
1597  return fxStepManager->GetInputEvent(stepindex);
1598 }
1599 
1600 TGo4EventElement *TGo4Analysis::GetInputEvent(const char *stepname) const
1601 {
1602  return fxStepManager->GetInputEvent(stepname);
1603 }
1604 
1606 {
1607  return fxStepManager->GetOutputEvent();
1608 }
1609 
1611 {
1612  return fxStepManager->GetOutputEvent(stepindex);
1613 }
1614 
1616 {
1617  return fxStepManager->GetOutputEvent(stepname);
1618 }
1619 
1621 {
1622  return fxStepManager->NewStepProcessor(name,par);
1623 }
1624 
1626 {
1627  return fxStepManager->NewStepSource(name,par);
1628 }
1629 
1631 {
1632  return fxStepManager->NewStepStore(name,par);
1633 }
1634 
1636 {
1637  return fxObjectManager->AddDynamicEntry(entry);
1638 }
1639 
1641 {
1643 }
1644 
1645 Bool_t TGo4Analysis::SetFirstStep(const char *name)
1646 {
1647  return fxStepManager->SetFirstStep(name);
1648 }
1649 
1650 Bool_t TGo4Analysis::SetLastStep(const char *name)
1651 {
1652  return fxStepManager->SetLastStep(name);
1653 }
1654 
1655 Bool_t TGo4Analysis::SetStepStorage(const char *name, Bool_t on)
1656 {
1657  return fxStepManager->SetStepStorage(name,on);
1658 }
1659 
1661 {
1663 }
1664 
1666 {
1667  return fxStepManager->AddAnalysisStep(next);
1668 }
1669 
1671 {
1673 }
1674 
1676 {
1677  fxStepManager->SetOutputEvent(event);
1678 }
1679 
1680 Int_t TGo4Analysis::StoreParameter(const char *name, TGo4Parameter *par)
1681 {
1682  return fxStepManager->Store(name, par);
1683 }
1684 
1685 Int_t TGo4Analysis::StoreCondition(const char *name, TGo4Condition *con)
1686 {
1687  return fxStepManager->Store(name, con);
1688 }
1689 
1690 Int_t TGo4Analysis::StoreFitter(const char *name, TGo4Fitter *fit)
1691 {
1692  return fxStepManager->Store(name, fit);
1693 }
1694 
1695 Int_t TGo4Analysis::StoreFolder(const char *name, TFolder *folder)
1696 {
1697  return fxStepManager->Store(name, folder);
1698 }
1699 
1700 Int_t TGo4Analysis::StoreFolder(const char *stepname, const char *foldername)
1701 {
1702  TFolder *myfolder = fxObjectManager->FindSubFolder(GetObjectFolder(), foldername, kFALSE);
1703  return myfolder ? fxStepManager->Store(stepname, myfolder) : 2;
1704 }
1705 
1706 void TGo4Analysis::DefineServerPasswords(const char *admin, const char *controller, const char *observer)
1707 {
1708  fServerAdminPass = admin ? admin : "";
1709  fServerCtrlPass = controller ? controller : "";
1710  fServerObserverPass = observer ? observer : "";
1711 }
1712 
1713 void TGo4Analysis::SetObserverPassword(const char *passwd)
1714 {
1715  fServerObserverPass = passwd ? passwd : "";
1716 }
1717 
1718 void TGo4Analysis::SetControllerPassword(const char *passwd)
1719 {
1720  fServerCtrlPass = passwd ? passwd : "";
1721 }
1722 
1724 {
1725  fServerAdminPass = passwd ? passwd : "";
1726 }
1727 
1728 Bool_t TGo4Analysis::EvaluateFolderpath(const char *fullname, TString &objectname, TString &foldername)
1729 {
1730  if (!fullname || (strlen(fullname) == 0))
1731  return kFALSE;
1732  const char *separ = strrchr(fullname, '/');
1733  if (separ) {
1734  objectname = separ + 1;
1735  foldername.Append(fullname, separ - fullname);
1736  } else
1737  objectname = fullname;
1738  return kTRUE;
1739 }
1740 
1741 TH1 *TGo4Analysis::MakeTH1(char type, const char *fullname, const char *title,
1742  Int_t nbinsx, Double_t xlow, Double_t xup,
1743  const char *xtitle, const char *ytitle)
1744 {
1745  fbObjMade = kFALSE;
1746  TString foldername, histoname;
1747  if (!EvaluateFolderpath(fullname, histoname, foldername)) {
1748  TGo4Log::Error("Histogram name not specified, can be a hard error");
1749  return nullptr;
1750  }
1751 // const char *separ = strrchr(fullname, '/');
1752 // if (separ) {
1753 // histoname = separ + 1;
1754 // foldername.Append(fullname, separ - fullname);
1755 // } else
1756 // histoname = fullname;
1757 
1758  int itype = 0;
1759  const char *sclass = "TH1I";
1760  switch (type) {
1761  case 'I': case 'i': itype = 0; sclass = "TH1I"; break;
1762  case 'F': case 'f': itype = 1; sclass = "TH1F"; break;
1763  case 'D': case 'd': itype = 2; sclass = "TH1D"; break;
1764  case 'S': case 's': itype = 3; sclass = "TH1S"; break;
1765  case 'C': case 'c': itype = 4; sclass = "TH1C"; break;
1766  default: TGo4Log::Error("There is no histogram type: %c, use I instead", type); break;
1767  }
1768 
1769  TH1 *oldh = GetHistogram(fullname);
1770 
1771  if (oldh) {
1772  if (oldh->InheritsFrom(sclass) && fbMakeWithAutosave) {
1773  if (title) oldh->SetTitle(title);
1774  if (xtitle) oldh->GetXaxis()->SetTitle(xtitle);
1775  if (ytitle) oldh->GetYaxis()->SetTitle(ytitle);
1776  return oldh;
1777  }
1778 
1779  if (fbMakeWithAutosave)
1780  TGo4Log::Info("There is histogram %s with type %s other than specified %s, create new and reuse content",
1781  fullname, oldh->ClassName(), sclass);
1782 
1783  // do not delete histogram immediately
1784  RemoveHistogram(fullname, kFALSE);
1785 
1786  // prevent ROOT to complain about same name
1787  oldh->SetName("___");
1788  }
1789 
1790  TH1 *newh = nullptr;
1791 
1792  switch (itype) {
1793  case 0: newh = new TH1I(histoname, title, nbinsx, xlow, xup); break;
1794  case 1: newh = new TH1F(histoname, title, nbinsx, xlow, xup); break;
1795  case 2: newh = new TH1D(histoname, title, nbinsx, xlow, xup); break;
1796  case 3: newh = new TH1S(histoname, title, nbinsx, xlow, xup); break;
1797  case 4: newh = new TH1C(histoname, title, nbinsx, xlow, xup); break;
1798  }
1799 
1800  newh->SetTitle(title);
1801 
1802  if (xtitle) newh->GetXaxis()->SetTitle(xtitle);
1803  if (ytitle) newh->GetYaxis()->SetTitle(ytitle);
1804 
1805  if (oldh) {
1806  if ((oldh->GetDimension()==1) && fbMakeWithAutosave) newh->Add(oldh);
1807  delete oldh;
1808  oldh = nullptr;
1809  }
1810 
1811  if (foldername.Length() > 0)
1812  AddHistogram(newh, foldername.Data());
1813  else
1814  AddHistogram(newh);
1815 
1816  fbObjMade = kTRUE;
1817 
1818  return newh;
1819 }
1820 
1821 TH2 *TGo4Analysis::MakeTH2(char type, const char *fullname, const char *title,
1822  Int_t nbinsx, Double_t xlow, Double_t xup,
1823  Int_t nbinsy, Double_t ylow, Double_t yup,
1824  const char *xtitle, const char *ytitle, const char *ztitle)
1825 {
1826  fbObjMade = kFALSE;
1827  TString foldername, histoname;
1828 
1829  if (!EvaluateFolderpath(fullname, histoname, foldername)) {
1830  TGo4Log::Error("Histogram name not specified, can be a hard error");
1831  return nullptr;
1832  }
1833 
1834 // const char *separ = strrchr(fullname, '/');
1835 // if (separ) {
1836 // histoname = separ + 1;
1837 // foldername.Append(fullname, separ - fullname);
1838 // } else
1839 // histoname = fullname;
1840 
1841  int itype = 0;
1842  const char *sclass = "TH2I";
1843  switch (type) {
1844  case 'I': case 'i': itype = 0; sclass = "TH2I"; break;
1845  case 'F': case 'f': itype = 1; sclass = "TH2F"; break;
1846  case 'D': case 'd': itype = 2; sclass = "TH2D"; break;
1847  case 'S': case 's': itype = 3; sclass = "TH2S"; break;
1848  case 'C': case 'c': itype = 4; sclass = "TH2C"; break;
1849  default: TGo4Log::Error("There is no histogram type: %c, use I instead", type); break;
1850  }
1851 
1852  TH1 *oldh = GetHistogram(fullname);
1853 
1854  if (oldh) {
1855  if (oldh->InheritsFrom(sclass) && fbMakeWithAutosave) {
1856  if (title) oldh->SetTitle(title);
1857  if (xtitle) oldh->GetXaxis()->SetTitle(xtitle);
1858  if (ytitle) oldh->GetYaxis()->SetTitle(ytitle);
1859  return (TH2 *) oldh;
1860  }
1861 
1862  if (fbMakeWithAutosave)
1863  TGo4Log::Info("There is histogram %s with type %s other than specified %s, create new and reuse content",
1864  fullname, oldh->ClassName(), sclass);
1865 
1866  // do not delete histogram immediately
1867  RemoveHistogram(fullname, kFALSE);
1868 
1869  // prevent ROOT to complain about same name
1870  oldh->SetName("___");
1871  }
1872 
1873  TH2 *newh = nullptr;
1874 
1875  switch (itype) {
1876  case 0: newh = new TH2I(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
1877  case 1: newh = new TH2F(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
1878  case 2: newh = new TH2D(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
1879  case 3: newh = new TH2S(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
1880  case 4: newh = new TH2C(histoname, title, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
1881  }
1882 
1883  newh->SetTitle(title);
1884 
1885  if (xtitle) newh->GetXaxis()->SetTitle(xtitle);
1886  if (ytitle) newh->GetYaxis()->SetTitle(ytitle);
1887  if (ztitle) newh->GetZaxis()->SetTitle(ztitle);
1888 
1889  if (oldh) {
1890  if ((oldh->GetDimension()==2) && fbMakeWithAutosave) newh->Add(oldh);
1891  delete oldh;
1892  oldh = nullptr;
1893  }
1894 
1895  if (foldername.Length() > 0)
1896  AddHistogram(newh, foldername.Data());
1897  else
1898  AddHistogram(newh);
1899 
1900  fbObjMade = kTRUE;
1901 
1902  return newh;
1903 }
1904 
1906  Double_t xmin, Double_t xmax,
1907  const char *HistoName)
1908 {
1909  fbObjMade = kFALSE;
1910  TString foldername, condname;
1911 
1912  if (!EvaluateFolderpath(fullname, condname, foldername)) {
1913  TGo4Log::Error("Condition name not specified, can be a hard error");
1914  return nullptr;
1915  }
1916  TGo4Condition *cond = GetAnalysisCondition(fullname);
1917 
1918  if (cond) {
1919  if (cond->InheritsFrom(TGo4WinCond::Class()) && fbMakeWithAutosave) {
1920  cond->ResetCounts();
1921  return (TGo4WinCond*) cond;
1922  }
1923  RemoveAnalysisCondition(fullname);
1924  }
1925 
1926  TGo4WinCond *wcond = new TGo4WinCond(condname);
1927  wcond->SetValues(xmin, xmax);
1928  wcond->SetHistogram(HistoName);
1929  wcond->Enable();
1930 
1931  if (foldername.Length() > 0)
1932  AddAnalysisCondition(wcond, foldername.Data());
1933  else
1934  AddAnalysisCondition(wcond);
1935 
1936  fbObjMade = kTRUE;
1937 
1938  return wcond;
1939 }
1940 
1942  Double_t xmin, Double_t xmax,
1943  Double_t ymin, Double_t ymax,
1944  const char *HistoName)
1945 {
1946  fbObjMade = kFALSE;
1947  TString foldername, condname;
1948 
1949  if (!EvaluateFolderpath(fullname, condname, foldername)) {
1950  TGo4Log::Error("Condition name not specified, can be a hard error");
1951  return nullptr;
1952  }
1953  TGo4Condition *cond = GetAnalysisCondition(fullname);
1954 
1955  if (cond) {
1956  if (cond->InheritsFrom(TGo4WinCond::Class()) && fbMakeWithAutosave) {
1957  cond->ResetCounts();
1958  return (TGo4WinCond*) cond;
1959  }
1960  RemoveAnalysisCondition(fullname);
1961  }
1962 
1963  TGo4WinCond *wcond = new TGo4WinCond(condname);
1964  wcond->SetValues(xmin, xmax, ymin, ymax);
1965  wcond->SetHistogram(HistoName);
1966  wcond->Enable();
1967 
1968  if (foldername.Length() > 0)
1969  AddAnalysisCondition(wcond, foldername.Data());
1970  else
1971  AddAnalysisCondition(wcond);
1972 
1973  fbObjMade = kTRUE;
1974 
1975  return wcond;
1976 }
1977 
1979  Int_t npoints,
1980  Double_t (*points) [2],
1981  const char *HistoName,
1982  Bool_t shapedcond)
1983 {
1984  fbObjMade = kFALSE;
1985  TString foldername, condname;
1986 
1987  if (!EvaluateFolderpath(fullname, condname, foldername)) {
1988  TGo4Log::Error("Condition name not specified, can be a hard error");
1989  return nullptr;
1990  }
1991 
1992  TGo4Condition *cond = GetAnalysisCondition(fullname);
1993 
1994  if (cond) {
1995  if (cond->InheritsFrom(TGo4PolyCond::Class()) && fbMakeWithAutosave) {
1996  cond->ResetCounts();
1997  return (TGo4PolyCond*) cond;
1998  }
1999  RemoveAnalysisCondition(fullname);
2000  }
2001 
2002  TArrayD fullx(npoints+1), fully(npoints+1);
2003 
2004  for (int i = 0; i < npoints; i++) {
2005  fullx[i] = points[i][0];
2006  fully[i] = points[i][1];
2007  }
2008 
2009  // connect first and last points
2010  if ((fullx[0]!=fullx[npoints-1]) || (fully[0]!=fully[npoints-1])) {
2011  fullx[npoints] = fullx[0];
2012  fully[npoints] = fully[0];
2013  npoints++;
2014  }
2015 
2016  TCutG mycat("initialcut", npoints, fullx.GetArray(), fully.GetArray());
2017  TGo4PolyCond *pcond;
2018  if(shapedcond)
2019  pcond = new TGo4ShapedCond(condname);
2020  else
2021  pcond = new TGo4PolyCond(condname);
2022  pcond->SetValues(&mycat);
2023  pcond->Enable();
2024 
2025  pcond->SetHistogram(HistoName);
2026 
2027  if (foldername.Length() > 0)
2028  AddAnalysisCondition(pcond, foldername.Data());
2029  else
2030  AddAnalysisCondition(pcond);
2031 
2032  fbObjMade = kTRUE;
2033 
2034  return pcond;
2035 }
2036 
2037 
2039  Int_t npoints,
2040  Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta,
2041  const char *HistoName)
2042 {
2043  fbObjMade = kFALSE;
2044  TString foldername, condname;
2045 
2046  if (!EvaluateFolderpath(fullname, condname, foldername)) {
2047  TGo4Log::Error("Condition name not specified, can be a hard error");
2048  return nullptr;
2049  }
2050 
2051  TGo4Condition *cond = GetAnalysisCondition(fullname);
2052 
2053  if (cond) {
2054  if (cond->InheritsFrom(TGo4ShapedCond::Class()) && fbMakeWithAutosave) {
2055  cond->ResetCounts();
2056  return (TGo4ShapedCond *)cond;
2057  }
2058  RemoveAnalysisCondition(fullname);
2059  }
2060 
2061  TGo4ShapedCond *econd = new TGo4ShapedCond(condname);
2062  econd->SetEllipse(cx, cy, a1, a2, theta, npoints);
2063  econd->Enable();
2064  econd->SetHistogram(HistoName);
2065  if (foldername.Length() > 0)
2066  AddAnalysisCondition(econd, foldername.Data());
2067  else
2068  AddAnalysisCondition(econd);
2069 
2070  fbObjMade = kTRUE;
2071 
2072  return econd;
2073 }
2074 
2076  Int_t npoints, Double_t cx, Double_t cy, Double_t r,
2077  const char *HistoName)
2078 {
2079  TGo4ShapedCond *elli = MakeEllipseCond(fullname, npoints, cx, cy, r, r, 0, HistoName);
2080  elli->SetCircle(); // mark "circle shape" property
2081  return elli;
2082 }
2083 
2084 TGo4ShapedCond *TGo4Analysis::MakeBoxCond(const char *fullname, Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta,
2085  const char *HistoName)
2086 {
2087  TGo4ShapedCond *elli = MakeEllipseCond(fullname, 4, cx, cy, a1, a2, theta, HistoName);
2088  elli->SetBox(); // convert to "box shape" property
2089  return elli;
2090 }
2091 
2093  Int_t npoints,
2094  Double_t (*points) [2],
2095  const char *HistoName)
2096 {
2097  TGo4ShapedCond *elli=dynamic_cast<TGo4ShapedCond*>(MakePolyCond(fullname, npoints, points, HistoName,true));
2098  elli->SetFreeShape();
2099  return elli;
2100 }
2101 
2102 TGo4ListCond *TGo4Analysis::MakeListCond(const char *fullname, const char *title, const char *HistoName)
2103 {
2104  fbObjMade = kFALSE;
2105  TString foldername, condname;
2106 
2107  if (!EvaluateFolderpath(fullname, condname, foldername)) {
2108  TGo4Log::Error("Condition name not specified, can be a hard error");
2109  return nullptr;
2110  }
2111 
2112  TGo4Condition *cond = GetAnalysisCondition(fullname);
2113 
2114  if (cond) {
2115  if (cond->InheritsFrom(TGo4ListCond::Class()) && fbMakeWithAutosave) {
2116  cond->ResetCounts();
2117  return (TGo4ListCond *)cond;
2118  }
2119  RemoveAnalysisCondition(fullname);
2120  }
2121 
2122  TGo4ListCond *lcond = new TGo4ListCond(condname.Data(), title);
2123  lcond->SetHistogram(HistoName);
2124  lcond->Enable();
2125 
2126  if (foldername.Length() > 0)
2127  AddAnalysisCondition(lcond, foldername.Data());
2128  else
2129  AddAnalysisCondition(lcond);
2130 
2131  fbObjMade = kTRUE;
2132 
2133  return lcond;
2134 }
2135 
2136 TGo4ListCond *TGo4Analysis::MakeListCond(const char *fullname, const Int_t num, const Int_t * values, const char *HistoName)
2137 {
2138  TGo4ListCond *lcond=MakeListCond(fullname, "Go4 valuelist condition", HistoName);
2139  if(fbObjMade) lcond->SetValues(num,values);
2140  return lcond;
2141 }
2142 
2143 
2144 TGo4ListCond *TGo4Analysis::MakeListCond(const char *fullname, const Int_t start, const Int_t stop, const Int_t step, const char *HistoName)
2145 {
2146  TGo4ListCond *lcond=MakeListCond(fullname, "Go4 valuelist condition", HistoName);
2147  if(fbObjMade) lcond->SetValues(start,stop,step);
2148  return lcond;
2149 }
2150 
2151 
2152 TGraph *TGo4Analysis::MakeGraph(const char *fullname, const char *title, Int_t points, Double_t *xvalues, Double_t *yvalues)
2153 {
2154  fbObjMade = kFALSE;
2155  TString foldername, graphname;
2156  if (!EvaluateFolderpath(fullname, graphname, foldername)) {
2157  TGo4Log::Error("TGraph name not specified, can be a hard error");
2158  return nullptr;
2159  }
2160 
2161  TGraph *graph = dynamic_cast<TGraph *>(GetObject(fullname));
2162  if (graph)
2163  return graph;
2164  if (!points)
2165  graph = new TGraph();
2166  else
2167  graph = new TGraph(points, xvalues, yvalues);
2168  graph->SetName(graphname.Data());
2169  graph->SetTitle(title);
2170 
2171  if (foldername.Length() > 0)
2172  AddObject(graph, foldername.Data());
2173  else
2174  AddObject(graph);
2175 
2176  fbObjMade = kTRUE;
2177  return graph;
2178 }
2179 
2180 TGraph *TGo4Analysis::MakeGraph(const char *fullname, const char *title, TF1 *function)
2181 {
2182  fbObjMade = kFALSE;
2183  TString foldername, graphname;
2184  if (!EvaluateFolderpath(fullname, graphname, foldername)) {
2185  TGo4Log::Error("TGraph name not specified, can be a hard error");
2186  return nullptr;
2187  }
2188 
2189  TGraph *graph = dynamic_cast<TGraph *>(GetObject(fullname));
2190  if (graph)
2191  return graph;
2192  graph = new TGraph(function);
2193  graph->SetName(graphname.Data());
2194  graph->SetTitle(title);
2195  if (foldername.Length() > 0)
2196  AddObject(graph, foldername.Data());
2197  else
2198  AddObject(graph);
2199  fbObjMade = kTRUE;
2200  return graph;
2201 }
2202 
2203 TGo4RollingGraph *TGo4Analysis::MakeRollingGraph(const char *fullname, const char *title, Int_t points, Int_t average)
2204 {
2205  fbObjMade = kFALSE;
2206  TString foldername, graphname;
2207  if (!EvaluateFolderpath(fullname, graphname, foldername)) {
2208  TGo4Log::Error("TGraph name not specified, can be a hard error");
2209  return nullptr;
2210  }
2211  TGo4RollingGraph *graph = dynamic_cast<TGo4RollingGraph *>(GetObject(fullname));
2212  if (graph)
2213  return graph;
2214  graph = new TGo4RollingGraph(points, average);
2215  graph->SetName(graphname.Data());
2216  graph->SetTitle(title);
2217  if (foldername.Length() > 0)
2218  AddObject(graph, foldername.Data());
2219  else
2220  AddObject(graph);
2221  fbObjMade = kTRUE;
2222  return graph;
2223 }
2224 
2226  const char *classname,
2227  const char *newcmd)
2228 {
2229  fbObjMade = kFALSE;
2230  TString foldername, paramname;
2231 
2232  if (!fullname || (strlen(fullname) == 0)) {
2233  TGo4Log::Error("Parameter name not specified, can be a hard error");
2234  return nullptr;
2235  }
2236  const char *separ = strrchr(fullname, '/');
2237  if (separ) {
2238  paramname = separ + 1;
2239  foldername.Append(fullname, separ - fullname);
2240  } else
2241  paramname = fullname;
2242 
2243  TGo4Parameter *param = GetParameter(fullname);
2244 
2245  if (param) {
2246  if (!param->InheritsFrom(classname)) {
2247  TGo4Log::Info("There is parameter %s with type %s other than specified %s, rebuild", fullname,
2248  param->ClassName(), classname);
2249  RemoveParameter(fullname);
2250  param = nullptr;
2251  }
2252  }
2253 
2254  if (!param) {
2255  paramname = TString("\"") + paramname + TString("\"");
2256 
2257  TString cmd;
2258  if (newcmd && (strstr(newcmd, "new ") == newcmd))
2259  cmd = TString::Format(newcmd, paramname.Data());
2260  else
2261  cmd = TString::Format("new %s(%s)", classname, paramname.Data());
2262 
2263  auto res = gROOT->ProcessLineFast(cmd.Data());
2264 
2265  if (res == 0) {
2266  TGo4Log::Error("Cannot create parameter of class %s", classname);
2267  return nullptr;
2268  }
2269 
2270  param = (TGo4Parameter *)res;
2271 
2272  if (foldername.Length() > 0)
2273  AddParameter(param, foldername.Data());
2274  else
2275  AddParameter(param);
2276 
2277  fbObjMade = kTRUE;
2278  }
2279 
2280  if (newcmd && (strstr(newcmd, "set_") == newcmd)) {
2281  // executing optional set macro
2282 
2283  ExecuteScript(newcmd);
2284  }
2285 
2286  return param;
2287 }
2288 
2290 {
2292 }
2293 
2295 {
2296  return fxObjectManager->IsSortedOrder();
2297 }
2298 
2299 
2300 Long64_t TGo4Analysis::ExecuteScript(const char *macro_name)
2301 {
2302  if (!macro_name || (strlen(macro_name) == 0)) return -1;
2303 
2304  // exclude arguments which could be specified with macro name
2305  TString file_name(macro_name);
2306  Ssiz_t pos = file_name.First('(');
2307  if (pos > 0) file_name.Resize(pos);
2308  bool has_plus = false;
2309  pos = file_name.First('+');
2310  if (pos > 0) { file_name.Resize(pos); has_plus = true; }
2311  while ((file_name.Length() > 0) && (file_name[file_name.Length()-1] == ' '))
2312  file_name.Resize(file_name.Length()-1);
2313  while ((file_name.Length() > 0) && (file_name[0] == ' '))
2314  file_name.Remove(0, 1);
2315 
2316  if (gSystem->AccessPathName(file_name.Data())) {
2317  TGo4Log::Error("ROOT script %s not found", file_name.Data());
2318  return -1;
2319  }
2320 
2321  TGo4Log::Info("Executing ROOT script %s", macro_name);
2322 
2323  TString exec = ".x ";
2324  exec.Append(macro_name);
2325  int error = 0;
2326 
2327  std::ifstream t(file_name.Data());
2328  std::string content = std::string(std::istreambuf_iterator<char>(t), {});
2329  if (content.empty()) {
2330  TGo4Log::Error("Fail to load content of %s", file_name.Data());
2331  return -1;
2332  }
2333 
2334  TString func_name = file_name;
2335  pos = func_name.Last('/');
2336  if (pos != kNPOS) func_name.Remove(0, pos+1);
2337  pos = func_name.Index(".C");
2338  if (pos == kNPOS) pos = func_name.Index(".cxx");
2339  if (pos != kNPOS) func_name.Resize(pos);
2340 
2341  bool fall_back = false;
2342  if (has_plus) fall_back = true;
2343  if (func_name.IsNull()) fall_back = true;
2344 
2345  std::string search = func_name.Data(); search += "(";
2346  auto name_pos = content.find(search);
2347  if (name_pos == std::string::npos) fall_back = true;
2348 
2349  if (fall_back) {
2350  auto res = gROOT->ProcessLineSync(exec.Data(), &error); // here faster than ExecuteLine...
2351  return error ? -1 : res;
2352  }
2353 
2354  static std::vector<std::string> script_names;
2355  static std::vector<std::string> script_contents;
2356  static std::vector<std::string> script_func;
2357  static int findx = 1;
2358 
2359  int indx = -1;
2360 
2361  for (unsigned n = 0; n < script_names.size(); n++)
2362  if (script_names[n] == file_name.Data()) {
2363  indx = n; break;
2364  }
2365 
2366  if (indx < 0) {
2367  // register new code with its func name
2368  script_names.push_back(file_name.Data());
2369  script_contents.push_back(content);
2370  script_func.push_back(func_name.Data());
2371  indx = script_names.size() - 1;
2372 
2373  if (!gInterpreter->LoadText(content.c_str())) {
2374  TGo4Log::Error("Cannot parse code of %s script", file_name.Data());
2375  return -1;
2376  }
2377  } else if (script_contents[indx] != content) {
2378  // script was modified, has to reload with new function name
2379  std::string new_name = func_name.Data();
2380  new_name += std::to_string(findx++);
2381  script_contents[indx] = content;
2382  script_func[indx] = new_name;
2383 
2384  content.erase(name_pos, func_name.Length());
2385  content.insert(name_pos, new_name);
2386 
2387  if (!gInterpreter->LoadText(content.c_str())) {
2388  TGo4Log::Error("Cannot parse modified code of %s script", file_name.Data());
2389  return -1;
2390  }
2391 
2392  func_name = new_name.c_str();
2393 
2394  } else {
2395  // script is same, just call again same function
2396  func_name = script_func[indx].c_str();
2397  }
2398 
2399  TGo4Log::Error("Execute function %s from script %s", func_name.Data(), file_name.Data());
2400 
2401  // just call function
2402  func_name.Append("()");
2403  auto res = gROOT->ProcessLineSync(func_name.Data(), &error); // here faster than ExecuteLine...
2404  if (error) res = -1;
2405 
2406  return res;
2407 }
2408 
2409 Long64_t TGo4Analysis::ExecutePython(const char *macro_name, Int_t *errcode)
2410 {
2411  if (!macro_name || (strlen(macro_name) == 0)) return -1;
2412  TString comstring=macro_name;
2413  comstring.Prepend(TGo4Analysis::fgcPYPROMPT); // emulate interactive command line mode here
2414  return ExecuteLine(comstring.Data(), errcode);
2415 }
2416 
2417 
2418 Long64_t TGo4Analysis::ExecuteLine(const char *command, Int_t *errcode)
2419 {
2420  TString comstring;
2421  if (strchr(command,TGo4Analysis::fgcPYPROMPT) && (strchr(command,TGo4Analysis::fgcPYPROMPT) == strrchr(command,TGo4Analysis::fgcPYPROMPT))) {
2422  // this one is by Sven Augustin, MPI Heidelberg
2423  comstring = command;
2424  comstring = comstring.Strip(TString::kBoth);
2425  comstring = comstring.Strip(TString::kLeading,TGo4Analysis::fgcPYPROMPT);
2426  comstring = comstring.Strip(TString::kLeading);
2427  TGo4Log::Debug("Executing Python script: %s", comstring.Data());
2428  const TString PY_EXT = ".py";
2429  int imin = comstring.Index(PY_EXT + " ");
2430  int imax = comstring.Length();
2431  if (imin == -1) {
2432  imin = imax;
2433  } else {
2434  imin += PY_EXT.Length();
2435  }
2436  int ilen = imax - imin;
2437  TString scrstring = comstring(0, imin);
2438  TString argstring = comstring(imin, ilen);
2439 
2440  comstring = "TPython::Exec(\"import sys; sys.argv = [\'" + scrstring + "\'] + \'" + argstring + "\'.split()\");";
2441  comstring += "TPython::LoadMacro(\"" + scrstring + "\");";
2442 
2443  if(!fbPythonBound) {
2444  TString go4sys = TGo4Log::GO4SYS();
2445  TString pyinit = TGo4Analysis::fgcPYINIT; // JAM todo: put python path and filename into settings
2446  comstring.Prepend("TPython::LoadMacro(\"" + go4sys + pyinit +"\");");
2447  comstring.Prepend("TPython::Bind(go4, \"go4\");" );
2448  fbPythonBound = kTRUE;
2449  }
2450  } else {
2451  comstring = "";
2452  const char *cursor = command;
2453  const char *at = nullptr;
2454  do {
2455  Ssiz_t len = strlen(cursor);
2456  at = strstr(cursor, "@");
2457  if (at) {
2458  len = (Ssiz_t)(at - cursor);
2459  comstring.Append(cursor, len);
2460  comstring.Append("TGo4Analysis::Instance()->");
2461  cursor = at + 1;
2462  } else {
2463  comstring.Append(cursor);
2464  }
2465  } while (at);
2466  }
2467 
2468  TGo4Log::Debug("ExecuteLine: %s", comstring.Data());
2469 
2470 // TInterpreter* theI = gROOT->GetInterpreter();
2471 // printf ("ExecuteLine sees interpreter of class %s \n",theI ? theI->IsA()->GetName() : "NULL");
2472 // printf ("IsProcessLineLocked is %s \n", theI->IsProcessLineLocked() ? "true" : "false");
2473 // printf ("gInterpreterMutex: 0x%x gGlobalMutex: 0x%x \n", gInterpreterMutex, gGlobalMutex);
2474 
2475 
2476 // theI->SetProcessLineLock(kFALSE);
2477  return gROOT->ProcessLineSync(comstring, errcode);
2478 }
2479 
2481 {
2482  if (fxAnalysisSlave) {
2483  // fxAnalysisSlave->GetTask()->SubmitCommand("THStop");
2484  fxAnalysisSlave->Stop();
2485  } else {
2488  }
2489 }
2490 
2492 {
2493  if (fxAnalysisSlave)
2494  {
2496  // fxAnalysisSlave->GetTask()->SubmitCommand("THStart");
2497  }
2498  else
2499  {
2500  // JAM reproduce behavior of analysis client, check init state before executing preloop
2501  if (fbInitIsDone)
2502  {
2504  {
2505  PreLoop();
2506  if(fxRate) fxRate->Reset(); // reset counters and time whenever started again
2507  }
2509  }
2510  else
2511  {
2512  Message(2, "Analysis %s was not initialized! Please SUBMIT settings first.", GetName());
2513  }
2514 
2515  }
2516 }
2517 
2518 
2519 #ifdef _MSC_VER
2520 
2521 #include "windows.h"
2522 
2523 namespace {
2524 
2525  BOOL WINAPI Go4ConsoleSigHandler(DWORD sig)
2526  {
2527  // WinNT signal handler.
2528 
2529  switch (sig) {
2530  case CTRL_C_EVENT:
2531  if (TGo4Analysis::Exists())
2533  return TRUE;
2534  case CTRL_BREAK_EVENT:
2535  case CTRL_LOGOFF_EVENT:
2536  case CTRL_SHUTDOWN_EVENT:
2537  case CTRL_CLOSE_EVENT:
2538  default:
2539  printf(" non CTRL-C signal - ignore\n");
2540  return TRUE;
2541  }
2542  }
2543 
2544  void InstallGo4CtrlCHandler(bool on)
2545  {
2546  SetConsoleCtrlHandler(Go4ConsoleSigHandler, on);
2547  }
2548 
2549 }
2550 
2551 #endif
Bool_t AddTreeHistogram(const char *hisname, const char *treename, const char *varexp, const char *cutexp)
Int_t Store(const char *name, TGo4Parameter *obj)
TGraph * MakeGraph(const char *fullname, const char *title, Int_t points=0, Double_t *xvalues=nullptr, Double_t *yvalues=nullptr)
void SendObject(TObject *obj, const char *receiver=nullptr)
Definition: TGo4Slave.cxx:115
void SetAutoFileName(const char *name)
const char * GetAutoFileName() const
void SetOutputEvent(TGo4EventElement *event)
TGo4PolyCond * MakePolyCond(const char *fullname, Int_t npoints, Double_t(*points) [2], const char *HistoName=nullptr, Bool_t shapedcond=kFALSE)
void SetRunning(Bool_t on=kTRUE)
Graphs that renew themselves iteratively to monitor a value.
static const Int_t fgiMACROSTARTPOLL
static Bool_t IsServerMode()
static const char * fgcPYINIT
void PrintConditions(const char *expression=nullptr)
Bool_t NewStepProcessor(const char *name, TGo4EventProcessorParameter *par)
void SetEllipse(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0, Int_t npoints=0)
Bool_t NewStepSource(const char *name, TGo4EventSourceParameter *par)
Bool_t RemoveEventProcessor(TGo4EventProcessor *pro)
Bool_t NewStepProcessor(const char *name, TGo4EventProcessorParameter *par)
virtual void StatusMessage(int level, Bool_t printout, const TString &)
void UpdateStatus(TGo4AnalysisStatus *state)
TGo4EventElement * GetOutputEvent(const char *stepname) const
Bool_t RemoveEventStructure(TGo4EventElement *ev)
TGo4Condition * GetAnalysisCondition(const char *name, const char *cond_cl=nullptr)
const char * GetName() const override
Bool_t SetStepStorage(const char *name, Bool_t on)
Int_t Handle() override
void SetDateTime(const char *str)
Definition: TGo4Ratemeter.h:70
void Print(Option_t *opt="") const override
virtual Int_t UserPreLoop()
TGo4AnalysisClient * fxAnalysisSlave
void SetStatus(TGo4AnalysisStatus *state)
void SetStepChecking(Bool_t on=kTRUE)
Bool_t AddPicture(TGo4Picture *pic, const char *subfolder=nullptr)
void SetAnalysisName(const char *name)
Int_t GetAutoSaveCompression() const
Bool_t IsAutoSaveFileName() const
void SetOutputEvent(TGo4EventElement *event)
TGo4ShapedCond * MakeBoxCond(const char *fullname, Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta, const char *HistoName=nullptr)
void DefineServerPasswords(const char *admin, const char *controller, const char *observer)
Bool_t RemoveParameter(const char *name)
void UpdateStatus(TGo4AnalysisStatus *state)
Bool_t AddDynamicEntry(TGo4DynamicEntry *entry)
static void SetCommandList(TGo4CommandProtoList *list)
virtual void UserPreLoop()
Long64_t ExecutePython(const char *script_name, Int_t *errcode=nullptr)
Bool_t SetParameter(const char *name, TGo4Parameter *par)
static void UnRegister(TGo4CommandReceiver *p)
static Bool_t CheckVersion(Int_t version)
Definition: TGo4Version.cxx:42
virtual void CloseAnalysis()
Int_t StoreFolder(const char *stepname, TFolder *folder)
void SetCurrentSource(const char *str)
Definition: TGo4Ratemeter.h:71
static void Info(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:294
const char * GetStatusMessage() const
TGo4TreeStructure * CreateTreeStructure(const char *treename)
void SetObserverPassword(const char *passwd)
Int_t StoreParameter(const char *name, TGo4Parameter *par)
TGo4InterruptHandler * fxInterruptHandler
void SetValues(Double_t low1, Double_t up1) override
Bool_t RemovePicture(const char *name)
Int_t GetAutoSaveInterval() const
virtual const char * What()
void SetAutoSaveOn(Bool_t on=kTRUE)
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=nullptr)
TObject * NextMatchingObject(const char *expr=nullptr, const char *folder=nullptr, Bool_t reset=kFALSE)
virtual void SetValues(const Int_t num, const Int_t *values)
static void CloseLogfile()
Definition: TGo4Log.cxx:444
void SetControllerPassword(const char *passwd)
void SetSortedOrder(Bool_t on=kTRUE)
static Bool_t IsOutputEnabled()
Definition: TGo4Log.cxx:358
TGo4ObjectStatus * CreateObjectStatus(const char *name, const char *folder=nullptr)
TGo4AnalysisObjectManager * ObjectManager() const
Bool_t ClearObjects(const char *name)
Bool_t EvaluateFolderpath(const char *fullname, TString &object, TString &folder)
TString fServerCtrlPass
void SetAutoSaveFile(const char *filename=nullptr, Bool_t overwrite=kFALSE, Int_t compression=5)
Bool_t DeleteObjects(const char *name)
void SetSortedOrder(Bool_t on=kTRUE)
Bool_t RemoveObject(const char *name, Bool_t del=kTRUE)
static const char * fgcDEFAULTSTATUSFILENAME
Bool_t AddDynamicHistogram(const char *name, const char *histo, const char *hevx, const char *hmemx, const char *hevy=nullptr, const char *hmemy=nullptr, const char *hevz=nullptr, const char *hmemz=nullptr, const char *condition=nullptr, const char *cevx=nullptr, const char *cmemx=nullptr, const char *cevy=nullptr, const char *cmemy=nullptr)
TGo4Picture * GetPicture(const char *name)
Bool_t RemoveDynamicEntry(const char *entryname, const char *listname=nullptr)
Int_t IsAutoSaveOverwrite() const
void SendMessageToGUI(Int_t level, Bool_t printout, const char *text)
TGo4AnalysisStep * GetAnalysisStep(const char *name) const
void SetStepChecking(Bool_t on=kTRUE)
static Bool_t IsClientMode()
TGo4AnalysisObjectNames * fxObjectNames
Int_t StoreFitter(const char *name, TGo4Fitter *fit)
Bool_t AddPicture(TGo4Picture *pic, const char *subfolder=nullptr)
Bool_t RemoveEventSource(TGo4EventSource *source)
Bool_t RemoveDynamicEntry(const char *entryname)
TH1 * GetHistogram(const char *name)
void ShowEvent(const char *stepname, Bool_t isoutput=kTRUE)
friend class TGo4AnalysisWebStatus
void SetUpdateInterval(double v)
Definition: TGo4Ratemeter.h:82
TString fServerAdminPass
TString fxDefaultTestFileName
Bool_t SetParameterStatus(const char *name, TGo4ParameterStatus *par)
TString fxConfigFilename
static void Register(const char *name, TGo4CommandReceiver *p)
virtual void RatemeterUpdate(TGo4Ratemeter *)
Bool_t RemoveAnalysisCondition(const char *name)
TGo4AnalysisObjectManager * fxObjectManager
Bool_t AddDynamicHistogram(const char *name, const char *histo, const char *hevx, const char *hmemx, const char *hevy=nullptr, const char *hmemy=nullptr, const char *hevz=nullptr, const char *hmemz=nullptr, const char *condition=nullptr, const char *cevx=nullptr, const char *cmemx=nullptr, const char *cevy=nullptr, const char *cmemy=nullptr)
virtual Int_t UserEventFunc()
Bool_t SetFirstStep(const char *name)
static void OutputEnable(Bool_t on=kTRUE)
Definition: TGo4Log.cxx:353
TH2 * MakeTH2(char type, const char *fullname, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, const char *xtitle=nullptr, const char *ytitle=nullptr, const char *ztitle=nullptr)
Int_t fiAutoSaveInterval
Int_t IsErrorStopEnabled() const
TGo4AnalysisStepManager * fxStepManager
void SendStatusMessage(Int_t level, Bool_t printout, const TString &text) override
TGo4Condition * GetAnalysisCondition(const char *name, const char *cond_cl=nullptr)
void SetDynListInterval(Int_t val)
Bool_t SetParameter(const char *name, TGo4Parameter *par, TFolder *parent=nullptr)
TGo4ListCond * MakeListCond(const char *fullname, const Int_t num, const Int_t *values, const char *HistoName=nullptr)
void SetRunning(Bool_t on=kTRUE)
Definition: TGo4Ratemeter.h:69
TGo4AnalysisObjectNames * CreateNamesList()
TMutex * fxAutoSaveMutex
Bool_t AddCanvas(TCanvas *can, const char *subfolder=nullptr)
const char * GetMessage() const
Bool_t RemoveTree(TTree *tree, const char *stepname=nullptr)
TNamed * GetObject(const char *name, const char *folder=nullptr)
virtual void ResetCounts()
TTree * CreateSingleEventTree(const char *name, Bool_t isoutput=kTRUE)
Bool_t fbMakeWithAutosave
const char * GetSourceName() const
Bool_t RemoveEventStructure(TGo4EventElement *ev)
Bool_t RemoveEventStore(TGo4EventStore *store)
Bool_t AddTree(TTree *tree, const char *subfolder=nullptr)
TGo4AnalysisStep * GetAnalysisStep(const char *name)
Bool_t AddTree(TTree *tree, const char *subfolder=nullptr)
virtual void UserPostLoop()
void SetAdministratorPassword(const char *passwd)
Bool_t AddEventProcessor(TGo4EventProcessor *pro)
Bool_t AddEventSource(TGo4EventSource *source)
static const char fgcPYPROMPT
void SetNewInputFile(Bool_t on=kTRUE)
void ProcessCrtlCSignal()
virtual void Enable()
Bool_t SetAnalysisCondition(const char *name, TGo4Condition *con, Bool_t counter=kTRUE)
TString fxAutoFileName
Bool_t LoadObjects(const char *filename=nullptr)
Bool_t ResetBackStores(Bool_t clearflag=kFALSE)
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Definition: TGo4Log.cxx:206
void PrintHistograms(const char *expression=nullptr)
Double_t GetRate() const
Definition: TGo4Ratemeter.h:50
Bool_t SetStepStorage(const char *name, Bool_t on)
static const char * fgcDEFAULTFILENAME
static void Debug(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:281
Int_t IsAutoSaveOn() const
Long64_t ExecuteScript(const char *script_name)
TGo4ObjectStatus * CreateObjectStatus(const char *name, const char *folder=nullptr)
TGo4AnalysisStep * GetAnalysisStepNum(Int_t number) const
void PrintConditions(const char *expression=nullptr)
Bool_t SetAnalysisCondition(const char *name, TGo4Condition *con, Bool_t counter=kTRUE, TFolder *parent=nullptr)
static const char * fgcDEFAULTFILESUF
#define __GO4RELEASE__
Definition: TGo4Version.h:25
Bool_t RemoveEventSource(TGo4EventSource *source)
TH1 * GetHistogram(const char *name)
Int_t RunImplicitLoop(Int_t times, Bool_t showrate=kFALSE, Double_t process_event_interval=-1., Bool_t iswebserver=kFALSE)
const char * GetStatusMessage() const
Bool_t RemoveTree(TTree *tree, const char *stepname=nullptr)
TCanvas * GetCanvas(const char *name)
TStopwatch * fxAutoSaveClock
void SetAutoSave(Bool_t on=kTRUE)
Bool_t RemoveEventStore(TGo4EventStore *store)
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=nullptr)
#define TRUE
Definition: f_stccomm.h:359
void SendObjectToGUI(TObject *ob)
Long64_t ExecuteLine(const char *command, Int_t *errcode=nullptr)
TString fServerObserverPass
Int_t GetPriority() const
static TGo4CommandInvoker * Instance()
const char * GetEntryClass() const
Bool_t RemoveCanvas(const char *name)
Bool_t AddEventStructure(TGo4EventElement *ev)
Bool_t AddEventStore(TGo4EventStore *store)
void Message(Int_t prio, const char *text,...)
const char * GetEntryName() const
Bool_t AddEventSource(TGo4EventSource *source)
void OpenAutoSaveFile(bool for_writing=false)
TFolder * FindSubFolder(TFolder *parent, const char *subfolder, Bool_t create=kTRUE)
TGo4Parameter * GetParameter(const char *name, const char *parameter_class=nullptr)
Int_t StoreCondition(const char *name, TGo4Condition *con)
Bool_t AddEventProcessor(TGo4EventProcessor *pro)
TGo4Parameter * GetParameter(const char *name, const char *parameter_class=nullptr)
void SetCircle(Double_t cx, Double_t cy, Double_t r, Int_t npoints=0)
Bool_t ResetBackStores(Bool_t clearflag=kFALSE)
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=nullptr)
void SetHistogram(const char *name)
TTree * GetTree(const char *name)
Bool_t NewStepStore(const char *name, TGo4EventStoreParameter *par)
static Bool_t IsBatchMode()
Bool_t DeleteObjects(const char *name)
static Bool_t fbExists
Bool_t RemoveCanvas(const char *name)
Bool_t RemoveEventProcessor(TGo4EventProcessor *pro)
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
TString fAnalysisName
TGo4Parameter * MakeParameter(const char *fullname, const char *classname, const char *cmd=nullptr)
virtual Int_t UserPostLoop()
void StartObjectServer(const char *basename, const char *passwd)
const char * GetEventSourceName() const
TGo4AnalysisObjectNames * CreateNamesList()
TObject * NextMatchingObject(const char *expr, const char *folder, Bool_t reset)
Bool_t ClearObjects(const char *name)
TGo4EventElement * GetInputEvent(const char *stepname) const
TGo4Picture * GetPicture(const char *name)
TGo4WinCond * MakeWinCond(const char *fullname, Double_t xmin, Double_t xmax, const char *HistoName=nullptr)
TGo4Ratemeter * fxRate
Bool_t AddHistogram(TH1 *his, const char *subfolder=nullptr, Bool_t replace=kTRUE)
#define __GO4BUILDVERSION__
Definition: TGo4Version.h:24
Int_t fiAutoSaveCompression
static TGo4Version * Instance()
Definition: TGo4Version.cxx:22
static TGo4Analysis * fxInstance
virtual void ProcessSnifferEvents()
TGo4EventElement * GetEventStructure(const char *name) const
Bool_t AddCanvas(TCanvas *can, const char *subfolder=nullptr)
virtual ~TGo4Analysis()
TGo4ShapedCond * MakeFreeShapeCond(const char *fullname, Int_t npoints, Double_t(*points)[2], const char *HistoName=nullptr)
Bool_t RemoveAnalysisCondition(const char *name)
TNamed * GetObject(const char *name, const char *folder=nullptr)
Bool_t AddObject(TNamed *anything, const char *subfolder=nullptr, Bool_t replace=kTRUE)
TGo4EventElement * GetOutputEvent() const
static void Error(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:320
TGo4AnalysisSniffer * fSniffer
Bool_t Update(Int_t increment=1)
TGo4RollingGraph * MakeRollingGraph(const char *fullname, const char *title, Int_t points=0, Int_t average=1)
virtual Bool_t InitEventClasses()
TGo4ShapedCond * MakeCircleCond(const char *fullname, Int_t npoints, Double_t cx, Double_t cy, Double_t r, const char *HistoName=nullptr)
TH1 * MakeTH1(char type, const char *fullname, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, const char *xtitle=nullptr, const char *ytitle=nullptr)
Bool_t NewStepStore(const char *name, TGo4EventStoreParameter *par)
Bool_t AddHistogram(TH1 *his, const char *subfolder=nullptr, Bool_t replace=kTRUE)
void Print(Option_t *opt="") const override
TGo4EventProcessor * GetEventProcessor() const
virtual Int_t Handle()
static void PrintRate(ULong64_t cnt, double rate)
Definition: TGo4Log.cxx:270
#define GO4TRACE(X)
Definition: TGo4Log.h:25
Bool_t Notify() override
static Int_t fiRunningMode
Bool_t RemoveObject(const char *name, Bool_t del=kTRUE)
static Int_t GetIgnoreLevel()
Definition: TGo4Log.cxx:338
Bool_t SetParameterStatus(const char *name, TGo4ParameterStatus *par, TFolder *parent=nullptr)
Bool_t RemoveHistogram(const char *name, Bool_t del=kTRUE)
void SetAutoSaveOverwrite(Bool_t over=kTRUE)
void PrintParameters(const char *expression=nullptr)
Bool_t MainIsRunning() const
Definition: TGo4Slave.h:95
TGo4AnalysisStep * GetAnalysisStepNum(Int_t number)
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
Bool_t ProtectObjects(const char *name, const Option_t *flags)
static TString subGO4SYS(const char *subdir)
Definition: TGo4Log.cxx:189
Bool_t ProtectObjects(const char *name, const Option_t *flags)
Bool_t SetPicture(const char *name, TGo4Picture *pic)
Bool_t AddTreeHistogram(const char *hisname, const char *treename, const char *varexp, const char *cutexp)
Bool_t IsRunning() const
void SetConfigFileName(const char *name)
Bool_t AddObject(TNamed *anything, const char *subfolder=nullptr, Bool_t replace=kTRUE)
TGo4EventElement * GetEventStructure(const char *name) const
Bool_t RemoveParameter(const char *name)
ULong64_t GetCurrentCount() const
Definition: TGo4Ratemeter.h:54
void PrintHistograms(const char *expression=nullptr)
void UpdateStatusBuffer()
Definition: TGo4Slave.cxx:152
Bool_t fbAutoSaveOverwrite
const char * GetSourceClass() const
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=nullptr)
void SetAutoSaveInterval(Int_t i)
TString fxCurrentInputFileName
Bool_t AddDynamicEntry(TGo4DynamicEntry *entry)
Int_t GetDynListInterval() const
TGo4AnalysisStatus * CreateStatus()
Bool_t SaveStatus(const char *filename=nullptr)
void SetBox(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0)
Bool_t AddEventStructure(TGo4EventElement *ev)
static Bool_t Exists()
void UpdateRate(Int_t counts=1)
static const char * GO4SYS()
Definition: TGo4Log.cxx:156
Bool_t RemoveHistogram(const char *name, Bool_t del=kTRUE)
Bool_t LoadObjects(TFile *statusfile)
Int_t ProcessAnalysisSteps()
enum TGo4Analysis::@0 fxDoWorkingFlag
Bool_t AddEventStore(TGo4EventStore *store)
void PrintParameters(const char *expression=nullptr)
Bool_t LoadStatus(const char *filename=nullptr)
static const Int_t fgiDYNLISTINTERVAL
static void SetRunningMode(int mode)
static TGo4Analysis * Instance()
TGo4ShapedCond * MakeEllipseCond(const char *fullname, Int_t npoints, Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0., const char *HistoName=nullptr)
TGo4EventElement * fxSampleEvent
static const Int_t fgiAUTOSAVECOUNTS
TGo4EventElement * GetInputEvent(const char *stepname) const
Bool_t IsSortedOrder() const
TTree * GetTree(const char *name)
Bool_t SetFirstStep(const char *name)
Bool_t SetPicture(const char *name, TGo4Picture *pic, TFolder *parent=nullptr)
TGo4AnalysisWebStatus * CreateWebStatus()
Bool_t NewStepSource(const char *name, TGo4EventSourceParameter *par)
Bool_t fbAutoSaveFileChange
void SetAutoSaveCompression(Int_t i=5)
TGo4TreeStructure * CreateTreeStructure(TTree *thetree)
TFolder * GetObjectFolder()
Bool_t SetLastStep(const char *name)
Bool_t RemovePicture(const char *name)
TCanvas * GetCanvas(const char *name)
TGo4Analysis(const char *name=nullptr)
Bool_t FindObjectPathName(TObject *obj, TString &pathname, TFolder *fold=nullptr)
Bool_t SetLastStep(const char *name)
void SetAutoSaveInterval(Int_t interval=0)
const char * GetErrMess() const
void SetStatus(TGo4AnalysisStatus *state)