Belle II Software  release-06-01-15
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 
18 using 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_Lane = unpackLane(dataWords[0]);
31  m_Axis = unpackAxis(dataWords[0]);
32  m_Channel = unpackChannel(dataWords[0]);
33  m_CTime = unpackCTime(dataWords[1]);
34  m_TriggerBits = unpackTriggerBits(dataWords[2]);
35  m_TDC = unpackTDC(dataWords[2]);
36  m_Charge = unpackCharge(dataWords[3]);
37  if (fillDigitRaws) {
38  *newDigitRaw = klmDigitRaws->appendNew(copper, slot,
39  dataWords[0], dataWords[1],
40  dataWords[2], dataWords[3]);
41  }
42 }
43 
45 {
46 }
47 
48 void RawData::getChannelGroups(std::vector<ChannelGroup>& channelGroups) const
49 {
50  ChannelGroup group;
51  if (multipleStripHit()) {
52  int asic = (m_Channel - 1) / 15;
53  int channelBase = 15 * asic;
54  channelGroups.clear();
55  if ((m_TriggerBits & 0x1) != 0) {
56  group.firstChannel = channelBase + 1;
57  group.lastChannel = channelBase + 4;
58  channelGroups.push_back(group);
59  }
60  if ((m_TriggerBits & 0x2) != 0) {
61  group.firstChannel = channelBase + 5;
62  group.lastChannel = channelBase + 8;
63  channelGroups.push_back(group);
64  }
65  if ((m_TriggerBits & 0x4) != 0) {
66  group.firstChannel = channelBase + 9;
67  group.lastChannel = channelBase + 12;
68  channelGroups.push_back(group);
69  }
70  if ((m_TriggerBits & 0x8) != 0) {
71  group.firstChannel = channelBase + 13;
72  group.lastChannel = channelBase + 15;
73  channelGroups.push_back(group);
74  }
75  } else {
76  group.firstChannel = m_Channel;
77  group.lastChannel = 0;
78  channelGroups.push_back(group);
79  }
80 }
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:223
uint16_t m_TDC
TDC (11 bits).
Definition: RawData.h:220
static uint16_t unpackTDC(uint16_t raw)
Unpack TDC.
Definition: RawData.h:189
static uint16_t unpackChannel(uint16_t raw)
Unpack channel.
Definition: RawData.h:162
static uint16_t unpackCharge(uint16_t raw)
Unpack charge.
Definition: RawData.h:197
uint16_t m_Axis
Axis (1 bit).
Definition: RawData.h:208
uint16_t m_Channel
Channel (7 bits).
Definition: RawData.h:211
uint16_t m_TriggerBits
Trigger bits (5 bits).
Definition: RawData.h:217
static uint16_t unpackCTime(uint16_t raw)
Unpack CTIME.
Definition: RawData.h:171
static uint16_t unpackLane(uint16_t raw)
Unpack lane.
Definition: RawData.h:144
static uint16_t unpackTriggerBits(uint16_t raw)
Unpack trigger bits.
Definition: RawData.h:180
uint16_t m_Lane
Lane (5 bits).
Definition: RawData.h:205
bool multipleStripHit() const
Check whether this hit corresponds to multiple strips.
Definition: RawData.h:129
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:153
void getChannelGroups(std::vector< ChannelGroup > &channelGroups) const
Get channel groups corresponding to this hit.
Definition: RawData.cc:48
~RawData()
Destructor.
Definition: RawData.cc:44
uint16_t m_CTime
CTIME (16 bits).
Definition: RawData.h:214
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:28