]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added function DetToLocal and LocalToDet used to consistanly go between
authornilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Apr 2001 23:11:07 +0000 (23:11 +0000)
committernilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Apr 2001 23:11:07 +0000 (23:11 +0000)
Geant local detector coordinates (local) to the detector pad coordinates (det).
For example, xl,zl<->ix,iz for the pixels, xl,zl<->anode,timebucket for the
drifts, and xl,zl->iP,iN i,P/N-> xl,zl. Additionaly For the strips the function
Bool_t GetCrossing(iP,iN,&x,&z,c[2][2]). If this function is true then the
two strips cross within the sensitive volume of the strip detector. One other
new function has been added, Int_t GetNPads(). This function returns the
total number of posible digits/channels for the given segmentation. Additionaly
some comments have been added.

ITS/AliITSsegmentation.h
ITS/AliITSsegmentationSDD.cxx
ITS/AliITSsegmentationSDD.h
ITS/AliITSsegmentationSPD.cxx
ITS/AliITSsegmentationSPD.h
ITS/AliITSsegmentationSSD.cxx
ITS/AliITSsegmentationSSD.h

index 335a2f0c2aed0986c1f4189f125e406322a3d590..e269c5caf60eccecfbd61c979742165907a0590a 100644 (file)
@@ -27,6 +27,8 @@ public TObject {
 
     // Maximum number of cells along the two coordinates  
     virtual void    SetNPads(Int_t p1, Int_t p2) {}
+    // Returns the maximum number of cells (digits) posible
+    virtual Int_t   GetNPads(){return 0;}
 
     // Set angles - find a generic name fit for other detectors as well
     // might be useful for beam test setups (3 angles ?)
@@ -42,7 +44,12 @@ public TObject {
     virtual void    GetGlobal(Int_t module,Float_t *l ,Float_t *g) {}
     // Local transformation of real local coordinates -
     virtual void    GetPadTxz(Float_t &x ,Float_t &z) {}
-     //
+    // Transformation from Geant cm detector center local coordinates
+    // to detector segmentation/cell coordiantes starting from (0,0).
+    virtual void    LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){}
+    // Transformation from detector segmentation/cell coordiantes starting
+    // from (0,0) to Geant cm detector center local coordinates.
+    virtual void    DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z){}
     // Initialisation
     virtual void Init() {}
     //
index 0d4cceff60729f92bcd729014353601b056a811a..96fa679054d0b5d6ce64e24834eba89b9febced6 100644 (file)
@@ -196,3 +196,104 @@ void AliITSsegmentationSDD::Print(){
    cout << "**************************************************" << endl;
 
 }
