9 #include <framework/logging/Logger.h>
11 #include <arich/dbobjects/ARICHChannelMapping.h>
18 ARICHChannelMapping::ARICHChannelMapping()
20 m_xy2asic.assign(N_XCHANNELS * N_YCHANNELS, -1);
21 m_asic2xy.assign(N_XCHANNELS * N_YCHANNELS, -1);
24 bool ARICHChannelMapping::getXYFromAsic(
unsigned asicChn,
int& xChn,
int& yChn)
const
26 if (asicChn > N_XCHANNELS * N_YCHANNELS - 1) {
27 B2ERROR(
"ARICHChannelMapping::getXYFromAsic: invalid channel asic number!");
30 int chId = (int)m_asic2xy[asicChn];
31 if (chId == -1)
return false;
32 xChn = chId % N_XCHANNELS;
33 yChn = chId / N_XCHANNELS;
37 int ARICHChannelMapping::getAsicFromXY(
unsigned xChn,
unsigned yChn)
const
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];
44 void ARICHChannelMapping::mapXY2Asic(
unsigned xChn,
unsigned yChn,
unsigned asicChn)
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;
53 void ARICHChannelMapping::print()
const
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);
63 std::cout <<
" |" << std::endl;
64 std::cout <<
" " << setfill(
'-') << setw(73) <<
"-" << std::endl;
66 std::cout << setfill(
' ') <<
" ";
67 for (
int x = 0; x < N_XCHANNELS; x++) std::cout <<
"x " << setw(2) << x <<
" ";
68 std::cout << std::endl;
Abstract base class for different kinds of events.