10#include <klm/modules/KLMPacker/KLMPackerModule.h>
13#include <framework/logging/Logger.h>
23 setDescription(
"KLM raw data packer (creates RawKLM from KLMDigits).");
41 B2FATAL(
"KLM electronics map is not available.");
50 std::vector<uint32_t> dataWords[8][4];
54 uint32_t buf[2] = {0};
61 digit.getSubdetector(), digit.getSection(), digit.getSector(),
62 digit.getLayer(), digit.getPlane(), digit.getStrip());
65 if (electronicsChannel ==
nullptr)
66 B2FATAL(
"Incomplete KLM electronics map.");
72 int lane = electronicsChannel->
getLane();
73 int plane = electronicsChannel->
getAxis();
76 digit.getCharge(), digit.getCTime(), digit.getTDC(),
77 bword1, bword2, bword3, bword4);
79 buf[0] |= ((bword1 << 16));
81 buf[1] |= ((bword3 << 16));
83 int copper = electronicsChannel->
getCopper() - BKLM_ID - 1;
84 int dataConcentrator = electronicsChannel->
getSlot() - 1;
85 dataWords[copper][dataConcentrator].push_back(buf[0]);
86 dataWords[copper][dataConcentrator].push_back(buf[1]);
88 int copper = electronicsChannel->
getCopper() - EKLM_ID - 1;
89 int dataConcentrator = electronicsChannel->
getSlot() - 1;
90 dataWords[copper + 4][dataConcentrator].push_back(buf[0]);
91 dataWords[copper + 4][dataConcentrator].push_back(buf[1]);
106 for (
int i = 0; i < 8; i++) {
108 packerInfo.
node_id = BKLM_ID + 1 + i;
110 packerInfo.
node_id = EKLM_ID + 1 + i - 4;
112 for (
int j = 0; j < 4; j++) {
113 nWords[j] = dataWords[i][j].size();
114 detectorBuf[j] =
new int[nWords[j] + 1];
115 for (
int k = 0; k < nWords[j]; k++)
116 detectorBuf[j][k] = dataWords[i][j][k];
117 detectorBuf[j][nWords[j]] = 0;
120 detectorBuf[1], nWords[1] + 1,
121 detectorBuf[2], nWords[2] + 1,
122 detectorBuf[3], nWords[3] + 1,
124 for (
int j = 0; j < 4; j++)
125 delete[] detectorBuf[j];
140 uint16_t& bword1, uint16_t& bword2, uint16_t& bword3, uint16_t& bword4)
146 bword1 |= (strip & 0x7F);
147 bword1 |= ((plane & 1) << 7);
148 bword1 |= ((lane & 0x1F) << 8);
149 bword1 |= (flag << 13);
150 bword2 |= (ctime & 0xFFFF);
151 bword3 |= (tdc & 0x3FF);
152 bword4 |= (charge & 0xFFF);
KLM digit (class representing a digitized hit in RPCs or scintillators).
BKLM electronics channel.
int getSlot() const
Get slot.
int getCopper() const
Get copper.
int getChannel() const
Get channel.
int getAxis() const
Get axis.
int getLane() const
Get lane.
KLMChannelNumber channelNumber(int subdetector, int section, int sector, int layer, int plane, int strip) const
Get channel number.
StoreArray< KLMDigit > m_Digits
KLM digits.
void initialize() override
Initializer.
void event() override
This method is called for each event.
const KLMElementNumbers * m_ElementNumbers
Element numbers.
void endRun() override
This method is called if the current run ends.
void terminate() override
This method is called at the end of the event processing.
void formatData(int flag, int lane, int plane, int strip, int charge, uint16_t ctime, uint16_t tdc, uint16_t &bword1, uint16_t &bword2, uint16_t &bword3, uint16_t &bword4)
Creation of raw data.
void beginRun() override
Called when entering a new run.
~KLMPackerModule()
Destructor.
DBObjPtr< KLMElectronicsMap > m_ElectronicsMap
Electronics map.
StoreArray< RawKLM > m_RawKLMs
Raw data.
KLMPackerModule()
Constructor.
StoreObjPtr< EventMetaData > m_EventMetaData
Event meta data.
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...
struct to contain header information used by RawCOPPERFormat::Packer()
unsigned int b2l_ctime
32bit unitx time at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user ...
unsigned int eve_num
Run # and subrun # ( 22bit )
unsigned int tt_ctime
Node ID (32bit)
unsigned int tt_utime
27bit clock ticks at trigger timing distributed by FTSW. For details, see Nakao-san's belle2link user...
unsigned int node_id
Event Number (32bit)
unsigned int run_subrun_num
Experiment number (10bit)
unsigned int exp_num
Experiment number (10bit)
void PackDetectorBuf(int *detector_buf_1st, int nwords_1st, int *detector_buf_2nd, int nwords_2nd, int *detector_buf_3rd, int nwords_3rd, int *detector_buf_4th, int nwords_4th, RawCOPPERPackerInfo rawcprpacker_info)
Packer for RawCOPPER class Pack data (format ver.
The Raw KLM class Class for RawCOPPER class data taken by KLM.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.