9#include <rawdata/dataobjects/PreRawCOPPERFormat_v2.h>
33 -
tmp_trailer.RAWTRAILER_NWORDS - SIZE_COPPER_DRIVER_TRAILER;
34 unsigned int chksum = 0;
35 for (
int i = min; i < max; i++) {
49 - (
static_cast<int>(SIZE_B2LHSLB_HEADER) + SIZE_B2LHSLB_TRAILER + SIZE_B2LFEE_HEADER + SIZE_B2LFEE_TRAILER);
63 "[FATAL] %s ch=%d : ERROR_EVENT : COPPER's magic word is invalid. Exiting... Maybe it is due to data corruption or different version of the data format. : slot%c eve 0x%x exp %d run %d sub %d\n %s %s %d\n",
64 hostname, finesse_num,
66 __FILE__, __PRETTY_FUNCTION__, __LINE__);
67 printf(
"[DEBUG] %s", err_buf); fflush(stdout);
70 for (
int i = 0; i < 4; i++) {
71 printf(
"[DEBUG] ========== CRC check : block # %d finesse %d ==========\n", n, i);
76 printf(
"[DEBUG] ========== No CRC error. : block %d =========\n", n);
81 switch (finesse_num) {
99 "[FATAL] %s ch=%d : ERROR_EVENT : Specified FINESSE number( = %d ) is invalid. Exiting... : slot%c eve 0x%x exp %d run %d sub %d\n %s %s %d\n",
100 hostname, finesse_num,
103 __FILE__, __PRETTY_FUNCTION__, __LINE__);
104 printf(
"%s", err_buf); fflush(stdout);
116#ifndef READ_OLD_B2LFEE_FORMAT_FILE
119 unsigned int eve_num = 0;
122 for (
int i = 0; i < 4 ; i++) {
123 eve[ i ] = 0xbaadf00d;
127 if (flag != 1) eve_num = eve[ i ];
128 if (eve_num != eve[ i ]) err_flag = 1;
139 "[FATAL] %s ch=%d : ERROR_EVENT : No HSLB data in COPPER data. Exiting... : eve 0x%x exp %d run %d sub %d\n %s %s %d\n",
142 __FILE__, __PRETTY_FUNCTION__, __LINE__);
143 printf(
"%s", err_buf); fflush(stdout);
153 "[FATAL] %s ch=%d : ERROR_EVENT : CORRUPTED DATA: Different event number over HSLBs : slot A 0x%.8x : B 0x%.8x :C 0x%.8x : D 0x%.8x : eve 0x%x exp %d run %d sub %d\n%s %s %d\n",
155 eve[ 0 ], eve[ 1 ], eve[ 2 ], eve[ 3 ],
157 __FILE__, __PRETTY_FUNCTION__, __LINE__);
158 printf(
"[DEBUG] %s\n", err_buf);
160 for (
int i = 0; i < 4; i++) {
161 printf(
"[DEBUG] ========== CRC check : block # %d finesse %d ==========\n", n, i);
166 printf(
"[DEBUG] ========== No CRC error. : block %d =========\n", n);
177 sprintf(err_buf,
"[FATAL] You need comment out READ_OLD_B2LFEE_FORMAT_FILE if you are handling a new data format\n%s %s %d\n",
178 __FILE__, __PRETTY_FUNCTION__, __LINE__);
179 printf(
"%s", err_buf); fflush(stdout);
187 unsigned int prev_evenum,
unsigned int* cur_evenum_rawcprhdr,
188 unsigned int prev_copper_ctr,
unsigned int* cur_copper_ctr,
189 unsigned int prev_exprunsubrun_no,
unsigned int* cur_exprunsubrun_no)
201 "[FATAL] %s ch=%d : ERROR_EVENT : Invalid Magic word 0x7FFFF0008=%u 0xFFFFFAFA=%u 0xFFFFF5F5=%u 0x7FFF0009=%u : eve 0x%x exp %d run %d sub %d\n%s %s %d\n",
205 __FILE__, __PRETTY_FUNCTION__, __LINE__);
212 *cur_evenum_rawcprhdr =
GetEveNo(n);
214 if (*cur_evenum_rawcprhdr != evenum_feehdr) {
219 "[FATAL] %s ch=%d : ERROR_EVENT : Event # in PreRawCOPPERFormat_v2 header and FEE header is different : cprhdr 0x%x feehdr 0x%x : Exiting... : eve 0x%x exp %d run %d sub %d\n%s %s %d\n",
221 *cur_evenum_rawcprhdr, evenum_feehdr,
223 __FILE__, __PRETTY_FUNCTION__, __LINE__);
232 if (prev_exprunsubrun_no == *cur_exprunsubrun_no) {
233 if ((
unsigned int)(prev_evenum + 1) != *cur_evenum_rawcprhdr) {
237 "[FATAL] %s ch=%d : ERROR_EVENT : Event # jump : i %d prev 0x%x cur 0x%x : prevrun %.8x currun %.8x: Exiting... : eve 0x%x exp %d run %d sub %d\n%s %s %d\n",
239 n, prev_evenum, *cur_evenum_rawcprhdr, prev_exprunsubrun_no, *cur_exprunsubrun_no,
241 __FILE__, __PRETTY_FUNCTION__, __LINE__);
244 if ((
unsigned int)(prev_copper_ctr + 1) != *cur_copper_ctr) {
248 "[FATAL] %s ch=%d : ERROR_EVENT : COPPER counter jump : i %d prev 0x%x cur 0x%x : eve 0x%x exp %d run %d sub %d\n%s %s %d\n",
250 n, prev_copper_ctr, *cur_copper_ctr,
252 __FILE__, __PRETTY_FUNCTION__, __LINE__);
256 printf(
"[DEBUG] New run started. cur run %.8x prev. run %.8x cur eve %.8x prev eve %8.x : eve 0x%x exp %d run %d sub %d\n",
257 *cur_exprunsubrun_no, prev_exprunsubrun_no, *cur_evenum_rawcprhdr, prev_evenum,
261 if ((
unsigned int)
GetRunNo(n) != (prev_exprunsubrun_no & RawHeader_v2::RUNNO_MASK) >> RawHeader_v2::RUNNO_SHIFT) {
262 if (*cur_evenum_rawcprhdr != 0) {
265 for (
int i = 0; i < 4 ; i++) {
266 eve[ i ] = 0xbaadf00d;
276 "[FATAL] %s ch=%d : ERROR_EVENT : Invalid Event # at the beginning of the run (It should be zero.): preveve 0x%x cureve 0x%x : prev(exp %u run %u sub %u ) cur(exp %u run %u sub %u ) ( A:0x%.8x B:0x%.8x C:0x%.8x D:0x%.8x ) Exiting... : eve 0x%x exp %d run %d sub %d\n %s %s %d\n",
278 prev_evenum, *cur_evenum_rawcprhdr,
279 prev_exprunsubrun_no >> 22, (prev_exprunsubrun_no >> 8) & 0x3FFF, prev_exprunsubrun_no & 0xFF,
280 *cur_exprunsubrun_no >> 22, (*cur_exprunsubrun_no >> 8) & 0x3FFF, *cur_exprunsubrun_no & 0xFF,
281 eve[ 0 ], eve[ 1 ], eve[ 2 ], eve[ 3 ],
283 __FILE__, __PRETTY_FUNCTION__, __LINE__);
304 "[FATAL] %s ch=%d : ERROR_EVENT : COPPER driver checkSum error : block %d : length %d eve 0x%x : Trailer chksum 0x%.8x : calcd. now 0x%.8x : eve 0x%x exp %d run %d sub %d\n%s %s %d\n",
308 __FILE__, __PRETTY_FUNCTION__, __LINE__);
321 "[FATAL] %s ch=%d : ERROR_EVENT : PreRawCOPPERFormat_v2 checksum error : block %d : length %d eve 0x%x : Trailer chksum 0x%.8x : calcd. now 0x%.8x : eve 0x%x exp %d run %d sub %d\n %s %s %d\n",
325 __FILE__, __PRETTY_FUNCTION__, __LINE__);
330 printf(
"%s", err_buf); fflush(stdout);
331 printf(
"[DEBUG] ========== dump a data blcok : block # %d==========\n", n);
333 for (
int i = 0; i < 4; i++) {
334 printf(
"[DEBUG] ========== CRC check : block # %d finesse %d ==========\n", n, i);
339 printf(
"[DEBUG] ========== No CRC error : block %d =========\n", n);
365#ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
366 CheckB2LFEEHeaderVersion(n);
370 unsigned int temp_utime = 0, temp_ctime_trgtype = 0, temp_eve = 0, temp_exprun = 0;
371 unsigned int temp_ctime_trgtype_footer, temp_eve_footer;
372 unsigned int utime[4], ctime_trgtype[4], eve[4], exprun[4];
376 memset(utime, 0,
sizeof(utime));
377 memset(ctime_trgtype, 0,
sizeof(ctime_trgtype));
378 memset(eve, 0,
sizeof(eve));
379 memset(exprun, 0,
sizeof(exprun));
382 for (
int i = 0; i < 4; i++) {
384 if (finesse_nwords > 0) {
386 ctime_trgtype[ i ] =
m_buffer[ offset_finesse + SIZE_B2LHSLB_HEADER + POS_TT_CTIME_TYPE ];
387 utime[ i ] =
m_buffer[ offset_finesse + SIZE_B2LHSLB_HEADER + POS_TT_UTIME ];
388 eve[ i ] =
m_buffer[ offset_finesse + SIZE_B2LHSLB_HEADER + POS_TT_TAG ];
389 exprun[ i ] =
m_buffer[ offset_finesse + SIZE_B2LHSLB_HEADER + POS_EXP_RUN ];
390 temp_ctime_trgtype_footer =
391 m_buffer[ offset_finesse + finesse_nwords - (
static_cast<int>(SIZE_B2LFEE_TRAILER) + SIZE_B2LHSLB_TRAILER) + POS_TT_CTIME_B2LFEE ];
393 m_buffer[ offset_finesse + finesse_nwords - (
static_cast<int>(SIZE_B2LFEE_TRAILER) + SIZE_B2LHSLB_TRAILER) + POS_CHKSUM_B2LFEE ];
396 temp_ctime_trgtype = ctime_trgtype[ i ];
397 temp_utime = utime[ i ];
399 temp_exprun = exprun[ i ];
403 if (temp_ctime_trgtype != ctime_trgtype[ i ] || temp_utime != utime[ i ] ||
404 temp_eve != eve[ i ] || temp_exprun != exprun[ i ]) {
408 for (
int j = 0; j < 4; j++) {
409 printf(
"[DEBUG] %s ch=%d : FINESSE #=%d buffsize %d ctimeTRGtype 0x%.8x utime 0x%.8x eve 0x%.8x exprun 0x%.8x\n",
411 j,
GetFINESSENwords(n, j), ctime_trgtype[ j ], utime[ j ], eve[ j ], exprun[ j ]);
415 char err_buf_1[2500], err_buf_2[3000], err_buf_3[3500];
417 "[FATAL] %s ch=%d : ERROR_EVENT : mismatch header value over FINESSEs. Exiting...",
420 "%s FINESSE #=%d buffsize %d ctimeTRGtype 0x%.8x utime 0x%.8x eve 0x%.8x exprun 0x%.8x",
422 first_ch,
GetFINESSENwords(n, first_ch), ctime_trgtype[ first_ch ], utime[ first_ch ], eve[ first_ch ], exprun[ first_ch ]);
424 "%s FINESSE #=%d buffsize %d ctimeTRGtype 0x%.8x utime 0x%.8x eve 0x%.8x exprun 0x%.8x",
426 i,
GetFINESSENwords(n, i), ctime_trgtype[ i ], utime[ i ], eve[ i ], exprun[ i ]);
427 sprintf(err_buf,
"%s\n %s %s %d\n",
429 __FILE__, __PRETTY_FUNCTION__, __LINE__);
430 printf(
"%s", err_buf); fflush(stdout);
434 }
else if (temp_ctime_trgtype != temp_ctime_trgtype_footer ||
435 (temp_eve & 0xffff) != ((temp_eve_footer >> 16) & 0xffff)) {
439 "[FATAL] %s ch=%d : ERROR_EVENT : mismatch(finesse %d) between header(ctime %.8x eve %.8x) and footer(ctime %.8x eve_crc16 %.8x). Exiting...\n %s %s %d\n",
441 i, temp_ctime_trgtype, temp_eve, temp_ctime_trgtype_footer, temp_eve_footer,
442 __FILE__, __PRETTY_FUNCTION__, __LINE__);
443 printf(
"%s", err_buf); fflush(stdout);
451 for (
int i = 0; i < 4; i++) {
453 printf(
"[DEBUG] ========== CRC check : block # %d finesse %d ==========\n", n, i);
455 printf(
"[DEBUG] ========== CRC check is done. : block %d =========\n", n);
467 unsigned int prev_exprunsubrun_no,
unsigned int* cur_exprunsubrun_no)
469 const int datablock_id = 0;
477 "[FATAL] This function should be used for PreRawCOPPERFormat_v2 containing only one datablock, while. this object has num_nodes of %d and num_events of %d\n %s %s %d\n",
479 printf(
"%s", err_buf); fflush(stdout);
504 if (copper_buf[ POS_CH_A_DATA_LENGTH ] == 0 &&
505 copper_buf[ POS_CH_B_DATA_LENGTH ] == 0 &&
506 copper_buf[ POS_CH_C_DATA_LENGTH ] == 0 &&
507 copper_buf[ POS_CH_D_DATA_LENGTH ] == 0) {
510 GetNodeName(hostname, m_node_id,
sizeof(hostname));
512 "[FATAL] %s ch=%d : ERROR_EVENT : No FINESSE data in a copper data block. Exiting...\n %s %s %d\n",
514 __FILE__, __PRETTY_FUNCTION__, __LINE__);
515 printf(
"%s", err_buf); fflush(stdout);
523 int datablock_nwords =
525 (copper_buf[ POS_DATA_LENGTH ]
526 + SIZE_COPPER_DRIVER_HEADER
527 + SIZE_COPPER_DRIVER_TRAILER)
539 GetNodeName(hostname, m_node_id,
sizeof(hostname));
541 "[FATAL] %s ch=%d : ERROR_EVENT : Data length is inconsistent m_nwords %d : nwords from COPPER data %d\n %s %s %d\n",
544 __FILE__, __PRETTY_FUNCTION__, __LINE__);
545 printf(
"%s", err_buf); fflush(stdout);
553 int offset_1st_finesse =
static_cast<int>(
tmp_header.RAWHEADER_NWORDS) + SIZE_COPPER_HEADER;
554 int offset_2nd_finesse = offset_1st_finesse + copper_buf[ POS_CH_A_DATA_LENGTH ];
555 int offset_3rd_finesse = offset_2nd_finesse + copper_buf[ POS_CH_B_DATA_LENGTH ];
556 int offset_4th_finesse = offset_3rd_finesse + copper_buf[ POS_CH_C_DATA_LENGTH ];
567 m_buffer[
tmp_header.POS_EXP_RUN_NO ] = finesse_buf[
static_cast<int>(SIZE_B2LHSLB_HEADER) + POS_EXP_RUN ];
573 unsigned int cur_ftsw_eve32 = finesse_buf[
static_cast<int>(SIZE_B2LHSLB_HEADER) + POS_TT_TAG ];
579 m_buffer[
tmp_header.POS_TTCTIME_TRGTYPE ] = finesse_buf[
static_cast<int>(SIZE_B2LHSLB_HEADER) + POS_TT_CTIME_TYPE ];
580 m_buffer[
tmp_header.POS_TTUTIME ] = finesse_buf[
static_cast<int>(SIZE_B2LHSLB_HEADER) + POS_TT_UTIME ];
596 unsigned int ff55_higher_bits, ff55_lower_bits;
598 if (copper_buf[ POS_CH_A_DATA_LENGTH ] != 0) {
599 ff55_higher_bits = (
unsigned int)(
m_buffer[ offset_1st_finesse + copper_buf[ POS_CH_A_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ]) &
602 ff55_lower_bits =
m_buffer[ offset_1st_finesse + copper_buf[ POS_CH_A_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ] & 0xFFFF;
604 if (ff55_higher_bits != 0xff550000) {
607 GetNodeName(hostname, m_node_id,
sizeof(hostname));
609 "[FATAL] %s ch=%d : ERROR_EVENT : HSLB slotA's trailer magic word(0xff55) is invalid. : eve %8u run %d foooter %.8x : %s %s %d\n",
612 m_buffer[ offset_1st_finesse + copper_buf[ POS_CH_A_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
613 __FILE__, __PRETTY_FUNCTION__, __LINE__);
614 printf(
"%s", err_buf); fflush(stdout);
619 if (ff55_lower_bits != 0) {
620 const int linkdown_bit = 15;
624 GetNodeName(hostname, m_node_id,
sizeof(hostname));
626 if ((ff55_lower_bits & (1 << linkdown_bit)) != 0) {
627 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : B2link down on slot A eve %8u foooter %.8x : %s %s %d\n",
630 m_buffer[ offset_1st_finesse + copper_buf[ POS_CH_A_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
631 __FILE__, __PRETTY_FUNCTION__, __LINE__);
632 printf(
"%s", err_buf); fflush(stdout);
637 if (((
unsigned int)m_node_id & DETECTOR_MASK) == ARICH_ID) {
641 "[WARNING] %s ch=%d : ARICH : B2link packet CRC error slot A eve %8u foooter %.8x : This error is ignored and the error event will be recorded in .sroot file acording to request from ARICH group: %s %s %d\n",
644 m_buffer[ offset_1st_finesse + copper_buf[ POS_CH_A_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
645 __FILE__, __PRETTY_FUNCTION__, __LINE__);
646 printf(
"%s", err_buf); fflush(stdout);
652 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : B2link packet CRC error slot A eve %8u foooter %.8x : %s %s %d\n",
655 m_buffer[ offset_1st_finesse + copper_buf[ POS_CH_A_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
656 __FILE__, __PRETTY_FUNCTION__, __LINE__);
657 printf(
"%s", err_buf); fflush(stdout);
666 if (copper_buf[ POS_CH_B_DATA_LENGTH ] != 0) {
667 ff55_higher_bits = (
unsigned int)(
m_buffer[ offset_2nd_finesse + copper_buf[ POS_CH_B_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ]) &
670 ff55_lower_bits = (
m_buffer[ offset_2nd_finesse + copper_buf[ POS_CH_B_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ] & 0xFFFF);
672 GetNodeName(hostname, m_node_id,
sizeof(hostname));
673 if (ff55_higher_bits != 0xff550000) {
676 "[FATAL] %s ch=%d : ERROR_EVENT : HSLB slotB's trailer magic word(0xff55) is invalid. : eve %8u run %d foooter %.8x : %s %s %d\n",
679 m_buffer[ offset_2nd_finesse + copper_buf[ POS_CH_B_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
680 __FILE__, __PRETTY_FUNCTION__, __LINE__);
681 printf(
"%s", err_buf); fflush(stdout);
686 if (ff55_lower_bits != 0) {
688 const int linkdown_bit = 15;
690 if ((ff55_lower_bits & (1 << linkdown_bit)) != 0) {
691 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : B2link down on slot B eve %8u foooter %.8x : %s %s %d\n",
694 m_buffer[ offset_2nd_finesse + copper_buf[ POS_CH_B_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
695 __FILE__, __PRETTY_FUNCTION__, __LINE__);
696 printf(
"%s", err_buf); fflush(stdout);
701 if (((
unsigned int)m_node_id & DETECTOR_MASK) == ARICH_ID) {
705 "[WARNING] %s ch=%d : ARICH : B2link packet CRC error slot B eve %8u foooter %.8x : This error is ignored and the error event will be recorded in .sroot file acording to request from ARICH group: %s %s %d\n",
708 m_buffer[ offset_2nd_finesse + copper_buf[ POS_CH_B_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
709 __FILE__, __PRETTY_FUNCTION__, __LINE__);
710 printf(
"%s", err_buf); fflush(stdout);
716 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : B2link packet CRC error slot B eve %8u foooter %.8x : %s %s %d\n",
719 m_buffer[ offset_2nd_finesse + copper_buf[ POS_CH_B_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
720 __FILE__, __PRETTY_FUNCTION__, __LINE__);
721 printf(
"%s", err_buf); fflush(stdout);
730 if (copper_buf[ POS_CH_C_DATA_LENGTH ] != 0) {
731 ff55_higher_bits = (
unsigned int)(
m_buffer[ offset_3rd_finesse + copper_buf[ POS_CH_C_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ]) &
734 ff55_lower_bits = (
m_buffer[ offset_3rd_finesse + copper_buf[ POS_CH_C_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ] & 0xFFFF);
736 GetNodeName(hostname, m_node_id,
sizeof(hostname));
737 if (ff55_higher_bits != 0xff550000) {
740 "[FATAL] %s ch=%d : ERROR_EVENT : HSLB slotC's trailer magic word(0xff55) is invalid. : eve %8u run %d foooter %.8x : %s %s %d\n",
743 m_buffer[ offset_3rd_finesse + copper_buf[ POS_CH_C_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
744 __FILE__, __PRETTY_FUNCTION__, __LINE__);
745 printf(
"%s", err_buf); fflush(stdout);
750 if (ff55_lower_bits != 0) {
752 const int linkdown_bit = 15;
754 if ((ff55_lower_bits & (1 << linkdown_bit)) != 0) {
755 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : B2link down on slot C eve %8u foooter %.8x : %s %s %d\n",
758 m_buffer[ offset_3rd_finesse + copper_buf[ POS_CH_C_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
759 __FILE__, __PRETTY_FUNCTION__, __LINE__);
760 printf(
"%s", err_buf); fflush(stdout);
765 if (((
unsigned int)m_node_id & DETECTOR_MASK) == ARICH_ID) {
769 "[WARNING] %s ch=%d : ARICH : B2link packet CRC error slot C eve %8u foooter %.8x : This error is ignored and the error event will be recorded in .sroot file acording to request from ARICH group: %s %s %d\n",
772 m_buffer[ offset_3rd_finesse + copper_buf[ POS_CH_C_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
773 __FILE__, __PRETTY_FUNCTION__, __LINE__);
774 printf(
"%s", err_buf); fflush(stdout);
780 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : B2link packet CRC error slot C eve %8u foooter %.8x : %s %s %d\n",
783 m_buffer[ offset_3rd_finesse + copper_buf[ POS_CH_C_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
784 __FILE__, __PRETTY_FUNCTION__, __LINE__);
785 printf(
"%s", err_buf); fflush(stdout);
795 if (copper_buf[ POS_CH_D_DATA_LENGTH ] != 0) {
796 ff55_higher_bits = (
unsigned int)(
m_buffer[ offset_4th_finesse + copper_buf[ POS_CH_D_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ]) &
799 ff55_lower_bits = (
m_buffer[ offset_4th_finesse + copper_buf[ POS_CH_D_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ] & 0xFFFF);
801 GetNodeName(hostname, m_node_id,
sizeof(hostname));
802 if (ff55_higher_bits != 0xff550000) {
805 "[FATAL] %s ch=%d : ERROR_EVENT : HSLB slotD's trailer magic word(0xff55) is invalid. : eve %8u run %d foooter %.8x : %s %s %d\n",
808 m_buffer[ offset_4th_finesse + copper_buf[ POS_CH_D_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
809 __FILE__, __PRETTY_FUNCTION__, __LINE__);
810 printf(
"%s", err_buf); fflush(stdout);
815 if (ff55_lower_bits != 0) {
817 const int linkdown_bit = 15;
819 if ((ff55_lower_bits & (1 << linkdown_bit)) != 0) {
820 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : B2link down on slot D eve %8u foooter %.8x : %s %s %d\n",
823 m_buffer[ offset_4th_finesse + copper_buf[ POS_CH_D_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
824 __FILE__, __PRETTY_FUNCTION__, __LINE__);
825 printf(
"%s", err_buf); fflush(stdout);
830 if (((
unsigned int)m_node_id & DETECTOR_MASK) == ARICH_ID) {
834 "[WARNING] %s ch=%d : ARICH : B2link packet CRC error slot D eve %8u foooter %.8x : This error is ignored and the error event will be recorded in .sroot file acording to request from ARICH group: %s %s %d\n",
837 m_buffer[ offset_4th_finesse + copper_buf[ POS_CH_D_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
838 __FILE__, __PRETTY_FUNCTION__, __LINE__);
839 printf(
"%s", err_buf); fflush(stdout);
845 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : B2link packet CRC error slot D eve %8u foooter %.8x : %s %s %d\n",
848 m_buffer[ offset_4th_finesse + copper_buf[ POS_CH_D_DATA_LENGTH ] - SIZE_B2LHSLB_HEADER ],
849 __FILE__, __PRETTY_FUNCTION__, __LINE__);
850 printf(
"%s", err_buf); fflush(stdout);
869 unsigned int chksum_top = 0, chksum_body = 0, chksum_bottom = 0;
872 for (
int i = 0; i < top_end; i++) {
875 int body_end = datablock_nwords - SIZE_COPPER_DRIVER_TRAILER -
tmp_trailer.RAWTRAILER_NWORDS;
876 for (
int i = top_end; i < body_end; i++) {
880 int bottom_end = datablock_nwords -
tmp_trailer.RAWTRAILER_NWORDS;
881 for (
int i = body_end; i < bottom_end; i++) {
888 if (chksum_body != (
unsigned int)(
m_buffer[ body_end ])) {
891 GetNodeName(hostname, m_node_id,
sizeof(hostname));
892 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : COPPER driver checksum is not consistent.: calcd. %.8x data %.8x\n %s %s %d\n",
895 __FILE__, __PRETTY_FUNCTION__, __LINE__);
896 printf(
"%s", err_buf); fflush(stdout);
903 unsigned int chksum = chksum_top ^ chksum_body ^ chksum_bottom;
919 int* fpga_trailer_magic = trl - (SIZE_COPPER_TRAILER - POS_MAGIC_COPPER_3);
920 int* driver_trailer_magic = trl - (SIZE_COPPER_TRAILER - POS_MAGIC_COPPER_4);
922 if ((
unsigned int)(copper_buf[ POS_MAGIC_COPPER_1 ]) != COPPER_MAGIC_DRIVER_HEADER) {
924 }
else if ((
unsigned int)(copper_buf[ POS_MAGIC_COPPER_2 ]) != COPPER_MAGIC_FPGA_HEADER) {
926 }
else if ((
unsigned int)(*fpga_trailer_magic) != COPPER_MAGIC_FPGA_TRAILER) {
928 }
else if ((
unsigned int)(*driver_trailer_magic) != COPPER_MAGIC_DRIVER_TRAILER) {
934 GetNodeName(hostname, m_node_id,
sizeof(hostname));
936 "[FATAL] %s ch=%d : ERROR_EVENT : Invalid Magic word 0x7FFFF0008=%u 0xFFFFFAFA=%u 0xFFFFF5F5=%u 0x7FFF0009=%u\n %s %s %d\n",
942 __FILE__, __PRETTY_FUNCTION__, __LINE__);
943 printf(
"[DEBUG] %s\n", err_buf);
960 if (prev_exprunsubrun_no == *cur_exprunsubrun_no) {
961 if (prev_eve32 + 1 != cur_ftsw_eve32) {
962 unsigned int eve[4] = {0xbaadf00d, 0xbaadf00d, 0xbaadf00d, 0xbaadf00d };
967 "[FATAL] This function should be used for PreRawCOPPERFormat_v2 containing only one datablock, while. this object has num_nodes of %d and num_events of %d\n %s %s %d\n",
969 printf(
"%s", err_buf); fflush(stdout);
973 for (
int i = 0; i < 4 ; i++) {
985 GetNodeName(hostname, m_node_id,
sizeof(hostname));
987 "[FATAL] %s ch=%d : ERROR_EVENT : Invalid event_number. Exiting...: cur 32bit eve %u preveve %u ( A:0x%.8x B:0x%.8x C:0x%.8x D:0x%.8x ) prun %u crun %u\n %s %s %d\n",
989 cur_ftsw_eve32, prev_eve32,
990 eve[ 0 ], eve[ 1 ], eve[ 2 ], eve[ 3 ],
991 prev_exprunsubrun_no, *cur_exprunsubrun_no,
992 __FILE__, __PRETTY_FUNCTION__, __LINE__);
993 printf(
"[DEBUG] %s\n", err_buf);
999 for (
int i = 0; i < 4; i++) {
1000 printf(
"[DEBUG] ========== CRC check : block # %d finesse %d ==========\n", datablock_id, i);
1005 printf(
"[DEBUG] ========== No CRC error : block %d =========\n", datablock_id);
1013 return cur_ftsw_eve32;
1019#ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
1020void PreRawCOPPERFormat_v2::CheckB2LFEEHeaderVersion(
int n)
1023 for (
int i = 0; i < 4; i++) {
1026 if ((temp_buf[ 3 ] & 0x40000000) == 0) {
1030 printf(
"[DEBUG] \033[31m");
1031 printf(
"[DEBUG] ===Firmware ver. ERROR===\n ");
1032 printf(
"[DEBUG] FTSW and b2tt firmwares was updated on Nov.22, 2013 and the header format attached by B2link was changed in the new firmwares.\n");
1033 printf(
"[DEBUG] If you are going to take data now, Please update the firmware.\n");
1034 printf(
"[DEBUG] For details, please see Nakao-san's e-mail [b2link_ml:0111] Re: [daq2ml:0159] beta version of trigger timing receiver firmware (b2tt) on bdaq SVN\n");
1035 printf(
"[DEBUG] Or if you are going to read data taken before the update, please use basf2 software before svn revision 7419\n");
1036 printf(
"[DEBUG] About the format please see Nakao-san's B2GM slides(p. 13 and 15) http://kds.kek.jp/getFile.py/access?contribId=143&sessionId=38&resId=0&materialId=slides&confId=13911.\n");
1037 printf(
"[DEBUG] Sorry for inconvenience.\n");
1038 printf(
"[DEBUG] \033[0m");
1043 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : FTSW and b2tt firmwares are old. Exiting...\n %s %s %d\n",
1045 __FILE__, __PRETTY_FUNCTION__, __LINE__);
1060 sprintf(err_buf,
"[FATAL] %s ch=%d : ERROR_EVENT : PreRawCOPPERFormat_v2 contains no FINESSE data. Exiting...\n %s %s %d\n",
1062 __FILE__, __PRETTY_FUNCTION__, __LINE__);
1063 printf(
"%s", err_buf); fflush(stdout);
1080 int delete_flag = 0;
1081 radblk_fmt.
SetBuffer(bufin, nwords, delete_flag, num_events, num_nodes);
1083 int reduced_nwords = 0;
1085 int num_nodes_in_sendblock = radblk_fmt.
GetNumNodes();
1086 for (
int l = 0; l < num_nodes_in_sendblock; l++) {
1087 int entry_id = l + k * num_nodes_in_sendblock;
1093 int temp_delete_flag = 0, temp_num_eve = 1, temp_num_nodes = 1;
1098 temp_delete_flag, temp_num_eve,
1104 return reduced_nwords;
1115 int delete_flag = 0;
1116 radblk_fmt.
SetBuffer(bufin, nwords, delete_flag, num_events, num_nodes);
1118 int pos_nwords_to = 0;
1120 int num_nodes_in_sendblock = radblk_fmt.
GetNumNodes();
1121 for (
int l = 0; l < num_nodes_in_sendblock; l++) {
1122 int entry_id = l + k * num_nodes_in_sendblock;
1125 radblk_fmt.
CopyBlock(entry_id, buf_to + pos_nwords_to);
1139 *nwords_to = pos_nwords_to;
1156 for (
int j = 0; j < 4; j++) {
1159 if (finesse_nwords > 0) {
1166 - (
static_cast<int>(SIZE_B2LHSLB_HEADER) -
m_reduced_rawcpr.SIZE_B2LHSLB_HEADER)
1167 - (
static_cast<int>(SIZE_B2LFEE_HEADER) -
m_reduced_rawcpr.SIZE_B2LFEE_HEADER)
1168 - (
static_cast<int>(SIZE_B2LFEE_TRAILER) -
m_reduced_rawcpr.SIZE_B2LFEE_TRAILER)
1169 - (
static_cast<int>(SIZE_B2LHSLB_TRAILER) -
m_reduced_rawcpr.SIZE_B2LHSLB_TRAILER);
1191 int* buf_from = NULL;
1193 int pos_nwords_to = 0;
1194 int copy_nwords = 0;
1196 unsigned int removed_xor_chksum = 0;
1203 copyData(buf_to, &pos_nwords_to, buf_from, copy_nwords, nwords_buf_to);
1207 removed_xor_chksum ^= buf_from[
tmp_header.POS_VERSION_HDRNWORDS ];
1210 buf_to[
tmp_header.POS_VERSION_HDRNWORDS ] &= 0xFFFF7FFF;
1213 removed_xor_chksum ^= buf_to[
tmp_header.POS_VERSION_HDRNWORDS ];
1214 for (
int i = 0; i < SIZE_COPPER_HEADER; i++) {
1215 removed_xor_chksum ^= buf_from[
tmp_header.RAWHEADER_NWORDS + i ];
1223 int pos_nwords_finesse[ 4 ];
1224 for (
int j = 0; j < 4; j++) {
1225 pos_nwords_finesse[ j ] = pos_nwords_to;
1233 buf_to[ pos_nwords_to ] = finesse_buf[ POS_MAGIC_B2LHSLB ];
1239 + SIZE_B2LHSLB_HEADER
1245 if (finesse_nwords - SIZE_B2LHSLB_HEADER - SIZE_B2LFEE_HEADER
1246 - SIZE_B2LFEE_TRAILER - SIZE_B2LHSLB_TRAILER < 0) {
1251 "[FATAL] %s ch=%d : ERROR_EVENT : Finesse buffer size is too small( %d words < %d words). May be the data are corrupted. Exiting...\n %s %s %d\n",
1253 finesse_nwords,
static_cast<int>(SIZE_B2LHSLB_HEADER) + SIZE_B2LFEE_HEADER + SIZE_B2LFEE_TRAILER + SIZE_B2LHSLB_TRAILER,
1254 __FILE__, __PRETTY_FUNCTION__, __LINE__);
1255 printf(
"%s", err_buf); fflush(stdout);
1261 for (
int k = 1; k <= 4 ; k++) {
1262 removed_xor_chksum ^= finesse_buf[ k ];
1267 - SIZE_B2LHSLB_HEADER
1269 - SIZE_B2LFEE_TRAILER
1270 - SIZE_B2LHSLB_TRAILER;
1271 copyData(buf_to, &pos_nwords_to, buf_from, copy_nwords, nwords_buf_to);
1275 buf_to[ pos_nwords_to ] = 0xffff & finesse_buf[ finesse_nwords - SIZE_B2LHSLB_TRAILER - (SIZE_B2LFEE_TRAILER - POS_CHKSUM_B2LFEE) ];
1277 buf_to[ pos_nwords_to ] |= (finesse_buf[ finesse_nwords - (
static_cast<int>(SIZE_B2LHSLB_TRAILER) - POS_MAGIC_B2LHSLB) ] << 16) &
1281 for (
int k = 0; k <= 2 ; k++) {
1282 removed_xor_chksum ^= finesse_buf[ finesse_nwords - SIZE_B2LFEE_TRAILER - SIZE_B2LHSLB_TRAILER + k ];
1284 removed_xor_chksum ^= buf_to[ pos_nwords_to ];
1299 copyData(buf_to, &pos_nwords_to, buf_from, copy_nwords, nwords_buf_to);
1302 unsigned int old_rawcopper_chksum = buf_from[
tmp_trailer.POS_CHKSUM ];
1303 for (
int i = 0; i < SIZE_COPPER_TRAILER; i++) {
1304 removed_xor_chksum ^= (
unsigned int) * (buf_from - SIZE_COPPER_TRAILER + i);
1309 if (pos_nwords_to != nwords_buf_to) {
1311 sprintf(err_buf,
"Buffer overflow. Exiting... %d %d\n", pos_nwords_to, nwords_buf_to);
1312 printf(
"%s", err_buf); fflush(stdout);
1344 if ((old_rawcopper_chksum ^ removed_xor_chksum) != new_rawcopper_chksum) {
1349 "[FATAL] %s ch=%d : ERROR_EVENT : RawCOPPER XOR checksum is inconsistent between before/after data reduction.(%.8x != %.8x ^ %.8x = %.8x ) Exiting...\n %s %s %d\n",
1351 new_rawcopper_chksum, old_rawcopper_chksum, removed_xor_chksum, old_rawcopper_chksum ^ removed_xor_chksum,
1352 __FILE__, __PRETTY_FUNCTION__, __LINE__);
1353 printf(
"%s", err_buf); fflush(stdout);
1367 sprintf(err_buf,
"Invalid data block numbers.(# of events %d, # of nodes %d) Exiting...\n",
1369 printf(
"%s", err_buf); fflush(stdout);
1377 int nonzero_finesse_buf = 0;
1378 for (
int j = 0; j < 4; j++) {
1382 nonzero_finesse_buf++;
1385 if (nonzero_finesse_buf == 0) {
1387 sprintf(err_buf,
"No non-zero FINESSE buffer. Exiting...\n");
1388 printf(
"%s", err_buf); fflush(stdout);
1412 return pos_nwords_to;
1419 if ((finesse_buf[ POS_MAGIC_B2LHSLB ] & 0xFFFF0000) == B2LHSLB_HEADER_MAGIC &&
1420 ((finesse_buf[ finesse_nwords - SIZE_B2LHSLB_TRAILER + POS_CHKSUM_B2LHSLB ] & 0xFFFF0000)
1421 == B2LHSLB_TRAILER_MAGIC)) {
1427 "Invalid B2LHSLB magic words : header 0x%x (= should be ffaa**** ) or trailer 0x%x (= should be ff55**** ). Exiting... :%s %s %d\n",
1428 finesse_buf[ POS_MAGIC_B2LHSLB ],
1429 finesse_buf[ finesse_nwords - SIZE_B2LHSLB_TRAILER + POS_CHKSUM_B2LHSLB ],
1430 __FILE__, __PRETTY_FUNCTION__, __LINE__);
1431#ifndef NO_ERROR_STOP
1432 printf(
"%s", err_buf); fflush(stdout);
1446 int nwords =
GetFINESSENwords(n, finesse_num) - (
static_cast<int>(SIZE_B2LHSLB_HEADER) + SIZE_B2LFEE_TRAILER +
1447 SIZE_B2LHSLB_TRAILER);
1448 unsigned short temp_crc16 = CalcCRC16LittleEndian(0xffff, buf, nwords);
1454 - ((SIZE_B2LFEE_TRAILER - POS_CHKSUM_B2LFEE) + SIZE_B2LHSLB_TRAILER) ;
1456 if ((
unsigned short)(*buf & 0xFFFF) != temp_crc16) {
1461 printf(
"[FATAL] %s ch=%d : ERROR_EVENT : PRE CRC16 error : slot %c : B2LCRC16 %x Calculated CRC16 %x : Nwords of FINESSE buf %d\n",
1462 hostname, finesse_num,
1466 printf(
"%.8x ", temp_buf[ k ]);
1467 if ((k + 1) % 10 == 0) {
1474 "[FATAL] %s ch=%d : ERROR_EVENT : slot %c : B2LCRC16 (%.4x) differs from one ( %.4x) calculated by PreRawCOPPERfromat class. Exiting...\n %s %s %d\n",
1475 hostname, finesse_num,
1476 65 + finesse_num, (
unsigned short)(*buf & 0xFFFF), temp_crc16,
1477 __FILE__, __PRETTY_FUNCTION__, __LINE__);
1478 printf(
"%s", err_buf); fflush(stdout);
1486 int* detector_buf_1st,
int nwords_1st,
1487 int* detector_buf_2nd,
int nwords_2nd,
1488 int* detector_buf_3rd,
int nwords_3rd,
1489 int* detector_buf_4th,
int nwords_4th,
1492 int* packed_buf = NULL;
1494 int poswords_to = 0;
1495 int* detector_buf[ 4 ] = { detector_buf_1st, detector_buf_2nd, detector_buf_3rd, detector_buf_4th };
1496 const int nwords[ 4 ] = { nwords_1st, nwords_2nd, nwords_3rd, nwords_4th };
1501 for (
int i = 0; i < 4; i++) {
1502 if (detector_buf[ i ] == NULL || nwords[ i ] <= 0)
continue;
1503 length_nwords += nwords[ i ];
1504 length_nwords +=
static_cast<int>(SIZE_B2LHSLB_HEADER) + SIZE_B2LFEE_HEADER
1505 + SIZE_B2LFEE_TRAILER + SIZE_B2LHSLB_TRAILER;
1509 packed_buf =
new int[ length_nwords ];
1510 memset(packed_buf, 0,
sizeof(
int) * length_nwords);
1517 packed_buf[
tmp_header.POS_NWORDS ] = length_nwords;
1518 packed_buf[
tmp_header.POS_VERSION_HDRNWORDS ] = 0x7f7f8000
1524 packed_buf[
tmp_header.POS_TTCTIME_TRGTYPE ] = (rawcpr_info.
tt_ctime & 0x7FFFFFF) << 4;
1532 packed_buf[
tmp_header.POS_OFFSET_1ST_FINESSE ] =
static_cast<int>(
tmp_header.RAWHEADER_NWORDS) + SIZE_COPPER_HEADER;
1534 packed_buf[
tmp_header.POS_OFFSET_2ND_FINESSE ] = packed_buf[
tmp_header.POS_OFFSET_1ST_FINESSE ];
1535 if (nwords[ 0 ] > 0) {
1536 packed_buf[
tmp_header.POS_OFFSET_2ND_FINESSE ] +=
1537 nwords[ 0 ] + SIZE_B2LHSLB_HEADER + SIZE_B2LFEE_HEADER + SIZE_B2LFEE_TRAILER + SIZE_B2LHSLB_TRAILER;
1540 packed_buf[
tmp_header.POS_OFFSET_3RD_FINESSE ] = packed_buf[
tmp_header.POS_OFFSET_2ND_FINESSE ];
1541 if (nwords[ 1 ] > 0) {
1542 packed_buf[
tmp_header.POS_OFFSET_3RD_FINESSE ] +=
1543 nwords[ 1 ] + SIZE_B2LHSLB_HEADER + SIZE_B2LFEE_HEADER + SIZE_B2LFEE_TRAILER + SIZE_B2LHSLB_TRAILER;
1546 packed_buf[
tmp_header.POS_OFFSET_4TH_FINESSE ] = packed_buf[
tmp_header.POS_OFFSET_3RD_FINESSE ];
1547 if (nwords[ 2 ] > 0) {
1548 packed_buf[
tmp_header.POS_OFFSET_4TH_FINESSE ] += nwords[ 2 ] + SIZE_B2LHSLB_HEADER + SIZE_B2LFEE_HEADER + SIZE_B2LFEE_TRAILER +
1549 SIZE_B2LHSLB_TRAILER;
1554 packed_buf[ poswords_to + POS_MAGIC_COPPER_1 ] = COPPER_MAGIC_DRIVER_HEADER;
1555 packed_buf[ poswords_to + POS_MAGIC_COPPER_2 ] = COPPER_MAGIC_FPGA_HEADER;
1556 packed_buf[ poswords_to + POS_EVE_NUM_COPPER ] = rawcpr_info.
eve_num;
1558 int size_b2l_hdrtrl =
static_cast<int>(SIZE_B2LHSLB_HEADER) + SIZE_B2LFEE_HEADER + SIZE_B2LFEE_TRAILER + SIZE_B2LHSLB_TRAILER;
1559 if (nwords[ 0 ] != 0) packed_buf[ poswords_to + POS_CH_A_DATA_LENGTH ] = nwords[ 0 ] + size_b2l_hdrtrl;
1560 if (nwords[ 1 ] != 0) packed_buf[ poswords_to + POS_CH_B_DATA_LENGTH ] = nwords[ 1 ] + size_b2l_hdrtrl;
1561 if (nwords[ 2 ] != 0) packed_buf[ poswords_to + POS_CH_C_DATA_LENGTH ] = nwords[ 2 ] + size_b2l_hdrtrl;
1562 if (nwords[ 3 ] != 0) packed_buf[ poswords_to + POS_CH_D_DATA_LENGTH ] = nwords[ 3 ] + size_b2l_hdrtrl;
1564 packed_buf[ poswords_to + POS_DATA_LENGTH ] =
1565 packed_buf[ poswords_to + POS_CH_A_DATA_LENGTH ] +
1566 packed_buf[ poswords_to + POS_CH_B_DATA_LENGTH ] +
1567 packed_buf[ poswords_to + POS_CH_C_DATA_LENGTH ] +
1568 packed_buf[ poswords_to + POS_CH_D_DATA_LENGTH ] +
1569 (
static_cast<int>(SIZE_COPPER_HEADER) - SIZE_COPPER_DRIVER_HEADER) +
1570 (
static_cast<int>(SIZE_COPPER_TRAILER) - SIZE_COPPER_DRIVER_TRAILER);
1572 poswords_to += SIZE_COPPER_HEADER;
1575 for (
int i = 0; i < 4; i++) {
1577 if (detector_buf[ i ] == NULL || nwords[ i ] <= 0)
continue;
1580 packed_buf[ poswords_to + POS_MAGIC_B2LHSLB ] = 0xffaa0000 | (0xffff & rawcpr_info.
eve_num);
1581 poswords_to += SIZE_B2LHSLB_HEADER;
1582 int* crc16_start = &(packed_buf[ poswords_to ]);
1586 packed_buf[ poswords_to + POS_TT_CTIME_TYPE ] = (rawcpr_info.
tt_ctime & 0x7FFFFFF) << 4;
1587 unsigned int temp_ctime_type = packed_buf[ poswords_to + POS_TT_CTIME_TYPE ];
1588 packed_buf[ poswords_to + POS_TT_TAG ] = rawcpr_info.
eve_num;
1589 packed_buf[ poswords_to + POS_TT_UTIME ] = rawcpr_info.
tt_utime;
1592 packed_buf[ poswords_to + POS_B2L_CTIME ] = (rawcpr_info.
b2l_ctime & 0x7FFFFFF) << 4;
1593 poswords_to += SIZE_B2LFEE_HEADER;
1596 memcpy(packed_buf + poswords_to, detector_buf[ i ], nwords[ i ]*
sizeof(
int));
1597 poswords_to += nwords[ i ];
1600 packed_buf[ poswords_to + POS_TT_CTIME_B2LFEE ] = temp_ctime_type;
1603 unsigned short crc16 = CalcCRC16LittleEndian(0xffff, crc16_start, nwords[ i ] + SIZE_B2LFEE_HEADER);
1604 packed_buf[ poswords_to + POS_CHKSUM_B2LFEE ] = ((0xffff & rawcpr_info.
eve_num) << 16) | (crc16 & 0xffff);
1605 poswords_to += SIZE_B2LFEE_TRAILER;
1608 packed_buf[ poswords_to + POS_CHKSUM_B2LHSLB ] = 0xff550000;
1609 poswords_to += SIZE_B2LHSLB_TRAILER;
1614 packed_buf[ poswords_to + POS_MAGIC_COPPER_3 ] = COPPER_MAGIC_FPGA_TRAILER;
1615 packed_buf[ poswords_to + POS_MAGIC_COPPER_4 ] = COPPER_MAGIC_DRIVER_TRAILER;
1616 unsigned int chksum = 0;
1617 for (
int i =
tmp_header.
GetHdrNwords(); i < poswords_to + (static_cast<int>(SIZE_COPPER_TRAILER) - SIZE_COPPER_DRIVER_TRAILER);
1619 chksum ^= packed_buf[ i ];
1621 packed_buf[ poswords_to + POS_CHKSUM_COPPER ] = chksum;
1622 poswords_to += SIZE_COPPER_TRAILER;
1626 for (
int i = 0; i < poswords_to; i++) {
1627 chksum ^= packed_buf[ i ];
1629 packed_buf[ poswords_to +
tmp_trailer.POS_CHKSUM ] = chksum;
1634 *packed_buf_nwords = poswords_to;
struct to contain header information used by RawCOPPERFormat::Packer()
unsigned int b2l_ctime
32bit unitx time at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user ...
unsigned int eve_num
Run # and subrun # ( 22bit )
unsigned int tt_ctime
Node ID (32bit)
unsigned int tt_utime
27bit clock ticks at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user...
unsigned int node_id
Event Number (32bit)
unsigned int run_subrun_num
Experiment number (10bit)
unsigned int exp_num
Experiment number (10bit)
unsigned int GetDriverChkSum(int n) OVERRIDE_CPP17
read COPPER driver's checksum value
unsigned int GetCOPPERCounter(int n) OVERRIDE_CPP17
get posistion of COPPER block in unit of word
unsigned int GetEveNo(int n) OVERRIDE_CPP17
get subrun #(8bit)
unsigned int GetMagicFPGATrailer(int n) OVERRIDE_CPP17
get magic word of COPPER FPGA trailer
unsigned int GetMagicDriverTrailer(int n) OVERRIDE_CPP17
get magic word of COPPER driver trailer
int GetHdrNwords()
get contents of header
int GetTrlNwords()
Set magic word.
unsigned int GetExpRunSubrun(int n) OVERRIDE_CPP17
get Experimental # from header
unsigned int GetMagicFPGAHeader(int n) OVERRIDE_CPP17
get magic word of COPPER FPGA header
int GetExpNo(int n) OVERRIDE_CPP17
get Experimental # from header
unsigned int GetChksum()
Set # of trailer words.
void SetBuffer(int *bufin)
return buffer
int GetRunNo(int n) OVERRIDE_CPP17
Exp# (10bit) run# (14bit) restart # (8bit)
int * GetRawTrlBufPtr(int n) OVERRIDE_CPP17
get buffer pointer of rawcopper trailer
unsigned int GetMagicDriverHeader(int n) OVERRIDE_CPP17
get magic word of COPPER driver header
int GetSubRunNo(int n) OVERRIDE_CPP17
get run # (14bit)
Abstract base class for different kinds of events.