ROOT logo
#ifndef ALIITSGEOMMATRIX_H
#define ALIITSGEOMMATRIX_H
/* Copyright(c) 2000, ALICE Experiment at CERN, All rights reserved. *
 * see cxx source for full Copyright notice.                         */

//////////////////////////////////////////////////////////////////////////
//  ITS geometry manipulation routines on the module level. This class is
//  to replace the structure ITS_geom in the class AliITSgeom.
//  Created May 30 2000.
//   version 0.0.0
// By Bjorn S. Nilsen
////////////////////////////////////////////////////////////////////////////
#include <TObject.h>
#include <TString.h>
class TPolyLine3D;
class TNode;
class TShape;

using std::ostream;
using std::istream;

class AliITSgeomMatrix : public TObject {
 public:
    AliITSgeomMatrix(); // Default constructor
    // Standard constructor #1
    AliITSgeomMatrix(Int_t idt,const Int_t id[3],
                     const Double_t rot[3],const Double_t tran[3]);
    // Standard constructor #2
    AliITSgeomMatrix(Int_t idt,const Int_t id[3],
                     Double_t matrix[3][3],const Double_t tran[3]);
    // Standard constructor #3
    AliITSgeomMatrix(const Double_t rotd[6]/*degrees GEANT angles*/,
                     Int_t idt,const Int_t id[3],
                     const Double_t tran[3]);
    // Copy constructor
    AliITSgeomMatrix(const AliITSgeomMatrix &source);
    // Assignment operator
    AliITSgeomMatrix& operator=(const AliITSgeomMatrix &source); 
    virtual ~AliITSgeomMatrix(){}; // default constructor.
    // Prints a line describing the output format of the function Print.
    void PrintComment(ostream *os) const;
    // Prints out the content of this class in ASCII format.
    void Print(ostream *os)const;
    // Prints out the content of this class in ASCII format but includes
    // formating and strings that make it more humanly readable.
    void PrintTitles(ostream *os) const;
    // Reads in the content of this class in the format of Print
    void Read(istream *is);
    virtual void Print(Option_t* const option="") const {
        TObject::Print(option);}
    virtual Int_t Read(const char *name) {return TObject::Read(name);}
    
    // Returns the geometry path corresponding to this transformation
    TString& GetPath(){return fPath;}
    // Sets the geometry path
    void SetPath(const Char_t *p){fPath = p;}
    void SetPath(const TString &p){fPath = p;}
    // Given the rotation angles [radians] it fills frot and computes
    // the rotation matrix fm.
    void SetAngles(const Double_t rot[3]){// [radians]
        for(Int_t i=0;i<3;i++)frot[i] = rot[i];this->MatrixFromAngle();}
    // Sets the translation vector and computes fCylR and fCylPhi.
    void SetTranslation(const Double_t tran[3]);
    // sets the rotation matrix and computes the rotation angles [radians]
    void SetMatrix(const Double_t matrix[3][3]){ for(Int_t i=0;i<3;i++)
        for(Int_t j=0;j<3;j++) fm[i][j]=matrix[i][j];this->AngleFromMatrix();}
    // Sets the detector index value
    void SetDetectorIndex(Int_t idt) {fDetectorIndex = idt;}
    // Sets the detector layer, ladder, detector (id) values.
    void SetIndex(const Int_t id[3]){
        for(Int_t i=0;i<3;i++) fid[i] = id[i];}
    // Returns the rotation angles [radians]
    void GetAngles(Double_t rot[3]) const {// [radians]
        for(Int_t i=0;i<3;i++)  rot[i] = frot[i];}
    // Returns the translation vector [cm]
    void GetTranslation(Double_t tran[3]) const {
        for(Int_t i=0;i<3;i++) tran[i] = ftran[i];}
    // Returns the translation vector in cylindrical
    // coordinates [cm,radians]
    void GetTranslationCylinderical (Double_t tran[3]) const {
        tran[0] = fCylR;
        tran[1] = fCylPhi;
        tran[2] = ftran[2];}
    // Returns the values of the rotation matrix
    void GetMatrix(Double_t matrix[3][3]) const {for(Int_t i=0;i<3;i++)
        for(Int_t j=0;j<3;j++) matrix[i][j] = fm[i][j];}
    // Returns the detector index value.
    Int_t GetDetectorIndex() const {return fDetectorIndex;}
    // returns the modules index layer, ladder, detector
    void  GetIndex(Int_t id[3]) const {for(Int_t i=0;i<3;i++) id[i] = fid[i];}
    // return the x,y,z components (global) of the normalized normal
    // vector which helps to define the plane the detector is a part of
    void GetGlobalNormal(Double_t &nx,Double_t &ny,Double_t &nz)const{
        Double_t ln[3]={0.0,1.0,0.0},gn[3];LtoGMomentum(ln,gn);
        nx = gn[0];ny=gn[1];nz=gn[2];return;}
    // Sets the rotation matrix based on the 6 GEANT rotation
    // angles [radian]
    void  MatrixFromSixAngles(const Double_t *ang);
    // Returns the 6 GEANT rotation angles [radians] from the
    // existing rotation matrix.
    void  SixAnglesFromMatrix(Double_t *ang)const;
    // Set rotation using the Euler's Chi-convention
    void SetEulerAnglesChi(const Double_t ang[3]);

