00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TMeshAnalysis.h"
00015
00016 #include <stdlib.h>
00017
00018 extern "C" {
00019 #include "s_filhe_swap.h"
00020 #include "s_bufhe_swap.h"
00021 #include "f_ut_utime.h"
00022 }
00023
00024 #include "TH1.h"
00025
00026 #include "TGo4Log.h"
00027 #include "TGo4Version.h"
00028 #include "TMeshParameter.h"
00029 #include "Go4EventServer.h"
00030 #include "TGo4StepFactory.h"
00031 #include "TGo4AnalysisStep.h"
00032
00033
00034 TMeshAnalysis::TMeshAnalysis() :
00035 TGo4Analysis(),
00036 fMbsEvent(0),
00037 fSize(0),
00038 fEvents(0),
00039 fLastEvent(0)
00040 {
00041 TGo4Log::Error("Wrong constructor TMeshAnalysis()!");
00042 }
00043
00044
00045 TMeshAnalysis::TMeshAnalysis(int argc, char** argv) :
00046 TGo4Analysis(argc, argv),
00047 fMbsEvent(0),
00048 fSize(0),
00049 fEvents(0),
00050 fLastEvent(0)
00051 {
00052 if (!TGo4Version::CheckVersion(__GO4BUILDVERSION__)) {
00053 TGo4Log::Error("Go4 version mismatch");
00054 exit(-1);
00055 }
00056
00057 TGo4Log::Info("Create TMeshAnalysis %s", GetName());
00058
00059 SetStepChecking(kFALSE);
00060
00061
00062 TGo4StepFactory* factory1 = new TGo4StepFactory("UnpackFactory");
00063 factory1->DefOutputEvent("RawEvent", "TMeshRawEvent");
00064 factory1->DefEventProcessor("Unpacker","TMeshUnpackProc");
00065 TGo4EventSourceParameter* source1 = new TGo4MbsFileParameter("/GSI/lea/gauss.lmd");
00066 TGo4EventStoreParameter* store1 = new TGo4FileStoreParameter("MeshRawEvent");
00067 TGo4AnalysisStep* step1 = new TGo4AnalysisStep("Unpack",factory1,source1,store1,0);
00068 AddAnalysisStep(step1);
00069 step1->SetSourceEnabled(kTRUE);
00070 step1->SetStoreEnabled(kFALSE);
00071 step1->SetProcessEnabled(kTRUE);
00072
00074 TGo4StepFactory* factory2 = new TGo4StepFactory("RawProvider1Factory");
00075
00076
00077 factory2->DefInputEvent("RawEvent.fxSub1", "TMeshRawEvent");
00078 factory2->DefEventProcessor("RawEvent.fxSub1_1","TMeshProviderProc");
00079 factory2->DefOutputEvent("Dummy", "TMeshDummyEvent");
00080 TGo4AnalysisStep* step2 = new TGo4AnalysisStep("Input1Provider",factory2,0,0,0);
00081 AddAnalysisStep(step2);
00082 step2->SetSourceEnabled(kFALSE);
00083 step2->SetStoreEnabled(kFALSE);
00084 step2->SetProcessEnabled(kTRUE);
00085
00087 TGo4StepFactory* factory3 = new TGo4StepFactory("RawProvider2Factory");
00088
00089
00090 factory3->DefInputEvent("RawEvent.fxSub2", "TMeshRawEvent");
00091 factory3->DefEventProcessor("RawEvent.fxSub2_1","TMeshProviderProc");
00092 factory3->DefOutputEvent("Dummy", "TMeshDummyEvent");
00093 TGo4AnalysisStep* step3 = new TGo4AnalysisStep("Input2Provider",factory3,0,0,0);
00094 AddAnalysisStep(step3);
00095 step3->SetSourceEnabled(kFALSE);
00096 step3->SetStoreEnabled(kFALSE);
00097 step3->SetProcessEnabled(kTRUE);
00098
00100 TGo4StepFactory* factory4 = new TGo4StepFactory("RawProvider3Factory");
00101
00102
00103 factory4->DefInputEvent("RawEvent.fxSub3", "TMeshRawEvent");
00104 factory4->DefEventProcessor("RawEvent.fxSub3_1","TMeshProviderProc");
00105 factory4->DefOutputEvent("Dummy", "TMeshDummyEvent");
00106
00107 TGo4AnalysisStep* step4 = new TGo4AnalysisStep("Input3Provider",factory4,0,0,0);
00108 AddAnalysisStep(step4);
00109 step4->SetSourceEnabled(kFALSE);
00110 step4->SetStoreEnabled(kFALSE);
00111 step4->SetProcessEnabled(kTRUE);
00112
00114 TGo4StepFactory* factory5 = new TGo4StepFactory("Branch1Factory");
00115 factory5->DefOutputEvent("EventB1", "TMeshB1OutputEvent");
00116 factory5->DefEventProcessor("Branch1","TMeshB1AnlProc");
00117 TGo4EventStoreParameter* store5 = new TGo4FileStoreParameter("MeshB1");
00118 TGo4AnalysisStep* step5 = new TGo4AnalysisStep("Exec1",factory5,0,store5,0);
00119
00120 AddAnalysisStep(step5);
00121 step5->SetSourceEnabled(kFALSE);
00122 step5->SetStoreEnabled(kTRUE);
00123 step5->SetProcessEnabled(kTRUE);
00124
00126 TGo4StepFactory* factory6 = new TGo4StepFactory("Branch2Factory");
00127 factory6->DefOutputEvent("EventB2", "TMeshB2OutputEvent");
00128 factory6->DefEventProcessor("Branch2","TMeshB2AnlProc");
00129 TGo4EventStoreParameter* store6 = new TGo4FileStoreParameter("MeshB2");
00130 TGo4AnalysisStep* step6 = new TGo4AnalysisStep("Exec2",factory6,0,store6,0);
00131
00132 AddAnalysisStep(step6);
00133 step6->SetSourceEnabled(kFALSE);
00134 step6->SetStoreEnabled(kTRUE);
00135 step6->SetProcessEnabled(kTRUE);
00136
00138 TGo4StepFactory* factory7 = new TGo4StepFactory("Branch3Factory");
00139 factory7->DefOutputEvent("EventB3", "TMeshB3OutputEvent");
00140 factory7->DefEventProcessor("Branch3","TMeshB3AnlProc");
00141 TGo4EventStoreParameter* store7 = new TGo4FileStoreParameter("MeshB3");
00142 TGo4AnalysisStep* step7 = new TGo4AnalysisStep("Exec3",factory7,0,store7,0);
00143
00144 AddAnalysisStep(step7);
00145 step7->SetSourceEnabled(kFALSE);
00146 step7->SetStoreEnabled(kTRUE);
00147 step7->SetProcessEnabled(kTRUE);
00148
00149
00151 TGo4StepFactory* factory8 = new TGo4StepFactory("OutProvider1Factory");
00152 factory8->DefInputEvent("EventB1", "TMeshB1OutputEvent");
00153 factory8->DefEventProcessor("EventB1_1","TMeshProviderProc");
00154 factory8->DefOutputEvent("Dummy", "TMeshDummyEvent");
00155 TGo4AnalysisStep* step8 = new TGo4AnalysisStep("Output1Provider",factory8,0,0,0);
00156 AddAnalysisStep(step8);
00157 step8->SetSourceEnabled(kFALSE);
00158 step8->SetStoreEnabled(kFALSE);
00159 step8->SetProcessEnabled(kTRUE);
00160
00162 TGo4StepFactory* factory9 = new TGo4StepFactory("OutProvider2Factory");
00163 factory9->DefInputEvent("EventB2", "TMeshB2OutputEvent");
00164 factory9->DefEventProcessor("EventB2_1","TMeshProviderProc");
00165 factory9->DefOutputEvent("Dummy", "TMeshDummyEvent");
00166 TGo4AnalysisStep* step9 = new TGo4AnalysisStep("Output2Provider",factory9,0,0,0);
00167 AddAnalysisStep(step9);
00168 step9->SetSourceEnabled(kFALSE);
00169 step9->SetStoreEnabled(kFALSE);
00170 step9->SetProcessEnabled(kTRUE);
00171
00173 TGo4StepFactory* factory10 = new TGo4StepFactory("OutProvider3Factory");
00174 factory10->DefInputEvent("EventB3", "TMeshB3OutputEvent");
00175 factory10->DefEventProcessor("EventB3_1","TMeshProviderProc");
00176 factory10->DefOutputEvent("Dummy", "TMeshDummyEvent");
00177 TGo4AnalysisStep* step10 = new TGo4AnalysisStep("Output3Provider",factory10,0,0,0);
00178 AddAnalysisStep(step10);
00179 step10->SetSourceEnabled(kFALSE);
00180 step10->SetStoreEnabled(kFALSE);
00181 step10->SetProcessEnabled(kTRUE);
00182
00184 TGo4StepFactory* factory11 = new TGo4StepFactory("Branch12Factory");
00185 factory11->DefOutputEvent("EventB12", "TMeshB12OutputEvent");
00186 factory11->DefEventProcessor("Branch12","TMeshB12AnlProc");
00187 TGo4EventStoreParameter* store11 = new TGo4FileStoreParameter("MeshB12");
00188 TGo4AnalysisStep* step11 = new TGo4AnalysisStep("Exec12",factory11,0,store11,0);
00189
00190 AddAnalysisStep(step11);
00191 step11->SetSourceEnabled(kFALSE);
00192 step11->SetStoreEnabled(kTRUE);
00193 step11->SetProcessEnabled(kTRUE);
00194
00196 TGo4StepFactory* factory12 = new TGo4StepFactory("OutProvider12Factory");
00197 factory12->DefInputEvent("EventB12", "TMeshB12OutputEvent");
00198 factory12->DefEventProcessor("EventB12_1","TMeshProviderProc");
00199 factory12->DefOutputEvent("Dummy", "TMeshDummyEvent");
00200 TGo4AnalysisStep* step12 = new TGo4AnalysisStep("Output12Provider",factory12,0,0,0);
00201 AddAnalysisStep(step12);
00202 step12->SetSourceEnabled(kFALSE);
00203 step12->SetStoreEnabled(kFALSE);
00204 step12->SetProcessEnabled(kTRUE);
00205
00207 TGo4StepFactory* factory13 = new TGo4StepFactory("Branch13Factory");
00208 factory13->DefOutputEvent("FinalEvent", "TMeshFinalEvent");
00209 factory13->DefEventProcessor("Collector","TMeshFinalProc");
00210 TGo4EventStoreParameter* store13 = new TGo4FileStoreParameter("MeshFinal");
00211 TGo4AnalysisStep* step13 = new TGo4AnalysisStep("Final",factory13,0,store13,0);
00212
00213 AddAnalysisStep(step13);
00214 step13->SetSourceEnabled(kFALSE);
00215 step13->SetStoreEnabled(kTRUE);
00216 step13->SetProcessEnabled(kTRUE);
00217
00218
00219
00220
00221
00222
00224
00225
00226
00227 fPar = new TMeshParameter("MeshSetup");
00228 AddParameter(fPar);
00229 }
00230
00231
00232 TMeshAnalysis::~TMeshAnalysis()
00233 {
00234 TGo4Log::Info("TMeshAnalysis: Delete");
00235 }
00236
00237
00238
00239 Int_t TMeshAnalysis::UserPreLoop()
00240 {
00241 TGo4Log::Info("TMeshAnalysis: PreLoop");
00242
00243 fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Unpack"));
00244 fEvents=0;
00245 fLastEvent=0;
00246
00247
00248
00249
00250
00251 fSize=(TH1D*)GetHistogram("Eventsize");
00252 if(fSize==0)
00253 {
00254 fSize = new TH1D ("Eventsize", "Event size [b]",160,1,160);
00255 AddHistogram(fSize);
00256 }
00257
00258
00259
00260 return 0;
00261 }
00262
00263 Int_t TMeshAnalysis::UserPostLoop()
00264 {
00265 TGo4Log::Info("TMeshAnalysis: PostLoop");
00266 TGo4Log::Info("Last event: %d Total events: %d", fLastEvent, fEvents);
00267 if(fMbsEvent)
00268 {
00269
00270
00271
00272
00273 fMbsEvent->PrintMbsFileHeader();
00274
00275
00276 fMbsEvent->PrintMbsBufferHeader();
00277
00278 }
00279
00281
00282 fMbsEvent = 0;
00283 fEvents = 0;
00284 return 0;
00285 }
00286
00287
00288 Int_t TMeshAnalysis::UserEventFunc()
00289 {
00291 Int_t value = 0;
00292 Int_t count = 0;
00293 if(fMbsEvent) value = fMbsEvent->GetDlen()/2+2;
00294 fSize->Fill(value);
00295 fEvents++;
00296 if(fEvents == 1 || IsNewInputFile()) {
00297 if(fMbsEvent) {
00298 count = fMbsEvent->GetCount();
00299 TGo4Log::Info("First event #: %d", count);
00300
00301 fMbsEvent->PrintMbsBufferHeader();
00302 }
00303 }
00304 fLastEvent = count;
00305 return 0;
00306 }