#include "TGeoManager.h"
#include "TMath.h"
#include "AliConst.h"
#include "AliGeomManager.h"
#include "AliLog.h"
#include "AliTOFGeometry.h"
extern TGeoManager *gGeoManager;
ClassImp(AliTOFGeometry)
const Float_t AliTOFGeometry::fgkZlenA = 370.6*2.;
const Float_t AliTOFGeometry::fgkZlenB = 146.5;
const Float_t AliTOFGeometry::fgkZlenC = 170.45;
const Float_t AliTOFGeometry::fgkMaxhZtof = 370.6;
const Float_t AliTOFGeometry::fgkxTOF = 372.00;
const Float_t AliTOFGeometry::fgkRmin = 371.00;
const Float_t AliTOFGeometry::fgkRmax = 400.05;
const Float_t AliTOFGeometry::fgkXPad = 2.5;
const Float_t AliTOFGeometry::fgkZPad = 3.5;
const Float_t AliTOFGeometry::fgkStripLength = 122.;
const Float_t AliTOFGeometry::fgkSigmaForTail1= 2.;
const Float_t AliTOFGeometry::fgkSigmaForTail2= 0.5;
const Float_t AliTOFGeometry::fgkPhiSec= 20;
Bool_t AliTOFGeometry::fgHoles = 1;
const Float_t AliTOFGeometry::fgkTdcBin = 24.4;
const Float_t AliTOFGeometry::fgkToTBin = 48.8;
const Float_t AliTOFGeometry::fgkBunchCrossingBin = fgkTdcBin * 1024;
const Float_t AliTOFGeometry::fgkSlewTOTMin = 10.;
const Float_t AliTOFGeometry::fgkSlewTOTMax = 16.;
const Float_t AliTOFGeometry::fgkDeadTime = 25E+03;
const Float_t AliTOFGeometry::fgkMatchingWindow = fgkTdcBin*TMath::Power(2,13);
const Float_t AliTOFGeometry::fgkAngles[kNPlates][kMaxNstrip] = {
{ 43.99, 43.20, 42.40, 41.59, 40.77, 39.94, 39.11, 38.25, 37.40, 36.53,
35.65, 34.76, 33.87, 32.96, 32.05, 31.13, 30.19, 29.24, 12.33, 0.00},
{ 27.26, 26.28, 25.30, 24.31, 23.31, 22.31, 21.30, 20.29, 19.26, 18.24,
17.20, 16.16, 15.11, 14.05, 13.00, 11.93, 10.87, 9.80, 8.74, 0.00},
{ 0.00, 6.30, 5.31, 4.25, 3.19, 2.12, 1.06, 0.00, -1.06, -2.12,
-3.19, -4.25, -5.31, -6.30, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00},
{ -8.74, -9.80, -10.87, -11.93, -13.00, -14.05, -15.11, -16.16, -17.20, -18.24,
-19.26, -20.29, -21.30, -22.31, -23.31, -24.31, -25.30, -26.28, -27.26, 0.00},
{-12.33, -29.24, -30.19, -31.13, -32.05, -32.96, -33.87, -34.76, -35.65, -36.53,
-37.40, -38.25, -39.11, -39.94, -40.77, -41.59, -42.40, -43.20, -43.99, 0.00}
};
const Float_t AliTOFGeometry::fgkHeights[kNPlates][kMaxNstrip] = {
{ -8.405, -7.725, -8.405, -7.765, -8.285, -7.745, -7.865, -7.905, -7.895, -7.885,
-7.705, -7.395, -7.525, -7.645, -7.835, -7.965, -8.365, -9.385, -3.255, 0.000 },
{ -7.905, -8.235, -8.605, -9.045, -10.205, -3.975, -5.915, -7.765, -10.205, -3.635,
-5.885, -8.005, -10.505, -4.395, -7.325, -10.235, -4.655, -7.495, -10.515, 0.000 },
{ -2.705, -10.645, -5.165, -10.095, -4.995, -10.085, -4.835, -10.385, -4.835, -10.085,
-4.995, -10.095, -5.165, -10.645, -2.705, 0.000, 0.000, 0.000, 0.000, 0.000 },
{-10.515, -7.495, -4.655, -10.235, -7.325, -4.395, -10.505, -8.005, -5.885, -3.635,
-10.205, -7.765, -5.915, -3.975, -10.205, -9.045, -8.605, -8.235, -7.905, 0.000 },
{ -3.255, -9.385, -8.365, -7.965, -7.835, -7.645, -7.525, -7.395, -7.705, -7.885,
-7.895, -7.905, -7.865, -7.745, -8.285, -7.765, -8.405, -7.725, -8.405, 0.000 }
};
const Float_t AliTOFGeometry::fgkDistances[kNPlates][kMaxNstrip] = {
{ 364.14, 354.88, 344.49, 335.31, 325.44, 316.51, 307.11, 297.91, 288.84, 279.89,
271.20, 262.62, 253.84, 245.20, 236.56, 228.06, 219.46, 210.63, 206.09, 0.00 },
{ 194.57, 186.38, 178.25, 170.13, 161.78, 156.62, 148.10, 139.72, 131.23, 125.87,
117.61, 109.44, 101.29, 95.46, 87.36, 79.37, 73.17, 65.33, 57.71, 0.00 },
{ 49.28, 41.35, 35.37, 27.91, 21.20, 13.94, 7.06, 0.00, -7.06, -13.94,
-21.20, -27.91, -35.37, -41.35, -49.28, 0.00, 0.00, 0.00, 0.00, 0.00 },
{ -57.71, -65.33, -73.17, -79.37, -87.36, -95.46, -101.29, -109.44, -117.61, -125.87,
-131.23, -139.72, -148.10, -156.62, -161.78, -170.13, -178.25, -186.38, -194.57, 0.00 },
{-206.09, -210.63, -219.46, -228.06, -236.56, -245.20, -253.84, -262.62, -271.20, -279.89,
-288.84, -297.91, -307.11, -316.51, -325.44, -335.31, -344.49, -354.88, -364.14, 0.00 }
};
AliTOFGeometry::AliTOFGeometry()
{
}
AliTOFGeometry::~AliTOFGeometry()
{
}
void AliTOFGeometry::ImportGeometry(){
TGeoManager::Import("geometry.root");
}
void AliTOFGeometry::GetPosPar(Int_t *det, Float_t *pos)
{
pos[0]=GetX(det);
pos[1]=GetY(det);
pos[2]=GetZ(det);
}
void AliTOFGeometry::GetDetID( Float_t *pos, Int_t *det)
{
det[0]=GetSector(pos);
det[1]=GetPlate(pos);
det[2]=GetStrip(pos);
det[3]=GetPadZ(pos);
det[4]=GetPadX(pos);
}
void AliTOFGeometry::DetToStripRF(Int_t nPadX, Int_t nPadZ, Float_t &x, Float_t &z) const
{
x = (nPadX - kNpadX*0.5) * fgkXPad;
z = (nPadZ - kNpadZ*0.5) * fgkZPad;
}
Float_t AliTOFGeometry::DistanceToPadPar(Int_t *det, const Float_t * pos, Float_t *dist3d)
{
Float_t x = pos[0];
Float_t y = pos[1];
Float_t z = pos[2];
Float_t radius = TMath::Sqrt(x*x+y*y);
Float_t phi = TMath::Pi()+TMath::ATan2(-y,-x);
Float_t angle = phi*kRaddeg-( Int_t (kRaddeg*phi/fgkPhiSec) + 0.5)*fgkPhiSec;
Float_t xs = radius*TMath::Cos(angle/kRaddeg);
Float_t ys = radius*TMath::Sin(angle/kRaddeg);
Float_t zs = z;
Float_t g[3];
GetPosPar(det,g);
Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
Float_t padPhi = TMath::Pi()+TMath::ATan2(-g[1],-g[0]);
Float_t padAngle = padPhi*kRaddeg-( Int_t (padPhi*kRaddeg/fgkPhiSec)+ 0.5) * fgkPhiSec;
Float_t padxs = padRadius*TMath::Cos(padAngle/kRaddeg);
Float_t padys = padRadius*TMath::Sin(padAngle/kRaddeg);
Float_t padzs = g[2];
Float_t xt = xs-padxs;
Float_t yt = ys-padys;
Float_t zt = zs-padzs;
Float_t alpha = GetAngles(det[1],det[2]);
Float_t xr = xt*TMath::Cos(alpha/kRaddeg)+zt*TMath::Sin(alpha/kRaddeg);
Float_t yr = yt;
Float_t zr = -xt*TMath::Sin(alpha/kRaddeg)+zt*TMath::Cos(alpha/kRaddeg);
Float_t dist = TMath::Sqrt(xr*xr+yr*yr+zr*zr);
if (dist3d){
dist3d[0] = xr;
dist3d[1] = yr;
dist3d[2] = zr;
}
return dist;
}
Bool_t AliTOFGeometry::IsInsideThePadPar(Int_t *det, const Float_t * pos)
{
Bool_t isInside=false;
const Float_t kPadDepth = 0.5;
Float_t x = pos[0];
Float_t y = pos[1];
Float_t z = pos[2];
Float_t radius = TMath::Sqrt(x*x+y*y);
Float_t phi = TMath::Pi()+TMath::ATan2(-y,-x);
Float_t angle = phi*kRaddeg-( Int_t (kRaddeg*phi/fgkPhiSec) + 0.5) *fgkPhiSec;
Float_t xs = radius*TMath::Cos(angle/kRaddeg);
Float_t ys = radius*TMath::Sin(angle/kRaddeg);
Float_t zs = z;
Float_t g[3];
GetPosPar(det,g);
Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
Float_t padPhi = TMath::Pi()+TMath::ATan2(-g[1],-g[0]);
Float_t padAngle = padPhi*kRaddeg-( Int_t (padPhi*kRaddeg/fgkPhiSec)+ 0.5) * fgkPhiSec;
Float_t padxs = padRadius*TMath::Cos(padAngle/kRaddeg);
Float_t padys = padRadius*TMath::Sin(padAngle/kRaddeg);
Float_t padzs = g[2];
Float_t xt = xs-padxs;
Float_t yt = ys-padys;
Float_t zt = zs-padzs;
Float_t alpha = GetAngles(det[1],det[2]);
Float_t xr = xt*TMath::Cos(alpha/kRaddeg)+zt*TMath::Sin(alpha/kRaddeg);
Float_t yr = yt;
Float_t zr = -xt*TMath::Sin(alpha/kRaddeg)+zt*TMath::Cos(alpha/kRaddeg);
if(TMath::Abs(xr)<=kPadDepth*0.5 && TMath::Abs(yr)<= (fgkXPad*0.5) && TMath::Abs(zr)<= (fgkZPad*0.5))
isInside=true;
return isInside;
}
Bool_t AliTOFGeometry::IsInsideThePad(TGeoHMatrix *mat, const Float_t * pos, Float_t *dist3d)
{
const Float_t kPadDepth = 0.5;
Double_t posg[3];
posg[0] = pos[0];
posg[1] = pos[1];
posg[2] = pos[2];
Double_t posl[3] = {0., 0., 0.};
mat->MasterToLocal(posg,posl);
Float_t xr = posl[0];
Float_t yr = posl[1];
Float_t zr = posl[2];
Bool_t isInside = false;
if (TMath::Abs(yr)<= kPadDepth*0.5 &&
TMath::Abs(xr)<= fgkXPad*0.5 &&
TMath::Abs(zr)<= fgkZPad*0.5)
isInside = true;
if (dist3d) {
dist3d[0] = posl[0];
dist3d[1] = posl[1];
dist3d[2] = posl[2];
}
return isInside;
}
void AliTOFGeometry::GetVolumePath(const Int_t * ind, Char_t *path ) {
Int_t sector = ind[0];
const Int_t kSize = 100;
Char_t string1[kSize];
Char_t string2[kSize];
Char_t string3[kSize];
Int_t icopy=-1;
icopy=sector;
snprintf(string1,kSize,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
Int_t iplate=ind[1];
Int_t istrip=ind[2];
if( iplate==0) icopy=istrip;
if( iplate==1) icopy=istrip+NStripC();
if( iplate==2) icopy=istrip+NStripC()+NStripB();
if( iplate==3) icopy=istrip+NStripC()+NStripB()+NStripA();
if( iplate==4) icopy=istrip+NStripC()+2*NStripB()+NStripA();
icopy++;
snprintf(string2,kSize,"FTOA_0/FLTA_0/FSTR_%i",icopy);
if(fgHoles && (sector==13 || sector==14 || sector==15)){
if(iplate<2) snprintf(string2,kSize,"FTOB_0/FLTB_0/FSTR_%i",icopy);
if(iplate>2) snprintf(string2,kSize,"FTOC_0/FLTC_0/FSTR_%i",icopy);
}
Int_t padz = ind[3]+1;
Int_t padx = ind[4]+1;
snprintf(string3,kSize,"FPCB_1/FSEN_1/FSEZ_%i/FPAD_%i",padz,padx);
snprintf(path,2*kSize,"%s/%s/%s",string1,string2,string3);
}
void AliTOFGeometry::GetVolumePath(Int_t sector, Char_t *path ){
const Int_t kSize = 100;
Char_t string[kSize];
Int_t icopy = sector;
snprintf(string,kSize,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
snprintf(path,2*kSize,"%s",string);
}
void AliTOFGeometry::GetVolumePath(Int_t sector, Int_t plate, Int_t strip, Char_t *path ) {
const Int_t kSize = 100;
Char_t string1[kSize];
Char_t string2[kSize];
Char_t string3[kSize];
Int_t icopy = sector;
snprintf(string1,kSize,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1",icopy,icopy);
if(plate==0) icopy=strip;
if(plate==1) icopy=strip+NStripC();
if(plate==2) icopy=strip+NStripC()+NStripB();
if(plate==3) icopy=strip+NStripC()+NStripB()+NStripA();
if(plate==4) icopy=strip+NStripC()+2*NStripB()+NStripA();
icopy++;
snprintf(string2,kSize,"FTOA_0/FLTA_0/FSTR_%i",icopy);
if(fgHoles && (sector==13 || sector==14 || sector==15)){
if(plate<2) snprintf(string2,kSize,"FTOB_0/FLTB_0/FSTR_%i",icopy);
if(plate>2) snprintf(string2,kSize,"FTOC_0/FLTC_0/FSTR_%i",icopy);
}
snprintf(string3,kSize,"FPCB_1/FSEN_1");
snprintf(path,2*kSize,"%s/%s/%s",string1,string2,string3);
}
void AliTOFGeometry::GetPos(Int_t *det, Float_t *pos)
{
Char_t path[200];
GetVolumePath(det,path);
if (!gGeoManager) {
printf("ERROR: no TGeo\n");
}
gGeoManager->cd(path);
TGeoHMatrix global;
global = *gGeoManager->GetCurrentMatrix();
const Double_t *tr = global.GetTranslation();
pos[0]=tr[0];
pos[1]=tr[1];
pos[2]=tr[2];
}
Int_t AliTOFGeometry::GetPlate(const Float_t * pos)
{
const Float_t kInterCentrModBorder1 = 49.5;
const Float_t kInterCentrModBorder2 = 57.5;
const Float_t kExterInterModBorder1 = 196.0;
const Float_t kExterInterModBorder2 = 203.5;
const Float_t kLengthExInModBorder = 4.7;
const Float_t kLengthInCeModBorder = 7.0;
const Float_t kModuleWallThickness = 0.3;
Int_t iPlate=-1;
Float_t posLocal[3];
for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
Int_t isector = GetSector(posLocal);
if(isector == -1){
return iPlate;
}
Double_t angles[6] =
{90., 90.+(isector+0.5)*fgkPhiSec,
0., 0.,
90., (isector+0.5)*fgkPhiSec
};
Rotation(posLocal,angles);
Float_t step[3] = {0., 0., static_cast<Float_t>((fgkRmax+fgkRmin)*0.5)};
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
Rotation(posLocal,angles);
Float_t yLocal = posLocal[1];
Float_t zLocal = posLocal[2];
Float_t deltaRhoLoc = (fgkRmax-fgkRmin)*0.5 - kModuleWallThickness + yLocal;
Float_t deltaZetaLoc = TMath::Abs(zLocal);
Float_t deltaRHOmax = 0.;
if (TMath::Abs(zLocal)>=kExterInterModBorder1 && TMath::Abs(zLocal)<=kExterInterModBorder2)
{
deltaRhoLoc -= kLengthExInModBorder;
deltaZetaLoc = kExterInterModBorder2-deltaZetaLoc;
deltaRHOmax = (fgkRmax - fgkRmin)*0.5 - kModuleWallThickness - 2.*kLengthExInModBorder;
if (deltaRhoLoc > deltaZetaLoc*deltaRHOmax/(kInterCentrModBorder2-kInterCentrModBorder1)) {
if (zLocal<0) iPlate = 0;
else iPlate = 4;
}
else {
if (zLocal<0) iPlate = 1;
else iPlate = 3;
}
}
else if (TMath::Abs(zLocal)>=kInterCentrModBorder1 && TMath::Abs(zLocal)<=kInterCentrModBorder2)
{
deltaRhoLoc -= kLengthInCeModBorder;
deltaZetaLoc = deltaZetaLoc-kInterCentrModBorder1;
deltaRHOmax = (fgkRmax - fgkRmin)*0.5 - kModuleWallThickness - 2.*kLengthInCeModBorder;
if (deltaRhoLoc>deltaZetaLoc*deltaRHOmax/(kInterCentrModBorder2-kInterCentrModBorder1)) iPlate = 2;
else {
if (zLocal<0) iPlate = 1;
else iPlate = 3;
}
}
if (zLocal>-fgkZlenA*0.5 && zLocal<-kExterInterModBorder2) iPlate = 0;
else if (zLocal>-kExterInterModBorder1 && zLocal<-kInterCentrModBorder2) iPlate = 1;
else if (zLocal>-kInterCentrModBorder1 && zLocal< kInterCentrModBorder1) iPlate = 2;
else if (zLocal> kInterCentrModBorder2 && zLocal< kExterInterModBorder1) iPlate = 3;
else if (zLocal> kExterInterModBorder2 && zLocal< fgkZlenA*0.5) iPlate = 4;
return iPlate;
}
Int_t AliTOFGeometry::GetSector(const Float_t * pos)
{
Int_t iSect = -1;
Float_t x = pos[0];
Float_t y = pos[1];
Float_t z = pos[2];
Float_t rho = TMath::Sqrt(x*x + y*y);
if (!((z>=-fgkZlenA*0.5 && z<=fgkZlenA*0.5) &&
(rho>=(fgkRmin) && rho<=(fgkRmax)))) {
return iSect;
}
Float_t phi = TMath::Pi() + TMath::ATan2(-y,-x);
iSect = (Int_t) (phi*kRaddeg/fgkPhiSec);
return iSect;
}
Int_t AliTOFGeometry::GetStrip(const Float_t * pos)
{
const Float_t khhony = 1.0 ;
const Float_t khpcby = 0.08 ;
const Float_t khrgly = 0.055 ;
const Float_t khglfy = 0.285 ;
const Float_t khcpcby = 0.16 ;
const Float_t kwcpcbz = 12.4 ;
const Float_t khstripy = 2.*khhony+2.*khpcby+4.*khrgly+2.*khglfy+khcpcby;
const Float_t kwstripz = kwcpcbz;
const Float_t klstripx = fgkStripLength;
Int_t iStrip=-1;
Float_t posLocal[3];
for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
Int_t isector = GetSector(posLocal);
if(isector == -1){
return iStrip;}
Int_t iplate = GetPlate(posLocal);
if(iplate == -1){
return iStrip;}
Int_t nstrips=0;
switch (iplate) {
case 0:
case 4:
nstrips=kNStripC;
break;
case 1:
case 3:
nstrips=kNStripB;
break;
case 2:
nstrips=kNStripA;
break;
}
Double_t angles[6] =
{90., 90.+(isector+0.5)*fgkPhiSec,
0., 0.,
90., (isector+0.5)*fgkPhiSec
};
Rotation(posLocal,angles);
Float_t step[3] = {0., 0., static_cast<Float_t>((fgkRmax+fgkRmin)*0.5)};
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
Rotation(posLocal,angles);
Int_t totStrip=0;
for (Int_t istrip=0; istrip<nstrips; istrip++){
Float_t posLoc2[3]={posLocal[0],posLocal[1],posLocal[2]};
step[0] = 0.;
step[1] = GetHeights(iplate,istrip);
step[2] = -GetDistances(iplate,istrip);
Translation(posLoc2,step);
if (GetAngles(iplate,istrip) >0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] = GetAngles(iplate,istrip);
angles[5] = 90.;
}
else if (GetAngles(iplate,istrip)==0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.;
angles[3] = 90.;
angles[4] = 0;
angles[5] = 0.;
}
else if (GetAngles(iplate,istrip) <0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] =-GetAngles(iplate,istrip);
angles[5] = 270.;
}
Rotation(posLoc2,angles);
if ((TMath::Abs(posLoc2[0])<=klstripx*0.5) &&
(TMath::Abs(posLoc2[1])<=khstripy*0.5) &&
(TMath::Abs(posLoc2[2])<=kwstripz*0.5)) {
iStrip = istrip;
totStrip++;
for (Int_t jj=0; jj<3; jj++) posLocal[jj]=posLoc2[jj];
break;
}
}
return iStrip;
}
Int_t AliTOFGeometry::GetPadZ(const Float_t * pos)
{
Int_t iPadZ = -1;
Float_t posLocal[3];
for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
Int_t isector = GetSector(posLocal);
if(isector == -1){
return iPadZ;}
Int_t iplate = GetPlate(posLocal);
if(iplate == -1){
return iPadZ;}
Int_t istrip = GetStrip(posLocal);
if(istrip == -1){
return iPadZ;}
Double_t angles[6] =
{90., 90.+(isector+0.5)*fgkPhiSec,
0., 0.,
90., (isector+0.5)*fgkPhiSec
};
Rotation(posLocal,angles);
Float_t step[3] = {0., 0., static_cast<Float_t>((fgkRmax+fgkRmin)*0.5)};
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
Rotation(posLocal,angles);
step[0] = 0.;
step[1] = GetHeights(iplate,istrip);
step[2] = -GetDistances(iplate,istrip);
Translation(posLocal,step);
if (GetAngles(iplate,istrip) >0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] = GetAngles(iplate,istrip);
angles[5] = 90.;
}
else if (GetAngles(iplate,istrip)==0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.;
angles[3] = 90.;
angles[4] = 0;
angles[5] = 0.;
}
else if (GetAngles(iplate,istrip) <0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] =-GetAngles(iplate,istrip);
angles[5] = 270.;
}
Rotation(posLocal,angles);
step[0] =-0.5*kNpadX*fgkXPad;
step[1] = 0.;
step[2] =-0.5*kNpadZ*fgkZPad;
Translation(posLocal,step);
iPadZ = (Int_t)(posLocal[2]/fgkZPad);
if (iPadZ==kNpadZ) iPadZ--;
else if (iPadZ>kNpadZ) iPadZ=-1;
return iPadZ;
}
Int_t AliTOFGeometry::GetPadX(const Float_t * pos)
{
Int_t iPadX = -1;
Float_t posLocal[3];
for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
Int_t isector = GetSector(posLocal);
if(isector == -1){
return iPadX;}
Int_t iplate = GetPlate(posLocal);
if(iplate == -1){
return iPadX;}
Int_t istrip = GetStrip(posLocal);
if(istrip == -1){
return iPadX;}
Double_t angles[6] =
{90., 90.+(isector+0.5)*fgkPhiSec,
0., 0.,
90., (isector+0.5)*fgkPhiSec
};
Rotation(posLocal,angles);
Float_t step[3] = {0., 0., static_cast<Float_t>((fgkRmax+fgkRmin)*0.5)};
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
Rotation(posLocal,angles);
step[0] = 0.;
step[1] = GetHeights(iplate,istrip);
step[2] = -GetDistances(iplate,istrip);
Translation(posLocal,step);
if (GetAngles(iplate,istrip) >0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] = GetAngles(iplate,istrip);
angles[5] = 90.;
}
else if (GetAngles(iplate,istrip)==0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.;
angles[3] = 90.;
angles[4] = 0;
angles[5] = 0.;
}
else if (GetAngles(iplate,istrip) <0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] =-GetAngles(iplate,istrip);
angles[5] = 270.;
}
Rotation(posLocal,angles);
step[0] =-0.5*kNpadX*fgkXPad;
step[1] = 0.;
step[2] =-0.5*kNpadZ*fgkZPad;
Translation(posLocal,step);
iPadX = (Int_t)(posLocal[0]/fgkXPad);
if (iPadX==kNpadX) iPadX--;
else if (iPadX>kNpadX) iPadX=-1;
return iPadX;
}
Float_t AliTOFGeometry::GetX(const Int_t * det)
{
Int_t isector = det[0];
Int_t iplate = det[1];
Int_t istrip = det[2];
Int_t ipadz = det[3];
Int_t ipadx = det[4];
Float_t posLocal[3] = {0., 0., 0.};
Float_t step[3] = {static_cast<Float_t>(-(ipadx+0.5)*fgkXPad), 0., static_cast<Float_t>(-(ipadz+0.5)*fgkZPad)};
Translation(posLocal,step);
step[0] = kNpadX*0.5*fgkXPad;
step[1] = 0.;
step[2] = kNpadZ*0.5*fgkZPad;
Translation(posLocal,step);
Double_t angles[6] = {0.,0.,0.,0.,0.,0.};
if (GetAngles(iplate,istrip) >0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] = GetAngles(iplate,istrip);
angles[5] = 90.;
}
else if (GetAngles(iplate,istrip)==0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.;
angles[3] = 90.;
angles[4] = 0;
angles[5] = 0.;
}
else if (GetAngles(iplate,istrip) <0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] =-GetAngles(iplate,istrip);
angles[5] = 270.;
}
InverseRotation(posLocal,angles);
step[0] = 0.;
step[1] = -GetHeights(iplate,istrip);
step[2] = GetDistances(iplate,istrip);
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
InverseRotation(posLocal,angles);
step[0] = 0.;
step[1] = 0.;
step[2] = -((fgkRmax+fgkRmin)*0.5);
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 90.+(isector+0.5)*fgkPhiSec;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] = (isector+0.5)*fgkPhiSec;
InverseRotation(posLocal,angles);
Float_t xCoor = posLocal[0];
return xCoor;
}
Float_t AliTOFGeometry::GetY(const Int_t * det)
{
Int_t isector = det[0];
Int_t iplate = det[1];
Int_t istrip = det[2];
Int_t ipadz = det[3];
Int_t ipadx = det[4];
Float_t posLocal[3] = {0., 0., 0.};
Float_t step[3] = {static_cast<Float_t>(-(ipadx+0.5)*fgkXPad), 0., static_cast<Float_t>(-(ipadz+0.5)*fgkZPad)};
Translation(posLocal,step);
step[0] = kNpadX*0.5*fgkXPad;
step[1] = 0.;
step[2] = kNpadZ*0.5*fgkZPad;
Translation(posLocal,step);
Double_t angles[6] = {0.,0.,0.,0.,0.,0.};
if (GetAngles(iplate,istrip) >0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] = GetAngles(iplate,istrip);
angles[5] = 90.;
}
else if (GetAngles(iplate,istrip)==0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.;
angles[3] = 90.;
angles[4] = 0;
angles[5] = 0.;
}
else if (GetAngles(iplate,istrip) <0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] =-GetAngles(iplate,istrip);
angles[5] = 270.;
}
InverseRotation(posLocal,angles);
step[0] = 0.;
step[1] = -GetHeights(iplate,istrip);
step[2] = GetDistances(iplate,istrip);
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
InverseRotation(posLocal,angles);
step[0] = 0.;
step[1] = 0.;
step[2] = -((fgkRmax+fgkRmin)*0.5);
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 90.+(isector+0.5)*fgkPhiSec;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] = (isector+0.5)*fgkPhiSec;
InverseRotation(posLocal,angles);
Float_t yCoor = posLocal[1];
return yCoor;
}
Float_t AliTOFGeometry::GetZ(const Int_t * det)
{
Int_t isector = det[0];
Int_t iplate = det[1];
Int_t istrip = det[2];
Int_t ipadz = det[3];
Int_t ipadx = det[4];
Float_t posLocal[3] = {0., 0., 0.};
Float_t step[3] = {static_cast<Float_t>(-(ipadx+0.5)*fgkXPad), 0., static_cast<Float_t>(-(ipadz+0.5)*fgkZPad)};
Translation(posLocal,step);
step[0] = kNpadX*0.5*fgkXPad;
step[1] = 0.;
step[2] = kNpadZ*0.5*fgkZPad;
Translation(posLocal,step);
Double_t angles[6] = {0.,0.,0.,0.,0.,0.};
if (GetAngles(iplate,istrip) >0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] = GetAngles(iplate,istrip);
angles[5] = 90.;
}
else if (GetAngles(iplate,istrip)==0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.;
angles[3] = 90.;
angles[4] = 0;
angles[5] = 0.;
}
else if (GetAngles(iplate,istrip) <0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] =-GetAngles(iplate,istrip);
angles[5] = 270.;
}
InverseRotation(posLocal,angles);
step[0] = 0.;
step[1] = -GetHeights(iplate,istrip);
step[2] = GetDistances(iplate,istrip);
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
InverseRotation(posLocal,angles);
step[0] = 0.;
step[1] = 0.;
step[2] = -((fgkRmax+fgkRmin)*0.5);
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 90.+(isector+0.5)*fgkPhiSec;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] = (isector+0.5)*fgkPhiSec;
InverseRotation(posLocal,angles);
Float_t zCoor = posLocal[2];
return zCoor;
}
void AliTOFGeometry::DetToSectorRF(Int_t vol[5], Double_t coord[4][3])
{
if (!gGeoManager) printf("ERROR: no TGeo\n");
Char_t path1[200];
GetVolumePath(vol[0],path1);
gGeoManager->cd(path1);
TGeoHMatrix aliceToSector;
aliceToSector = *gGeoManager->GetCurrentMatrix();
Char_t path2[200];
GetVolumePath(vol,path2);
gGeoManager->cd(path2);
TGeoHMatrix aliceToPad;
aliceToPad = *gGeoManager->GetCurrentMatrix();
TGeoHMatrix padToALICE = aliceToPad.Inverse();
TGeoHMatrix padToSector = padToALICE*aliceToSector;
Double_t **cornerPad = new Double_t*[4];
for (Int_t ii=0; ii<4; ii++) cornerPad[ii] = new Double_t[3];
cornerPad[0][0] = -fgkXPad/2.;
cornerPad[0][1] = 0.;
cornerPad[0][2] = -fgkZPad/2.;
cornerPad[1][0] = fgkXPad/2.;
cornerPad[1][1] = 0.;
cornerPad[1][2] = -fgkZPad/2.;
cornerPad[2][0] = fgkXPad/2.;
cornerPad[2][1] = 0.;
cornerPad[2][2] = fgkZPad/2.;
cornerPad[3][0] = -fgkXPad/2.;
cornerPad[3][1] = 0.;
cornerPad[3][2] = fgkZPad/2.;
for(Int_t aa=0; aa<4; aa++) for(Int_t bb=0; bb<3; bb++) coord[aa][bb]=0.;
for (Int_t jj=0; jj<4; jj++) padToSector.MasterToLocal(&cornerPad[jj][0], &coord[jj][0]);
delete [] cornerPad;
}
Float_t AliTOFGeometry::GetPadDx(const Float_t * pos)
{
Float_t xpad = -2.;
Float_t posLocal[3];
for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
Int_t isector = GetSector(posLocal);
if(isector == -1){
return xpad;}
Int_t iplate = GetPlate(posLocal);
if(iplate == -1){
return xpad;}
Int_t istrip = GetStrip(posLocal);
if(istrip == -1){
return xpad;}
Int_t ipadz = GetPadZ(posLocal);
if(ipadz == -1){
return xpad;}
Int_t ipadx = GetPadX(posLocal);
if(ipadx == -1){
return xpad;}
Double_t angles[6] =
{90., 90.+(isector+0.5)*fgkPhiSec,
0., 0.,
90., (isector+0.5)*fgkPhiSec
};
Rotation(posLocal,angles);
Float_t step[3] = {0., 0., static_cast<Float_t>((fgkRmax+fgkRmin)*0.5)};
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
Rotation(posLocal,angles);
step[0] = 0.;
step[1] = GetHeights(iplate,istrip);
step[2] = -GetDistances(iplate,istrip);
Translation(posLocal,step);
if (GetAngles(iplate,istrip) >0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] = GetAngles(iplate,istrip);
angles[5] = 90.;
}
else if (GetAngles(iplate,istrip)==0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.;
angles[3] = 90.;
angles[4] = 0;
angles[5] = 0.;
}
else if (GetAngles(iplate,istrip) <0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] =-GetAngles(iplate,istrip);
angles[5] = 270.;
}
Rotation(posLocal,angles);
step[0] =-0.5*kNpadX*fgkXPad;
step[1] = 0.;
step[2] =-0.5*kNpadZ*fgkZPad;
Translation(posLocal,step);
step[0] = (ipadx+0.5)*fgkXPad;
step[1] = 0.;
step[2] = (ipadz+0.5)*fgkZPad;
Translation(posLocal,step);
xpad=posLocal[0];
return xpad;
}
Float_t AliTOFGeometry::GetPadDy(const Float_t * pos)
{
Float_t ypad = -2.;
Float_t posLocal[3];
for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
Int_t isector = GetSector(posLocal);
if(isector == -1){
return ypad;}
Int_t iplate = GetPlate(posLocal);
if(iplate == -1){
return ypad;}
Int_t istrip = GetStrip(posLocal);
if(istrip == -1){
return ypad;}
Int_t ipadz = GetPadZ(posLocal);
if(ipadz == -1){
return ypad;}
Int_t ipadx = GetPadX(posLocal);
if(ipadx == -1){
return ypad;}
Double_t angles[6] =
{90., 90.+(isector+0.5)*fgkPhiSec,
0., 0.,
90., (isector+0.5)*fgkPhiSec
};
Rotation(posLocal,angles);
Float_t step[3] = {0., 0., static_cast<Float_t>((fgkRmax+fgkRmin)*0.5)};
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
Rotation(posLocal,angles);
step[0] = 0.;
step[1] = GetHeights(iplate,istrip);
step[2] = -GetDistances(iplate,istrip);
Translation(posLocal,step);
if (GetAngles(iplate,istrip) >0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] = GetAngles(iplate,istrip);
angles[5] = 90.;
}
else if (GetAngles(iplate,istrip)==0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.;
angles[3] = 90.;
angles[4] = 0;
angles[5] = 0.;
}
else if (GetAngles(iplate,istrip) <0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] =-GetAngles(iplate,istrip);
angles[5] = 270.;
}
Rotation(posLocal,angles);
step[0] =-0.5*kNpadX*fgkXPad;
step[1] = 0.;
step[2] =-0.5*kNpadZ*fgkZPad;
Translation(posLocal,step);
step[0] = (ipadx+0.5)*fgkXPad;
step[1] = 0.;
step[2] = (ipadz+0.5)*fgkZPad;
Translation(posLocal,step);
ypad=posLocal[1];
return ypad;
}
Float_t AliTOFGeometry::GetPadDz(const Float_t * pos)
{
Float_t zpad = -2.;
Float_t posLocal[3];
for (Int_t ii=0; ii<3; ii++) posLocal[ii] = pos[ii];
Int_t isector = GetSector(posLocal);
if(isector == -1){
return zpad;}
Int_t iplate = GetPlate(posLocal);
if(iplate == -1){
return zpad;}
Int_t istrip = GetStrip(posLocal);
if(istrip == -1){
return zpad;}
Int_t ipadz = GetPadZ(posLocal);
if(ipadz == -1){
return zpad;}
Int_t ipadx = GetPadX(posLocal);
if(ipadx == -1){
return zpad;}
Double_t angles[6] =
{90., 90.+(isector+0.5)*fgkPhiSec,
0., 0.,
90., (isector+0.5)*fgkPhiSec
};
Rotation(posLocal,angles);
Float_t step[3] = {0., 0., static_cast<Float_t>((fgkRmax+fgkRmin)*0.5)};
Translation(posLocal,step);
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 0.;
angles[3] = 0.;
angles[4] = 90.;
angles[5] =270.;
Rotation(posLocal,angles);
step[0] = 0.;
step[1] = GetHeights(iplate,istrip);
step[2] = -GetDistances(iplate,istrip);
Translation(posLocal,step);
if (GetAngles(iplate,istrip) >0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] = GetAngles(iplate,istrip);
angles[5] = 90.;
}
else if (GetAngles(iplate,istrip)==0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.;
angles[3] = 90.;
angles[4] = 0;
angles[5] = 0.;
}
else if (GetAngles(iplate,istrip) <0.) {
angles[0] = 90.;
angles[1] = 0.;
angles[2] = 90.+GetAngles(iplate,istrip);
angles[3] = 90.;
angles[4] =-GetAngles(iplate,istrip);
angles[5] = 270.;
}
Rotation(posLocal,angles);
step[0] =-0.5*kNpadX*fgkXPad;
step[1] = 0.;
step[2] =-0.5*kNpadZ*fgkZPad;
Translation(posLocal,step);
step[0] = (ipadx+0.5)*fgkXPad;
step[1] = 0.;
step[2] = (ipadz+0.5)*fgkZPad;
Translation(posLocal,step);
zpad=posLocal[2];
return zpad;
}
void AliTOFGeometry::Translation(Float_t *xyz, Float_t translationVector[3])
{
Int_t ii=0;
for (ii=0; ii<3; ii++)
xyz[ii] -= translationVector[ii];
return;
}
void AliTOFGeometry::Rotation(Float_t *xyz, Double_t rotationAngles[6])
{
Int_t ii=0;
for (ii=0; ii<6; ii++) rotationAngles[ii]*=kDegrad;
Float_t xyzDummy[3] = {0., 0., 0.};
for (ii=0; ii<3; ii++) {
xyzDummy[ii] =
xyz[0]*TMath::Sin(rotationAngles[2*ii])*TMath::Cos(rotationAngles[2*ii+1]) +
xyz[1]*TMath::Sin(rotationAngles[2*ii])*TMath::Sin(rotationAngles[2*ii+1]) +
xyz[2]*TMath::Cos(rotationAngles[2*ii]);
}
for (ii=0; ii<3; ii++) xyz[ii]=xyzDummy[ii];
return;
}
void AliTOFGeometry::InverseRotation(Float_t *xyz, Double_t rotationAngles[6])
{
Int_t ii=0;
for (ii=0; ii<6; ii++) rotationAngles[ii]*=kDegrad;
Float_t xyzDummy[3] = {0., 0., 0.};
xyzDummy[0] =
xyz[0]*TMath::Sin(rotationAngles[0])*TMath::Cos(rotationAngles[1]) +
xyz[1]*TMath::Sin(rotationAngles[2])*TMath::Cos(rotationAngles[3]) +
xyz[2]*TMath::Sin(rotationAngles[4])*TMath::Cos(rotationAngles[5]);
xyzDummy[1] =
xyz[0]*TMath::Sin(rotationAngles[0])*TMath::Sin(rotationAngles[1]) +
xyz[1]*TMath::Sin(rotationAngles[2])*TMath::Sin(rotationAngles[3]) +
xyz[2]*TMath::Sin(rotationAngles[4])*TMath::Sin(rotationAngles[5]);
xyzDummy[2] =
xyz[0]*TMath::Cos(rotationAngles[0]) +
xyz[1]*TMath::Cos(rotationAngles[2]) +
xyz[2]*TMath::Cos(rotationAngles[4]);
for (ii=0; ii<3; ii++) xyz[ii]=xyzDummy[ii];
return;
}
Int_t AliTOFGeometry::GetIndex(const Int_t * detId)
{
Int_t isector = detId[0];
if (isector >= kNSectors){
printf("Wrong sector number in TOF (%d) !\n",isector);
return -1;
}
Int_t iplate = detId[1];
if (iplate >= kNPlates){
printf("Wrong plate number in TOF (%d) !\n",iplate);
return -1;
}
Int_t istrip = detId[2];
Int_t stripOffset = GetStripNumberPerSM(iplate,istrip);
if (stripOffset==-1) {
printf("Wrong strip number per SM in TOF (%d) !\n",stripOffset);
return -1;
}
Int_t ipadz = detId[3];
Int_t ipadx = detId[4];
Int_t idet = ((2*(kNStripC+kNStripB)+kNStripA)*kNpadZ*kNpadX)*isector +
(stripOffset*kNpadZ*kNpadX)+
(kNpadX)*ipadz+
ipadx;
return idet;
}
void AliTOFGeometry::GetVolumeIndices(Int_t index, Int_t *detId)
{
detId[0] = index/NpadXStrip()/NStripXSector();
Int_t dummyStripPerModule =
( index - ( NStripXSector()*NpadXStrip()*detId[0]) ) / NpadXStrip();
if (dummyStripPerModule<kNStripC) {
detId[1] = 0;
detId[2] = dummyStripPerModule;
}
else if (dummyStripPerModule>=kNStripC && dummyStripPerModule<kNStripC+kNStripB) {
detId[1] = 1;
detId[2] = dummyStripPerModule-kNStripC;
}
else if (dummyStripPerModule>=kNStripC+kNStripB && dummyStripPerModule<kNStripC+kNStripB+kNStripA) {
detId[1] = 2;
detId[2] = dummyStripPerModule-kNStripC-kNStripB;
}
else if (dummyStripPerModule>=kNStripC+kNStripB+kNStripA && dummyStripPerModule<kNStripC+kNStripB+kNStripA+kNStripB) {
detId[1] = 3;
detId[2] = dummyStripPerModule-kNStripC-kNStripB-kNStripA;
}
else if (dummyStripPerModule>=kNStripC+kNStripB+kNStripA+kNStripB && dummyStripPerModule<NStripXSector()) {
detId[1] = 4;
detId[2] = dummyStripPerModule-kNStripC-kNStripB-kNStripA-kNStripB;
}
Int_t padPerStrip = ( index - ( NStripXSector()*NpadXStrip()*detId[0]) ) - dummyStripPerModule*NpadXStrip();
detId[3] = padPerStrip / kNpadX;
detId[4] = padPerStrip - detId[3]*kNpadX;
}
Int_t AliTOFGeometry::NStrip(Int_t nPlate)
{
Int_t nStrips = kNStripC;
switch(nPlate) {
case 2:
nStrips = kNStripA;
break;
case 1:
case 3:
nStrips = kNStripB;
break;
case 0:
case 4:
default:
nStrips = kNStripC;
break;
}
return nStrips;
}
UShort_t AliTOFGeometry::GetAliSensVolIndex(Int_t isector, Int_t iplate, Int_t istrip)
{
Int_t index = GetStripNumber(isector, iplate, istrip);
UShort_t volIndex = AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,index);
return volIndex;
}
Int_t AliTOFGeometry::GetStripNumber(Int_t isector, Int_t iplate, Int_t istrip)
{
Bool_t check = (isector >= kNSectors);
if (check)
printf("E-AliTOFGeometry::GetStripNumber: Wrong sector number in TOF (%d)!\n",isector);
Int_t index = -1;
Int_t stripInSM = GetStripNumberPerSM(iplate, istrip);
if (!check && stripInSM!=-1)
index = (2*(kNStripC+kNStripB)+kNStripA)*isector + stripInSM;
return index;
}
void AliTOFGeometry::GetStripAndModule(Int_t iStripPerSM, Int_t &iplate, Int_t &istrip)
{
if (iStripPerSM<0 || iStripPerSM>=kNStripC+kNStripB+kNStripA+kNStripB+kNStripC) {
iplate = -1;
istrip = -1;
}
else if (iStripPerSM<kNStripC) {
iplate = 0;
istrip = iStripPerSM;
}
else if (iStripPerSM>=kNStripC && iStripPerSM<kNStripC+kNStripB) {
iplate = 1;
istrip = iStripPerSM-kNStripC;
}
else if (iStripPerSM>=kNStripC+kNStripB && iStripPerSM<kNStripC+kNStripB+kNStripA) {
iplate = 2;
istrip = iStripPerSM-kNStripC-kNStripB;
}
else if (iStripPerSM>=kNStripC+kNStripB+kNStripA && iStripPerSM<kNStripC+kNStripB+kNStripA+kNStripB) {
iplate = 3;
istrip = iStripPerSM-kNStripC-kNStripB-kNStripA;
}
else if (iStripPerSM>=kNStripC+kNStripB+kNStripA+kNStripB && iStripPerSM<kNStripC+kNStripB+kNStripA+kNStripB+kNStripC) {
iplate = 4;
istrip = iStripPerSM-kNStripC-kNStripB-kNStripA-kNStripB;
}
}
Int_t AliTOFGeometry::GetStripNumberPerSM(Int_t iplate, Int_t istrip)
{
Int_t index = -1;
Bool_t check = (
(iplate<0 || iplate>=kNPlates)
||
(
(iplate==2 && (istrip<0 || istrip>=kNStripA))
||
(iplate!=2 && (istrip<0 || istrip>=kNStripC))
)
);
if (iplate<0 || iplate>=kNPlates)
printf("E-AliTOFGeometry::GetStripNumberPerSM: Wrong plate number in TOF (%1d)!\n",iplate);
if (
(iplate==2 && (istrip<0 || istrip>=kNStripA))
||
(iplate!=2 && (istrip<0 || istrip>=kNStripC))
)
printf("E-AliTOFGeometry::GetStripNumberPerSM: Wrong strip number in TOF "
"(strip=%2d in the plate=%1d)!\n",istrip,iplate);
Int_t stripOffset = 0;
switch (iplate) {
case 0:
stripOffset = 0;
break;
case 1:
stripOffset = kNStripC;
break;
case 2:
stripOffset = kNStripC+kNStripB;
break;
case 3:
stripOffset = kNStripC+kNStripB+kNStripA;
break;
case 4:
stripOffset = kNStripC+kNStripB+kNStripA+kNStripB;
break;
};
if (!check) index = stripOffset + istrip;
return index;
}
void AliTOFGeometry::PadRF2TrackingRF(Float_t *ctrackPos, Float_t *differenceT)
{
for (Int_t ii=0; ii<3; ii++) differenceT[ii] = 999.;
AliDebug(1,Form(" track position in ALICE global Ref. frame -> %f, %f, %f",
ctrackPos[0],ctrackPos[1],ctrackPos[2]));
Int_t detId[5] = {-1,-1,-1,-1,-1};
detId[0] = GetSector(ctrackPos);
if (detId[0]==-1) {
AliWarning(Form("This point does not belong to any TOF sector"));
return;
}
detId[1] = GetPlate(ctrackPos);
if (detId[1]==-1) {
AliWarning(Form("This point does not belong to any TOF module"));
return;
}
detId[2] = GetStrip(ctrackPos);
if (detId[2]==-1) {
AliWarning(Form("This point does not belong to any TOF strip"));
return;
}
detId[3] = GetPadZ(ctrackPos);
if (detId[3]==-1) {
AliWarning(Form("This point does not belong to any TOF pad-row"));
return;
}
detId[4] = GetPadX(ctrackPos);
if (detId[4]==-1) {
AliWarning(Form("This point does not belong to any TOF pad"));
return;
}
UShort_t alignableStripIndex =
GetAliSensVolIndex(detId[0],detId[1],detId[2]);
AliDebug(1,Form(" sector = %2d, plate = %1d, strip = %2d (padZ = %1d, padX = %2d) "
"---> stripIndex = %4d",
detId[0], detId[1], detId[2], detId[3], detId[4], alignableStripIndex));
Double_t padCentreL[3] = {(detId[4]-AliTOFGeometry::NpadX()/2)*AliTOFGeometry::XPad()
+AliTOFGeometry::XPad()/2.,
0.,
(detId[3]-AliTOFGeometry::NpadZ()/2)*AliTOFGeometry::XPad()
+AliTOFGeometry::XPad()/2.};
Double_t padCentreT[3] = {0., 0., 0.};
TGeoHMatrix l2t = *AliGeomManager::GetTracking2LocalMatrix(alignableStripIndex);
l2t.MasterToLocal(padCentreL,padCentreT);
Char_t path[200];
Double_t padCentreL2[3] = {0., 0., 0.};
Double_t padCentreG[3] = {0., 0., 0.};
GetVolumePath(detId,path);
gGeoManager->cd(path);
TGeoHMatrix g2l = *gGeoManager->GetCurrentMatrix();
TGeoHMatrix l2g = g2l.Inverse();
l2g.MasterToLocal(padCentreL2,padCentreG);
Char_t path2[200];
Double_t stripCentreL[3] = {0., 0., 0.};
Double_t stripCentreG[3] = {0., 0., 0.};
GetVolumePath(detId[0],detId[1],detId[2],path2);
gGeoManager->cd(path2);
TGeoHMatrix g2lb = *gGeoManager->GetCurrentMatrix();
TGeoHMatrix l2gb = g2lb.Inverse();
l2gb.MasterToLocal(stripCentreL,stripCentreG);
TGeoHMatrix g2t = 0;
AliGeomManager::GetTrackingMatrix(alignableStripIndex, g2t);
Double_t posG[3];
for (Int_t ii=0; ii<3; ii++) posG[ii] = (Double_t)ctrackPos[ii];
Double_t stripCentreT[3] = {0., 0., 0.};
Double_t posT[3] = {0., 0., 0.};
g2t.MasterToLocal(posG,posT);
g2t.MasterToLocal(stripCentreG,stripCentreT);
for (Int_t ii=0; ii<3; ii++)
AliDebug(1,Form(" track position in ALICE global and tracking RFs -> posG[%d] = %f --- posT[%d] = %f",
ii, posG[ii], ii, posT[ii]));
for (Int_t ii=0; ii<3; ii++)
AliDebug(1,Form(" pad centre coordinates in its, the ALICE global and tracking RFs -> "
"padCentreL[%d] = %f --- padCentreG[%d] = %f --- padCentreT[%d] = %f",
ii, padCentreL[ii],
ii, padCentreG[ii],
ii, padCentreT[ii]));
for (Int_t ii=0; ii<3; ii++)
AliDebug(1,Form(" strip centre coordinates in its, the ALICE global and tracking RFs -> "
"stripCentreL[%d] = %f --- stripCentreG[%d] = %f --- stripCentreT[%d] = %f",
ii, stripCentreL[ii],
ii, stripCentreG[ii],
ii, stripCentreT[ii]));
for (Int_t ii=0; ii<3; ii++)
AliDebug(1,Form(" difference between the track position and the pad centre in the tracking RF "
"-> posT[%d]-padCentreT[%d] = %f",
ii,ii,
posT[ii]-padCentreT[ii]));
for (Int_t ii=0; ii<3; ii++) differenceT[ii] = (Float_t)(posT[ii]-padCentreT[ii]);
}
Int_t AliTOFGeometry::GetTOFsupermodule(Int_t index)
{
if (index<0 || index>=NPadXSector()*NSectors()) return -1;
else return index/NpadXStrip()/NStripXSector();
}