]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSgeomMatrix.cxx
warning added if the method GetITSgeom has to fetch the AliITSgeom pointer from file
[u/mrichter/AliRoot.git] / ITS / AliITSgeomMatrix.cxx
index a40e4f0ac2951f2522b88a9fcacc317970494368..20a8251c45f1466ac46accc8393f265ed5a593ce 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.7  2001/02/03 00:00:30  nilsen
-New version of AliITSgeom and related files. Now uses automatic streamers,
-set up for new formatted .det file which includes detector information.
-Additional smaller modifications are still to come.
-
-Revision 1.5  2000/10/02 16:32:35  barbera
-Forward declaration added
-
-Revision 1.1.2.6  2000/10/02 15:52:05  barbera
-Forward declaration added
-
-Revision 1.4  2000/09/07 17:30:45  nilsen
-fixed a bug in SixAnglesFromMatrix.
+/* $Id$ */
 
-Revision 1.3  2000/09/05 14:25:50  nilsen
-Made fixes for HP compiler. All function parameter default values placed
-in .h file. Fixed the usual problem with HP comilers and the "for(Int_t i..."
-business. Replaced casting (Double_t [3][3]) to (Double_t (*)[3]) for HP.
-Lastly removed all "const" before function parameters which were 2 dim. arrays,
-because on HP root generates some strange code (?). Thanks Peter for the
-changes.
-
-Revision 1.2  2000/08/29 20:16:50  nilsen
-New class for ITS coordiante transformations used by AliITSgeom nearly
-exclusively.
-
-Revision 1.1.2.1  2000/06/04 16:32:31  Nilsen
-A new class to hold the matrix information needed by AliITSgeom.
+////////////////////////////////////////////////////////////////////////
+// This is the implementation file for AliITSgeomMatrix class. It 
+// contains the routines to manipulate, setup, and queary the geometry 
+// of a given ITS module. An ITS module may be one of at least three
+// ITS detector technologies, Silicon Pixel, Drift, or Strip Detectors,
+// and variations of these in size and/or layout. These routines let
+// one go between ALICE global coordiantes (cm) to a given modules 
+// specific local coordinates (cm).
+////////////////////////////////////////////////////////////////////////
 
-*/
-#include <iostream.h>
-#include <iomanip.h>
+#include <Riostream.h>
 #include <TMath.h>
 #include <TBuffer.h>
+#include <TClass.h>
 
 #include "AliITSgeomMatrix.h"
 
@@ -78,13 +58,15 @@ AliITSgeomMatrix::AliITSgeomMatrix(){
        fid[i] = 0;
        frot[i] = ftran[i] = 0.0;
        for(j=0;j<3;j++) fm[i][j] = 0.0;
+       fCylR = fCylPhi = 0.0;
     }// end for i
     fm[0][0] = fm[1][1] = fm[2][2] = 1.0;
 }
 //----------------------------------------------------------------------
-AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &sourse){
+AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &sourse) : 
+    TObject(sourse){
 ////////////////////////////////////////////////////////////////////////
-// The standard copy constructor. This make a full / proper copy of
+// The standard Copy constructor. This make a full / proper copy of
 // this class.
 ////////////////////////////////////////////////////////////////////////
        Int_t i,j;
@@ -94,6 +76,8 @@ AliITSgeomMatrix::AliITSgeomMatrix(const AliITSgeomMatrix &sourse){
                this->fid[i]     = sourse.fid[i];
                this->frot[i]    = sourse.frot[i];
                this->ftran[i]   = sourse.ftran[i];
+               this->fCylR      = sourse.fCylR;
+               this->fCylPhi    = sourse.fCylPhi;
                for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
        }// end for i
 }
