Belle II Software development
ARICHChannelMapping.cc
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#include <framework/logging/Logger.h>
10
11#include <arich/dbobjects/ARICHChannelMapping.h>
12#include <iostream>
13#include<iomanip>
14
15using namespace std;
16using namespace Belle2;
17
19{
20 m_xy2asic.assign(N_XCHANNELS * N_YCHANNELS, -1);
21 m_asic2xy.assign(N_XCHANNELS * N_YCHANNELS, -1);
22}
23
24bool ARICHChannelMapping::getXYFromAsic(unsigned asicChn, int& xChn, int& yChn) const
25{
26 if (asicChn > N_XCHANNELS * N_YCHANNELS - 1) {
27 B2ERROR("ARICHChannelMapping::getXYFromAsic: invalid channel asic number!");
28 return false;
29 }
30 int chId = (int)m_asic2xy[asicChn];
31 if (chId == -1) return false;
32 xChn = chId % N_XCHANNELS;
33 yChn = chId / N_XCHANNELS;
34 return true;
35}
36
37int ARICHChannelMapping::getAsicFromXY(unsigned xChn, unsigned yChn) const
38{
39 unsigned chId = yChn * N_XCHANNELS + xChn;
40 if (chId > N_XCHANNELS * N_YCHANNELS - 1) B2FATAL("ARICHChannelMapping::getAsicFromXY: invalid channel X,Y number!");
41 return (int)m_xy2asic[chId];
42}
43
44void ARICHChannelMapping::mapXY2Asic(unsigned xChn, unsigned yChn, unsigned asicChn)
45{
46 if (asicChn > N_XCHANNELS * N_YCHANNELS - 1 || xChn > N_XCHANNELS - 1
47 || yChn > N_YCHANNELS - 1) B2ERROR("ARICHChannelMapping::mapXY2Asich: invalid channel number!");
48 unsigned chId = yChn * N_XCHANNELS + xChn;
49 m_xy2asic.at(chId) = asicChn;
50 m_asic2xy.at(asicChn) = chId;
51}
52
54{
55 std::cout << std::endl;
56 std::cout << "HAPD X,Y channel mapping to asic channels" << std::endl << std::endl;
57 std::cout << " " << setfill('-') << setw(73) << "-" << std::endl;
58 for (int y = N_YCHANNELS - 1; y > -1; y--) {
59 std::cout << setfill(' ') << "y " << setw(2) << y << " ";
60 for (int x = 0; x < N_XCHANNELS; x++) {
61 std::cout << " | " << setw(3) << getAsicFromXY(x, y);
62 }
63 std::cout << " |" << std::endl;
64 std::cout << " " << setfill('-') << setw(73) << "-" << std::endl;
65 }
66 std::cout << setfill(' ') << " ";
67 for (int x = 0; x < N_XCHANNELS; x++) std::cout << "x " << setw(2) << x << " ";
68 std::cout << std::endl;
69}
int getAsicFromXY(unsigned xChn, unsigned yChn) const
Get asic channel number from HAPD channel X,Y numbers.
ARICHChannelMapping()
Default constructor.
std::vector< uint8_t > m_xy2asic
map of X,Y to asic channels numbers
bool getXYFromAsic(unsigned asicChn, int &xChn, int &yChn) const
Get HAPD channel X,Y numbers from asic channel number.
std::vector< uint8_t > m_asic2xy
map of asic to X,Y channel numbers
void print() const
Print mapping parameters.
void mapXY2Asic(unsigned xChn, unsigned yChn, unsigned asicChn)
Add entry to channel map.
Abstract base class for different kinds of events.
STL namespace.