10 #include <arich/modules/arichRawUnpacker/ARICHRawUnpackerModule.h>
11 #include <arich/dataobjects/ARICHRawDigit.h>
14 #include <framework/datastore/StoreArray.h>
17 #include <rawdata/dataobjects/RawARICH.h>
39 ARICHRawUnpackerModule::ARICHRawUnpackerModule() :
HistoModule()
50 h_rate_a_all =
new TH1F(
"h_rate_a_all",
";Channel ID", 144 * 6, 0, 144 * 6);
51 h_rate_b_all =
new TH1F(
"h_rate_b_all",
";Channel ID", 144 * 6, 0, 144 * 6);
52 h_rate_c_all =
new TH1F(
"h_rate_c_all",
";Channel ID", 144 * 6, 0, 144 * 6);
53 h_rate_d_all =
new TH1F(
"h_rate_d_all",
";Channel ID", 144 * 6, 0, 144 * 6);
73 for (
auto& raw : rawdata) {
74 for (
int finesse = 0; finesse < 4; finesse++) {
75 const int* buf = (
const int*)raw.GetDetectorBuffer(0, finesse);
76 int bufSize = raw.GetDetectorNwords(0, finesse);
77 if (bufSize < 1)
continue;
80 int type = calbyte(buf);
81 int ver = calbyte(buf);
82 int boardid = calbyte(buf);
83 int febno = calbyte(buf);
84 unsigned int length_all = calword(buf);
85 unsigned int mrg_evtno = calword(buf);
87 rawdigit->setCopperId(raw.GetNodeID(0));
88 rawdigit->setHslbId(finesse);
90 while (m_ibyte < length_all) {
91 int type_feb = calbyte(buf);
93 boardid = calbyte(buf);
95 unsigned int length = calword(buf);
96 int evtno = calword(buf);
97 unsigned int ibyte = 0;
99 ss <<
"type=" << type_feb <<
", ver=" << ver <<
" "
100 <<
", boardid=" << boardid <<
", febno=" << febno
101 <<
", length=" << length <<
", evtno=" << evtno <<
" ";
103 long long feb_trigno = 0;
104 for (
int i = 0; i < 10; i++) {
105 int val = calbyte(buf);
108 feb_trigno |= (0xff & val) << (5 - i) * 8;
113 if (type_feb == 0x02) {
116 while (ibyte < length) {
117 int val = calbyte(buf);
120 ss <<
"ch# " << ch <<
"(" << val <<
") ";
122 if (febno < 0 || febno > 6) {
123 B2ERROR(
"FEB is bad : " << febno <<
" hslb-" << finesse <<
":"
124 <<
" type=" << type_feb <<
", ver=" << ver <<
" "
125 <<
", boardid=" << boardid <<
", febno=" << febno
126 <<
", length=" << length <<
", evtno=" << evtno);
128 feb.push_back(ch, val);
133 }
else if (type_feb == 0x01) {
134 if (length > 144 * 2 + 10) B2FATAL(
"error " << length);
136 while (ibyte < length) {
137 int ch = calbyte(buf);
139 int val = calbyte(buf);
142 ss <<
"ch# " << ch <<
"(" << val <<
") ";
144 if (febno < 0 || febno > 6) {
145 B2ERROR(
"FEB is bad : " << febno <<
" hslb-" << finesse <<
":"
146 <<
" type=" << type_feb <<
", ver=" << ver <<
" "
147 <<
", boardid=" << boardid <<
", febno=" << febno
148 <<
", length=" << length <<
", evtno=" << evtno);
151 feb.push_back(ch, val);
155 rawdigit->addFEB(feb, type, ver, boardid, febno, length, evtno, feb_trigno);
156 if (m_debug && hasHit) {
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
T * appendNew()
Construct a new T object at the end of the array.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual void endRun() override
End-of-run action.
virtual void terminate() override
Termination action.
virtual void beginRun() override
Called when entering a new run.
virtual ~ARICHRawUnpackerModule()
Destructor.
virtual void defineHisto() override
Function to define histograms.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.