GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TXXXAnalysis.cxx
Go to the documentation of this file.
1 // $Id: TXXXAnalysis.cxx 2771 2020-04-16 15:24:45Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "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  fMbsEvent(0),
30  fRawEvent(0),
31  fCalEvent(0)
32 {
33  TGo4Log::Error("Wrong constructor TXXXAnalysis()!");
34 }
35 
36 //***********************************************************
37 // this constructor is called by go4analysis executable
38 TXXXAnalysis::TXXXAnalysis(int argc, char** argv) :
39  TGo4Analysis(argc, argv),
40  fMbsEvent(0),
41  fRawEvent(0),
42  fCalEvent(0),
43  fSize(0),
44  fEvents(0),
45  fLastEvent(0)
46 {
48  TGo4Log::Error("Go4 version mismatch");
49  exit(-1);
50  }
51 
52  TGo4Log::Info("TXXXAnalysis: Create %s", GetName());
53 
54  TString kind, input, out1, out2;
55 
56 // Create step 1 Unpack.
57  TGo4StepFactory* factory1 = new TGo4StepFactory("UnpackFactory");
58  factory1->DefEventProcessor("UnpackProc", "TXXXUnpackProc");// object name, class name
59  factory1->DefOutputEvent("UnpackEvent", "TXXXUnpackEvent"); // object name, class name
60  TGo4AnalysisStep* step1 = new TGo4AnalysisStep("Unpack",factory1,0,0,0);
61  step1->SetErrorStopEnabled(kTRUE);
62  AddAnalysisStep(step1);
63 // These settings will be overwritten by setup.C
64  step1->SetSourceEnabled(kTRUE);
65  step1->SetStoreEnabled(kFALSE);
66  step1->SetProcessEnabled(kTRUE);
67 
68 // Create step 2 Analysis.
69  TGo4StepFactory* factory2 = new TGo4StepFactory("AnalysisFactory");
70  factory2->DefInputEvent("UnpackEvent", "TXXXUnpackEvent"); // object name, class name
71  factory2->DefEventProcessor("AnlProc", "TXXXAnlProc"); // object name, class name
72  factory2->DefOutputEvent("AnlEvent", "TXXXAnlEvent"); // object name, class name
73  TGo4AnalysisStep* step2 = new TGo4AnalysisStep("Analysis",factory2,0,0,0);
74  step2->SetErrorStopEnabled(kTRUE);
75  AddAnalysisStep(step2);
76 // These settings will be overwritten by setup.C
77  step2->SetSourceEnabled(kFALSE);
78  step2->SetStoreEnabled(kFALSE);
79  step2->SetProcessEnabled(kTRUE);
80 
81  // This condition is used in both steps.
82  // Therefore we create it here
83  fWinCon1 = MakeWinCond("wincon1", 50, 2000);
84 
85 
86 }
87 //***********************************************************
89 {
90  TGo4Log::Info("TXXXAnalysis: Delete");
91 }
92 //***********************************************************
93 
94 //-----------------------------------------------------------
96 {
97  TGo4Log::Info("TXXXAnalysis: PreLoop");
98  Print(); // printout the step settings
99  // we update the pointers to the current event structures here:
100  fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Unpack")); // of step "Unpack"
101  fRawEvent = dynamic_cast<TXXXUnpackEvent*> (GetOutputEvent("Unpack"));
102  fCalEvent = dynamic_cast<TXXXAnlEvent*> (GetOutputEvent("Analysis"));
103  fEvents=0;
104  fLastEvent=0;
105 
106  // create histogram for UserEventFunc
107  // At this point, the histogram has been restored
108  // from auto-save file if any.
109  fSize = (TH1D*) MakeTH1('D',"Eventsize", "Event size [b]",160,1,160);
110  return 0;
111 }
112 //-----------------------------------------------------------
114 {
115  TGo4Log::Info("TXXXAnalysis: PostLoop");
116  TGo4Log::Info("Last event: %d, total events: %d", fLastEvent, fEvents);
117  if(fMbsEvent) {
118  // we can check some properties of last event here:
119  fMbsEvent->PrintEvent(); // header and data content
120 
121  // fileheader structure:
123 
124  // mbs buffer header structure:
126  }
127 
128  fMbsEvent = 0; // reset to avoid invalid pointer if analysis is changed in between
129  fRawEvent = 0;
130  fCalEvent = 0;
131  fEvents = 0;
132  return 0;
133 }
134 
135 //-----------------------------------------------------------
137 {
139  Int_t value = 0;
140  Int_t count = 0;
141  if(fMbsEvent) value = fMbsEvent->GetDlen()/2+2; // total longwords
142  fSize->Fill(value); // fill histogram
143  fEvents++;
144  if(fEvents == 1 || IsNewInputFile()) {
145  if(fMbsEvent) {
146  count = fMbsEvent->GetCount();
147  TGo4Log::Info("First event #: %d", count);
149  }
150  }
151  fLastEvent = count;
152  return 0;
153 }
TH1 * MakeTH1(char type, const char *fullname, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, const char *xtitle=0, const char *ytitle=0)
Int_t fLastEvent
Definition: TXXXAnalysis.h:34
static Bool_t CheckVersion(Int_t version)
Definition: TGo4Version.cxx:42
TGo4MbsEvent * fMbsEvent
Definition: TXXXAnalysis.h:31
virtual Int_t UserPreLoop()
void DefEventProcessor(const char *Pname, const char *Pclass)
TXXXAnlEvent * fCalEvent
Definition: TXXXAnalysis.h:37
TGo4WinCond * fWinCon1
Definition: TXXXAnalysis.h:38
virtual void PrintEvent()
friend class TGo4AnalysisStep
TH1D * fSize
Definition: TXXXAnalysis.h:39
TGo4EventElement * GetOutputEvent()
virtual Int_t UserEventFunc()
Bool_t IsNewInputFile() const
void SetSourceEnabled(Bool_t on=kTRUE)
Int_t GetDlen() const
Definition: TGo4MbsEvent.h:135
TGo4EventElement * GetInputEvent(const char *stepname)
void DefOutputEvent(const char *Oname, const char *Oclass)
Int_t GetCount() const
Definition: TGo4MbsEvent.h:152
#define __GO4BUILDVERSION__
Definition: TGo4Version.h:24
virtual const char * GetName() const
void SetStoreEnabled(Bool_t on=kTRUE)
void PrintMbsFileHeader()
virtual void Print(Option_t *opt="") const
void PrintMbsBufferHeader()
virtual Int_t UserPostLoop()
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
static void Error(const char *text,...)
Definition: TGo4Log.cxx:323
static void Info(const char *text,...)
Definition: TGo4Log.cxx:297
virtual ~TXXXAnalysis()
TGo4WinCond * MakeWinCond(const char *fullname, Double_t xmin, Double_t xmax, const char *HistoName=0)