6 #include "EztEmcRawData.h"
13 for(
int i=0;i<MAXEMCDATABANK;i++) {
16 setCorruption(i,0xffff);
21 EztEmcRawData::EztEmcRawData(
const EztEmcRawData& h) : TObject(h)
23 for(
int i=0;i<MAXEMCDATABANK;i++) {
24 if(h.header(i) && h.data(i)) {
25 createBank(i,h.sizeHeader(i),h.sizeData(i));
26 setHeader(i,(
unsigned short*)h.header(i));
27 setData(i,(
unsigned short*)h.data(i));
33 EztEmcRawData::~EztEmcRawData()
35 for(
int i=0;i<MAXEMCDATABANK;i++) deleteBank(i);
41 EztEmcRawData::createBank(
int bank,
int sizeHeader,
int sizeData)
44 mHeader[bank].Set(sizeHeader);
45 mData[bank].Set(sizeData);
46 for(
int i = 0;i<sizeHeader;i++) mHeader[bank][i] = 0;
47 for(
int i = 0;i<sizeData;i++) mData[bank][i] = 0;
48 setCorruption(bank,0xffff);
54 EztEmcRawData::deleteBank(
int bank)
58 setCorruption(bank,0xffff);
63 EztEmcRawData::setHeader(
int bank,
unsigned short*
data)
65 if(sizeHeader(bank)==0)
return;
66 mHeader[bank].Set(sizeHeader(bank),(
const Short_t*)data);
71 EztEmcRawData::setData(
int bank,
unsigned short* data)
73 if(sizeData(bank)==0)
return;
74 mData[bank].Set(sizeData(bank),(
const Short_t*)data);
80 EztEmcRawData::header(
int bank)
const
82 return (UShort_t*)mHeader[bank].GetArray();
87 EztEmcRawData::data(
int bank)
const
89 return (UShort_t*)mData[bank].GetArray();
94 EztEmcRawData::sizeHeader(
int bank)
const
96 return mHeader[bank].GetSize();
101 EztEmcRawData::sizeData(
int bank)
const
103 return mData[bank].GetSize();
108 EztEmcRawData::purgeCrateOFF(
int ib){
109 bool isOFF=isCrateOFF(header(ib));
118 EztEmcRawData::tagHeadValid(
int ib,
int token,
int crId,
int len,
int trigComm,
int errFlag,
int dbg) {
119 UShort_t ret= isHeadValid(header(ib), token, crId, len, trigComm, errFlag, dbg);
120 setCorruption(ib,ret);
126 EztEmcRawData::doHeadCorruptionTest(
int token,
int lenCount,
int firstCrId,
int errFlag){
134 for(icr=0;icr<getNBlocks();icr++) {
135 if(isCrateVoid(icr))
continue;
136 if(purgeCrateOFF(icr))
continue;
138 int crID=icr+firstCrId;
140 tagHeadValid(icr,token, crID,lenCount,trigComm,errFlag);
141 if(getCorruption(icr))
continue;
151 EztEmcRawData::isCrateOFF(
const UShort_t* hd) {
152 bool a=(hd[0]& 0xFFF)==0xFFF;
153 bool b=(hd[1]& 0xFFF)==0xFFF;
159 EztEmcRawData::isHeadValid(
const UShort_t* hd,
int token,
int crId,
int len,
int trigComm,
int errFlag,
int dbg) {
162 if (getCrateID(hd)!=crId) ret |=bitCrateID;
163 if (getToken(hd)!=token) ret |=bitToken;
164 if (getLenCount(hd)!=len) ret |=bitLenCount;
165 if (getTrigComm(hd)!=trigComm) ret |=bitTrigComm;
166 if (getErrFlag(hd)!=errFlag) ret |=bitErrFlag;
169 printf(
"getCrateID()/0x is=%x %x=required\n",getCrateID(hd),crId);
170 printf(
"getToken()/0x = %x %x\n",getToken(hd),token);
171 printf(
"getLenCount()/0x = %x %x\n",getLenCount(hd),len);
172 printf(
"getTrigComm()/0x = %x %x\n",getTrigComm(hd),trigComm);
173 printf(
"getErrFlag()/0x = %x %x\n",getErrFlag(hd),errFlag);
174 printf(
" corruption=0x%02x\n",ret);
182 EztEmcRawData::print(
int ib,
int flag)
184 printf(
"EztEmcRawData block=%d corruption=0x%04x\n",ib,getCorruption(ib));
186 if(flag<=0) { print(header(ib));
return; }
188 print(header(ib),data(ib),sizeData(ib));
194 EztEmcRawData::print(
int flag)
197 for(icr=0;icr<getNBlocks();icr++) {
198 if(sizeHeader(icr)<=0)
continue;
202 printf(
"EztEmcRawData total %d of non empty blocks\n\n",nb);
207 void EztEmcRawData::print(
const UShort_t* hd,
const UShort_t* d,
int nd) {
208 printf(
"EztEmcRawData Head: 0x%04hx 0x%04hx 0x%04hx 0x%04hx ",hd[0],hd[1],hd[2],hd[3]);
209 printf(
"\n --> token=0x%2x crateID=0x%x trigComm=0x%x lenCount=0x%x errFlag=0x%x\n",
210 getToken(hd),getCrateID(hd),getTrigComm(hd),getLenCount(hd),getErrFlag(hd));
212 printf(
"Data[%3d]:",nd);
213 for(
int i=0;i<nd;i++) {
214 if( i%8 == 0 ) printf(
"\n");
215 printf(
"0x%04hx ",d[i]);