Belle II Software development
RawData.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9/* Own header. */
10#include <klm/rawdata/RawData.h>
11
12/* KLM headers. */
13#include <klm/dataobjects/KLMDigitRaw.h>
14
15/* C++ headers. */
16#include <cstdint>
17
18using namespace Belle2::KLM;
19
21 int copper, int slot, const int* buffer,
22 StoreArray<KLMDigitRaw>* klmDigitRaws,
23 KLMDigitRaw** newDigitRaw, bool fillDigitRaws)
24{
25 uint16_t dataWords[4];
26 dataWords[0] = (buffer[0] >> 16) & 0xFFFF;
27 dataWords[1] = buffer[0] & 0xFFFF;
28 dataWords[2] = (buffer[1] >> 16) & 0xFFFF;
29 dataWords[3] = buffer[1] & 0xFFFF;
30 m_Type = unpackType(dataWords[0]);
31 m_Lane = unpackLane(dataWords[0]);
32 m_Axis = unpackAxis(dataWords[0]);
33 m_Channel = unpackChannel(dataWords[0]);
34 m_CTime = unpackCTime(dataWords[1]);
35 m_TriggerBits = unpackTriggerBits(dataWords[2]);
36 m_TDC = unpackTDC(dataWords[2]);
37 m_Charge = unpackCharge(dataWords[3]);
38 m_FE = unpackFE(dataWords[3]);
39 if (fillDigitRaws) {
40 *newDigitRaw = klmDigitRaws->appendNew(copper, slot,
41 dataWords[0], dataWords[1],
42 dataWords[2], dataWords[3]);
43 }
44}
45
47{
48}
49
50void RawData::getChannelGroups(std::vector<ChannelGroup>& channelGroups) const
51{
52 ChannelGroup group;
53 if (multipleStripHit()) {
54 int asic = (m_Channel - 1) / c_NChannelsAsic;
55 int channelBase = c_NChannelsAsic * asic;
56 channelGroups.clear();
57 if (m_Type == 0x4) { // for old scintillator-readout firmware with bug
58 if ((m_TriggerBits & 0xF) != 0) {
59 group.firstChannel = channelBase + 1;
60 group.lastChannel = channelBase + c_NChannelsAsic;
61 channelGroups.push_back(group);
62 }
63 } else if ((m_Type == 0x5) && (m_FE != 0)) { // for new scintillator-readout firmware
64 group.firstChannel = m_Channel;
65 group.lastChannel = 0;
66 channelGroups.push_back(group);
67 } else if ((m_Type == 0x5) && (m_FE == 0)) { // for new scintillator-readout firmware
68 if ((m_TriggerBits & 0x1) != 0) {
69 group.firstChannel = channelBase + 1;
70 group.lastChannel = channelBase + 4;
71 channelGroups.push_back(group);
72 }
73 if ((m_TriggerBits & 0x2) != 0) {
74 group.firstChannel = channelBase + 5;
75 group.lastChannel = channelBase + 8;
76 channelGroups.push_back(group);
77 }
78 if ((m_TriggerBits & 0x4) != 0) {
79 group.firstChannel = channelBase + 9;
80 group.lastChannel = channelBase + 12;
81 channelGroups.push_back(group);
82 }
83 if ((m_TriggerBits & 0x8) != 0) {
84 group.firstChannel = channelBase + 13;
85 group.lastChannel = channelBase + c_NChannelsAsic;
86 channelGroups.push_back(group);
87 }
88 }
89 } else { // for RPC strip or isolated scintillator
90 group.firstChannel = m_Channel;
91 group.lastChannel = 0;
92 channelGroups.push_back(group);
93 }
94}
Class to store the raw words from the unpacker, digit-by-digit.
Definition: KLMDigitRaw.h:29
uint16_t m_Charge
Charge (12 bits).
Definition: RawData.h:262
static uint16_t unpackFE(uint16_t raw)
Unpack feature-extraction bit.
Definition: RawData.h:233
uint16_t m_TDC
TDC (11 bits).
Definition: RawData.h:259
static uint16_t unpackTDC(uint16_t raw)
Unpack TDC.
Definition: RawData.h:217
static uint16_t unpackType(uint16_t raw)
Unpack packet type.
Definition: RawData.h:163
static uint16_t unpackChannel(uint16_t raw)
Unpack channel.
Definition: RawData.h:190
static uint16_t unpackCharge(uint16_t raw)
Unpack charge.
Definition: RawData.h:225
uint16_t m_Axis
Axis (1 bit).
Definition: RawData.h:247
uint16_t m_Channel
Channel (7 bits).
Definition: RawData.h:250
uint16_t m_TriggerBits
Trigger bits (5 bits).
Definition: RawData.h:256
static uint16_t unpackCTime(uint16_t raw)
Unpack CTIME.
Definition: RawData.h:199
uint16_t m_Type
Packet type (3 bits).
Definition: RawData.h:241
uint16_t m_FE
Feature extraction mode (1 bit).
Definition: RawData.h:265
static uint16_t unpackLane(uint16_t raw)
Unpack lane.
Definition: RawData.h:172
static uint16_t unpackTriggerBits(uint16_t raw)
Unpack trigger bits.
Definition: RawData.h:208
uint16_t m_Lane
Lane (5 bits).
Definition: RawData.h:244
bool multipleStripHit() const
Check whether this hit corresponds to multiple strips.
Definition: RawData.h:148
RawData(int copper, int slot, const int *buffer, StoreArray< KLMDigitRaw > *klmDigitRaws, KLMDigitRaw **newDigitRaw, bool fillDigitRaws)
Constructor (unpack KLM raw data).
Definition: RawData.cc:20
static uint16_t unpackAxis(uint16_t raw)
Unpack axis.
Definition: RawData.h:181
void getChannelGroups(std::vector< ChannelGroup > &channelGroups) const
Get channel groups corresponding to this hit.
Definition: RawData.cc:50
~RawData()
Destructor.
Definition: RawData.cc:46
uint16_t m_CTime
CTIME (16 bits).
Definition: RawData.h:253
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
Channel group.
Definition: RawData.h:31