    // Given a position in Cartesian ALICE global coordinates [cm]
    // returns the position in Cartesian detector/module local
    //coordinates [cm]
    void GtoLPosition(const Double_t g[3],Double_t l[3]) const;
    // Given a position in Cartesian detector/module local coordinates [cm]
    // returns the position in Cartesian ALICE global
    //coordinates [cm]
    void LtoGPosition(const Double_t l[3],Double_t g[3]) const;
    // Given a momentum in Cartesian ALICE global coordinates
    // returns the momentum in Cartesian detector/module local
    //coordinates
    void GtoLMomentum(const Double_t g[3],Double_t l[3]) const;
    // Given a momentum in Cartesian detector/module local coordinates 
    // returns the momentum in Cartesian ALICE global coordinates
    void LtoGMomentum(const Double_t l[3],Double_t g[3]) const;
    // given a position error matrix in ALICE Cartesian global
    // coordinates [cm] returns a position error matrix in detector/
    // module local Cartesian local coordinates [cm]
    void GtoLPositionError(const Double_t g[3][3],Double_t l[3][3]) const;
    // given a position error matrix in detector/module Cartesian local
    // coordinates [cm] returns a position error matrix in ALICE
    // Cartesian global coordinates [cm]
    void LtoGPositionError(const Double_t l[3][3],Double_t g[3][3]) const;
    // Tracking Related Routines
    void GtoLPositionTracking(const Double_t g[3],Double_t l[3]) const;
    // Given a position in Cartesian Tracking global coordinates [cm]
    // returns the position in Cartesian detector/module local
    // coordinates [cm]
    void LtoGPositionTracking(const Double_t l[3],Double_t g[3]) const;
    // Given a position in Cartesian detector/module local coordinates [cm]
    // returns the position in Cartesian Tracking global
    //coordinates [cm]
    void GtoLMomentumTracking(const Double_t g[3],Double_t l[3]) const;
    // Given a momentum in Cartesian detector/module local coordinates 
    // returns the momentum in Cartesian Tracking global coordinates
    void LtoGMomentumTracking(const Double_t l[3],Double_t g[3]) const;
    // given a position error matrix in Tracking Cartesian global
    // coordinates [cm] returns a position error matrix in detector/
    // module local Cartesian local coordinates [cm]
    void GtoLPositionErrorTracking(const Double_t g[3][3],
                                   Double_t l[3][3]) const;
    // given a position error matrix in detector/module Cartesian local
    // coordinates [cm] returns a position error matrix in Tracking
    // Cartesian global coordinates [cm]
    void LtoGPositionErrorTracking(const Double_t l[3][3],
                                   Double_t g[3][3]) const;
    // Computes the distance squared [cm^2] between a point t[3] and
    // this module/detector
    Double_t Distance2(const Double_t t[3]) const {Double_t d=0.0,q;
    for(Int_t i=0;i<3;i++){q = t[i]-ftran[i]; d += q*q;}
    return d;}
     //
     // Documentation related Class
     TPolyLine3D* CreateLocalAxis() const;
     TPolyLine3D* CreateLocalAxisTracking() const;
     TNode* CreateNode(const Char_t *nodeName,const Char_t *nodeTitle,
                       TNode *mother,TShape *shape,Bool_t axis=kTRUE) const;
     void MakeFigures() const;
     //
 private: // private functions
     // Given the rotation matrix fm it fills the rotation angles frot
     void MatrixFromAngle();
     // Given the rotation angles frot it fills the rotation matrix fm
     void AngleFromMatrix();
 private: // Data members.
     Int_t    fDetectorIndex; // Detector type index (like fShapeIndex was)
     Int_t    fid[3];         // layer, ladder, detector numbers.
     Double_t frot[3];        //! vector of rotations about x,y,z [radians].
     Double_t ftran[3];       // Translation vector of module x,y,z.
     Double_t fCylR,fCylPhi;  //! Translation vector in Cylindrical coord.
     Double_t fm[3][3];       // Rotation matrix based on frot.
     TString  fPath;          // Path within Geometry to this volume
     
