9#include <trg/ecl/modules/trgeclUnpacker/trgeclUnpackerModule.h>
11#include "trg/ecl/TrgEclDataBase.h"
12#include "trg/ecl/TrgEclMapping.h"
22 return string(
"4.02");
29 string desc =
"TRGECLUnpackerModule(" +
version() +
")";
33 B2DEBUG(20,
"trgeclunpacker: Constructor done.");
61 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
63 for (
int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
64 nodeid = ((raw_trgarray[i]->GetNodeID(j)) >> 24) & 0x1F;
65 trgtype = raw_trgarray[i]->GetTRGType(j);
68 for (
int ch = 0; ch < raw_trgarray[i]->GetMaxNumOfCh(j); ch++) {
69 nwords = raw_trgarray[i]->GetDetectorNwords(j, ch);
73 B2ERROR(
"Consistecy error in unpacker.");
74 B2ERROR(
"data length " <<
nwords <<
" nWord " <<
nwords);
85 uint16_t nTCsPerRegion[3] = {};
86 const int firstBarrelId = 81;
87 const int lastBarrelId = 512;
89 const int tcId = trgeclhit.getTCId();
90 if (tcId < firstBarrelId) {
92 }
else if (tcId > lastBarrelId) {
125 int version_check = (rdat[0] >> 12) & 0xf;
126 if (version_check != 15)
return;
129 unsigned char check_sum = (rdat[nnn - 1] >> 24) & 0xFF;
130 unsigned char data_sum = 0;
131 unsigned char kdat[4] = {0};
132 for (
int j = nnn - 2; j > -1; j--) {
133 kdat[0] = rdat[j] & 0xff;
134 kdat[1] = (rdat[j] >> 8) & 0xff;
135 kdat[2] = (rdat[j] >> 16) & 0xff;
136 kdat[3] = (rdat[j] >> 24) & 0xff;
137 for (
int k = 0; k < 4; k++) {
138 data_sum = data_sum + kdat[k];
142 int flag_checksum = 0;
144 if (check_sum == data_sum) {
151 int l1_revo = rdat[0] & 0x7ff;
157 int summary_data = 0;
158 int summary_recon = 0;
160 int summary_revo = 0;
162 bool summary_trg =
false;
175 int win3_revo = -9999;
177 vector<unsigned> sum_data;
178 vector<vector<unsigned>> sum_info;
181 vector<vector<int>> tc_info;
182 vector<vector<int>> tc_info_FE1;
183 vector<vector<int>> tc_info_FE2;
184 vector<vector<int>> tc_info_BE1;
185 vector<vector<int>> tc_info_BE2;
188 while (i < nnn - 2) {
189 summary_data = rdat[i + 1];
190 summary_trg = (summary_data >> 23) & 0x1;
191 summary_revo = (summary_data >> 16) & 0x7f;
192 ntc_win = summary_data & 0x3ff;
198 data_win = window_num;
199 if (window_num == 3) win3_revo = summary_revo;
201 if (summary_trg ==
true) {
202 sum_data.push_back(data_win);
203 sum_data.push_back(summary_revo);
204 for (
int j = 0; j < 12; j++) {
206 (((rdat[i + j + 2] >> 0) & 0xFF) << 24) +
207 (((rdat[i + j + 2] >> 8) & 0xFF) << 16) +
208 (((rdat[i + j + 2] >> 16) & 0xFF) << 8) +
209 (((rdat[i + j + 2] >> 24) & 0xFF) << 0);
210 sum_data.push_back(summary_recon);
212 sum_info.push_back(sum_data);
216 if (tc_trg ==
true) {
217 for (
int j = 0; j < ntc_win; j++) {
218 tc_id = (rdat[i + j] >> 20) & 0x3FF;
219 tc_t = (rdat[i + j] >> 12) & 0x7F;
220 tc_e = rdat[i + j] & 0xFFF;
221 conv_tc_t = (data_win - 3) * 128 + tc_t;
224 tc_data.push_back(tc_id);
225 tc_data.push_back(conv_tc_t);
226 tc_data.push_back(tc_e);
227 tc_data.push_back(data_win);
230 tc_info_FE1.push_back(tc_data);
232 tc_info_FE2.push_back(tc_data);
234 }
else if (tc_id > 512) {
236 tc_info_BE1.push_back(tc_data);
238 tc_info_BE2.push_back(tc_data);
241 tc_info.push_back(tc_data);
249 if (tc_trg ==
true) {
250 for (
int j = 0; j < ntc_win; j++) {
251 tc_id = (rdat[i + j + 2] >> 20) & 0x3FF;
252 tc_t = (rdat[i + j + 2] >> 12) & 0x7F;
253 conv_tc_t = (data_win - 3) * 128 + tc_t;
254 tc_e = rdat[i + j + 2] & 0xFFF;
257 tc_data.push_back(tc_id);
258 tc_data.push_back(conv_tc_t);
259 tc_data.push_back(tc_e);
260 tc_data.push_back(data_win);
263 tc_info_FE1.push_back(tc_data);
265 tc_info_FE2.push_back(tc_data);
267 }
else if (tc_id > 512) {
269 tc_info_BE1.push_back(tc_data);
271 tc_info_BE2.push_back(tc_data);
274 tc_info.push_back(tc_data);
295 int cl_theta[6] = {0};
297 int cl_time[6] = { -9999};
298 int cl_energy[6] = {0};
299 int cl_1gev[6] = {0};
300 int cl_2gev[6] = {0};
326 vector<vector<int>> cl_2d;
328 vector<int> evt_1d_vector;
329 vector<vector<int>> evt_2d_vector;
332 int sum_size = sum_info.size();
334 for (
int j = 0; j < sum_size; j++) {
335 sum_num = sum_info[j][0];
336 sum_revo = sum_info[j][1];
338 time = (sum_info[j][2]) & 0x7F;
339 time_type = (sum_info[j][2] >> 7) & 0x7;
340 physics = (sum_info[j][2] >> 10) & 0x1;
341 b1bhabha = (sum_info[j][2] >> 11) & 0x1;
342 b1_type = (sum_info[j][2] >> 12) & 0x3FFF;
343 etot = ((sum_info[j][3] & 0x7F) << 6) + ((sum_info[j][2] >> 26) & 0x3F);
344 etot_type = (sum_info[j][3] >> 7) & 0x7;
345 icn = (sum_info[j][3] >> 10) & 0x7F;
346 bg_veto = (sum_info[j][3] >> 17) & 0x7;
347 icn_over = (sum_info[j][3] >> 20) & 0x1;
348 b2bhabha_v = (sum_info[j][3] >> 21) & 0x1;
349 low_multi = (((sum_info[j][4] >> 6) & 0x3) << 12) + ((sum_info[j][4] & 0x3) << 10) + ((sum_info[j][3] >> 22) & 0x3FF);
350 b2bhabha_s = (sum_info[j][4] >> 2) & 0x1;
351 mumu = (sum_info[j][4] >> 3) & 0x1;
352 prescale = (sum_info[j][4] >> 4) & 0x1;
353 ecl_bst = (sum_info[j][4] >> 5) & 0x1;
355 cl_energy[0] = (sum_info[j][5]) & 0xFFF;
356 cl_time[0] = (sum_info[j][5] >> 12) & 0xFF;
357 cl_phi[0] = (sum_info[j][5] >> 20) & 0xFF;
358 cl_theta[0] = ((sum_info[j][6] & 0x7) << 4) + ((sum_info[j][5] >> 28) & 0xF);
360 cl_energy[1] = (sum_info[j][6] >> 3) & 0xFFF;
361 cl_time[1] = (sum_info[j][6] >> 15) & 0xFF;
362 cl_phi[1] = (sum_info[j][6] >> 23) & 0xFF;
363 cl_theta[1] = ((sum_info[j][7] & 0x3F) << 1) + ((sum_info[j][6] >> 31) & 0x1);
365 cl_energy[2] = (sum_info[j][7] >> 6) & 0xFFF;
366 cl_time[2] = (sum_info[j][7] >> 18) & 0xFF;
367 cl_phi[2] = ((sum_info[j][8] & 0x3) << 6) + ((sum_info[j][7] >> 26) & 0x3F);
368 cl_theta[2] = (sum_info[j][8] >> 2) & 0x7F;
370 cl_energy[3] = (sum_info[j][8] >> 9) & 0xFFF;
371 cl_time[3] = (sum_info[j][8] >> 21) & 0xFF;
372 cl_phi[3] = ((sum_info[j][9] & 0x1F) << 3) + ((sum_info[j][8] >> 29) & 0x7);
373 cl_theta[3] = (sum_info[j][9] >> 5) & 0x7F;
375 cl_energy[4] = (sum_info[j][ 9] >> 12) & 0xFFF;
376 cl_time[4] = (sum_info[j][ 9] >> 24) & 0xFF;
377 cl_phi[4] = (sum_info[j][10]) & 0xFF;
378 cl_theta[4] = (sum_info[j][10] >> 8) & 0x7F;
380 cl_energy[5] = (sum_info[j][10] >> 15) & 0xFFF;
381 cl_time[5] = ((sum_info[j][11] & 0x7) << 5) + ((sum_info[j][10] >> 27) & 0x1F);
382 cl_phi[5] = (sum_info[j][11] >> 3) & 0xFF;
383 cl_theta[5] = (sum_info[j][11] >> 11) & 0x7F;
385 for (
int k = 0; k < 6; k++) {
386 cl_1gev[k] = (sum_info[j][12] >> k) & 0x1;
387 cl_2gev[k] = (sum_info[j][12] >> (k + 6)) & 0x1;
388 cl_bha[k] = (sum_info[j][12] >> (k + 12)) & 0x1;
390 ncl = (sum_info[j][13]) & 0x7;
422 for (
int k = 0; k < 6; k++) {
423 cl_1d.push_back(cl_theta[k]);
424 cl_1d.push_back(cl_phi[k]);
425 cl_1d.push_back(cl_time[k]);
426 cl_1d.push_back(cl_energy[k]);
427 cl_1d.push_back(cl_1gev[k]);
428 cl_1d.push_back(cl_2gev[k]);
429 cl_1d.push_back(cl_bha[k]);
430 cl_2d.push_back(cl_1d);
433 sort(cl_2d.begin(), cl_2d.end(),
434 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[3] > aa2[3];});
436 if (sum_num == -9999) {
438 }
else if (sum_num <= 3) {
439 sum_num_ord = 2 * abs(sum_num - 3);
441 sum_num_ord = (sum_num * 2) - 7;
443 evt_1d_vector.push_back(sum_num_ord);
444 evt_1d_vector.push_back(sum_revo);
445 evt_1d_vector.push_back(sum_num);
446 evt_1d_vector.push_back(time);
447 for (
int k = 0; k < 6; k++) {
448 for (
int l = 0; l < 7; l++) {
449 evt_1d_vector.push_back(cl_2d[k][l]);
452 evt_1d_vector.push_back(ncl);
453 evt_1d_vector.push_back(low_multi);
454 evt_1d_vector.push_back(b2bhabha_v);
455 evt_1d_vector.push_back(b2bhabha_s);
456 evt_1d_vector.push_back(mumu);
457 evt_1d_vector.push_back(prescale);
458 evt_1d_vector.push_back(icn);
459 evt_1d_vector.push_back(icn_over);
460 evt_1d_vector.push_back(etot_type);
461 evt_1d_vector.push_back(etot);
462 evt_1d_vector.push_back(ecl_bst);
463 evt_1d_vector.push_back(b1_type);
464 evt_1d_vector.push_back(b1bhabha);
465 evt_1d_vector.push_back(physics);
466 evt_1d_vector.push_back(time_type);
467 evt_2d_vector.push_back(evt_1d_vector);
468 evt_1d_vector.clear();
471 for (
int k = 0; k < 6; k++) {
529 tc_info.insert(tc_info.end(), tc_info_FE1.begin(), tc_info_FE1.end());
530 tc_info.insert(tc_info.end(), tc_info_FE2.begin(), tc_info_FE2.end());
531 tc_info.insert(tc_info.end(), tc_info_BE1.begin(), tc_info_BE1.end());
532 tc_info.insert(tc_info.end(), tc_info_BE2.begin(), tc_info_BE2.end());
548 int m_caltime = -9999;
550 int tot_ntc = tc_info.size();
554 int evt_revo = -9999;
558 int evt_timing = -9999;
559 int evt_cl_theta[6] = {0};
560 int evt_cl_phi[6] = {0};
561 int evt_cl_time[6] = { -9999};
562 int evt_cl_energy[6] = {0};
563 int evt_cl_1gev[6] = {0};
564 int evt_cl_2gev[6] = {0};
565 int evt_cl_bha[6] = {0};
569 int evt_low_multi = 0;
571 int evt_b2bhabha_v = 0;
573 int evt_b2bhabha_s = 0;
577 int evt_prescale = 0;
581 int evt_icn_over = 0;
583 int evt_etot_type = 0;
591 int evt_b1bhabha = 0;
595 int evt_time_type = 0;
597 int evt_etot_all = 0;
599 int evt_time_min = 0;
601 int evt_time_max = 0;
603 int evt_time_win = 0;
620 int evt_v_size = evt_2d_vector.size();
621 if (evt_v_size != 0) {
623 sort(evt_2d_vector.begin(), evt_2d_vector.end(),
624 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[0] < aa2[0];});
627 if (tot_ntc != 0 && flag_checksum == 0 && nnn > 7) {
628 if (evt_v_size == 0) {
630 sort(tc_info.begin(), tc_info.end(),
631 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[2] > aa2[2];});
632 evt_revo = win3_revo;
633 evt_win = tc_info[0][3];
634 evt_timing = tc_info[0][1];
635 for (
int k = 0; k < 6; k++) {
639 evt_cl_energy[k] = 0;
660 evt_revo = evt_2d_vector[0][1];
661 evt_win = evt_2d_vector[0][2];
662 evt_timing = evt_2d_vector[0][3];
663 for (
int k = 0; k < 6; k++) {
664 evt_cl_theta[k] = evt_2d_vector[0][ 4 + k * 7];
665 evt_cl_phi[k] = evt_2d_vector[0][ 5 + k * 7];
666 evt_cl_time[k] = evt_2d_vector[0][ 6 + k * 7];
667 evt_cl_energy[k] = evt_2d_vector[0][ 7 + k * 7];
668 evt_cl_1gev[k] = evt_2d_vector[0][ 8 + k * 7];
669 evt_cl_2gev[k] = evt_2d_vector[0][ 9 + k * 7];
670 evt_cl_bha[k] = evt_2d_vector[0][10 + k * 7];
672 evt_ncl = evt_2d_vector[0][46];
673 evt_low_multi = evt_2d_vector[0][47];
674 evt_b2bhabha_v = evt_2d_vector[0][48];
675 evt_b2bhabha_s = evt_2d_vector[0][49];
676 evt_mumu = evt_2d_vector[0][50];
677 evt_prescale = evt_2d_vector[0][51];
678 evt_icn = evt_2d_vector[0][52];
679 evt_icn_over = evt_2d_vector[0][53];
680 evt_etot_type = evt_2d_vector[0][54];
681 evt_etot = evt_2d_vector[0][55];
682 evt_ecl_bst = evt_2d_vector[0][56];
683 evt_b1_type = evt_2d_vector[0][57];
684 evt_b1bhabha = evt_2d_vector[0][58];
685 evt_physics = evt_2d_vector[0][59];
686 evt_time_type = evt_2d_vector[0][60];
689 sort(tc_info.begin(), tc_info.end(),
690 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[0] < aa2[0];});
692 for (
int ii = 0; ii < tot_ntc; ii++) {
693 m_tcid = tc_info[ii][0];
694 m_time = tc_info[ii][1];
695 m_energy = tc_info[ii][2];
696 m_win = tc_info[ii][3];
698 m_caltime = m_time - ((evt_win - 3) * 128 + evt_timing);
710 if (m_win == evt_win || m_win == evt_win + 1) evt_ntc++;
711 if (m_win == evt_win - 1) {
714 if (m_win == evt_win) {
717 if (m_win == evt_win + 1) {
722 if (etot_i == 0 && etot_f == 0) {
723 evt_etot_all = etot_c;
724 evt_time_min = - evt_timing;
725 evt_time_max = 256 - evt_timing;
727 }
else if (etot_i >= etot_f) {
728 evt_etot_all = etot_c + etot_i;
729 evt_time_min = -128 - evt_timing;
730 evt_time_max = 128 - evt_timing;
733 evt_etot_all = etot_c + etot_f;
734 evt_time_min = - evt_timing;
735 evt_time_max = 256 - evt_timing;
739 for (
int icluster = 0; icluster < 6; icluster++) {
740 if (evt_cl_energy[icluster] == 0 || evt_cl_theta[icluster] == 0 || evt_cl_phi[icluster] == 0) {
continue;}
742 if (cl_tcid == 0) {
continue;}
821 for (
int k = 0; k < 6; k++) {
824 evt_cl_time[k] = -9999;
825 evt_cl_energy[k] = 0;
867 int version_check = (rdat[0] >> 12) & 0xf;
868 if (version_check != 15)
return;
871 unsigned char check_sum = (rdat[nnn - 1] >> 24) & 0xFF;
872 unsigned char data_sum = 0;
873 unsigned char kdat[4] = {0};
874 for (
int j = nnn - 2; j > -1; j--) {
875 kdat[0] = rdat[j] & 0xff;
876 kdat[1] = (rdat[j] >> 8) & 0xff;
877 kdat[2] = (rdat[j] >> 16) & 0xff;
878 kdat[3] = (rdat[j] >> 24) & 0xff;
879 for (
int k = 0; k < 4; k++) {
880 data_sum = data_sum + kdat[k];
884 int flag_checksum = 0;
886 if (check_sum == data_sum) {
893 int l1_revo = rdat[0] & 0x7ff;
899 int summary_data = 0;
901 int summary_revo = 0;
903 bool summary_trg =
false;
916 int win3_revo = -9999;
918 vector<unsigned> sum_data;
919 vector<vector<unsigned>> sum_info;
922 vector<vector<int>> tc_info;
923 vector<vector<int>> tc_info_FE1;
924 vector<vector<int>> tc_info_FE2;
925 vector<vector<int>> tc_info_BE1;
926 vector<vector<int>> tc_info_BE2;
929 while (i < nnn - 2) {
930 summary_data = rdat[i + 1];
931 summary_trg = (summary_data >> 23) & 0x1;
932 summary_revo = (summary_data >> 16) & 0x7f;
933 ntc_win = summary_data & 0x3ff;
939 data_win = window_num;
940 if (window_num == 3) win3_revo = summary_revo;
942 if (summary_trg ==
true) {
943 sum_data.push_back(data_win);
944 sum_data.push_back(summary_revo);
945 for (
int j = 0; j < 9; j++) {
946 sum_data.push_back(rdat[i + j + 2]);
948 sum_info.push_back(sum_data);
952 if (tc_trg ==
true) {
953 for (
int j = 0; j < ntc_win; j++) {
954 tc_id = (rdat[i + j] >> 20) & 0x3FF;
955 tc_t = (rdat[i + j] >> 12) & 0x7F;
956 tc_e = rdat[i + j] & 0xFFF;
957 conv_tc_t = (data_win - 3) * 128 + tc_t;
960 tc_data.push_back(tc_id);
961 tc_data.push_back(conv_tc_t);
962 tc_data.push_back(tc_e);
963 tc_data.push_back(data_win);
966 tc_info_FE1.push_back(tc_data);
968 tc_info_FE2.push_back(tc_data);
970 }
else if (tc_id > 512) {
972 tc_info_BE1.push_back(tc_data);
974 tc_info_BE2.push_back(tc_data);
977 tc_info.push_back(tc_data);
985 if (tc_trg ==
true) {
986 for (
int j = 0; j < ntc_win; j++) {
987 tc_id = (rdat[i + j + 2] >> 20) & 0x3FF;
988 tc_t = (rdat[i + j + 2] >> 12) & 0x7F;
989 conv_tc_t = (data_win - 3) * 128 + tc_t;
990 tc_e = rdat[i + j + 2] & 0xFFF;
993 tc_data.push_back(tc_id);
994 tc_data.push_back(conv_tc_t);
995 tc_data.push_back(tc_e);
996 tc_data.push_back(data_win);
999 tc_info_FE1.push_back(tc_data);
1001 tc_info_FE2.push_back(tc_data);
1003 }
else if (tc_id > 512) {
1005 tc_info_BE1.push_back(tc_data);
1007 tc_info_BE2.push_back(tc_data);
1010 tc_info.push_back(tc_data);
1014 i = i + ntc_win + 1;
1029 int cl_theta[6] = {0};
1030 int cl_phi[6] = {0};
1031 int cl_time[6] = { -9999};
1032 int cl_energy[6] = {0};
1057 vector<vector<int>> cl_2d;
1059 vector<int> evt_1d_vector;
1060 vector<vector<int>> evt_2d_vector;
1063 int sum_size = sum_info.size();
1064 if (sum_size != 0) {
1065 for (
int j = 0; j < sum_size; j++) {
1066 sum_num = sum_info[j][0];
1067 sum_revo = sum_info[j][1];
1069 ecl_bst = (sum_info[j][2] >> 26) & 0x1;
1072 cl_theta[5] = (sum_info[j][2] >> 19) & 0x7f;
1073 cl_phi[5] = (sum_info[j][2] >> 11) & 0xff;
1074 cl_time[5] = (sum_info[j][2] >> 3) & 0xff;
1075 cl_energy[5] = ((sum_info[j][2] & 0x7) << 9) + ((sum_info[j][3] >> 23) & 0x1ff);
1077 cl_theta[4] = (sum_info[j][3] >> 16) & 0x7f;
1078 cl_phi[4] = (sum_info[j][3] >> 8) & 0xff;
1079 cl_time[4] = (sum_info[j][3]) & 0xff;
1080 cl_energy[4] = (sum_info[j][4] >> 20) & 0xfff;
1082 cl_theta[3] = (sum_info[j][4] >> 13) & 0x7f;
1083 cl_phi[3] = (sum_info[j][4] >> 5) & 0xff;
1084 cl_time[3] = ((sum_info[j][4] & 0x1f) << 3) + ((sum_info[j][5] >> 29) & 0x7);
1085 cl_energy[3] = (sum_info[j][5] >> 17) & 0xfff;
1087 cl_theta[2] = (sum_info[j][5] >> 10) & 0x7f;
1088 cl_phi[2] = (sum_info[j][5] >> 2) & 0xff;
1089 cl_time[2] = ((sum_info[j][5] & 0x3) << 6) + ((sum_info[j][6] >> 26) & 0x3f);
1090 cl_energy[2] = (sum_info[j][6] >> 14) & 0xfff;
1092 cl_theta[1] = (sum_info[j][6] >> 7) & 0x7f;
1093 cl_phi[1] = ((sum_info[j][6] & 0x7f) << 1) + ((sum_info[j][7] >> 31) & 0x1);
1094 cl_time[1] = (sum_info[j][7] >> 23) & 0xff;
1095 cl_energy[1] = (sum_info[j][7] >> 11) & 0xfff;
1097 cl_theta[0] = (sum_info[j][7] >> 4) & 0x7f;
1098 cl_phi[0] = ((sum_info[j][7] & 0xf) << 4) + ((sum_info[j][8] >> 28) & 0xf);
1099 cl_time[0] = (sum_info[j][8] >> 20) & 0xff;
1100 cl_energy[0] = (sum_info[j][8] >> 8) & 0xfff;
1102 ncl = (sum_info[j][8] >> 5) & 0x7;
1104 prescale = (sum_info[j][8] >> 4) & 0x1;
1105 mumu = (sum_info[j][8] >> 3) & 0x1;
1106 b2bhabha_s = (sum_info[j][8] >> 2) & 0x1;
1108 low_multi = (((sum_info[j][2] >> 27) & 0x3) << 12) + ((sum_info[j][8] & 0x3) << 10) + ((sum_info[j][9] >> 22) & 0x3ff);
1110 low_multi = ((sum_info[j][8] & 0x3) << 10) + ((sum_info[j][9] >> 22) & 0x3ff);
1112 b2bhabha_v = (sum_info[j][9] >> 21) & 0x1;
1113 icn_over = (sum_info[j][9] >> 20) & 0x1;
1114 bg_veto = (sum_info[j][9] >> 17) & 0x7;
1115 icn = (sum_info[j][9] >> 10) & 0x7f;
1116 etot_type = (sum_info[j][9] >> 7) & 0x7;
1117 etot = ((sum_info[j][9] & 0x7f) << 6) + ((sum_info[j][10] >> 26) & 0x3f);
1118 b1_type = (sum_info[j][10] >> 12) & 0x3fff;
1119 b1bhabha = (sum_info[j][10] >> 11) & 0x1;
1120 physics = (sum_info[j][10] >> 10) & 0x1;
1121 time_type = (sum_info[j][10] >> 7) & 0x7;
1122 time = (sum_info[j][10]) & 0x7f;
1124 cl_theta[5] = (sum_info[j][2] >> 24) & 0x7f;
1125 cl_phi[5] = (sum_info[j][2] >> 16) & 0xff;
1126 cl_time[5] = (sum_info[j][2] >> 8) & 0xff;
1127 cl_energy[5] = ((sum_info[j][2] & 0xff) << 4) + ((sum_info[j][3] >> 28) & 0xf);
1129 cl_theta[4] = (sum_info[j][3] >> 21) & 0x7f;
1130 cl_phi[4] = (sum_info[j][3] >> 13) & 0xff;
1131 cl_time[4] = (sum_info[j][3] >> 5) & 0xff;
1132 cl_energy[4] = ((sum_info[j][3] & 0x1f) << 7) + ((sum_info[j][4] >> 25) & 0x7f);
1134 cl_theta[3] = (sum_info[j][4] >> 18) & 0x7f;
1135 cl_phi[3] = (sum_info[j][4] >> 10) & 0xff;
1136 cl_time[3] = (sum_info[j][4] >> 2) & 0xff;
1137 cl_energy[3] = ((sum_info[j][4] & 0x3) << 10) + ((sum_info[j][5] >> 22) & 0x3ff);
1139 cl_theta[2] = (sum_info[j][5] >> 15) & 0x7f;
1140 cl_phi[2] = (sum_info[j][5] >> 7) & 0xff;
1141 cl_time[2] = ((sum_info[j][5] & 0x7f) << 1) + ((sum_info[j][6] >> 31) & 0x1);
1142 cl_energy[2] = (sum_info[j][6] >> 19) & 0xfff;
1144 cl_theta[1] = (sum_info[j][6] >> 12) & 0x7f;
1145 cl_phi[1] = (sum_info[j][6] >> 4) & 0xff;
1146 cl_time[1] = ((sum_info[j][6] & 0xf) << 4) + ((sum_info[j][7] >> 28) & 0xf);
1147 cl_energy[1] = (sum_info[j][7] >> 16) & 0xfff;
1149 cl_theta[0] = (sum_info[j][7] >> 9) & 0x7f;
1150 cl_phi[0] = (sum_info[j][7] >> 1) & 0xff;
1151 cl_time[0] = ((sum_info[j][7] & 0x1) << 7) + ((sum_info[j][8] >> 25) & 0x7f);
1152 cl_energy[0] = (sum_info[j][8] >> 13) & 0xfff;
1154 ncl = (sum_info[j][8] >> 10) & 0x7;
1156 low_multi = ((sum_info[j][8] & 0x3ff) << 2) + ((sum_info[j][9] >> 30) & 0x3);
1157 b2bhabha_v = (sum_info[j][9] >> 29) & 0x1;
1158 icn_over = (sum_info[j][9] >> 28) & 0x1;
1159 bg_veto = (sum_info[j][9] >> 25) & 0x7;
1160 icn = (sum_info[j][9] >> 18) & 0x7f;
1161 etot_type = (sum_info[j][9] >> 15) & 0x7;
1162 etot = (sum_info[j][9] >> 2) & 0x1fff;
1164 b1_type = ((sum_info[j][9] & 0x3) << 12) + ((sum_info[j][10] >> 20) & 0xfff);
1165 b1bhabha = (sum_info[j][10] >> 19) & 0x1;
1166 physics = (sum_info[j][10] >> 18) & 0x1;
1167 time_type = (sum_info[j][10] >> 15) & 0x7;
1168 time = (sum_info[j][10] >> 8) & 0x7f;
1202 for (
int k = 0; k < 6; k++) {
1203 cl_1d.push_back(cl_theta[k]);
1204 cl_1d.push_back(cl_phi[k]);
1205 cl_1d.push_back(cl_time[k]);
1206 cl_1d.push_back(cl_energy[k]);
1207 cl_2d.push_back(cl_1d);
1210 sort(cl_2d.begin(), cl_2d.end(),
1211 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[3] > aa2[3];});
1213 evt_1d_vector.push_back(abs(sum_num - 3));
1214 evt_1d_vector.push_back(sum_revo);
1215 evt_1d_vector.push_back(sum_num);
1216 evt_1d_vector.push_back(time);
1217 for (
int k = 0; k < 6; k++) {
1218 evt_1d_vector.push_back(cl_2d[k][0]);
1219 evt_1d_vector.push_back(cl_2d[k][1]);
1220 evt_1d_vector.push_back(cl_2d[k][2]);
1221 evt_1d_vector.push_back(cl_2d[k][3]);
1223 evt_1d_vector.push_back(ncl);
1224 evt_1d_vector.push_back(low_multi);
1225 evt_1d_vector.push_back(b2bhabha_v);
1226 evt_1d_vector.push_back(b2bhabha_s);
1227 evt_1d_vector.push_back(mumu);
1228 evt_1d_vector.push_back(prescale);
1229 evt_1d_vector.push_back(icn);
1230 evt_1d_vector.push_back(icn_over);
1231 evt_1d_vector.push_back(etot_type);
1232 evt_1d_vector.push_back(etot);
1233 evt_1d_vector.push_back(ecl_bst);
1234 evt_1d_vector.push_back(b1_type);
1235 evt_1d_vector.push_back(b1bhabha);
1236 evt_1d_vector.push_back(physics);
1237 evt_1d_vector.push_back(time_type);
1238 evt_2d_vector.push_back(evt_1d_vector);
1239 evt_1d_vector.clear();
1243 for (
int k = 0; k < 6; k++) {
1295 tc_info.insert(tc_info.end(), tc_info_FE1.begin(), tc_info_FE1.end());
1296 tc_info.insert(tc_info.end(), tc_info_FE2.begin(), tc_info_FE2.end());
1297 tc_info.insert(tc_info.end(), tc_info_BE1.begin(), tc_info_BE1.end());
1298 tc_info.insert(tc_info.end(), tc_info_BE2.begin(), tc_info_BE2.end());
1314 int m_caltime = -9999;
1316 int tot_ntc = tc_info.size();
1320 int evt_revo = -9999;
1324 int evt_timing = -9999;
1325 int evt_cl_theta[6] = {0};
1326 int evt_cl_phi[6] = {0};
1327 int evt_cl_time[6] = { -9999};
1328 int evt_cl_energy[6] = {0};
1332 int evt_low_multi = 0;
1334 int evt_b2bhabha_v = 0;
1336 int evt_b2bhabha_s = 0;
1340 int evt_prescale = 0;
1344 int evt_icn_over = 0;
1346 int evt_etot_type = 0;
1350 int evt_ecl_bst = 0;
1352 int evt_b1_type = 0;
1354 int evt_b1bhabha = 0;
1356 int evt_physics = 0;
1358 int evt_time_type = 0;
1360 int evt_etot_all = 0;
1362 int evt_time_min = 0;
1364 int evt_time_max = 0;
1366 int evt_time_win = 0;
1383 int evt_v_size = evt_2d_vector.size();
1384 if (evt_v_size != 0) {
1386 sort(evt_2d_vector.begin(), evt_2d_vector.end(),
1387 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[0] < aa2[0];});
1390 if (tot_ntc != 0 && flag_checksum == 0 && nnn > 7) {
1391 if (evt_v_size == 0) {
1393 sort(tc_info.begin(), tc_info.end(),
1394 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[2] > aa2[2];});
1395 evt_revo = win3_revo;
1396 evt_win = tc_info[0][3];
1397 evt_timing = tc_info[0][1];
1398 for (
int k = 0; k < 6; k++) {
1399 evt_cl_theta[k] = 0;
1402 evt_cl_energy[k] = 0;
1420 evt_revo = evt_2d_vector[0][1];
1421 evt_win = evt_2d_vector[0][2];
1422 evt_timing = evt_2d_vector[0][3];
1423 for (
int k = 0; k < 6; k++) {
1424 evt_cl_theta[k] = evt_2d_vector[0][4 + k * 4];
1425 evt_cl_phi[k] = evt_2d_vector[0][5 + k * 4];
1426 evt_cl_time[k] = evt_2d_vector[0][6 + k * 4];
1427 evt_cl_energy[k] = evt_2d_vector[0][7 + k * 4];
1429 evt_ncl = evt_2d_vector[0][28];
1430 evt_low_multi = evt_2d_vector[0][29];
1431 evt_b2bhabha_v = evt_2d_vector[0][30];
1432 evt_b2bhabha_s = evt_2d_vector[0][31];
1433 evt_mumu = evt_2d_vector[0][32];
1434 evt_prescale = evt_2d_vector[0][33];
1435 evt_icn = evt_2d_vector[0][34];
1436 evt_icn_over = evt_2d_vector[0][35];
1437 evt_etot_type = evt_2d_vector[0][36];
1438 evt_etot = evt_2d_vector[0][37];
1439 evt_ecl_bst = evt_2d_vector[0][38];
1440 evt_b1_type = evt_2d_vector[0][39];
1441 evt_b1bhabha = evt_2d_vector[0][40];
1442 evt_physics = evt_2d_vector[0][41];
1443 evt_time_type = evt_2d_vector[0][42];
1446 sort(tc_info.begin(), tc_info.end(),
1447 [](
const vector<int>& aa1,
const vector<int>& aa2) {return aa1[0] < aa2[0];});
1449 for (
int ii = 0; ii < tot_ntc; ii++) {
1450 m_tcid = tc_info[ii][0];
1451 m_time = tc_info[ii][1];
1452 m_energy = tc_info[ii][2];
1453 m_win = tc_info[ii][3];
1455 m_caltime = m_time - ((evt_win - 3) * 128 + evt_timing);
1467 if (m_win == evt_win || m_win == evt_win + 1) evt_ntc++;
1468 if (m_win == evt_win - 1) {
1471 if (m_win == evt_win) {
1474 if (m_win == evt_win + 1) {
1479 if (etot_i == 0 && etot_f == 0) {
1480 evt_etot_all = etot_c;
1481 evt_time_min = - evt_timing;
1482 evt_time_max = 256 - evt_timing;
1484 }
else if (etot_i >= etot_f) {
1485 evt_etot_all = etot_c + etot_i;
1486 evt_time_min = -128 - evt_timing;
1487 evt_time_max = 128 - evt_timing;
1490 evt_etot_all = etot_c + etot_f;
1491 evt_time_min = - evt_timing;
1492 evt_time_max = 256 - evt_timing;
1496 for (
int icluster = 0; icluster < 6; icluster++) {
1497 if (evt_cl_energy[icluster] == 0 || evt_cl_theta[icluster] == 0 || evt_cl_phi[icluster] == 0) {
continue;}
1499 if (cl_tcid == 0) {
continue;}
1575 for (
int k = 0; k < 6; k++) {
1576 evt_cl_theta[k] = 0;
1578 evt_cl_time[k] = -9999;
1579 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.
TRGECLUnpackerModule()
Constructor.
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)
ROOT::Math::XYZVector 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.