]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSgeomMatrix.cxx
Revert one change (Sun,Alpha)
[u/mrichter/AliRoot.git] / ITS / AliITSgeomMatrix.cxx
index 617eb48221115fa7023c930dd301144fa1683a10..c3d932b5c3956a1108c7964a33d9cef0f0016a0f 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-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.
-
-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.
+/* $Id$ */
 
-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"
 
@@ -73,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;
@@ -89,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
 }
@@ -105,6 +94,8 @@ 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
 }
@@ -127,15 +118,18 @@ 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],
@@ -157,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){
@@ -271,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);
 }
 //----------------------------------------------------------------------
@@ -375,7 +375,7 @@ void AliITSgeomMatrix::LtoGMomentum(const Double_t l[3],Double_t g[3]){
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::GtoLPositionError(Double_t g[3][3],
+void AliITSgeomMatrix::GtoLPositionError(      Double_t g[3][3],
                                                Double_t l[3][3]){
 ////////////////////////////////////////////////////////////////////////
 // Given an Uncertainty matrix in Global coordinates it is rotated so that 
@@ -384,13 +384,16 @@ 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],
+void AliITSgeomMatrix::LtoGPositionError(      Double_t l[3][3],
                                                Double_t g[3][3]){
 ////////////////////////////////////////////////////////////////////////
 // Given an Uncertainty matrix in Local coordinates it is rotated so that 
@@ -399,9 +402,12 @@ 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;
 }
 //----------------------------------------------------------------------
@@ -496,7 +502,6 @@ void AliITSgeomMatrix::GtoLMomentumTracking(const Double_t g[3],
        l[2] = +l0[2];
     } // end if
     return;
-       return;
 }
 //----------------------------------------------------------------------
 void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
@@ -530,7 +535,7 @@ void AliITSgeomMatrix::LtoGMomentumTracking(const Double_t l[3],
        return;
 }
 //----------------------------------------------------------------------
-void AliITSgeomMatrix::GtoLPositionErrorTracking(Double_t g[3][3],
+void AliITSgeomMatrix::GtoLPositionErrorTracking(     Double_t g[3][3],
                                                 Double_t l[3][3]){
 ////////////////////////////////////////////////////////////////////////
 // A slightly different coordinate system is used when tracking.
@@ -546,21 +551,24 @@ 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],
+void AliITSgeomMatrix::LtoGPositionErrorTracking( Double_t l[3][3],
                                                 Double_t g[3][3]){
 ////////////////////////////////////////////////////////////////////////
 // A slightly different coordinate system is used when tracking.
@@ -576,17 +584,20 @@ 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;
 }
 //----------------------------------------------------------------------
@@ -624,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
     ios::fmtflags fmt;
+#else
+    Int_t fmt;
+#endif
+#endif
 
     fmt = os->setf(ios::scientific);  // set scientific floating point output
     *os << fDetectorIndex << " ";
@@ -650,8 +673,25 @@ 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);
+   }
+}
 //----------------------------------------------------------------------
 ostream &operator<<(ostream &os,AliITSgeomMatrix &p){
 ////////////////////////////////////////////////////////////////////////