12#ifndef ALICEO2_TRD_HELPERMETHODS_HH
13#define ALICEO2_TRD_HELPERMETHODS_HH
18#include <fmt/format.h>
28 return (irow / constants::NMCMROBINROW) * 2 +
getColSide(icol);
33 if (irow < 0 || icol < 0 || irow > constants::NROWC1 || icol > constants::NCOLUMN) {
36 return (icol % (constants::NCOLUMN / 2)) / constants::NCOLMCM + constants::NMCMROBINCOL * (irow % constants::NMCMROBINROW);
41 if (icol < 0 || icol >= constants::NCOLUMN) {
45 return icol / (constants::NCOLUMN / 2);
50 return constants::NMCMROBINROW * (irob / 2) + imcm / constants::NMCMROBINCOL;
56 printf(
"%02i_%i_%i\n", det / constants::NCHAMBERPERSEC, (det % constants::NCHAMBERPERSEC) / constants::NLAYER, det % constants::NLAYER);
62 std::string
side = (hcid % 2 == 0) ?
"A" :
"B";
74 if (iadc < 0 || iadc > constants::NADCMCM) {
77 int mcmcol = imcm % constants::NMCMROBINCOL +
getROBSide(irob) * constants::NMCMROBINCOL;
78 int padcol = mcmcol * constants::NCOLMCM + constants::NCOLMCM + 1 - iadc;
79 if (padcol < 0 || padcol >= constants::NCOLUMN) {
87 if (irob < 0 || irob >= constants::NROBC1) {
95 return det / constants::NCHAMBERPERSEC;
100 return det % (constants::NSTACK * constants::NLAYER) / constants::NLAYER;
104 return det % constants::NLAYER;
109 return (
layer +
stack * constants::NLAYER + sector * constants::NLAYER * constants::NSTACK);
119 int side = (hcid % 2 == 0) ? 0 : 1;
120 bool isAside =
false;
125 ori =
stack * constants::NLAYER * 2 +
side * constants::NLAYER + 5 -
layer;
128 ori = (4 -
stack) * constants::NLAYER * 2 +
side * constants::NLAYER + 5 -
layer;
130 ori -= constants::NLAYER;
132 ori += constants::NLINKSPERCRU;
142 int sector =
link / constants::NHCPERSEC;
143 int linkSector =
link % constants::NHCPERSEC;
144 int linkCRU = linkSector % constants::NLINKSPERCRU;
145 int stack = linkCRU / (constants::NLAYER * 2);
146 int layer = 5 - (linkCRU % constants::NLAYER);
147 int side = (linkCRU / constants::NLAYER) % 2;
148 if (linkSector >= constants::NLINKSPERCRU) {
155 return sector * constants::NHCPERSEC +
stack * constants::NLAYER * 2 +
layer * 2 +
side;
163 int sector = hcid / constants::NHCPERSEC;
170 int mcmCol = (
rob % 2) ?
mcm % constants::NMCMROBINROW + constants::NMCMROBINCOL :
mcm % constants::NMCMROBINROW;
171 return mcmCol * constants::NADCMCM + constants::NADCMCM - 1 - channel;
178 int idx =
getSector(det) * constants::NCHANNELSPERSECTOR;
180 idx +=
getLayer(det) * constants::NCHANNELSPERLAYER;
182 idx += (
getStack(det) < 3) ?
getStack(det) * constants::NCHANNELSC1 : (
getStack(det) - 1) * constants::NCHANNELSC1 + constants::NCHANNELSC0;
193 int sec = idx / constants::NCHANNELSPERSECTOR;
194 int layer = (idx % constants::NCHANNELSPERSECTOR) / constants::NCHANNELSPERLAYER;
195 int stackIndex = ((idx % constants::NCHANNELSPERSECTOR) % constants::NCHANNELSPERLAYER);
196 int stack, chamberIndex;
197 if (stackIndex >= 2 * constants::NCHANNELSC1 + constants::NCHANNELSC0) {
198 stack = 3 + (stackIndex - 2 * constants::NCHANNELSC1 - constants::NCHANNELSC0) / constants::NCHANNELSC1;
199 chamberIndex = (stackIndex - constants::NCHANNELSC0) % constants::NCHANNELSC1;
200 }
else if (stackIndex > 2 * constants::NCHANNELSC1) {
202 chamberIndex = stackIndex - 2 * constants::NCHANNELSC1;
204 stack = stackIndex / constants::NCHANNELSC1;
205 chamberIndex = stackIndex % constants::NCHANNELSC1;
207 int row = chamberIndex / constants::NCHANNELSPERROW;
208 int mcmCol = (chamberIndex % constants::NCHANNELSPERROW) / constants::NADCMCM;
210 rob = (mcmCol >= constants::NMCMROBINCOL) ? (
row / constants::NMCMROBINROW) * 2 + 1 : (
row / constants::NMCMROBINROW) * 2;
211 mcm = (
row % constants::NMCMROBINROW) * constants::NMCMROBINCOL + (mcmCol % constants::NMCMROBINCOL);
212 channel = constants::NADCMCM - 1 - ((chamberIndex % constants::NCHANNELSPERROW) % constants::NADCMCM);
GLenum GLuint GLint GLint layer
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
static int getGlobalChannelIndex(int det, int rob, int mcm, int channel)
static int getROBfromPad(int irow, int icol)
static void getPositionFromGlobalChannelIndex(int idx, int &det, int &rob, int &mcm, int &channel)
static void printSectorStackLayerSide(int hcid)
static std::string getSectorStackLayerSide(int hcid)
static int getColSide(int icol)
static int getDetector(int sector, int stack, int layer)
static int getPadRowFromMCM(int irob, int imcm)
static int getLinkIDfromHCID(int hcid)
static int getStack(int det)
static void printSectorStackLayer(int det)
static int getPadColFromADC(int irob, int imcm, int iadc)
static int getHCIDFromLinkID(int link)
static int getLayer(int det)
static int getSector(int det)
static int getMCMfromPad(int irow, int icol)
static int getROBSide(int irob)
static int getORIinSuperModule(int hcid)
static int getChannelIndexInColumn(int rob, int mcm, int channel)