+//______________________________________________________________________
+
+//______________________________________________________________________
+void AliITSsegmentationSDD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
+// Transformation from Geant detector centered local coordinates (cm) to
+// time bucket numbers ix and anode number iz.
+// Input:
+// Float_t   x      detector local coordinate x in cm with respect to the
+//                  center of the sensitive volume.
+// Float_t   z      detector local coordinate z in cm with respect to the
+//                  center of the sensitive volulme.
+// Output:
+// Int_t    ix      detector x time coordinate. Has the range 0<=ix<fNsamples.
+// Int_t    iz      detector z anode coordinate. Has the range 0<=iz<fNandoes.
+//   A value of -1 for ix or iz indecates that this point is outside of the
+// detector segmentation as defined.
+//     This segmentation geometry can be discribed as the following:
+// {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
+//  res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the 
+//  specific numbers will change not their layout.}
+//
+//        0                     191                    0
+//      0 |----------------------|---------------------| 256
+//        | a     time-bins      |     time-bins     a |
+//        | n                    |                   n |
+//        | o                    |___________________o_|__> X
+//        | d                    |                   d |
+//        | e                    |                   e |
+//        | s                    |                   s |
+//    255 |----------------------|---------------------| 511
+//                               |
+//                               V
+//                               Z
+    Float_t dx,dz,tb;
+    const Float_t kconv = 1.0E-04; // converts microns to cm.
+
+    ix = -1; // default values
+    iz = -1; // default values
+    dx = -kconv*Dx(); // lower left edge in cm.
+    dz = -0.5*kconv*Dz(); // lower left edge in cm.
+    if(x<dx || x>-dx) return; // outside of defined volume.
+    if(z<dz || z>-dz) return; // outside of defined volume.
+    tb = fResponse->DriftSpeed()*fTimeStep*kconv; // compute size of time bin.
+    if(x>0) dx = -(dx + x)/tb; // distance from + side in time bin units
+    else dx = (x - dx)/tb;     // distance from - side in time bin units
+    dz = (z - dz)/(kconv*fPitch); // distance in z in anode pitch units
+    ix = (Int_t) dx;   // time bin
+    iz = (Int_t) dz;   // anode
+    if(x>0) iz += Npz()/2; // if x>0 then + side anodes values.
+    return; // Found ix and iz, return.
+}
+//______________________________________________________________________
+void AliITSsegmentationSDD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z)
+{
+// Transformation from Detector time bucket and anode coordiantes to Geant 
+// detector centerd local coordinates (cm).
+// Input:
+// Int_t    ix      detector x time coordinate. Has the range 0<=ix<fNsamples.
+// Int_t    iz      detector z anode coordinate. Has the range 0<=iz<fNandoes.
+// Output:
+// Float_t   x      detector local coordinate x in cm with respect to the
+//                  center of the sensitive volume.
+// Float_t   z      detector local coordinate z in cm with respect to the
+//                  center of the sensitive volulme.
+// If ix and or iz is outside of the segmentation range a value of -Dx()
+// or -0.5*Dz() is returned.
+//     This segmentation geometry can be discribed as the following:
+// {assumes 2*Dx()=7.0cm Dz()=7.5264cm, Dpx()=25ns,
+//  res->DeriftSpeed()=7.3mic/ns, Dpz()=512. For other values a only the 
+//  specific numbers will change not their layout.}
+//
+//        0                     191                    0
+//      0 |----------------------|---------------------| 256
+//        | a     time-bins      |     time-bins     a |
+//        | n                    |                   n |
+//        | o                    |___________________o_|__> X
+//        | d                    |                   d |
+//        | e                    |                   e |
+//        | s                    |                   s |
+//    255 |----------------------|---------------------| 511
+//                               |
+//                               V
+//                               Z
+    Int_t i,j;
+    Float_t tb;
+    const Float_t kconv = 1.0E-04; // converts microns to cm.
+
+    if(iz>=Npz()/2) x = kconv*Dx(); // default value for +x side.
+    else x = -kconv*Dx(); // default value for -x side.
+    z = -0.5*kconv*Dz(); // default value.
+    if(ix<0 || ix>=Npx()) return; // outside of detector
+    if(iz<0 || iz>=Npz()) return; // outside of detctor
+    tb = fResponse->DriftSpeed()*fTimeStep*kconv; // compute size of time bin.
+    if(iz>=Npz()/2) tb *= -1.0; // for +x side decrement frmo Dx().
+    for(i=0;i<ix;i++) x += tb; // sum up to cell ix-1
+    x += 0.5*tb; // add 1/2 of cell ix for center location.
+    if(iz>=Npz()/2) iz -=Npz()/2;// If +x side don't count anodes from -x side.
+    for(j=0;j<iz;j++) z += kconv*fPitch; // sum up cell iz-1
+    z += 0.5*kconv*fPitch; // add 1/2 of cell iz for center location.
+    return; // Found x and z, return.
+}
index c2b2f95069ce0c9b724af36103d05d1aef24ad6c..37bec709a32693e82ec9e7f27aa472d0ef3506ba 100644 (file)
@@ -32,6 +32,8 @@ public AliITSsegmentation {
     // Maximum number of cells along the two coordinates z,x (anodes,samples) 
     virtual void    SetNPads(Int_t p1=256, Int_t p2=256) 
                          {fNanodes=2*p1;fNsamples=p2;}
+    // Returns the maximum number of cells (digits) posible
+    virtual Int_t   GetNPads(){return fNandoes*fNsamples;}
 
     // Transform from real local to cell coordinates
     virtual void    GetPadIxz(Float_t x ,Float_t z ,Int_t   &ix,Int_t   &iz);
@@ -43,6 +45,12 @@ public AliITSsegmentation {
     virtual void    GetGlobal(Int_t module,Float_t *l ,Float_t *g);
     // Get anode and time bucket as floats - numbering from 0
     virtual void    GetPadTxz(Float_t &x ,Float_t &z);
+    // Transformation from Geant cm detector center local coordinates
+    // to detector segmentation/cell coordiantes starting from (0,0).
+    virtual void    LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz);
+    // Transformation from detector segmentation/cell coordiantes starting
+    // from (0,0) to Geant cm detector center local coordinates.
+    virtual void    DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z);
     //
     // Initialisation
     virtual void Init();
