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