GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TMeshAnalysis.cxx
Go to the documentation of this file.
1 // $Id: TMeshAnalysis.cxx 1905 2016-04-27 07:54:31Z 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 "TMeshAnalysis.h"
15 
16 #include <stdlib.h>
17 
18 extern "C" {
19  #include "s_filhe_swap.h"
20  #include "s_bufhe_swap.h"
21  #include "f_ut_utime.h"
22 }
23 
24 #include "TH1.h"
25 
26 #include "TGo4Log.h"
27 #include "TGo4Version.h"
28 #include "TMeshParameter.h"
29 #include "Go4EventServer.h"
30 #include "TGo4StepFactory.h"
31 #include "TGo4AnalysisStep.h"
32 
33 //***********************************************************
35  TGo4Analysis(),
36  fMbsEvent(0),
37  fSize(0),
38  fEvents(0),
39  fLastEvent(0)
40 {
41  TGo4Log::Error("Wrong constructor TMeshAnalysis()!");
42 }
43 //***********************************************************
44 // this constructor is used
45 TMeshAnalysis::TMeshAnalysis(int argc, char** argv) :
46  TGo4Analysis(argc, argv),
47  fMbsEvent(0),
48  fSize(0),
49  fEvents(0),
50  fLastEvent(0)
51 {
53  TGo4Log::Error("Go4 version mismatch");
54  exit(-1);
55  }
56 
57  TGo4Log::Info("Create TMeshAnalysis %s", GetName());
58 
59  SetStepChecking(kFALSE); // necessary for non-subsequent mesh analysis
60 
61  // first step definitions:
62  TGo4StepFactory* factory1 = new TGo4StepFactory("UnpackFactory");
63  factory1->DefOutputEvent("RawEvent", "TMeshRawEvent");
64  factory1->DefEventProcessor("Unpacker","TMeshUnpackProc");
66  TGo4EventStoreParameter* store1 = new TGo4FileStoreParameter("MeshRawEvent");
67  TGo4AnalysisStep* step1 = new TGo4AnalysisStep("Unpack",factory1,source1,store1,0);
68  AddAnalysisStep(step1);
69  step1->SetSourceEnabled(kTRUE);
70  step1->SetStoreEnabled(kFALSE);
71  step1->SetProcessEnabled(kTRUE);
72 
74  TGo4StepFactory* factory2 = new TGo4StepFactory("RawProvider1Factory");
75  // factory2->DefInputEvent("RawEvent", "TMeshRawEvent"); // read full raw event without partial io
76  // factory2->DefEventProcessor("RawEvent_1","TMeshProviderProc"); // processorname must match name of input event + "_"
77  factory2->DefInputEvent("RawEvent.fxSub1", "TMeshRawEvent"); // try partial io: eventname must match branch name!
78  factory2->DefEventProcessor("RawEvent.fxSub1_1","TMeshProviderProc"); // processorname must match name of input event +"_"
79  factory2->DefOutputEvent("Dummy", "TMeshDummyEvent");
80  TGo4AnalysisStep* step2 = new TGo4AnalysisStep("Input1Provider",factory2,0,0,0);
81  AddAnalysisStep(step2);
82  step2->SetSourceEnabled(kFALSE);
83  step2->SetStoreEnabled(kFALSE);
84  step2->SetProcessEnabled(kTRUE);
85 
87  TGo4StepFactory* factory3 = new TGo4StepFactory("RawProvider2Factory");
88  // factory3->DefInputEvent("RawEvent", "TMeshRawEvent"); // read full raw event without partial io
89  // factory3->DefEventProcessor("RawEvent_2","TMeshProviderProc"); // name must match name of input event!
90  factory3->DefInputEvent("RawEvent.fxSub2", "TMeshRawEvent"); // build full raw event, but fill only subbranch as defined in name
91  factory3->DefEventProcessor("RawEvent.fxSub2_1","TMeshProviderProc");
92  factory3->DefOutputEvent("Dummy", "TMeshDummyEvent");
93  TGo4AnalysisStep* step3 = new TGo4AnalysisStep("Input2Provider",factory3,0,0,0);
94  AddAnalysisStep(step3);
95  step3->SetSourceEnabled(kFALSE);
96  step3->SetStoreEnabled(kFALSE);
97  step3->SetProcessEnabled(kTRUE);
98 
100  TGo4StepFactory* factory4 = new TGo4StepFactory("RawProvider3Factory");
101  // factory4->DefInputEvent("RawEvent", "TMeshRawEvent"); // read full raw event without partial io
102  // factory4->DefEventProcessor("RawEvent_3","TMeshProviderProc"); // name must match name of input event!
103  factory4->DefInputEvent("RawEvent.fxSub3", "TMeshRawEvent"); // build full raw event, but fill only subbranch as defined in name
104  factory4->DefEventProcessor("RawEvent.fxSub3_1","TMeshProviderProc");
105  factory4->DefOutputEvent("Dummy", "TMeshDummyEvent");
106  // provider factories without definition of output event and proc
107  TGo4AnalysisStep* step4 = new TGo4AnalysisStep("Input3Provider",factory4,0,0,0);
108  AddAnalysisStep(step4);
109  step4->SetSourceEnabled(kFALSE);
110  step4->SetStoreEnabled(kFALSE);
111  step4->SetProcessEnabled(kTRUE);
112 
114  TGo4StepFactory* factory5 = new TGo4StepFactory("Branch1Factory");
115  factory5->DefOutputEvent("EventB1", "TMeshB1OutputEvent");
116  factory5->DefEventProcessor("Branch1","TMeshB1AnlProc");
117  TGo4EventStoreParameter* store5 = new TGo4FileStoreParameter("MeshB1");
118  TGo4AnalysisStep* step5 = new TGo4AnalysisStep("Exec1",factory5,0,store5,0);
119  // no own event source for execution step
120  AddAnalysisStep(step5);
121  step5->SetSourceEnabled(kFALSE);
122  step5->SetStoreEnabled(kTRUE);
123  step5->SetProcessEnabled(kTRUE);
124 
126  TGo4StepFactory* factory6 = new TGo4StepFactory("Branch2Factory");
127  factory6->DefOutputEvent("EventB2", "TMeshB2OutputEvent");
128  factory6->DefEventProcessor("Branch2","TMeshB2AnlProc");
129  TGo4EventStoreParameter* store6 = new TGo4FileStoreParameter("MeshB2");
130  TGo4AnalysisStep* step6 = new TGo4AnalysisStep("Exec2",factory6,0,store6,0);
131  // no own event source for execution step
132  AddAnalysisStep(step6);
133  step6->SetSourceEnabled(kFALSE);
134  step6->SetStoreEnabled(kTRUE);
135  step6->SetProcessEnabled(kTRUE);
136 
138  TGo4StepFactory* factory7 = new TGo4StepFactory("Branch3Factory");
139  factory7->DefOutputEvent("EventB3", "TMeshB3OutputEvent");
140  factory7->DefEventProcessor("Branch3","TMeshB3AnlProc");
141  TGo4EventStoreParameter* store7 = new TGo4FileStoreParameter("MeshB3");
142  TGo4AnalysisStep* step7 = new TGo4AnalysisStep("Exec3",factory7,0,store7,0);
143  // no own event source for execution step
144  AddAnalysisStep(step7);
145  step7->SetSourceEnabled(kFALSE);
146  step7->SetStoreEnabled(kTRUE);
147  step7->SetProcessEnabled(kTRUE);
148 
149 
151  TGo4StepFactory* factory8 = new TGo4StepFactory("OutProvider1Factory");
152  factory8->DefInputEvent("EventB1", "TMeshB1OutputEvent");
153  factory8->DefEventProcessor("EventB1_1","TMeshProviderProc"); // name must match name of input event!
154  factory8->DefOutputEvent("Dummy", "TMeshDummyEvent");
155  TGo4AnalysisStep* step8 = new TGo4AnalysisStep("Output1Provider",factory8,0,0,0);
156  AddAnalysisStep(step8);
157  step8->SetSourceEnabled(kFALSE);
158  step8->SetStoreEnabled(kFALSE);
159  step8->SetProcessEnabled(kTRUE);
160 
162  TGo4StepFactory* factory9 = new TGo4StepFactory("OutProvider2Factory");
163  factory9->DefInputEvent("EventB2", "TMeshB2OutputEvent");
164  factory9->DefEventProcessor("EventB2_1","TMeshProviderProc"); // name must match name of input event!
165  factory9->DefOutputEvent("Dummy", "TMeshDummyEvent");
166  TGo4AnalysisStep* step9 = new TGo4AnalysisStep("Output2Provider",factory9,0,0,0);
167  AddAnalysisStep(step9);
168  step9->SetSourceEnabled(kFALSE);
169  step9->SetStoreEnabled(kFALSE);
170  step9->SetProcessEnabled(kTRUE);
171 
173  TGo4StepFactory* factory10 = new TGo4StepFactory("OutProvider3Factory");
174  factory10->DefInputEvent("EventB3", "TMeshB3OutputEvent");
175  factory10->DefEventProcessor("EventB3_1","TMeshProviderProc"); // name must match name of input event!
176  factory10->DefOutputEvent("Dummy", "TMeshDummyEvent");
177  TGo4AnalysisStep* step10 = new TGo4AnalysisStep("Output3Provider",factory10,0,0,0);
178  AddAnalysisStep(step10);
179  step10->SetSourceEnabled(kFALSE);
180  step10->SetStoreEnabled(kFALSE);
181  step10->SetProcessEnabled(kTRUE);
182 
184  TGo4StepFactory* factory11 = new TGo4StepFactory("Branch12Factory");
185  factory11->DefOutputEvent("EventB12", "TMeshB12OutputEvent");
186  factory11->DefEventProcessor("Branch12","TMeshB12AnlProc");
187  TGo4EventStoreParameter* store11 = new TGo4FileStoreParameter("MeshB12");
188  TGo4AnalysisStep* step11 = new TGo4AnalysisStep("Exec12",factory11,0,store11,0);
189  // no own event source for execution step
190  AddAnalysisStep(step11);
191  step11->SetSourceEnabled(kFALSE);
192  step11->SetStoreEnabled(kTRUE);
193  step11->SetProcessEnabled(kTRUE);
194 
196  TGo4StepFactory* factory12 = new TGo4StepFactory("OutProvider12Factory");
197  factory12->DefInputEvent("EventB12", "TMeshB12OutputEvent");
198  factory12->DefEventProcessor("EventB12_1","TMeshProviderProc"); // name must match name of input event!
199  factory12->DefOutputEvent("Dummy", "TMeshDummyEvent");
200  TGo4AnalysisStep* step12 = new TGo4AnalysisStep("Output12Provider",factory12,0,0,0);
201  AddAnalysisStep(step12);
202  step12->SetSourceEnabled(kFALSE);
203  step12->SetStoreEnabled(kFALSE);
204  step12->SetProcessEnabled(kTRUE);
205 
207  TGo4StepFactory* factory13 = new TGo4StepFactory("Branch13Factory");
208  factory13->DefOutputEvent("FinalEvent", "TMeshFinalEvent");
209  factory13->DefEventProcessor("Collector","TMeshFinalProc");
210  TGo4EventStoreParameter* store13 = new TGo4FileStoreParameter("MeshFinal");
211  TGo4AnalysisStep* step13 = new TGo4AnalysisStep("Final",factory13,0,store13,0);
212  // no own event source for execution step
213  AddAnalysisStep(step13);
214  step13->SetSourceEnabled(kFALSE);
215  step13->SetStoreEnabled(kTRUE);
216  step13->SetProcessEnabled(kTRUE);
217 
218 
219  // uncomment following line to define custom passwords for analysis server
220  // DefineServerPasswords("Meshadmin", "Meshctrl", "Meshview");
221 
222 
224  // At this point, autosave file has not yet been read!
225  // Therefore parameter values set here will be overwritten
226  // if an autosave file is there.
227  fPar = new TMeshParameter("MeshSetup");
229 }
230 
231 //***********************************************************
233 {
234  TGo4Log::Info("TMeshAnalysis: Delete");
235 }
236 //***********************************************************
237 
238 //-----------------------------------------------------------
240 {
241  TGo4Log::Info("TMeshAnalysis: PreLoop");
242  // we update the pointers to the current event structures here:
243  fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Unpack")); // of step "Unpack"
244  fEvents=0;
245  fLastEvent=0;
246 
247 
248 
249  // create histogram for UserEventFunc
250  // At this point, the histogram has been restored from autosave file if any.
251  fSize=(TH1D*)GetHistogram("Eventsize");
252  if(fSize==0)
253  { // no autosave read, create new and register
254  fSize = new TH1D ("Eventsize", "Event size [b]",160,1,160);
256  }
257  // we use a fitter envelope parameters to exchange fit results:
258 
259 
260  return 0;
261 }
262 //-----------------------------------------------------------
264 {
265  TGo4Log::Info("TMeshAnalysis: PostLoop");
266  TGo4Log::Info("Last event: %d Total events: %d", fLastEvent, fEvents);
267  if(fMbsEvent)
268  {
269  // we can check some properties of last event here:
270  //fMbsEvent->PrintEvent(); // header and data content
271 
272  // fileheader structure:
274 
275  // mbs buffer header structure:
277 
278  }
279 
281 
282  fMbsEvent = 0; // reset to avoid invalid pointer if analysis is changed in between
283  fEvents = 0;
284  return 0;
285 }
286 
287 //-----------------------------------------------------------
289 {
291  Int_t value = 0;
292  Int_t count = 0;
293  if(fMbsEvent) value = fMbsEvent->GetDlen()/2+2; // total longwords
294  fSize->Fill(value); // fill histogram
295  fEvents++;
296  if(fEvents == 1 || IsNewInputFile()) {
297  if(fMbsEvent) {
298  count = fMbsEvent->GetCount();
299  TGo4Log::Info("First event #: %d", count);
300  // mbs buffer header structure:
302  }
303  }
304  fLastEvent = count;
305  return 0;
306 }
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=0)
virtual ~TMeshAnalysis()
static Bool_t CheckVersion(Int_t version)
Definition: TGo4Version.cxx:42
void DefEventProcessor(const char *Pname, const char *Pclass)
void SetStepChecking(Bool_t on=kTRUE)
friend class TGo4AnalysisStep
Bool_t AddHistogram(TH1 *his, const char *subfolder=0, Bool_t replace=kTRUE)
Bool_t IsNewInputFile() const
void SetSourceEnabled(Bool_t on=kTRUE)
Int_t GetDlen() const
Definition: TGo4MbsEvent.h:132
TH1 * GetHistogram(const char *name)
TGo4EventElement * GetInputEvent(const char *stepname)
void DefOutputEvent(const char *Oname, const char *Oclass)
TGo4MbsEvent * fMbsEvent
Definition: TMeshAnalysis.h:34
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()
void PrintMbsBufferHeader()
virtual Int_t UserPreLoop()
void SetProcessEnabled(Bool_t on=kTRUE)
virtual Int_t UserEventFunc()
const char * GetDefaultTestFileName() const
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
TMeshParameter * fPar
Definition: TMeshAnalysis.h:33
void DefInputEvent(const char *Iname, const char *Iclass)
virtual Int_t UserPostLoop()
static void Error(const char *text,...)
Definition: TGo4Log.cxx:309
static void Info(const char *text,...)
Definition: TGo4Log.cxx:283