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