GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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//***********************************************************
26{
27 TGo4Log::Error("Wrong constructor TMeshAnalysis()!");
28}
29
30//***********************************************************
31// this constructor is used
32TMeshAnalysis::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:
250 fMbsEvent->PrintMbsFileHeader();
251
252 // mbs buffer header structure:
253 fMbsEvent->PrintMbsBufferHeader();
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:
278 fMbsEvent->PrintMbsBufferHeader();
279 }
280 }
281 fLastEvent = count;
282 return 0;
283}
#define __GO4BUILDVERSION__
Definition TGo4Version.h:24
void SetProcessEnabled(Bool_t on=kTRUE)
Enables or disables the event processing.
void SetStoreEnabled(Bool_t on=kTRUE)
Enables or disables the event store.
void SetSourceEnabled(Bool_t on=kTRUE)
Enables or disables the event source.
TGo4EventElement * GetInputEvent(const char *stepname) const
Returns the input event structure of analysis step.
TGo4Analysis(const char *name=nullptr)
Protected constructor for singleton instance.
friend class TGo4AnalysisStep
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=nullptr)
Puts a new parameter object in corresponding folder.
TH1 * GetHistogram(const char *name)
Search histogram in histogram list (directory).
const char * GetDefaultTestFileName() const
Returns default lmd test file name (in GO4SYS installation directory)
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
Method for user analysis constructor to setup the list of analysis steps.
Bool_t AddHistogram(TH1 *his, const char *subfolder=nullptr, Bool_t replace=kTRUE)
Add external histogram to go4 histogram directory.
const char * GetName() const override
Return analysis name.
void SetStepChecking(Bool_t on=kTRUE)
Enable or disable check of subsequent analysis step for io consistency.
Bool_t IsNewInputFile() const
True if input filelist has changed to a new lmd file.
Basic type for all classes containing information to parameterize the event source.
Basic type for all classes containing information to parametrize the event store.
static void Info(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 1.
Definition TGo4Log.cxx:294
static void Error(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 3.
Definition TGo4Log.cxx:320
Wrapper for the standard gsi event structure as delivered from mbs.
MBS file parameter.
Ready to use step factory.
void DefEventProcessor(const char *Pname, const char *Pclass)
Configure name and class name for event processor.
void DefInputEvent(const char *Iname, const char *Iclass)
Configure name and class name for input event.
void DefOutputEvent(const char *Oname, const char *Oclass)
Configure name and class name for output event.
static Bool_t CheckVersion(Int_t version)
Returns true if Version number matches the argument of the Method.
TMeshParameter * fPar
virtual ~TMeshAnalysis()
Int_t UserPostLoop() override
User defined function called once after processing the main event loop.
Int_t UserEventFunc() override
User defined function which processes the actual analysis.
TGo4MbsEvent * fMbsEvent
Int_t UserPreLoop() override
User defined function called once before processing the main event loop.
This parameter may be used for a global setup of the mesh.