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