5 #ifndef HTBDAQ_DATA_STANDALONE
21 : m_formatVersion(hd.m_formatVersion), m_rawLength(hd.m_rawLength), m_rawConst(hd.m_rawConst), m_ownData(nullptr) {}
28 const int needed = 0x200;
32 memset(
m_ownData, 0,
sizeof(
unsigned short) * needed);
162 const unsigned short** daq_last,
163 const unsigned short** tp_first,
164 const unsigned short** tp_last)
const {
165 int tp_words_total, daq_words_total, headerLen, trailerLen;
169 *tp_last = *tp_first + (tp_words_total - 1);
170 *daq_first = *tp_last + 1;
171 *daq_last = *daq_first + (daq_words_total - 1);
175 static const int channelDecoder[32] = {0, 1, 2, 99, 3, 4, 5, 99, 6, 7, 8, 99, 9, 10, 11, 99,
176 12, 13, 14, 99, 15, 16, 17, 99, 18, 19, 20, 99, 21, 22, 23, 99};
179 unsigned short* daq_samples,
180 unsigned char* tp_lengths,
181 unsigned short* tp_samples)
const {
182 if (daq_lengths !=
nullptr)
184 if (tp_lengths !=
nullptr)
191 int tp_words_total, daq_words_total, headerLen, trailerLen;
196 const unsigned short* tpBase =
m_rawConst + headerLen;
198 if (tp_lengths !=
nullptr) {
199 for (wordPtr = 0; wordPtr < tp_words_total; wordPtr++) {
208 const unsigned short* daqBase =
m_rawConst + headerLen + tp_words_total;
212 if (daq_lengths !=
nullptr) {
213 for (wordPtr = 0; wordPtr < daq_words_total; wordPtr++) {
217 int capid = (daqBase[wordPtr] & 0x180) >> 7;
218 int erdv = (daqBase[wordPtr] & 0x600) >> 9;
219 if (erdv != 0
x1 || (lastChan == ichan && (capid != ((lastCapid + 1) % 4)))) {
220 daq_lengths[ichan] |= 0x80;
225 int useLength = daq_lengths[ichan] & 0x1F;
228 daq_lengths[ichan] = (useLength + 1) | (daq_lengths[ichan] & 0xE0);
234 unsigned short* daq_samples,
235 unsigned char* tp_lengths,
236 unsigned short* tp_samples,
238 int tp_words_total = 0, daq_words_total = 0, headerLen, trailerLen;
246 unsigned short* ptr =
m_ownData + headerLen;
247 if (tp_samples !=
nullptr && tp_lengths !=
nullptr) {
248 for (ichan = 0; ichan < 24; ichan++) {
249 unsigned short chanid = ((ichan % 4) + (((ichan / 4) + 1) << 2)) << 11;
258 ptr =
m_ownData + headerLen + tp_words_total;
259 for (ichan = 0; ichan < 24; ichan++) {
260 unsigned short chanid = ((ichan % 3) + ((ichan / 3) << 2)) << 11;
264 basedata = (basedata & 0x7F) | (0x200) | ((isample % 4) << 7);
265 ptr[daq_words_total] = chanid | basedata;
269 unsigned short totalLen;
272 totalLen = headerLen + tp_words_total + daq_words_total + trailerLen;
278 totalLen = headerLen + tp_words_total + daq_words_total + trailerLen;
279 if ((totalLen % 2) == 1) {
286 m_ownData[totalLen - 4] = daq_words_total;
288 if (trailerLen == 12) {
289 for (
int i = 12;
i > 4;
i--)
304 m_ownData[1] = (L1Anumber & 0xFFFF00) >> 8;
307 m_ownData[3] = ((orbitn & 0xFF) << 8) | (submodule & 0xFF);
313 m_ownData[3] = ((orbitn & 0x3F) << 10) | (submodule & 0x3FF);
315 m_ownData[3] = ((orbitn & 0x1F) << 11) | (submodule & 0x7FF);
317 m_ownData[5] |= ((nps & 0x1F) << 3) | 0x1;
318 m_ownData[6] = ((firmwareRev & 0x70000) >> 3) | (firmwareRev & 0x1FFF);
319 m_ownData[7] = (pipeline & 0xFF) | ((firmwareFlav & 0x3F) << 8);
331 for (
int fiber = 1; fiber <= 8; fiber++) {
332 for (
int fiberchan = 0; fiberchan <= 2; fiberchan++) {
333 int linchan = (fiber - 1) * 3 + fiberchan;
337 val |= 1 << (linchan % 8);
367 return ((smid >> 1) & 0x1F);
371 return (smid & 0x01);
375 return ((smid >> 6) & 0x1F);
380 if (fiber < 1 || fiber > 8 || fiberchan < 0 || fiberchan > 2)
384 int linchan = (fiber - 1) * 3 + fiberchan;
387 return ((
val >> (linchan % 8)) & 0
x1) != 0;
390 if (slb < 1 || slb > 6 || slbchan < 0 || slbchan > 3)
394 int linchan = (
slb - 1) * 4 + slbchan;
397 return ((
val >> (linchan % 8)) & 0x100) != 0;
450 retval = ((
m_rawConst[7]) & (1 << ifiber)) != 0;
456 unsigned short header,
int& flav,
int& error_flags,
int& capid0,
int& channelid) {
457 flav = (
header >> 12) & 0x7;
458 error_flags = (
header >> 10) & 0x3;
459 capid0 = (
header >> 8) & 0x3;
460 channelid = (
header)&0xFF;
461 return (
header & 0x8000) != 0;
471 if (fiber1 != myfiber && fiber2 != myfiber)
475 int offset = 6 + mysc * 4 * 32 + capid * 32;
476 if (myfiber == fiber2)
478 for (
int i = 0;
i < 32;
i++)
482 int offset = 8 + mysc * 4 * 32 + capid * 32;
483 if (myfiber == fiber2)
485 for (
int i = 0;
i < 32;
i++)