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