9 #include <trg/ecl/modules/trgeclUnpacker/trgeclUnpackerModule.h>
11 #include "trg/ecl/TrgEclDataBase.h"
12 #include "trg/ecl/TrgEclMapping.h"
20 string TRGECLUnpackerModule::version()
const
22 return string(
"4.02");
25 TRGECLUnpackerModule::TRGECLUnpackerModule()
29 string desc =
"TRGECLUnpackerModule(" +
version() +
")";
33 B2DEBUG(20,
"trgeclunpacker: Constructor done.");
59 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
61 for (
int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
62 nodeid = ((raw_trgarray[i]->GetNodeID(j)) >> 24) & 0x1F;
63 trgtype = raw_trgarray[i]->GetTRGType(j);
66 for (
int ch = 0; ch < raw_trgarray[i]->GetMaxNumOfCh(j); ch++) {
67 nwords = raw_trgarray[i]->GetDetectorNwords(j, ch);
71 B2ERROR(
"Consistecy error in unpacker.");
72 B2ERROR(
"data length " <<
nwords <<
" nWord " <<
nwords);
83 uint16_t nTCsPerRegion[3] = {};
84 const int firstBarrelId = 81;
85 const int lastBarrelId = 512;
87 const int tcId = trgeclhit.getTCId();
88 if (tcId < firstBarrelId) {
90 }
else if (tcId > lastBarrelId) {
123 int version_check = (rdat[0] >> 12) & 0xf;
124 if (version_check != 15)
return;
127 unsigned char check_sum = (rdat[nnn - 1] >> 24) & 0xFF;
128 unsigned char data_sum = 0;
129 unsigned char kdat[4] = {0};
130 for (
int j = nnn - 2; j > -1; j--) {
131 kdat[0] = rdat[j] & 0xff;
132 kdat[1] = (rdat[j] >> 8) & 0xff;
133 kdat[2] = (rdat[j] >> 16) & 0xff;
134 kdat[3] = (rdat[j] >> 24) & 0xff;
135 for (
int k = 0; k < 4; k++) {
136 data_sum = data_sum + kdat[k];
140 int flag_checksum = 0;
142 if (check_sum == data_sum) {
149 int l1_revo = rdat[0] & 0x7ff;
155 int summary_data = 0;
156 int summary_recon = 0;
158 int summary_revo = 0;
160 bool summary_trg =
false;
173 int win3_revo = -9999;
175 vector<unsigned> sum_data;
176 vector<vector<unsigned>> sum_info;
179 vector<vector<int>> tc_info;
180 vector<vector<int>> tc_info_FE1;
181 vector<vector<int>> tc_info_FE2;
182 vector<vector<int>> tc_info_BE1;
183 vector<vector<int>> tc_info_BE2;
186 while (i < nnn - 2) {
187 summary_data = rdat[i + 1];
188 summary_trg = (summary_data >> 23) & 0x1;
189 summary_revo = (summary_data >> 16) & 0x7f;
190 ntc_win = summary_data & 0x3ff;
196 data_win = window_num;
197 if (window_num == 3) win3_revo = summary_revo;
199 if (summary_trg ==
true) {
200 sum_data.push_back(data_win);
201 sum_data.push_back(summary_revo);
202 for (
int j = 0; j < 12; j++) {
204 (((rdat[i + j + 2] >> 0) & 0xFF) << 24) +
205 (((rdat[i + j + 2] >> 8) & 0xFF) << 16) +
206 (((rdat[i + j + 2] >> 16) & 0xFF) << 8) +
207 (((rdat[i + j + 2] >> 24) & 0xFF) << 0);
208 sum_data.push_back(summary_recon);
210 sum_info.push_back(sum_data);
214 if (tc_trg ==
true) {
215 for (
int j = 0; j < ntc_win; j++) {
216 tc_id = (rdat[i + j] >> 20) & 0x3FF;
217 tc_t = (rdat[i + j] >> 12) & 0x7F;
218 tc_e = rdat[i + j] & 0xFFF;
219 conv_tc_t = (data_win - 3) * 128 + tc_t;
222 tc_data.push_back(tc_id);
223 tc_data.push_back(conv_tc_t);
224 tc_data.push_back(tc_e);
225 tc_data.push_back(data_win);
228 tc_info_FE1.push_back(tc_data);
230 tc_info_FE2.push_back(tc_data);
232 }
else if (tc_id > 512) {
234 tc_info_BE1.push_back(tc_data);
236 tc_info_BE2.push_back(tc_data);
239 tc_info.push_back(tc_data);
247 if (tc_trg ==
true) {
248 for (
int j = 0; j < ntc_win; j++) {
249 tc_id = (rdat[i + j + 2] >> 20) & 0x3FF;
250 tc_t = (rdat[i + j + 2] >> 12) & 0x7F;
251 conv_tc_t = (data_win - 3) * 128 + tc_t;
252 tc_e = rdat[i + j + 2] & 0xFFF;
255 tc_data.push_back(tc_id);
256 tc_data.push_back(conv_tc_t);
257 tc_data.push_back(tc_e);
258 tc_data.push_back(data_win);
261 tc_info_FE1.push_back(tc_data);
263 tc_info_FE2.push_back(tc_data);
265 }
else if (tc_id > 512) {
267 tc_info_BE1.push_back(tc_data);
269 tc_info_BE2.push_back(tc_data);
272 tc_info.push_back(tc_data);
293 int cl_theta[6] = {0};
295 int cl_time[6] = { -9999};
296 int cl_energy[6] = {0};
297 int cl_1gev[6] = {0};
298 int cl_2gev[6] = {0};
324 vector<vector<int>> cl_2d;
326 vector<int> evt_1d_vector;
327 vector<vector<int>> evt_2d_vector;
330 int sum_size = sum_info.size();
332 for (
int j = 0; j < sum_size; j++) {
333 sum_num = sum_info[j][0];
334 sum_revo = sum_info[j][1];
336 time = (sum_info[j][2]) & 0x7F;
337 time_type = (sum_info[j][2] >> 7) & 0x7;
338 physics = (sum_info[j][2] >> 10) & 0x1;
339 b1bhabha = (sum_info[j][2] >> 11) & 0x1;
340 b1_type = (sum_info[j][2] >> 12) & 0x3FFF;
341 etot = ((sum_info[j][3] & 0x7F) << 6) + ((sum_info[j][2] >> 26) & 0x3F);
342 etot_type = (sum_info[j][3] >> 7) & 0x7;
343 icn = (sum_info[j][3] >> 10) & 0x7F;
344 bg_veto = (sum_info[j][3] >> 17) & 0x7;
345 icn_over = (sum_info[j][3] >> 20) & 0x1;
346 b2bhabha_v = (sum_info[j][3] >> 21) & 0x1;
347 low_multi = (((sum_info[j][4] >> 6) & 0x3) << 12) + ((sum_info[j][4] & 0x3) << 10) + ((sum_info[j][3] >> 22) & 0x3FF);
348 b2bhabha_s = (sum_info[j][4] >> 2) & 0x1;
349 mumu = (sum_info[j][4] >> 3) & 0x1;
350 prescale = (sum_info[j][4] >> 4) & 0x1;
351 ecl_bst = (sum_info[j][4] >> 5) & 0x1;
353 cl_energy[0] = (sum_info[j][5]) & 0xFFF;
354 cl_time[0] = (sum_info[j][5] >> 12) & 0xFF;
355 cl_phi[0] = (sum_info[j][5] >> 20) & 0xFF;
356 cl_theta[0] = ((sum_info[j][6] & 0x7) << 4) + ((sum_info[j][5] >> 28) & 0xF);
358 cl_energy[1] = (sum_info[j][6] >> 3) & 0xFFF;
359 cl_time[1] = (sum_info[j][6] >> 15) & 0xFF;
360 cl_phi[1] = (sum_info[j][6] >> 23) & 0xFF;
361 cl_theta[1] = ((sum_info[j][7] & 0x3F) << 1) + ((sum_info[j][6] >> 31) & 0x1);
363 cl_energy[2] = (sum_info[j][7] >> 6) & 0xFFF;
364 cl_time[2] = (sum_info[j][7] >> 18) & 0xFF;
365 cl_phi[2] = ((sum_info[j][8] & 0x3) << 6) + ((sum_info[j][7] >> 26) & 0x3F);
366 cl_theta[2] = (sum_info[j][8] >> 2) & 0x7F;
368 cl_energy[3] = (sum_info[j][8] >> 9) & 0xFFF;
369 cl_time[3] = (sum_info[j][8] >> 21) & 0xFF;
370 cl_phi[3] = ((sum_info[j][9] & 0x1F) << 3) + ((sum_info[j][8] >> 29) & 0x7);
371 cl_theta[3] = (sum_info[j][9] >> 5) & 0x7F;
373 cl_energy[4] = (sum_info[j][ 9] >> 12) & 0xFFF;
374 cl_time[4] = (sum_info[j][ 9] >> 24) & 0xFF;
375 cl_phi[4] = (sum_info[j][10]) & 0xFF;
376 cl_theta[4] = (sum_info[j][10] >> 8) & 0x7F;
378 cl_energy[5] = (sum_info[j][10] >> 15) & 0xFFF;
379 cl_time[5] = ((sum_info[j][11] & 0x7) << 5) + ((sum_info[j][10] >> 27) & 0x1F);
380 cl_phi[5] = (sum_info[j][11] >> 3) & 0xFF;
381 cl_theta[5] = (sum_info[j][11] >> 11) & 0x7F;
383 for (
int k = 0; k < 6; k++) {
384 cl_1gev[k] = (sum_info[j][12] >> k) & 0x1;
385 cl_2gev[k] = (sum_info[j][12] >> (k + 6)) & 0x1;
386 cl_bha[k] = (sum_info[j][12] >> (k + 12)) & 0x1;
388 ncl = (sum_info[j][13]) & 0x7;
420 for (
int k = 0; k < 6; k++) {
421 cl_1d.push_back(cl_theta[k]);
422 cl_1d.push_back(cl_phi[k]);
423 cl_1d.push_back(cl_time[k]);
424 cl_1d.push_back(cl_energy[k]);
425 cl_1d.push_back(cl_1gev[k]);
426 cl_1d.push_back(cl_2gev[k]);
427 cl_1d.push_back(cl_bha[k]);
428 cl_2d.push_back(cl_1d);
431 sort(cl_2d.begin(), cl_2d.end(),
432 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[3] > aa2[3];});
434 if (sum_num == -9999) {
436 }
else if (sum_num <= 3) {
437 sum_num_ord = 2 * abs(sum_num - 3);
439 sum_num_ord = (sum_num * 2) - 7;
441 evt_1d_vector.push_back(sum_num_ord);
442 evt_1d_vector.push_back(sum_revo);
443 evt_1d_vector.push_back(sum_num);
444 evt_1d_vector.push_back(time);
445 for (
int k = 0; k < 6; k++) {
446 for (
int l = 0; l < 7; l++) {
447 evt_1d_vector.push_back(cl_2d[k][l]);
450 evt_1d_vector.push_back(ncl);
451 evt_1d_vector.push_back(low_multi);
452 evt_1d_vector.push_back(b2bhabha_v);
453 evt_1d_vector.push_back(b2bhabha_s);
454 evt_1d_vector.push_back(mumu);
455 evt_1d_vector.push_back(prescale);
456 evt_1d_vector.push_back(icn);
457 evt_1d_vector.push_back(icn_over);
458 evt_1d_vector.push_back(etot_type);
459 evt_1d_vector.push_back(etot);
460 evt_1d_vector.push_back(ecl_bst);
461 evt_1d_vector.push_back(b1_type);
462 evt_1d_vector.push_back(b1bhabha);
463 evt_1d_vector.push_back(physics);
464 evt_1d_vector.push_back(time_type);
465 evt_2d_vector.push_back(evt_1d_vector);
466 evt_1d_vector.clear();
469 for (
int k = 0; k < 6; k++) {
527 tc_info.insert(tc_info.end(), tc_info_FE1.begin(), tc_info_FE1.end());
528 tc_info.insert(tc_info.end(), tc_info_FE2.begin(), tc_info_FE2.end());
529 tc_info.insert(tc_info.end(), tc_info_BE1.begin(), tc_info_BE1.end());
530 tc_info.insert(tc_info.end(), tc_info_BE2.begin(), tc_info_BE2.end());
546 int m_caltime = -9999;
548 int tot_ntc = tc_info.size();
552 int evt_revo = -9999;
556 int evt_timing = -9999;
557 int evt_cl_theta[6] = {0};
558 int evt_cl_phi[6] = {0};
559 int evt_cl_time[6] = { -9999};
560 int evt_cl_energy[6] = {0};
561 int evt_cl_1gev[6] = {0};
562 int evt_cl_2gev[6] = {0};
563 int evt_cl_bha[6] = {0};
567 int evt_low_multi = 0;
569 int evt_b2bhabha_v = 0;
571 int evt_b2bhabha_s = 0;
575 int evt_prescale = 0;
579 int evt_icn_over = 0;
581 int evt_etot_type = 0;
589 int evt_b1bhabha = 0;
593 int evt_time_type = 0;
595 int evt_etot_all = 0;
597 int evt_time_min = 0;
599 int evt_time_max = 0;
601 int evt_time_win = 0;
618 int evt_v_size = evt_2d_vector.size();
619 if (evt_v_size != 0) {
621 sort(evt_2d_vector.begin(), evt_2d_vector.end(),
622 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[0] < aa2[0];});
625 if (tot_ntc != 0 && flag_checksum == 0 && nnn > 7) {
626 if (evt_v_size == 0) {
628 sort(tc_info.begin(), tc_info.end(),
629 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[2] > aa2[2];});
630 evt_revo = win3_revo;
631 evt_win = tc_info[0][3];
632 evt_timing = tc_info[0][1];
633 for (
int k = 0; k < 6; k++) {
637 evt_cl_energy[k] = 0;
658 evt_revo = evt_2d_vector[0][1];
659 evt_win = evt_2d_vector[0][2];
660 evt_timing = evt_2d_vector[0][3];
661 for (
int k = 0; k < 6; k++) {
662 evt_cl_theta[k] = evt_2d_vector[0][ 4 + k * 7];
663 evt_cl_phi[k] = evt_2d_vector[0][ 5 + k * 7];
664 evt_cl_time[k] = evt_2d_vector[0][ 6 + k * 7];
665 evt_cl_energy[k] = evt_2d_vector[0][ 7 + k * 7];
666 evt_cl_1gev[k] = evt_2d_vector[0][ 8 + k * 7];
667 evt_cl_2gev[k] = evt_2d_vector[0][ 9 + k * 7];
668 evt_cl_bha[k] = evt_2d_vector[0][10 + k * 7];
670 evt_ncl = evt_2d_vector[0][46];
671 evt_low_multi = evt_2d_vector[0][47];
672 evt_b2bhabha_v = evt_2d_vector[0][48];
673 evt_b2bhabha_s = evt_2d_vector[0][49];
674 evt_mumu = evt_2d_vector[0][50];
675 evt_prescale = evt_2d_vector[0][51];
676 evt_icn = evt_2d_vector[0][52];
677 evt_icn_over = evt_2d_vector[0][53];
678 evt_etot_type = evt_2d_vector[0][54];
679 evt_etot = evt_2d_vector[0][55];
680 evt_ecl_bst = evt_2d_vector[0][56];
681 evt_b1_type = evt_2d_vector[0][57];
682 evt_b1bhabha = evt_2d_vector[0][58];
683 evt_physics = evt_2d_vector[0][59];
684 evt_time_type = evt_2d_vector[0][60];
687 sort(tc_info.begin(), tc_info.end(),
688 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[0] < aa2[0];});
690 for (
int ii = 0; ii < tot_ntc; ii++) {
691 m_tcid = tc_info[ii][0];
692 m_time = tc_info[ii][1];
693 m_energy = tc_info[ii][2];
694 m_win = tc_info[ii][3];
696 m_caltime = m_time - ((evt_win - 3) * 128 + evt_timing);
708 if (m_win == evt_win || m_win == evt_win + 1) evt_ntc++;
709 if (m_win == evt_win - 1) {
712 if (m_win == evt_win) {
715 if (m_win == evt_win + 1) {
720 if (etot_i == 0 && etot_f == 0) {
721 evt_etot_all = etot_c;
722 evt_time_min = - evt_timing;
723 evt_time_max = 256 - evt_timing;
725 }
else if (etot_i >= etot_f) {
726 evt_etot_all = etot_c + etot_i;
727 evt_time_min = -128 - evt_timing;
728 evt_time_max = 128 - evt_timing;
731 evt_etot_all = etot_c + etot_f;
732 evt_time_min = - evt_timing;
733 evt_time_max = 256 - evt_timing;
737 for (
int icluster = 0; icluster < 6; icluster++) {
738 if (evt_cl_energy[icluster] == 0 || evt_cl_theta[icluster] == 0 || evt_cl_phi[icluster] == 0) {
continue;}
740 if (cl_tcid == 0) {
continue;}
819 for (
int k = 0; k < 6; k++) {
822 evt_cl_time[k] = -9999;
823 evt_cl_energy[k] = 0;
865 int version_check = (rdat[0] >> 12) & 0xf;
866 if (version_check != 15)
return;
869 unsigned char check_sum = (rdat[nnn - 1] >> 24) & 0xFF;
870 unsigned char data_sum = 0;
871 unsigned char kdat[4] = {0};
872 for (
int j = nnn - 2; j > -1; j--) {
873 kdat[0] = rdat[j] & 0xff;
874 kdat[1] = (rdat[j] >> 8) & 0xff;
875 kdat[2] = (rdat[j] >> 16) & 0xff;
876 kdat[3] = (rdat[j] >> 24) & 0xff;
877 for (
int k = 0; k < 4; k++) {
878 data_sum = data_sum + kdat[k];
882 int flag_checksum = 0;
884 if (check_sum == data_sum) {
891 int l1_revo = rdat[0] & 0x7ff;
897 int summary_data = 0;
899 int summary_revo = 0;
901 bool summary_trg =
false;
914 int win3_revo = -9999;
916 vector<unsigned> sum_data;
917 vector<vector<unsigned>> sum_info;
920 vector<vector<int>> tc_info;
921 vector<vector<int>> tc_info_FE1;
922 vector<vector<int>> tc_info_FE2;
923 vector<vector<int>> tc_info_BE1;
924 vector<vector<int>> tc_info_BE2;
927 while (i < nnn - 2) {
928 summary_data = rdat[i + 1];
929 summary_trg = (summary_data >> 23) & 0x1;
930 summary_revo = (summary_data >> 16) & 0x7f;
931 ntc_win = summary_data & 0x3ff;
937 data_win = window_num;
938 if (window_num == 3) win3_revo = summary_revo;
940 if (summary_trg ==
true) {
941 sum_data.push_back(data_win);
942 sum_data.push_back(summary_revo);
943 for (
int j = 0; j < 9; j++) {
944 sum_data.push_back(rdat[i + j + 2]);
946 sum_info.push_back(sum_data);
950 if (tc_trg ==
true) {
951 for (
int j = 0; j < ntc_win; j++) {
952 tc_id = (rdat[i + j] >> 20) & 0x3FF;
953 tc_t = (rdat[i + j] >> 12) & 0x7F;
954 tc_e = rdat[i + j] & 0xFFF;
955 conv_tc_t = (data_win - 3) * 128 + tc_t;
958 tc_data.push_back(tc_id);
959 tc_data.push_back(conv_tc_t);
960 tc_data.push_back(tc_e);
961 tc_data.push_back(data_win);
964 tc_info_FE1.push_back(tc_data);
966 tc_info_FE2.push_back(tc_data);
968 }
else if (tc_id > 512) {
970 tc_info_BE1.push_back(tc_data);
972 tc_info_BE2.push_back(tc_data);
975 tc_info.push_back(tc_data);
983 if (tc_trg ==
true) {
984 for (
int j = 0; j < ntc_win; j++) {
985 tc_id = (rdat[i + j + 2] >> 20) & 0x3FF;
986 tc_t = (rdat[i + j + 2] >> 12) & 0x7F;
987 conv_tc_t = (data_win - 3) * 128 + tc_t;
988 tc_e = rdat[i + j + 2] & 0xFFF;
991 tc_data.push_back(tc_id);
992 tc_data.push_back(conv_tc_t);
993 tc_data.push_back(tc_e);
994 tc_data.push_back(data_win);
997 tc_info_FE1.push_back(tc_data);
999 tc_info_FE2.push_back(tc_data);
1001 }
else if (tc_id > 512) {
1003 tc_info_BE1.push_back(tc_data);
1005 tc_info_BE2.push_back(tc_data);
1008 tc_info.push_back(tc_data);
1012 i = i + ntc_win + 1;
1027 int cl_theta[6] = {0};
1028 int cl_phi[6] = {0};
1029 int cl_time[6] = { -9999};
1030 int cl_energy[6] = {0};
1055 vector<vector<int>> cl_2d;
1057 vector<int> evt_1d_vector;
1058 vector<vector<int>> evt_2d_vector;
1061 int sum_size = sum_info.size();
1062 if (sum_size != 0) {
1063 for (
int j = 0; j < sum_size; j++) {
1064 sum_num = sum_info[j][0];
1065 sum_revo = sum_info[j][1];
1067 ecl_bst = (sum_info[j][2] >> 26) & 0x1;
1070 cl_theta[5] = (sum_info[j][2] >> 19) & 0x7f;
1071 cl_phi[5] = (sum_info[j][2] >> 11) & 0xff;
1072 cl_time[5] = (sum_info[j][2] >> 3) & 0xff;
1073 cl_energy[5] = ((sum_info[j][2] & 0x7) << 9) + ((sum_info[j][3] >> 23) & 0x1ff);
1075 cl_theta[4] = (sum_info[j][3] >> 16) & 0x7f;
1076 cl_phi[4] = (sum_info[j][3] >> 8) & 0xff;
1077 cl_time[4] = (sum_info[j][3]) & 0xff;
1078 cl_energy[4] = (sum_info[j][4] >> 20) & 0xfff;
1080 cl_theta[3] = (sum_info[j][4] >> 13) & 0x7f;
1081 cl_phi[3] = (sum_info[j][4] >> 5) & 0xff;
1082 cl_time[3] = ((sum_info[j][4] & 0x1f) << 3) + ((sum_info[j][5] >> 29) & 0x7);
1083 cl_energy[3] = (sum_info[j][5] >> 17) & 0xfff;
1085 cl_theta[2] = (sum_info[j][5] >> 10) & 0x7f;
1086 cl_phi[2] = (sum_info[j][5] >> 2) & 0xff;
1087 cl_time[2] = ((sum_info[j][5] & 0x3) << 6) + ((sum_info[j][6] >> 26) & 0x3f);
1088 cl_energy[2] = (sum_info[j][6] >> 14) & 0xfff;
1090 cl_theta[1] = (sum_info[j][6] >> 7) & 0x7f;
1091 cl_phi[1] = ((sum_info[j][6] & 0x7f) << 1) + ((sum_info[j][7] >> 31) & 0x1);
1092 cl_time[1] = (sum_info[j][7] >> 23) & 0xff;
1093 cl_energy[1] = (sum_info[j][7] >> 11) & 0xfff;
1095 cl_theta[0] = (sum_info[j][7] >> 4) & 0x7f;
1096 cl_phi[0] = ((sum_info[j][7] & 0xf) << 4) + ((sum_info[j][8] >> 28) & 0xf);
1097 cl_time[0] = (sum_info[j][8] >> 20) & 0xff;
1098 cl_energy[0] = (sum_info[j][8] >> 8) & 0xfff;
1100 ncl = (sum_info[j][8] >> 5) & 0x7;
1102 prescale = (sum_info[j][8] >> 4) & 0x1;
1103 mumu = (sum_info[j][8] >> 3) & 0x1;
1104 b2bhabha_s = (sum_info[j][8] >> 2) & 0x1;
1106 low_multi = (((sum_info[j][2] >> 27) & 0x3) << 12) + ((sum_info[j][8] & 0x3) << 10) + ((sum_info[j][9] >> 22) & 0x3ff);
1108 low_multi = ((sum_info[j][8] & 0x3) << 10) + ((sum_info[j][9] >> 22) & 0x3ff);
1110 b2bhabha_v = (sum_info[j][9] >> 21) & 0x1;
1111 icn_over = (sum_info[j][9] >> 20) & 0x1;
1112 bg_veto = (sum_info[j][9] >> 17) & 0x7;
1113 icn = (sum_info[j][9] >> 10) & 0x7f;
1114 etot_type = (sum_info[j][9] >> 7) & 0x7;
1115 etot = ((sum_info[j][9] & 0x7f) << 6) + ((sum_info[j][10] >> 26) & 0x3f);
1116 b1_type = (sum_info[j][10] >> 12) & 0x3fff;
1117 b1bhabha = (sum_info[j][10] >> 11) & 0x1;
1118 physics = (sum_info[j][10] >> 10) & 0x1;
1119 time_type = (sum_info[j][10] >> 7) & 0x7;
1120 time = (sum_info[j][10]) & 0x7f;
1122 cl_theta[5] = (sum_info[j][2] >> 24) & 0x7f;
1123 cl_phi[5] = (sum_info[j][2] >> 16) & 0xff;
1124 cl_time[5] = (sum_info[j][2] >> 8) & 0xff;
1125 cl_energy[5] = ((sum_info[j][2] & 0xff) << 4) + ((sum_info[j][3] >> 28) & 0xf);
1127 cl_theta[4] = (sum_info[j][3] >> 21) & 0x7f;
1128 cl_phi[4] = (sum_info[j][3] >> 13) & 0xff;
1129 cl_time[4] = (sum_info[j][3] >> 5) & 0xff;
1130 cl_energy[4] = ((sum_info[j][3] & 0x1f) << 7) + ((sum_info[j][4] >> 25) & 0x7f);
1132 cl_theta[3] = (sum_info[j][4] >> 18) & 0x7f;
1133 cl_phi[3] = (sum_info[j][4] >> 10) & 0xff;
1134 cl_time[3] = (sum_info[j][4] >> 2) & 0xff;
1135 cl_energy[3] = ((sum_info[j][4] & 0x3) << 10) + ((sum_info[j][5] >> 22) & 0x3ff);
1137 cl_theta[2] = (sum_info[j][5] >> 15) & 0x7f;
1138 cl_phi[2] = (sum_info[j][5] >> 7) & 0xff;
1139 cl_time[2] = ((sum_info[j][5] & 0x7f) << 1) + ((sum_info[j][6] >> 31) & 0x1);
1140 cl_energy[2] = (sum_info[j][6] >> 19) & 0xfff;
1142 cl_theta[1] = (sum_info[j][6] >> 12) & 0x7f;
1143 cl_phi[1] = (sum_info[j][6] >> 4) & 0xff;
1144 cl_time[1] = ((sum_info[j][6] & 0xf) << 4) + ((sum_info[j][7] >> 28) & 0xf);
1145 cl_energy[1] = (sum_info[j][7] >> 16) & 0xfff;
1147 cl_theta[0] = (sum_info[j][7] >> 9) & 0x7f;
1148 cl_phi[0] = (sum_info[j][7] >> 1) & 0xff;
1149 cl_time[0] = ((sum_info[j][7] & 0x1) << 7) + ((sum_info[j][8] >> 25) & 0x7f);
1150 cl_energy[0] = (sum_info[j][8] >> 13) & 0xfff;
1152 ncl = (sum_info[j][8] >> 10) & 0x7;
1154 low_multi = ((sum_info[j][8] & 0x3ff) << 2) + ((sum_info[j][9] >> 30) & 0x3);
1155 b2bhabha_v = (sum_info[j][9] >> 29) & 0x1;
1156 icn_over = (sum_info[j][9] >> 28) & 0x1;
1157 bg_veto = (sum_info[j][9] >> 25) & 0x7;
1158 icn = (sum_info[j][9] >> 18) & 0x7f;
1159 etot_type = (sum_info[j][9] >> 15) & 0x7;
1160 etot = (sum_info[j][9] >> 2) & 0x1fff;
1162 b1_type = ((sum_info[j][9] & 0x3) << 12) + ((sum_info[j][10] >> 20) & 0xfff);
1163 b1bhabha = (sum_info[j][10] >> 19) & 0x1;
1164 physics = (sum_info[j][10] >> 18) & 0x1;
1165 time_type = (sum_info[j][10] >> 15) & 0x7;
1166 time = (sum_info[j][10] >> 8) & 0x7f;
1200 for (
int k = 0; k < 6; k++) {
1201 cl_1d.push_back(cl_theta[k]);
1202 cl_1d.push_back(cl_phi[k]);
1203 cl_1d.push_back(cl_time[k]);
1204 cl_1d.push_back(cl_energy[k]);
1205 cl_2d.push_back(cl_1d);
1208 sort(cl_2d.begin(), cl_2d.end(),
1209 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[3] > aa2[3];});
1211 evt_1d_vector.push_back(abs(sum_num - 3));
1212 evt_1d_vector.push_back(sum_revo);
1213 evt_1d_vector.push_back(sum_num);
1214 evt_1d_vector.push_back(time);
1215 for (
int k = 0; k < 6; k++) {
1216 evt_1d_vector.push_back(cl_2d[k][0]);
1217 evt_1d_vector.push_back(cl_2d[k][1]);
1218 evt_1d_vector.push_back(cl_2d[k][2]);
1219 evt_1d_vector.push_back(cl_2d[k][3]);
1221 evt_1d_vector.push_back(ncl);
1222 evt_1d_vector.push_back(low_multi);
1223 evt_1d_vector.push_back(b2bhabha_v);
1224 evt_1d_vector.push_back(b2bhabha_s);
1225 evt_1d_vector.push_back(mumu);
1226 evt_1d_vector.push_back(prescale);
1227 evt_1d_vector.push_back(icn);
1228 evt_1d_vector.push_back(icn_over);
1229 evt_1d_vector.push_back(etot_type);
1230 evt_1d_vector.push_back(etot);
1231 evt_1d_vector.push_back(ecl_bst);
1232 evt_1d_vector.push_back(b1_type);
1233 evt_1d_vector.push_back(b1bhabha);
1234 evt_1d_vector.push_back(physics);
1235 evt_1d_vector.push_back(time_type);
1236 evt_2d_vector.push_back(evt_1d_vector);
1237 evt_1d_vector.clear();
1241 for (
int k = 0; k < 6; k++) {
1293 tc_info.insert(tc_info.end(), tc_info_FE1.begin(), tc_info_FE1.end());
1294 tc_info.insert(tc_info.end(), tc_info_FE2.begin(), tc_info_FE2.end());
1295 tc_info.insert(tc_info.end(), tc_info_BE1.begin(), tc_info_BE1.end());
1296 tc_info.insert(tc_info.end(), tc_info_BE2.begin(), tc_info_BE2.end());
1312 int m_caltime = -9999;
1314 int tot_ntc = tc_info.size();
1318 int evt_revo = -9999;
1322 int evt_timing = -9999;
1323 int evt_cl_theta[6] = {0};
1324 int evt_cl_phi[6] = {0};
1325 int evt_cl_time[6] = { -9999};
1326 int evt_cl_energy[6] = {0};
1330 int evt_low_multi = 0;
1332 int evt_b2bhabha_v = 0;
1334 int evt_b2bhabha_s = 0;
1338 int evt_prescale = 0;
1342 int evt_icn_over = 0;
1344 int evt_etot_type = 0;
1348 int evt_ecl_bst = 0;
1350 int evt_b1_type = 0;
1352 int evt_b1bhabha = 0;
1354 int evt_physics = 0;
1356 int evt_time_type = 0;
1358 int evt_etot_all = 0;
1360 int evt_time_min = 0;
1362 int evt_time_max = 0;
1364 int evt_time_win = 0;
1381 int evt_v_size = evt_2d_vector.size();
1382 if (evt_v_size != 0) {
1384 sort(evt_2d_vector.begin(), evt_2d_vector.end(),
1385 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[0] < aa2[0];});
1388 if (tot_ntc != 0 && flag_checksum == 0 && nnn > 7) {
1389 if (evt_v_size == 0) {
1391 sort(tc_info.begin(), tc_info.end(),
1392 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[2] > aa2[2];});
1393 evt_revo = win3_revo;
1394 evt_win = tc_info[0][3];
1395 evt_timing = tc_info[0][1];
1396 for (
int k = 0; k < 6; k++) {
1397 evt_cl_theta[k] = 0;
1400 evt_cl_energy[k] = 0;
1418 evt_revo = evt_2d_vector[0][1];
1419 evt_win = evt_2d_vector[0][2];
1420 evt_timing = evt_2d_vector[0][3];
1421 for (
int k = 0; k < 6; k++) {
1422 evt_cl_theta[k] = evt_2d_vector[0][4 + k * 4];
1423 evt_cl_phi[k] = evt_2d_vector[0][5 + k * 4];
1424 evt_cl_time[k] = evt_2d_vector[0][6 + k * 4];
1425 evt_cl_energy[k] = evt_2d_vector[0][7 + k * 4];
1427 evt_ncl = evt_2d_vector[0][28];
1428 evt_low_multi = evt_2d_vector[0][29];
1429 evt_b2bhabha_v = evt_2d_vector[0][30];
1430 evt_b2bhabha_s = evt_2d_vector[0][31];
1431 evt_mumu = evt_2d_vector[0][32];
1432 evt_prescale = evt_2d_vector[0][33];
1433 evt_icn = evt_2d_vector[0][34];
1434 evt_icn_over = evt_2d_vector[0][35];
1435 evt_etot_type = evt_2d_vector[0][36];
1436 evt_etot = evt_2d_vector[0][37];
1437 evt_ecl_bst = evt_2d_vector[0][38];
1438 evt_b1_type = evt_2d_vector[0][39];
1439 evt_b1bhabha = evt_2d_vector[0][40];
1440 evt_physics = evt_2d_vector[0][41];
1441 evt_time_type = evt_2d_vector[0][42];
1444 sort(tc_info.begin(), tc_info.end(),
1445 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[0] < aa2[0];});
1447 for (
int ii = 0; ii < tot_ntc; ii++) {
1448 m_tcid = tc_info[ii][0];
1449 m_time = tc_info[ii][1];
1450 m_energy = tc_info[ii][2];
1451 m_win = tc_info[ii][3];
1453 m_caltime = m_time - ((evt_win - 3) * 128 + evt_timing);
1465 if (m_win == evt_win || m_win == evt_win + 1) evt_ntc++;
1466 if (m_win == evt_win - 1) {
1469 if (m_win == evt_win) {
1472 if (m_win == evt_win + 1) {
1477 if (etot_i == 0 && etot_f == 0) {
1478 evt_etot_all = etot_c;
1479 evt_time_min = - evt_timing;
1480 evt_time_max = 256 - evt_timing;
1482 }
else if (etot_i >= etot_f) {
1483 evt_etot_all = etot_c + etot_i;
1484 evt_time_min = -128 - evt_timing;
1485 evt_time_max = 128 - evt_timing;
1488 evt_etot_all = etot_c + etot_f;
1489 evt_time_min = - evt_timing;
1490 evt_time_max = 256 - evt_timing;
1494 for (
int icluster = 0; icluster < 6; icluster++) {
1495 if (evt_cl_energy[icluster] == 0 || evt_cl_theta[icluster] == 0 || evt_cl_phi[icluster] == 0) {
continue;}
1497 if (cl_tcid == 0) {
continue;}
1573 for (
int k = 0; k < 6; k++) {
1574 evt_cl_theta[k] = 0;
1576 evt_cl_time[k] = -9999;
1577 evt_cl_energy[k] = 0;
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
The Raw TOP class Class for RawCOPPER class data taken by TOP Currently, this class is almost same as...
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
virtual ~TRGECLUnpackerModule()
Destructor.
int etm_version
ETM Version.
void initialize() override
Initilizes TRGECLUnpackerModuel.
void event() override
Called event by event.
virtual void readCOPPEREvent(RawTRG *, int, int, int)
Read data from TRG copper.
unsigned int nodeid
Node Id.
void endRun() override
Called when run ended.
StoreArray< TRGECLUnpackerSumStore > m_TRGECLSumArray
ECL Trigger Unpacker Summary output.
void terminate() override
Called when processing ended.
int n_basf2evt
Event number.
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.
StoreObjPtr< EventLevelClusteringInfo > m_eventLevelClusteringInfo
EventLevelClusteringInfo.
virtual void checkBuffer(int *, int)
Unpacker main function.
StoreArray< TRGECLCluster > m_TRGECLClusterArray
ECL Trigger Cluster output.
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.
int GetDetectorNwords(int n, int finesse_num)
get Detector buffer length
int * GetDetectorBuffer(int n, int finesse_num)
get Detector buffer
Abstract base class for different kinds of events.