+Float_t AliTOFGeometry::GetX(const Int_t * const 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] = {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);
+
+ // 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(const Int_t * const 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] = {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);
+
+ // 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(const Int_t * const 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] = {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);
+
+ // 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[4][3])
+{
+ //
+ // 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[200];
+ 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[200];
+ 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(const Float_t * const 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(const Float_t * const 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(const Float_t * const 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
+{
+ //
+ // Rotates the vector xyz acordint to the rotationAngles
+ //
+
+ 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 * const detId)
+{
+ //Retrieve calibration channel index
+ 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)
+{
+ //
+ // 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; // padZ
+ detId[4] = padPerStrip - detId[3]*kNpadX; // padX
+
+}
+//_____________________________________________________________________________
+
+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;
+
+}
+//-------------------------------------------------------------------------
+
+UShort_t AliTOFGeometry::GetAliSensVolIndex(Int_t isector, Int_t iplate, Int_t istrip) const
+{
+ //
+ // Get the index of the TOF alignable volume in the AliGeomManager order.
+ //
+
+ 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)
+{
+ //
+ // Get the serial number of the TOF strip number istrip [0,14/18],
+ // in the module number iplate [0,4],
+ // in the TOF SM number isector [0,17].
+ // This number will range in [0,1637].
+ //
+
+ 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)
+{
+ //
+ // Convert the serial number of the TOF strip number iStripPerSM [0,90]
+ // in module number iplate [0,4] and strip number istrip [0,14/18].
+ //
+
+ 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)
+{
+ //
+ // Get the serial number of the TOF strip number istrip [0,14/18],
+ // in the module number iplate [0,4].
+ // This number will range in [0,90].
+ //
+
+ 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)
+{
+ //
+ // To convert the 3D distance ctrackPos, referred to the ALICE RF,
+ // into the 3D distance differenceT, referred to the tracking RF
+ // in case ctrakPos belongs to a TOF sensitive volume.
+ //
+
+ 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));
+
+ // pad centre coordinates in the strip ref. frame
+ 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.};
+ // pad centre coordinates in the strip tracking frame
+ Double_t padCentreT[3] = {0., 0., 0.};
+ TGeoHMatrix l2t = *AliGeomManager::GetTracking2LocalMatrix(alignableStripIndex);
+ l2t.MasterToLocal(padCentreL,padCentreT);
+
+
+ Char_t path[200];
+ // pad centre coordinates in its ref. frame
+ Double_t padCentreL2[3] = {0., 0., 0.};
+ // pad centre coordinates in the ALICE global ref. frame
+ 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];
+ // strip centre coordinates in its ref. frame
+ Double_t stripCentreL[3] = {0., 0., 0.};
+ // strip centre coordinates in the ALICE global ref. frame
+ 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);
+
+ // track position in the ALICE global ref. frame
+ Double_t posG[3];
+ for (Int_t ii=0; ii<3; ii++) posG[ii] = (Double_t)ctrackPos[ii];
+
+ // strip centre coordinates in the tracking ref. frame
+ Double_t stripCentreT[3] = {0., 0., 0.};
+ // track position in the tracking ref. frame
+ 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(const Int_t index)
+{
+ // Return the TOF supermodule where TOF channel index is located
+
+ if (index<0 || index>=NPadXSector()*NSectors()) return -1;
+ else return index/NpadXStrip()/NStripXSector();
+
+}