@@ -53,7 +61,7 @@ public AliITSsegmentation {
     virtual AliITSgeom* Geometry() {return fGeom;}
     // Detector length
     virtual Float_t Dx() {return fDx;}
-    // Detector width
+    // Detector drift distance or detector active area half width
     virtual Float_t Dz()  {return fDz;}  
     // Detector thickness
     virtual Float_t Dy() {return fDy;}
@@ -112,13 +120,13 @@ public AliITSsegmentation {
            
   protected:
 
-    Int_t      fNsamples;      // Number of time samples in x
-    Int_t      fNanodes;       // Summed # of anodes in the two det halves (z)
-    Float_t    fPitch;         // Anode pitch - microns
-    Float_t    fTimeStep;      // Sampling time - ns
-    Float_t    fDx   ;         // Full width of the detector (x axis) - microns
-    Float_t    fDz    ;        // Length of half-detector (z axis) - microns
-    Float_t    fDy;            // Full thickness of the detector (y axis)
+    Int_t      fNsamples; // Number of time samples in x
+    Int_t      fNanodes;  // Summed # of anodes in the two det halves (z)
+    Float_t    fPitch;    // Anode pitch - microns
+    Float_t    fTimeStep; // Sampling time - ns
+    Float_t    fDx;       // Drift distance of the 1/2detector (x axis)-microns
+    Float_t    fDz;       // Length of half-detector (z axis) - microns
+    Float_t    fDy;       // Full thickness of the detector (y axis) - microns
 
     AliITSgeom *fGeom;         //! pointer to the geometry class
     AliITSresponse *fResponse; // pointer to the response class
index 9dd0a0137b3f8492f25065ae2add27c0e6707122..129d952d89e1b90b77da33ee1231569bd0dcf561 100644 (file)
@@ -45,7 +45,7 @@ Float_t ZpitchFromCol300(Int_t col) {
   return 300.0;
 }
 //_____________________________________________________________________________
-Float_t ColFromZ(Float_t z) {
+Float_t  AliITSsegmentationSPD::ColFromZ(Float_t z) {
 // hard-wired - keep it like this till we can parametrise 
 // and get rid of AliITSgeomSPD425
 // Get column number for each z-coordinate taking into account the 
@@ -85,7 +85,7 @@ Float_t ColFromZ(Float_t z) {
 }
 
 //_____________________________________________________________________________
-Float_t ZFromCol(Int_t col) {
+Float_t  AliITSsegmentationSPD::ZFromCol(Int_t col) {
 // same comments as above
 // Get z-coordinate for each colunm number
 
@@ -118,29 +118,33 @@ Float_t ZFromCol(Int_t col) {
     z = 69175 + (col -159 + 0.5)*pitchz;    
   } else if( col >= 161 && col <= 191) {  
     z = 70425 + (col -161 + 0.5)*pitchz;    
-  }   
+  }
 
   return z;
 }
-
-Float_t ZpitchFromCol(Int_t col) {
+//______________________________________________________________________
+Float_t AliITSsegmentationSPD::ZpitchFromCol(Int_t col) {
 // Get pitch size in z direction for each colunm
 
-  Float_t pitchz = 425;
-  if( col >=32 && col <= 33 ) {  
-    pitchz = 625;
-  } else if( col >= 64 && col <= 65) {  
-    pitchz = 625;
-  } else if( col >= 96 && col <= 97) {  
-    pitchz = 625;
-  } else if( col >= 128 && col <= 129) {  
-    pitchz = 625;
-  } else if( col >= 160 && col <= 161) {  
-    pitchz = 625;
-  }   
-  return pitchz;
+    Float_t pitchz = 425;
+    if(col < 0){
+       pitchz = 0.0;
+    } else if(col >=  31 && col <=  32) {  
+       pitchz = 625;
+    } else if(col >=  63 && col <=  64) {  
+       pitchz = 625;
+    } else if(col >=  95 && col <=  96) {  
+       pitchz = 625;
+    } else if(col >= 127 && col <= 128) {  
+       pitchz = 625;
+    } else if(col >= 159 && col <= 160) {  
+       pitchz = 625;
+    } else if(col>=192){
+       pitchz = 0.0;
+    }
+    return pitchz;
 }
-
+//______________________________________________________________________
 AliITSsegmentationSPD::AliITSsegmentationSPD(){
   // Default constructor
    fNpx = 0;
@@ -149,7 +153,7 @@ AliITSsegmentationSPD::AliITSsegmentationSPD(){
    fGeom = 0;
 
 }
-//____________________________________________________________________________
+//______________________________________________________________________
 AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSgeom *gm){
   // Constructor
    fCorr=0;
@@ -159,7 +163,7 @@ AliITSsegmentationSPD::AliITSsegmentationSPD(AliITSgeom *gm){
    fGeom = gm;
 
 }
-//____________________________________________________________________________
+//______________________________________________________________________
 AliITSsegmentationSPD& AliITSsegmentationSPD::operator=(AliITSsegmentationSPD &source){
    // = operator
    if(this==&source) return *this;
@@ -331,3 +335,69 @@ Neighbours(Int_t iX, Int_t iZ, Int_t* Nlist, Int_t Xlist[8], Int_t Zlist[8]){
     Xlist[7]=iX+1;
     Zlist[7]=iZ-1;
 }
+//______________________________________________________________________
+void AliITSsegmentationSPD::LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz){
+// Transformation from Geant detector centered local coordinates (cm) to
+// Pixel cell numbers ix and iz.
+// Input:
+// Float_t   x        detector local coordinate x in cm with respect to the
+//                    center of the sensitive volume.
+// Float_t   z        detector local coordinate z in cm with respect to the
+//                    center of the sensitive volulme.
+// Output:
+// Int_t    ix        detector x cell coordinate. Has the range 0<=ix<fNpx.
+// Int_t    iz        detector z cell coordinate. Has the range 0<=iz<fNpz.
+//   A value of -1 for ix or iz indecates that this point is outside of the
+// detector segmentation as defined.
+    Int_t i,j;
+    Float_t dx,dz;
+    const Float_t kconv = 1.0E-04; // converts microns to cm.
+
+    dx = -0.5*kconv*Dx();
+    dz = -0.5*kconv*Dz();
+    ix = -1;
+    iz = -1;
+    if(x<dx) return; // outside x range.
+    if(z<dz) return; // outside z range.
+    for(i=0;i<Npx();i++){
+       dx += kconv*fCellSizeX[i];
+       if(x<dx) break;
+    } // end for i
+    if(i>=Npx()) return; // outside x range.
+    for(j=0;j<Npz();j++){
+       dz += kconv*fCellSizeZ[j];
+       if(z<dz) break;
+    } // end for j
+    if(j>=Npz()) return; // outside z range.
+    ix = i;
+    iz = j;
+    return; // Found ix and iz, return.
+}
+//______________________________________________________________________
+void AliITSsegmentationSPD::DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z)
+{
+// Transformation from Detector cell coordiantes to Geant detector centerd 
+// local coordinates (cm).
+// Input:
+// Int_t    ix        detector x cell coordinate. Has the range 0<=ix<fNpx.
+// Int_t    iz        detector z cell coordinate. Has the range 0<=iz<fNpz.
+// Output:
+// Float_t   x        detector local coordinate x in cm with respect to the
+//                    center of the sensitive volume.
+// Float_t   z        detector local coordinate z in cm with respect to the
+//                    center of the sensitive volulme.
+// If ix and or iz is outside of the segmentation range a value of -0.5*Dx()
+// or -0.5*Dz() is returned.
+    Int_t i,j;
+    const Float_t kconv = 1.0E-04; // converts microns to cm.
+
+    x = -0.5*kconv*Dx(); // default value.
+    z = -0.5*kconv*Dz(); // default value.
+    if(ix<0 || ix>=Npx()) return; // outside of detector
+    if(iz<0 || iz>=Npz()) return; // outside of detctor
+    for(i=0;i<ix;i++) x += kconv*fCellSizeX[i]; // sum up to cell ix-1
+    x += 0.5*kconv*fCellSizeX[ix]; // add 1/2 of cell ix for center location.
+    for(j=0;j<iz;j++) z += kconv*fCellSizeZ[j]; // sum up cell iz-1
+    z += 0.5*kconv*fCellSizeZ[iz]; // add 1/2 of cell iz for center location.
+    return; // Found x and z, return.
+}
index 753e597f1281d4d4ac4d81e622f45ec42202dbfb..f4d78fe959039bc0e88dc05f60fb8958e8052b19 100644 (file)
@@ -26,6 +26,8 @@ public AliITSsegmentation {
 
     // Maximum number of pixels along the two coordinates  
     virtual void    SetNPads(Int_t p1, Int_t p2);
+    // Returns the maximum number of cells (digits) posible
+    virtual Int_t   GetNPads(){return fNpx*fNpz;}
 
     // Transform from real to pixel coordinates
     virtual void    GetPadIxz
@@ -39,6 +41,12 @@ public AliITSsegmentation {
     virtual void    GetGlobal(Int_t module,Float_t *l ,Float_t *g) {}
     // Local transformation of real local coordinates -
     virtual void    GetPadTxz(Float_t &x ,Float_t &z);
+    // Transformation from Geant cm detector center local coordinates
+    // to detector segmentation/cell coordiantes starting from (0,0).
+    virtual void    LocalToDet(Float_t x,Float_t z,Int_t &ix,Int_t &iz);
+    // Transformation from detector segmentation/cell coordiantes starting
+    // from (0,0) to Geant cm detector center local coordinates.
+    virtual void    DetToLocal(Int_t ix,Int_t iz,Float_t &x,Float_t &z);
     //
     // Initialisation
     virtual void Init();
@@ -67,7 +75,11 @@ public AliITSsegmentation {
     // Get next neighbours 
     virtual void Neighbours
        (Int_t iX,Int_t iZ,Int_t* Nlist,Int_t Xlist[10],Int_t Zlist[10]);
+    Float_t ColFromZ(Float_t z);
+    Float_t ZFromCol(Int_t col);
+    Float_t ZpitchFromCol(Int_t col);
 
+    
   protected:
 
     Int_t   fNpx;           // Number of pixels in x
index 1540aa7139caad90d351b35427277d5354fc74af..ecf28a497e64a59fffcc04184670eb176360e1ca 100644 (file)
@@ -25,11 +25,6 @@ AliITSsegmentationSSD::AliITSsegmentationSSD(){
   // default constructor
    fGeom=0;
    fCorr=0;
-   SetDetSize();
-   SetPadSize();
-   SetNPads();
-   SetAngles();
-   fLayer =5;
 }
 //------------------------------
 AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom){
@@ -40,10 +35,7 @@ AliITSsegmentationSSD::AliITSsegmentationSSD(AliITSgeom *geom){
    cout<<"Dx="<<fDx<<endl;
    SetPadSize();
    SetNPads();
-   SetAngles();
-   //Init(); 
-   fLayer =5;
-   cout<<"segmSSD - geom"<<endl;
+   Init();
 
 }
 //____________________________________________________________________________
@@ -53,16 +45,10 @@ AliITSsegmentationSSD& AliITSsegmentationSSD::operator=(AliITSsegmentationSSD &s
      this->fNstrips = source.fNstrips;
      this->fStereoP = source.fStereoP;
      this->fStereoN = source.fStereoN;
-     this->fStereoPl5 = source.fStereoPl5;
-     this->fStereoNl5 = source.fStereoNl5;
-     this->fStereoPl6 = source.fStereoPl6;
-     this->fStereoNl6 = source.fStereoNl6;
-     this->fLayer   = source.fLayer;
      this->fPitch   = source.fPitch;
      this->fDz      = source.fDz;
      this->fDx      = source.fDx;
      this->fDy      = source.fDy;
-     this->fLayer   = source.fLayer;
      this->fGeom    = source.fGeom; // copy only the pointer
      this->fCorr    = new TF1(*(source.fCorr)); // make a proper copy
      return *this;
@@ -90,34 +76,64 @@ void AliITSsegmentationSSD::Init(){
 
 }
 //-------------------------------------------------------
-void AliITSsegmentationSSD::Angles(Float_t &aP,Float_t &aN)
-     {
-        if (fLayer == 5)
-        {
-         aP = fStereoPl5;
-         aN = fStereoNl5;
-        }
-   
-        if (fLayer == 6)
-        {
-         aP = fStereoPl6;
-         aN = fStereoNl6;
-        }
-     }
-
-     void AliITSsegmentationSSD::SetLayer(Int_t l)
-     {
-     if (l==5) fLayer =5;
-     if (l==6) fLayer =6;
-     }
+void AliITSsegmentationSSD::GetPadTxz(Float_t &x,Float_t &z){
+  // returns P and N sided strip numbers for a given location.
+    // Transformation from microns detector center local coordinates
+    // to detector P and N side strip numbers..
+    /*                       _-  Z
+                    + angle /    ^
+        fNstrips           v     |   N-Side        ...0
+            \-------/------------|-----------\--------\
+            |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
+            |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
+            |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
+       X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
+            |00/////////////...  | ...\\\\\\\\\\\\\\\\|
+            |0/////////////...   |  ...\\\\\\\\\\\\\\\|
+            |//////////////...   |  ...\\\\\\\\\\\\\\\|
+            /-----\--------------|--------------------/
+        fNstrips-1             P-Side              ...0
+                     |0\
+                     |00\
+       Dead region: |000/
+                     |00/
+                     |0/
+    // expects x, z in microns
 
+    Float_t tanP=TMath::Tan(fStereoP);
+    Float_t tanN=TMath::Tan(-fStereoN);
+    Float_t x1 = x;
+    Float_t z1 = z;
+    x1 += fDx/2;
+    z1 += fDz/2;
+    x = (x1 - z1*tanP)/fPitch;
+    z = (x1 - tanN*(z1 - fDz))/fPitch;
+}
 //-------------------------------------------------------
 void AliITSsegmentationSSD::GetPadIxz(Float_t x,Float_t z,Int_t &iP,Int_t &iN)
 {
   // returns P and N sided strip numbers for a given location.
+    /*                       _-  Z
+                    + angle /    ^
+        fNstrips           v     |   N-Side        ...0
+            \-------/------------|-----------\--------\
+            |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
+            |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
+            |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
+       X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
+            |00/////////////...  | ...\\\\\\\\\\\\\\\\|
+            |0/////////////...   |  ...\\\\\\\\\\\\\\\|
+            |//////////////...   |  ...\\\\\\\\\\\\\\\|
+            /-----\--------------|--------------------/
+        fNstrips-1             P-Side              ...0
+                     |0\
+                     |00\
+       Dead region: |000/
+                     |00/
+                     |0/
 
     // expects x, z in microns
-
+/*
     Float_t tanP=TMath::Tan(fStereoP);
     Float_t tanN=TMath::Tan(fStereoN);
     //cout<<"1 segment::GetPad: xL,zL,fDx,fDz ="<<x<<","<<z<<","<<fDx<<","<<fDz<<endl;
@@ -125,17 +141,22 @@ void AliITSsegmentationSSD::GetPadIxz(Float_t x,Float_t z,Int_t &iP,Int_t &iN)
    tanP = 0.0075;
    tanN = 0.0275;
     Float_t x1=x,z1=z;
+//    cout << "GetPadIxz::Tan(" << fStereoP << ")=" << tanP << endl;
+//    cout << "GetPadIxz::Tan(" << fStereoN << ")=" << tanN << endl;
     x1 += fDx/2;
     z1 += fDz/2;
     Float_t  ldX = x1 - z1*tanP;          // distance from left-down edge 
-    iP = (Int_t)(ldX/fPitch);
+*/
+    this->GetPadTxz(x,z);  // use existing routine.
+    iP = (Int_t) x; //(Int_t)(ldX/fPitch);
     iP = (iP<0)? -1: iP;      
     iP = (iP>fNstrips)? -1: iP;
-
+/*
     //cout<<"3 segment::GetPad: x1,tanP,ix1 ="<<ldX<<","<<tanP<<","<<iP<<endl;
 
     ldX = x1 - tanN*(fDz - z1);
-    iN = (Int_t)(ldX/fPitch);
+*/
+    iN = (Int_t) z;  //(Int_t)(ldX/fPitch);
     iN = (iN<0)? -1: iN;
     iN = (iN>fNstrips)? -1: iN;
 
@@ -155,6 +176,9 @@ void AliITSsegmentationSSD::GetPadCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z)
     Float_t tanN=TMath::Tan(fStereoN);
 
     Float_t dx = 0.1;
+//    cout << "GetPadCxz::Tan(" << fStereoP << ")=" << tanP << endl;
+//    cout << "GetPadCxz::Tan(" << fStereoN << ")=" << tanN << endl;
+//    cout << "GetPadCxz::dx=" << dx << endl;
     x = iP*fPitch;
     z = iN*fPitch; 
 
@@ -171,3 +195,169 @@ void AliITSsegmentationSSD::GetPadCxz(Int_t iP,Int_t iN,Float_t &x,Float_t &z)
 
     return;   
 }
+//______________________________________________________________________
+void AliITSsegmentationSSD::LocalToDet(Float_t x,Float_t z,
+                                      Int_t &iP,Int_t &iN){
+    // Transformation from Geant cm detector center local coordinates
+    // to detector P and N side strip numbers..
+    /*                       _-  Z
+                    + angle /    ^
+        fNstrips           v     |   N-Side        ...0
+            \-------/------------|-----------\--------\
+            |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
+            |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
+            |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
+       X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
+            |00/////////////...  | ...\\\\\\\\\\\\\\\\|
+            |0/////////////...   |  ...\\\\\\\\\\\\\\\|
+            |//////////////...   |  ...\\\\\\\\\\\\\\\|
+            /-----\--------------|--------------------/
+        fNstrips-1             P-Side              ...0
+                     |0\
+                     |00\
+       Dead region: |000/
+                     |00/
+                     |0/
+    */
+    const Double_t kconst = 1.0E-04; // convert microns to cm.
+
+    x /= kconst;  // convert to microns
+    z /= kconst;  // convert to microns
+    this->GetPadTxz(x,z);
+
+    // first for P side
+    iP = (Int_t) x;
+    if(iP<0 || iP>=fNstrips) iP=-1; // strip number must be in range.
+    // Now for N side)
+    iN = (Int_t) z;
+    if(iN<0 || iN>=fNstrips) iN=-1; // strip number must be in range.
+    return;
+}
+//----------------------------------------------------------------------
+void AliITSsegmentationSSD::DetToLocal(Int_t ix,Int_t iPN,
+                                      Float_t &x,Float_t &z){
+    // Transformation from detector segmentation/cell coordiantes starting
+    // from 0. iPN=0 for P side and 1 for N side strip. Returned is z=0.0
+    // and the corresponding x value..
+    /*                       _-  Z
+                    + angle /    ^
+        fNstrips           v     |   N-Side        ...0
+            \-------/------------|-----------\--------\
+            |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
+            |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
+            |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
+       X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
+            |00/////////////...  | ...\\\\\\\\\\\\\\\\|
+            |0/////////////...   |  ...\\\\\\\\\\\\\\\|
+            |//////////////...   |  ...\\\\\\\\\\\\\\\|
+            /-----\--------------|--------------------/
+        fNstrips-1             P-Side              ...0
+                     |0\
+                     |00\
+       Dead region: |000/
+                     |00/
+                     |0/
+    */
+    // for strips p-side
+    // x = a + b + z*tan(fStereoP); a = Dpx(iP)*(iP+0.5)-dx; b = dz*th;
+    // for strips n-side
+    // x = a + b + z*tan(fStereoP); a = Dpx(iN)*(iN+0.5)-dx; b = -dz*th;
+    const Double_t kconst = 1.0E-04; // convert microns to cm.
+    Float_t flag=kconst*Dx(); // error value
+    Double_t th=0.0,dx,dz,i,a,b=0.0,xb[4],zb[4];
+
+    z = 0.0;  // Strip center in z.
+    if(iPN<0 || iPN>1){// if error return full detector size in x.
+       x = z = flag; return;
+    } // end if
+    if(ix<0 || ix>=fNstrips) {x = z = flag; return;} // if error return full
+                                                     // detector size in x.
+    i  = (Double_t) ix;      // convert to double
+    dx = 0.5*kconst*Dx();    // half distance in x in cm
+    dz = 0.5*kconst*Dz();    // half distance in z in cm
+    a  = kconst*Dpx(ix)*(i+0.5)-dx; // Min x value.
+    if(iPN==0){ //P-side angle defined backwards.
+       th = TMath::Tan(fStereoP); 
+       b  = dz*th;
+    }else if(iPN==1){ // N-side
+        th = TMath::Tan(-fStereoN);
+        b  = -dz*th;
+    } // end if
+    // compute average/center position of the strip.
+    xb[0] = +dx; if(th!=0.0) zb[0] = (+dx-a-b)/th; else zb[0] = 0.0;
+    xb[1] = -dx; if(th!=0.0) zb[1] = (-dx-a-b)/th; else zb[1] = 0.0;
+    xb[2] = a+b+dz*th; zb[2] = +dz;
+    xb[3] = a+b-dz*th; zb[3] = -dz;
+    x = 0.0; z = 0.0;
+    for(Int_t j=0;j<4;j++){
+//     cout << "xb["<<j<<"]="<<xb[j]<<" zb["<<j<<"[="<<zb[j]<<endl;
+       if(xb[j]>=-dx && xb[j]<=dx && zb[j]>=-dz && zb[j]<=dz){
+           x += xb[j];
+           z += zb[j];
+       } // end if
+    } // end for
+    x *= 0.5;
+    z *= 0.5;
+    return;
+}
+//----------------------------------------------------------------------
+Bool_t AliITSsegmentationSSD::GetCrossing(Int_t iP,Int_t iN,
+                                         Float_t &x,Float_t &z,
+                                         Float_t c[2][2]){
+    // Given one P side strip and one N side strip, Returns kTRUE if they
+    // cross each other and the location of the two crossing strips and
+    // their correxlation matrix c[2][2].
+    /*                       _-  Z
+                    + angle /    ^
+        fNstrips           v     |   N-Side        ...0
+            \-------/------------|-----------\--------\
+            |\\\\\\/////////////.|\\\\\\\\\\\\\\\\\\\\|
+            |0\\\\/////////////..|.\\\\\\\\\\\\\\\\\\\|
+            |00\\/////////////...|..\\\\\\\\\\\\\\\\\\|
+       X <--|000/////////////... |...\\\\\\\\\\\\\\\\\|
+            |00/////////////...  | ...\\\\\\\\\\\\\\\\|
+            |0/////////////...   |  ...\\\\\\\\\\\\\\\|
+            |//////////////...   |  ...\\\\\\\\\\\\\\\|
+            /-----\--------------|--------------------/
+        fNstrips-1             P-Side              ...0
+                     |0\
+                     |00\
+       Dead region: |000/
+                     |00/
+                     |0/
+       c[2][2] is defined as follows
+       /c[0][0]  c[0][1]\ /delta iP\ = /delta x\
+       \c[1][0]  c[1][1]/ \delta iN/ = \delta z/
+    */
+    const Double_t kconst = 1.0E-04; // convert microns to cm.
+    Double_t thp,thn,th,dx,dz,p,ip,in;
+
+    
+    thp = TMath::Tan(fStereoP);
+    thn = TMath::Tan(-fStereoN);
+    th  = thp-thn;
+    if(th==0.0) { // parall strips then never cross.
+       x = 0.0;
+       z = 0.0;
+       c[0][0] = c[1][0] = c[0][1] = c[1][1] = 0.0;
+       return kFALSE;
+    } // end if
+    // The strips must cross some place in space.
+    ip = (Double_t) iP;       // convert to double now for speed
+    in = (Double_t) iN;       // convert to double now for speed
+    dx = 0.5*kconst*Dx();     // half distance in x in cm
+    dz = 0.5*kconst*Dz();     // half distance in z in cm
+    p  = kconst*Dpx(iP);             // Get strip spacing/pitch now
+    x  = 0.5*p+dx + (p*(in*thp-ip*thn)-2.0*dz*thp*thn)/th;
+    z  =(p*(in-ip)-dz*(thp+thn))/th;
+    // compute correlations.
+    c[0][0] = -thn*p/th; // dx/diP
+    c[1][1] = p/th; // dz/diN
+    c[0][1] = p*thp/th; // dx/diN
+    c[1][0] = -p/th; // dz/diP
+    if(x<-dx || x>dx || z<-dz || z>dz) return kFALSE; // crossing is outside
+                                                      // of the detector so
+                                                      // these strips don't
+                                                      // cross.
+    return kTRUE;
+}
index 36981c72e4fb03fbeec57ab10bc330b7b9c81c62..d4137c8edf72f4535b65f47bc898843c27aadc85 100644 (file)
@@ -17,8 +17,8 @@ public AliITSsegmentation {
 
 
     // Detector size: x,z,y 
-    virtual  void   SetDetSize
-          (Float_t p1=72960., Float_t p2=40000., Float_t p3= 300.) 
+    virtual void   SetDetSize(Float_t p1=72960.,Float_t p2=40000.,
+                             Float_t p3= 300.) 
                         {fDx=p1; fDz=p2; fDy=p3;}
 
     // Strip size  
@@ -28,31 +28,38 @@ public AliITSsegmentation {
     // Maximum number of strips along the two coordinates  
     virtual void    SetNPads(Int_t p1=768, Int_t dummy=1) 
                          {fNstrips=p1;}
+    // Returns the maximum number of cells (digits) posible
+    virtual Int_t   GetNPads(){return 2*fNstrips;}
 
 
     // Set stereo angles Pside-Nside 
-    virtual void    SetAngles(Float_t pa=0.0075, Float_t na=0.0275) 
-                         {fStereoPl5=pa; fStereoNl5=na; fStereoPl6=na; fStereoNl6=pa;}
-
-    virtual void    SetAnglesLay5(Float_t pa=0.0075, Float_t na=0.0275) 
-                         {fStereoPl5=pa; fStereoNl5=na;}
-
-    virtual void    SetAnglesLay6(Float_t pa=0.0275, Float_t na=0.0075) 
-                         {fStereoPl6=pa; fStereoNl6=na;}
+    virtual void    SetAngles(Float_t pa=0.0175, Float_t na=0.0175) 
+                         {fStereoP=pa; fStereoN=na;}
 
     // Set stereo angles Pside-Nside 
     // Transform from real coordinates to strips
-    virtual void    GetPadIxz
-    (Float_t x ,Float_t z ,Int_t   &iP,Int_t  &iN);
+    virtual void    GetPadIxz(Float_t x ,Float_t z ,Int_t   &iP,Int_t  &iN);
     // Transform from strips to real coordinates
-    virtual void    GetPadCxz
-    (Int_t iP, Int_t iN, Float_t &x , Float_t &z);
+    virtual void    GetPadCxz(Int_t iP, Int_t iN, Float_t &x , Float_t &z);
+    virtual void    GetPadTxz(Float_t &x , Float_t &z);
 
     // Transform from real global to local coordinates
     virtual void    GetLocal(Int_t module,Float_t *g ,Float_t *l) {}
     // Transform from real local to global coordinates
     virtual void    GetGlobal(Int_t module,Float_t *l ,Float_t *g) {}
-
+    // Transformation from Geant cm detector center local coordinates
+    // to detector P and N side strip numbers..
+    virtual void    LocalToDet(Float_t x,Float_t z,Int_t &iP,Int_t &iN);
+    // Transformation from detector segmentation/cell coordiantes starting
+    // from 0. iPN=0 for P side and 1 for N side strip. Returned is z=0.0
+    // and the corresponding x value..
+    virtual void    DetToLocal(Int_t ix,Int_t iPN,Float_t &x,Float_t &z);
+    // Given one P side strip and one N side strip, Returns kTRUE if they
+    // cross each other and the location of the two crossing strips and
+    // their correxlation matrix c[2][2].
+    virtual Bool_t  GetCrossing(Int_t iP,Int_t iN,Float_t &x,Float_t &z,
+                               Float_t c[2][2]);
+    //
     virtual void Init();
 
     // Detector type geometry
@@ -72,26 +79,15 @@ public AliITSsegmentation {
     // Maximum number of Strips in z
     virtual Int_t    Npz(){return 1;}
 
-    // Angles : Pside stereo angle-Nside stereo angle
-     virtual void Angles(Float_t &aP,Float_t &aN);
-     virtual void SetLayer(Int_t l);
-     virtual Int_t GetLayer() const {return fLayer;}
-
   protected:
 
   Int_t      fNstrips;       // Number of strips in x 
-  Float_t    fStereoP;       // Stereo angle for Pside
-  Float_t    fStereoN;       // Stereo angle for Nside
-  Float_t    fPitch;         // Pitch of the strips
+  Float_t    fStereoP;       // Stereo angle for Pside (rad)
+  Float_t    fStereoN;       // Stereo angle for Nside (rad)
+  Float_t    fPitch;         // Pitch of the strips (microns)
   Float_t    fDz;            // Full width of the detector (z axis)- microns
   Float_t    fDx;            // Full length of the detector (x axis)- microns
-  Float_t    fDy;            // Full thickness of the detector (y axis) -um 
-  
-  Float_t    fStereoPl5;       // Stereo angle for Pside
-  Float_t    fStereoNl5;       // Stereo angle for Nside
-  Float_t    fStereoPl6;       // Stereo angle for Pside
-  Float_t    fStereoNl6;       // Stereo angle for Nside
-  Int_t      fLayer;
+  Float_t    fDy;            // Full thickness of the detector (y axis) -um
 
   AliITSgeom *fGeom;         //! pointer to the geometry class
   TF1*       fCorr;          // correction function