]>
Commit | Line | Data |
---|---|---|
1 | #ifndef ALIITSUGEOMTGEO_H | |
2 | #define ALIITSUGEOMTGEO_H | |
3 | ||
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 chip types: // | |
21 | // The coarse type defines chips served by different classes, // | |
22 | // like Pix. Each such a chip type can have kMaxSegmPerChipType // | |
23 | // segmentations (pitch etc.) whose parameteres are stored in the // | |
24 | // AliITSsegmentation derived class (like AliITSUSegmentationPix) // | |
25 | // This allows to have in the setup chips served by the same // | |
26 | // classes but with different segmentations. // | |
27 | // The full chip type is composed as: // | |
28 | // CoarseType*kMaxSegmPerChipType + segmentationType // | |
29 | // The only requirement on the segmentationType that should be // | |
30 | // < kMaxSegmPerChipType. // | |
31 | // The methods like GetLayerChipTypeID return the full chip type // | |
32 | // // | |
33 | // // | |
34 | ///////////////////////////////////////////////////////////////////////// | |
35 | ||
36 | #include <TObject.h> | |
37 | #include <TGeoMatrix.h> | |
38 | #include <TString.h> | |
39 | #include <TObjArray.h> | |
40 | #include "AliITSUAux.h" | |
41 | ||
42 | class TGeoPNEntry; | |
43 | class TDatime; | |
44 | class AliITSsegmentation; | |
45 | ||
46 | class AliITSUGeomTGeo : public TObject { | |
47 | ||
48 | public: | |
49 | enum {kITSVNA, kITSVUpg}; // ITS version | |
50 | enum {kChipTypePix=0, kNChipTypes, kMaxSegmPerChipType=10}; // defined detector chip types (each one can have different segmentations) | |
51 | // | |
52 | AliITSUGeomTGeo(Bool_t build = kFALSE, Bool_t loadSegmentations = kTRUE); | |
53 | virtual ~AliITSUGeomTGeo(); | |
54 | AliITSUGeomTGeo(const AliITSUGeomTGeo &src); | |
55 | AliITSUGeomTGeo& operator=(const AliITSUGeomTGeo &geom); | |
56 | // | |
57 | Int_t GetNChips() const {return fNChips;} | |
58 | Int_t GetNChipRowsPerModule(Int_t lay) const {return fNChipRowsPerModule[lay];} | |
59 | Int_t GetNChipColsPerModule(Int_t lay) const {return fNChipRowsPerModule[lay] ? fNChipsPerModule[lay]/fNChipRowsPerModule[lay] : -1;} | |
60 | Int_t GetNChipsPerModule(Int_t lay) const {return fNChipsPerModule[lay];} | |
61 | Int_t GetNChipsPerHalfStave(Int_t lay) const {return fNChipsPerHalfStave[lay];} | |
62 | Int_t GetNChipsPerStave(Int_t lay) const {return fNChipsPerStave[lay];} | |
63 | Int_t GetNChipsPerLayer(Int_t lay) const {return fNChipsPerLayer[lay];} | |
64 | Int_t GetNModules(Int_t lay) const {return fNModules[lay];} | |
65 | Int_t GetNHalfStaves(Int_t lay) const {return fNHalfStaves[lay];} | |
66 | Int_t GetNStaves(Int_t lay) const {return fNStaves[lay];} | |
67 | Int_t GetNLayers() const {return fNLayers;} | |
68 | ||
69 | Int_t GetChipIndex(Int_t lay,int detInLay) const {return GetFirstChipIndex(lay)+detInLay;} | |
70 | Int_t GetChipIndex(Int_t lay,Int_t sta,Int_t detInSta) const; | |
71 | Int_t GetChipIndex(Int_t lay,Int_t sta, Int_t subSta, Int_t detInSubSta) const; | |
72 | Int_t GetChipIndex(Int_t lay,Int_t sta, Int_t subSta, Int_t md, Int_t detInMod) const; | |
73 | Bool_t GetChipId(Int_t index,Int_t &lay,Int_t &sta,Int_t &ssta,Int_t &mod,Int_t &chip) const; | |
74 | Int_t GetLayer(Int_t index) const; | |
75 | Int_t GetStave(Int_t index) const; | |
76 | Int_t GetHalfStave(Int_t index) const; | |
77 | Int_t GetModule(Int_t index) const; | |
78 | Int_t GetChipIdInLayer(Int_t index) const; | |
79 | Int_t GetChipIdInStave(Int_t index) const; | |
80 | Int_t GetChipIdInHalfStave(Int_t index) const; | |
81 | Int_t GetChipIdInModule(Int_t index) const; | |
82 | // | |
83 | Int_t GetLastChipIndex(Int_t lay) const {return fLastChipIndex[lay];} | |
84 | Int_t GetFirstChipIndex(Int_t lay) const {return (lay==0) ? 0:fLastChipIndex[lay-1]+1;} | |
85 | // | |
86 | const char *GetSymName(Int_t index) const; | |
87 | const char *GetSymName(Int_t lay,Int_t sta,Int_t det) const; | |
88 | // | |
89 | // Attention: these are the matrices for the alignable volumes of the chips, i.e. not necessarily the sensors | |
90 | TGeoHMatrix* GetMatrix(Int_t index) const; | |
91 | TGeoHMatrix* GetMatrix(Int_t lay,Int_t sta,Int_t det) const; | |
92 | Bool_t GetTranslation(Int_t index, Double_t t[3]) const; | |
93 | Bool_t GetTranslation(Int_t lay,Int_t sta,Int_t det, Double_t t[3]) const; | |
94 | Bool_t GetRotation(Int_t index, Double_t r[9]) const; | |
95 | Bool_t GetRotation(Int_t lay,Int_t sta,Int_t det, Double_t r[9]) const; | |
96 | Bool_t GetOrigMatrix(Int_t index, TGeoHMatrix &m) const; | |
97 | Bool_t GetOrigMatrix(Int_t lay,Int_t sta,Int_t det, TGeoHMatrix &m) const; | |
98 | Bool_t GetOrigTranslation(Int_t index, Double_t t[3]) const; | |
99 | Bool_t GetOrigTranslation(Int_t lay,Int_t sta,Int_t det, Double_t t[3]) const; | |
100 | Bool_t GetOrigRotation(Int_t index, Double_t r[9]) const; | |
101 | Bool_t GetOrigRotation(Int_t lay,Int_t sta,Int_t det, Double_t r[9]) const; | |
102 | // | |
103 | const TGeoHMatrix* GetMatrixT2L(Int_t index); | |
104 | const TGeoHMatrix* GetMatrixT2L(Int_t lay,Int_t sta,Int_t det) {return GetMatrixT2L( GetChipIndex(lay,sta,det) );} | |
105 | const TGeoHMatrix* GetMatrixSens(Int_t index); | |
106 | const TGeoHMatrix* GetMatrixSens(Int_t lay,Int_t sta,Int_t det) {return GetMatrixSens( GetChipIndex(lay,sta,det) );} | |
107 | // | |
108 | Bool_t GetTrackingMatrix(Int_t index, TGeoHMatrix &m); | |
109 | Bool_t GetTrackingMatrix(Int_t lay,Int_t sta,Int_t det, TGeoHMatrix &m); | |
110 | // | |
111 | // Attention: these are transformations wrt sensitive volume! | |
112 | void LocalToGlobal(Int_t index, const Double_t *loc, Double_t *glob); | |
113 | void LocalToGlobal(Int_t lay, Int_t sta, Int_t det,const Double_t *loc, Double_t *glob); | |
114 | // | |
115 | void GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc); | |
116 | void GlobalToLocal(Int_t lay, Int_t sta, Int_t det,const Double_t *glob, Double_t *loc); | |
117 | // | |
118 | void LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob); | |
119 | void GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc); | |
120 | Int_t GetLayerChipTypeID(Int_t lr) const; | |
121 | Int_t GetChipChipTypeID(Int_t id) const; | |
122 | // | |
123 | const AliITSsegmentation* GetSegmentationByID(Int_t id) const; | |
124 | const AliITSsegmentation* GetSegmentation(Int_t lr) const; | |
125 | TObjArray* GetSegmentations() const {return (TObjArray*)fSegm;} | |
126 | virtual void Print(Option_t *opt="") const; | |
127 | // | |
128 | static UInt_t GetUIDShift() {return fgUIDShift;} | |
129 | static void SetUIDShift(UInt_t s=16) {fgUIDShift = s<16 ? s:16;} | |
130 | // | |
131 | static const char* GetITSVolPattern() {return fgITSVolName.Data();} | |
132 | static const char* GetITSLayerPattern() {return fgITSLrName.Data();} | |
133 | static const char* GetITSWrapVolPattern() {return fgITSWrapVolName.Data();} | |
134 | static const char* GetITSStavePattern() {return fgITSStaveName.Data();} | |
135 | static const char* GetITSHalfStavePattern() {return fgITSHalfStaveName.Data();} | |
136 | static const char* GetITSModulePattern() {return fgITSModuleName.Data();} | |
137 | static const char* GetITSChipPattern() {return fgITSChipName.Data();} | |
138 | static const char* GetITSSensorPattern() {return fgITSSensName.Data();} | |
139 | static const char* GetITSsegmentationFileName() {return fgITSsegmFileName.Data();} | |
140 | static const char* GetChipTypeName(Int_t i); | |
141 | ||
142 | static void SetITSVolPattern(const char* nm) {fgITSVolName = nm;} | |
143 | static void SetITSLayerPattern(const char* nm) {fgITSLrName = nm;} | |
144 | static void SetITSWrapVolPattern(const char* nm) {fgITSWrapVolName = nm;} | |
145 | static void SetITSStavePattern(const char* nm) {fgITSStaveName = nm;} | |
146 | static void SetITSHalfStavePattern(const char* nm) {fgITSHalfStaveName = nm;} | |
147 | static void SetITSModulePattern(const char* nm) {fgITSModuleName = nm;} | |
148 | static void SetITSChipPattern(const char* nm) {fgITSChipName = nm;} | |
149 | static void SetITSSensorPattern(const char* nm) {fgITSSensName = nm;} | |
150 | static void SetChipTypeName(Int_t i,const char* nm); | |
151 | static void SetITSsegmentationFileName(const char* nm) {fgITSsegmFileName = nm;} | |
152 | static UInt_t ComposeChipTypeID(UInt_t segmId); | |
153 | // | |
154 | static const char *ComposeSymNameITS(); | |
155 | static const char *ComposeSymNameLayer(Int_t lr); | |
156 | static const char *ComposeSymNameStave(Int_t lr, Int_t sta); | |
157 | static const char *ComposeSymNameHalfStave(Int_t lr, Int_t sta, Int_t ssta); | |
158 | static const char *ComposeSymNameModule(Int_t lr, Int_t sta, Int_t ssta, Int_t mod); | |
159 | static const char *ComposeSymNameChip(Int_t lr, Int_t sta, Int_t ssta, Int_t mod, Int_t chip); | |
160 | // | |
161 | // hack to avoid using AliGeomManager | |
162 | Int_t LayerToVolUID(Int_t lay,int detInLay) const {return ChipVolUID(GetChipIndex(lay,detInLay));} | |
163 | static Int_t ChipVolUID(Int_t mod) {return (mod&0xffff)<<fgUIDShift;} | |
164 | // | |
165 | protected: | |
166 | void FetchMatrices(); | |
167 | void CreateT2LMatrices(); | |
168 | TGeoHMatrix* ExtractMatrixT2L(Int_t index) const; | |
169 | TGeoHMatrix* ExtractMatrixSens(Int_t index) const; | |
170 | Bool_t GetLayer(Int_t index,Int_t &lay,Int_t &index2) const; | |
171 | TGeoPNEntry* GetPNEntry(Int_t index) const; | |
172 | Int_t ExtractNChipsPerModule(Int_t lay, Int_t &nrow) const; | |
173 | Int_t ExtractNumberOfStaves(Int_t lay) const; | |
174 | Int_t ExtractNumberOfHalfStaves(Int_t lay) const; | |
175 | Int_t ExtractNumberOfModules(Int_t lay) const; | |
176 | Int_t ExtractLayerChipType(Int_t lay) const; | |
177 | Int_t ExtractNumberOfLayers(); | |
178 | void BuildITS(Bool_t loadSegm); | |
179 | // | |
180 | Int_t ExtractVolumeCopy(const char* name, const char* prefix) const; | |
181 | protected: | |
182 | // | |
183 | // | |
184 | Int_t fVersion; // ITS Version | |
185 | Int_t fNLayers; // number of layers | |
186 | Int_t fNChips; // The total number of chips | |
187 | Int_t *fNStaves; //[fNLayers] Array of the number of staves/layer(layer) | |
188 | Int_t *fNHalfStaves; //[fNLayers] Array of the number of substaves/stave(layer) | |
189 | Int_t *fNModules; //[fNLayers] Array of the number of modules/substave(layer) | |
190 | Int_t *fNChipsPerModule; //[fNLayers] Array of the number of chips per module (group of chips on the substaves) | |
191 | Int_t *fNChipRowsPerModule; //[fNLayers] Array of the number of chips rows per module (relevant for OB modules) | |
192 | Int_t *fNChipsPerHalfStave; //[fNLayers] Array of the number of chips per substave | |
193 | Int_t *fNChipsPerStave; //[fNLayers] Array of the number of chips per stave | |
194 | Int_t *fNChipsPerLayer; //[fNLayers] Array of the number of chips per stave | |
195 | ||
196 | // | |
197 | Int_t *fLrChipType; //[fNLayers] Array of layer chip types | |
198 | Int_t *fLastChipIndex; //[fNLayers] max ID of the detctor in the layer | |
199 | Char_t fLr2Wrapper[AliITSUAux::kMaxLayers]; // layer -> wrapper correspondence | |
200 | // | |
201 | TObjArray* fMatSens; // Sensor's matrices pointers in the geometry | |
202 | TObjArray* fMatT2L; // Tracking to Local matrices pointers in the geometry | |
203 | TObjArray* fSegm; // segmentations | |
204 | // | |
205 | static UInt_t fgUIDShift; // bit shift to go from mod.id to modUUID for TGeo | |
206 | static TString fgITSVolName; // ITS mother volume name | |
207 | static TString fgITSLrName; // ITS Layer name | |
208 | static TString fgITSStaveName; // ITS Stave name | |
209 | static TString fgITSHalfStaveName; // ITS HalfStave name | |
210 | static TString fgITSModuleName; // ITS Module name | |
211 | static TString fgITSChipName; // ITS Chip name | |
212 | static TString fgITSSensName; // ITS Sensor name | |
213 | static TString fgITSWrapVolName; // ITS Wrapper volume name | |
214 | static TString fgITSChipTypeName[kNChipTypes]; // ITS upg detType Names | |
215 | // | |
216 | static TString fgITSsegmFileName; // file name for segmentations | |
217 | // | |
218 | ClassDef(AliITSUGeomTGeo, 2) // ITS geometry based on TGeo | |
219 | }; | |
220 | ||
221 | //_____________________________________________________________________________________________ | |
222 | inline const char *AliITSUGeomTGeo::GetSymName(Int_t lay,Int_t sta,Int_t det) const | |
223 | { | |
224 | // sym name | |
225 | return GetSymName(GetChipIndex(lay,sta,det)); | |
226 | } | |
227 | ||
228 | //_____________________________________________________________________________________________ | |
229 | inline TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t lay,Int_t sta,Int_t det) const | |
230 | { | |
231 | // chip current matrix | |
232 | return GetMatrix(GetChipIndex(lay,sta,det)); | |
233 | } | |
234 | ||
235 | //_____________________________________________________________________________________________ | |
236 | inline Bool_t AliITSUGeomTGeo::GetTranslation(Int_t lay,Int_t sta,Int_t det, Double_t t[3]) const | |
237 | { | |
238 | // translation | |
239 | return GetTranslation(GetChipIndex(lay,sta,det),t); | |
240 | } | |
241 | ||
242 | //_____________________________________________________________________________________________ | |
243 | inline Bool_t AliITSUGeomTGeo::GetRotation(Int_t lay,Int_t sta,Int_t det, Double_t r[9]) const | |
244 | { | |
245 | // rot | |
246 | return GetRotation(GetChipIndex(lay,sta,det),r); | |
247 | } | |
248 | ||
249 | //_____________________________________________________________________________________________ | |
250 | inline Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t lay,Int_t sta,Int_t det, TGeoHMatrix &m) const | |
251 | { | |
252 | // orig matrix | |
253 | return GetOrigMatrix(GetChipIndex(lay,sta,det),m); | |
254 | } | |
255 | ||
256 | //_____________________________________________________________________________________________ | |
257 | inline Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t lay,Int_t sta,Int_t det, Double_t t[3]) const | |
258 | { | |
259 | // orig trans | |
260 | return GetOrigTranslation(GetChipIndex(lay,sta,det),t); | |
261 | } | |
262 | ||
263 | //_____________________________________________________________________________________________ | |
264 | inline Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t lay,Int_t sta,Int_t det, Double_t r[9]) const | |
265 | { | |
266 | // orig rot | |
267 | return GetOrigRotation(GetChipIndex(lay,sta,det),r); | |
268 | } | |
269 | ||
270 | //_____________________________________________________________________________________________ | |
271 | inline Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t lay,Int_t sta,Int_t det, TGeoHMatrix &m) | |
272 | { | |
273 | // tracking mat | |
274 | return GetTrackingMatrix(GetChipIndex(lay,sta,det),m); | |
275 | } | |
276 | ||
277 | //_____________________________________________________________________________________________ | |
278 | inline Int_t AliITSUGeomTGeo::GetLayerChipTypeID(Int_t lr) const | |
279 | { | |
280 | // detector type ID of layer | |
281 | return fLrChipType[lr]; | |
282 | } | |
283 | ||
284 | //_____________________________________________________________________________________________ | |
285 | inline Int_t AliITSUGeomTGeo::GetChipChipTypeID(Int_t id) const | |
286 | { | |
287 | // detector type ID of chip | |
288 | return GetLayerChipTypeID(GetLayer(id)); | |
289 | } | |
290 | ||
291 | //_____________________________________________________________________________________________ | |
292 | inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t index) | |
293 | { | |
294 | // access global to sensor matrix | |
295 | if (!fMatSens) FetchMatrices(); | |
296 | return (TGeoHMatrix*)fMatSens->At(index); | |
297 | } | |
298 | ||
299 | //_____________________________________________________________________________________________ | |
300 | inline const TGeoHMatrix* AliITSUGeomTGeo::GetMatrixT2L(Int_t index) | |
301 | { | |
302 | // access tracking to local matrix | |
303 | if (!fMatT2L) FetchMatrices(); | |
304 | return (TGeoHMatrix*)fMatT2L->At(index); | |
305 | } | |
306 | ||
307 | //______________________________________________________________________ | |
308 | inline void AliITSUGeomTGeo::LocalToGlobal(Int_t index,const Double_t *loc, Double_t *glob) | |
309 | { | |
310 | // sensor local to global | |
311 | GetMatrixSens(index)->LocalToMaster(loc,glob); | |
312 | } | |
313 | ||
314 | //______________________________________________________________________ | |
315 | inline void AliITSUGeomTGeo::GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc) | |
316 | { | |
317 | // global to sensor local | |
318 | GetMatrixSens(index)->MasterToLocal(glob,loc); | |
319 | } | |
320 | ||
321 | //______________________________________________________________________ | |
322 | inline void AliITSUGeomTGeo::LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob) | |
323 | { | |
324 | // sensor local to global | |
325 | GetMatrixSens(index)->LocalToMasterVect(loc,glob); | |
326 | } | |
327 | ||
328 | //______________________________________________________________________ | |
329 | inline void AliITSUGeomTGeo::GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc) | |
330 | { | |
331 | // global to sensor local | |
332 | GetMatrixSens(index)->MasterToLocalVect(glob,loc); | |
333 | } | |
334 | ||
335 | //_____________________________________________________________________________________________ | |
336 | inline void AliITSUGeomTGeo::LocalToGlobal(Int_t lay, Int_t sta, Int_t det,const Double_t *loc, Double_t *glob) | |
337 | { | |
338 | // Local2Master (sensor) | |
339 | LocalToGlobal(GetChipIndex(lay,sta,det), loc, glob); | |
340 | } | |
341 | ||
342 | //_____________________________________________________________________________________________ | |
343 | inline void AliITSUGeomTGeo::GlobalToLocal(Int_t lay, Int_t sta, Int_t det,const Double_t *glob, Double_t *loc) | |
344 | { | |
345 | // master2local (sensor) | |
346 | GlobalToLocal(GetChipIndex(lay,sta,det), glob, loc); | |
347 | } | |
348 | ||
349 | //_____________________________________________________________________________________________ | |
350 | inline const char* AliITSUGeomTGeo::GetChipTypeName(Int_t i) | |
351 | { | |
352 | if (i>=kNChipTypes) i/=kMaxSegmPerChipType; // full type is provided | |
353 | return fgITSChipTypeName[i].Data(); | |
354 | } | |
355 | ||
356 | //_____________________________________________________________________________________________ | |
357 | inline void AliITSUGeomTGeo::SetChipTypeName(Int_t i, const char* nm) | |
358 | { | |
359 | if (i>=kNChipTypes) i/=kMaxSegmPerChipType; // full type is provided | |
360 | fgITSChipTypeName[i] = nm; | |
361 | } | |
362 | ||
363 | //_____________________________________________________________________________________________ | |
364 | inline const AliITSsegmentation* AliITSUGeomTGeo::GetSegmentationByID(Int_t id) const | |
365 | { | |
366 | // get segmentation by ID | |
367 | return fSegm ? (AliITSsegmentation*)fSegm->At(id) : 0; | |
368 | } | |
369 | ||
370 | //_____________________________________________________________________________________________ | |
371 | inline const AliITSsegmentation* AliITSUGeomTGeo::GetSegmentation(Int_t lr) const | |
372 | { | |
373 | // get segmentation of layer | |
374 | return fSegm ? (AliITSsegmentation*)fSegm->At( GetLayerChipTypeID(lr) ) : 0; | |
375 | } | |
376 | ||
377 | #endif |