5 #include "EEfeeDataBlock.h"
18 MaxHead = DefaultMaxHead;
20 head =
new UShort_t[MaxHead];
27 MaxData = b->getDataLen();
28 MaxHead = b->getHeadLen();
30 if(MaxHead>0) head =
new UShort_t[MaxHead];
32 if(MaxData>0)
data =
new UShort_t[MaxData];
42 EEfeeDataBlock :: ~EEfeeDataBlock() {
43 if(head)
delete [] head;
51 void EEfeeDataBlock :: print(
int flag){
52 printf(
"feeDataBlock Head: 0x%04hx 0x%04hx 0x%04hx 0x%04hx ",head[0],head[1],head[2],head[3]);
53 printf(
"\n --> token=0x%2x crateID=0x%x trigComm=0x%x lenCount=0x%x errFlag=0x%x\n NpositiveData=%d sanity=0x%02x\n",
54 getToken(),getCrateID(),getTrigComm(),getLenCount(),getErrFlag(),getNData(0),sanity);
59 printf(
"Data[%3d]:",nd);
60 for(
int i=0;i<nd;i++) {
61 if( i%8 == 0 ) printf(
"\n");
62 printf(
"0x%04hx ",
data[i]);
76 setHead(b->getHead());
77 setDataArray(b->getData(),b->getDataLen());
84 void EEfeeDataBlock ::setHead(
const UShort_t *h) {
86 memcpy(head,h,
sizeof(head[0])*MaxHead);
88 memset(head,0,
sizeof(head[0])*MaxHead);
96 int EEfeeDataBlock ::getNData(
int thres)
const {
99 const int nd=getValidDataLen();
100 for(i=0;i<nd;i++) if(data[i]>thres) n++;
108 void EEfeeDataBlock ::setDataArray(
const UShort_t *dIn,
int size) {
109 const UShort_t x=0,*d=&x;
119 data =
new UShort_t[MaxData];
121 memset(
data,0x0,
sizeof(
data[0])*MaxData);
123 memcpy(
data,d,size*
sizeof(
data[0]));
131 void EEfeeDataBlock ::setData(
int chan, UShort_t d){
134 Int_t newsize = MaxData + DefaultMaxData;
135 UShort_t *newdata =
new UShort_t[newsize];
137 memcpy(newdata,
data,MaxData);
151 void EEfeeDataBlock :: clear(){
152 if(head) memset(head,0,
sizeof(head[0])*MaxHead);
161 UChar_t EEfeeDataBlock
162 ::isHeadValid(
int token,
int crId,
int len,
int trigComm,
int errFlag){
165 ret|=(getCrateID()!=crId)<<0;
166 ret|=(getToken()!=token)<<1;
167 ret|=(getLenCount()!=len)<<2;
168 ret|=(getTrigComm()!=trigComm)<<3;
169 ret|=(getErrFlag()!=errFlag)<<4;
173 printf(
"\nask/0x: %x %x %x %x %x\n", token,crId,len,trigComm,errFlag);
175 printf(
"getCrateID()/0x = %x %x\n",getCrateID(),crId);
176 printf(
"getToken()/0x = %x %x\n",getToken(),token);
177 printf(
"getLenCount()/0x = %x %x\n",getLenCount(),len);
178 printf(
"getTrigComm()/0x = %x %x\n",getTrigComm(),trigComm);
179 printf(
"getErrFlag()/0x = %x %x\n",getErrFlag(),errFlag);