00001
00002
00003
00004
00005 #include "emcMixedDataObject.h"
00006 #include "emcRawDataAccessor.h"
00007 #include <iomanip>
00008 #include <iostream>
00009 #include <cassert>
00010 #include <map>
00011 #include "TString.h"
00012
00013 ClassImp(emcMixedDataObject)
00014
00015 using namespace std;
00016
00017
00018 emcMixedDataObject::emcMixedDataObject() : emcDataObject()
00019 {
00020 fADC = fTDC = fHG = fLG = 0 ;
00021 fOwnAllocation = false ;
00022 fPedestal = false ;
00023 fHLRatio = false ;
00024 UseHGLG(false) ;
00025 }
00026
00027
00028
00029
00030 emcMixedDataObject::~emcMixedDataObject()
00031 {
00032 delete[] fADC ;
00033 delete[] fTDC ;
00034 delete[] fHG ;
00035 delete[] fLG ;
00036 }
00037
00038
00039 void emcMixedDataObject::Get(Int_t index, Float_t& adc, Float_t& tdc) const
00040 {
00041
00042
00043
00044
00045 if (index>=0) {
00046 adc = fADC[index] ;
00047 tdc = fTDC[index] ;
00048 }
00049 else {
00050 adc = tdc = 0. ;
00051 }
00052 }
00053
00054
00055 void emcMixedDataObject::Get(Int_t index, Float_t& adc, Float_t& tdc,
00056 Float_t& hg, Float_t& lg) const
00057 {
00058
00059
00060
00061
00062 if (index>=0) {
00063 adc = fADC[index] ;
00064 tdc = fTDC[index] ;
00065 if (IsUsingHGLG()) {
00066 hg = fHG[index] ;
00067 lg = fLG[index] ;
00068 }
00069 else {
00070 cerr << "<E> emcMixedDataObject::Get : You are requesting HG, LG "
00071 << " but this MDO was not created for that. See UseHGLG(bool) "
00072 << " method."
00073 << endl ;
00074 }
00075 }
00076 else {
00077 adc=tdc=hg=lg= 0. ;
00078 }
00079 }
00080
00081
00082 Float_t emcMixedDataObject::GetADC(Int_t index) const
00083 {
00084
00085
00086 if (index>=0) {
00087 return fADC[index] ;
00088 }
00089 else {
00090 return 0. ;
00091 }
00092 }
00093
00094
00095 Float_t emcMixedDataObject::GetHG(Int_t index) const
00096 {
00097
00098
00099 if (!IsUsingHGLG()) {
00100 cerr << "<E> emcMixedDataObject::GetHG : I am not using HGLG" << endl ;
00101 return -1 ;
00102 }
00103
00104 if (index>=0) {
00105 return fHG[index] ;
00106 }
00107 else {
00108 return 0. ;
00109 }
00110 }
00111
00112
00113 Float_t emcMixedDataObject::GetLG(Int_t index) const
00114 {
00115
00116
00117 if (!IsUsingHGLG()) {
00118 cerr << "<E> emcMixedDataObject::GetLG : I am not using HGLG" << endl ;
00119 return 0. ;
00120 }
00121
00122 if (index>=0) {
00123 return fLG[index] ;
00124 }
00125 else {
00126 return 0. ;
00127 }
00128 }
00129
00130
00131 void emcMixedDataObject::GetPointers(float*& ADC, float*& TDC,int*& KEY)
00132 {
00133
00134 ADC = fADC ;
00135 TDC = fTDC ;
00136 KEY = fDataMap ;
00137 }
00138
00139
00140 void emcMixedDataObject::GetPointers(float*& ADC, float*& TDC,
00141 float*& HG, float*& LG, int*& KEY)
00142 {
00143
00144 ADC = fADC ;
00145 TDC = fTDC ;
00146 if (IsUsingHGLG()) {
00147 LG = fLG ;
00148 HG = fHG ;
00149 }
00150 else {
00151 cerr << "<E> emcMixedDataObject::GetPointers : You are requesting HG, LG "
00152 << " but this MDO was not created for that. See UseHGLG(bool) "
00153 << " method."
00154 << endl ;
00155 }
00156 KEY = fDataMap ;
00157 }
00158
00159
00160 Float_t emcMixedDataObject::GetTDC(Int_t index) const
00161 {
00162
00163
00164 if (index>=0) {
00165 return fTDC[index] ;
00166 }
00167 else {
00168 return 0. ;
00169 }
00170 }
00171
00172
00173 TString emcMixedDataObject::Status()
00174 {
00175 TString status ;
00176 TString blank = " " ;
00177 status = "emcMixedDataObject status : \n" ;
00178 status += blank ;
00179 if ( IsPedestalSubtracted() )
00180 status += "Pedestals have been subtracted\n" ;
00181 else
00182 status += "Pedestals have NOT been subtracted\n" ;
00183
00184 status += blank ;
00185 if ( IsHLRatioReal() )
00186 status += "Real H/L ratios have been applied\n" ;
00187 else
00188 status += "H/L ratios = 16 have been applied\n" ;
00189
00190 return status ;
00191 }
00192
00193
00194 void emcMixedDataObject::Set(int index, float adc, float tdc)
00195 {
00196
00197
00198
00199 assert (ValidIndex(index)) ;
00200
00201 if ( index+1 > fSize)
00202 fSize = index+1 ;
00203
00204 fADC[index] = adc ;
00205 fTDC[index] = tdc ;
00206
00207 }
00208
00209
00210 void emcMixedDataObject::Set(int index, float adc, float tdc,
00211 float hg, float lg)
00212 {
00213
00214
00215
00216 assert (ValidIndex(index)) ;
00217
00218 if ( index+1 > fSize)
00219 fSize = index+1 ;
00220
00221 fADC[index] = adc ;
00222 fTDC[index] = tdc ;
00223 fHG[index] = hg ;
00224 fLG[index] = lg ;
00225 }
00226
00227
00228 void emcMixedDataObject::SetToZero(int index)
00229 {
00230 if (IsUsingHGLG()) {
00231 Set(index,0.0,0.0,0.0,0.0) ;
00232 }
00233 else {
00234 Set(index,0.0,0.0) ;
00235 }
00236 }
00237
00238
00239 bool emcMixedDataObject::IsZero(Int_t index) const
00240 {
00241
00242
00243 if (!ValidIndex(index)) return true ;
00244
00245 if ( fADC[index] == 0.0 ) return true ;
00246 return false ;
00247 }
00248
00249
00250 void emcMixedDataObject::SetMaxSize(Int_t thesize)
00251 {
00257 if ( fMaxSize != thesize) {
00258
00259 delete[] fADC ;
00260 delete[] fTDC ;
00261 delete[] fHG ;
00262 delete[] fLG ;
00263
00264 fMaxSize = thesize ;
00265 fSize = 0 ;
00266 if(thesize){
00267 fADC = new Float_t[fMaxSize] ;
00268 fTDC = new Float_t[fMaxSize] ;
00269 if (IsUsingHGLG()) {
00270 fHG = new Float_t[fMaxSize] ;
00271 fLG = new Float_t[fMaxSize] ;
00272 }
00273 } else {
00274 fADC = fTDC = fHG = fLG = 0;
00275 }
00276 fPedestal = fHLRatio = false ;
00277 }
00278 }
00279
00280
00281 void emcMixedDataObject::Streamer(TBuffer&)
00282 {
00283
00284
00285 cout << "<W> emcMixedDataObject::Streamer disabled for the moment. Contact aphecetc@in2p3.fr." << endl ;
00286 exit(1);
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318 }
00319
00320
00321 void emcMixedDataObject::UseHGLG(bool use)
00322 {
00323
00324
00325
00326
00327 delete[] fLG ;
00328 delete[] fHG ;
00329
00330 if ( use == true && fMaxSize) {
00331 fLG = new Float_t[fMaxSize] ;
00332 fHG = new Float_t[fMaxSize] ;
00333 } else {
00334 fHG = fLG = 0;
00335 }
00336
00337 fUseHGLG = use ;
00338 }
00339
00340
00341 ostream& operator << (ostream& out, const emcMixedDataObject& mdo)
00342 {
00343 string head = " Tower : arm sector yrow zrow ADC TDC " ;
00344 if (mdo.IsUsingHGLG()) head += " HG LG" ;
00345 head += " ERR" ;
00346 head += " DeadNeighbours" ;
00347
00348 int i ;
00349 int counter = 0 ;
00350 out << head << endl ;
00351 out << dec ;
00352 Int_t arm, sector, yrow, zrow ;
00353 TString ans ;
00354
00355 for (i = 0; i < mdo.GetSize(); i++) {
00356 out << dec ;
00357 counter++ ;
00358 if ( counter == 30 ) {
00359 counter = 0 ;
00360 cout << "S(top) or C(ontinue) ? " ;
00361 cin >> ans ;
00362 cout << endl ;
00363 if ( ans == "s" || ans == "S" )
00364 break ;
00365 out << head << endl ;
00366 }
00367 mdo.DecodeKey( mdo.GetSoftwareKey(mdo.fDataMap[i]), arm,sector, yrow, zrow ) ;
00368 out << "#" << mdo.GetItemId(i) << " : "
00369 << arm <<" "
00370 << sector <<" "
00371 << yrow <<" "
00372 << zrow <<" * "
00373 << mdo.fADC[i] <<" "
00374 << mdo.fTDC[i] <<" ";
00375 if (mdo.IsUsingHGLG()) {
00376 out << mdo.fHG[i]
00377 << mdo.fLG[i] ;
00378 }
00379 out << ") "
00380 << hex << mdo.GetDataError(i) << dec << " D"
00381 << hex << mdo.GetDead(i)
00382 << endl ;
00383 }
00384
00385 return out ;
00386
00387 }