17#include <fairlogger/Logger.h>
22Mapping* Mapping::sMapping =
nullptr;
24Mapping::Mapping(std::basic_string_view<char>
path) : mPath(
path),
43 if (sMapping->mPath ==
path) {
58 LOG(error) <<
"Mapping not initialized";
62 if (ddl < 0 || ddl > 14) {
66 if ((hwAddr >= 112 && hwAddr < 128) || (hwAddr >= 2159 && hwAddr < 2176)) {
76 absId = mAbsId[ddl][hwAddr];
77 caloFlag = mCaloFlag[ddl][hwAddr];
82 if (caloFlag < 2 && (absId >
NCHANNELS || absId <= 1792)) {
92 if (caloFlag < 0 || caloFlag > 2) {
113 LOG(error) <<
"Mapping not initialized";
117 ddl = mAbsToHW[absId - 1][caloFlag][0];
118 hwAddr = mAbsToHW[absId - 1][caloFlag][1];
128 p = gSystem->Getenv(
"O2_ROOT");
129 p +=
"/share/Detectors/PHOS/files";
134 for (
short m = 0;
m < 4;
m++) {
135 for (
short i = 0;
i < 4;
i++) {
136 if (
m == 0 && (
i < 2)) {
140 short numberOfChannels = 0;
141 short maxHWAddress = 0;
142 std::string fname = fmt::format(
"{:s}/Mod{:d}RCU{:d}.data", p,
m,
i);
143 std::ifstream fIn(fname);
144 if (!fIn.is_open()) {
145 LOG(fatal) <<
"Missing mapping file " << p <<
"/Mod" <<
m <<
"RCU" <<
i <<
".data";
148 if (!(fIn >> numberOfChannels)) {
149 LOG(fatal) <<
"Syntax of mapping file " << p <<
"/Mod" <<
m <<
"RCU" <<
i <<
".data is wrong: no numberOfChannels";
153 LOG(fatal) <<
"Unexpected number of channels: " << numberOfChannels <<
" expecting " <<
NHWPERDDL <<
" file " << p <<
"/Mod" <<
m <<
"RCU" <<
i <<
".data is wrong: no numberOfChannels";
156 if (!(fIn >> maxHWAddress)) {
157 LOG(fatal) <<
"Syntax of mapping file " << p <<
"/Mod" <<
m <<
"RCU" <<
i <<
".data is wrong: no maxHWAddress";
161 LOG(fatal) <<
"Maximal HW address in file " << maxHWAddress <<
"larger than array size " <<
NMaxHWAddress <<
"for /Mod" <<
m <<
"RCU" <<
i <<
".data is wrong: no maxHWAddress";
164 for (
short ich = 0; ich < numberOfChannels; ich++) {
166 if (!(fIn >> hwAddress)) {
167 LOG(fatal) <<
"Syntax of mapping file " << p <<
"/Mod" <<
m <<
"RCU" <<
i <<
".data is wrong: no HWadd for ch " << ich;
170 if (hwAddress > maxHWAddress) {
171 LOG(fatal) <<
"Hardware (ALTRO) adress (" << hwAddress <<
") outside the range (0 -> " << maxHWAddress <<
") !";
175 if (!(fIn >>
row >>
col >> caloFlag)) {
176 LOG(fatal) <<
"Syntax of mapping file " << p <<
"/Mod" <<
m <<
"RCU" <<
i <<
".data is wrong: no (raw col caloFlag)";
180 if (caloFlag < 0 || caloFlag > 2) {
181 LOG(fatal) <<
"Wrong CaloFlag value found (" << caloFlag <<
"). Should be 0, 1, 2 !";
190 short ddl = 4 *
m +
i - 2;
191 if (ddl < 0 || ddl >=
NDDL) {
192 LOG(fatal) <<
"Wrong ddl address found (" << ddl <<
"). Module= " <<
m <<
" RCU =" <<
i;
198 char relid[3] = {
static_cast<char>(
m + 1),
static_cast<char>(
row + 1),
static_cast<char>(
col + 1)};
202 if (hwAddress < 2048) {
212 mAbsId[ddl][hwAddress] = absId;
213 mCaloFlag[ddl][hwAddress] = (
CaloFlag)caloFlag;
214 mAbsToHW[absId - 1][caloFlag][0] = ddl;
215 mAbsToHW[absId - 1][caloFlag][1] = hwAddress;
static bool relToAbsNumbering(const char *RelId, short &AbsId)
static constexpr short NDDL
Total number of DDLs.
static constexpr short NMaxHWAddress
Maximal HW address (size of array)
static Mapping * Instance()
static constexpr short NTRUBranchReadoutChannels
Number of TRU readout channels per branch.
static bool isTRUReadoutchannel(short hwAddress)
static constexpr short NHWPERDDL
Number of HW addressed per DDL.
static constexpr short NCHANNELS
Number of channels starting from 1.
ErrorStatus hwToAbsId(short ddl, short hw, short &absId, CaloFlag &caloFlag) const
convert hardware address to absId and caloFlag
ErrorStatus absIdTohw(short absId, short caloFlag, short &ddl, short &hwAddr) const
convert absId and caloflag to hardware address and ddl
static constexpr short NTRUReadoutChannels
Total number of TRU readout channels.
GLsizei const GLchar *const * path
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"