]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFGeometryV4.cxx
filter out additional compile defines to fit into rootcints 1024 char limit
[u/mrichter/AliRoot.git] / TOF / AliTOFGeometryV4.cxx
index 6f8f3c1d13f3a7f28e88c724f7e944bf8ab2c574..2c15d098e3920c8095d1ef974019442fa704c191 100644 (file)
 
 /*
 $Log$
+Revision 1.5  2006/04/20 22:30:50  hristov
+Coding conventions (Annalisa)
+
+Revision 1.4  2006/04/16 22:29:05  hristov
+Coding conventions (Annalisa)
+
+Revision 1.3  2006/03/12 14:38:13  arcelli
+ Changes for TOF Reconstruction using TGeo
+
+Revision 1.2  2006/02/28 10:38:00  decaro
+AliTOFGeometry::fAngles, AliTOFGeometry::fHeights, AliTOFGeometry::fDistances arrays: dimension definition in the right location
+
 Revision 1.1  2005/12/15 08:55:33  decaro
 New TOF geometry description (V5) -G. Cara Romeo and A. De Caro
 
@@ -29,23 +41,23 @@ Revision 0.1  2005/07/19 A. De Caro
                according to the PPR TOF geometry
 */
 
-#include <stdlib.h>
-#include <Riostream.h>
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
 //  TOF Geometry class (PPR version)                                         //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "AliLog.h"
+#include "TGeoManager.h"
+
 #include "AliConst.h"
+#include "AliLog.h"
 
-#include "AliTOFGeometry.h"
 #include "AliTOFGeometryV4.h"
 
+extern TGeoManager *gGeoManager;
+
 ClassImp(AliTOFGeometryV4)
 
-const Int_t AliTOFGeometryV4::kNStripC      = 20;       // number of strips in C type module
 
 const Float_t AliTOFGeometryV4::fgkZlenA    = 106.0;    // length (cm) of the A module
 const Float_t AliTOFGeometryV4::fgkZlenB    = 141.0;    // length (cm) of the B module
@@ -72,16 +84,16 @@ AliTOFGeometryV4::AliTOFGeometryV4()
   // AliTOFGeometryV4 default constructor
   //
 
-  AliTOFGeometry::kNStripC   = kNStripC;         // number of strips in C type module
+  AliTOFGeometry::fNStripC   = kNStripC;         // number of strips in C type module
 
-  AliTOFGeometry::kZlenA    = fgkZlenA;          // length (cm) of the A module
-  AliTOFGeometry::kZlenB    = fgkZlenB;          // length (cm) of the B module
-  AliTOFGeometry::kZlenC    = fgkZlenC;          // length (cm) of the C module
-  AliTOFGeometry::kMaxhZtof = fgkMaxhZtof;       // Max half z-size of TOF (cm)
+  AliTOFGeometry::fZlenA    = fgkZlenA;          // length (cm) of the A module
+  AliTOFGeometry::fZlenB    = fgkZlenB;          // length (cm) of the B module
+  AliTOFGeometry::fZlenC    = fgkZlenC;          // length (cm) of the C module
+  AliTOFGeometry::fMaxhZtof = fgkMaxhZtof;       // Max half z-size of TOF (cm)
 
-  AliTOFGeometry::fgkxTOF   = fgkxTOF;           // Inner radius of the TOF for Reconstruction (cm)
-  AliTOFGeometry::fgkRmin   = fgkRmin;           // Inner radius of the TOF (cm)
-  AliTOFGeometry::fgkRmax   = fgkRmax;           // Outer radius of the TOF (cm)
+  AliTOFGeometry::fxTOF   = fgkxTOF;           // Inner radius of the TOF for Reconstruction (cm)
+  AliTOFGeometry::fRmin   = fgkRmin;           // Inner radius of the TOF (cm)
+  AliTOFGeometry::fRmax   = fgkRmax;           // Outer radius of the TOF (cm)
 
   Init();
 
@@ -96,6 +108,10 @@ AliTOFGeometryV4::~AliTOFGeometryV4()
 
 }
 //_____________________________________________________________________________
