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