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