12 #include <arich/modules/arichRawUnpacker/ARICHRawUnpackerModule.h>
13 #include <arich/dataobjects/ARICHRawDigit.h>
16 #include <framework/datastore/StoreArray.h>
19 #include <rawdata/dataobjects/RawARICH.h>
41 ARICHRawUnpackerModule::ARICHRawUnpackerModule() :
HistoModule()
52 h_rate_a_all =
new TH1F(
"h_rate_a_all",
";Channel ID", 144 * 6, 0, 144 * 6);
53 h_rate_b_all =
new TH1F(
"h_rate_b_all",
";Channel ID", 144 * 6, 0, 144 * 6);
54 h_rate_c_all =
new TH1F(
"h_rate_c_all",
";Channel ID", 144 * 6, 0, 144 * 6);
55 h_rate_d_all =
new TH1F(
"h_rate_d_all",
";Channel ID", 144 * 6, 0, 144 * 6);
64 rawdigit.registerInDataStore();
75 for (
auto& raw : rawdata) {
76 for (
int finesse = 0; finesse < 4; finesse++) {
77 const int* buf = (
const int*)raw.GetDetectorBuffer(0, finesse);
78 int bufSize = raw.GetDetectorNwords(0, finesse);
79 if (bufSize < 1)
continue;
82 int type = calbyte(buf);
83 int ver = calbyte(buf);
84 int boardid = calbyte(buf);
85 int febno = calbyte(buf);
86 unsigned int length_all = calword(buf);
87 unsigned int mrg_evtno = calword(buf);
89 rawdigit->setCopperId(raw.GetNodeID(0));
90 rawdigit->setHslbId(finesse);
92 while (m_ibyte < length_all) {
93 int type_feb = calbyte(buf);
95 boardid = calbyte(buf);
97 unsigned int length = calword(buf);
98 int evtno = calword(buf);
99 unsigned int ibyte = 0;
100 std::stringstream ss;
101 ss <<
"type=" << type_feb <<
", ver=" << ver <<
" "
102 <<
", boardid=" << boardid <<
", febno=" << febno
103 <<
", length=" << length <<
", evtno=" << evtno <<
" ";
105 long long feb_trigno = 0;
106 for (
int i = 0; i < 10; i++) {
107 int val = calbyte(buf);
110 feb_trigno |= (0xff & val) << (5 - i) * 8;
115 if (type_feb == 0x02) {
118 while (ibyte < length) {
119 int val = calbyte(buf);
122 ss <<
"ch# " << ch <<
"(" << val <<
") ";
124 if (febno < 0 || febno > 6) {
125 B2ERROR(
"FEB is bad : " << febno <<
" hslb-" << finesse <<
":"
126 <<
" type=" << type_feb <<
", ver=" << ver <<
" "
127 <<
", boardid=" << boardid <<
", febno=" << febno
128 <<
", length=" << length <<
", evtno=" << evtno);
130 feb.push_back(ch, val);
135 }
else if (type_feb == 0x01) {
136 if (length > 144 * 2 + 10) B2FATAL(
"error " << length);
138 while (ibyte < length) {
139 int ch = calbyte(buf);
141 int val = calbyte(buf);
144 ss <<
"ch# " << ch <<
"(" << val <<
") ";
146 if (febno < 0 || febno > 6) {
147 B2ERROR(
"FEB is bad : " << febno <<
" hslb-" << finesse <<
":"
148 <<
" type=" << type_feb <<
", ver=" << ver <<
" "
149 <<
", boardid=" << boardid <<
", febno=" << febno
150 <<
", length=" << length <<
", evtno=" << evtno);
153 feb.push_back(ch, val);
157 rawdigit->addFEB(feb, type, ver, boardid, febno, length, evtno, feb_trigno);
158 if (m_debug && hasHit) {