00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TMeshAnalysis.h"
00017
00018 #include <time.h>
00019
00020 #include "Riostream.h"
00021 #include "TH1.h"
00022 #include "TMeshParameter.h"
00023 #include "Go4EventServer.h"
00024 #include "TGo4StepFactory.h"
00025 #include "TGo4AnalysisStep.h"
00026
00027
00028 TMeshAnalysis::TMeshAnalysis() :
00029 TGo4Analysis(),
00030 fMbsEvent(0)
00031 {
00032 cout << "Wrong constructor TMeshAnalysis()!" << endl;
00033 }
00034
00035
00036 TMeshAnalysis::TMeshAnalysis(const char* input, Int_t type, Int_t port,
00037 const char* out1, const char* out2, Bool_t enable1, Bool_t enable2) :
00038 TGo4Analysis(),
00039 fMbsEvent(0),
00040 fSize(0),
00041 fEvents(0),
00042 fLastEvent(0)
00043 {
00044
00045
00046
00047 cout << "**** TMeshAnalysis: Create" << endl;
00048
00049 SetStepChecking(kFALSE);
00050
00051
00052 TGo4EventSourceParameter* source1=0;
00053 TGo4RevServParameter* mbsrev=0;
00054 switch (type){
00055 case GO4EV_MBS_FILE:
00056 source1 = new TGo4MbsFileParameter(input);
00057 cout << "**** Unpack: Create file input " << input << endl;
00058 break;
00059 case GO4EV_MBS_STREAM:
00060 source1 = new TGo4MbsStreamParameter(input);
00061 cout << "**** Unpack: Create stream input " << input << endl;
00062 break;
00063 case GO4EV_MBS_TRANSPORT:
00064 source1 = new TGo4MbsTransportParameter(input);
00065 cout << "**** Unpack: Create transport input " << input << endl;
00066 break;
00067 case GO4EV_MBS_REVSERV:
00068 mbsrev = new TGo4RevServParameter(input);
00069 mbsrev->SetPort(port);
00070 source1=mbsrev;
00071 cout << "**** Unpack: Create remote event server input " << input << " port " << port <<endl;
00072 break;
00073 case GO4EV_MBS_EVENTSERVER:
00074 source1 = new TGo4MbsEventServerParameter(input);
00075 cout << "**** Unpack: Create mbs event server input " << input << endl;
00076 break;
00077 default:break;
00078 }
00079 TGo4StepFactory* factory1 = new TGo4StepFactory("UnpackFactory");
00080 factory1->DefOutputEvent("RawEvent", "TMeshRawEvent");
00081 factory1->DefEventProcessor("Unpacker","TMeshUnpackProc");
00082 TGo4EventStoreParameter* store1 = new TGo4FileStoreParameter("MeshRawEvent");
00083 TGo4AnalysisStep* step1 = new TGo4AnalysisStep("Unpack",factory1,source1,store1,0);
00084 AddAnalysisStep(step1);
00085 step1->SetSourceEnabled(kTRUE);
00086 step1->SetStoreEnabled(enable1);
00087 step1->SetProcessEnabled(kTRUE);
00088
00090 TGo4StepFactory* factory2 = new TGo4StepFactory("RawProvider1Factory");
00091
00092
00093 factory2->DefInputEvent("RawEvent.fxSub1", "TMeshRawEvent");
00094 factory2->DefEventProcessor("RawEvent.fxSub1_1","TMeshProviderProc");
00095 factory2->DefOutputEvent("Dummy", "TMeshDummyEvent");
00096 TGo4AnalysisStep* step2 = new TGo4AnalysisStep("Input1Provider",factory2,0,0,0);
00097 AddAnalysisStep(step2);
00098 step2->SetSourceEnabled(kFALSE);
00099 step2->SetStoreEnabled(kFALSE);
00100 step2->SetProcessEnabled(kTRUE);
00101
00103 TGo4StepFactory* factory3 = new TGo4StepFactory("RawProvider2Factory");
00104
00105
00106 factory3->DefInputEvent("RawEvent.fxSub2", "TMeshRawEvent");
00107 factory3->DefEventProcessor("RawEvent.fxSub2_1","TMeshProviderProc");
00108 factory3->DefOutputEvent("Dummy", "TMeshDummyEvent");
00109 TGo4AnalysisStep* step3 = new TGo4AnalysisStep("Input2Provider",factory3,0,0,0);
00110 AddAnalysisStep(step3);
00111 step3->SetSourceEnabled(kFALSE);
00112 step3->SetStoreEnabled(kFALSE);
00113 step3->SetProcessEnabled(kTRUE);
00114
00116 TGo4StepFactory* factory4 = new TGo4StepFactory("RawProvider3Factory");
00117
00118
00119 factory4->DefInputEvent("RawEvent.fxSub3", "TMeshRawEvent");
00120 factory4->DefEventProcessor("RawEvent.fxSub3_1","TMeshProviderProc");
00121 factory4->DefOutputEvent("Dummy", "TMeshDummyEvent");
00122
00123 TGo4AnalysisStep* step4 = new TGo4AnalysisStep("Input3Provider",factory4,0,0,0);
00124 AddAnalysisStep(step4);
00125 step4->SetSourceEnabled(kFALSE);
00126 step4->SetStoreEnabled(kFALSE);
00127 step4->SetProcessEnabled(kTRUE);
00128
00130 TGo4StepFactory* factory5 = new TGo4StepFactory("Branch1Factory");
00131 factory5->DefOutputEvent("EventB1", "TMeshB1OutputEvent");
00132 factory5->DefEventProcessor("Branch1","TMeshB1AnlProc");
00133 TGo4EventStoreParameter* store5 = new TGo4FileStoreParameter("MeshB1");
00134 TGo4AnalysisStep* step5 = new TGo4AnalysisStep("Exec1",factory5,0,store5,0);
00135
00136 AddAnalysisStep(step5);
00137 step5->SetSourceEnabled(kFALSE);
00138 step5->SetStoreEnabled(kTRUE);
00139 step5->SetProcessEnabled(kTRUE);
00140
00142 TGo4StepFactory* factory6 = new TGo4StepFactory("Branch2Factory");
00143 factory6->DefOutputEvent("EventB2", "TMeshB2OutputEvent");
00144 factory6->DefEventProcessor("Branch2","TMeshB2AnlProc");
00145 TGo4EventStoreParameter* store6 = new TGo4FileStoreParameter("MeshB2");
00146 TGo4AnalysisStep* step6 = new TGo4AnalysisStep("Exec2",factory6,0,store6,0);
00147
00148 AddAnalysisStep(step6);
00149 step6->SetSourceEnabled(kFALSE);
00150 step6->SetStoreEnabled(kTRUE);
00151 step6->SetProcessEnabled(kTRUE);
00152
00154 TGo4StepFactory* factory7 = new TGo4StepFactory("Branch3Factory");
00155 factory7->DefOutputEvent("EventB3", "TMeshB3OutputEvent");
00156 factory7->DefEventProcessor("Branch3","TMeshB3AnlProc");
00157 TGo4EventStoreParameter* store7 = new TGo4FileStoreParameter("MeshB3");
00158 TGo4AnalysisStep* step7 = new TGo4AnalysisStep("Exec3",factory7,0,store7,0);
00159
00160 AddAnalysisStep(step7);
00161 step7->SetSourceEnabled(kFALSE);
00162 step7->SetStoreEnabled(kTRUE);
00163 step7->SetProcessEnabled(kTRUE);
00164
00165
00167 TGo4StepFactory* factory8 = new TGo4StepFactory("OutProvider1Factory");
00168 factory8->DefInputEvent("EventB1", "TMeshB1OutputEvent");
00169 factory8->DefEventProcessor("EventB1_1","TMeshProviderProc");
00170 factory8->DefOutputEvent("Dummy", "TMeshDummyEvent");
00171 TGo4AnalysisStep* step8 = new TGo4AnalysisStep("Output1Provider",factory8,0,0,0);
00172 AddAnalysisStep(step8);
00173 step8->SetSourceEnabled(kFALSE);
00174 step8->SetStoreEnabled(kFALSE);
00175 step8->SetProcessEnabled(kTRUE);
00176
00178 TGo4StepFactory* factory9 = new TGo4StepFactory("OutProvider2Factory");
00179 factory9->DefInputEvent("EventB2", "TMeshB2OutputEvent");
00180 factory9->DefEventProcessor("EventB2_1","TMeshProviderProc");
00181 factory9->DefOutputEvent("Dummy", "TMeshDummyEvent");
00182 TGo4AnalysisStep* step9 = new TGo4AnalysisStep("Output2Provider",factory9,0,0,0);
00183 AddAnalysisStep(step9);
00184 step9->SetSourceEnabled(kFALSE);
00185 step9->SetStoreEnabled(kFALSE);
00186 step9->SetProcessEnabled(kTRUE);
00187
00189 TGo4StepFactory* factory10 = new TGo4StepFactory("OutProvider3Factory");
00190 factory10->DefInputEvent("EventB3", "TMeshB3OutputEvent");
00191 factory10->DefEventProcessor("EventB3_1","TMeshProviderProc");
00192 factory10->DefOutputEvent("Dummy", "TMeshDummyEvent");
00193 TGo4AnalysisStep* step10 = new TGo4AnalysisStep("Output3Provider",factory10,0,0,0);
00194 AddAnalysisStep(step10);
00195 step10->SetSourceEnabled(kFALSE);
00196 step10->SetStoreEnabled(kFALSE);
00197 step10->SetProcessEnabled(kTRUE);
00198
00200 TGo4StepFactory* factory11 = new TGo4StepFactory("Branch12Factory");
00201 factory11->DefOutputEvent("EventB12", "TMeshB12OutputEvent");
00202 factory11->DefEventProcessor("Branch12","TMeshB12AnlProc");
00203 TGo4EventStoreParameter* store11 = new TGo4FileStoreParameter("MeshB12");
00204 TGo4AnalysisStep* step11 = new TGo4AnalysisStep("Exec12",factory11,0,store11,0);
00205
00206 AddAnalysisStep(step11);
00207 step11->SetSourceEnabled(kFALSE);
00208 step11->SetStoreEnabled(kTRUE);
00209 step11->SetProcessEnabled(kTRUE);
00210
00212 TGo4StepFactory* factory12 = new TGo4StepFactory("OutProvider12Factory");
00213 factory12->DefInputEvent("EventB12", "TMeshB12OutputEvent");
00214 factory12->DefEventProcessor("EventB12_1","TMeshProviderProc");
00215 factory12->DefOutputEvent("Dummy", "TMeshDummyEvent");
00216 TGo4AnalysisStep* step12 = new TGo4AnalysisStep("Output12Provider",factory12,0,0,0);
00217 AddAnalysisStep(step12);
00218 step12->SetSourceEnabled(kFALSE);
00219 step12->SetStoreEnabled(kFALSE);
00220 step12->SetProcessEnabled(kTRUE);
00221
00223 TGo4StepFactory* factory13 = new TGo4StepFactory("Branch13Factory");
00224 factory13->DefOutputEvent("FinalEvent", "TMeshFinalEvent");
00225 factory13->DefEventProcessor("Collector","TMeshFinalProc");
00226 TGo4EventStoreParameter* store13 = new TGo4FileStoreParameter("MeshFinal");
00227 TGo4AnalysisStep* step13 = new TGo4AnalysisStep("Final",factory13,0,store13,0);
00228
00229 AddAnalysisStep(step13);
00230 step13->SetSourceEnabled(kFALSE);
00231 step13->SetStoreEnabled(kTRUE);
00232 step13->SetProcessEnabled(kTRUE);
00233
00234
00235
00237
00238
00239
00240 fPar = new TMeshParameter("MeshSetup");
00241 AddParameter(fPar);
00242
00243
00244 }
00245
00246
00247 TMeshAnalysis::~TMeshAnalysis()
00248 {
00249 cout << "**** TMeshAnalysis: Delete" << endl;
00250 }
00251
00252
00253
00254 Int_t TMeshAnalysis::UserPreLoop()
00255 {
00256 cout << "**** TMeshAnalysis: PreLoop" << endl;
00257
00258 fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Unpack"));
00259 fEvents=0;
00260 fLastEvent=0;
00261
00262
00263
00264
00265
00266 fSize=(TH1D*)GetHistogram("Eventsize");
00267 if(fSize==0)
00268 {
00269 fSize = new TH1D ("Eventsize", "Event size [b]",160,1,160);
00270 AddHistogram(fSize);
00271 }
00272
00273
00274
00275 return 0;
00276 }
00277
00278 Int_t TMeshAnalysis::UserPostLoop()
00279 {
00280 cout << "**** TMeshAnalysis: PostLoop" << endl;
00281 cout << "Last event: " << fLastEvent << " Total events: " << fEvents << endl;
00282 if(fMbsEvent)
00283 {
00284
00285
00286
00287
00288 s_filhe* fileheader=fMbsEvent->GetMbsSourceHeader();
00289 if(fileheader)
00290 {
00291 cout <<"\nInput file was: "<<fileheader->filhe_file << endl;
00292 cout <<"Tapelabel:\t" << fileheader->filhe_label<<endl;
00293 cout <<"UserName:\t" << fileheader->filhe_user<<endl;
00294 cout <<"RunID:\t" << fileheader->filhe_run<<endl;
00295 cout <<"\tExplanation: "<<fileheader->filhe_exp <<endl;
00296 cout <<"\tComments: "<<endl;
00297 Int_t numlines=fileheader->filhe_lines;
00298 for(Int_t i=0; i<numlines;++i)
00299 {
00300 cout<<"\t\t"<<fileheader->s_strings[i].string << endl;
00301 }
00302 }
00303
00304
00305 s_bufhe* bufheader=fMbsEvent->GetMbsBufferHeader();
00306 if(bufheader)
00307 {
00308 cout <<"Last Buffer:" << endl;
00309 cout <<"\tNumber: " << bufheader->l_buf << endl;
00310 void* timptr=&(bufheader->l_time[0]);
00311 cout <<"\tTime: "<<ctime((const time_t*) timptr);
00312 cout << "\t\t\t + " << bufheader->l_time[1] << " µs"<<endl;
00313 }
00314
00315
00316 }
00317
00319
00320 fMbsEvent = 0;
00321 fEvents=0;
00322 return 0;
00323 }
00324
00325
00326 Int_t TMeshAnalysis::UserEventFunc()
00327 {
00329 Int_t value = 0;
00330 Int_t count = 0;
00331 if(fMbsEvent) value = fMbsEvent->GetDlen()/2+2;
00332 fSize->Fill(value);
00333 fEvents++;
00334 if(fEvents == 1 || IsNewInputFile()) {
00335 if(fMbsEvent) {
00336 count=fMbsEvent->GetCount();
00337 cout << "\nFirst event #: " << count << endl;
00338 s_bufhe* bufheader=fMbsEvent->GetMbsBufferHeader();
00339 if(bufheader) {
00340 cout <<"First Buffer:"<<endl;
00341 cout <<"\tNumber: "<<bufheader->l_buf << endl;
00342 void* timptr=&(bufheader->l_time[0]);
00343 cout <<"\tTime: "<<ctime((const time_t*) timptr);
00344 cout << "\t\t\t + "<<bufheader->l_time[1] << " µs"<<endl;
00345 }
00346 }
00347 SetNewInputFile(kFALSE);
00348 }
00349 fLastEvent = count;
00350 return 0;
00351 }
00352
00353