GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TXXXAnalysis.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 "TXXXAnalysis.h"
15 
16 #include "TH1.h"
17 
18 #include "TGo4Log.h"
19 #include "TGo4AnalysisStep.h"
20 #include "TGo4StepFactory.h"
21 
22 #include "TXXXUnpackEvent.h"
23 #include "TXXXAnlEvent.h"
24 #include "TGo4Version.h"
25 
26 //***********************************************************
28  TGo4Analysis()
29 {
30  TGo4Log::Error("Wrong constructor TXXXAnalysis()!");
31 }
32 
33 //***********************************************************
34 // this constructor is called by go4analysis executable
35 TXXXAnalysis::TXXXAnalysis(int argc, char **argv) :
36  TGo4Analysis(argc, argv)
37 {
39  TGo4Log::Error("Go4 version mismatch");
40  exit(-1);
41  }
42 
43  TGo4Log::Info("TXXXAnalysis: Create %s", GetName());
44 
45 // Create step 1 Unpack.
46  TGo4StepFactory* factory1 = new TGo4StepFactory("UnpackFactory");
47  factory1->DefEventProcessor("UnpackProc", "TXXXUnpackProc");// object name, class name
48  factory1->DefOutputEvent("UnpackEvent", "TXXXUnpackEvent"); // object name, class name
49  TGo4AnalysisStep *step1 = new TGo4AnalysisStep("Unpack", factory1, nullptr, nullptr, nullptr);
50  step1->SetErrorStopEnabled(kTRUE);
51  AddAnalysisStep(step1);
52 // These settings will be overwritten by setup.C
53  step1->SetSourceEnabled(kTRUE);
54  step1->SetStoreEnabled(kFALSE);
55  step1->SetProcessEnabled(kTRUE);
56 
57 // Create step 2 Analysis.
58  TGo4StepFactory* factory2 = new TGo4StepFactory("AnalysisFactory");
59  factory2->DefInputEvent("UnpackEvent", "TXXXUnpackEvent"); // object name, class name
60  factory2->DefEventProcessor("AnlProc", "TXXXAnlProc"); // object name, class name
61  factory2->DefOutputEvent("AnlEvent", "TXXXAnlEvent"); // object name, class name
62  TGo4AnalysisStep *step2 = new TGo4AnalysisStep("Analysis", factory2, nullptr, nullptr, nullptr);
63  step2->SetErrorStopEnabled(kTRUE);
64  AddAnalysisStep(step2);
65 // These settings will be overwritten by setup.C
66  step2->SetSourceEnabled(kFALSE);
67  step2->SetStoreEnabled(kFALSE);
68  step2->SetProcessEnabled(kTRUE);
69 
70  // This condition is used in both steps.
71  // Therefore we create it here
72  fWinCon1 = MakeWinCond("wincon1", 50, 2000);
73 }
74 
75 //-----------------------------------------------------------
77 {
78  TGo4Log::Info("TXXXAnalysis: Delete");
79 }
80 
81 //-----------------------------------------------------------
83 {
84  TGo4Log::Info("TXXXAnalysis: PreLoop");
85  Print(); // printout the step settings
86  // we update the pointers to the current event structures here:
87  fMbsEvent = dynamic_cast<TGo4MbsEvent *> (GetInputEvent("Unpack")); // of step "Unpack"
88  fRawEvent = dynamic_cast<TXXXUnpackEvent *> (GetOutputEvent("Unpack"));
89  fCalEvent = dynamic_cast<TXXXAnlEvent *> (GetOutputEvent("Analysis"));
90  fEvents = 0;
91  fLastEvent = 0;
92 
93  // create histogram for UserEventFunc
94  // At this point, the histogram has been restored
95  // from auto-save file if any.
96  fSize = MakeTH1('D', "Eventsize", "Event size [b]", 160, 1., 160.);
97  return 0;
98 }
99 
100 //-----------------------------------------------------------
102 {
103  TGo4Log::Info("TXXXAnalysis: PostLoop");
104  TGo4Log::Info("Last event: %d, total events: %d", fLastEvent, fEvents);
105  if(fMbsEvent) {
106  // we can check some properties of last event here:
107  fMbsEvent->PrintEvent(); // header and data content
108 
109  // fileheader structure:
111 
112  // mbs buffer header structure:
114  }
115 
116  fMbsEvent = nullptr; // reset to avoid invalid pointer if analysis is changed in between
117  fRawEvent = nullptr;
118  fCalEvent = nullptr;
119  fEvents = 0;
120  return 0;
121 }
122 
123 //-----------------------------------------------------------
125 {
127  Int_t value = 0;
128  Int_t count = 0;
129  if(fMbsEvent) value = fMbsEvent->GetDlen()/2+2; // total longwords
130  fSize->Fill(value); // fill histogram
131  fEvents++;
132  if(fEvents == 1 || IsNewInputFile()) {
133  if(fMbsEvent) {
134  count = fMbsEvent->GetCount();
135  TGo4Log::Info("First event #: %d", count);
137  }
138  }
139  fLastEvent = count;
140  return 0;
141 }
const char * GetName() const override
void Print(Option_t *opt="") const override
Int_t UserPreLoop() override
Int_t fLastEvent
Definition: TXXXAnalysis.h:34
static Bool_t CheckVersion(Int_t version)
Definition: TGo4Version.cxx:42
static void Info(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:294
TGo4MbsEvent * fMbsEvent
Definition: TXXXAnalysis.h:31
void DefEventProcessor(const char *Pname, const char *Pclass)
TXXXAnlEvent * fCalEvent
Definition: TXXXAnalysis.h:37
TGo4WinCond * fWinCon1
Definition: TXXXAnalysis.h:38
friend class TGo4AnalysisStep
void SetSourceEnabled(Bool_t on=kTRUE)
Int_t UserPostLoop() override
Bool_t IsNewInputFile() const
void DefOutputEvent(const char *Oname, const char *Oclass)
void PrintEvent() override
Int_t UserEventFunc() override
TGo4EventElement * GetInputEvent(const char *stepname) const
TGo4WinCond * MakeWinCond(const char *fullname, Double_t xmin, Double_t xmax, const char *HistoName=nullptr)
#define __GO4BUILDVERSION__
Definition: TGo4Version.h:24
void SetStoreEnabled(Bool_t on=kTRUE)
void PrintMbsFileHeader()
Int_t GetCount() const
Definition: TGo4MbsEvent.h:151
TGo4EventElement * GetOutputEvent() const
static void Error(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:320
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)
void PrintMbsBufferHeader()
void SetProcessEnabled(Bool_t on=kTRUE)
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
void SetErrorStopEnabled(Bool_t on)
void DefInputEvent(const char *Iname, const char *Iclass)
TXXXUnpackEvent * fRawEvent
Definition: TXXXAnalysis.h:36
Int_t GetDlen() const
Definition: TGo4MbsEvent.h:134
virtual ~TXXXAnalysis()