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