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