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