Belle II Software  release-05-02-19
ChannelMapper Class Reference

Provides mapping between electronic channels and pixels. More...

#include <ChannelMapper.h>

Collaboration diagram for ChannelMapper:

Public Types

enum  {
  c_numBoardstacks = 4,
  c_numCarrierBoards = 4,
  c_numAsics = 4,
  c_numChannels = 8,
  c_numRows = 2,
  c_numColumns = 16,
  c_numPixelRows = c_numRows * c_numCarrierBoards,
  c_numPixelColumns = c_numColumns * c_numBoardstacks,
  c_numPixels = c_numPixelRows * c_numPixelColumns,
  c_invalidChannel = c_numPixels,
  c_invalidPixelID = 0
}
 Enum for the number of different quantities etc. More...
 
enum  EType {
  c_unknown = 0,
  c_default = 1,
  c_IRS3B = 2,
  c_IRSX = 3
}
 Enum for electornic types.
 

Public Member Functions

 ChannelMapper ()
 constructor
 
 ~ChannelMapper ()
 destructor
 
void initialize (const GearDir &channelMapping)
 Initialize from Gearbox (XML) More...
 
void initialize ()
 Initialize from database.
 
bool isValid () const
 Checks if mapping is available. More...
 
void import (const IntervalOfValidity &iov) const
 import mappings to database More...
 
EType getType () const
 Return electornic type (see enum) More...
 
std::string getName () const
 Return electornic name. More...
 
bool isPixelIDValid (int pixel) const
 Checks validity of pixel ID. More...
 
bool isChannelValid (unsigned channel) const
 Checks validity of hardware channel number. More...
 
unsigned getChannel (int pixel) const
 Converts pixel to hardware channel number (0-based) More...
 
unsigned getChannel (unsigned boardstack, unsigned carrier, unsigned asic, unsigned chan) const
 Returns hardware channel number (0-based) More...
 
void splitChannelNumber (unsigned channel, unsigned &boardstack, unsigned &carrier, unsigned &asic, unsigned &chan) const
 Splits hardware channel number into boardstack, carrier, asic and asic channel. More...
 
int getPixelID (unsigned channel) const
 Converts hardware channel number to pixel ID (1-based) More...
 
int getPmtID (int pixel) const
 Returns PMT ID (1-based) More...
 
void print () const
 Print mappings to terminal screen.
 
void test () const
 test that the conversion and inverse of it gives identity, if not B2ERROR
 

Private Member Functions

 ChannelMapper (const ChannelMapper &)
 Copy constructor.
 
ChannelMapperoperator= (const ChannelMapper &)
 Assignment operator.
 
void clear ()
 Clear.
 
void update ()
 re-do conversion arrays when DBArray has changed
 

Private Attributes

EType m_type = c_unknown
 electornic type
 
std::string m_typeName
 electronic type name
 
std::vector< TOPChannelMapm_mapping
 mappings from gearbox
 
DBArray< TOPChannelMap > * m_mappingDB = 0
 mappings from database
 
bool m_valid = false
 true if mapping available
 
bool m_fromDB = false
 true, if from database
 
const TOPChannelMapm_channels [c_numRows][c_numColumns] = {{0}}
 conversion array
 
const TOPChannelMapm_pixels [c_numAsics][c_numChannels] = {{0}}
 conversion array
 

Detailed Description

Provides mapping between electronic channels and pixels.

Definition at line 37 of file ChannelMapper.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Enum for the number of different quantities etc.

Enumerator
c_numBoardstacks 

number of boardstacks per TOP module

c_numCarrierBoards 

number of carrier boards per boardstack

c_numAsics 

number of ASIC's per carrier board

c_numChannels 

number of channels per ASIC

c_numRows 

number of pixel rows per carrier board

c_numColumns 

number of pixel columns per carrier board

c_numPixelRows 

per module

c_numPixelColumns 

per module

c_numPixels 

per module

c_invalidChannel 

value of invalid channel number

c_invalidPixelID 

value of invalid pixel ID

Definition at line 43 of file ChannelMapper.h.

