00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00031 #include "Riostream.h"
00032 #include <stdlib.h>
00033
00034 #include "TApplication.h"
00035
00036 #include "TH1.h"
00037 #include "TBrowser.h"
00038 #include "TCanvas.h"
00039 #include "TBenchmark.h"
00040
00041 #include "TGo4Log.h"
00042
00043 #include "Go4EventServer.h"
00044
00045 #include "TGo4SimpleEvent.h"
00046 #include "TGo4SimpleSubEvent.h"
00047 #include "TGo4SimpleEventProcessor.h"
00048
00049 void usage();
00050
00051 int main(int argc, char **argv)
00052 {
00053 if(argc<2) { usage(); return 0; }
00054
00055 TApplication theApp("App", &argc, argv);
00056
00057
00058 TGo4Log::Instance();
00059 TGo4Log::SetIgnoreLevel(0);
00060
00061
00062 TGo4Log::LogfileEnable(kFALSE);
00063
00064 TBenchmark mybench;
00065 Text_t* num=argv[1];
00066 Int_t maxevents=atoi(num);
00067 Int_t value=0;
00068
00069 TCanvas* can = new TCanvas("MyCanvas","MainGo4EventServer");
00070 can->Divide(1,2);
00071 TH1D* histo1 = new TH1D ("histogram 1", "mbsevent data",400,0,4000);
00072 TH1D* histo2 = new TH1D ("histogram 2", "simpleevent data",400,0,4000);
00073
00074 TGo4MbsSubEvent* sub=0;
00075 TGo4SimpleSubEvent* simpsub=0;
00076
00077
00078
00079 Short_t idfield[2]= {0,3};
00080
00081
00082 TGo4MbsEvent* event = new TGo4MbsEvent(2, idfield, 1);
00083
00084
00085
00086
00087 TGo4SimpleEvent* simpevent = new TGo4SimpleEvent(2);
00088
00089 TGo4SimpleEventProcessor* proc = new TGo4SimpleEventProcessor();
00090
00091 TGo4EventSource* input=0;
00092
00093 TGo4EventStore* output=0;
00094 TGo4EventStore* simpoutput=0;
00095
00096
00097
00098
00100 input= new TGo4MbsFile("/GSI/lea/examples/gauss.lmd");
00101
00102
00103
00105
00106
00107
00109
00110
00111
00113
00114
00115
00117
00118
00119
00120
00121
00122 output = new TGo4FileStore("MbsEvents",99,5);
00123
00124
00125
00126
00127
00128 simpoutput = new TGo4FileStore("SimpleEvents",99,5);
00129
00131 event->PrintEvent();
00132 simpevent->PrintEvent();
00133
00135 event->SetEventSource(input);
00136
00137
00138 proc->SetInputEvent(event);
00139 simpevent->SetEventSource(proc);
00140
00141
00142 cout << "starting event loop:"<< endl;
00143 mybench.Start("Go4EventServer");
00144 for(Int_t t=0; t<maxevents; ++t)
00145 {
00147 event->Clear();
00148 Int_t errmess=event->Fill();
00149 if(errmess==GETEVT__NOMORE)
00150 {
00151 cout << "no more events from MbsSource."<< endl;
00152 break;
00153
00154 }
00155 else if(errmess!=0)
00156 {
00157 cout << "ERROR on event fill."<< endl;
00158 break;
00159 }
00161 sub=event->GetSubEvent(3);
00162 if (sub)
00163 {
00164 value= sub->Data(1);
00165 if(value)
00166 {
00167 histo1->Fill(value);
00168
00169 }
00170 }
00171
00172
00173
00174
00175 if(output)
00176 output->Store(event);
00177
00179 simpevent->Clear();
00180 simpevent->Fill();
00182 simpsub=simpevent->GetSubEvent(3);
00183 if (simpsub)
00184 {
00185 value= simpsub->fiD1;
00186
00187 if(value)
00188
00189 {
00190 histo2->Fill(value);
00191
00192 }
00193
00194 }
00195
00196 if(simpoutput)
00197 simpoutput->Store(simpevent);
00198
00199
00200 if(t%2000==0 && t!=0)
00201 {
00202 event->PrintEvent();
00203 can->cd(1);
00204 histo1->Draw();
00205 can->cd(2);
00206 histo2->Draw();
00207 can->Modified();
00208 can->Update();
00209 cout << " 2000 events processed "<< endl;
00210 }
00211
00212 }
00213 cout << "\t finished filling and saving events."<<endl;
00214 mybench.Show("Go4EventServer");
00215 delete output;
00216 delete event;
00217 delete input;
00218 delete simpoutput;
00219 delete simpevent;
00220 delete proc;
00221
00222 theApp.Run();
00223 return 0;
00224 }
00225
00226 void usage()
00227 {
00228 cout << "usage: MainGo4EventServerExample eventnumber"<<endl;
00229 }
00230
00231
00232
00233
00234
00235