Belle II Software  release-05-02-19
ChannelMapper.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Marko Staric *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <top/dbobjects/TOPChannelMap.h>
14 #include <framework/gearbox/GearDir.h>
15 #include <framework/database/DBArray.h>
16 #include <framework/database/IntervalOfValidity.h>
17 
18 
19 namespace Belle2 {
24  namespace TOP {
25 
29  class ChannelMapper {
30 
31  public:
35  enum {c_numBoardstacks = 4,
36  c_numCarrierBoards = 4,
37  c_numAsics = 4,
38  c_numChannels = 8,
39  c_numRows = 2,
40  c_numColumns = 16,
46  };
47 
51  enum EType {c_unknown = 0,
52  c_default = 1,
53  c_IRS3B = 2,
54  c_IRSX = 3
55  };
56 
60  ChannelMapper();
61 
66 
71  void initialize(const GearDir& channelMapping);
72 
76  void initialize();
77 
82  bool isValid() const {return m_valid;}
83 
88  void import(const IntervalOfValidity& iov) const;
89 
94  EType getType() const {return m_type;}
95 
100  std::string getName() const {return m_typeName;}
101 
107  bool isPixelIDValid(int pixel) const
108  {
109  unsigned pix = pixel - 1;
110  return pix < c_numPixels;
111  }
112 
118  bool isChannelValid(unsigned channel) const
119  {
120  return channel < c_numPixels;
121  }
122 
128  unsigned getChannel(int pixel) const;
129 
138  unsigned getChannel(unsigned boardstack,
139  unsigned carrier,
140  unsigned asic,
141  unsigned chan) const
142  {
143  return chan + c_numChannels * (asic + c_numAsics *
144  (carrier + c_numCarrierBoards * boardstack));
145  }
146 
155  void splitChannelNumber(unsigned channel,
156  unsigned& boardstack,
157  unsigned& carrier,
158  unsigned& asic,
159  unsigned& chan) const;
160 
166  int getPixelID(unsigned channel) const;
167 
173  int getPmtID(int pixel) const;
174 
178  void print() const;
179 
183  void test() const;
184 
185  private:
186 
191  {}
192 
197  {return *this;}
198 
199 
203  void clear();
204 
208  void update();
209 
210  EType m_type = c_unknown;
211  std::string m_typeName;
212  std::vector<TOPChannelMap> m_mapping;
214  bool m_valid = false;
215  bool m_fromDB = false;
220  };
221 
222  } // TOP namespace
224 } // Belle2 namespace
225 
Belle2::IntervalOfValidity
A class that describes the interval of experiments/runs for which an object in the database is valid.
Definition: IntervalOfValidity.h:35
Belle2::TOP::ChannelMapper::m_channels
const TOPChannelMap * m_channels[c_numRows][c_numColumns]
conversion array
Definition: ChannelMapper.h:225
Belle2::TOP::ChannelMapper
Provides mapping between electronic channels and pixels.
Definition: ChannelMapper.h:37
Belle2::TOP::ChannelMapper::getPixelID
int getPixelID(unsigned channel) const
Converts hardware channel number to pixel ID (1-based)
Definition: ChannelMapper.cc:250
Belle2::TOP::ChannelMapper::c_numPixelRows
@ c_numPixelRows
per module
Definition: ChannelMapper.h:49
Belle2::TOP::ChannelMapper::c_numChannels
@ c_numChannels
number of channels per ASIC
Definition: ChannelMapper.h:46
Belle2::TOP::ChannelMapper::EType
EType
Enum for electornic types.
Definition: ChannelMapper.h:59
Belle2::TOP::ChannelMapper::operator=
ChannelMapper & operator=(const ChannelMapper &)
Assignment operator.
Definition: ChannelMapper.h:204
Belle2::TOP::ChannelMapper::m_typeName
std::string m_typeName
electronic type name
Definition: ChannelMapper.h:219
Belle2::DBArray
Class for accessing arrays of objects in the database.
Definition: DBArray.h:36
Belle2::TOP::ChannelMapper::c_numRows
@ c_numRows
number of pixel rows per carrier board
Definition: ChannelMapper.h:47
Belle2::TOP::ChannelMapper::isValid
bool isValid() const
Checks if mapping is available.
Definition: ChannelMapper.h:90
Belle2::TOP::ChannelMapper::c_numColumns
@ c_numColumns
number of pixel columns per carrier board
Definition: ChannelMapper.h:48
Belle2::TOP::ChannelMapper::splitChannelNumber
void splitChannelNumber(unsigned channel, unsigned &boardstack, unsigned &carrier, unsigned &asic, unsigned &chan) const
Splits hardware channel number into boardstack, carrier, asic and asic channel.
Definition: ChannelMapper.cc:235
Belle2::TOP::ChannelMapper::c_numPixels
@ c_numPixels
per module
Definition: ChannelMapper.h:51
Belle2::TOP::ChannelMapper::m_fromDB
bool m_fromDB
true, if from database
Definition: ChannelMapper.h:223
Belle2::TOP::ChannelMapper::initialize
void initialize()
Initialize from database.
Definition: ChannelMapper.cc:176
Belle2::TOP::ChannelMapper::isPixelIDValid
bool isPixelIDValid(int pixel) const
Checks validity of pixel ID.
Definition: ChannelMapper.h:115
Belle2::TOP::ChannelMapper::test
void test() const
test that the conversion and inverse of it gives identity, if not B2ERROR
Definition: ChannelMapper.cc:323
Belle2::TOP::ChannelMapper::c_numPixelColumns
@ c_numPixelColumns
per module
Definition: ChannelMapper.h:50
Belle2::TOP::ChannelMapper::c_invalidPixelID
@ c_invalidPixelID
value of invalid pixel ID
Definition: ChannelMapper.h:53
Belle2::TOP::ChannelMapper::getChannel
unsigned getChannel(int pixel) const
Converts pixel to hardware channel number (0-based)
Definition: ChannelMapper.cc:209
Belle2::TOP::ChannelMapper::isChannelValid
bool isChannelValid(unsigned channel) const
Checks validity of hardware channel number.
Definition: ChannelMapper.h:126
Belle2::TOP::ChannelMapper::c_numBoardstacks
@ c_numBoardstacks
number of boardstacks per TOP module
Definition: ChannelMapper.h:43
Belle2::TOP::ChannelMapper::getName
std::string getName() const
Return electornic name.
Definition: ChannelMapper.h:108
Belle2::TOP::ChannelMapper::clear
void clear()
Clear.
Definition: ChannelMapper.cc:335
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::GearDir
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:41
Belle2::TOP::ChannelMapper::c_invalidChannel
@ c_invalidChannel
value of invalid channel number
Definition: ChannelMapper.h:52
Belle2::TOPChannelMap
Map of pixels and channels within the carrier board.
Definition: TOPChannelMap.h:32
Belle2::TOP::ChannelMapper::m_valid
bool m_valid
true if mapping available
Definition: ChannelMapper.h:222
Belle2::TOP::ChannelMapper::m_mappingDB
DBArray< TOPChannelMap > * m_mappingDB
mappings from database
Definition: ChannelMapper.h:221
Belle2::TOP::ChannelMapper::m_type
EType m_type
electornic type
Definition: ChannelMapper.h:218
Belle2::TOP::ChannelMapper::c_numCarrierBoards
@ c_numCarrierBoards
number of carrier boards per boardstack
Definition: ChannelMapper.h:44
Belle2::TOP::ChannelMapper::~ChannelMapper
~ChannelMapper()
destructor
Definition: ChannelMapper.cc:41
Belle2::TOP::ChannelMapper::m_pixels
const TOPChannelMap * m_pixels[c_numAsics][c_numChannels]
conversion array
Definition: ChannelMapper.h:226
Belle2::TOP::ChannelMapper::getType
EType getType() const
Return electornic type (see enum)
Definition: ChannelMapper.h:102
Belle2::TOP::ChannelMapper::m_mapping
std::vector< TOPChannelMap > m_mapping
mappings from gearbox
Definition: ChannelMapper.h:220
Belle2::TOP::ChannelMapper::print
void print() const
Print mappings to terminal screen.
Definition: ChannelMapper.cc:285
Belle2::TOP::ChannelMapper::getPmtID
int getPmtID(int pixel) const
Returns PMT ID (1-based)
Definition: ChannelMapper.cc:276
Belle2::TOP::ChannelMapper::update
void update()
re-do conversion arrays when DBArray has changed
Definition: ChannelMapper.cc:349
Belle2::TOP::ChannelMapper::c_numAsics
@ c_numAsics
number of ASIC's per carrier board
Definition: ChannelMapper.h:45
Belle2::TOP::ChannelMapper::ChannelMapper
ChannelMapper()
constructor
Definition: ChannelMapper.cc:26