9 #include <rawdata/dataobjects/RawCOPPERFormat_v0.h>
21 RawCOPPERFormat_v0::RawCOPPERFormat_v0()
25 RawCOPPERFormat_v0::~RawCOPPERFormat_v0()
29 unsigned int RawCOPPERFormat_v0::CalcDriverChkSum(
int n)
31 int min = GetBufferPos(n) + tmp_header.RAWHEADER_NWORDS;
32 int max = GetBufferPos(n) + GetBlockNwords(n)
33 - tmp_trailer.RAWTRAILER_NWORDS - SIZE_COPPER_DRIVER_TRAILER;
34 unsigned int chksum = 0;
35 for (
int i = min; i < max; i++) {
36 chksum ^= m_buffer[ i ];
42 int RawCOPPERFormat_v0::GetNumFINESSEBlock(
int n)
46 int pos_nwords = GetBufferPos(n) + POS_CH_A_DATA_LENGTH + tmp_header.RAWHEADER_NWORDS;
47 if (m_buffer[ pos_nwords ] > 0) cnt++;
48 pos_nwords = GetBufferPos(n) + POS_CH_B_DATA_LENGTH + tmp_header.RAWHEADER_NWORDS;
49 if (m_buffer[ pos_nwords ] > 0) cnt++;
50 pos_nwords = GetBufferPos(n) + POS_CH_C_DATA_LENGTH + tmp_header.RAWHEADER_NWORDS;
51 if (m_buffer[ pos_nwords ] > 0) cnt++;
52 pos_nwords = GetBufferPos(n) + POS_CH_D_DATA_LENGTH + tmp_header.RAWHEADER_NWORDS;
53 if (m_buffer[ pos_nwords ] > 0) cnt++;
57 int RawCOPPERFormat_v0::GetDetectorNwords(
int n,
int finesse_num)
59 switch (finesse_num) {
61 return Get1stDetectorNwords(n);
64 return Get2ndDetectorNwords(n);
67 return Get3rdDetectorNwords(n);
70 return Get4thDetectorNwords(n);
77 sprintf(err_buf,
"Specifined FINESSE number( = %d ) is invalid. Exiting...\n %s %s %d\n", finesse_num,
78 __FILE__, __PRETTY_FUNCTION__, __LINE__);
79 printf(
"%s\n", err_buf); fflush(stdout);
84 int RawCOPPERFormat_v0::GetFINESSENwords(
int n,
int finesse_num)
86 switch (finesse_num) {
88 return Get1stFINESSENwords(n);
91 return Get2ndFINESSENwords(n);
94 return Get3rdFINESSENwords(n);
97 return Get4thFINESSENwords(n);
104 sprintf(err_buf,
"Specifined FINESSE number( = %d ) is invalid. Exiting...\n %s %s %d\n",
105 finesse_num, __FILE__, __PRETTY_FUNCTION__, __LINE__);
106 printf(
"%s\n", err_buf); fflush(stdout);
117 unsigned int RawCOPPERFormat_v0::GetB2LFEE32bitEventNumber(
int n)
120 #ifndef READ_OLD_B2LFEE_FORMAT_FILE
123 unsigned int eve_num = 0;
126 for (
int i = 0; i < 4 ; i++) {
128 if (GetFINESSENwords(n, i) > 0) {
129 int pos_nwords = GetOffsetFINESSE(n, i) + SIZE_B2LHSLB_HEADER + POS_TT_TAG;
130 eve[ i ] = m_buffer[ pos_nwords ];
131 if (flag != 1) eve_num = eve[ i ];
132 if (eve_num != eve[ i ]) err_flag = 1;
139 sprintf(err_buf,
"No HSLB data in COPPER data. Exiting...\n%s %s %d\n",
140 __FILE__, __PRETTY_FUNCTION__, __LINE__);
141 printf(
"%s\n", err_buf); fflush(stdout);
148 sprintf(err_buf,
"CORRUPTED DATA: Different event number over HSLBs : slot A 0x%x : B 0x%x :C 0x%x : D 0x%x\n%s %s %d\n",
149 eve[ 0 ], eve[ 1 ], eve[ 2 ], eve[ 3 ],
150 __FILE__, __PRETTY_FUNCTION__, __LINE__);
151 printf(
"[DEBUG] [ERROR] %s\n", err_buf);
152 #ifndef NO_DATA_CHECK
161 sprintf(err_buf,
"You need comment out READ_OLD_B2LFEE_FORMAT_FILE if you are handling a new data format\n%s %s %d\n",
162 __FILE__, __PRETTY_FUNCTION__, __LINE__);
163 printf(
"%s", err_buf); fflush(stdout);
172 void RawCOPPERFormat_v0::CheckData(
int n,
173 unsigned int prev_evenum,
unsigned int* cur_evenum_rawcprhdr,
174 unsigned int prev_copper_ctr,
unsigned int* cur_copper_ctr,
175 unsigned int prev_exprunsubrun_no,
unsigned int* cur_exprunsubrun_no)
180 "This function for format ver.0 is not supported. (n %d preveve %u eve %u prectr %u ctr %u prevrun %u run %u) Exiting...\n %s %s %d\n",
181 n, prev_evenum, *cur_evenum_rawcprhdr, prev_copper_ctr, *cur_copper_ctr,
182 prev_exprunsubrun_no, *cur_exprunsubrun_no,
183 __FILE__, __PRETTY_FUNCTION__, __LINE__);
184 printf(
"%s", err_buf); fflush(stdout);
335 bool RawCOPPERFormat_v0::CheckCOPPERMagic(
int n)
337 if (GetMagicDriverHeader(n) != COPPER_MAGIC_DRIVER_HEADER) {
339 }
else if (GetMagicFPGAHeader(n) != COPPER_MAGIC_FPGA_HEADER) {
341 }
else if (GetMagicFPGATrailer(n) != COPPER_MAGIC_FPGA_TRAILER) {
343 }
else if (GetMagicDriverTrailer(n) != COPPER_MAGIC_DRIVER_TRAILER) {
349 void RawCOPPERFormat_v0::CheckUtimeCtimeTRGType(
int n)
352 #ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
353 CheckB2LFEEHeaderVersion(n);
357 unsigned int temp_utime = 0, temp_ctime_trgtype = 0;
358 unsigned int utime[4], ctime_trgtype[4];
359 memset(utime, 0,
sizeof(utime));
360 memset(ctime_trgtype, 0,
sizeof(ctime_trgtype));
362 for (
int i = 0; i < 4; i++) {
363 if (GetFINESSENwords(n, i) > 0) {
364 ctime_trgtype[ i ] = m_buffer[ GetOffsetFINESSE(n, i) +
365 SIZE_B2LHSLB_HEADER + POS_TT_CTIME_TYPE ];
366 utime[ i ] = m_buffer[ GetOffsetFINESSE(n, i) +
367 SIZE_B2LHSLB_HEADER + POS_TT_UTIME ];
369 temp_ctime_trgtype = ctime_trgtype[ i ];
370 temp_utime = utime[ i ];
373 if (temp_ctime_trgtype != ctime_trgtype[ i ]
374 || temp_utime != utime[ i ]) {
382 for (
int i = 0; i < 4; i++) {
383 printf(
"[DEBUG] FINESSE #=%d buffsize %d ctimeTRGtype 0x%.8x utime 0x%.8x\n",
384 i, GetFINESSENwords(n, i), ctime_trgtype[ i ], utime[ i ]);
387 sprintf(err_buf,
"CORRUPTED DATA: mismatch over FINESSEs. Exiting...\n %s %s %d\n",
388 __FILE__, __PRETTY_FUNCTION__, __LINE__);
389 printf(
"%s", err_buf); fflush(stdout);
396 unsigned int RawCOPPERFormat_v0::FillTopBlockRawHeader(
unsigned int m_node_id,
unsigned int prev_eve32,
397 unsigned int prev_exprunsubrun_no,
unsigned int* cur_exprunsubrun_no)
402 "This function for format ver.0 is not supported. (node %.8x preveve %u prevrun %u currun %u ) Exiting...\n %s %s %d\n",
403 m_node_id, prev_eve32, prev_exprunsubrun_no, *cur_exprunsubrun_no,
404 __FILE__, __PRETTY_FUNCTION__, __LINE__);
405 printf(
"%s", err_buf); fflush(stdout);
653 #ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
654 void RawCOPPERFormat_v0::CheckB2LFEEHeaderVersion(
int n)
659 for (
int i = 0; i < 4; i++) {
660 if (GetFINESSENwords(n, i) > 0) {
661 temp_buf = GetFINESSEBuffer(n, i);
662 if ((temp_buf[ 3 ] & 0x40000000) == 0) {
666 printf(
"[DEBUG] \033[31m");
667 printf(
"[DEBUG] ===Firmware ver. ERROR===\n ");
668 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");
669 printf(
"[DEBUG] If you are going to take data now, Please update the firmware.\n");
670 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");
671 printf(
"[DEBUG] Or if you are going to read data taken before the update, please use basf2 software before rev. 7419\n");
672 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");
673 printf(
"[DEBUG] Sorry for inconvenience.\n");
674 printf(
"[DEBUG] \033[0m");
677 sprintf(err_buf,
"FTSW and b2tt firmwares are old. Exiting...\n %s %s %d\n",
678 __FILE__, __PRETTY_FUNCTION__, __LINE__);
679 printf(
"%s", err_buf); fflush(stdout);
692 sprintf(err_buf,
"RawCOPPERFormat_v0 contains no FINESSE data. Exiting...\n %s %s %d\n",
693 __FILE__, __PRETTY_FUNCTION__, __LINE__);
694 printf(
"%s", err_buf); fflush(stdout);
703 int* RawCOPPERFormat_v0::PackDetectorBuf(
int* packed_buf_nwords,
704 int* detector_buf_1st,
int nwords_1st,
705 int* detector_buf_2nd,
int nwords_2nd,
706 int* detector_buf_3rd,
int nwords_3rd,
707 int* detector_buf_4th,
int nwords_4th,
711 sprintf(err_buf,
"This function is not supported (%p %p %d %p %d %p %d %p %d %p ) Exiting...\n%s %s %d\n"
712 , packed_buf_nwords, detector_buf_1st, nwords_1st, detector_buf_2nd, nwords_2nd, detector_buf_3rd,
713 nwords_3rd, detector_buf_4th, nwords_4th, &rawcprpacker_info, __FILE__, __PRETTY_FUNCTION__, __LINE__);
714 printf(
"%s", err_buf); fflush(stdout);
struct to contain header information used by RawCOPPERFormat::Packer()
Abstract base class for different kinds of events.