1#include "RawDataCnv/Util/ZddConverter.h"
2#include "ZddEvent/ZddBoard.h"
3#include "ZddEvent/ZddChannel.h"
11 if ( s_instance == 0 ) {
20 if ( s_instance != 0 ) {
37 uint32_t* pend = pdata + size;
39 while ( pdata < pend ) {
40 pdata = decodeBoard(pdata, evt);
43 if ( pdata != pend ) {
44 std::cout <<
"ZddConverter: there are problems within the event data size" << std::endl;
51uint32_t* ZddConverter::decodeBoard(uint32_t* pevt,
Event::ZddEvent* evt)
53 if ( (pevt[0] >> 28) != 10 ) {
54 std::cout <<
"ZddConverter get wrong event marker!" << std::endl;
58 int size = pevt[0] & 0xFFFFFFF;
59 int board = pevt[1] >> 27;
60 uint32_t chMask = pevt[1] & 0xFF;
69 uint32_t* pend = pevt + size;
70 uint32_t* pchannel = pevt + 4;
72 while ( pchannel < pend ) {
73 while ( (chMask&(1<<ich)) == 0 ) {
76 std::cout <<
"ZddConverter get wrong channel mask!" << std::endl;
83 pchannel = decodeChannel(pchannel, zddCh);
87 if ( pchannel != pend ) {
88 std::cout <<
"ZddConverter: there are problems within the channel data size" << std::endl;
95uint32_t* ZddConverter::decodeChannel(uint32_t* pch,
ZddChannel* zddCh)
97 uint32_t* pend = pch + pch[0];
98 uint32_t* pfrag = pch + 1;
106 while ( pfrag < pend ) {
107 uint32_t& ctrl_word = pfrag[0];
108 int size = (ctrl_word & 0x1FFFFF) * 4;
110 if ( ctrl_word >> 31 ) {
111 if ( (pfrag + size/4 + 1) > pend ) {
112 std::cout <<
"BAD ZDD RAW DATA!" << std::endl;
118 zddFrag.
sample =
new unsigned char[size];
119 memcpy(zddFrag.
sample, pfrag+1, size);
122 if ( lstat < 0 ) ++nCtrlWord;
127 if ( lstat > 0 ) ++ nCtrlWord;
133 if ( nCtrlWord == 14 ) {
134 if ( pfrag < pend ) {
136 zddFrag.
length = (pend-pfrag)*4;
148ZddConverter::ZddConverter(
int runMode)
153ZddConverter::~ZddConverter()
void addChannel(ZddChannel *ch)
void setBoardId(int boardId)
void setCounter(int counter)
void setTimeTag(int timeTag)
void addFragments(const ZddFragment &frag)
static ZddConverter * instance(int runMode=2)
bool convert(uint32_t *pdata, int size, Event::ZddEvent *evt)