     // Note, fCylR and fCylPhi are added as data members because it costs
     // about a factor of 10 to compute them over looking them up. Since
     // they are used in some tracking algorithms this can be a large cost
     // in computing time. They are not written out but computed.
     
     ClassDef(AliITSgeomMatrix,2) // Matrix class used by AliITSgeom.
};
// Input and output function for standard C++ input/output.
ostream &operator<<(ostream &os,AliITSgeomMatrix &source);
istream &operator>>(istream &os,AliITSgeomMatrix &source);

#endif
 AliITSgeomMatrix.h:1
 AliITSgeomMatrix.h:2
 AliITSgeomMatrix.h:3
 AliITSgeomMatrix.h:4
 AliITSgeomMatrix.h:5
 AliITSgeomMatrix.h:6
 AliITSgeomMatrix.h:7
 AliITSgeomMatrix.h:8
 AliITSgeomMatrix.h:9
 AliITSgeomMatrix.h:10
 AliITSgeomMatrix.h:11
 AliITSgeomMatrix.h:12
 AliITSgeomMatrix.h:13
 AliITSgeomMatrix.h:14
 AliITSgeomMatrix.h:15
 AliITSgeomMatrix.h:16
 AliITSgeomMatrix.h:17
 AliITSgeomMatrix.h:18
 AliITSgeomMatrix.h:19
 AliITSgeomMatrix.h:20
 AliITSgeomMatrix.h:21
 AliITSgeomMatrix.h:22
 AliITSgeomMatrix.h:23
 AliITSgeomMatrix.h:24
 AliITSgeomMatrix.h:25
 AliITSgeomMatrix.h:26
 AliITSgeomMatrix.h:27
 AliITSgeomMatrix.h:28
 AliITSgeomMatrix.h:29
 AliITSgeomMatrix.h:30
 AliITSgeomMatrix.h:31
 AliITSgeomMatrix.h:32
 AliITSgeomMatrix.h:33
 AliITSgeomMatrix.h:34
 AliITSgeomMatrix.h:35
 AliITSgeomMatrix.h:36
 AliITSgeomMatrix.h:37
 AliITSgeomMatrix.h:38
 AliITSgeomMatrix.h:39
 AliITSgeomMatrix.h:40
 AliITSgeomMatrix.h:41
 AliITSgeomMatrix.h:42
 AliITSgeomMatrix.h:43
 AliITSgeomMatrix.h:44
 AliITSgeomMatrix.h:45
 AliITSgeomMatrix.h:46
 AliITSgeomMatrix.h:47
 AliITSgeomMatrix.h:48
 AliITSgeomMatrix.h:49
 AliITSgeomMatrix.h:50
 AliITSgeomMatrix.h:51
 AliITSgeomMatrix.h:52
 AliITSgeomMatrix.h:53
 AliITSgeomMatrix.h:54
 AliITSgeomMatrix.h:55
 AliITSgeomMatrix.h:56
 AliITSgeomMatrix.h:57
 AliITSgeomMatrix.h:58
 AliITSgeomMatrix.h:59
 AliITSgeomMatrix.h:60
 AliITSgeomMatrix.h:61
 AliITSgeomMatrix.h:62
 AliITSgeomMatrix.h:63
 AliITSgeomMatrix.h:64
 AliITSgeomMatrix.h:65
 AliITSgeomMatrix.h:66
 AliITSgeomMatrix.h:67
 AliITSgeomMatrix.h:68
 AliITSgeomMatrix.h:69
 AliITSgeomMatrix.h:70
 AliITSgeomMatrix.h:71
 AliITSgeomMatrix.h:72
 AliITSgeomMatrix.h:73
 AliITSgeomMatrix.h:74
 AliITSgeomMatrix.h:75
 AliITSgeomMatrix.h:76
 AliITSgeomMatrix.h:77
 AliITSgeomMatrix.h:78
 AliITSgeomMatrix.h:79
 AliITSgeomMatrix.h:80
 AliITSgeomMatrix.h:81
 AliITSgeomMatrix.h:82
 AliITSgeomMatrix.h:83
 AliITSgeomMatrix.h:84
 AliITSgeomMatrix.h:85
 AliITSgeomMatrix.h:86
 AliITSgeomMatrix.h:87
 AliITSgeomMatrix.h:88
 AliITSgeomMatrix.h:89
 AliITSgeomMatrix.h:90
 AliITSgeomMatrix.h:91
 AliITSgeomMatrix.h:92
 AliITSgeomMatrix.h:93
 AliITSgeomMatrix.h:94
 AliITSgeomMatrix.h:95
 AliITSgeomMatrix.h:96
 AliITSgeomMatrix.h:97
 AliITSgeomMatrix.h:98
 AliITSgeomMatrix.h:99
 AliITSgeomMatrix.h:100
 AliITSgeomMatrix.h:101
 AliITSgeomMatrix.h:102
 AliITSgeomMatrix.h:103
 AliITSgeomMatrix.h:104
 AliITSgeomMatrix.h:105
 AliITSgeomMatrix.h:106
 AliITSgeomMatrix.h:107
 AliITSgeomMatrix.h:108
 AliITSgeomMatrix.h:109
 AliITSgeomMatrix.h:110
 AliITSgeomMatrix.h:111
 AliITSgeomMatrix.h:112
 AliITSgeomMatrix.h:113
 AliITSgeomMatrix.h:114
 AliITSgeomMatrix.h:115
 AliITSgeomMatrix.h:116
 AliITSgeomMatrix.h:117
 AliITSgeomMatrix.h:118
 AliITSgeomMatrix.h:119
 AliITSgeomMatrix.h:120
 AliITSgeomMatrix.h:121
 AliITSgeomMatrix.h:122
 AliITSgeomMatrix.h:123
 AliITSgeomMatrix.h:124
 AliITSgeomMatrix.h:125
 AliITSgeomMatrix.h:126
 AliITSgeomMatrix.h:127
 AliITSgeomMatrix.h:128
 AliITSgeomMatrix.h:129
 AliITSgeomMatrix.h:130
 AliITSgeomMatrix.h:131
 AliITSgeomMatrix.h:132
 AliITSgeomMatrix.h:133
 AliITSgeomMatrix.h:134
 AliITSgeomMatrix.h:135
 AliITSgeomMatrix.h:136
 AliITSgeomMatrix.h:137
 AliITSgeomMatrix.h:138
 AliITSgeomMatrix.h:139
 AliITSgeomMatrix.h:140
 AliITSgeomMatrix.h:141
 AliITSgeomMatrix.h:142
 AliITSgeomMatrix.h:143
 AliITSgeomMatrix.h:144
 AliITSgeomMatrix.h:145
 AliITSgeomMatrix.h:146
 AliITSgeomMatrix.h:147
 AliITSgeomMatrix.h:148
 AliITSgeomMatrix.h:149
 AliITSgeomMatrix.h:150
 AliITSgeomMatrix.h:151
 AliITSgeomMatrix.h:152
 AliITSgeomMatrix.h:153
 AliITSgeomMatrix.h:154
 AliITSgeomMatrix.h:155
 AliITSgeomMatrix.h:156
 AliITSgeomMatrix.h:157
 AliITSgeomMatrix.h:158
 AliITSgeomMatrix.h:159
 AliITSgeomMatrix.h:160
 AliITSgeomMatrix.h:161
 AliITSgeomMatrix.h:162
 AliITSgeomMatrix.h:163
 AliITSgeomMatrix.h:164
 AliITSgeomMatrix.h:165
 AliITSgeomMatrix.h:166
 AliITSgeomMatrix.h:167
 AliITSgeomMatrix.h:168
 AliITSgeomMatrix.h:169
 AliITSgeomMatrix.h:170
 AliITSgeomMatrix.h:171
 AliITSgeomMatrix.h:172
 AliITSgeomMatrix.h:173
 AliITSgeomMatrix.h:174
 AliITSgeomMatrix.h:175
 AliITSgeomMatrix.h:176
 AliITSgeomMatrix.h:177
 AliITSgeomMatrix.h:178
 AliITSgeomMatrix.h:179
 AliITSgeomMatrix.h:180
 AliITSgeomMatrix.h:181
 AliITSgeomMatrix.h:182
 AliITSgeomMatrix.h:183
 AliITSgeomMatrix.h:184
 AliITSgeomMatrix.h:185
 AliITSgeomMatrix.h:186
 AliITSgeomMatrix.h:187
 AliITSgeomMatrix.h:188
 AliITSgeomMatrix.h:189