11 #include <framework/logging/Logger.h>
13 #include <arich/dbobjects/ARICHChannelMapping.h>
20 ARICHChannelMapping::ARICHChannelMapping()
22 m_xy2asic.assign(N_XCHANNELS * N_YCHANNELS, -1);
23 m_asic2xy.assign(N_XCHANNELS * N_YCHANNELS, -1);
26 bool ARICHChannelMapping::getXYFromAsic(
unsigned asicChn,
int& xChn,
int& yChn)
const
28 if (asicChn > N_XCHANNELS * N_YCHANNELS - 1) {
29 B2ERROR(
"ARICHChannelMapping::getXYFromAsic: invalid channel asic number!");
32 int chId = (int)m_asic2xy[asicChn];
33 if (chId == -1)
return false;
34 xChn = chId % N_XCHANNELS;
35 yChn = chId / N_XCHANNELS;
39 int ARICHChannelMapping::getAsicFromXY(
unsigned xChn,
unsigned yChn)
const
41 unsigned chId = yChn * N_XCHANNELS + xChn;
42 if (chId > N_XCHANNELS * N_YCHANNELS - 1) B2FATAL(
"ARICHChannelMapping::getAsicFromXY: invalid channel X,Y number!");
43 return (
int)m_xy2asic[chId];
46 void ARICHChannelMapping::mapXY2Asic(
unsigned xChn,
unsigned yChn,
unsigned asicChn)
48 if (asicChn > N_XCHANNELS * N_YCHANNELS - 1 || xChn > N_XCHANNELS - 1
49 || yChn > N_YCHANNELS - 1) B2ERROR(
"ARICHChannelMapping::mapXY2Asich: invalid channel number!");
50 unsigned chId = yChn * N_XCHANNELS + xChn;
51 m_xy2asic.at(chId) = asicChn;
52 m_asic2xy.at(asicChn) = chId;
55 void ARICHChannelMapping::print()
const
57 std::cout << std::endl;
58 std::cout <<
"HAPD X,Y channel mapping to asic channels" << std::endl << std::endl;
59 std::cout <<
" " << setfill(
'-') << setw(73) <<
"-" << std::endl;
60 for (
int y = N_YCHANNELS - 1; y > -1; y--) {
61 std::cout << setfill(
' ') <<
"y " << setw(2) << y <<
" ";
62 for (
int x = 0; x < N_XCHANNELS; x++) {
63 std::cout <<
" | " << setw(3) << getAsicFromXY(x, y);
65 std::cout <<
" |" << std::endl;
66 std::cout <<
" " << setfill(
'-') << setw(73) <<
"-" << std::endl;
68 std::cout << setfill(
' ') <<
" ";
69 for (
int x = 0; x < N_XCHANNELS; x++) std::cout <<
"x " << setw(2) << x <<
" ";
70 std::cout << std::endl;