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