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