Belle II Software development
ChannelMapper.h
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#pragma once
10
11#include <top/dbobjects/TOPChannelMap.h>
12#include <framework/gearbox/GearDir.h>
13#include <framework/database/DBArray.h>
14#include <framework/database/IntervalOfValidity.h>
15
16
17namespace Belle2 {
22 namespace TOP {
23
28
29 public:
33 enum {c_numBoardstacks = 4,
44 };
45
49 enum EType {c_unknown = 0,
50 c_default = 1,
51 c_IRS3B = 2,
52 c_IRSX = 3
53 };
54
59
64 void initialize(const GearDir& channelMapping);
65
69 void initialize();
70
75 bool isValid() const {return m_valid;}
76
81 void importPayload(const IntervalOfValidity& iov) const;
82
87 EType getType() const {return m_type;}
88
93 const std::string& getName() const {return m_typeName;}
94
100 static bool isPixelIDValid(int pixel)
101 {
102 unsigned pix = pixel - 1;
103 return pix < c_numPixels; // cppcheck-suppress knownConditionTrueFalse
104 }
105
111 static bool isChannelValid(unsigned channel)
112 {
113 return channel < c_numPixels;
114 }
115
121 unsigned getChannel(int pixel) const;
122
131 static unsigned getChannel(unsigned boardstack,
132 unsigned carrier,
133 unsigned asic,
134 unsigned chan)
135 {
136 return chan + c_numChannels * (asic + c_numAsics *
137 (carrier + c_numCarrierBoards * boardstack));
138 }
139
148 static void splitChannelNumber(unsigned channel,
149 unsigned& boardstack,
150 unsigned& carrier,
151 unsigned& asic,
152 unsigned& chan);
153
159 int getPixelID(unsigned channel) const;
160
166 static int getPmtID(int pixel);
167
171 void print() const;
172
176 void test() const;
177
178 private:
179
183 void clear();
184
188 void update();
189
190 EType m_type = c_unknown;
191 std::string m_typeName;
192 std::vector<TOPChannelMap> m_mapping;
194 bool m_valid = false;
195 bool m_fromDB = false;
196
199
200 };
201
202 } // TOP namespace
204} // Belle2 namespace
205
Class for accessing arrays of objects in the database.
Definition DBArray.h:26
GearDir is the basic class used for accessing the parameter store.
Definition GearDir.h:31
A class that describes the interval of experiments/runs for which an object in the database is valid.
Map of pixels and channels within the carrier board.
EType m_type
electornic type
void test() const
test that the conversion and inverse of it gives identity, if not B2ERROR
void initialize()
Initialize from database.
bool m_fromDB
true, if from database
std::vector< TOPChannelMap > m_mapping
mappings from gearbox
static bool isChannelValid(unsigned channel)
Checks validity of hardware channel number.
DBArray< TOPChannelMap > m_mappingDB
mappings from database
const TOPChannelMap * m_pixels[c_numAsics][c_numChannels]
conversion array
const std::string & getName() const
Return electornic name.
bool isValid() const
Checks if mapping is available.
@ c_numCarrierBoards
number of carrier boards per boardstack
@ c_numColumns
number of pixel columns per carrier board
@ c_numChannels
number of channels per ASIC
@ c_numRows
number of pixel rows per carrier board
@ c_numBoardstacks
number of boardstacks per TOP module
@ c_invalidChannel
value of invalid channel number
@ c_invalidPixelID
value of invalid pixel ID
@ c_numAsics
number of ASIC's per carrier board
static void splitChannelNumber(unsigned channel, unsigned &boardstack, unsigned &carrier, unsigned &asic, unsigned &chan)
Splits hardware channel number into boardstack, carrier, asic and asic channel.
int getPixelID(unsigned channel) const
Converts hardware channel number to pixel ID (1-based)
static int getPmtID(int pixel)
Returns PMT ID (1-based)
bool m_valid
true if mapping available
static unsigned getChannel(unsigned boardstack, unsigned carrier, unsigned asic, unsigned chan)
Returns hardware channel number (0-based)
void update()
re-do conversion arrays when DBArray has changed
void importPayload(const IntervalOfValidity &iov) const
import mappings to database
void print() const
Print mappings to terminal screen.
EType
Enum for electornic types.
static bool isPixelIDValid(int pixel)
Checks validity of pixel ID.
const TOPChannelMap * m_channels[c_numRows][c_numColumns]
conversion array
unsigned getChannel(int pixel) const
Converts pixel to hardware channel number (0-based)
EType getType() const
Return electornic type (see enum)
std::string m_typeName
electronic type name
Abstract base class for different kinds of events.