00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4MbsSubEvent.h"
00017
00018 #include <iostream.h>
00019 #include <iomanip.h>
00020
00021 #include "Go4Log/TGo4Log.h"
00022 #include "TGo4MbsSource.h"
00023
00024 TGo4MbsSubEvent::TGo4MbsSubEvent() :
00025 TGo4EventElement(),
00026 fbIsFilled(kFALSE),
00027 fbIsDataOwner(kFALSE),
00028 fxHeader(),
00029 fiAllocLen(0),
00030 fiData(0)
00031 {
00032 TRACE((12,"TGo4MbstSubEvent::TGo4MbsSubEvent()",__LINE__, __FILE__));
00033 }
00034
00035 TGo4MbsSubEvent::TGo4MbsSubEvent(Int_t datasize) :
00036 TGo4EventElement(),
00037 fbIsFilled(kFALSE),
00038 fbIsDataOwner(kTRUE),
00039 fxHeader(),
00040 fiAllocLen(0),
00041 fiData(0)
00042 {
00043 TRACE((12,"TGo4MbsSubEvent::TGo4MbsSubEvent(UInt_t)",__LINE__, __FILE__));
00044 if(fbIsDataOwner)
00045 {
00046 fiData= new Int_t[datasize];
00047 fiAllocLen=datasize;
00048 }
00049 }
00050
00051 TGo4MbsSubEvent::~TGo4MbsSubEvent()
00052 {
00053 TRACE((12,"TGo4MbsSubEvent::~TGo4MbsSubEvent()",__LINE__, __FILE__));
00054
00055 Clear();
00056 if(fbIsDataOwner)
00057 {
00058 for(Int_t t=0; t<GetAllocatedLength() ;++t)
00059 {
00060 if(fiData[t]!=0)
00061 {
00062 TGo4Log::Debug( " MBS SubEvent dtor WARNING: Data(%d) not zero after Clear !!! ",t);
00063 }
00064 else {}
00065 }
00066 delete [] fiData;
00067 }
00068 }
00069
00070
00071
00072 void TGo4MbsSubEvent::PrintEvent() {
00073 TRACE((11,"TGo4MbsSubEvent::PrintEvent()",__LINE__, __FILE__));
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00104 Bool_t printhexa=kFALSE;
00105 Int_t* pData = (Int_t *) GetDataField();
00106 cout << " Mbs Subevent t/s "
00107 << dec << setw(4) << (Int_t)GetType()
00108 << " " << setw(4) << (Int_t)GetSubtype()
00109 << " len " << setw(8) << (Int_t)GetDlen()
00110 << " procid " << setw(4) << (Int_t)GetProcid()
00111 << " ctrl " << setw(4) << (Int_t)GetControl()
00112 << " cr " << setw(4) << (Int_t)GetSubcrate()
00113 << endl;
00114 if(printhexa) cout << hex; else cout << dec;
00115 for(Int_t i=0; i < GetDlen()/2-1; i++)
00116 {
00117 cout << setw(12) << *pData << " ";
00118 if((i-3) % 4 == 0) cout << endl;
00119 pData++;
00120 }
00121 cout << endl;
00122 }
00123
00124 void TGo4MbsSubEvent::Set(Int_t dlen,
00125 Short_t type,
00126 Short_t subtype,
00127 Short_t procid,
00128 Char_t subcrate,
00129 Char_t ctrl)
00130 {
00131 SetDlen(dlen);
00132 SetType(type);
00133 SetSubtype(subtype);
00134
00135
00136
00137 }
00138
00139 void TGo4MbsSubEvent::Clear(Option_t *t)
00140 {
00141 TRACE((11,"TGo4MbsSubEvent::Clear()",__LINE__, __FILE__));
00142 fbIsFilled=kFALSE;
00143 if(fbIsDataOwner)
00144 {
00145
00146 Int_t dleng= GetDlen();
00147 if(dleng==0) dleng=2;
00148
00149
00150 Int_t fieldlength= (dleng-2) / TGo4MbsSource::fguLONGBYSHORT ;
00151 if(fieldlength>fiAllocLen)
00152 fieldlength=fiAllocLen;
00153
00154 if(fieldlength==0)
00155 fiData[0]=0;
00156 for(Int_t t=0; t<fieldlength;++t)
00157 {
00158 fiData[t]=0;
00159
00160 }
00161
00162 fxHeader.Clear();
00163 Set(dleng);
00164 }
00165 else {}
00166 }
00167
00168 void TGo4MbsSubEvent::ReAllocate(Int_t newsize)
00169 {
00170 TRACE((11,"TGo4MbsSubEvent::ReAllocate(UInt_t)",__LINE__, __FILE__));
00171 if(!fbIsDataOwner) return;
00172 if( newsize <= fiAllocLen )
00173 {
00174
00175 }
00176 else
00177 {
00178 delete [] fiData;
00179 fiData= new Int_t[newsize];
00180
00181 TGo4Log::Debug(" MbsSubEvent: Reallocating Data field from %d to %d longwords ",fiAllocLen,newsize);
00182 fiAllocLen=newsize;
00183 Clear();
00184 }
00185
00186 }
00187
00188 ClassImp(TGo4MbsSubEvent)
00189
00190
00191
00192
00193