32#include <TGeoManager.h>
33#include <TGeoPhysicalNode.h>
35#include <TVirtualMC.h>
36#include <fairlogger/Logger.h>
55FeeParam* FeeParam::mgInstance =
nullptr;
67 if (mgInstance ==
nullptr) {
83 for (
int j = 0;
j < constants::NLAYER; ++
j) {
84 mInvX[
j] = 1. / mX[
j];
85 mInvWidthPad[
j] = 1. / mWidthPad[
j];
86 mTiltingAngleTan[
j] = std::tan(mTiltingAngle[
j] * M_PI / 180.0);
89 fillPad2MCMLookUpTable();
132 if (iadc < 0 || iadc > NADCMCM) {
135 int mcmcol = imcm % NMCMROBINCOL +
getROBSide(irob) * NMCMROBINCOL;
136 int padcol = mcmcol * NADCMCM + NCOLMCM + 2 - iadc;
160 if (irow < 0 || icol < 0 || irow > NROWC1 || icol > NCOLUMN + 8 * 3) {
164 int adc = 20 - (icol % 18) - 1;
180 return (icol % (NCOLUMN / 2)) / NCOLMCM + NMCMROBINCOL * (irow % NMCMROBINROW);
200 return (irow / NMCMROBINROW) * 2 +
getColSide(icol + 5);
202 return (irow / NMCMROBINROW) * 2 +
getColSide(icol - 5);
228 return ((1 << 10) | (
rob << 7) | aliid);
234int FeeParam::extAliToAli(
unsigned int dest,
unsigned short linkpair,
unsigned short rocType,
int* mcmList,
int listSize)
243 unsigned int mcm,
rob, robAB;
244 unsigned int cmA = 0, cmB = 0;
247 const unsigned int gkChipmaskDefLp[4] = {0x1FFFF, 0x1FFFF, 0x3FFFF, 0x1FFFF};
266 }
else if ((
mcm & 0x40) != 0) {
267 if ((
mcm & 0x01) != 0) {
271 if ((
mcm & 0x02) != 0) {
275 if ((
mcm & 0x04) != 0 && rocType == 0) {
279 if ((
mcm & 0x08) != 0 && rocType == 1) {
283 if ((
mcm & 0x10) != 0) {
287 if ((
mcm & 0x20) != 0) {
297 cmA &= gkChipmaskDefLp[linkpair];
298 cmB &= gkChipmaskDefLp[linkpair];
306 if (robAB == 4 && linkpair != 2) {
320 if ((robsel & 0x8) != 0) {
322 if ((robsel % 2) == 0 && (robsel / 2) == linkpair) {
325 if ((robsel % 2) == 1 && (robsel / 2) == linkpair) {
397 halfchamberside = (
link / 6) % 2;
402 halfchamberside = (
link / 6) % 2;
415 for (
i = 0;
i < 18;
i++) {
416 if ((cmA & (1 <<
i)) != 0 && nmcm < listSize) {
417 mcmList[nmcm] = ((linkpair * 2) << 7) |
i;
420 if ((cmB & (1 <<
i)) != 0 && nmcm < listSize) {
421 mcmList[nmcm] = ((linkpair * 2 + 1) << 7) |
i;
438 if (rawver >= 0 && rawver <= mkMaxRAWversion) {
439 mRAWversion = rawver;
441 LOG(error) <<
"Raw version is out of range: " << rawver;
449void FeeParam::fillPad2MCMLookUpTable()
455 for (
int mcm = 0;
mcm < NMCMROBINCOL * 2;
mcm++) {
456 int lowerlimit =
mcm * NCOLMCM;
457 int upperlimit = NCOLMCM +
mcm * NCOLMCM;
458 int shiftposition = 1 + 3 *
mcm;
460 mLUTPadNumbering[
index] =
index + shiftposition;
470 int layer = det % NLAYER;
472 float dyTilt = (mDriftLength * std::tan(mTiltingAngle[
layer] * M_PI / 180.) *
476 float dyCorr = -mOmegaTau * mDriftLength;
482 return (
int)TMath::Nint(dyCorr * mScalePad * mInvWidthPad[
layer]);
486 int& dyMinInt,
int& dyMaxInt)
const
494 if (std::abs(mMagField) < 0.1) {
501 (e * 1e-2 * std::abs(mMagField) * mInvPtMin);
504 if (maxDeflTemp < std::cos(phi)) {
505 float maxDeflAngle = std::asin(maxDeflTemp);
507 float dyMin = (mDriftLength *
508 std::tan(phi - maxDeflAngle));
510 dyMinInt = int(dyMin / mBinDy);
512 if (dyMinInt < mDyMin) {
514 }
else if (dyMinInt > mDyMax) {
518 float dyMax = (mDriftLength *
519 std::tan(phi + maxDeflAngle));
521 dyMaxInt = int(dyMax / mBinDy);
523 if (dyMaxInt > mDyMax) {
525 }
else if (dyMaxInt < mDyMin) {
528 }
else if (maxDeflTemp < 0.) {
530 printf(
"Inconsistent calculation of sin(alpha): %f\n", maxDeflTemp);
536 if ((dyMaxInt - dyMinInt) <= 0) {
537 LOG(
debug) <<
"strange dy range: [" << dyMinInt <<
"," << dyMaxInt <<
"], using max range now";
548 int layer = det % NLAYER;
553 if (elongation < 0.001) {
560 unsigned int& cor0,
unsigned int& cor1,
float gain)
const
564 if (mPidGainCorr ==
true) {
568 if (mPidTracklengthCorr ==
true) {
570 cor0 = (
unsigned int)(mScaleQ0 * InvElongationOverGain);
571 cor1 = (
unsigned int)(mScaleQ1 * InvElongationOverGain);
573 cor0 = (
unsigned int)(mScaleQ0 * Invgain);
574 cor1 = (
unsigned int)(mScaleQ1 * Invgain);
589 int layer = det % NLAYER;
597 int layer = det % NLAYER;
599 float ypos = (-4 + 1 + (
rob & 0x1) * 4 + (
mcm & 0x3)) * 18 - ch - 0.5;
600 return ypos * mWidthPad[
layer];
607 int stack = (det % NCHAMBERPERSEC) / NLAYER;
608 int layer = det % NLAYER;
613 return (mZrow[
layer * NLAYER +
stack] - 0.5 * mLengthOuterPadC0);
614 }
else if (
row == 11) {
615 return (mZrow[
layer * NLAYER +
stack] - 1.5 * mLengthOuterPadC0 - (
row - 1) * mLengthInnerPadC0);
617 return (mZrow[
layer * NLAYER +
stack] - mLengthOuterPadC0 - (
row - 0.5) * mLengthInnerPadC0);
621 return (mZrow[
layer * NLAYER +
stack] - 0.5 * mLengthOuterPadC1[
layer]);
622 }
else if (
row == 15) {
623 return (mZrow[
layer * NLAYER +
stack] - 1.5 * mLengthOuterPadC1[
layer] - (
row - 1) * mLengthInnerPadC1[
layer]);
637 return std::sqrt(
y *
y +
x *
x);
655 return std::sqrt(
y *
y +
x *
x +
z *
z);
Definition of the GeometryManager class.
static int getROBSide(int irob)
static int getPadRowFromMCM(int irob, int imcm)
void setRAWversion(int rawver)
float getElongation(int det, int rob, int mcm, int) const
static int getPadColFromADC(int irob, int imcm, int iadc)
void getDyRange(int det, int rob, int mcm, int ch, int &dyMinInt, int &dyMaxInt) const
static int getROBfromPad(int irow, int icol)
void getCorrectionFactors(int det, int rob, int mcm, int ch, unsigned int &cor0, unsigned int &cor1, float gain=1.) const
static int getExtendedPadColFromADC(int irob, int imcm, int iadc)
float getLocalY(int det, int rob, int mcm, int ch) const
static int getMCMfromSharedPad(int irow, int icol)
float getX(int det, int rob, int mcm) const
static short getRobAB(unsigned short robsel, unsigned short linkpair)
static int extAliToAli(unsigned int dest, unsigned short linkpair, unsigned short rocType, int *list, int listSize)
static short chipmaskToMCMlist(unsigned int cmA, unsigned int cmB, unsigned short linkpair, int *mcmList, int listSize)
static unsigned int aliToExtAli(int rob, int aliid)
float getDist(int det, int rob, int mcm, int ch) const
static FeeParam * instance()
float getPerp(int det, int rob, int mcm, int ch) const
static int getColSide(int icol)
static void unpackORI(int link, int side, int &stack, int &layer, int &halfchamberside)
static int getMCMfromPad(int irow, int icol)
int getDyCorrection(int det, int rob, int mcm) const
float getLocalZ(int det, int rob, int mcm) const
static int getROBfromSharedPad(int irow, int icol)
float getPhi(int det, int rob, int mcm, int ch) const
GLenum GLuint GLint GLint layer
GLdouble GLdouble GLdouble z
static int getROBfromPad(int irow, int icol)
static int getColSide(int icol)
static int getPadRowFromMCM(int irob, int imcm)
static int getPadColFromADC(int irob, int imcm, int iadc)
static int getMCMfromPad(int irow, int icol)
static int getROBSide(int irob)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"