GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TXXXAnalysis.cxx
Go to the documentation of this file.
1 // $Id: TXXXAnalysis.cxx 1385 2015-02-13 09:00:26Z adamczew $
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 f�r 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 <stdlib.h>
17 
18 #include "TH1.h"
19 #include "TFile.h"
20 #include "TSystem.h"
21 
22 extern "C" {
23  #include "s_filhe_swap.h"
24  #include "s_bufhe_swap.h"
25  #include "f_ut_utime.h"
26 }
27 
28 #include "TGo4Log.h"
29 #include "TGo4Fitter.h"
30 #include "TGo4FitterEnvelope.h"
31 #include "TGo4AnalysisStep.h"
32 #include "TGo4StepFactory.h"
33 #include "TXXXParameter.h"
34 #include "TXXXUnpackEvent.h"
35 #include "TXXXAnlEvent.h"
36 #include "TGo4Version.h"
37 
38 #include "Go4EventServer.h"
39 
40 //***********************************************************
42  TGo4Analysis(),
43  fMbsEvent(0),
44  fRawEvent(0),
45  fCalEvent(0)
46 {
47  TGo4Log::Error("Wrong constructor TXXXAnalysis()!");
48 }
49 
50 //***********************************************************
51 // this constructor is called by go4analysis executable
52 TXXXAnalysis::TXXXAnalysis(int argc, char** argv) :
53  TGo4Analysis(argc, argv),
54  fMbsEvent(0),
55  fRawEvent(0),
56  fCalEvent(0),
57  fSize(0),
58  fEvents(0),
59  fLastEvent(0)
60 {
62  TGo4Log::Error("Go4 version mismatch");
63  exit(-1);
64  }
65 
66  TGo4Log::Info("TXXXAnalysis: Create %s", GetName());
67 
68  TString kind, input, out1, out2;
69 
70 // Create step 1 Unpack.
71  TGo4StepFactory* factory1 = new TGo4StepFactory("UnpackFactory");
72  factory1->DefEventProcessor("UnpackProc", "TXXXUnpackProc");// object name, class name
73  factory1->DefOutputEvent("UnpackEvent", "TXXXUnpackEvent"); // object name, class name
74  TGo4AnalysisStep* step1 = new TGo4AnalysisStep("Unpack",factory1,0,0,0);
75  step1->SetErrorStopEnabled(kTRUE);
76  AddAnalysisStep(step1);
77 // These settings will be overwritten by setup.C
78  step1->SetSourceEnabled(kTRUE);
79  step1->SetStoreEnabled(kFALSE);
80  step1->SetProcessEnabled(kTRUE);
81 
82 // Create step 2 Analysis.
83  TGo4StepFactory* factory2 = new TGo4StepFactory("AnalysisFactory");
84  factory2->DefInputEvent("UnpackEvent", "TXXXUnpackEvent"); // object name, class name
85  factory2->DefEventProcessor("AnlProc", "TXXXAnlProc"); // object name, class name
86  factory2->DefOutputEvent("AnlEvent", "TXXXAnlEvent"); // object name, class name
87  TGo4AnalysisStep* step2 = new TGo4AnalysisStep("Analysis",factory2,0,0,0);
88  step2->SetErrorStopEnabled(kTRUE);
89  AddAnalysisStep(step2);
90 // These settings will be overwritten by setup.C
91  step2->SetSourceEnabled(kFALSE);
92  step2->SetStoreEnabled(kFALSE);
93  step2->SetProcessEnabled(kTRUE);
94 
95  // This condition is used in both steps.
96  // Therefore we create it here
97  fWinCon1 = MakeWinCond("wincon1", 50, 2000);
98 
99 
100 }
101 //***********************************************************
103 {
104  TGo4Log::Info("TXXXAnalysis: Delete");
105 }
106 //***********************************************************
107 
108 //-----------------------------------------------------------
110 {
111  TGo4Log::Info("TXXXAnalysis: PreLoop");
112  Print(); // printout the step settings
113  // we update the pointers to the current event structures here:
114  fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Unpack")); // of step "Unpack"
115  fRawEvent = dynamic_cast<TXXXUnpackEvent*> (GetOutputEvent("Unpack"));
116  fCalEvent = dynamic_cast<TXXXAnlEvent*> (GetOutputEvent("Analysis"));
117  fEvents=0;
118  fLastEvent=0;
119 
120  // create histogram for UserEventFunc
121  // At this point, the histogram has been restored
122  // from auto-save file if any.
123  fSize = (TH1D*) MakeTH1('D',"Eventsize", "Event size [b]",160,1,160);
124  return 0;
125 }
126 //-----------------------------------------------------------
128 {
129  TGo4Log::Info("TXXXAnalysis: PostLoop");
130  TGo4Log::Info("Last event: %d, total events: %d", fLastEvent, fEvents);
131  if(fMbsEvent) {
132  // we can check some properties of last event here:
133  fMbsEvent->PrintEvent(); // header and data content
134 
135  // fileheader structure:
137 
138  // mbs buffer header structure:
140  }
141 
142  fMbsEvent = 0; // reset to avoid invalid pointer if analysis is changed in between
143  fRawEvent = 0;
144  fCalEvent = 0;
145  fEvents = 0;
146  return 0;
147 }
148 
149 //-----------------------------------------------------------
151 {
153  Int_t value = 0;
154  Int_t count = 0;
155  if(fMbsEvent) value = fMbsEvent->GetDlen()/2+2; // total longwords
156  fSize->Fill(value); // fill histogram
157  fEvents++;
158  if(fEvents == 1 || IsNewInputFile()) {
159  if(fMbsEvent) {
160  count = fMbsEvent->GetCount();
161  TGo4Log::Info("First event #: %d", count);
163  }
164  }
165  fLastEvent = count;
166  return 0;
167 }
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:132
TGo4EventElement * GetInputEvent(const char *stepname)
void DefOutputEvent(const char *Oname, const char *Oclass)
Int_t GetCount() const
Definition: TGo4MbsEvent.h:149
#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:309
static void Info(const char *text,...)
Definition: TGo4Log.cxx:283
virtual ~TXXXAnalysis()
TGo4WinCond * MakeWinCond(const char *fullname, Double_t xmin, Double_t xmax, const char *HistoName=0)