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