11 if ( s_instance == 0 ) {
20 if ( s_instance != 0 ) {
38 uint32_t* pend = pdata + size;
40 while ( pdata < pend ) {
41 pdata = decodeBoard(pdata, evt);
44 if ( pdata != pend ) {
45 std::cout <<
"ZddConverter: there are problems within the event data size" << std::endl;
52uint32_t* ZddConverter::decodeBoard(uint32_t* pevt,
Event::ZddEvent* evt)
54 if ( (pevt[0] >> 28) != 10 ) {
55 std::cout <<
"ZddConverter get wrong event marker!" << std::endl;
59 int size = pevt[0] & 0xFFFFFFF;
60 int board = pevt[1] >> 27;
61 uint32_t chMask = pevt[1] & 0xFF;
70 uint32_t* pend = pevt + size;
71 uint32_t* pchannel = pevt + 4;
73 while ( pchannel < pend ) {
74 while ( (chMask&(1<<ich)) == 0 ) {
77 std::cout <<
"ZddConverter get wrong channel mask!" << std::endl;
84 pchannel = decodeChannel(pchannel, zddCh);
88 if ( pchannel != pend ) {
89 std::cout <<
"ZddConverter: there are problems within the channel data size" << std::endl;
96uint32_t* ZddConverter::decodeChannel(uint32_t* pch,
ZddChannel* zddCh)
98 uint32_t* pend = pch + pch[0];
99 uint32_t* pfrag = pch + 1;
109 while ( pfrag < pend ) {
110 uint32_t& ctrl_word = pfrag[0];
111 int size = (ctrl_word & 0x1FFFFF) * 4;
113 if ( ctrl_word >> 31 ) {
115 if ( ctrl_word == 0xFEFEFEFE )
break;
119 if ( (pfrag + size/4 + 1) > pend ) {
120 std::cout <<
"BAD ZDD RAW DATA!" << std::endl;
126 zddFrag.
sample =
new unsigned char[size];
127 memcpy(zddFrag.
sample, pfrag+1, size);
130 if ( lstat < 0 ) ++nCtrlWord;
135 if ( lstat > 0 ) ++ nCtrlWord;
154 if ( index < samples ) {
163ZddConverter::ZddConverter(
int runMode)
168ZddConverter::~ZddConverter()
void addChannel(ZddChannel *ch)
void setBoardId(int boardId)
void setCounter(int counter)
void setTimeTag(int timeTag)
void addFragments(const ZddFragment &frag)
void setScanCode(int scanCode)
static ZddConverter * instance(int runMode=2)
bool convert(uint32_t *pdata, int size, Event::ZddEvent *evt)