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