Belle II Software  release-05-01-25
trgeclUnpackerModule.cc
1 //---------------------------------------------------------------
2 // $Id$
3 //---------------------------------------------------------------
4 // Filename : trgeclUnpackerModule.cc
5 // Section : TRG ECL
6 // Owner : SungHyun Kim
7 // Email : sungnhyun.kim@belle2.org
8 //---------------------------------------------------------------
9 // Description : TRG ECL Unpacker Module
10 //---------------------------------------------------------------
11 // 1.00 : 2017/05/06 : First version
12 // 1.01 : 2017/07/17 : Add FTSW clock from FAM, fine timing (ETM Ver. old_89)
13 // 2.00 : 2018/02/17 : 8 window data (ETM Ver. 100)
14 // 3.00 : 2018/07/31 : ETM version dependence included
15 // 3.01 : 2019/02/25 : Trigger bit modify
16 // 3.01 : 2019/05/10 : Update Trigger summary contaning Cluster information
17 // 3.02 : 2019/06/24 : 20GeV ECL BST bit
18 // 3.03 : 2019/10/07 : New Lowmulti (12 & 13) bit
19 // 4.00 : 2019/10/11 : Summary totally change
20 // 4.01 : 2020/03/13 : Bug fixed. (Bug : SumStore always save only one TRG info. in latest window)
21 // 4.02 : 2020/03/30 : Bug fixed. (Bug : vector sorting does not support '>=' => '>')
22 //---------------------------------------------------------------
23 
24 #include <trg/ecl/modules/trgeclUnpacker/trgeclUnpackerModule.h>
25 
26 #include "trg/ecl/TrgEclDataBase.h"
27 #include "trg/ecl/TrgEclMapping.h"
28 
29 using namespace std;
30 using namespace Belle2;
31 
33 REG_MODULE(TRGECLUnpacker);
34 
35 string TRGECLUnpackerModule::version() const
36 {
37  return string("4.02");
38 }
39 
40 TRGECLUnpackerModule::TRGECLUnpackerModule()
41  : Module::Module(), n_basf2evt(0)
42 {
43 
44  string desc = "TRGECLUnpackerModule(" + version() + ")";
45  setDescription(desc);
47 
48  B2DEBUG(20, "trgeclunpacker: Constructor done.");
49 }
50 
52 
54 {
55 }
56 
58 {
59  m_TRGECLSumArray.registerInDataStore();
60  m_TRGECLTCArray.registerInDataStore();
61  m_TRGECLEvtArray.registerInDataStore();
62  m_TRGECLClusterArray.registerInDataStore();
63 }
64 
68 {
69 
70  StoreArray<RawTRG> raw_trgarray;
71 
72  for (int i = 0; i < raw_trgarray.getEntries(); i++) {
73  iFiness = i;
74  for (int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
75  nodeid = ((raw_trgarray[i]->GetNodeID(j)) >> 24) & 0x1F;
76  nwords = raw_trgarray[i]->GetDetectorNwords(j, 0);
77  trgtype = raw_trgarray[i]->GetTRGType(j);
78  n_basf2evt = raw_trgarray[i]->GetEveNo(j);
79  if (nodeid == 0x13) {
80  if (nwords < 9) {
81  B2ERROR("Consistecy error in unpacker.");
82  B2ERROR("data length " << nwords << " nWord " << nwords);
83  B2ERROR("Node ID " << nodeid << ", Finness ID " << iFiness);
84  continue;
85  }
86  readCOPPEREvent(raw_trgarray[i], j, nwords);
87  }
88  }
89  }
90 }
91 
92 void TRGECLUnpackerModule::readCOPPEREvent(RawTRG* raw_copper, int i, int nnn)
93 {
94  /* cppcheck-suppress variableScope */
95  int* rdat;
96  if (raw_copper->GetDetectorNwords(i, 0) > 0) {
97  rdat = raw_copper->GetDetectorBuffer(i, 0);
98  etm_version = ((rdat[0] >> 16) & 0xffff);
99  if (etm_version > 136) {
100  checkBuffer(rdat, nnn);
101  } else if (etm_version <= 136) {
102  checkBuffer_v136(rdat, nnn);
103  }
104  }
105 }
106 
107 void TRGECLUnpackerModule::checkBuffer(int* rdat, int nnn)
108 {
109 
110  int version_check = (rdat[0] >> 12) & 0xf;
111  if (version_check != 15) return;
112 
113  // Checksum variable
114  unsigned char check_sum = (rdat[nnn - 1] >> 24) & 0xFF;
115  unsigned char data_sum = 0;
116  unsigned char kdat[4] = {0};
117  for (int j = nnn - 2; j > -1; j--) {
118  kdat[0] = rdat[j] & 0xff;
119  kdat[1] = (rdat[j] >> 8) & 0xff;
120  kdat[2] = (rdat[j] >> 16) & 0xff;
121  kdat[3] = (rdat[j] >> 24) & 0xff;
122  for (int k = 0; k < 4; k++) {
123  data_sum = data_sum + kdat[k];
124  }
125  }
126 
127  int flag_checksum = 0;
128 
129  if (check_sum == data_sum) {
130  flag_checksum = 0;
131  } else {
132  flag_checksum = 1;
133  }
134 
135  // Information
136  int l1_revo = rdat[0] & 0x7ff;
137  int i = 0;
138  int window_num = 0;
139 
140  // Summary
141  /* cppcheck-suppress variableScope */
142  int summary_data = 0;
143  int summary_recon = 0;
144  /* cppcheck-suppress variableScope */
145  int summary_revo = 0;
146  /* cppcheck-suppress variableScope */
147  bool summary_trg = false;
148  /* cppcheck-suppress variableScope */
149  int data_win = 0;
150 
151  // TC
152  /* cppcheck-suppress variableScope */
153  int ntc_win = 0;
154  bool tc_trg = false;
155  // TC info
156  int tc_id = 0;
157  int tc_t = 0;
158  int tc_e = 0;
159  int conv_tc_t = 0;
160  int win3_revo = -9999;
161 
162  vector<int> sum_data;
163  vector<vector<int>> sum_info;
164 
165  vector<int> tc_data;
166  vector<vector<int>> tc_info;
167  vector<vector<int>> tc_info_FE1;
168  vector<vector<int>> tc_info_FE2;
169  vector<vector<int>> tc_info_BE1;
170  vector<vector<int>> tc_info_BE2;
171 
172  // Unpacking ---->
173  while (i < nnn - 2) {
174  summary_data = rdat[i + 1];
175  summary_trg = (summary_data >> 23) & 0x1;
176  summary_revo = (summary_data >> 16) & 0x7f;
177  ntc_win = summary_data & 0x3ff;
178  if (ntc_win == 0) {
179  tc_trg = false;
180  } else {
181  tc_trg = true;
182  }
183  data_win = window_num;
184  if (window_num == 3) win3_revo = summary_revo;
185 
186  if (summary_trg == true) { // Summary on
187  sum_data.push_back(data_win);
188  sum_data.push_back(summary_revo);
189  for (int j = 0; j < 12; j++) {
190  summary_recon =
191  (((rdat[i + j + 2] >> 0) & 0xFF) << 24) +
192  (((rdat[i + j + 2] >> 8) & 0xFF) << 16) +
193  (((rdat[i + j + 2] >> 16) & 0xFF) << 8) +
194  (((rdat[i + j + 2] >> 24) & 0xFF) << 0);
195  sum_data.push_back(summary_recon);
196  }
197  sum_info.push_back(sum_data);
198  sum_data.clear();
199  i = i + 14;
200 
201  if (tc_trg == true) { // summary on & TC on
202  for (int j = 0; j < ntc_win; j++) {
203  tc_id = (rdat[i + j] >> 20) & 0x3FF;
204  tc_t = (rdat[i + j] >> 12) & 0x7F;
205  tc_e = rdat[i + j] & 0xFFF;
206  conv_tc_t = (data_win - 3) * 128 + tc_t;
207 
208  // TC vector
209  tc_data.push_back(tc_id);
210  tc_data.push_back(conv_tc_t);
211  tc_data.push_back(tc_e);
212  tc_data.push_back(data_win);
213  if (tc_id < 81) {
214  if (tc_id > 75) {
215  tc_info_FE1.push_back(tc_data);
216  } else {
217  tc_info_FE2.push_back(tc_data);
218  }
219  } else if (tc_id > 512) {
220  if (tc_id > 572) {
221  tc_info_BE1.push_back(tc_data);
222  } else {
223  tc_info_BE2.push_back(tc_data);
224  }
225  } else {
226  tc_info.push_back(tc_data);
227  }
228  tc_data.clear();
229  }
230  i = i + ntc_win - 1;
231  }
232 
233  } else { // Summary off
234  if (tc_trg == true) { // summary off & TC on
235  for (int j = 0; j < ntc_win; j++) {
236  tc_id = (rdat[i + j + 2] >> 20) & 0x3FF;
237  tc_t = (rdat[i + j + 2] >> 12) & 0x7F;
238  conv_tc_t = (data_win - 3) * 128 + tc_t;
239  tc_e = rdat[i + j + 2] & 0xFFF;
240 
241  // TC vector
242  tc_data.push_back(tc_id);
243  tc_data.push_back(conv_tc_t);
244  tc_data.push_back(tc_e);
245  tc_data.push_back(data_win);
246  if (tc_id < 81) {
247  if (tc_id > 75) {
248  tc_info_FE1.push_back(tc_data);
249  } else {
250  tc_info_FE2.push_back(tc_data);
251  }
252  } else if (tc_id > 512) {
253  if (tc_id > 572) {
254  tc_info_BE1.push_back(tc_data);
255  } else {
256  tc_info_BE2.push_back(tc_data);
257  }
258  } else {
259  tc_info.push_back(tc_data);
260  }
261  tc_data.clear();
262  }
263  i = i + ntc_win + 1;
264  } else { // Summary off & TC off
265  i = i + 1;
266  }
267  }
268  window_num++;
269  }
270 
271  // <---- Unpacking
272 
273  // Summary
274  /* cppcheck-suppress variableScope */
275  int sum_num_ord = 0;
276  /* cppcheck-suppress variableScope */
277  int sum_num = 0;
278  /* cppcheck-suppress variableScope */
279  int sum_revo = 0;
280  int cl_theta[6] = {0};
281  int cl_phi[6] = {0};
282  int cl_time[6] = { -9999};
283  int cl_energy[6] = {0};
284  int cl_1gev[6] = {0};
285  int cl_2gev[6] = {0};
286  int cl_bha[6] = {0};
287  int ncl = 0;
288  int low_multi = 0;
289  int b2bhabha_v = 0;
290  int b2bhabha_s = 0;
291  int mumu = 0;
292  int prescale = 0;
293  int icn_over = 0;
294  int bg_veto = 0;
295  int icn = 0;
296  int etot_type = 0;
297  int etot = 0;
298  int b1_type = 0;
299  int b1bhabha = 0;
300  int physics = 0;
301  int time_type = 0;
302  int time = 0;
303  int ecl_bst = 0;
304 
305  int m_sumNum = 0;
306 
307  TrgEclDataBase database;
308  TrgEclMapping mapping;
309 
310  vector<int> cl_1d;
311  vector<vector<int>> cl_2d;
312 
313  vector<int> evt_1d_vector;
314  vector<vector<int>> evt_2d_vector;
315 
316  // Store Summary
317  int sum_size = sum_info.size();
318  if (sum_size != 0) {
319  for (int j = 0; j < sum_size; j++) {
320  sum_num = sum_info[j][0];
321  sum_revo = sum_info[j][1];
322  // TRG
323  time = (sum_info[j][2]) & 0x7F;
324  time_type = (sum_info[j][2] >> 7) & 0x7;
325  physics = (sum_info[j][2] >> 10) & 0x1;
326  b1bhabha = (sum_info[j][2] >> 11) & 0x1;
327  b1_type = (sum_info[j][2] >> 12) & 0x3FFF;
328  etot = ((sum_info[j][3] & 0x7F) << 6) + ((sum_info[j][2] >> 26) & 0x3F);
329  etot_type = (sum_info[j][3] >> 7) & 0x7;
330  icn = (sum_info[j][3] >> 10) & 0x7F;
331  bg_veto = (sum_info[j][3] >> 17) & 0x7;
332  icn_over = (sum_info[j][3] >> 20) & 0x1;
333  b2bhabha_v = (sum_info[j][3] >> 21) & 0x1;
334  low_multi = (((sum_info[j][4] >> 6) & 0x3) << 12) + ((sum_info[j][4] & 0x3) << 10) + ((sum_info[j][3] >> 22) & 0x3FF);
335  b2bhabha_s = (sum_info[j][4] >> 2) & 0x1;
336  mumu = (sum_info[j][4] >> 3) & 0x1;
337  prescale = (sum_info[j][4] >> 4) & 0x1;
338  ecl_bst = (sum_info[j][4] >> 5) & 0x1;
339  // CL
340  cl_energy[0] = (sum_info[j][5]) & 0xFFF;
341  cl_time[0] = (sum_info[j][5] >> 12) & 0xFF;
342  cl_phi[0] = (sum_info[j][5] >> 20) & 0xFF;
343  cl_theta[0] = ((sum_info[j][6] & 0x7) << 4) + ((sum_info[j][5] >> 28) & 0xF);
344 
345  cl_energy[1] = (sum_info[j][6] >> 3) & 0xFFF;
346  cl_time[1] = (sum_info[j][6] >> 15) & 0xFF;
347  cl_phi[1] = (sum_info[j][6] >> 23) & 0xFF;
348  cl_theta[1] = ((sum_info[j][7] & 0x3F) << 1) + ((sum_info[j][6] >> 31) & 0x1);
349 
350  cl_energy[2] = (sum_info[j][7] >> 6) & 0xFFF;
351  cl_time[2] = (sum_info[j][7] >> 18) & 0xFF;
352  cl_phi[2] = ((sum_info[j][8] & 0x3) << 6) + ((sum_info[j][7] >> 26) & 0x3F);
353  cl_theta[2] = (sum_info[j][8] >> 2) & 0x3F;
354 
355  cl_energy[3] = (sum_info[j][8] >> 9) & 0xFFF;
356  cl_time[3] = (sum_info[j][8] >> 21) & 0xFF;
357  cl_phi[3] = ((sum_info[j][9] & 0x1F) << 3) + ((sum_info[j][8] >> 29) & 0x7);
358  cl_theta[3] = (sum_info[j][9] >> 5) & 0x3F;
359 
360  cl_energy[4] = (sum_info[j][ 9] >> 12) & 0xFFF;
361  cl_time[4] = (sum_info[j][ 9] >> 24) & 0xFF;
362  cl_phi[4] = (sum_info[j][10]) & 0xFF;
363  cl_theta[4] = (sum_info[j][10] >> 8) & 0x3F;
364 
365  cl_energy[5] = (sum_info[j][10] >> 15) & 0xFFF;
366  cl_time[5] = ((sum_info[j][11] & 0x7) << 5) + ((sum_info[j][10] >> 27) & 0x1F);
367  cl_phi[5] = (sum_info[j][11] >> 3) & 0xFF;
368  cl_theta[5] = (sum_info[j][11] >> 11) & 0x3F;
369  // CL others
370  for (int k = 0; k < 6; k++) {
371  cl_1gev[k] = (sum_info[j][12] >> k) & 0x1;
372  cl_2gev[k] = (sum_info[j][12] >> (k + 6)) & 0x1;
373  cl_bha[k] = (sum_info[j][12] >> (k + 12)) & 0x1;
374  }
375  ncl = (sum_info[j][13]) & 0x7;
376 
377  m_TRGECLSumArray.appendNew();
378  m_sumNum = m_TRGECLSumArray.getEntries() - 1;
379  m_TRGECLSumArray[m_sumNum]->setEventId(n_basf2evt);
380  m_TRGECLSumArray[m_sumNum]->setSumNum(sum_num);
381  m_TRGECLSumArray[m_sumNum]->setSumRevo(sum_revo);
382  m_TRGECLSumArray[m_sumNum]->setCLTheta(cl_theta);
383  m_TRGECLSumArray[m_sumNum]->setCLPhi(cl_phi);
384  m_TRGECLSumArray[m_sumNum]->setCLTime(cl_time);
385  m_TRGECLSumArray[m_sumNum]->setCLEnergy(cl_energy);
386  m_TRGECLSumArray[m_sumNum]->setCLF1GeV(cl_1gev);
387  m_TRGECLSumArray[m_sumNum]->setCLF2GeV(cl_2gev);
388  m_TRGECLSumArray[m_sumNum]->setCLFBha(cl_bha);
389  m_TRGECLSumArray[m_sumNum]->setNCL(ncl);
390  m_TRGECLSumArray[m_sumNum]->setICN(icn);
391  m_TRGECLSumArray[m_sumNum]->setICNOver(icn_over);
392  m_TRGECLSumArray[m_sumNum]->setLowMulti(low_multi);
393  m_TRGECLSumArray[m_sumNum]->set3DBhabhaV(b2bhabha_v);
394  m_TRGECLSumArray[m_sumNum]->set3DBhabhaS(b2bhabha_s);
395  m_TRGECLSumArray[m_sumNum]->setMumu(mumu);
396  m_TRGECLSumArray[m_sumNum]->setPrescale(prescale);
397  m_TRGECLSumArray[m_sumNum]->set2DBhabha(b1bhabha);
398  m_TRGECLSumArray[m_sumNum]->setBhabhaType(b1_type);
399  m_TRGECLSumArray[m_sumNum]->setPhysics(physics);
400  m_TRGECLSumArray[m_sumNum]->setBG(bg_veto);
401  m_TRGECLSumArray[m_sumNum]->setEtot(etot);
402  m_TRGECLSumArray[m_sumNum]->setEtotType(etot_type);
403  m_TRGECLSumArray[m_sumNum]->setECLBST(ecl_bst);
404  m_TRGECLSumArray[m_sumNum]->setTime(time);
405  m_TRGECLSumArray[m_sumNum]->setTimeType(time_type);
406 
407  for (int k = 0; k < 6; k++) {
408  cl_1d.push_back(cl_theta[k]);
409  cl_1d.push_back(cl_phi[k]);
410  cl_1d.push_back(cl_time[k]);
411  cl_1d.push_back(cl_energy[k]);
412  cl_1d.push_back(cl_1gev[k]);
413  cl_1d.push_back(cl_2gev[k]);
414  cl_1d.push_back(cl_bha[k]);
415  cl_2d.push_back(cl_1d);
416  cl_1d.clear();
417  }
418  sort(cl_2d.begin(), cl_2d.end(),
419  [](const vector<int>& aa1, const vector<int>& aa2) {return aa1[3] > aa2[3];});
420 
421  if (sum_num == -9999) {
422  sum_num_ord = -9999;
423  } else if (sum_num <= 3) {
424  sum_num_ord = 2 * abs(sum_num - 3);
425  } else {
426  sum_num_ord = (sum_num * 2) - 7;
427  }
428  evt_1d_vector.push_back(sum_num_ord);
429  evt_1d_vector.push_back(sum_revo);
430  evt_1d_vector.push_back(sum_num);
431  evt_1d_vector.push_back(time);
432  for (int k = 0; k < 6; k++) {
433  for (int l = 0; l < 7; l++) {
434  evt_1d_vector.push_back(cl_2d[k][l]);
435  }
436  }
437  evt_1d_vector.push_back(ncl);
438  evt_1d_vector.push_back(low_multi);
439  evt_1d_vector.push_back(b2bhabha_v);
440  evt_1d_vector.push_back(b2bhabha_s);
441  evt_1d_vector.push_back(mumu);
442  evt_1d_vector.push_back(prescale);
443  evt_1d_vector.push_back(icn);
444  evt_1d_vector.push_back(icn_over);
445  evt_1d_vector.push_back(etot_type);
446  evt_1d_vector.push_back(etot);
447  evt_1d_vector.push_back(ecl_bst);
448  evt_1d_vector.push_back(b1_type);
449  evt_1d_vector.push_back(b1bhabha);
450  evt_1d_vector.push_back(physics);
451  evt_1d_vector.push_back(time_type);
452  evt_2d_vector.push_back(evt_1d_vector);
453  evt_1d_vector.clear();
454  }
455  } else {
456  for (int k = 0; k < 6; k++) {
457  cl_theta[k] = 0;
458  cl_phi[k] = 0;
459  cl_time[k] = -9999;
460  cl_energy[k] = 0;
461  cl_1gev[k] = 0;
462  cl_2gev[k] = 0;
463  cl_bha[k] = 0;
464  }
465  ncl = 0;
466  low_multi = 0;
467  b2bhabha_v = 0;
468  b2bhabha_s = 0;
469  mumu = 0;
470  prescale = 0;
471  icn_over = 0;
472  bg_veto = 0;
473  icn = 0;
474  etot_type = 0;
475  etot = 0;
476  ecl_bst = 0;
477  b1_type = 0;
478  b1bhabha = 0;
479  physics = 0;
480  time_type = 0;
481  time = -9999;
482 
483  m_TRGECLSumArray.appendNew();
484  m_sumNum = m_TRGECLSumArray.getEntries() - 1;
485  m_TRGECLSumArray[m_sumNum]->setEventId(n_basf2evt);
486  m_TRGECLSumArray[m_sumNum]->setSumNum(0);
487  m_TRGECLSumArray[m_sumNum]->setCLTheta(cl_theta);
488  m_TRGECLSumArray[m_sumNum]->setCLPhi(cl_phi);
489  m_TRGECLSumArray[m_sumNum]->setCLTime(cl_time);
490  m_TRGECLSumArray[m_sumNum]->setCLEnergy(cl_energy);
491  m_TRGECLSumArray[m_sumNum]->setCLF1GeV(cl_1gev);
492  m_TRGECLSumArray[m_sumNum]->setCLF2GeV(cl_2gev);
493  m_TRGECLSumArray[m_sumNum]->setCLFBha(cl_bha);
494  m_TRGECLSumArray[m_sumNum]->setNCL(ncl);
495  m_TRGECLSumArray[m_sumNum]->setICN(icn);
496  m_TRGECLSumArray[m_sumNum]->setICNOver(icn_over);
497  m_TRGECLSumArray[m_sumNum]->setLowMulti(low_multi);
498  m_TRGECLSumArray[m_sumNum]->set3DBhabhaV(b2bhabha_v);
499  m_TRGECLSumArray[m_sumNum]->set3DBhabhaS(b2bhabha_s);
500  m_TRGECLSumArray[m_sumNum]->setMumu(mumu);
501  m_TRGECLSumArray[m_sumNum]->setPrescale(prescale);
502  m_TRGECLSumArray[m_sumNum]->set2DBhabha(b1bhabha);
503  m_TRGECLSumArray[m_sumNum]->setBhabhaType(b1_type);
504  m_TRGECLSumArray[m_sumNum]->setPhysics(physics);
505  m_TRGECLSumArray[m_sumNum]->setBG(bg_veto);
506  m_TRGECLSumArray[m_sumNum]->setEtot(etot);
507  m_TRGECLSumArray[m_sumNum]->setEtotType(etot_type);
508  m_TRGECLSumArray[m_sumNum]->setECLBST(ecl_bst);
509  m_TRGECLSumArray[m_sumNum]->setTime(time);
510  m_TRGECLSumArray[m_sumNum]->setTimeType(time_type);
511  }
512 
513  // TC & TRG
514  tc_info.insert(tc_info.end(), tc_info_FE1.begin(), tc_info_FE1.end());
515  tc_info.insert(tc_info.end(), tc_info_FE2.begin(), tc_info_FE2.end());
516  tc_info.insert(tc_info.end(), tc_info_BE1.begin(), tc_info_BE1.end());
517  tc_info.insert(tc_info.end(), tc_info_BE2.begin(), tc_info_BE2.end());
518 
519  int m_evtNum = 0;
520 
521  int m_tcNum = 0;
522  /* cppcheck-suppress variableScope */
523  int m_tcid = 0;
524  /* cppcheck-suppress variableScope */
525  int m_time = -9999;
526  /* cppcheck-suppress variableScope */
527  int m_energy = 0;
528  /* cppcheck-suppress variableScope */
529  int m_win = 0;
530  /* cppcheck-suppress variableScope */
531  int m_revo = 0;
532  /* cppcheck-suppress variableScope */
533  int m_caltime = -9999;
534 
535  int tot_ntc = tc_info.size();
536  /* cppcheck-suppress variableScope */
537  int evt_ntc = 0;
538  /* cppcheck-suppress variableScope */
539  int evt_revo = -9999;
540  /* cppcheck-suppress variableScope */
541  int evt_win = 0;
542  /* cppcheck-suppress variableScope */
543  int evt_timing = -9999; // most energetic
544  int evt_cl_theta[6] = {0};
545  int evt_cl_phi[6] = {0};
546  int evt_cl_time[6] = { -9999};
547  int evt_cl_energy[6] = {0};
548  int evt_cl_1gev[6] = {0};
549  int evt_cl_2gev[6] = {0};
550  int evt_cl_bha[6] = {0};
551  /* cppcheck-suppress variableScope */
552  int evt_ncl = 0;
553  /* cppcheck-suppress variableScope */
554  int evt_low_multi = 0;
555  /* cppcheck-suppress variableScope */
556  int evt_b2bhabha_v = 0;
557  /* cppcheck-suppress variableScope */
558  int evt_b2bhabha_s = 0;
559  /* cppcheck-suppress variableScope */
560  int evt_mumu = 0;
561  /* cppcheck-suppress variableScope */
562  int evt_prescale = 0;
563  /* cppcheck-suppress variableScope */
564  int evt_icn = 0;
565  /* cppcheck-suppress variableScope */
566  int evt_icn_over = 0;
567  /* cppcheck-suppress variableScope */
568  int evt_etot_type = 0;
569  /* cppcheck-suppress variableScope */
570  int evt_etot = 0;
571  /* cppcheck-suppress variableScope */
572  int evt_ecl_bst = 0;
573  /* cppcheck-suppress variableScope */
574  int evt_b1_type = 0;
575  /* cppcheck-suppress variableScope */
576  int evt_b1bhabha = 0;
577  /* cppcheck-suppress variableScope */
578  int evt_physics = 0;
579  /* cppcheck-suppress variableScope */
580  int evt_time_type = 0;
581  /* cppcheck-suppress variableScope */
582  int evt_etot_all = 0;
583  /* cppcheck-suppress variableScope */
584  int evt_time_min = 0;
585  /* cppcheck-suppress variableScope */
586  int evt_time_max = 0;
587  /* cppcheck-suppress variableScope */
588  int evt_time_win = 0;
589  /* cppcheck-suppress variableScope */
590  int etot_i = 0;
591  /* cppcheck-suppress variableScope */
592  int etot_c = 0;
593  /* cppcheck-suppress variableScope */
594  int etot_f = 0;
595  /* cppcheck-suppress variableScope */
596  int cl_tcid = 0;
597  /* cppcheck-suppress variableScope */
598  int cl_thetaid = 0;
599  /* cppcheck-suppress variableScope */
600  int cl_phiid = 0;
601  /* cppcheck-suppress variableScope */
602  int m_clNum = 0;
603 
604 
605  int evt_v_size = evt_2d_vector.size();
606  if (evt_v_size != 0) {
607  // Sort window : 3 => 4 => 2 => 5 => 1 => 6 => 7
608  sort(evt_2d_vector.begin(), evt_2d_vector.end(),
609  [](const vector<int>& aa1, const vector<int>& aa2) {return aa1[0] < aa2[0];});
610  }
611 
612  if (tot_ntc != 0 && flag_checksum == 0 && nnn > 7) {
613  if (evt_v_size == 0) {
614  // Find most energetic TC timing
615  sort(tc_info.begin(), tc_info.end(),
616  [](const vector<int>& aa1, const vector<int>& aa2) {return aa1[2] > aa2[2];});
617  evt_revo = win3_revo;
618  evt_win = tc_info[0][3];
619  evt_timing = tc_info[0][1];
620  for (int k = 0; k < 6; k++) {
621  evt_cl_theta[k] = 0;
622  evt_cl_phi[k] = 0;
623  evt_cl_time[k] = 0;
624  evt_cl_energy[k] = 0;
625  evt_cl_1gev[k] = 0;
626  evt_cl_2gev[k] = 0;
627  evt_cl_bha[k] = 0;
628  }
629  evt_ncl = 0;
630  evt_low_multi = 0;
631  evt_b2bhabha_v = 0;
632  evt_b2bhabha_s = 0;
633  evt_mumu = 0;
634  evt_prescale = 0;
635  evt_icn = 0;
636  evt_icn_over = 0;
637  evt_etot_type = 0;
638  evt_etot = 0;
639  evt_ecl_bst = 0;
640  evt_b1_type = 0;
641  evt_b1bhabha = 0;
642  evt_physics = 0;
643  evt_time_type = 0;
644  } else {
645  evt_revo = evt_2d_vector[0][1];
646  evt_win = evt_2d_vector[0][2];
647  evt_timing = evt_2d_vector[0][3];
648  for (int k = 0; k < 6; k++) {
649  evt_cl_theta[k] = evt_2d_vector[0][ 4 + k * 7];
650  evt_cl_phi[k] = evt_2d_vector[0][ 5 + k * 7];
651  evt_cl_time[k] = evt_2d_vector[0][ 6 + k * 7];
652  evt_cl_energy[k] = evt_2d_vector[0][ 7 + k * 7];
653  evt_cl_1gev[k] = evt_2d_vector[0][ 8 + k * 7];
654  evt_cl_2gev[k] = evt_2d_vector[0][ 9 + k * 7];
655  evt_cl_bha[k] = evt_2d_vector[0][10 + k * 7];
656  }
657  evt_ncl = evt_2d_vector[0][46];
658  evt_low_multi = evt_2d_vector[0][47];
659  evt_b2bhabha_v = evt_2d_vector[0][48];
660  evt_b2bhabha_s = evt_2d_vector[0][49];
661  evt_mumu = evt_2d_vector[0][50];
662  evt_prescale = evt_2d_vector[0][51];
663  evt_icn = evt_2d_vector[0][52];
664  evt_icn_over = evt_2d_vector[0][53];
665  evt_etot_type = evt_2d_vector[0][54];
666  evt_etot = evt_2d_vector[0][55];
667  evt_ecl_bst = evt_2d_vector[0][56];
668  evt_b1_type = evt_2d_vector[0][57];
669  evt_b1bhabha = evt_2d_vector[0][58];
670  evt_physics = evt_2d_vector[0][59];
671  evt_time_type = evt_2d_vector[0][60];
672  }
673  // Sort by TC number
674  sort(tc_info.begin(), tc_info.end(),
675  [](const vector<int>& aa1, const vector<int>& aa2) {return aa1[0] < aa2[0];});
676 
677  for (int ii = 0; ii < tot_ntc; ii++) {
678  m_tcid = tc_info[ii][0];
679  m_time = tc_info[ii][1];
680  m_energy = tc_info[ii][2];
681  m_win = tc_info[ii][3];
682  m_revo = win3_revo;
683  m_caltime = m_time - ((evt_win - 3) * 128 + evt_timing);
684  m_TRGECLTCArray.appendNew();
685  m_tcNum = m_TRGECLTCArray.getEntries() - 1;
686  m_TRGECLTCArray[m_tcNum]->setEventId(n_basf2evt);
687  m_TRGECLTCArray[m_tcNum]->setTCId(m_tcid);
688  m_TRGECLTCArray[m_tcNum]->setTCTime(m_time);
689  m_TRGECLTCArray[m_tcNum]->setTCCALTime(m_caltime);
690  m_TRGECLTCArray[m_tcNum]->setHitWin(m_win);
691  m_TRGECLTCArray[m_tcNum]->setRevoFAM(m_revo);
692  m_TRGECLTCArray[m_tcNum]->setTCEnergy(m_energy);
693  m_TRGECLTCArray[m_tcNum]->setChecksum(flag_checksum);
694 
695  if (m_win == evt_win || m_win == evt_win + 1) evt_ntc++;
696  if (m_win == evt_win - 1) {
697  etot_i += m_energy;
698  }
699  if (m_win == evt_win) {
700  etot_c += m_energy;
701  }
702  if (m_win == evt_win + 1) {
703  etot_f += m_energy;
704  }
705  }
706 
707  if (etot_i == 0 && etot_f == 0) {
708  evt_etot_all = etot_c;
709  evt_time_min = - evt_timing;
710  evt_time_max = 256 - evt_timing;
711  evt_time_win = 1;
712  } else if (etot_i >= etot_f) {
713  evt_etot_all = etot_c + etot_i;
714  evt_time_min = -128 - evt_timing;
715  evt_time_max = 128 - evt_timing;
716  evt_time_win = -1;
717  } else {
718  evt_etot_all = etot_c + etot_f;
719  evt_time_min = - evt_timing;
720  evt_time_max = 256 - evt_timing;
721  evt_time_win = 1;
722  }
723 
724  for (int icluster = 0; icluster < 6; icluster++) {
725  if (evt_cl_energy[icluster] == 0 || evt_cl_theta[icluster] == 0 || evt_cl_phi[icluster] == 0) {continue;}
726  cl_tcid = mapping.getTCIdFromPosition(evt_cl_theta[icluster], evt_cl_phi[icluster]);
727  if (cl_tcid == 0) {continue;}
728  cl_thetaid = mapping.getTCThetaIdFromTCId(cl_tcid);
729  cl_phiid = mapping.getTCPhiIdFromTCId(cl_tcid);
730 
731  m_TRGECLClusterArray.appendNew();
732  m_clNum = m_TRGECLClusterArray.getEntries() - 1;
733  m_TRGECLClusterArray[m_clNum]->setEventId(n_basf2evt);
734  m_TRGECLClusterArray[m_clNum]->setClusterId(icluster);
735  m_TRGECLClusterArray[m_clNum]->setEventRevo(evt_revo);
736 
737  m_TRGECLClusterArray[m_clNum]->setMaxTCId(cl_tcid); // center of Cluster
738  m_TRGECLClusterArray[m_clNum]->setMaxThetaId(cl_thetaid);
739  m_TRGECLClusterArray[m_clNum]->setMaxPhiId(cl_phiid);
740  m_TRGECLClusterArray[m_clNum]->setClusterId(icluster);
741  m_TRGECLClusterArray[m_clNum]->setEnergyDep((double)evt_cl_energy[icluster] * 5.25); // MeV
742  m_TRGECLClusterArray[m_clNum]->setTimeAve((double)evt_cl_time[icluster]);
743  m_TRGECLClusterArray[m_clNum]->setPositionX(mapping.getTCPosition(cl_tcid).X());
744  m_TRGECLClusterArray[m_clNum]->setPositionY(mapping.getTCPosition(cl_tcid).Y());
745  m_TRGECLClusterArray[m_clNum]->setPositionZ(mapping.getTCPosition(cl_tcid).Z());
746  }
747  m_TRGECLEvtArray.appendNew();
748  m_evtNum = m_TRGECLEvtArray.getEntries() - 1;
749  m_TRGECLEvtArray[m_evtNum]->setEventId(n_basf2evt);
750  m_TRGECLEvtArray[m_evtNum]->setETM(etm_version);
751  m_TRGECLEvtArray[m_evtNum]->setL1Revo(l1_revo);
752  m_TRGECLEvtArray[m_evtNum]->setEvtRevo(evt_revo);
753  m_TRGECLEvtArray[m_evtNum]->setEvtWin(evt_win);
754  m_TRGECLEvtArray[m_evtNum]->setEvtTime(evt_timing);
755  m_TRGECLEvtArray[m_evtNum]->setNTC(evt_ntc);
756  m_TRGECLEvtArray[m_evtNum]->setCLTheta(evt_cl_theta);
757  m_TRGECLEvtArray[m_evtNum]->setCLPhi(evt_cl_phi);
758  m_TRGECLEvtArray[m_evtNum]->setCLTime(evt_cl_time);
759  m_TRGECLEvtArray[m_evtNum]->setCLEnergy(evt_cl_energy);
760  m_TRGECLEvtArray[m_evtNum]->setCLF1GeV(evt_cl_1gev);
761  m_TRGECLEvtArray[m_evtNum]->setCLF2GeV(evt_cl_2gev);
762  m_TRGECLEvtArray[m_evtNum]->setCLFBha(evt_cl_bha);
763  m_TRGECLEvtArray[m_evtNum]->setNCL(evt_ncl);
764  m_TRGECLEvtArray[m_evtNum]->setLowMulti(evt_low_multi);
765  m_TRGECLEvtArray[m_evtNum]->set3DBhabhaV(evt_b2bhabha_v);
766  m_TRGECLEvtArray[m_evtNum]->set3DBhabhaS(evt_b2bhabha_s);
767  m_TRGECLEvtArray[m_evtNum]->setMumu(evt_mumu);
768  m_TRGECLEvtArray[m_evtNum]->setPrescale(evt_prescale);
769  m_TRGECLEvtArray[m_evtNum]->setICN(evt_icn);
770  m_TRGECLEvtArray[m_evtNum]->setICNOver(evt_icn_over);
771  m_TRGECLEvtArray[m_evtNum]->setEtotType(evt_etot_type);
772  m_TRGECLEvtArray[m_evtNum]->setEtot(evt_etot);
773  m_TRGECLEvtArray[m_evtNum]->setECLBST(evt_ecl_bst);
774  m_TRGECLEvtArray[m_evtNum]->set2DBhabha(evt_b1bhabha);
775  m_TRGECLEvtArray[m_evtNum]->setBhabhaType(evt_b1_type);
776  m_TRGECLEvtArray[m_evtNum]->setPhysics(evt_physics);
777  m_TRGECLEvtArray[m_evtNum]->setTimeType(evt_time_type);
778  m_TRGECLEvtArray[m_evtNum]->setCheckSum(flag_checksum);
779  m_TRGECLEvtArray[m_evtNum]->setEvtExist(1);
780  m_TRGECLEvtArray[m_evtNum]->setTRGTYPE(trgtype);
781  m_TRGECLEvtArray[m_evtNum]->setEtotAll(evt_etot_all);
782  m_TRGECLEvtArray[m_evtNum]->setEvtTimeMin(evt_time_min);
783  m_TRGECLEvtArray[m_evtNum]->setEvtTimeMax(evt_time_max);
784  m_TRGECLEvtArray[m_evtNum]->setEvtTimeWin(evt_time_win);
785  } else {
786  m_TRGECLTCArray.appendNew();
787  m_tcNum = m_TRGECLTCArray.getEntries() - 1;
788  m_TRGECLTCArray[m_tcNum]->setEventId(n_basf2evt);
789  m_TRGECLTCArray[m_tcNum]->setTCId(0);
790  m_TRGECLTCArray[m_tcNum]->setTCTime(-9999);
791  m_TRGECLTCArray[m_tcNum]->setTCCALTime(-9999);
792  m_TRGECLTCArray[m_tcNum]->setHitWin(-9999);
793  m_TRGECLTCArray[m_tcNum]->setRevoFAM(-9999);
794  m_TRGECLTCArray[m_tcNum]->setTCEnergy(0);
795  m_TRGECLTCArray[m_tcNum]->setChecksum(flag_checksum);
796 
797  m_TRGECLEvtArray.appendNew();
798  m_evtNum = m_TRGECLEvtArray.getEntries() - 1;
799  m_TRGECLEvtArray[m_evtNum]->setEventId(n_basf2evt);
800  m_TRGECLEvtArray[m_evtNum]->setETM(etm_version);
801  m_TRGECLEvtArray[m_evtNum]->setL1Revo(-9999);
802  m_TRGECLEvtArray[m_evtNum]->setEvtTime(-9999);
803  m_TRGECLEvtArray[m_evtNum]->setEvtRevo(-9999);
804  m_TRGECLEvtArray[m_evtNum]->setEvtWin(-9999);
805  m_TRGECLEvtArray[m_evtNum]->setNTC(0);
806  for (int k = 0; k < 6; k++) {
807  evt_cl_theta[k] = 0;
808  evt_cl_phi[k] = 0;
809  evt_cl_time[k] = -9999;
810  evt_cl_energy[k] = 0;
811  evt_cl_1gev[k] = 0;
812  evt_cl_2gev[k] = 0;
813  evt_cl_bha[k] = 0;
814  }
815  m_TRGECLEvtArray[m_evtNum]->setCLTheta(evt_cl_theta);
816  m_TRGECLEvtArray[m_evtNum]->setCLPhi(evt_cl_phi);
817  m_TRGECLEvtArray[m_evtNum]->setCLTime(evt_cl_time);
818  m_TRGECLEvtArray[m_evtNum]->setCLEnergy(evt_cl_energy);
819  m_TRGECLEvtArray[m_evtNum]->setCLF1GeV(evt_cl_1gev);
820  m_TRGECLEvtArray[m_evtNum]->setCLF2GeV(evt_cl_2gev);
821  m_TRGECLEvtArray[m_evtNum]->setCLFBha(evt_cl_bha);
822  m_TRGECLEvtArray[m_evtNum]->setNCL(0);
823  m_TRGECLEvtArray[m_evtNum]->setLowMulti(0);
824  m_TRGECLEvtArray[m_evtNum]->set3DBhabhaV(0);
825  m_TRGECLEvtArray[m_evtNum]->set3DBhabhaS(0);
826  m_TRGECLEvtArray[m_evtNum]->setMumu(0);
827  m_TRGECLEvtArray[m_evtNum]->setPrescale(0);
828  m_TRGECLEvtArray[m_evtNum]->setICN(0);
829  m_TRGECLEvtArray[m_evtNum]->setICNOver(0);
830  m_TRGECLEvtArray[m_evtNum]->setEtotType(0);
831  m_TRGECLEvtArray[m_evtNum]->setEtot(0);
832  m_TRGECLEvtArray[m_evtNum]->setECLBST(0);
833  m_TRGECLEvtArray[m_evtNum]->set2DBhabha(0);
834  m_TRGECLEvtArray[m_evtNum]->setBhabhaType(0);
835  m_TRGECLEvtArray[m_evtNum]->setPhysics(0);
836  m_TRGECLEvtArray[m_evtNum]->setTimeType(0);
837  m_TRGECLEvtArray[m_evtNum]->setCheckSum(flag_checksum);
838  m_TRGECLEvtArray[m_evtNum]->setEvtExist(0);
839  m_TRGECLEvtArray[m_evtNum]->setTRGTYPE(trgtype);
840  m_TRGECLEvtArray[m_evtNum]->setEtotAll(0);
841  m_TRGECLEvtArray[m_evtNum]->setEvtTimeMin(-9999);
842  m_TRGECLEvtArray[m_evtNum]->setEvtTimeMax(-9999);
843  m_TRGECLEvtArray[m_evtNum]->setEvtTimeWin(0);
844  }
845 
846  return;
847 }
848 
850 {
851 
852  int version_check = (rdat[0] >> 12) & 0xf;
853  if (version_check != 15) return;
854 
855  // Checksum variable
856  unsigned char check_sum = (rdat[nnn - 1] >> 24) & 0xFF;
857  unsigned char data_sum = 0;
858  unsigned char kdat[4] = {0};
859  for (int j = nnn - 2; j > -1; j--) {
860  kdat[0] = rdat[j] & 0xff;
861  kdat[1] = (rdat[j] >> 8) & 0xff;
862  kdat[2] = (rdat[j] >> 16) & 0xff;
863  kdat[3] = (rdat[j] >> 24) & 0xff;
864  for (int k = 0; k < 4; k++) {
865  data_sum = data_sum + kdat[k];
866  }
867  }
868 
869  int flag_checksum = 0;
870 
871  if (check_sum == data_sum) {
872  flag_checksum = 0;
873  } else {
874  flag_checksum = 1;
875  }
876 
877  // Information
878  int l1_revo = rdat[0] & 0x7ff;
879  int i = 0;
880  int window_num = 0;
881 
882  // Summary
883  /* cppcheck-suppress variableScope */
884  int summary_data = 0;
885  /* cppcheck-suppress variableScope */
886  int summary_revo = 0;
887  /* cppcheck-suppress variableScope */
888  bool summary_trg = false;
889  /* cppcheck-suppress variableScope */
890  int data_win = 0;
891 
892  // TC
893  /* cppcheck-suppress variableScope */
894  int ntc_win = 0;
895  bool tc_trg = false;
896  // TC info
897  int tc_id = 0;
898  int tc_t = 0;
899  int tc_e = 0;
900  int conv_tc_t = 0;
901  int win3_revo = -9999;
902 
903  vector<int> sum_data;
904  vector<vector<int>> sum_info;
905 
906  vector<int> tc_data;
907  vector<vector<int>> tc_info;
908  vector<vector<int>> tc_info_FE1;
909  vector<vector<int>> tc_info_FE2;
910  vector<vector<int>> tc_info_BE1;
911  vector<vector<int>> tc_info_BE2;
912 
913  // Unpacking ---->
914  while (i < nnn - 2) {
915  summary_data = rdat[i + 1];
916  summary_trg = (summary_data >> 23) & 0x1;
917  summary_revo = (summary_data >> 16) & 0x7f;
918  ntc_win = summary_data & 0x3ff;
919  if (ntc_win == 0) {
920  tc_trg = false;
921  } else {
922  tc_trg = true;
923  }
924  data_win = window_num;
925  if (window_num == 3) win3_revo = summary_revo;
926 
927  if (summary_trg == true) { // Summary on
928  sum_data.push_back(data_win);
929  sum_data.push_back(summary_revo);
930  for (int j = 0; j < 9; j++) {
931  sum_data.push_back(rdat[i + j + 2]);
932  }
933  sum_info.push_back(sum_data);
934  sum_data.clear();
935  i = i + 11;
936 
937  if (tc_trg == true) { // summary on & TC on
938  for (int j = 0; j < ntc_win; j++) {
939  tc_id = (rdat[i + j] >> 20) & 0x3FF;
940  tc_t = (rdat[i + j] >> 12) & 0x7F;
941  tc_e = rdat[i + j] & 0xFFF;
942  conv_tc_t = (data_win - 3) * 128 + tc_t;
943 
944  // TC vector
945  tc_data.push_back(tc_id);
946  tc_data.push_back(conv_tc_t);
947  tc_data.push_back(tc_e);
948  tc_data.push_back(data_win);
949  if (tc_id < 81) {
950  if (tc_id > 75) {
951  tc_info_FE1.push_back(tc_data);
952  } else {
953  tc_info_FE2.push_back(tc_data);
954  }
955  } else if (tc_id > 512) {
956  if (tc_id > 572) {
957  tc_info_BE1.push_back(tc_data);
958  } else {
959  tc_info_BE2.push_back(tc_data);
960  }
961  } else {
962  tc_info.push_back(tc_data);
963  }
964  tc_data.clear();
965  }
966  i = i + ntc_win - 1;
967  }
968 
969  } else { // Summary off
970  if (tc_trg == true) { // summary off & TC on
971  for (int j = 0; j < ntc_win; j++) {
972  tc_id = (rdat[i + j + 2] >> 20) & 0x3FF;
973  tc_t = (rdat[i + j + 2] >> 12) & 0x7F;
974  conv_tc_t = (data_win - 3) * 128 + tc_t;
975  tc_e = rdat[i + j + 2] & 0xFFF;
976 
977  // TC vector
978  tc_data.push_back(tc_id);
979  tc_data.push_back(conv_tc_t);
980  tc_data.push_back(tc_e);
981  tc_data.push_back(data_win);
982  if (tc_id < 81) {
983  if (tc_id > 75) {
984  tc_info_FE1.push_back(tc_data);
985  } else {
986  tc_info_FE2.push_back(tc_data);
987  }
988  } else if (tc_id > 512) {
989  if (tc_id > 572) {
990  tc_info_BE1.push_back(tc_data);
991  } else {
992  tc_info_BE2.push_back(tc_data);
993  }
994  } else {
995  tc_info.push_back(tc_data);
996  }
997  tc_data.clear();
998  }
999  i = i + ntc_win + 1;
1000  } else { // Summary off & TC off
1001  i = i + 1;
1002  }
1003  }
1004  window_num++;
1005  }
1006 
1007  // <---- Unpacking
1008 
1009  // Summary
1010  /* cppcheck-suppress variableScope */
1011  int sum_num = 0;
1012  /* cppcheck-suppress variableScope */
1013  int sum_revo = 0;
1014  int cl_theta[6] = {0};
1015  int cl_phi[6] = {0};
1016  int cl_time[6] = { -9999};
1017  int cl_energy[6] = {0};
1018  int ncl = 0;
1019  int low_multi = 0;
1020  int b2bhabha_v = 0;
1021  int b2bhabha_s = 0;
1022  int mumu = 0;
1023  int prescale = 0;
1024  int icn_over = 0;
1025  int bg_veto = 0;
1026  int icn = 0;
1027  int etot_type = 0;
1028  int etot = 0;
1029  int b1_type = 0;
1030  int b1bhabha = 0;
1031  int physics = 0;
1032  int time_type = 0;
1033  int time = 0;
1034  int ecl_bst = 0;
1035 
1036  int m_sumNum = 0;
1037 
1038  TrgEclDataBase database;
1039  TrgEclMapping mapping;
1040 
1041  vector<int> cl_1d;
1042  vector<vector<int>> cl_2d;
1043 
1044  vector<int> evt_1d_vector;
1045  vector<vector<int>> evt_2d_vector;
1046 
1047  // Store Summary
1048  int sum_size = sum_info.size();
1049  if (sum_size != 0) {
1050  for (int j = 0; j < sum_size; j++) {
1051  sum_num = sum_info[j][0];
1052  sum_revo = sum_info[j][1];
1053  if (etm_version >= 128) {
1054  ecl_bst = (sum_info[j][2] >> 26) & 0x1;
1055  }
1056  if (etm_version > 119) {
1057  cl_theta[5] = (sum_info[j][2] >> 19) & 0x7f;
1058  cl_phi[5] = (sum_info[j][2] >> 11) & 0xff;
1059  cl_time[5] = (sum_info[j][2] >> 3) & 0xff;
1060  cl_energy[5] = ((sum_info[j][2] & 0x7) << 9) + ((sum_info[j][3] >> 23) & 0x1ff);
1061 
1062  cl_theta[4] = (sum_info[j][3] >> 16) & 0x7f;
1063  cl_phi[4] = (sum_info[j][3] >> 8) & 0xff;
1064  cl_time[4] = (sum_info[j][3]) & 0xff;
1065  cl_energy[4] = (sum_info[j][4] >> 20) & 0xfff;
1066 
1067  cl_theta[3] = (sum_info[j][4] >> 13) & 0x7f;
1068  cl_phi[3] = (sum_info[j][4] >> 5) & 0xff;
1069  cl_time[3] = ((sum_info[j][4] & 0x1f) << 3) + ((sum_info[j][5] >> 29) & 0x7);
1070  cl_energy[3] = (sum_info[j][5] >> 17) & 0xfff;
1071 
1072  cl_theta[2] = (sum_info[j][5] >> 10) & 0x7f;
1073  cl_phi[2] = (sum_info[j][5] >> 2) & 0xff;
1074  cl_time[2] = ((sum_info[j][5] & 0x3) << 6) + ((sum_info[j][6] >> 26) & 0x3f);
1075  cl_energy[2] = (sum_info[j][6] >> 14) & 0xfff;
1076 
1077  cl_theta[1] = (sum_info[j][6] >> 7) & 0x7f;
1078  cl_phi[1] = ((sum_info[j][6] & 0x7f) << 1) + ((sum_info[j][7] >> 31) & 0x1);
1079  cl_time[1] = (sum_info[j][7] >> 23) & 0xff;
1080  cl_energy[1] = (sum_info[j][7] >> 11) & 0xfff;
1081 
1082  cl_theta[0] = (sum_info[j][7] >> 4) & 0x7f;
1083  cl_phi[0] = ((sum_info[j][7] & 0xf) << 4) + ((sum_info[j][8] >> 28) & 0xf);
1084  cl_time[0] = (sum_info[j][8] >> 20) & 0xff;
1085  cl_energy[0] = (sum_info[j][8] >> 8) & 0xfff;
1086 
1087  ncl = (sum_info[j][8] >> 5) & 0x7;
1088 
1089  prescale = (sum_info[j][8] >> 4) & 0x1;
1090  mumu = (sum_info[j][8] >> 3) & 0x1;
1091  b2bhabha_s = (sum_info[j][8] >> 2) & 0x1;
1092  if (etm_version >= 135) {
1093  low_multi = (((sum_info[j][2] >> 27) & 0x3) << 12) + ((sum_info[j][8] & 0x3) << 10) + ((sum_info[j][9] >> 22) & 0x3ff);
1094  } else {
1095  low_multi = ((sum_info[j][8] & 0x3) << 10) + ((sum_info[j][9] >> 22) & 0x3ff);
1096  }
1097  b2bhabha_v = (sum_info[j][9] >> 21) & 0x1;
1098  icn_over = (sum_info[j][9] >> 20) & 0x1;
1099  bg_veto = (sum_info[j][9] >> 17) & 0x7;
1100  icn = (sum_info[j][9] >> 10) & 0x7f;
1101  etot_type = (sum_info[j][9] >> 7) & 0x7;
1102  etot = ((sum_info[j][9] & 0x7f) << 6) + ((sum_info[j][10] >> 26) & 0x3f);
1103  b1_type = (sum_info[j][10] >> 12) & 0x3fff;
1104  b1bhabha = (sum_info[j][10] >> 11) & 0x1;
1105  physics = (sum_info[j][10] >> 10) & 0x1;
1106  time_type = (sum_info[j][10] >> 7) & 0x7;
1107  time = (sum_info[j][10]) & 0x7f;
1108  } else {
1109  cl_theta[5] = (sum_info[j][2] >> 24) & 0x7f;
1110  cl_phi[5] = (sum_info[j][2] >> 16) & 0xff;
1111  cl_time[5] = (sum_info[j][2] >> 8) & 0xff;
1112  cl_energy[5] = ((sum_info[j][2] & 0xff) << 4) + ((sum_info[j][3] >> 28) & 0xf);
1113 
1114  cl_theta[4] = (sum_info[j][3] >> 21) & 0x7f;
1115  cl_phi[4] = (sum_info[j][3] >> 13) & 0xff;
1116  cl_time[4] = (sum_info[j][3] >> 5) & 0xff;
1117  cl_energy[4] = ((sum_info[j][3] & 0x1f) << 7) + ((sum_info[j][4] >> 25) & 0x7f);
1118 
1119  cl_theta[3] = (sum_info[j][4] >> 18) & 0x7f;
1120  cl_phi[3] = (sum_info[j][4] >> 10) & 0xff;
1121  cl_time[3] = (sum_info[j][4] >> 2) & 0xff;
1122  cl_energy[3] = ((sum_info[j][4] & 0x3) << 10) + ((sum_info[j][5] >> 22) & 0x3ff);
1123 
1124  cl_theta[2] = (sum_info[j][5] >> 15) & 0x7f;
1125  cl_phi[2] = (sum_info[j][5] >> 7) & 0xff;
1126  cl_time[2] = ((sum_info[j][5] & 0x7f) << 1) + ((sum_info[j][6] >> 31) & 0x1);
1127  cl_energy[2] = (sum_info[j][6] >> 19) & 0xfff;
1128 
1129  cl_theta[1] = (sum_info[j][6] >> 12) & 0x7f;
1130  cl_phi[1] = (sum_info[j][6] >> 4) & 0xff;
1131  cl_time[1] = ((sum_info[j][6] & 0xf) << 4) + ((sum_info[j][7] >> 28) & 0xf);
1132  cl_energy[1] = (sum_info[j][7] >> 16) & 0xfff;
1133 
1134  cl_theta[0] = (sum_info[j][7] >> 9) & 0x7f;
1135  cl_phi[0] = (sum_info[j][7] >> 1) & 0xff;
1136  cl_time[0] = ((sum_info[j][7] & 0x1) << 7) + ((sum_info[j][8] >> 25) & 0x7f);
1137  cl_energy[0] = (sum_info[j][8] >> 13) & 0xfff;
1138 
1139  ncl = (sum_info[j][8] >> 10) & 0x7;
1140 
1141  low_multi = ((sum_info[j][8] & 0x3ff) << 2) + ((sum_info[j][9] >> 30) & 0x3);
1142  b2bhabha_v = (sum_info[j][9] >> 29) & 0x1;
1143  icn_over = (sum_info[j][9] >> 28) & 0x1;
1144  bg_veto = (sum_info[j][9] >> 25) & 0x7;
1145  icn = (sum_info[j][9] >> 18) & 0x7f;
1146  etot_type = (sum_info[j][9] >> 15) & 0x7;
1147  etot = (sum_info[j][9] >> 2) & 0x1fff;
1148 
1149  b1_type = ((sum_info[j][9] & 0x3) << 12) + ((sum_info[j][10] >> 20) & 0xfff);
1150  b1bhabha = (sum_info[j][10] >> 19) & 0x1;
1151  physics = (sum_info[j][10] >> 18) & 0x1;
1152  time_type = (sum_info[j][10] >> 15) & 0x7;
1153  time = (sum_info[j][10] >> 8) & 0x7f;
1154 
1155  b2bhabha_s = 0;
1156  mumu = 0;
1157  prescale = 0;
1158  }
1159 
1160  m_TRGECLSumArray.appendNew();
1161  m_sumNum = m_TRGECLSumArray.getEntries() - 1;
1162  m_TRGECLSumArray[m_sumNum]->setEventId(n_basf2evt);
1163  m_TRGECLSumArray[m_sumNum]->setSumNum(sum_num);
1164  m_TRGECLSumArray[m_sumNum]->setSumRevo(sum_revo);
1165  m_TRGECLSumArray[m_sumNum]->setCLTheta(cl_theta);
1166  m_TRGECLSumArray[m_sumNum]->setCLPhi(cl_phi);
1167  m_TRGECLSumArray[m_sumNum]->setCLTime(cl_time);
1168  m_TRGECLSumArray[m_sumNum]->setCLEnergy(cl_energy);
1169  m_TRGECLSumArray[m_sumNum]->setNCL(ncl);
1170  m_TRGECLSumArray[m_sumNum]->setICN(icn);
1171  m_TRGECLSumArray[m_sumNum]->setICNOver(icn_over);
1172  m_TRGECLSumArray[m_sumNum]->setLowMulti(low_multi);
1173  m_TRGECLSumArray[m_sumNum]->set3DBhabhaV(b2bhabha_v);
1174  m_TRGECLSumArray[m_sumNum]->set3DBhabhaS(b2bhabha_s);
1175  m_TRGECLSumArray[m_sumNum]->setMumu(mumu);
1176  m_TRGECLSumArray[m_sumNum]->setPrescale(prescale);
1177  m_TRGECLSumArray[m_sumNum]->set2DBhabha(b1bhabha);
1178  m_TRGECLSumArray[m_sumNum]->setBhabhaType(b1_type);
1179  m_TRGECLSumArray[m_sumNum]->setPhysics(physics);
1180  m_TRGECLSumArray[m_sumNum]->setBG(bg_veto);
1181  m_TRGECLSumArray[m_sumNum]->setEtot(etot);
1182  m_TRGECLSumArray[m_sumNum]->setEtotType(etot_type);
1183  m_TRGECLSumArray[m_sumNum]->setECLBST(ecl_bst);
1184  m_TRGECLSumArray[m_sumNum]->setTime(time);
1185  m_TRGECLSumArray[m_sumNum]->setTimeType(time_type);
1186 
1187  for (int k = 0; k < 6; k++) {
1188  cl_1d.push_back(cl_theta[k]);
1189  cl_1d.push_back(cl_phi[k]);
1190  cl_1d.push_back(cl_time[k]);
1191  cl_1d.push_back(cl_energy[k]);
1192  cl_2d.push_back(cl_1d);
1193  cl_1d.clear();
1194  }
1195  sort(cl_2d.begin(), cl_2d.end(),
1196  [](const vector<int>& aa1, const vector<int>& aa2) {return aa1[3] > aa2[3];});
1197 
1198  evt_1d_vector.push_back(abs(sum_num - 3));
1199  evt_1d_vector.push_back(sum_revo);
1200  evt_1d_vector.push_back(sum_num);
1201  evt_1d_vector.push_back(time);
1202  for (int k = 0; k < 6; k++) {
1203  evt_1d_vector.push_back(cl_2d[k][0]);
1204  evt_1d_vector.push_back(cl_2d[k][1]);
1205  evt_1d_vector.push_back(cl_2d[k][2]);
1206  evt_1d_vector.push_back(cl_2d[k][3]);
1207  }
1208  evt_1d_vector.push_back(ncl);
1209  evt_1d_vector.push_back(low_multi);
1210  evt_1d_vector.push_back(b2bhabha_v);
1211  evt_1d_vector.push_back(b2bhabha_s);
1212  evt_1d_vector.push_back(mumu);
1213  evt_1d_vector.push_back(prescale);
1214  evt_1d_vector.push_back(icn);
1215  evt_1d_vector.push_back(icn_over);
1216  evt_1d_vector.push_back(etot_type);
1217  evt_1d_vector.push_back(etot);
1218  evt_1d_vector.push_back(ecl_bst);
1219  evt_1d_vector.push_back(b1_type);
1220  evt_1d_vector.push_back(b1bhabha);
1221  evt_1d_vector.push_back(physics);
1222  evt_1d_vector.push_back(time_type);
1223  evt_2d_vector.push_back(evt_1d_vector);
1224  evt_1d_vector.clear();
1225  }
1226  } else {
1227 
1228  for (int k = 0; k < 6; k++) {
1229  cl_theta[k] = 0;
1230  cl_phi[k] = 0;
1231  cl_time[k] = -9999;
1232  cl_energy[k] = 0;
1233  }
1234  ncl = 0;
1235  low_multi = 0;
1236  b2bhabha_v = 0;
1237  b2bhabha_s = 0;
1238  mumu = 0;
1239  prescale = 0;
1240  icn_over = 0;
1241  bg_veto = 0;
1242  icn = 0;
1243  etot_type = 0;
1244  etot = 0;
1245  ecl_bst = 0;
1246  b1_type = 0;
1247  b1bhabha = 0;
1248  physics = 0;
1249  time_type = 0;
1250  time = -9999;
1251 
1252  m_TRGECLSumArray.appendNew();
1253  m_sumNum = m_TRGECLSumArray.getEntries() - 1;
1254  m_TRGECLSumArray[m_sumNum]->setEventId(n_basf2evt);
1255  m_TRGECLSumArray[m_sumNum]->setSumNum(0);
1256  m_TRGECLSumArray[m_sumNum]->setCLTheta(cl_theta);
1257  m_TRGECLSumArray[m_sumNum]->setCLPhi(cl_phi);
1258  m_TRGECLSumArray[m_sumNum]->setCLTime(cl_time);
1259  m_TRGECLSumArray[m_sumNum]->setCLEnergy(cl_energy);
1260  m_TRGECLSumArray[m_sumNum]->setNCL(ncl);
1261  m_TRGECLSumArray[m_sumNum]->setICN(icn);
1262  m_TRGECLSumArray[m_sumNum]->setICNOver(icn_over);
1263  m_TRGECLSumArray[m_sumNum]->setLowMulti(low_multi);
1264  m_TRGECLSumArray[m_sumNum]->set3DBhabhaV(b2bhabha_v);
1265  m_TRGECLSumArray[m_sumNum]->set3DBhabhaS(b2bhabha_s);
1266  m_TRGECLSumArray[m_sumNum]->setMumu(mumu);
1267  m_TRGECLSumArray[m_sumNum]->setPrescale(prescale);
1268  m_TRGECLSumArray[m_sumNum]->set2DBhabha(b1bhabha);
1269  m_TRGECLSumArray[m_sumNum]->setBhabhaType(b1_type);
1270  m_TRGECLSumArray[m_sumNum]->setPhysics(physics);
1271  m_TRGECLSumArray[m_sumNum]->setBG(bg_veto);
1272  m_TRGECLSumArray[m_sumNum]->setEtot(etot);
1273  m_TRGECLSumArray[m_sumNum]->setEtotType(etot_type);
1274  m_TRGECLSumArray[m_sumNum]->setECLBST(ecl_bst);
1275  m_TRGECLSumArray[m_sumNum]->setTime(time);
1276  m_TRGECLSumArray[m_sumNum]->setTimeType(time_type);
1277  }
1278 
1279  // TC & TRG
1280  tc_info.insert(tc_info.end(), tc_info_FE1.begin(), tc_info_FE1.end());
1281  tc_info.insert(tc_info.end(), tc_info_FE2.begin(), tc_info_FE2.end());
1282  tc_info.insert(tc_info.end(), tc_info_BE1.begin(), tc_info_BE1.end());
1283  tc_info.insert(tc_info.end(), tc_info_BE2.begin(), tc_info_BE2.end());
1284 
1285  int m_evtNum = 0;
1286 
1287  int m_tcNum = 0;
1288  /* cppcheck-suppress variableScope */
1289  int m_tcid = 0;
1290  /* cppcheck-suppress variableScope */
1291  int m_time = -9999;
1292  /* cppcheck-suppress variableScope */
1293  int m_energy = 0;
1294  /* cppcheck-suppress variableScope */
1295  int m_win = 0;
1296  /* cppcheck-suppress variableScope */
1297  int m_revo = 0;
1298  /* cppcheck-suppress variableScope */
1299  int m_caltime = -9999;
1300 
1301  int tot_ntc = tc_info.size();
1302  /* cppcheck-suppress variableScope */
1303  int evt_ntc = 0;
1304  /* cppcheck-suppress variableScope */
1305  int evt_revo = -9999;
1306  /* cppcheck-suppress variableScope */
1307  int evt_win = 0;
1308  /* cppcheck-suppress variableScope */
1309  int evt_timing = -9999;
1310  int evt_cl_theta[6] = {0};
1311  int evt_cl_phi[6] = {0};
1312  int evt_cl_time[6] = { -9999};
1313  int evt_cl_energy[6] = {0};
1314  /* cppcheck-suppress variableScope */
1315  int evt_ncl = 0;
1316  /* cppcheck-suppress variableScope */
1317  int evt_low_multi = 0;
1318  /* cppcheck-suppress variableScope */
1319  int evt_b2bhabha_v = 0;
1320  /* cppcheck-suppress variableScope */
1321  int evt_b2bhabha_s = 0;
1322  /* cppcheck-suppress variableScope */
1323  int evt_mumu = 0;
1324  /* cppcheck-suppress variableScope */
1325  int evt_prescale = 0;
1326  /* cppcheck-suppress variableScope */
1327  int evt_icn = 0;
1328  /* cppcheck-suppress variableScope */
1329  int evt_icn_over = 0;
1330  /* cppcheck-suppress variableScope */
1331  int evt_etot_type = 0;
1332  /* cppcheck-suppress variableScope */
1333  int evt_etot = 0;
1334  /* cppcheck-suppress variableScope */
1335  int evt_ecl_bst = 0;
1336  /* cppcheck-suppress variableScope */
1337  int evt_b1_type = 0;
1338  /* cppcheck-suppress variableScope */
1339  int evt_b1bhabha = 0;
1340  /* cppcheck-suppress variableScope */
1341  int evt_physics = 0;
1342  /* cppcheck-suppress variableScope */
1343  int evt_time_type = 0;
1344  /* cppcheck-suppress variableScope */
1345  int evt_etot_all = 0;
1346  /* cppcheck-suppress variableScope */
1347  int evt_time_min = 0;
1348  /* cppcheck-suppress variableScope */
1349  int evt_time_max = 0;
1350  /* cppcheck-suppress variableScope */
1351  int evt_time_win = 0;
1352  /* cppcheck-suppress variableScope */
1353  int etot_i = 0;
1354  /* cppcheck-suppress variableScope */
1355  int etot_c = 0;
1356  /* cppcheck-suppress variableScope */
1357  int etot_f = 0;
1358  /* cppcheck-suppress variableScope */
1359  int cl_tcid = 0;
1360  /* cppcheck-suppress variableScope */
1361  int cl_thetaid = 0;
1362  /* cppcheck-suppress variableScope */
1363  int cl_phiid = 0;
1364  /* cppcheck-suppress variableScope */
1365  int m_clNum = 0;
1366 
1367 
1368  int evt_v_size = evt_2d_vector.size();
1369  if (evt_v_size != 0) {
1370  // Sort window : 3 => 4 => 2 => 5 => 1 => 6 => 7
1371  sort(evt_2d_vector.begin(), evt_2d_vector.end(),
1372  [](const vector<int>& aa1, const vector<int>& aa2) {return aa1[0] < aa2[0];});
1373  }
1374 
1375  if (tot_ntc != 0 && flag_checksum == 0 && nnn > 7) {
1376  if (evt_v_size == 0) {
1377  // Find most energetic TC timing
1378  sort(tc_info.begin(), tc_info.end(),
1379  [](const vector<int>& aa1, const vector<int>& aa2) {return aa1[2] > aa2[2];});
1380  evt_revo = win3_revo;
1381  evt_win = tc_info[0][3];
1382  evt_timing = tc_info[0][1];
1383  for (int k = 0; k < 6; k++) {
1384  evt_cl_theta[k] = 0;
1385  evt_cl_phi[k] = 0;
1386  evt_cl_time[k] = 0;
1387  evt_cl_energy[k] = 0;
1388  }
1389  evt_ncl = 0;
1390  evt_low_multi = 0;
1391  evt_b2bhabha_v = 0;
1392  evt_b2bhabha_s = 0;
1393  evt_mumu = 0;
1394  evt_prescale = 0;
1395  evt_icn = 0;
1396  evt_icn_over = 0;
1397  evt_etot_type = 0;
1398  evt_etot = 0;
1399  evt_ecl_bst = 0;
1400  evt_b1_type = 0;
1401  evt_b1bhabha = 0;
1402  evt_physics = 0;
1403  evt_time_type = 0;
1404  } else {
1405  evt_revo = evt_2d_vector[0][1];
1406  evt_win = evt_2d_vector[0][2];
1407  evt_timing = evt_2d_vector[0][3];
1408  for (int k = 0; k < 6; k++) {
1409  evt_cl_theta[k] = evt_2d_vector[0][4 + k * 4];
1410  evt_cl_phi[k] = evt_2d_vector[0][5 + k * 4];
1411  evt_cl_time[k] = evt_2d_vector[0][6 + k * 4];
1412  evt_cl_energy[k] = evt_2d_vector[0][7 + k * 4];
1413  }
1414  evt_ncl = evt_2d_vector[0][28];
1415  evt_low_multi = evt_2d_vector[0][29];
1416  evt_b2bhabha_v = evt_2d_vector[0][30];
1417  evt_b2bhabha_s = evt_2d_vector[0][31];
1418  evt_mumu = evt_2d_vector[0][32];
1419  evt_prescale = evt_2d_vector[0][33];
1420  evt_icn = evt_2d_vector[0][34];
1421  evt_icn_over = evt_2d_vector[0][35];
1422  evt_etot_type = evt_2d_vector[0][36];
1423  evt_etot = evt_2d_vector[0][37];
1424  evt_ecl_bst = evt_2d_vector[0][38];
1425  evt_b1_type = evt_2d_vector[0][39];
1426  evt_b1bhabha = evt_2d_vector[0][40];
1427  evt_physics = evt_2d_vector[0][41];
1428  evt_time_type = evt_2d_vector[0][42];
1429  }
1430  // Sort by TC number
1431  sort(tc_info.begin(), tc_info.end(),
1432  [](const vector<int>& aa1, const vector<int>& aa2) {return aa1[0] < aa2[0];});
1433 
1434  for (int ii = 0; ii < tot_ntc; ii++) {
1435  m_tcid = tc_info[ii][0];
1436  m_time = tc_info[ii][1];
1437  m_energy = tc_info[ii][2];
1438  m_win = tc_info[ii][3];
1439  m_revo = win3_revo;
1440  m_caltime = m_time - ((evt_win - 3) * 128 + evt_timing);
1441  m_TRGECLTCArray.appendNew();
1442  m_tcNum = m_TRGECLTCArray.getEntries() - 1;
1443  m_TRGECLTCArray[m_tcNum]->setEventId(n_basf2evt);
1444  m_TRGECLTCArray[m_tcNum]->setTCId(m_tcid);
1445  m_TRGECLTCArray[m_tcNum]->setTCTime(m_time);
1446  m_TRGECLTCArray[m_tcNum]->setTCCALTime(m_caltime);
1447  m_TRGECLTCArray[m_tcNum]->setHitWin(m_win);
1448  m_TRGECLTCArray[m_tcNum]->setRevoFAM(m_revo);
1449  m_TRGECLTCArray[m_tcNum]->setTCEnergy(m_energy);
1450  m_TRGECLTCArray[m_tcNum]->setChecksum(flag_checksum);
1451 
1452  if (m_win == evt_win || m_win == evt_win + 1) evt_ntc++;
1453  if (m_win == evt_win - 1) {
1454  etot_i += m_energy;
1455  }
1456  if (m_win == evt_win) {
1457  etot_c += m_energy;
1458  }
1459  if (m_win == evt_win + 1) {
1460  etot_f += m_energy;
1461  }
1462  }
1463 
1464  if (etot_i == 0 && etot_f == 0) {
1465  evt_etot_all = etot_c;
1466  evt_time_min = - evt_timing;
1467  evt_time_max = 256 - evt_timing;
1468  evt_time_win = 1;
1469  } else if (etot_i >= etot_f) {
1470  evt_etot_all = etot_c + etot_i;
1471  evt_time_min = -128 - evt_timing;
1472  evt_time_max = 128 - evt_timing;
1473  evt_time_win = -1;
1474  } else {
1475  evt_etot_all = etot_c + etot_f;
1476  evt_time_min = - evt_timing;
1477  evt_time_max = 256 - evt_timing;
1478  evt_time_win = 1;
1479  }
1480 
1481  for (int icluster = 0; icluster < 6; icluster++) {
1482  if (evt_cl_energy[icluster] == 0 || evt_cl_theta[icluster] == 0 || evt_cl_phi[icluster] == 0) {continue;}
1483  cl_tcid = mapping.getTCIdFromPosition(evt_cl_theta[icluster], evt_cl_phi[icluster]);
1484  if (cl_tcid == 0) {continue;}
1485  cl_thetaid = mapping.getTCThetaIdFromTCId(cl_tcid);
1486  cl_phiid = mapping.getTCPhiIdFromTCId(cl_tcid);
1487 
1488  m_TRGECLClusterArray.appendNew();
1489  m_clNum = m_TRGECLClusterArray.getEntries() - 1;
1490  m_TRGECLClusterArray[m_clNum]->setEventId(n_basf2evt);
1491  m_TRGECLClusterArray[m_clNum]->setClusterId(icluster);
1492  m_TRGECLClusterArray[m_clNum]->setEventRevo(evt_revo);
1493 
1494  m_TRGECLClusterArray[m_clNum]->setMaxTCId(cl_tcid); // center of Cluster
1495  m_TRGECLClusterArray[m_clNum]->setMaxThetaId(cl_thetaid);
1496  m_TRGECLClusterArray[m_clNum]->setMaxPhiId(cl_phiid);
1497  m_TRGECLClusterArray[m_clNum]->setClusterId(icluster);
1498  m_TRGECLClusterArray[m_clNum]->setEnergyDep((double)evt_cl_energy[icluster] * 5.25); // MeV
1499  m_TRGECLClusterArray[m_clNum]->setTimeAve((double)evt_cl_time[icluster]);
1500  m_TRGECLClusterArray[m_clNum]->setPositionX(mapping.getTCPosition(cl_tcid).X());
1501  m_TRGECLClusterArray[m_clNum]->setPositionY(mapping.getTCPosition(cl_tcid).Y());
1502  m_TRGECLClusterArray[m_clNum]->setPositionZ(mapping.getTCPosition(cl_tcid).Z());
1503  }
1504  m_TRGECLEvtArray.appendNew();
1505  m_evtNum = m_TRGECLEvtArray.getEntries() - 1;
1506  m_TRGECLEvtArray[m_evtNum]->setEventId(n_basf2evt);
1507  m_TRGECLEvtArray[m_evtNum]->setETM(etm_version);
1508  m_TRGECLEvtArray[m_evtNum]->setL1Revo(l1_revo);
1509  m_TRGECLEvtArray[m_evtNum]->setEvtRevo(evt_revo);
1510  m_TRGECLEvtArray[m_evtNum]->setEvtWin(evt_win);
1511  m_TRGECLEvtArray[m_evtNum]->setEvtTime(evt_timing);
1512  m_TRGECLEvtArray[m_evtNum]->setNTC(evt_ntc);
1513  m_TRGECLEvtArray[m_evtNum]->setCLTheta(evt_cl_theta);
1514  m_TRGECLEvtArray[m_evtNum]->setCLPhi(evt_cl_phi);
1515  m_TRGECLEvtArray[m_evtNum]->setCLTime(evt_cl_time);
1516  m_TRGECLEvtArray[m_evtNum]->setCLEnergy(evt_cl_energy);
1517  m_TRGECLEvtArray[m_evtNum]->setNCL(evt_ncl);
1518  m_TRGECLEvtArray[m_evtNum]->setLowMulti(evt_low_multi);
1519  m_TRGECLEvtArray[m_evtNum]->set3DBhabhaV(evt_b2bhabha_v);
1520  m_TRGECLEvtArray[m_evtNum]->set3DBhabhaS(evt_b2bhabha_s);
1521  m_TRGECLEvtArray[m_evtNum]->setMumu(evt_mumu);
1522  m_TRGECLEvtArray[m_evtNum]->setPrescale(evt_prescale);
1523  m_TRGECLEvtArray[m_evtNum]->setICN(evt_icn);
1524  m_TRGECLEvtArray[m_evtNum]->setICNOver(evt_icn_over);
1525  m_TRGECLEvtArray[m_evtNum]->setEtotType(evt_etot_type);
1526  m_TRGECLEvtArray[m_evtNum]->setEtot(evt_etot);
1527  m_TRGECLEvtArray[m_evtNum]->setECLBST(evt_ecl_bst);
1528  m_TRGECLEvtArray[m_evtNum]->set2DBhabha(evt_b1bhabha);
1529  m_TRGECLEvtArray[m_evtNum]->setBhabhaType(evt_b1_type);
1530  m_TRGECLEvtArray[m_evtNum]->setPhysics(evt_physics);
1531  m_TRGECLEvtArray[m_evtNum]->setTimeType(evt_time_type);
1532  m_TRGECLEvtArray[m_evtNum]->setCheckSum(flag_checksum);
1533  m_TRGECLEvtArray[m_evtNum]->setEvtExist(1);
1534  m_TRGECLEvtArray[m_evtNum]->setTRGTYPE(trgtype);
1535  m_TRGECLEvtArray[m_evtNum]->setEtotAll(evt_etot_all);
1536  m_TRGECLEvtArray[m_evtNum]->setEvtTimeMin(evt_time_min);
1537  m_TRGECLEvtArray[m_evtNum]->setEvtTimeMax(evt_time_max);
1538  m_TRGECLEvtArray[m_evtNum]->setEvtTimeWin(evt_time_win);
1539  } else {
1540  m_TRGECLTCArray.appendNew();
1541  m_tcNum = m_TRGECLTCArray.getEntries() - 1;
1542  m_TRGECLTCArray[m_tcNum]->setEventId(n_basf2evt);
1543  m_TRGECLTCArray[m_tcNum]->setTCId(0);
1544  m_TRGECLTCArray[m_tcNum]->setTCTime(-9999);
1545  m_TRGECLTCArray[m_tcNum]->setTCCALTime(-9999);
1546  m_TRGECLTCArray[m_tcNum]->setHitWin(-9999);
1547  m_TRGECLTCArray[m_tcNum]->setRevoFAM(-9999);
1548  m_TRGECLTCArray[m_tcNum]->setTCEnergy(0);
1549  m_TRGECLTCArray[m_tcNum]->setChecksum(flag_checksum);
1550 
1551  m_TRGECLEvtArray.appendNew();
1552  m_evtNum = m_TRGECLEvtArray.getEntries() - 1;
1553  m_TRGECLEvtArray[m_evtNum]->setEventId(n_basf2evt);
1554  m_TRGECLEvtArray[m_evtNum]->setETM(etm_version);
1555  m_TRGECLEvtArray[m_evtNum]->setL1Revo(-9999);
1556  m_TRGECLEvtArray[m_evtNum]->setEvtTime(-9999);
1557  m_TRGECLEvtArray[m_evtNum]->setEvtRevo(-9999);
1558  m_TRGECLEvtArray[m_evtNum]->setEvtWin(-9999);
1559  m_TRGECLEvtArray[m_evtNum]->setNTC(0);
1560  for (int k = 0; k < 6; k++) {
1561  evt_cl_theta[k] = 0;
1562  evt_cl_phi[k] = 0;
1563  evt_cl_time[k] = -9999;
1564  evt_cl_energy[k] = 0;
1565  }
1566  m_TRGECLEvtArray[m_evtNum]->setCLTheta(evt_cl_theta);
1567  m_TRGECLEvtArray[m_evtNum]->setCLPhi(evt_cl_phi);
1568  m_TRGECLEvtArray[m_evtNum]->setCLTime(evt_cl_time);
1569  m_TRGECLEvtArray[m_evtNum]->setCLEnergy(evt_cl_energy);
1570  m_TRGECLEvtArray[m_evtNum]->setNCL(0);
1571  m_TRGECLEvtArray[m_evtNum]->setLowMulti(0);
1572  m_TRGECLEvtArray[m_evtNum]->set3DBhabhaV(0);
1573  m_TRGECLEvtArray[m_evtNum]->set3DBhabhaS(0);
1574  m_TRGECLEvtArray[m_evtNum]->setMumu(0);
1575  m_TRGECLEvtArray[m_evtNum]->setPrescale(0);
1576  m_TRGECLEvtArray[m_evtNum]->setICN(0);
1577  m_TRGECLEvtArray[m_evtNum]->setICNOver(0);
1578  m_TRGECLEvtArray[m_evtNum]->setEtotType(0);
1579  m_TRGECLEvtArray[m_evtNum]->setEtot(0);
1580  m_TRGECLEvtArray[m_evtNum]->setECLBST(0);
1581  m_TRGECLEvtArray[m_evtNum]->set2DBhabha(0);
1582  m_TRGECLEvtArray[m_evtNum]->setBhabhaType(0);
1583  m_TRGECLEvtArray[m_evtNum]->setPhysics(0);
1584  m_TRGECLEvtArray[m_evtNum]->setTimeType(0);
1585  m_TRGECLEvtArray[m_evtNum]->setCheckSum(flag_checksum);
1586  m_TRGECLEvtArray[m_evtNum]->setEvtExist(0);
1587  m_TRGECLEvtArray[m_evtNum]->setTRGTYPE(trgtype);
1588  m_TRGECLEvtArray[m_evtNum]->setEtotAll(0);
1589  m_TRGECLEvtArray[m_evtNum]->setEvtTimeMin(-9999);
1590  m_TRGECLEvtArray[m_evtNum]->setEvtTimeMax(-9999);
1591  m_TRGECLEvtArray[m_evtNum]->setEvtTimeWin(0);
1592  }
1593 
1594  return;
1595 }
1596 
Belle2::TRGECLUnpackerModule::initialize
virtual void initialize()
Initilizes TRGECLUnpackerModuel.
Definition: trgeclUnpackerModule.cc:57
Belle2::TRGECLUnpackerModule::endRun
virtual void endRun()
Called when run ended.
Definition: trgeclUnpackerModule.cc:66
Belle2::RawTRG
The Raw TOP class Class for RawCOPPER class data taken by TOP Currently, this class is almost same as...
Definition: RawTRG.h:27
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::TRGECLUnpackerModule::nwords
int nwords
N Word.
Definition: trgeclUnpackerModule.h:86
Belle2::RawCOPPER::GetDetectorBuffer
int * GetDetectorBuffer(int n, int finesse_num)
get Detector buffer
Definition: RawCOPPER.h:667
Belle2::TRGECLUnpackerModule::m_TRGECLTCArray
StoreArray< TRGECLUnpackerStore > m_TRGECLTCArray
ECL Trigger Unpacker TC output.
Definition: trgeclUnpackerModule.h:94
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:82
Belle2::RawCOPPER::GetDetectorNwords
int GetDetectorNwords(int n, int finesse_num)
get Detector buffer length
Definition: RawCOPPER.h:643
Belle2::TRGECLUnpackerModule::trgtype
int trgtype
Trigger Type.
Definition: trgeclUnpackerModule.h:90
Belle2::TRGECLUnpackerModule::m_TRGECLEvtArray
StoreArray< TRGECLUnpackerEvtStore > m_TRGECLEvtArray
ECL Trigger Unpacker Event output.
Definition: trgeclUnpackerModule.h:98
Belle2::TrgEclMapping::getTCPhiIdFromTCId
int getTCPhiIdFromTCId(int)
get [TC Phi ID] from [TC ID]
Definition: TrgEclMapping.cc:227
Belle2::TrgEclDataBase
class TrgEclDataBase;
Definition: TrgEclDataBase.h:24
Belle2::TrgEclMapping
A class of TC Mapping.
Definition: TrgEclMapping.h:31
Belle2::TRGECLUnpackerModule::m_TRGECLClusterArray
StoreArray< TRGECLCluster > m_TRGECLClusterArray
ECL Trigger Cluster output.
Definition: trgeclUnpackerModule.h:100
Belle2::TRGECLUnpackerModule::~TRGECLUnpackerModule
virtual ~TRGECLUnpackerModule()
Destructor.
Definition: trgeclUnpackerModule.cc:51
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::TRGECLUnpackerModule::readCOPPEREvent
virtual void readCOPPEREvent(RawTRG *, int, int)
Read data from TRG copper.
Definition: trgeclUnpackerModule.cc:92
Belle2::TRGECLUnpackerModule::checkBuffer
virtual void checkBuffer(int *, int)
Unpacker main function.
Definition: trgeclUnpackerModule.cc:107
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrgEclMapping::getTCPosition
TVector3 getTCPosition(int)
TC position (cm)
Definition: TrgEclMapping.cc:251
Belle2::TRGECLUnpackerModule::terminate
virtual void terminate()
Called when processing ended.
Definition: trgeclUnpackerModule.cc:53
Belle2::TrgEclMapping::getTCIdFromPosition
int getTCIdFromPosition(int, int)
get TCId from phi and theta position(LSB = 1.4)
Definition: TrgEclMapping.cc:2114
Belle2::TRGECLUnpackerModule::event
virtual void event()
Called event by event.
Definition: trgeclUnpackerModule.cc:67
Belle2::TRGECLUnpackerModule::checkBuffer_v136
virtual void checkBuffer_v136(int *, int)
Unpacker main function for upto version 136.
Definition: trgeclUnpackerModule.cc:849
Belle2::TRGECLUnpackerModule::beginRun
virtual void beginRun()
Called when new run started.
Definition: trgeclUnpackerModule.cc:65
Belle2::TRGECLUnpackerModule::nodeid
unsigned int nodeid
Node Id.
Definition: trgeclUnpackerModule.h:84
Belle2::TrgEclMapping::getTCThetaIdFromTCId
int getTCThetaIdFromTCId(int)
get [TC Theta ID] from [TC ID]
Definition: TrgEclMapping.cc:200
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::TRGECLUnpackerModule::n_basf2evt
int n_basf2evt
Event number.
Definition: trgeclUnpackerModule.h:80
Belle2::TRGECLUnpackerModule::version
std::string version() const
returns version of TRGECLUnpackerModule.
Definition: trgeclUnpackerModule.cc:35
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226
Belle2::TRGECLUnpackerModule::m_TRGECLSumArray
StoreArray< TRGECLUnpackerSumStore > m_TRGECLSumArray
ECL Trigger Unpacker Summary output.
Definition: trgeclUnpackerModule.h:96
Belle2::TRGECLUnpackerModule::iFiness
int iFiness
Finess.
Definition: trgeclUnpackerModule.h:88
Belle2::TRGECLUnpackerModule::etm_version
int etm_version
ETM Version.
Definition: trgeclUnpackerModule.h:82