00001 #include <cassert>
00002 #include <ctime>
00003
00004 #include "EEfeeDataBlock.h"
00005 #include "EEfeeRawEvent.h"
00006
00007 #include "EEfeeRawEvent.h"
00008 ClassImp(EEfeeRawEvent)
00009
00010
00011
00012
00013
00014
00015 EEfeeRawEvent :: EEfeeRawEvent() {
00016 ID=-1;
00017 block= new TClonesArray("EEfeeDataBlock",10);
00018 block->Clear();
00019
00020 }
00021
00022
00023
00024
00025
00026 EEfeeRawEvent :: ~EEfeeRawEvent() {
00027 delete block;
00028
00029 }
00030
00031
00032
00033
00034
00035 void EEfeeRawEvent :: clear(){
00036 ID=-1;
00037 block->Delete();
00038
00039 }
00040
00041
00042
00043
00044
00045 void EEfeeRawEvent :: print(int flag) const{
00046 printf("\nEEfeeRawEvent ID=%d with DataBlock entered=%d of %d\n",
00047 ID,block->GetEntries(),block->GetSize());
00048
00049 int i;
00050 for(i=0;i<block->GetEntries();i++) {
00051 printf("%d-",i+1);
00052 ((EEfeeDataBlock *)(block->At(i)))->print(flag);
00053 }
00054
00055 }
00056
00057
00058
00059
00060
00061 void EEfeeRawEvent ::addFeeDataBlock(EEfeeDataBlock* b){
00062
00063
00064
00065
00066
00067 assert(b);
00068
00069 TClonesArray &Block=*block;
00070 int nB=Block.GetEntries();
00071 EEfeeDataBlock *bl1= new(Block[nB]) EEfeeDataBlock();
00072 bl1->set(b);
00073
00074 }
00075
00076
00077
00078
00079
00080
00081 int EEfeeRawEvent::getNGoodBlock() {
00082 int ic;
00083 int nOK=0;
00084 for(ic=0;ic<block->GetEntries();ic++) {
00085 EEfeeDataBlock *b=(EEfeeDataBlock *)block->At(ic);
00086 if(!b->isValid()) continue;
00087
00088 nOK++;
00089 }
00090 return nOK;
00091 }
00092
00093
00094
00095
00096
00097
00098
00099 int EEfeeRawEvent::maskWrongCrates( long timeStamp, unsigned headToken, HeadVer headVersion) {
00100
00101
00102
00103
00104
00105
00106
00107 if(timeStamp< 1068744930) {
00108 printf(" maskWrongCrates() not implemented for time stamp : %ld / %s",timeStamp,ctime((const time_t *)& timeStamp));
00109 assert(1==2);
00110 }
00111
00112
00113 int listA[]={1,2,3,4,5,6};
00114 int listB[]={1,2,3,4,5,6,84,85,86};
00115 int listC[]={1,2,3,4,5,6,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
00116 18,17,16,30,29,28,27,26,25,24,23,22,21,20,19,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
00117
00118 int listD[]={1,2,3,4,5,6,100,101,102,103,1,2,3,4,1,2,3,4,1,2,3,4};
00119
00120
00121 int *list, dim;
00122 if (timeStamp< 1068761131)
00123 { list=listA; dim=sizeof(listA)/sizeof(int); }
00124 else if (timeStamp< 1070474417 )
00125 { list=listB; dim=sizeof(listB)/sizeof(int); }
00126 else if (timeStamp< 1093360000 )
00127 { list=listC; dim=sizeof(listC)/sizeof(int); }
00128 else
00129 { list=listD; dim=sizeof(listD)/sizeof(int); }
00130
00131
00132
00133 int ic;
00134 int nOK=0;
00135 for(ic=0;ic<block->GetEntries();ic++) {
00136 EEfeeDataBlock *b=(EEfeeDataBlock *)block->At(ic);
00137 assert(ic<dim);
00138
00139 int lenCount=0;
00140 int errFlag=0;
00141 int trigCommand=4;
00142
00143 if(ic<6) {
00144
00145 lenCount=5*32;
00146 } else if (ic<22) {
00147
00148 lenCount=12*16;
00149 errFlag=0x28;
00150 } else {
00151 lenCount=10*16;
00152 };
00153
00154
00155
00156 UChar_t sick=0;
00157 switch (headVersion) {
00158 case headVer1:
00159 sick =b->isHeadValid(headToken,list[ic],lenCount,trigCommand,errFlag);
00160 break;
00161 case headVer2:
00162 sick=b->isHeadValid(headToken,list[ic],errFlag,lenCount,trigCommand);
00163 break;
00164 case headVer3:
00165 errFlag=9;
00166 if(ic<6) errFlag=4; else errFlag=9;
00167 sick=b->isHeadValid(headToken,list[ic],trigCommand,errFlag,lenCount);
00168 break;
00169 default:
00170 assert(1==2);
00171 }
00172
00173
00174
00175
00176
00177 if(!sick) nOK++;
00178
00179 }
00180
00181 return nOK;
00182 }
00183
00184
00185
00186
00187
00188 void EEfeeRawEvent :: maskBEMC(){
00189
00190
00191 for(int ic=22;ic<block->GetEntries();ic++) {
00192 EEfeeDataBlock *b=(EEfeeDataBlock *)block->At(ic);
00193 b->maskCrate();
00194 }
00195
00196 }
00197
00198
00199
00200
00201
00202 UShort_t EEfeeRawEvent::getValue(int crateID, int channel) const {
00203 int i;
00204 for(i=0;i<block->GetEntries();i++) {
00205 EEfeeDataBlock *b=(EEfeeDataBlock *)block->At(i);
00206 if( crateID!=b->getCrateID()) continue;
00207 int nd=b->getValidDataLen();
00208 assert(channel>=0 );
00209 assert(channel<nd );
00210 UShort_t* data=b->getData();
00211 return data[channel];
00212 }
00213 return 0xffff;
00214 }
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270