+void AliTOFGeometryV4::ImportGeometry(){
+  TGeoManager::Import("geometry.root");
+}
+//_____________________________________________________________________________
 void AliTOFGeometryV4::Init()
 {
   //
@@ -103,6 +119,8 @@ void AliTOFGeometryV4::Init()
   //
   // Strips Tilt Angles
  
+  fPhiSec   = 360./kNSectors;
+
   Float_t const kangles[kNPlates][kMaxNstrip] ={
 
  {44.494, 43.725, 42.946, 42.156, 41.357, 40.548, 39.729, 38.899, 
@@ -157,7 +175,7 @@ void AliTOFGeometryV4::Init()
 }
 
 //_____________________________________________________________________________
-Float_t AliTOFGeometryV4::DistanceToPad(Int_t *det, Float_t *pos, Float_t *dist3d) 
+Float_t AliTOFGeometryV4::DistanceToPadPar(Int_t *det, Float_t *pos, Float_t *dist3d) const
 {
 //
 // Returns distance of  space point with coor pos (x,y,z) (cm) wrt 
@@ -182,7 +200,7 @@ Float_t AliTOFGeometryV4::DistanceToPad(Int_t *det, Float_t *pos, Float_t *dist3
   // Do the same for the selected pad
 
   Float_t g[3];
-  GetPos(det,g);
+  GetPosPar(det,g);
 
   Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
   Float_t padPhi=TMath::ATan2(g[1],g[0]);      
@@ -206,7 +224,6 @@ Float_t AliTOFGeometryV4::DistanceToPad(Int_t *det, Float_t *pos, Float_t *dist3
   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;
@@ -218,7 +235,7 @@ Float_t AliTOFGeometryV4::DistanceToPad(Int_t *det, Float_t *pos, Float_t *dist3
 }
 
 //_____________________________________________________________________________
-Bool_t AliTOFGeometryV4::IsInsideThePad(Int_t *det, Float_t *pos) 
+Bool_t AliTOFGeometryV4::IsInsideThePadPar(Int_t *det, Float_t *pos) const
 {
 //
 // Returns true if space point with coor pos (x,y,z) (cm) falls 
@@ -245,7 +262,7 @@ Bool_t AliTOFGeometryV4::IsInsideThePad(Int_t *det, Float_t *pos)
   // Do the same for the selected pad
 
   Float_t g[3];
-  GetPos(det,g);
+  GetPosPar(det,g);
 
   Float_t padRadius = TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
   Float_t padPhi=TMath::ATan2(g[1],g[0]);      
@@ -275,8 +292,86 @@ Bool_t AliTOFGeometryV4::IsInsideThePad(Int_t *det, Float_t *pos)
 
 }
 
+
 //_____________________________________________________________________________
-Float_t AliTOFGeometryV4::GetX(Int_t *det) 
+Float_t AliTOFGeometryV4::DistanceToPad(Int_t *det, TGeoHMatrix mat, Float_t *pos, Float_t *dist3d) const
+{
+//
+// Returns distance of  space point with coor pos (x,y,z) (cm) wrt 
+// pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) 
+//
+  if (!gGeoManager) {
+    printf("ERROR: no TGeo\n");
+    return 0.;
+  }
+  Double_t vecg[3];
+  vecg[0]=pos[0];
+  vecg[1]=pos[1];
+  vecg[2]=pos[2];
+  Double_t veclr[3]={-1.,-1.,-1.};
+  Double_t vecl[3]={-1.,-1.,-1.};
+  mat.MasterToLocal(vecg,veclr);  
+  vecl[0]=veclr[1];
+  vecl[1]=veclr[0];
+  vecl[2]=-veclr[2];
+  //Take into account reflections
+  if(det[1]>2){
+    vecl[1]=-veclr[0];
+    vecl[2]= veclr[2];
+  }    
+
+  Float_t dist = TMath::Sqrt(vecl[0]*vecl[0]+vecl[1]*vecl[1]+vecl[2]*vecl[2]);
+
+
+  if (dist3d){
+    dist3d[0] = vecl[0];
+    dist3d[1] = vecl[1];
+    dist3d[2] = vecl[2];
+  }
+
+  return dist;
+
+}
+
+
+//_____________________________________________________________________________
+Bool_t AliTOFGeometryV4::IsInsideThePad( Int_t *det, TGeoHMatrix mat, Float_t *pos) const
+{
+//
+// Returns true if space point with coor pos (x,y,z) (cm) falls 
+// inside pad with Detector Indices idet (iSect,iPlate,iStrip,iPadX,iPadZ) 
+//
+
+  const Float_t khsensmy = 0.5;      // heigth of Sensitive Layer
+
+  Double_t vecg[3];
+  vecg[0]=pos[0];
+  vecg[1]=pos[1];
+  vecg[2]=pos[2];
+  Double_t veclr[3]={-1.,-1.,-1.};
+  Double_t vecl[3]={-1.,-1.,-1.};
+  mat.MasterToLocal(vecg,veclr);  
+  vecl[0]=veclr[1];
+  vecl[1]=veclr[0];
+  vecl[2]=-veclr[2];
+  //Take into account reflections
+  if(det[1]>2){
+    vecl[1]=-veclr[0];
+    vecl[2]= veclr[2];
+  }    
+
+  Float_t xr = vecl[0];
+  Float_t yr = vecl[1];
+  Float_t zr = vecl[2];
+
+  Bool_t isInside=false; 
+  if(TMath::Abs(xr)<= khsensmy*0.5 && TMath::Abs(yr)<= (fgkXPad*0.5) && TMath::Abs(zr)<= (fgkZPad*0.5))
+    isInside=true; 
+  return isInside;
+
+}
+//_____________________________________________________________________________
+Float_t AliTOFGeometryV4::GetX(Int_t *det) const
 {
   //
   // Returns X coordinate (cm)
@@ -307,7 +402,7 @@ Float_t AliTOFGeometryV4::GetX(Int_t *det)
 
 }
 //_____________________________________________________________________________
-Float_t AliTOFGeometryV4::GetY(Int_t *det) 
+Float_t AliTOFGeometryV4::GetY(Int_t *det) const
 {
   //
   // Returns Y coordinate (cm)
@@ -339,7 +434,7 @@ Float_t AliTOFGeometryV4::GetY(Int_t *det)
 }
 
 //_____________________________________________________________________________
-Float_t AliTOFGeometryV4::GetZ(Int_t *det) 
+Float_t AliTOFGeometryV4::GetZ(Int_t *det) const
 {
   //
   // Returns Z coordinate (cm)
@@ -359,7 +454,7 @@ Float_t AliTOFGeometryV4::GetZ(Int_t *det)
 }
 
 //_____________________________________________________________________________
-Int_t AliTOFGeometryV4::GetSector(Float_t *pos) 
+Int_t AliTOFGeometryV4::GetSector(Float_t *pos) const
 {
   //
   // Returns the Sector index 
@@ -379,7 +474,7 @@ Int_t AliTOFGeometryV4::GetSector(Float_t *pos)
 }
 
 //_____________________________________________________________________________
-Int_t AliTOFGeometryV4::GetPadX(Float_t *pos) 
+Int_t AliTOFGeometryV4::GetPadX(Float_t *pos) const
 {
   //
   // Returns the Pad index along X 
@@ -428,7 +523,7 @@ Int_t AliTOFGeometryV4::GetPadX(Float_t *pos)
 
 }
 //_____________________________________________________________________________
-Int_t AliTOFGeometryV4::GetPlate(Float_t *pos) 
+Int_t AliTOFGeometryV4::GetPlate(Float_t *pos) const
 {
   //
   // Returns the Plate index 
@@ -463,7 +558,7 @@ Int_t AliTOFGeometryV4::GetPlate(Float_t *pos)
 }
 
 //_____________________________________________________________________________
-Int_t AliTOFGeometryV4::GetStrip(Float_t *pos) 
+Int_t AliTOFGeometryV4::GetStrip(Float_t *pos) const
 {
   //
   // Returns the Strip index 
@@ -513,7 +608,7 @@ Int_t AliTOFGeometryV4::GetStrip(Float_t *pos)
 
 }
 //_____________________________________________________________________________
-Int_t AliTOFGeometryV4::GetPadZ(Float_t *pos) 
+Int_t AliTOFGeometryV4::GetPadZ(Float_t *pos) const
 {
   //
   // Returns the Pad index along Z 
@@ -552,7 +647,7 @@ Int_t AliTOFGeometryV4::GetPadZ(Float_t *pos)
 
 }
 //_____________________________________________________________________________
-Float_t AliTOFGeometryV4::GetMinPlateTheta(Int_t iPlate) 
+Float_t AliTOFGeometryV4::GetMinPlateTheta(Int_t iPlate) const
 {
   //
   // Returns the minimum theta angle of a given plate iPlate (rad)
@@ -577,7 +672,7 @@ Float_t AliTOFGeometryV4::GetMinPlateTheta(Int_t iPlate)
 
 }
 //_____________________________________________________________________________
-Float_t AliTOFGeometryV4::GetMaxPlateTheta(Int_t iPlate) 
+Float_t AliTOFGeometryV4::GetMaxPlateTheta(Int_t iPlate) const
 {
   //
   // Returns the maximum theta angle of a given plate iPlate (rad)
@@ -604,7 +699,7 @@ Float_t AliTOFGeometryV4::GetMaxPlateTheta(Int_t iPlate)
 
 }
 //_____________________________________________________________________________
-Float_t  AliTOFGeometryV4::GetMaxStripTheta(Int_t iPlate, Int_t iStrip) 
+Float_t  AliTOFGeometryV4::GetMaxStripTheta(Int_t iPlate, Int_t iStrip) const
 {
   //
   // Returns the maximum theta angle of a given strip iStrip (rad)
@@ -626,7 +721,7 @@ Float_t  AliTOFGeometryV4::GetMaxStripTheta(Int_t iPlate, Int_t iStrip)
 
 }
 //_____________________________________________________________________________
-Float_t  AliTOFGeometryV4::GetMinStripTheta(Int_t iPlate, Int_t iStrip) 
+Float_t  AliTOFGeometryV4::GetMinStripTheta(Int_t iPlate, Int_t iStrip) const
 {
   //
   // Returns the minimum theta angle of a given Strip iStrip (rad)
@@ -650,7 +745,7 @@ Float_t  AliTOFGeometryV4::GetMinStripTheta(Int_t iPlate, Int_t iStrip)
 
 }
 //_____________________________________________________________________________
-Float_t  AliTOFGeometryV4::GetStripTheta(Int_t iPlate, Int_t iStrip) 
+Float_t  AliTOFGeometryV4::GetStripTheta(Int_t iPlate, Int_t iStrip) const
 {
   //
   // returns the median theta angle of a given strip iStrip (rad)
@@ -674,3 +769,192 @@ Float_t  AliTOFGeometryV4::GetStripTheta(Int_t iPlate, Int_t iStrip)
 
 }
 //_____________________________________________________________________________
+void AliTOFGeometryV4::GetVolumePath(Int_t *ind, Char_t *path ) {
+  //--------------------------------------------------------------------
+  // This function returns the colume path of a given pad 
+  //--------------------------------------------------------------------
+  Int_t sector = ind[0];
+  Char_t  string1[100];
+  Char_t  string2[100];
+  Char_t  string3[100];
+  Char_t  string4[100];
+  Int_t nstrB = NStripB();
+  Int_t nstrC = NStripC();
+  
+  Int_t icopy=-1;
+  
+  if(sector<3){
+    icopy=sector+1;
+    sprintf(string1,"/ALIC_1/B077_1/B075_%i/BTO3_1",icopy);
+  }
+  else if(sector<11){
+    // icopy=sector-2;
+    icopy=sector+3;
+    sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  else if(sector==11 || sector==12){
+    icopy=sector-10;
+    sprintf(string1,"/ALIC_1/B077_1/B074_%i/BTO2_1",icopy);
+  }
+  else {
+    // icopy=sector-4;
+    icopy=sector-12;
+    sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  
+  Int_t modnum=ind[1];
+  Int_t istrip=ind[2];
+  
+  if( modnum ==0){
+    sprintf(string2,"FTOC_1/FLTC_0");
+    icopy= nstrC - istrip;
+    sprintf(string3,"FSTR_%i",icopy);
+  }    
+  else if( modnum ==1){
+    sprintf(string2,"FTOB_1/FLTB_0");
+    icopy= nstrB - istrip;
+      sprintf(string3,"FSTR_%i",icopy);
+  }
+  else if( modnum ==2){
+    sprintf(string2,"FTOA_0/FLTA_0");
+    icopy= istrip+1;
+    sprintf(string3,"FSTR_%i",icopy);
+  }
+  else if( modnum ==3){
+    sprintf(string2,"FTOB_2/FLTB_0");
+    icopy= istrip+1;
+    sprintf(string3,"FSTR_%i",icopy);
+  }
+  else if( modnum ==4){
+    sprintf(string2,"FTOC_2/FLTC_0");
+    icopy= istrip+1;
+    sprintf(string3,"FSTR_%i",icopy);
+  }
+
+
+  Int_t padz = ind[3]+1; 
+  Int_t padx = ind[4]+1;
+  if(modnum==3 || modnum==4){
+    padz = NpadZ() -ind[3];
+    padx = NpadX() -ind[4];
+  }
+  sprintf(string4,"FSEN_0/FSEZ_%i/FSEX_%i",padz,padx);
+  sprintf(path,"%s/%s/%s/%s",string1,string2,string3,string4); 
+
+}
+
+//_____________________________________________________________________________
+void AliTOFGeometryV4::GetVolumePath(Int_t sector, Char_t *path ) {
+  //--------------------------------------------------------------------
+  // This function returns the colume path of a given sector 
+  //--------------------------------------------------------------------
+  Char_t string[100];
+  
+  Int_t icopy=-1;
+  
+  if(sector<3){
+    icopy=sector+1;
+    sprintf(string,"/ALIC_1/B077_1/B075_%i/BTO3_1",icopy);
+  }
+  else if(sector<11){
+    // icopy=sector-2;
+    icopy=sector+3;
+    sprintf(string,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  else if(sector==11 || sector==12){
+    icopy=sector-10;
+    sprintf(string,"/ALIC_1/B077_1/B074_%i/BTO2_1",icopy);
+  }
+  else {
+    // icopy=sector-4;
+    icopy=sector-12;
+    sprintf(string,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  
+  sprintf(path,"%s",string); 
+
+}
+//_____________________________________________________________________________
+void AliTOFGeometryV4::GetVolumePath(Int_t sector, Int_t plate, Int_t strip, Char_t *path ) {
+  //--------------------------------------------------------------------
+  // This function returns the colume path of a given strip 
+  //--------------------------------------------------------------------
+  Char_t string1[100];
+  Char_t string2[100];
+  Char_t string3[100];
+  Int_t nstrB = NStripB();
+  Int_t nstrC = NStripC();
+  
+  Int_t icopy=-1;
+  
+  if(sector<3){
+    icopy=sector+1;
+    sprintf(string1,"/ALIC_1/B077_1/B075_%i/BTO3_1",icopy);
+  }
+  else if(sector<11){
+    // icopy=sector-2;
+    icopy=sector+3;
+    sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  else if(sector==11 || sector==12){
+    icopy=sector-10;
+    sprintf(string1,"/ALIC_1/B077_1/B074_%i/BTO2_1",icopy);
+  }
+  else {
+    // icopy=sector-4;
+    icopy=sector-12;
+    sprintf(string1,"/ALIC_1/B077_1/B071_%i/BTO1_1",icopy);
+  }
+  
+  if( plate ==0){
+    sprintf(string2,"FTOC_1/FLTC_0");
+    icopy = nstrC - strip;
+    sprintf(string3,"FSTR_%i",icopy);
+  }    
+  else if( plate ==1){
+    sprintf(string2,"FTOB_1/FLTB_0");
+    icopy = nstrB - strip;
+      sprintf(string3,"FSTR_%i",icopy);
+  }
+  else if( plate ==2){
+    sprintf(string2,"FTOA_0/FLTA_0");
+    icopy = strip+1;
+    sprintf(string3,"FSTR_%i",icopy);
+  }
+  else if( plate ==3){
+    sprintf(string2,"FTOB_2/FLTB_0");
+    icopy = strip+1;
+    sprintf(string3,"FSTR_%i",icopy);
+  }
+  else if( plate ==4){
+    sprintf(string2,"FTOC_2/FLTC_0");
+    icopy = strip+1;
+    sprintf(string3,"FSTR_%i",icopy);
+  }
+
+  sprintf(path,"%s/%s/%s/FSEN_0",string1,string2,string3); 
+
+}
+
+//_____________________________________________________________________________
+void AliTOFGeometryV4::GetPos(Int_t *det, Float_t *pos) 
+{
+//
+// Returns space point coor (x,y,z) (cm)  for Detector 
+// Indices  (iSect,iPlate,iStrip,iPadX,iPadZ) 
+//
+  Char_t path[100];
+  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];
+}
+//_____________________________________________________________________________