00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4SimpleEvent.h"
00017
00018 #include <iostream.h>
00019
00020 #include "TGo4SimpleEventProcessor.h"
00021 #include "Go4EventServer/Go4EventServer.h"
00022
00023 TGo4SimpleEvent::TGo4SimpleEvent(Int_t subevtnum)
00024 : fiCount(0), fiLastSlot(0), fiMaxSlot(subevtnum), fxIterator(0)
00025 {
00026 TRACE((12,"TGo4SimpleEvent::TGo4SimpleEvent(Int_t)",__LINE__, __FILE__));
00027
00028 fxSubEventArray=new TClonesArray("TGo4SimpleSubEvent", subevtnum);
00029 fxIterator=fxSubEventArray->MakeIterator();
00030
00031 fiArrLen=10;
00032 for(Int_t z=0; z<10; ++z)
00033 {
00034 fiTestArray[z]=z*5;
00035 }
00036
00037
00038 TGo4SimpleSubEvent* subeve;
00039 for (Int_t t=0;t<subevtnum;++t)
00040 {
00041 subeve= new( (*fxSubEventArray) [t] ) TGo4SimpleSubEvent();
00042
00043 }
00044
00045
00046 }
00047
00048
00049 TGo4SimpleEvent::TGo4SimpleEvent()
00050 : fiCount(0), fiLastSlot(0),fiMaxSlot(5), fxIterator(0)
00051 {
00052 TRACE((12,"TGo4SimpleEvent::TGo4SimpleEvent()",__LINE__, __FILE__));
00053
00054 fxSubEventArray=new TClonesArray("TGo4SimpleSubEvent", fiMaxSlot );
00055 fxIterator=fxSubEventArray->MakeIterator();
00056
00057 }
00058
00059
00060
00061
00062 TGo4SimpleEvent::~TGo4SimpleEvent()
00063 {
00064 TRACE((12,"TGo4SimpleEvent::~TGo4SimpleEvent()",__LINE__, __FILE__));
00065 delete fxIterator;
00066 fxSubEventArray->Delete();
00067 delete fxSubEventArray;
00068
00069
00070 }
00071
00072
00073
00074
00075
00076 void TGo4SimpleEvent::PrintEvent() {
00077 TRACE((11,"TGo4SimpleEvent::PrintEvent()",__LINE__, __FILE__));
00078
00079 TGo4EventElement::PrintEvent();
00080 TGo4Log::Debug( " Simple Event Header printout: ");
00081 TGo4Log::Debug( "\tCount: %d ", GetCount() );
00082 TGo4SimpleSubEvent* sub;
00083 ResetIterator();
00084
00085 while ((sub = NextSubEvent() ) !=0)
00086 {
00087 sub->PrintEvent();
00088 }
00089
00090 }
00091
00092 void TGo4SimpleEvent::Clear(Option_t *t)
00093 {
00094 TRACE((11,"TGo4SimpleEvent::Clear()",__LINE__, __FILE__));
00095
00096 TGo4SimpleSubEvent* sub;
00097
00098
00099
00100
00101
00102
00103 Int_t i=0;
00104
00105 for(i=0;i<fiMaxSlot; ++i )
00106 {
00107 sub = dynamic_cast<TGo4SimpleSubEvent*>( fxSubEventArray->UncheckedAt(i));
00108 sub->Clear();
00109 }
00110 fiCount=0;
00111 }
00112
00113
00114 Int_t TGo4SimpleEvent::Fill()
00115 {
00116 TRACE((11,"TGo4SimpleEvent::Fill()",__LINE__, __FILE__));
00117
00118
00119 Int_t rev=-1;
00120 TGo4SimpleEventProcessor* proc;
00121 if(CheckEventSource("TGo4SimpleEventProcessor"))
00122 {
00123 proc = (TGo4SimpleEventProcessor*) GetEventSource();
00124 proc->BuildSimpleEvent(this);
00125 rev=0;
00126 }
00127 else if(CheckEventSource("TGo4TreeSource"))
00128 {
00129
00130
00131 TGo4TreeSource* source = (TGo4TreeSource*) GetEventSource();
00132 Clear();
00133 if(source->BuildEvent(this))
00134 {
00135 rev=0;
00136 }
00137 else
00138 {
00139
00140 rev = 1;
00141 }
00142 }
00143 else if(CheckEventSource("TGo4FileSource"))
00144 {
00145
00146
00147 TGo4FileSource* source = (TGo4FileSource*) GetEventSource();
00148 Clear();
00149 if(source->BuildEvent(this))
00150 {
00151 rev=0;
00152 }
00153 else
00154 {
00155
00156 rev = 1;
00157 }
00158 }
00159
00160
00161 else
00162 {
00163 rev=1;
00164 }
00165
00166 return rev;
00167
00168 }
00169
00170
00171 TGo4SimpleSubEvent * TGo4SimpleEvent::GetSubEvent(Short_t procid)
00172 {
00173 TRACE((11,"TGo4SimpleEvent::GetSubEvent(Short_t)",__LINE__, __FILE__));
00174 TGo4SimpleSubEvent* result=0;
00175 TGo4SimpleSubEvent* sub;
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 Int_t i=0;
00189
00190 for(i=0;i<fiMaxSlot; ++i )
00191 {
00192 sub = dynamic_cast<TGo4SimpleSubEvent*>( fxSubEventArray->UncheckedAt(i));
00193 if(sub->fsProcid==procid)
00194 {
00195 result=sub;
00196 break;
00197 }
00198 else
00199 { }
00200 }
00201
00202 return result;
00203 }
00204
00205 Int_t TGo4SimpleEvent::GetCount() const
00206 {
00207 return fiCount;
00208 }
00209 TGo4SimpleSubEvent * TGo4SimpleEvent::AddSubEvent(Short_t procid)
00210 {
00211 TRACE((11,"TGo4SimpleEvent::AddSubEvent(Short_t)",__LINE__, __FILE__));
00212
00213 TGo4SimpleSubEvent* result=0;
00214 if( (result=GetSubEvent(procid)) != 0 )
00215 {
00216
00217 }
00218 else
00219 {
00220
00221 if(fiLastSlot+1<fiMaxSlot)
00222 {
00223 fiLastSlot++;
00224 result=new( (*fxSubEventArray) [fiLastSlot] ) TGo4SimpleSubEvent();
00225 result->fsProcid=procid;
00226
00227 TGo4Log::Debug(" SimpleEvent: Added subevent with procid %d: ", procid);
00228 }
00229 else
00230 {
00231 cout << "simple event: clonesarray is full, cannot add another subevent"<<endl;
00232 result=0;
00233 }
00234
00235 }
00236
00237 return result;
00238 }
00239 void TGo4SimpleEvent::ResetIterator()
00240 {
00241 TRACE((11,"TGo4SimpleEvent::ResetIterator()",__LINE__, __FILE__));
00242 delete fxIterator;
00243 fxIterator = fxSubEventArray->MakeIterator();
00244
00245
00246 }
00247
00248 TGo4SimpleSubEvent* TGo4SimpleEvent::NextSubEvent()
00249 {
00250 TRACE((11,"TGo4SimpleEvent::NextSubEvent()",__LINE__, __FILE__));
00251 TGo4SimpleSubEvent* sub = (TGo4SimpleSubEvent*) fxIterator ->Next();
00252 return sub;
00253 }
00254
00255
00256 ClassImp(TGo4SimpleEvent)
00257
00258
00259
00260
00261