Belle II Software development
RawCOPPERFormat_latest.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <algorithm>
10#include <rawdata/dataobjects/RawCOPPERFormat_latest.h>
11
12
13using namespace std;
14using namespace Belle2;
15
16//#define DESY
17//#define NO_DATA_CHECK
18//#define WO_FIRST_EVENUM_CHECK
19
20//ClassImp(RawCOPPERFormat_latest);
21
23{
24}
25
27{
28}
29
31{
32 int cnt = 0;
33 for (int i = 0; i < 4; i++) {
34 if (GetFINESSENwords(n, i) > 0) {
35 cnt++;
36 }
37 }
38 return cnt;
39}
40
41
42#ifdef USE_B2LFEE_FORMAT_BOTH_VER1_AND_2
43void RawCOPPERFormat_latest::CheckB2LFEEHeaderVersion(int n)
44{
45
46 int* temp_buf;
47
48 for (int i = 0; i < 4; i++) {
49 if (GetFINESSENwords(n, i) > 0) {
50 temp_buf = GetFINESSEBuffer(n, i);
51 if ((temp_buf[ 3 ] & 0x40000000) == 0) {
52#ifdef TEMP
53 // this word for exp/run
54 // old one (ver.1) used for SPring8 test in 2013
55 printf("[DEBUG] \033[31m");
56 printf("[DEBUG] ===Firmware ver. ERROR===\n ");
57 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");
58 printf("[DEBUG] If you are going to take data now, Please update the firmware.\n");
59 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");
60 printf("[DEBUG] Or if you are going to read data taken before the update, please use basf2 software before svn rev. 7419\n");
61 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");
62 printf("[DEBUG] Sorry for inconvenience.\n");
63 printf("[DEBUG] \033[0m");
64 fflush(stderr);
65 char err_buf[500];
66 sprintf(err_buf, "FTSW and b2tt firmwares are old. Exiting...\n %s %s %d\n",
67 __FILE__, __PRETTY_FUNCTION__, __LINE__);
68 printf("%s\n", err_buf); fflush(stdout);
69 B2FATAL(err_buf);
70#endif
71 } else {
72 // this word for 32bit unixtime
73 // new one (ver.2)
74 break;
75 }
76 }
77
78 if (i == 3) {
79#ifdef TEMP
80 char err_buf[500];
81 sprintf(err_buf, "RawCOPPERFormat_latest contains no FINESSE data. Exiting...\n %s %s %d\n",
82 __FILE__, __PRETTY_FUNCTION__, __LINE__);
83 printf("%s\n", err_buf); fflush(stdout);
84 B2FATAL(err_buf);
85#endif
86 }
87 }
88 return;
89}
90#endif
91
93{
94 char err_buf[500];
95 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
96 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
97 printf("[DEBUG] %s\n", err_buf);
98 B2FATAL(err_buf);
99 return 0;
100}
101
103{
104 char err_buf[500];
105 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
106 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
107 printf("[DEBUG] %s\n", err_buf);
108 B2FATAL(err_buf);
109 return 0;
110}
111
113{
114 char err_buf[500];
115 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
116 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
117 printf("[DEBUG] %s\n", err_buf);
118 B2FATAL(err_buf);
119 return 0;
120}
121
123{
124 char err_buf[500];
125 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
126 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
127 printf("[DEBUG] %s\n", err_buf);
128 B2FATAL(err_buf);
129 return 0;
130}
131
132
134{
135 char err_buf[500];
136 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
137 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
138 printf("[DEBUG] %s\n", err_buf);
139 B2FATAL(err_buf);
140 return 0;
141}
142
144{
145 char err_buf[500];
146 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
147 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
148 printf("[DEBUG] %s\n", err_buf);
149 B2FATAL(err_buf);
150 return 0;
151}
152
154{
155 char err_buf[500];
156 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
157 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
158 printf("[DEBUG] %s\n", err_buf);
159 B2FATAL(err_buf);
160 return 0;
161}
162
164{
165 char err_buf[500];
166 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
167 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
168 printf("[DEBUG] %s\n", err_buf);
169 B2FATAL(err_buf);
170 return 0;
171}
172
173
175{
176 char err_buf[500];
177 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
178 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
179 printf("[DEBUG] %s\n", err_buf);
180 B2FATAL(err_buf);
181 return NULL;
182}
183
185{
186 char err_buf[500];
187 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
188 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
189 printf("[DEBUG] %s\n", err_buf);
190 B2FATAL(err_buf);
191 return NULL;
192}
193
195{
196 char err_buf[500];
197 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
198 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
199 printf("[DEBUG] %s\n", err_buf);
200 B2FATAL(err_buf);
201 return NULL;
202}
203
205{
206 char err_buf[500];
207 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
208 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
209 printf("[DEBUG] %s\n", err_buf);
210 B2FATAL(err_buf);
211 return NULL;
212}
213
215{
216 char err_buf[500];
217 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
218 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
219 printf("[DEBUG] %s\n", err_buf);
220 B2FATAL(err_buf);
221 return 0;
222}
223
224
226{
227 char err_buf[500];
228 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
229 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
230 printf("[DEBUG] %s\n", err_buf);
231 B2FATAL(err_buf);
232 return 0;
233}
234
235
237{
238 char err_buf[500];
239 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
240 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
241 printf("[DEBUG] %s\n", err_buf);
242 B2FATAL(err_buf);
243 return 0;
244}
245
247{
248 char err_buf[500];
249 sprintf(err_buf, "[FATAL] This function is not supported.(block %d) Exiting...: \n%s %s %d\n",
250 n, __FILE__, __PRETTY_FUNCTION__, __LINE__);
251 printf("[DEBUG] %s\n", err_buf);
252 B2FATAL(err_buf);
253 return 0;
254}
255
256void RawCOPPERFormat_latest::CompareHeaderValue(int n, const unsigned int (&input_val)[MAX_PCIE40_CH],
257 std::vector<std::vector<unsigned int>>& summary_table)
258{
259
260 //
261 // Format of summary_table
262 // <The 1st channel of a value> <# of channels of the value> <the value>
263 //
264 std::vector<std::vector<unsigned int>> temp;
265 for (int i = 0; i < MAX_PCIE40_CH; i++) {
266 if (GetFINESSENwords(n, i) > 0) {
267
268 int same_flag = 0;
269 for (unsigned j = 0; j < summary_table.size(); ++j) {
270 if (input_val[i] == summary_table.at(j).at(2)) {
271 summary_table.at(j).at(1)++;
272 same_flag = 1;
273 break;
274 }
275 }
276 if (same_flag == 0) {
277 summary_table.push_back({ static_cast<unsigned int>(i), 1, input_val[i] });
278 }
279 }
280 }
281 sort(summary_table.begin(), summary_table.end(), [](const std::vector<unsigned int>& alpha,
282 const std::vector<unsigned int>& beta) {return alpha.at(1) < beta.at(1);});
283 return;
284}
int * Get4thDetectorBuffer(int n) OVERRIDE_CPP17 FINAL_CPP17
get Detector Buffer of slot D
int Get1stDetectorNwords(int n) OVERRIDE_CPP17 FINAL_CPP17
get Detector buffer length of slot A
int Get4thDetectorNwords(int n) OVERRIDE_CPP17 FINAL_CPP17
get Detector buffer length of slot D
int Get2ndDetectorNwords(int n) OVERRIDE_CPP17 FINAL_CPP17
get Detector buffer length of slot B
void CompareHeaderValue(int n, const unsigned int(&input_val)[MAX_PCIE40_CH], std::vector< std::vector< unsigned int > > &summary_table) OVERRIDE_CPP17
Check header value of all channels.
int Get3rdFINESSENwords(int n) OVERRIDE_CPP17 FINAL_CPP17
get data size of FINESSE slot C buffer
int * Get2ndDetectorBuffer(int n) OVERRIDE_CPP17 FINAL_CPP17
get Detector Buffer of slot B
int * Get3rdDetectorBuffer(int n) OVERRIDE_CPP17 FINAL_CPP17
get Detector Buffer of slot C
int GetOffset3rdFINESSE(int n) OVERRIDE_CPP17 FINAL_CPP17
get # of offset words for FINESSE slot C buffer position
int Get2ndFINESSENwords(int n) OVERRIDE_CPP17 FINAL_CPP17
get data size of FINESSE slot B buffer
int GetOffset1stFINESSE(int n) OVERRIDE_CPP17 FINAL_CPP17
get # of offset words for FINESSE slot A buffer position
RawCOPPERFormat_latest()
Default constructor.
int * Get1stDetectorBuffer(int n) OVERRIDE_CPP17 FINAL_CPP17
get Detector buffer of slot A
virtual int GetNumFINESSEBlock(int n) OVERRIDE_CPP17
get # of FINNESEs which contains data
virtual ~RawCOPPERFormat_latest()
Constructor using existing pointer to raw data buffer.
int Get3rdDetectorNwords(int n) OVERRIDE_CPP17 FINAL_CPP17
get Detector buffer length of slot C
int GetOffset4thFINESSE(int n) OVERRIDE_CPP17 FINAL_CPP17
get # of offset words for FINESSE slot D buffer position
int Get1stFINESSENwords(int n) OVERRIDE_CPP17 FINAL_CPP17
get data size of FINESSE slot A buffer
int GetOffset2ndFINESSE(int n) OVERRIDE_CPP17 FINAL_CPP17
get # of offset words for FINESSE slot B buffer position
int Get4thFINESSENwords(int n) OVERRIDE_CPP17 FINAL_CPP17
get data size of FINESSE slot D buffer
int * GetFINESSEBuffer(int n, int finesse_num) OVERRIDE_CPP17
Get a pointer to a FINESSE buffer.
int GetFINESSENwords(int n, int finesse_num) OVERRIDE_CPP17
Get the size of a finesse buffer.
Abstract base class for different kinds of events.
STL namespace.