+Int_t AliTOFGeometry::GetPadZ(Float_t *pos) const
+{
+ //
+ // Returns the Pad index along Z
+ //
+ //const Float_t klsensmx = kNpadX*fgkXPad; // length of Sensitive Layer
+ //const Float_t khsensmy = 0.05;//0.11;//0.16;// heigth of Sensitive Layer
+ //const Float_t kwsensmz = kNpadZ*fgkZPad; // width of Sensitive Layer
+
+ 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){
+ //AliError("Detector Index could not be determined");
+ return iPadZ;}
+ Int_t iplate = GetPlate(posLocal);
+ if(iplate == -1){
+ //AliError("Detector Index could not be determined");
+ return iPadZ;}
+ Int_t istrip = GetStrip(posLocal);
+ if(istrip == -1){
+ //AliError("Detector Index could not be determined");
+ return iPadZ;}
+
+ // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
+ 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., (fgkRmax+fgkRmin)*0.5};
+ Translation(posLocal,step);
+
+ // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA = FLTA reference frame
+ angles[0] = 90.;
+ angles[1] = 0.;
+ angles[2] = 0.;
+ angles[3] = 0.;
+ angles[4] = 90.;
+ angles[5] =270.;
+
+ Rotation(posLocal,angles);
+
+ // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
+ 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);
+
+ //if (TMath::Abs(posLocal[0])<=klsensmx*0.5 && /*TMath::Abs(posLocal[1])<=khsensmy*0.5+0.005 &&*/ TMath::Abs(posLocal[2])<=kwsensmz*0.5) {
+ //if (TMath::Abs(posLocal[1])<=khsensmy*0.5) {
+
+ 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;
+
+ //}
+ // else AliError("Detector Index could not be determined");
+
+ return iPadZ;
+
+}
+//_____________________________________________________________________________
+Int_t AliTOFGeometry::GetPadX(Float_t *pos) const
+{
+ //
+ // Returns the Pad index along X
+ //
+ //const Float_t klsensmx = kNpadX*fgkXPad; // length of Sensitive Layer
+ //const Float_t khsensmy = 0.05;//0.11;//0.16;// heigth of Sensitive Layer
+ //const Float_t kwsensmz = kNpadZ*fgkZPad; // width of Sensitive Layer
+
+ 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){
+ //AliError("Detector Index could not be determined");
+ return iPadX;}
+ Int_t iplate = GetPlate(posLocal);
+ if(iplate == -1){
+ //AliError("Detector Index could not be determined");
+ return iPadX;}
+ Int_t istrip = GetStrip(posLocal);
+ if(istrip == -1){
+ //AliError("Detector Index could not be determined");
+ return iPadX;}
+
+ // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
+ 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., (fgkRmax+fgkRmin)*0.5};
+ Translation(posLocal,step);
+
+ // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA/B/C = FLTA/B/C reference frame
+ angles[0] = 90.;
+ angles[1] = 0.;
+ angles[2] = 0.;
+ angles[3] = 0.;
+ angles[4] = 90.;
+ angles[5] =270.;
+
+ Rotation(posLocal,angles);
+
+ // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
+ 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);
+
+ //if (TMath::Abs(posLocal[0])<=klsensmx*0.5 && /*TMath::Abs(posLocal[1])<=khsensmy*0.5+0.005 &&*/ TMath::Abs(posLocal[2])<=kwsensmz*0.5) {
+ //if (TMath::Abs(posLocal[1])<=khsensmy*0.5) {
+
+ 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;
+
+ //}
+ //else AliError("Detector Index could not be determined");
+
+ return iPadX;
+
+}
+//_____________________________________________________________________________
+Float_t AliTOFGeometry::GetX(Int_t *det) const
+{
+ //
+ // Returns X coordinate (cm)
+ //
+
+ 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];
+
+ /*
+ // Find out distance d on the plane wrt median phi:
+ Float_t d = (ipadx+0.5-kNpadX*0.5)*fgkXPad;
+
+ // The radius r in xy plane:
+ //Float_t r = (fgkRmin+fgkRmax)*0.5-0.01+GetHeights(iplate,istrip)+
+ // (ipadz-0.5)*fgkZPad*TMath::Sin(GetAngles(iplate,istrip)/kRaddeg)-0.25; ???
+ Float_t r = (fgkRmin+fgkRmax)*0.5-0.01+GetHeights(iplate,istrip)+
+ (ipadz-0.5)*fgkZPad*TMath::Sin(GetAngles(iplate,istrip)/kRaddeg);
+
+ // local azimuthal angle in the sector philoc
+ Float_t philoc = TMath::ATan(d/r);
+ //if(philoc<0.) philoc = k2PI + philoc;
+
+ // azimuthal angle in the global frame phi
+ Float_t phi = philoc*kRaddeg+(isector+0.5)*fgkPhiSec;
+
+ Float_t xCoor = r/TMath::Cos(philoc)*TMath::Cos(phi/kRaddeg);
+ */
+
+ // Pad reference frame -> FSTR reference frame
+ // /*
+ Float_t posLocal[3] = {0., 0., 0.};
+ Float_t step[3] = {-(ipadx+0.5)*fgkXPad, 0., -(ipadz+0.5)*fgkZPad};
+ Translation(posLocal,step);
+
+ step[0] = kNpadX*0.5*fgkXPad;
+ step[1] = 0.;
+ step[2] = kNpadZ*0.5*fgkZPad;
+ // */
+ /*
+ Float_t posLocal[3] = {(ipadx+0.5)*fgkXPad, 0., (ipadz+0.5)*fgkZPad};
+ Float_t step[3]= {kNpadX*0.5*fgkXPad, 0., kNpadZ*0.5*fgkZPad};
+ */
+ Translation(posLocal,step);
+
+ // FSTR reference frame -> FTOA/B/C = FLTA/B/C reference frame
+ Double_t angles[6];
+ 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);
+
+ // FTOA = FLTA reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
+ angles[0] = 90.;
+ angles[1] = 0.;
+ angles[2] = 0.;
+ angles[3] = 0.;
+ angles[4] = 90.;
+ angles[5] =270.;
+
+ InverseRotation(posLocal,angles);
+
+ // B071/B074/B075 = BTO1/2/3 reference frame -> ALICE reference frame
+ 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(Int_t *det) const
+{
+ //
+ // Returns Y coordinate (cm)
+ //
+
+ 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];
+
+ /*
+ // Find out distance d on the plane wrt median phi:
+ Float_t d = (ipadx+0.5-kNpadX*0.5)*fgkXPad;
+
+ // The radius r in xy plane:
+ //Float_t r = (fgkRmin+fgkRmax)*0.5-0.01+GetHeights(iplate,istrip)+
+ // (ipadz-0.5)*fgkZPad*TMath::Sin(GetAngles(iplate,istrip)/kRaddeg)-0.25; ???
+ Float_t r = (fgkRmin+fgkRmax)*0.5-0.01+GetHeights(iplate,istrip)+
+ (ipadz-0.5)*fgkZPad*TMath::Sin(GetAngles(iplate,istrip)/kRaddeg);
+
+ // local azimuthal angle in the sector philoc
+ Float_t philoc = TMath::ATan(d/r);
+ //if(philoc<0.) philoc = k2PI + philoc;
+
+ // azimuthal angle in the global frame phi
+ Float_t phi = philoc*kRaddeg+(isector+0.5)*fgkPhiSec;
+
+ Float_t yCoor = r/TMath::Cos(philoc)*TMath::Sin(phi/kRaddeg);
+ */
+
+ // Pad reference frame -> FSTR reference frame
+ // /*
+ Float_t posLocal[3] = {0., 0., 0.};
+ Float_t step[3] = {-(ipadx+0.5)*fgkXPad, 0., -(ipadz+0.5)*fgkZPad};
+ Translation(posLocal,step);
+
+ step[0] = kNpadX*0.5*fgkXPad;
+ step[1] = 0.;
+ step[2] = kNpadZ*0.5*fgkZPad;
+ // */
+ /*
+ Float_t posLocal[3] = {(ipadx+0.5)*fgkXPad, 0., (ipadz+0.5)*fgkZPad};
+ Float_t step[3]= {kNpadX*0.5*fgkXPad, 0., kNpadZ*0.5*fgkZPad};
+ */
+ Translation(posLocal,step);
+
+ // FSTR reference frame -> FTOA/B/C = FLTA/B/C reference frame
+
+ Double_t angles[6];
+ 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);
+
+ // FTOA = FLTA reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
+ angles[0] = 90.;
+ angles[1] = 0.;
+ angles[2] = 0.;
+ angles[3] = 0.;
+ angles[4] = 90.;
+ angles[5] =270.;
+
+ InverseRotation(posLocal,angles);
+
+ // B071/B074/B075 = BTO1/2/3 reference frame -> ALICE reference frame
+ 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(Int_t *det) const
+{
+ //
+ // Returns Z coordinate (cm)
+ //
+
+ 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 zCoor = GetDistances(iplate,istrip) +
+ (0.5-ipadz) * fgkZPad * TMath::Cos(GetAngles(iplate,istrip)*kDegrad);
+ */
+
+ // Pad reference frame -> FSTR reference frame
+ // /*
+ Float_t posLocal[3] = {0., 0., 0.};
+ Float_t step[3] = {-(ipadx+0.5)*fgkXPad, 0., -(ipadz+0.5)*fgkZPad};
+ Translation(posLocal,step);
+
+ step[0] = kNpadX*0.5*fgkXPad;
+ step[1] = 0.;
+ step[2] = kNpadZ*0.5*fgkZPad;
+ // */
+ /*
+ Float_t posLocal[3] = {(ipadx+0.5)*fgkXPad, 0., (ipadz+0.5)*fgkZPad};
+ Float_t step[3]= {kNpadX*0.5*fgkXPad, 0., kNpadZ*0.5*fgkZPad};
+ */
+ Translation(posLocal,step);
+
+ // FSTR reference frame -> FTOA/B/C = FLTA/B/C reference frame
+ Double_t angles[6];
+ 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);
+
+ // FTOA = FLTA reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
+ angles[0] = 90.;
+ angles[1] = 0.;
+ angles[2] = 0.;
+ angles[3] = 0.;
+ angles[4] = 90.;
+ angles[5] =270.;
+
+ InverseRotation(posLocal,angles);
+
+ // B071/B074/B075 = BTO1/2/3 reference frame -> ALICE reference frame
+ 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)
+{
+ //
+ // Returns the local coordinates (x, y, z) in sector reference frame
+ // for the 4 corners of each sector pad (vol[1], vol[2], vol[3], vol[4])
+ //
+
+ if (!gGeoManager) printf("ERROR: no TGeo\n");
+
+ // ALICE -> TOF Sector
+ Char_t path1[100]="";
+ GetVolumePath(vol[0],path1);
+ gGeoManager->cd(path1);
+ TGeoHMatrix aliceToSector;
+ aliceToSector = *gGeoManager->GetCurrentMatrix();
+
+ // TOF Sector -> ALICE
+ //TGeoHMatrix sectorToALICE = aliceToSector.Inverse();
+
+ // ALICE -> TOF Pad
+ Char_t path2[100]="";
+ GetVolumePath(vol,path2);
+ gGeoManager->cd(path2);
+ TGeoHMatrix aliceToPad;
+ aliceToPad = *gGeoManager->GetCurrentMatrix();
+
+ // TOF Pad -> ALICE
+ TGeoHMatrix padToALICE = aliceToPad.Inverse();
+
+ // TOF Pad -> TOF Sector
+ TGeoHMatrix padToSector = padToALICE*aliceToSector;
+
+ // TOF Sector -> TOF Pad
+ //TGeoHMatrix sectorToPad = sectorToALICE*aliceToPad;
+
+ // coordinates of the pad bottom corner
+ 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;
+
+ //sectorToPad.LocalToMaster(cornerPad, coord);
+
+}
+//_____________________________________________________________________________
+Float_t AliTOFGeometry::GetPadDx(Float_t *pos)
+{
+ //
+ // Returns the x coordinate in the Pad reference frame
+ //
+
+ 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){
+ //AliError("Detector Index could not be determined");
+ return xpad;}
+ Int_t iplate = GetPlate(posLocal);
+ if(iplate == -1){
+ //AliError("Detector Index could not be determined");
+ return xpad;}
+ Int_t istrip = GetStrip(posLocal);
+ if(istrip == -1){
+ //AliError("Detector Index could not be determined");
+ return xpad;}
+ Int_t ipadz = GetPadZ(posLocal);
+ if(ipadz == -1){
+ //AliError("Detector Index could not be determined");
+ return xpad;}
+ Int_t ipadx = GetPadX(posLocal);
+ if(ipadx == -1){
+ //AliError("Detector Index could not be determined");
+ return xpad;}
+
+ // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
+ 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., (fgkRmax+fgkRmin)*0.5};
+ Translation(posLocal,step);
+
+ // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA/B/C = FLTA/B/C reference frame
+ angles[0] = 90.;
+ angles[1] = 0.;
+ angles[2] = 0.;
+ angles[3] = 0.;
+ angles[4] = 90.;
+ angles[5] =270.;
+
+ Rotation(posLocal,angles);
+
+ // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
+ 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(Float_t *pos)
+{
+ //
+ // Returns the y coordinate in the Pad reference frame
+ //
+
+ 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){
+ //AliError("Detector Index could not be determined");
+ return ypad;}
+ Int_t iplate = GetPlate(posLocal);
+ if(iplate == -1){
+ //AliError("Detector Index could not be determined");
+ return ypad;}
+ Int_t istrip = GetStrip(posLocal);
+ if(istrip == -1){
+ //AliError("Detector Index could not be determined");
+ return ypad;}
+ Int_t ipadz = GetPadZ(posLocal);
+ if(ipadz == -1){
+ //AliError("Detector Index could not be determined");
+ return ypad;}
+ Int_t ipadx = GetPadX(posLocal);
+ if(ipadx == -1){
+ //AliError("Detector Index could not be determined");
+ return ypad;}
+
+ // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
+ 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., (fgkRmax+fgkRmin)*0.5};
+ Translation(posLocal,step);
+
+ // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA/B/C = FLTA/B/C reference frame
+ angles[0] = 90.;
+ angles[1] = 0.;
+ angles[2] = 0.;
+ angles[3] = 0.;
+ angles[4] = 90.;
+ angles[5] =270.;
+
+ Rotation(posLocal,angles);
+
+ // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
+ 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(Float_t *pos)
+{
+ //
+ // Returns the z coordinate in the Pad reference frame
+ //
+
+ 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){
+ //AliError("Detector Index could not be determined");
+ return zpad;}
+ Int_t iplate = GetPlate(posLocal);
+ if(iplate == -1){
+ //AliError("Detector Index could not be determined");
+ return zpad;}
+ Int_t istrip = GetStrip(posLocal);
+ if(istrip == -1){
+ //AliError("Detector Index could not be determined");
+ return zpad;}
+ Int_t ipadz = GetPadZ(posLocal);
+ if(ipadz == -1){
+ //AliError("Detector Index could not be determined");
+ return zpad;}
+ Int_t ipadx = GetPadX(posLocal);
+ if(ipadx == -1){
+ //AliError("Detector Index could not be determined");
+ return zpad;}
+
+ // ALICE reference frame -> B071/B074/B075 = BTO1/2/3 reference frame
+ 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., (fgkRmax+fgkRmin)*0.5};
+ Translation(posLocal,step);
+
+ // B071/B074/B075 = BTO1/2/3 reference frame -> FTOA/B/C = FLTA/B/C reference frame
+ angles[0] = 90.;
+ angles[1] = 0.;
+ angles[2] = 0.;
+ angles[3] = 0.;
+ angles[4] = 90.;
+ angles[5] =270.;
+
+ Rotation(posLocal,angles);
+
+ // FTOA/B/C = FLTA/B/C reference frame -> FSTR reference frame
+ 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]) const
+{
+ //
+ // Return the vector xyz translated by translationVector vector
+ //
+
+ 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]) const
+{
+ //
+ // Return the vector xyz rotated according to the rotationAngles angles
+ //
+
+ Int_t ii=0;
+ /*
+ TRotMatrix *matrix = new TRotMatrix("matrix","matrix", angles[0], angles[1],
+ angles[2], angles[3],
+ angles[4], angles[5]);
+ */
+
+ 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]) const
+{
+ //
+ //
+ //
+
+ 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(Int_t *detId)
+{
+ //Retrieve calibration channel index
+ Int_t isector = detId[0];
+ if (isector >= kNSectors){
+ printf("Wrong sector number in TOF (%d) !",isector);
+ return -1;
+ }
+ Int_t iplate = detId[1];
+ if (iplate >= kNPlates){
+ printf("Wrong plate number in TOF (%d) !",iplate);
+ return -1;
+ }
+ Int_t istrip = detId[2];
+ Int_t ipadz = detId[3];
+ Int_t ipadx = detId[4];
+ 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;
+ default:
+ printf("Wrong plate number in TOF (%d) !",iplate);
+ return -1;
+ };
+
+ Int_t idet = ((2*(kNStripC+kNStripB)+kNStripA)
+ *kNpadZ*kNpadX)*isector +
+ (stripOffset*kNpadZ*kNpadX)+
+ (kNpadZ*kNpadX)*istrip+
+ (kNpadX)*ipadz+
+ ipadx;
+ return idet;
+}
+//_____________________________________________________________________________
+
+void AliTOFGeometry::GetVolumeIndices(Int_t index, Int_t *detId)
+{
+ //
+ // Retrieve volume indices from the calibration channel index
+ //
+
+ 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)
+{
+ //
+ // Returns the strips number for the plate number '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;
+
+}