]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSgeomMatrix.h
Merge remote-tracking branch 'origin/master' into flatdev
[u/mrichter/AliRoot.git] / ITS / AliITSgeomMatrix.h
CommitLineData
df5240ea 1#ifndef ALIITSGEOMMATRIX_H
2#define ALIITSGEOMMATRIX_H
3/* Copyright(c) 2000, ALICE Experiment at CERN, All rights reserved. *
4 * see cxx source for full Copyright notice. */
6b0f3880 5
6//////////////////////////////////////////////////////////////////////////
7// ITS geometry manipulation routines on the module level. This class is
8// to replace the structure ITS_geom in the class AliITSgeom.
9// Created May 30 2000.
10// version 0.0.0
11// By Bjorn S. Nilsen
12////////////////////////////////////////////////////////////////////////////
85f1e34a 13#include <TObject.h>
023ae34b 14#include <TString.h>
15class TPolyLine3D;
16class TNode;
17class TShape;
85f1e34a 18
fe7d86eb 19using std::ostream;
20using std::istream;
21
8253cd9a 22class AliITSgeomMatrix : public TObject {
df5240ea 23 public:
012f0f4c 24 AliITSgeomMatrix(); // Default constructor
25 // Standard constructor #1
26 AliITSgeomMatrix(Int_t idt,const Int_t id[3],
27 const Double_t rot[3],const Double_t tran[3]);
28 // Standard constructor #2
29 AliITSgeomMatrix(Int_t idt,const Int_t id[3],
30 Double_t matrix[3][3],const Double_t tran[3]);
31 // Standard constructor #3
32 AliITSgeomMatrix(const Double_t rotd[6]/*degrees GEANT angles*/,
33 Int_t idt,const Int_t id[3],
34 const Double_t tran[3]);
35 // Copy constructor
36 AliITSgeomMatrix(const AliITSgeomMatrix &source);
37 // Assignment operator
38 AliITSgeomMatrix& operator=(const AliITSgeomMatrix &source);
39 virtual ~AliITSgeomMatrix(){}; // default constructor.
40 // Prints a line describing the output format of the function Print.
41 void PrintComment(ostream *os) const;
42 // Prints out the content of this class in ASCII format.
43 void Print(ostream *os)const;
44 // Prints out the content of this class in ASCII format but includes
45 // formating and strings that make it more humanly readable.
46 void PrintTitles(ostream *os) const;
47 // Reads in the content of this class in the format of Print
48 void Read(istream *is);
494c2a61 49 virtual void Print(Option_t* const option="") const {
012f0f4c 50 TObject::Print(option);}
51 virtual Int_t Read(const char *name) {return TObject::Read(name);}
52
53 // Returns the geometry path corresponding to this transformation
54 TString& GetPath(){return fPath;}
55 // Sets the geometry path
56 void SetPath(const Char_t *p){fPath = p;}
57 void SetPath(const TString &p){fPath = p;}
58 // Given the rotation angles [radians] it fills frot and computes
59 // the rotation matrix fm.
60 void SetAngles(const Double_t rot[3]){// [radians]
61 for(Int_t i=0;i<3;i++)frot[i] = rot[i];this->MatrixFromAngle();}
62 // Sets the translation vector and computes fCylR and fCylPhi.
63 void SetTranslation(const Double_t tran[3]);
64 // sets the rotation matrix and computes the rotation angles [radians]
65 void SetMatrix(const Double_t matrix[3][3]){ for(Int_t i=0;i<3;i++)
66 for(Int_t j=0;j<3;j++) fm[i][j]=matrix[i][j];this->AngleFromMatrix();}
67 // Sets the detector index value
68 void SetDetectorIndex(Int_t idt) {fDetectorIndex = idt;}
69 // Sets the detector layer, ladder, detector (id) values.
70 void SetIndex(const Int_t id[3]){
71 for(Int_t i=0;i<3;i++) fid[i] = id[i];}
72 // Returns the rotation angles [radians]
73 void GetAngles(Double_t rot[3]) const {// [radians]
74 for(Int_t i=0;i<3;i++) rot[i] = frot[i];}
75 // Returns the translation vector [cm]
76 void GetTranslation(Double_t tran[3]) const {
77 for(Int_t i=0;i<3;i++) tran[i] = ftran[i];}
78 // Returns the translation vector in cylindrical
79 // coordinates [cm,radians]
80 void GetTranslationCylinderical (Double_t tran[3]) const {
81 tran[0] = fCylR;
82 tran[1] = fCylPhi;
83 tran[2] = ftran[2];}
84 // Returns the values of the rotation matrix
85 void GetMatrix(Double_t matrix[3][3]) const {for(Int_t i=0;i<3;i++)
86 for(Int_t j=0;j<3;j++) matrix[i][j] = fm[i][j];}
87 // Returns the detector index value.
88 Int_t GetDetectorIndex() const {return fDetectorIndex;}
89 // returns the modules index layer, ladder, detector
90 void GetIndex(Int_t id[3]) const {for(Int_t i=0;i<3;i++) id[i] = fid[i];}
91 // return the x,y,z components (global) of the normalized normal
92 // vector which helps to define the plane the detector is a part of
93 void GetGlobalNormal(Double_t &nx,Double_t &ny,Double_t &nz)const{
94 Double_t ln[3]={0.0,1.0,0.0},gn[3];LtoGMomentum(ln,gn);
95 nx = gn[0];ny=gn[1];nz=gn[2];return;}
96 // Sets the rotation matrix based on the 6 GEANT rotation
97 // angles [radian]
98 void MatrixFromSixAngles(const Double_t *ang);
99 // Returns the 6 GEANT rotation angles [radians] from the
100 // existing rotation matrix.
101 void SixAnglesFromMatrix(Double_t *ang)const;
102 // Set rotation using the Euler's Chi-convention
103 void SetEulerAnglesChi(const Double_t ang[3]);
df5240ea 104
012f0f4c 105 // Given a position in Cartesian ALICE global coordinates [cm]
106 // returns the position in Cartesian detector/module local
107 //coordinates [cm]
108 void GtoLPosition(const Double_t g[3],Double_t l[3]) const;
109 // Given a position in Cartesian detector/module local coordinates [cm]
110 // returns the position in Cartesian ALICE global
111 //coordinates [cm]
112 void LtoGPosition(const Double_t l[3],Double_t g[3]) const;
113 // Given a momentum in Cartesian ALICE global coordinates
114 // returns the momentum in Cartesian detector/module local
115 //coordinates
116 void GtoLMomentum(const Double_t g[3],Double_t l[3]) const;
117 // Given a momentum in Cartesian detector/module local coordinates
118 // returns the momentum in Cartesian ALICE global coordinates
119 void LtoGMomentum(const Double_t l[3],Double_t g[3]) const;
120 // given a position error matrix in ALICE Cartesian global
121 // coordinates [cm] returns a position error matrix in detector/
122 // module local Cartesian local coordinates [cm]
123 void GtoLPositionError(const Double_t g[3][3],Double_t l[3][3]) const;
124 // given a position error matrix in detector/module Cartesian local
125 // coordinates [cm] returns a position error matrix in ALICE
126 // Cartesian global coordinates [cm]
127 void LtoGPositionError(const Double_t l[3][3],Double_t g[3][3]) const;
128 // Tracking Related Routines
129 void GtoLPositionTracking(const Double_t g[3],Double_t l[3]) const;
130 // Given a position in Cartesian Tracking global coordinates [cm]
131 // returns the position in Cartesian detector/module local
132 // coordinates [cm]
133 void LtoGPositionTracking(const Double_t l[3],Double_t g[3]) const;
134 // Given a position in Cartesian detector/module local coordinates [cm]
135 // returns the position in Cartesian Tracking global
136 //coordinates [cm]
137 void GtoLMomentumTracking(const Double_t g[3],Double_t l[3]) const;
138 // Given a momentum in Cartesian detector/module local coordinates
139 // returns the momentum in Cartesian Tracking global coordinates
140 void LtoGMomentumTracking(const Double_t l[3],Double_t g[3]) const;
141 // given a position error matrix in Tracking Cartesian global
142 // coordinates [cm] returns a position error matrix in detector/
143 // module local Cartesian local coordinates [cm]
144 void GtoLPositionErrorTracking(const Double_t g[3][3],
145 Double_t l[3][3]) const;
146 // given a position error matrix in detector/module Cartesian local
147 // coordinates [cm] returns a position error matrix in Tracking
148 // Cartesian global coordinates [cm]
149 void LtoGPositionErrorTracking(const Double_t l[3][3],
150 Double_t g[3][3]) const;
151 // Computes the distance squared [cm^2] between a point t[3] and
152 // this module/detector
153 Double_t Distance2(const Double_t t[3]) const {Double_t d=0.0,q;
154 for(Int_t i=0;i<3;i++){q = t[i]-ftran[i]; d += q*q;}
155 return d;}
023ae34b 156 //
157 // Documentation related Class
6b0f3880 158 TPolyLine3D* CreateLocalAxis() const;
159 TPolyLine3D* CreateLocalAxisTracking() const;
023ae34b 160 TNode* CreateNode(const Char_t *nodeName,const Char_t *nodeTitle,
6b0f3880 161 TNode *mother,TShape *shape,Bool_t axis=kTRUE) const;
162 void MakeFigures() const;
023ae34b 163 //
df5240ea 164 private: // private functions
012f0f4c 165 // Given the rotation matrix fm it fills the rotation angles frot
166 void MatrixFromAngle();
167 // Given the rotation angles frot it fills the rotation matrix fm
168 void AngleFromMatrix();
df5240ea 169 private: // Data members.
012f0f4c 170 Int_t fDetectorIndex; // Detector type index (like fShapeIndex was)
171 Int_t fid[3]; // layer, ladder, detector numbers.
172 Double_t frot[3]; //! vector of rotations about x,y,z [radians].
173 Double_t ftran[3]; // Translation vector of module x,y,z.
174 Double_t fCylR,fCylPhi; //! Translation vector in Cylindrical coord.
175 Double_t fm[3][3]; // Rotation matrix based on frot.
176 TString fPath; // Path within Geometry to this volume
177
178 // Note, fCylR and fCylPhi are added as data members because it costs
179 // about a factor of 10 to compute them over looking them up. Since
180 // they are used in some tracking algorithms this can be a large cost
181 // in computing time. They are not written out but computed.
182
183 ClassDef(AliITSgeomMatrix,2) // Matrix class used by AliITSgeom.
df5240ea 184};
185// Input and output function for standard C++ input/output.
186ostream &operator<<(ostream &os,AliITSgeomMatrix &source);
187istream &operator>>(istream &os,AliITSgeomMatrix &source);
188
189#endif