51  {c_unknown = 0,
52  c_default = 1,
53  c_IRS3B = 2,
54  c_IRSX = 3

Member Function Documentation

◆ getChannel() [1/2]

unsigned getChannel ( int  pixel) const

Converts pixel to hardware channel number (0-based)

Parameters
pixelpixel ID (1-based)
Returns
channel number (or c_invalidChannel for invalid pixel)

Definition at line 209 of file ChannelMapper.cc.

210  {
211  if (!isPixelIDValid(pixel)) return c_invalidChannel;
212 
213  unsigned pix = pixel - 1;
214  unsigned pixRow = pix / c_numPixelColumns;
215  unsigned pixCol = pix % c_numPixelColumns;
216 
217  unsigned carrier = pixRow / c_numRows;
218  unsigned row = pixRow % c_numRows;
219  unsigned boardstack = pixCol / c_numColumns;
220  unsigned col = pixCol % c_numColumns;
221 
222  const auto& map = m_channels[row][col];
223  if (!map) {
224  B2WARNING("TOP::ChannelMapper: no channel mapped to pixel. Return invalid channel."
225  << LogVar("pixelID", pixel));
226  return c_invalidChannel;
227  }
228  unsigned asic = map->getASICNumber();
229  unsigned chan = map->getASICChannel();
230 
231  return getChannel(boardstack, carrier, asic, chan);
232  }

◆ getChannel() [2/2]

unsigned getChannel ( unsigned  boardstack,
unsigned  carrier,
unsigned  asic,
unsigned  chan 
) const
inline

Returns hardware channel number (0-based)

Parameters
boardstackboardstack number (0-based)
carriercarrier board number (0-based)
asicASIC number (0-based)
chanASIC channel number (0-based)
Returns
channel number (or c_invalidChannel for invalid pixel)

Definition at line 146 of file ChannelMapper.h.

◆ getName()

std::string getName ( ) const
inline

Return electornic name.

Returns
name

Definition at line 108 of file ChannelMapper.h.

◆ getPixelID()

int getPixelID ( unsigned  channel) const

Converts hardware channel number to pixel ID (1-based)

Parameters
channelhardware channel number (0-based)
Returns
pixel ID (or c_invalidPixelID for invalid channel number)

Definition at line 250 of file ChannelMapper.cc.

◆ getPmtID()

int getPmtID ( int  pixel) const

Returns PMT ID (1-based)

Parameters
pixelpixelID (1-based)
Returns
PMT ID (or 0 for invalid pixel)

Definition at line 276 of file ChannelMapper.cc.

◆ getType()

EType getType ( ) const
inline

Return electornic type (see enum)

Returns
type

Definition at line 102 of file ChannelMapper.h.

◆ import()

void import ( const IntervalOfValidity iov) const

import mappings to database

Parameters
iovInterval of validity.

Definition at line 199 of file ChannelMapper.cc.

◆ initialize()

void initialize ( const GearDir channelMapping)

Initialize from Gearbox (XML)

Parameters
channelMappingXML data directory

Definition at line 46 of file ChannelMapper.cc.

◆ isChannelValid()

bool isChannelValid ( unsigned  channel) const
inline

Checks validity of hardware channel number.

Parameters
channelhardware channel number (0-based)
Returns
true for valid ID

Definition at line 126 of file ChannelMapper.h.

◆ isPixelIDValid()

bool isPixelIDValid ( int  pixel) const
inline

Checks validity of pixel ID.

Parameters
pixelpixel ID (1-based)
Returns
true for valid ID

Definition at line 115 of file ChannelMapper.h.

◆ isValid()

bool isValid ( ) const
inline

Checks if mapping is available.

Returns
true if available

Definition at line 90 of file ChannelMapper.h.

◆ 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.

Parameters
channelhardware channel number (0-based) [input]
boardstackboardstack number (0-based) [output]
carriercarrier board number (0-based) [output]
asicASIC number (0-based) [output]
chanASIC channel number (0-based) [output]

Definition at line 235 of file ChannelMapper.cc.


The documentation for this class was generated from the following files:
Belle2::TOP::ChannelMapper::m_channels
const TOPChannelMap * m_channels[c_numRows][c_numColumns]
conversion array
Definition: ChannelMapper.h:225
Belle2::TOP::ChannelMapper::c_numRows
@ c_numRows
number of pixel rows per carrier board
Definition: ChannelMapper.h:47
Belle2::TOP::ChannelMapper::c_numColumns
@ c_numColumns
number of pixel columns per carrier board
Definition: ChannelMapper.h:48
Belle2::TOP::ChannelMapper::isPixelIDValid
bool isPixelIDValid(int pixel) const
Checks validity of pixel ID.
Definition: ChannelMapper.h:115
Belle2::TOP::ChannelMapper::c_numPixelColumns
@ c_numPixelColumns
per module
Definition: ChannelMapper.h:50
Belle2::TOP::ChannelMapper::getChannel
unsigned getChannel(int pixel) const
Converts pixel to hardware channel number (0-based)
Definition: ChannelMapper.cc:209
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24
Belle2::TOP::ChannelMapper::c_invalidChannel
@ c_invalidChannel
value of invalid channel number
Definition: ChannelMapper.h:52