Belle II Software  release-08-01-10
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 
17 namespace Belle2 {
22  namespace TOP {
23 
27  class ChannelMapper {
28 
29  public:
33  enum {c_numBoardstacks = 4,
35  c_numAsics = 4,
37  c_numRows = 2,
38  c_numColumns = 16,
43  c_invalidPixelID = 0
44  };
45 
49  enum EType {c_unknown = 0,
50  c_default = 1,
51  c_IRS3B = 2,
52  c_IRSX = 3
53  };
54 
58  ChannelMapper();
59 
64 
69  void initialize(const GearDir& channelMapping);
70 
74  void initialize();
75 
80  bool isValid() const {return m_valid;}
81 
86  void importPayload(const IntervalOfValidity& iov) const;
87 
92  EType getType() const {return m_type;}
93 
98  std::string getName() const {return m_typeName;}
99 
105  bool isPixelIDValid(int pixel) const
106  {
107  unsigned pix = pixel - 1;
108  return pix < c_numPixels;
109  }
110 
116  bool isChannelValid(unsigned channel) const
117  {
118  return channel < c_numPixels;
119  }
120 
126  unsigned getChannel(int pixel) const;
127 
136  unsigned getChannel(unsigned boardstack,
137  unsigned carrier,
138  unsigned asic,
139  unsigned chan) const
140  {
141  return chan + c_numChannels * (asic + c_numAsics *
142  (carrier + c_numCarrierBoards * boardstack));
143  }
144 
153  void splitChannelNumber(unsigned channel,
154  unsigned& boardstack,
155  unsigned& carrier,
156  unsigned& asic,
157  unsigned& chan) const;
158 
164  int getPixelID(unsigned channel) const;
165 
171  int getPmtID(int pixel) const;
172 
176  void print() const;
177 
181  void test() const;
182 
183  private:
184 
189  {}
190 
195  {return *this;}
196 
197 
201  void clear();
202 
206  void update();
207 
208  EType m_type = c_unknown;
209  std::string m_typeName;
210  std::vector<TOPChannelMap> m_mapping;
212  bool m_valid = false;
213  bool m_fromDB = false;
218  };
219 
220  } // TOP namespace
222 } // Belle2 namespace
223 
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.
Definition: TOPChannelMap.h:22
Provides mapping between electronic channels and pixels.
Definition: ChannelMapper.h:27
EType m_type
electornic type
void test() const
test that the conversion and inverse of it gives identity, if not B2ERROR
ChannelMapper(const ChannelMapper &)
Copy constructor.
void initialize()
Initialize from database.
bool m_fromDB
true, if from database
std::vector< TOPChannelMap > m_mapping
mappings from gearbox
const TOPChannelMap * m_pixels[c_numAsics][c_numChannels]
conversion array
unsigned getChannel(unsigned boardstack, unsigned carrier, unsigned asic, unsigned chan) const
Returns hardware channel number (0-based)
ChannelMapper & operator=(const ChannelMapper &)
Assignment operator.
void splitChannelNumber(unsigned channel, unsigned &boardstack, unsigned &carrier, unsigned &asic, unsigned &chan) const
Splits hardware channel number into boardstack, carrier, asic and asic channel.
bool isValid() const
Checks if mapping is available.
Definition: ChannelMapper.h:80
int getPixelID(unsigned channel) const
Converts hardware channel number to pixel ID (1-based)
bool isChannelValid(unsigned channel) const
Checks validity of hardware channel number.
bool m_valid
true if mapping available
std::string getName() const
Return electornic name.
Definition: ChannelMapper.h:98
bool isPixelIDValid(int pixel) const
Checks validity of pixel ID.
int getPmtID(int pixel) const
Returns PMT ID (1-based)
DBArray< TOPChannelMap > * m_mappingDB
mappings from database
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.
Definition: ChannelMapper.h:49
@ c_numCarrierBoards
number of carrier boards per boardstack
Definition: ChannelMapper.h:34
@ c_numColumns
number of pixel columns per carrier board
Definition: ChannelMapper.h:38
@ c_numChannels
number of channels per ASIC
Definition: ChannelMapper.h:36
@ c_numRows
number of pixel rows per carrier board
Definition: ChannelMapper.h:37
@ c_numBoardstacks
number of boardstacks per TOP module
Definition: ChannelMapper.h:33
@ c_invalidChannel
value of invalid channel number
Definition: ChannelMapper.h:42
@ c_invalidPixelID
value of invalid pixel ID
Definition: ChannelMapper.h:43
@ c_numAsics
number of ASIC's per carrier board
Definition: ChannelMapper.h:35
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)
Definition: ChannelMapper.h:92
std::string m_typeName
electronic type name
Abstract base class for different kinds of events.