Belle II Software  release-05-02-19
RawData.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Kirill Chilikin *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 /* Own header. */
12 #include <klm/rawdata/RawData.h>
13 
14 /* KLM headers. */
15 #include <klm/dataobjects/KLMDigitRaw.h>
16 
17 /* C++ headers. */
18 #include <cstdint>
19 
20 using namespace Belle2::KLM;
21 
23  int copper, int slot, const int* buffer,
24  StoreArray<KLMDigitRaw>* klmDigitRaws,
25  KLMDigitRaw** newDigitRaw, bool fillDigitRaws)
26 {
27  uint16_t dataWords[4];
28  dataWords[0] = (buffer[0] >> 16) & 0xFFFF;
29  dataWords[1] = buffer[0] & 0xFFFF;
30  dataWords[2] = (buffer[1] >> 16) & 0xFFFF;
31  dataWords[3] = buffer[1] & 0xFFFF;
32  m_Lane = unpackLane(dataWords[0]);
33  m_Axis = unpackAxis(dataWords[0]);
34  m_Channel = unpackChannel(dataWords[0]);
35  m_CTime = unpackCTime(dataWords[1]);
36  m_TriggerBits = unpackTriggerBits(dataWords[2]);
37  m_TDC = unpackTDC(dataWords[2]);
38  m_Charge = unpackCharge(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 
50 void RawData::getChannelGroups(std::vector<ChannelGroup>& channelGroups) const
51 {
52  ChannelGroup group;
53  if (multipleStripHit()) {
54  int asic = (m_Channel - 1) / 15;
55  int channelBase = 15 * asic;
56  channelGroups.clear();
57  if ((m_TriggerBits & 0x1) != 0) {
58  group.firstChannel = channelBase + 1;
59  group.lastChannel = channelBase + 4;
60  channelGroups.push_back(group);
61  }
62  if ((m_TriggerBits & 0x2) != 0) {
63  group.firstChannel = channelBase + 5;
64  group.lastChannel = channelBase + 8;
65  channelGroups.push_back(group);
66  }
67  if ((m_TriggerBits & 0x4) != 0) {
68  group.firstChannel = channelBase + 9;
69  group.lastChannel = channelBase + 12;
70  channelGroups.push_back(group);
71  }
72  if ((m_TriggerBits & 0x8) != 0) {
73  group.firstChannel = channelBase + 13;
74  group.lastChannel = channelBase + 15;
75  channelGroups.push_back(group);
76  }
77  } else {
78  group.firstChannel = m_Channel;
79  group.lastChannel = 0;
80  channelGroups.push_back(group);
81  }
82 }
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::KLM::RawData::unpackTriggerBits
static uint16_t unpackTriggerBits(uint16_t raw)
Unpack trigger bits.
Definition: RawData.h:190
Belle2::KLM::RawData::m_CTime
uint16_t m_CTime
CTIME (16 bits).
Definition: RawData.h:224
Belle2::KLM::RawData::m_Axis
uint16_t m_Axis
Axis (1 bit).
Definition: RawData.h:218
Belle2::KLM::RawData::unpackLane
static uint16_t unpackLane(uint16_t raw)
Unpack lane.
Definition: RawData.h:154
Belle2::KLM::RawData::~RawData
~RawData()
Destructor.
Definition: RawData.cc:46
Belle2::KLM::RawData::m_Lane
uint16_t m_Lane
Lane (5 bits).
Definition: RawData.h:215
Belle2::KLM::RawData::unpackTDC
static uint16_t unpackTDC(uint16_t raw)
Unpack TDC.
Definition: RawData.h:199
Belle2::KLM::RawData::m_Charge
uint16_t m_Charge
Charge (12 bits).
Definition: RawData.h:233
Belle2::KLM::RawData::RawData
RawData(int copper, int slot, const int *buffer, StoreArray< KLMDigitRaw > *klmDigitRaws, KLMDigitRaw **newDigitRaw, bool fillDigitRaws)
Constructor (unpack KLM raw data).
Definition: RawData.cc:22
Belle2::KLM::RawData::unpackChannel
static uint16_t unpackChannel(uint16_t raw)
Unpack channel.
Definition: RawData.h:172
Belle2::KLM::RawData::m_Channel
uint16_t m_Channel
Channel (7 bits).
Definition: RawData.h:221
Belle2::KLMDigitRaw
Class to store the raw words from the unpacker, digit-by-digit.
Definition: KLMDigitRaw.h:39
Belle2::KLM::RawData::m_TriggerBits
uint16_t m_TriggerBits
Trigger bits (5 bits).
Definition: RawData.h:227
Belle2::KLM::RawData::unpackCTime
static uint16_t unpackCTime(uint16_t raw)
Unpack CTIME.
Definition: RawData.h:181
Belle2::KLM::RawData::multipleStripHit
bool multipleStripHit() const
Check whether this hit corresponds to multiple strips.
Definition: RawData.h:139
Belle2::KLM::RawData::unpackCharge
static uint16_t unpackCharge(uint16_t raw)
Unpack charge.
Definition: RawData.h:207
Belle2::KLM::RawData::m_TDC
uint16_t m_TDC
TDC (11 bits).
Definition: RawData.h:230
Belle2::KLM::RawData::getChannelGroups
void getChannelGroups(std::vector< ChannelGroup > &channelGroups) const
Get channel groups corresponding to this hit.
Definition: RawData.cc:50
Belle2::KLM::ChannelGroup
Channel group.
Definition: RawData.h:38
Belle2::KLM::RawData::unpackAxis
static uint16_t unpackAxis(uint16_t raw)
Unpack axis.
Definition: RawData.h:163
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33