@@ -110,11 +94,13 @@ void AliITSgeomMatrix::operator=(const AliITSgeomMatrix &sourse){
                this->fid[i]     = sourse.fid[i];
                this->frot[i]    = sourse.frot[i];
                this->ftran[i]   = sourse.ftran[i];
+               this->fCylR      = sourse.fCylR;
+               this->fCylPhi    = sourse.fCylPhi;
                for(j=0;j<3;j++) this->fm[i][j] = sourse.fm[i][j];
        }// end for i
 }
 //----------------------------------------------------------------------
-AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt,const Int_t id[3],
+AliITSgeomMatrix::AliITSgeomMatrix(Int_t idt,const Int_t id[3],
                   const Double_t rot[3],const Double_t tran[3]){
 ////////////////////////////////////////////////////////////////////////
 // This is a constructor for the AliITSgeomMatrix class. The matrix is
@@ -132,18 +118,21 @@ AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt,const Int_t id[3],
 */
 //End_Html
 ////////////////////////////////////////////////////////////////////////
-       Int_t i;
+    Int_t i;
 
-       fDetectorIndex = idt; // a value never defined.
-       for(i=0;i<3;i++){
-               fid[i]   = id[i];
-               frot[i]  = rot[i];
-               ftran[i] = tran[i];
-       }// end for i
-       this->MatrixFromAngle();
+    fDetectorIndex = idt; // a value never defined.
+    for(i=0;i<3;i++){
+       fid[i]   = id[i];
+       frot[i]  = rot[i];
+       ftran[i] = tran[i];
+    }// end for i
+    fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+    fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+    if(fCylPhi<0.0) fCylPhi += TMath::Pi();
+    this->MatrixFromAngle();
 }
 //----------------------------------------------------------------------
-AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt, const Int_t id[3],
+AliITSgeomMatrix::AliITSgeomMatrix(Int_t idt, const Int_t id[3],
                                    Double_t matrix[3][3],
                                    const Double_t tran[3]){
 ////////////////////////////////////////////////////////////////////////
@@ -162,15 +151,18 @@ AliITSgeomMatrix::AliITSgeomMatrix(const Int_t idt, const Int_t id[3],
 */
 //End_Html
 ////////////////////////////////////////////////////////////////////////
-       Int_t i,j;
+    Int_t i,j;
 
-       fDetectorIndex = idt; // a value never defined.
-       for(i=0;i<3;i++){
-               fid[i]   = id[i];
-               ftran[i] = tran[i];
-               for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
-       }// end for i
-       this->AngleFromMatrix();
+    fDetectorIndex = idt; // a value never defined.
+    for(i=0;i<3;i++){
+       fid[i]   = id[i];
+       ftran[i] = tran[i];
+       for(j=0;j<3;j++) fm[i][j] = matrix[i][j];
+    }// end for i
+    fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+    fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+    if(fCylPhi<0.0) fCylPhi += TMath::Pi();
+    this->AngleFromMatrix();
 }
 //----------------------------------------------------------------------
 void AliITSgeomMatrix::SixAnglesFromMatrix(Double_t *ang){
@@ -251,7 +243,7 @@ void AliITSgeomMatrix::MatrixFromSixAngles(const Double_t *ang){
 }
 //----------------------------------------------------------------------
 AliITSgeomMatrix::AliITSgeomMatrix(const Double_t rotd[6]/*degrees*/,
-                                   const Int_t idt,const Int_t id[3],
+                                   Int_t idt,const Int_t id[3],
                                   const Double_t tran[3]){
 ////////////////////////////////////////////////////////////////////////
 // This is a constructor for the AliITSgeomMatrix class. The matrix is
@@ -276,6 +268,9 @@ AliITSgeomMatrix::AliITSgeomMatrix(const Double_t rotd[6]/*degrees*/,
        fid[i]   = id[i];
        ftran[i] = tran[i];
     }// end for i
+    fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+    fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+    if(fCylPhi<0.0) fCylPhi += TMath::Pi();
     this->MatrixFromSixAngles(rotd);
 }
 //----------------------------------------------------------------------
@@ -317,7 +312,7 @@ void AliITSgeomMatrix::MatrixFromAngle(){
 
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]){
+void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]) const {
 ////////////////////////////////////////////////////////////////////////
 // Returns the local coordinates given the global coordinates [cm].
 ////////////////////////////////////////////////////////////////////////
@@ -333,7 +328,7 @@ void AliITSgeomMatrix::GtoLPosition(const Double_t g0[3],Double_t l[3]){
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]){
+void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]) const {
 ////////////////////////////////////////////////////////////////////////
 // Returns the global coordinates given the local coordinates [cm].
 ////////////////////////////////////////////////////////////////////////
@@ -348,7 +343,7 @@ void AliITSgeomMatrix::LtoGPosition(const Double_t l[3],Double_t g[3]){
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::GtoLMomentum(const Double_t g[3],Double_t l[3]){
+void AliITSgeomMatrix::GtoLMomentum(const Double_t g[3],Double_t l[3]) const{
 ////////////////////////////////////////////////////////////////////////
 // Returns the local coordinates of the momentum given the global
 // coordinates of the momentum. It transforms just like GtoLPosition
@@ -364,7 +359,7 @@ void AliITSgeomMatrix::GtoLMomentum(const Double_t g[3],Double_t l[3]){
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]){
+void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]) const {
 ////////////////////////////////////////////////////////////////////////
 // Returns the Global coordinates of the momentum given the local
 // coordinates of the momentum. It transforms just like LtoGPosition
@@ -380,8 +375,8 @@ void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]){
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::GtoLPositionError(Double_t g[3][3],
-                                               Double_t l[3][3]){
+void AliITSgeomMatrix::GtoLPositionError(      Double_t g[3][3],
+                                               Double_t l[3][3]) const {
 ////////////////////////////////////////////////////////////////////////
 // Given an Uncertainty matrix in Global coordinates it is rotated so that 
 // its representation in local coordinates can be returned. There is no
@@ -389,14 +384,17 @@ void AliITSgeomMatrix::GtoLPositionError(Double_t g[3][3],
 ////////////////////////////////////////////////////////////////////////
        Int_t    i,j,k,m;
 
-       for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
-               l[i][m] = fm[j][i]*g[j][k]*fm[k][m];
-               // g = R^t l R
+       for(i=0;i<3;i++)for(m=0;m<3;m++){
+           l[i][m] = 0.0;
+           for(j=0;j<3;j++)for(k=0;k<3;k++)
+               l[i][m] += fm[j][i]*g[j][k]*fm[k][m];
+       } // end for i,m
+           // g = R^t l R
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::LtoGPositionError(Double_t l[3][3],
-                                               Double_t g[3][3]){
+void AliITSgeomMatrix::LtoGPositionError(      Double_t l[3][3],
+                                               Double_t g[3][3]) const {
 ////////////////////////////////////////////////////////////////////////
 // Given an Uncertainty matrix in Local coordinates it is rotated so that 
 // its representation in global coordinates can be returned. There is no
@@ -404,14 +402,17 @@ void AliITSgeomMatrix::LtoGPositionError(Double_t l[3][3],
 ////////////////////////////////////////////////////////////////////////
        Int_t    i,j,k,m;
 
-       for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
-               g[i][m] = fm[i][j]*l[j][k]*fm[m][k];
-               // g = R l R^t
+       for(i=0;i<3;i++)for(m=0;m<3;m++){
+           g[i][m] = 0.0;
+           for(j=0;j<3;j++)for(k=0;k<3;k++)
+               g[i][m] += fm[i][j]*l[j][k]*fm[m][k];
+       } // end for i,m
+           // g = R l R^t
        return;
 }
 //----------------------------------------------------------------------
 void AliITSgeomMatrix::GtoLPositionTracking(const Double_t g0[3],
-                                           Double_t l[3]){
+                                           Double_t l[3]) const {
 ////////////////////////////////////////////////////////////////////////
 // A slightly different coordinate system is used when tracking.
 // This coordinate system is only relevant when the geometry represents
@@ -442,7 +443,7 @@ void AliITSgeomMatrix::GtoLPositionTracking(const Double_t g0[3],
 }
 //----------------------------------------------------------------------
 void AliITSgeomMatrix::LtoGPositionTracking(const Double_t l[3],
-                                           Double_t g[3]){
+                                           Double_t g[3]) const {
 ////////////////////////////////////////////////////////////////////////
 // A slightly different coordinate system is used when tracking.
 // This coordinate system is only relevant when the geometry represents
@@ -473,7 +474,7 @@ void AliITSgeomMatrix::LtoGPositionTracking(const Double_t l[3],
 }
 //----------------------------------------------------------------------
 void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
-                                           Double_t l[3]){
+                                           Double_t l[3]) const {
 ////////////////////////////////////////////////////////////////////////
 // A slightly different coordinate system is used when tracking.
 // This coordinate system is only relevant when the geometry represents
@@ -501,11 +502,10 @@ void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
        l[2] = +l0[2];
     } // end if
     return;
-       return;
 }
 //----------------------------------------------------------------------
 void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
-                                           Double_t g[3]){
+                                           Double_t g[3]) const {
 ////////////////////////////////////////////////////////////////////////
 // A slightly different coordinate system is used when tracking.
 // This coordinate system is only relevant when the geometry represents
@@ -535,8 +535,8 @@ void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::GtoLPositionErrorTracking(Double_t g[3][3],
-                                                Double_t l[3][3]){
+void AliITSgeomMatrix::GtoLPositionErrorTracking(     Double_t g[3][3],
+                                                Double_t l[3][3]) const {
 ////////////////////////////////////////////////////////////////////////
 // A slightly different coordinate system is used when tracking.
 // This coordinate system is only relevant when the geometry represents
@@ -551,22 +551,25 @@ void AliITSgeomMatrix::GtoLPositionErrorTracking(Double_t g[3][3],
 //End_Html
 ////////////////////////////////////////////////////////////////////////
        Int_t    i,j,k,m;
-       Double_t Rt[3][3];
-       Double_t A0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
-       Double_t A1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
+       Double_t rt[3][3];
+       Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
+       Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
 
        if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
-           Rt[i][k] = A0[i][j]*fm[j][k];
+           rt[i][k] = a0[i][j]*fm[j][k];
        else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
-           Rt[i][k] = A1[i][j]*fm[j][k];
-       for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
-               l[i][m] = Rt[j][i]*g[j][k]*Rt[k][m];
-               // g = R^t l R
+           rt[i][k] = a1[i][j]*fm[j][k];
+       for(i=0;i<3;i++)for(m=0;m<3;m++){
+           l[i][m] = 0.0;
+           for(j=0;j<3;j++)for(k=0;k<3;k++)
+               l[i][m] += rt[j][i]*g[j][k]*rt[k][m];
+       } // end for i,m
+           // g = R^t l R
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::LtoGPositionErrorTracking(Double_t l[3][3],
-                                                Double_t g[3][3]){
+void AliITSgeomMatrix::LtoGPositionErrorTracking( Double_t l[3][3],
+                                                Double_t g[3][3]) const {
 ////////////////////////////////////////////////////////////////////////
 // A slightly different coordinate system is used when tracking.
 // This coordinate system is only relevant when the geometry represents
@@ -581,21 +584,24 @@ void AliITSgeomMatrix::LtoGPositionErrorTracking(Double_t l[3][3],
 //End_Html
 ////////////////////////////////////////////////////////////////////////
        Int_t    i,j,k,m;
-       Double_t Rt[3][3];
-       Double_t A0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
-       Double_t A1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
+       Double_t rt[3][3];
+       Double_t a0[3][3] = {{0.,+1.,0.},{-1.,0.,0.},{0.,0.,+1.}};
+       Double_t a1[3][3] = {{0.,-1.,0.},{+1.,0.,0.},{0.,0.,+1.}};
 
        if(fid[0]==1) for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
-           Rt[i][k] = A0[i][j]*fm[j][k];
+           rt[i][k] = a0[i][j]*fm[j][k];
        else for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)
-           Rt[i][k] = A1[i][j]*fm[j][k];
-       for(i=0;i<3;i++)for(j=0;j<3;j++)for(k=0;k<3;k++)for(m=0;m<3;m++)
-               g[i][m] = Rt[i][j]*l[j][k]*Rt[m][k];
-               // g = R l R^t
+           rt[i][k] = a1[i][j]*fm[j][k];
+       for(i=0;i<3;i++)for(m=0;m<3;m++){
+           g[i][m] = 0.0;
+           for(j=0;j<3;j++)for(k=0;k<3;k++)
+               g[i][m] += rt[i][j]*l[j][k]*rt[m][k];
+       } // end for i,m
+           // g = R l R^t
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::PrintTitles(ostream *os){
+void AliITSgeomMatrix::PrintTitles(ostream *os) const {
 ////////////////////////////////////////////////////////////////////////
 // Standard output format for this class but it includes variable
 // names and formatting that makes it easer to read.
@@ -614,7 +620,7 @@ void AliITSgeomMatrix::PrintTitles(ostream *os){
     return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::PrintComment(ostream *os){
+void AliITSgeomMatrix::PrintComment(ostream *os) const {
 ////////////////////////////////////////////////////////////////////////
 //  output format used by Print..
 ////////////////////////////////////////////////////////////////////////
@@ -629,7 +635,19 @@ void AliITSgeomMatrix::Print(ostream *os){
 // Standard output format for this class.
 ////////////////////////////////////////////////////////////////////////
     Int_t i,j;
+#if defined __GNUC__
+#if __GNUC__ > 2
+    ios::fmtflags fmt;
+#else
     Int_t fmt;
+#endif
+#else
+#if defined __ICC || defined __ECC || defined __xlC__
+    ios::fmtflags fmt;
+#else
+    Int_t fmt;
+#endif
+#endif
 
     fmt = os->setf(ios::scientific);  // set scientific floating point output
     *os << fDetectorIndex << " ";
@@ -655,8 +673,34 @@ void AliITSgeomMatrix::Read(istream *is){
     for(i=0;i<3;i++) *is >> ftran[i];
     for(i=0;i<3;i++)for(j=0;j<3;j++)  *is >> fm[i][j];
     AngleFromMatrix(); // compute angles frot[].
+    fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+    fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+    if(fCylPhi<0.0) fCylPhi += TMath::Pi();
     return;
 }
+//______________________________________________________________________
+void AliITSgeomMatrix::Streamer(TBuffer &R__b){
+   // Stream an object of class AliITSgeomMatrix.
+
+   if (R__b.IsReading()) {
+      AliITSgeomMatrix::Class()->ReadBuffer(R__b, this);
+      fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+      fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+      this->AngleFromMatrix();
+    if(fCylPhi<0.0) fCylPhi += TMath::Pi();
+   } else {
+      AliITSgeomMatrix::Class()->WriteBuffer(R__b, this);
+   }
+}
+//______________________________________________________________________
+void AliITSgeomMatrix::SetTranslation(const Double_t tran[3]){
+  // Sets the translation vector and computes fCylR and fCylPhi.
+  for(Int_t i=0;i<3;i++) ftran[i] = tran[i];
+  fCylR   = TMath::Sqrt(ftran[0]*ftran[0]+ftran[1]*ftran[1]);
+  fCylPhi = TMath::ATan2(ftran[1],ftran[0]);
+  if(fCylPhi<0.0) fCylPhi += TMath::Pi();
+}
+
 //----------------------------------------------------------------------
 ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
 ////////////////////////////////////////////////////////////////////////