]>
Commit | Line | Data |
---|---|---|
451f5018 | 1 | #ifndef ALIITSUGEOMTGEO_H |
2 | #define ALIITSUGEOMTGEO_H | |
3 | /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * See cxx source for full Copyright notice */ | |
5 | ||
6 | ///////////////////////////////////////////////////////////////////////// | |
7 | // AliITSUGeomTGeo is a simple interface class to TGeoManager // | |
8 | // It is used in the simulation and reconstruction in order to // | |
9 | // query the TGeo ITS geometry // | |
10 | // // | |
11 | // author - cvetan.cheshkov@cern.ch // | |
12 | // 15/02/2007 // | |
13 | // adapted to ITSupg 18/07/2012 - ruben.shahoyan@cern.ch // | |
14 | // RS: in order to preserve the static character of the class but // | |
15 | // make it dynamically access geometry, we need to check in every // | |
16 | // method if the structures are initialized. To be converted to // | |
17 | // singleton at later stage. // | |
18 | // // | |
19 | // Note on the upgrade detector types: // | |
20 | // The coarse type defines detectors served by different classes, // | |
75875328 | 21 | // like Pix. Each such a detector type can have kMaxSegmPerDetType // |
451f5018 | 22 | // segmentations (pitch etc.) whose parameteres are stored in the // |
75875328 | 23 | // AliITSsegmentation derived class (like AliITSUSegmentationPix) // |
451f5018 | 24 | // This allows to have in the setup modules served by the same // |
25 | // classes but with different segmentations. // | |
26 | // The full detector type is composed as: // | |
27 | // CoarseType*kMaxSegmPerDetType + segmentationType // | |
28 | // The only requirement on the segmentationType that should be // | |
29 | // < kMaxSegmPerDetType. // | |
30 | // The methods like GetLayerDetTypeID return the full detector type // | |
31 | // // | |
32 | // // | |
33 | ///////////////////////////////////////////////////////////////////////// | |
34 | ||
35 | #include <TObject.h> | |
36 | #include <TGeoMatrix.h> | |
37 | #include <TString.h> | |
38 | ||
39 | class TGeoPNEntry; | |
40 | class TDatime; | |
41 | ||
42 | class AliITSUGeomTGeo : public TObject { | |
43 | ||
44 | public: | |
45 | enum {kITSVNA, kITSVUpg}; // ITS version | |
02d6eccc | 46 | enum {kDetTypePix=0, kNDetTypes, kMaxSegmPerDetType=10}; // defined detector types (each one can have different segmentations) |
451f5018 | 47 | // |
48 | AliITSUGeomTGeo(Bool_t build = kFALSE); | |
49 | virtual ~AliITSUGeomTGeo(); | |
50 | AliITSUGeomTGeo(const AliITSUGeomTGeo &src); | |
51 | AliITSUGeomTGeo& operator=(const AliITSUGeomTGeo &geom); | |
52 | // | |
02d6eccc | 53 | Int_t GetNModules() const {return fNModules;} |
54 | Int_t GetNDetectors(Int_t lay) const {return fNDetectors[lay];} | |
55 | Int_t GetNLadders(Int_t lay) const {return fNLadders[lay];} | |
56 | Int_t GetNLayers() const {return fNLayers;} | |
451f5018 | 57 | |
02d6eccc | 58 | Int_t GetModuleIndex(Int_t lay,int detInLay) const {return GetFirstModIndex(lay)+detInLay;} |
451f5018 | 59 | Int_t GetModuleIndex(Int_t lay,Int_t lad,Int_t det) const; |
60 | Bool_t GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det) const; | |
61 | Int_t GetLayer(Int_t index) const; | |
62 | Int_t GetLadder(Int_t index) const; | |
63 | Int_t GetModIdInLayer(Int_t index) const; | |
64 | Int_t GetModIdInLadder(Int_t index) const; | |
65 | // | |
66 | Int_t GetLastModIndex(Int_t lay) const {return fLastModIndex[lay];} | |
67 | Int_t GetFirstModIndex(Int_t lay) const {return (lay==0) ? 0:fLastModIndex[lay-1]+1;} | |
68 | // | |
69 | const char *GetSymName(Int_t index) const; | |
70 | const char *GetSymName(Int_t lay,Int_t lad,Int_t det) const; | |
71 | // | |
72 | // Attention: these are the matrices for the alignable volumes of the modules, i.e. not necessarily the sensors | |
73 | TGeoHMatrix* GetMatrix(Int_t index) const; | |
74 | TGeoHMatrix* GetMatrix(Int_t lay,Int_t lad,Int_t det) const; | |
75 | Bool_t GetTranslation(Int_t index, Double_t t[3]) const; | |
76 | Bool_t GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const; | |
77 | Bool_t GetRotation(Int_t index, Double_t r[9]) const; | |
78 | Bool_t GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const; | |
79 | Bool_t GetOrigMatrix(Int_t index, TGeoHMatrix &m) const; | |
80 | Bool_t GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const; | |
81 | Bool_t GetOrigTranslation(Int_t index, Double_t t[3]) const; | |
82 | Bool_t GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const; | |
83 | Bool_t GetOrigRotation(Int_t index, Double_t r[9]) const; | |
84 | Bool_t GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const; | |
85 | // | |
cf457606 | 86 | const TGeoHMatrix* GetMatrixT2L(Int_t index); |
87 | const TGeoHMatrix* GetMatrixT2L(Int_t lay,Int_t lad,Int_t det) {return GetMatrixT2L( GetModuleIndex(lay,lad,det) );} | |
88 | const TGeoHMatrix* GetMatrixSens(Int_t index); | |
89 | const TGeoHMatrix* GetMatrixSens(Int_t lay,Int_t lad,Int_t det) {return GetMatrixSens( GetModuleIndex(lay,lad,det) );} | |
451f5018 | 90 | // |
cf457606 | 91 | Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m); |
92 | Bool_t GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m); | |
451f5018 | 93 | // |
94 | // Attention: these are transformations wrt sensitive volume! | |
cf457606 | 95 | void LocalToGlobal(Int_t index, const Double_t *loc, Double_t *glob); |
96 | void LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob); | |
451f5018 | 97 | // |
cf457606 | 98 | void GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc); |
99 | void GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc); | |
451f5018 | 100 | // |
cf457606 | 101 | void LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob); |
102 | void GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc); | |
451f5018 | 103 | Int_t GetLayerDetTypeID(Int_t lr) const; |
104 | Int_t GetModuleDetTypeID(Int_t id) const; | |
105 | // | |
02d6eccc | 106 | virtual void Print(Option_t *opt="") const; |
107 | ||
cf457606 | 108 | static const char* GetITSVolPattern() {return fgkITSVolName;} |
109 | static const char* GetITSLayerPattern() {return fgkITSLrName;} | |
110 | static const char* GetITSLadderPattern() {return fgkITSLadName;} | |
111 | static const char* GetITSModulePattern() {return fgkITSModName;} | |
112 | static const char* GetITSSensorPattern() {return fgkITSSensName;} | |
cf457606 | 113 | static const char* GetITSsegmentationFileName() {return fgITSsegmFileName.Data();} |
75875328 | 114 | static const char* GetDetTypeName(Int_t i); |
cf457606 | 115 | static void SetITSsegmentationFileName(const char* nm) {fgITSsegmFileName = nm;} |
451f5018 | 116 | static UInt_t ComposeDetTypeID(UInt_t segmId); |
117 | // | |
02d6eccc | 118 | // hack to avoid using AliGeomManager |
cf457606 | 119 | Int_t LayerToVolUID(Int_t lay,int detInLay) const {return GetModuleIndex(lay,detInLay);} |
120 | static Int_t ModuleVolUID(Int_t mod) {return mod;} | |
121 | // | |
122 | protected: | |
123 | void FetchMatrices(); | |
124 | TGeoHMatrix* ExtractMatrixT2L(Int_t index) const; | |
125 | TGeoHMatrix* ExtractMatrixSens(Int_t index) const; | |
126 | Bool_t GetLayer(Int_t index,Int_t &lay,Int_t &index2) const; | |
127 | TGeoPNEntry* GetPNEntry(Int_t index) const; | |
128 | Int_t ExtractNumberOfDetectors(Int_t lay) const; | |
129 | Int_t ExtractNumberOfLadders(Int_t lay) const; | |
130 | Int_t ExtractLayerDetType(Int_t lay) const; | |
131 | Int_t ExtractNumberOfLayers() const; | |
132 | void BuildITS(); | |
02d6eccc | 133 | // |
451f5018 | 134 | private: |
135 | // | |
451f5018 | 136 | // |
137 | Int_t fVersion; // ITS Version | |
138 | Int_t fNLayers; // number of layers | |
139 | Int_t fNModules; //[fNLayers] The total number of modules | |
140 | Int_t *fNLadders; //[fNLayers] Array of the number of ladders/layer(layer) | |
141 | Int_t *fLrDetType; //[fNLayers] Array of layer detector types | |
142 | Int_t *fNDetectors; //[fNLayers] Array of the number of detector/ladder(layer) | |
143 | Int_t *fLastModIndex; //[fNLayers] max ID of the detctor in the layer | |
144 | // | |
cf457606 | 145 | TObjArray* fMatSens; // Sensor's matrices pointers in the geometry |
146 | TObjArray* fMatT2L; // Tracking to Local matrices pointers in the geometry | |
147 | // | |
451f5018 | 148 | static const char* fgkITSVolName; // ITS mother volume name |
149 | static const char* fgkITSLrName; // ITS Layer name | |
150 | static const char* fgkITSLadName; // ITS Ladder name | |
151 | static const char* fgkITSModName; // ITS Module name | |
152 | static const char* fgkITSSensName; // ITS Sensor name | |
153 | static const char* fgkITSDetTypeName[kNDetTypes]; // ITS upg detType Names | |
154 | // | |
155 | static TString fgITSsegmFileName; // file name for segmentations | |
156 | // | |
157 | ClassDef(AliITSUGeomTGeo, 1) // ITS geometry based on TGeo | |
158 | }; | |
159 | ||
160 | //_____________________________________________________________________________________________ | |
161 | inline const char *AliITSUGeomTGeo::GetSymName(Int_t lay,Int_t lad,Int_t det) const | |
162 | { | |
163 | // sym name | |
164 | return GetSymName(GetModuleIndex(lay,lad,det)); | |
165 | } | |
166 | ||
167 | //_____________________________________________________________________________________________ | |
168 | inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t lay,Int_t lad,Int_t det) const | |
169 | { | |
170 | // module current matrix | |
171 | return GetMatrix(GetModuleIndex(lay,lad,det)); | |
172 | } | |
173 | ||
174 | //_____________________________________________________________________________________________ | |
175 | inline Bool_t AliITSUGeomTGeo::GetTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const | |
176 | { | |
177 | // translation | |
178 | return GetTranslation(GetModuleIndex(lay,lad,det),t); | |
179 | } | |
180 | ||
181 | //_____________________________________________________________________________________________ | |
182 | inline Bool_t AliITSUGeomTGeo::GetRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const | |
183 | { | |
184 | // rot | |
185 | return GetRotation(GetModuleIndex(lay,lad,det),r); | |
186 | } | |
187 | ||
188 | //_____________________________________________________________________________________________ | |
189 | inline Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) const | |
190 | { | |
191 | // orig matrix | |
192 | return GetOrigMatrix(GetModuleIndex(lay,lad,det),m); | |
193 | } | |
194 | ||
195 | //_____________________________________________________________________________________________ | |
196 | inline Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t lay,Int_t lad,Int_t det, Double_t t[3]) const | |
197 | { | |
198 | // orig trans | |
199 | return GetOrigTranslation(GetModuleIndex(lay,lad,det),t); | |
200 | } | |
201 | ||
202 | //_____________________________________________________________________________________________ | |
203 | inline Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t lay,Int_t lad,Int_t det, Double_t r[9]) const | |
204 | { | |
205 | // orig rot | |
206 | return GetOrigRotation(GetModuleIndex(lay,lad,det),r); | |
207 | } | |
208 | ||
209 | //_____________________________________________________________________________________________ | |
cf457606 | 210 | inline Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t lay,Int_t lad,Int_t det, TGeoHMatrix &m) |
451f5018 | 211 | { |
cf457606 | 212 | // tracking mat |
213 | return GetTrackingMatrix(GetModuleIndex(lay,lad,det),m); | |
451f5018 | 214 | } |
215 | ||
216 | //_____________________________________________________________________________________________ | |
cf457606 | 217 | inline Int_t AliITSUGeomTGeo::GetLayerDetTypeID(Int_t lr) const |
451f5018 | 218 | { |
cf457606 | 219 | // detector type ID of layer |
220 | return fLrDetType[lr]; | |
451f5018 | 221 | } |
222 | ||
223 | //_____________________________________________________________________________________________ | |
cf457606 | 224 | inline Int_t AliITSUGeomTGeo::GetModuleDetTypeID(Int_t id) const |
451f5018 | 225 | { |
cf457606 | 226 | // detector type ID of module |
227 | return GetLayerDetTypeID(GetLayer(id)); | |
228 | } | |
451f5018 | 229 | |
230 | //_____________________________________________________________________________________________ | |
cf457606 | 231 | inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t index) |
451f5018 | 232 | { |
cf457606 | 233 | // access global to sensor matrix |
234 | if (!fMatSens) FetchMatrices(); | |
235 | return (TGeoHMatrix*)fMatSens->At(index); | |
451f5018 | 236 | } |
237 | ||
238 | //_____________________________________________________________________________________________ | |
cf457606 | 239 | inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixT2L(Int_t index) |
451f5018 | 240 | { |
cf457606 | 241 | // access tracking to local matrix |
242 | if (!fMatT2L) FetchMatrices(); | |
243 | return (TGeoHMatrix*)fMatT2L->At(index); | |
244 | } | |
245 | ||
246 | //______________________________________________________________________ | |
247 | inline void AliITSUGeomTGeo::LocalToGlobal(Int_t index,const Double_t *loc, Double_t *glob) | |
248 | { | |
249 | // sensor local to global | |
250 | GetMatrixSens(index)->LocalToMaster(loc,glob); | |
251 | } | |
252 | ||
253 | //______________________________________________________________________ | |
254 | inline void AliITSUGeomTGeo::GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc) | |
255 | { | |
256 | // global to sensor local | |
257 | GetMatrixSens(index)->MasterToLocal(glob,loc); | |
258 | } | |
259 | ||
260 | //______________________________________________________________________ | |
261 | inline void AliITSUGeomTGeo::LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob) | |
262 | { | |
263 | // sensor local to global | |
264 | GetMatrixSens(index)->LocalToMasterVect(loc,glob); | |
265 | } | |
266 | ||
267 | //______________________________________________________________________ | |
268 | inline void AliITSUGeomTGeo::GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc) | |
269 | { | |
270 | // global to sensor local | |
271 | GetMatrixSens(index)->MasterToLocalVect(glob,loc); | |
451f5018 | 272 | } |
273 | ||
274 | //_____________________________________________________________________________________________ | |
cf457606 | 275 | inline void AliITSUGeomTGeo::LocalToGlobal(Int_t lay, Int_t lad, Int_t det,const Double_t *loc, Double_t *glob) |
451f5018 | 276 | { |
cf457606 | 277 | // Local2Master (sensor) |
278 | LocalToGlobal(GetModuleIndex(lay,lad,det), loc, glob); | |
451f5018 | 279 | } |
280 | ||
281 | //_____________________________________________________________________________________________ | |
cf457606 | 282 | inline void AliITSUGeomTGeo::GlobalToLocal(Int_t lay, Int_t lad, Int_t det,const Double_t *glob, Double_t *loc) |
451f5018 | 283 | { |
cf457606 | 284 | // master2local (sensor) |
285 | GlobalToLocal(GetModuleIndex(lay,lad,det), glob, loc); | |
286 | } | |
451f5018 | 287 | |
75875328 | 288 | //_____________________________________________________________________________________________ |
289 | inline const char* AliITSUGeomTGeo::GetDetTypeName(Int_t i) | |
290 | { | |
291 | if (i>=kNDetTypes) i/=kMaxSegmPerDetType; // full type is provided | |
292 | return fgkITSDetTypeName[i]; | |
293 | } | |
451f5018 | 294 | |
295 | #endif |