]>
Commit | Line | Data |
---|---|---|
ce886e8e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /////////////////////////////////////////////////////////////////////////// | |
451f5018 | 17 | // AliITSUGeomTGeo is a simple interface class to TGeoManager // |
ce886e8e | 18 | // It is used in the simulation and reconstruction in order to // |
19 | // query the TGeo ITS geometry // | |
20 | // // | |
21 | // author - cvetan.cheshkov@cern.ch // | |
22 | // 15/02/2007 // | |
23 | // adapted to ITSupg 18/07/2012 - ruben.shahoyan@cern.ch // | |
24 | // // | |
451f5018 | 25 | // ATTENTION: In opposite to ols AliITSgeomTGeo, all indices start // |
26 | // from 0, not from 1!!! // | |
27 | // // | |
ce886e8e | 28 | /////////////////////////////////////////////////////////////////////////// |
29 | ||
30 | #include <TClass.h> | |
31 | #include <TString.h> | |
32 | #include <TGeoManager.h> | |
33 | #include <TGeoPhysicalNode.h> | |
34 | #include <TDatime.h> | |
35 | ||
451f5018 | 36 | #include "AliITSUGeomTGeo.h" |
ce886e8e | 37 | #include "AliLog.h" |
38 | #include "AliAlignObj.h" | |
39 | ||
451f5018 | 40 | ClassImp(AliITSUGeomTGeo) |
41 | ||
ce886e8e | 42 | |
451f5018 | 43 | const char* AliITSUGeomTGeo::fgkITSVolName = "ITSV"; |
44 | const char* AliITSUGeomTGeo::fgkITSLrName = "ITSupgLayer"; | |
45 | const char* AliITSUGeomTGeo::fgkITSLadName = "ITSupgLadder"; | |
46 | const char* AliITSUGeomTGeo::fgkITSModName = "ITSupgModule"; | |
47 | const char* AliITSUGeomTGeo::fgkITSSensName ="ITSupgSensor"; | |
48 | const char* AliITSUGeomTGeo::fgkITSDetTypeName[AliITSUGeomTGeo::kNDetTypes] = {"PixUpg"}; | |
49 | // | |
50 | TString AliITSUGeomTGeo::fgITSsegmFileName = "itsSegmentations.root"; | |
ce886e8e | 51 | |
451f5018 | 52 | //______________________________________________________________________ |
53 | AliITSUGeomTGeo::AliITSUGeomTGeo(Bool_t build) | |
54 | : fVersion(kITSVNA) | |
55 | ,fNLayers(0) | |
56 | ,fNModules(0) | |
57 | ,fNLadders(0) | |
58 | ,fLrDetType(0) | |
59 | ,fNDetectors(0) | |
60 | ,fLastModIndex(0) | |
61 | { | |
62 | // default c-tor | |
63 | if (build) BuildITS(); | |
64 | } | |
ce886e8e | 65 | |
451f5018 | 66 | //______________________________________________________________________ |
67 | AliITSUGeomTGeo::AliITSUGeomTGeo(const AliITSUGeomTGeo &src) | |
68 | :TObject(src) | |
69 | ,fVersion(src.fVersion) | |
70 | ,fNLayers(src.fNLayers) | |
71 | ,fNModules(src.fNModules) | |
72 | ,fNLadders(0) | |
73 | ,fLrDetType(0) | |
74 | ,fNDetectors(0) | |
75 | ,fLastModIndex(0) | |
76 | { | |
77 | // copy c-tor | |
78 | if (fNLayers) { | |
79 | fNLadders = new Int_t[fNLayers]; | |
80 | fNDetectors = new Int_t[fNLayers]; | |
81 | fLrDetType = new Int_t[fNLayers]; | |
82 | fLastModIndex = new Int_t[fNLayers]; | |
83 | for (int i=fNLayers;i--;) { | |
84 | fNLadders[i] = src.fNLadders[i]; | |
85 | fNDetectors[i] = src.fNDetectors[i]; | |
86 | fLrDetType[i] = src.fLrDetType[i]; | |
87 | fLastModIndex[i] = src.fLastModIndex[i]; | |
88 | } | |
89 | } | |
90 | } | |
ce886e8e | 91 | |
451f5018 | 92 | //______________________________________________________________________ |
93 | AliITSUGeomTGeo::~AliITSUGeomTGeo() | |
94 | { | |
95 | //d-tor | |
96 | delete[] fNLadders; | |
97 | delete[] fLrDetType; | |
98 | delete[] fNDetectors; | |
99 | delete[] fLastModIndex; | |
100 | } | |
ce886e8e | 101 | |
102 | ||
103 | //______________________________________________________________________ | |
451f5018 | 104 | AliITSUGeomTGeo& AliITSUGeomTGeo::operator=(const AliITSUGeomTGeo &src) |
105 | { | |
106 | // cp op. | |
107 | if (this!=&src) { | |
108 | delete[] fNLadders; | |
109 | delete[] fLrDetType; | |
110 | delete[] fNDetectors; | |
111 | delete[] fLastModIndex; | |
112 | fNLadders = fLrDetType = fNDetectors = fLastModIndex = 0; | |
113 | fVersion = src.fVersion; | |
114 | fNLayers = src.fNLayers; | |
115 | fNModules = src.fNModules; | |
116 | if (fNLayers) { | |
117 | fNLadders = new Int_t[fNLayers]; | |
118 | fNDetectors = new Int_t[fNLayers]; | |
119 | fLrDetType = new Int_t[fNLayers]; | |
120 | fLastModIndex = new Int_t[fNLayers]; | |
121 | for (int i=fNLayers;i--;) { | |
122 | fNLadders[i] = src.fNLadders[i]; | |
123 | fNDetectors[i] = src.fNDetectors[i]; | |
124 | fLrDetType[i] = src.fLrDetType[i]; | |
125 | fLastModIndex[i] = src.fLastModIndex[i]; | |
126 | } | |
127 | } | |
128 | } | |
129 | return *this; | |
130 | } | |
131 | ||
132 | //______________________________________________________________________ | |
133 | Int_t AliITSUGeomTGeo::GetModuleIndex(Int_t lay,Int_t lad,Int_t det) const | |
ce886e8e | 134 | { |
ce886e8e | 135 | // This routine computes the module index number from the layer, |
136 | // ladder, and detector numbers. The number of ladders and detectors | |
137 | // per layer is set statically | |
138 | // see above for details. | |
139 | // Inputs: | |
451f5018 | 140 | // Int_t lay The layer number. Starting from 0. |
141 | // Int_t lad The ladder number. Starting from 0 | |
142 | // Int_t det The detector number in the ladder. Starting from 0 | |
ce886e8e | 143 | // |
451f5018 | 144 | return GetFirstModIndex(lay) + fNDetectors[lay]*lad + det; |
ce886e8e | 145 | } |
146 | ||
147 | //______________________________________________________________________ | |
451f5018 | 148 | Bool_t AliITSUGeomTGeo::GetLayer(Int_t index,Int_t &lay,Int_t &index2) const |
ce886e8e | 149 | { |
ce886e8e | 150 | // This routine computes the layer number for a |
451f5018 | 151 | // given the module index. The |
ce886e8e | 152 | // Inputs: |
153 | // Int_t index The module index number, starting from zero. | |
154 | // Outputs: | |
155 | // Int_t index2 The module index inside a layer, starting from zero. | |
451f5018 | 156 | // Int_t lay The layer number. Starting from 0. |
157 | // | |
158 | lay = GetLayer(index); | |
159 | index2 = index - GetFirstModIndex(lay); | |
160 | return kTRUE; | |
161 | // | |
162 | } | |
ce886e8e | 163 | |
451f5018 | 164 | //______________________________________________________________________ |
165 | Int_t AliITSUGeomTGeo::GetLayer(Int_t index) const | |
166 | { | |
167 | // Get module layer, from 0 | |
168 | // | |
169 | int lay = 0; | |
170 | while(index<=fLastModIndex[lay]) lay++; | |
171 | return --lay; | |
172 | } | |
ce886e8e | 173 | |
451f5018 | 174 | //______________________________________________________________________ |
175 | Int_t AliITSUGeomTGeo::GetLadder(Int_t index) const | |
176 | { | |
177 | // Get module ladder, from 0 | |
178 | // | |
179 | int lay = 0; | |
180 | while(index<=fLastModIndex[lay]) lay++; | |
181 | index -= GetFirstModIndex(--lay); | |
182 | return index/fNDetectors[lay]; | |
ce886e8e | 183 | } |
184 | ||
185 | //______________________________________________________________________ | |
451f5018 | 186 | Int_t AliITSUGeomTGeo::GetModIdInLayer(Int_t index) const |
187 | { | |
188 | // Get module number within layer, from 0 | |
189 | // | |
190 | int lay = 0; | |
191 | while(index<=fLastModIndex[lay]) lay++; | |
192 | index -= GetFirstModIndex(--lay); | |
193 | return index; | |
194 | } | |
195 | ||
196 | //______________________________________________________________________ | |
197 | Int_t AliITSUGeomTGeo::GetModIdInLadder(Int_t index) const | |
198 | { | |
199 | // Get module number within ladder, from 0 | |
200 | // | |
201 | int lay = 0; | |
202 | while(index<=fLastModIndex[lay]) lay++; | |
203 | index -= GetFirstModIndex(--lay); | |
204 | return index%fNDetectors[lay]; | |
205 | } | |
206 | ||
207 | //______________________________________________________________________ | |
208 | Bool_t AliITSUGeomTGeo::GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det) const | |
ce886e8e | 209 | { |
210 | // The method is taken from the old AliITSgeom class by Bjorn Nilsen | |
211 | // | |
212 | // This routine computes the layer, ladder and detector number | |
451f5018 | 213 | // given the module index number. |
ce886e8e | 214 | // Inputs: |
215 | // Int_t index The module index number, starting from zero. | |
216 | // Outputs: | |
451f5018 | 217 | // Int_t lay The layer number. Starting from 0 |
218 | // Int_t lad The ladder number. Starting from 0 | |
219 | // Int_t det The detector number. Starting from 0 | |
220 | // | |
221 | lay = GetLayer(index); | |
222 | index -= GetFirstModIndex(lay); | |
223 | lad = index/fNDetectors[lay]; | |
224 | det = index%fNDetectors[lay]; | |
ce886e8e | 225 | return kTRUE; |
226 | } | |
227 | ||
228 | //______________________________________________________________________ | |
451f5018 | 229 | const char* AliITSUGeomTGeo::GetSymName(Int_t index) const |
ce886e8e | 230 | { |
231 | // Get the TGeoPNEntry symbolic name | |
232 | // for a given module identified by 'index' | |
ce886e8e | 233 | // |
ce886e8e | 234 | Int_t lay, index2; |
235 | if (!GetLayer(index,lay,index2)) return NULL; | |
451f5018 | 236 | // return AliGeomManager::SymName((AliGeomManager::ELayerID)((lay-1)+AliGeomManager::kSPD1),index2); |
237 | // RS: this is not optimal, but we cannod access directly AliGeomManager, since the latter has hardwired layers | |
238 | TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID( AliGeomManager::LayerToVolUID(lay+1,index2) ); | |
239 | if (!pne) { | |
240 | AliError(Form("Failed to find alignable entry with index %d: (Lr%d Mod:%d) !",index,lay,index2)); | |
241 | return NULL; | |
ce886e8e | 242 | } |
451f5018 | 243 | return pne->GetName(); |
ce886e8e | 244 | } |
245 | ||
246 | //______________________________________________________________________ | |
451f5018 | 247 | TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t index) const |
ce886e8e | 248 | { |
249 | // Get the transformation matrix for a given module 'index' | |
250 | // by quering the TGeoManager | |
ce886e8e | 251 | TGeoPNEntry *pne = GetPNEntry(index); |
252 | if (!pne) return NULL; | |
253 | ||
254 | TGeoPhysicalNode *pnode = pne->GetPhysicalNode(); | |
255 | if (pnode) return pnode->GetMatrix(); | |
256 | ||
257 | const char* path = pne->GetTitle(); | |
451f5018 | 258 | gGeoManager->PushPath(); // Preserve the modeler state. |
ce886e8e | 259 | if (!gGeoManager->cd(path)) { |
451f5018 | 260 | gGeoManager->PopPath(); |
261 | AliError(Form("Volume path %s not valid!",path)); | |
ce886e8e | 262 | return NULL; |
263 | } | |
451f5018 | 264 | TGeoHMatrix *mat = gGeoManager->GetCurrentMatrix(); |
265 | gGeoManager->PopPath(); | |
266 | return mat; | |
ce886e8e | 267 | } |
268 | ||
269 | //______________________________________________________________________ | |
451f5018 | 270 | Bool_t AliITSUGeomTGeo::GetTranslation(Int_t index, Double_t t[3]) const |
ce886e8e | 271 | { |
272 | // Get the translation vector for a given module 'index' | |
273 | // by quering the TGeoManager | |
ce886e8e | 274 | TGeoHMatrix *m = GetMatrix(index); |
275 | if (!m) return kFALSE; | |
276 | ||
277 | Double_t *trans = m->GetTranslation(); | |
278 | for (Int_t i = 0; i < 3; i++) t[i] = trans[i]; | |
279 | ||
280 | return kTRUE; | |
281 | } | |
282 | ||
283 | //______________________________________________________________________ | |
451f5018 | 284 | Bool_t AliITSUGeomTGeo::GetRotation(Int_t index, Double_t r[9]) const |
ce886e8e | 285 | { |
286 | // Get the rotation matrix for a given module 'index' | |
287 | // by quering the TGeoManager | |
ce886e8e | 288 | TGeoHMatrix *m = GetMatrix(index); |
289 | if (!m) return kFALSE; | |
290 | ||
291 | Double_t *rot = m->GetRotationMatrix(); | |
292 | for (Int_t i = 0; i < 9; i++) r[i] = rot[i]; | |
293 | ||
294 | return kTRUE; | |
295 | } | |
296 | ||
297 | //______________________________________________________________________ | |
451f5018 | 298 | Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t index, TGeoHMatrix &m) const |
ce886e8e | 299 | { |
300 | // Get the original (ideal geometry) TGeo matrix for | |
301 | // a given module identified by 'index'. | |
302 | // The method is slow, so it should be used | |
303 | // with great care. | |
ce886e8e | 304 | m.Clear(); |
305 | ||
306 | const char *symname = GetSymName(index); | |
307 | if (!symname) return kFALSE; | |
308 | ||
309 | return AliGeomManager::GetOrigGlobalMatrix(symname,m); | |
310 | } | |
311 | ||
312 | //______________________________________________________________________ | |
451f5018 | 313 | Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t index, Double_t t[3]) const |
ce886e8e | 314 | { |
315 | // Get the original translation vector (ideal geometry) | |
316 | // for a given module 'index' by quering the TGeoManager | |
ce886e8e | 317 | TGeoHMatrix m; |
318 | if (!GetOrigMatrix(index,m)) return kFALSE; | |
319 | ||
320 | Double_t *trans = m.GetTranslation(); | |
321 | for (Int_t i = 0; i < 3; i++) t[i] = trans[i]; | |
322 | ||
323 | return kTRUE; | |
324 | } | |
325 | ||
326 | //______________________________________________________________________ | |
451f5018 | 327 | Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t index, Double_t r[9]) const |
ce886e8e | 328 | { |
329 | // Get the original rotation matrix (ideal geometry) | |
330 | // for a given module 'index' by quering the TGeoManager | |
ce886e8e | 331 | TGeoHMatrix m; |
332 | if (!GetOrigMatrix(index,m)) return kFALSE; | |
333 | ||
334 | Double_t *rot = m.GetRotationMatrix(); | |
335 | for (Int_t i = 0; i < 9; i++) r[i] = rot[i]; | |
336 | ||
337 | return kTRUE; | |
338 | } | |
339 | ||
340 | //______________________________________________________________________ | |
451f5018 | 341 | const TGeoHMatrix* AliITSUGeomTGeo::GetTracking2LocalMatrix(Int_t index) const |
ce886e8e | 342 | { |
343 | // Get the matrix which transforms from the tracking to local r.s. | |
344 | // The method queries directly the TGeoPNEntry | |
ce886e8e | 345 | TGeoPNEntry *pne = GetPNEntry(index); |
346 | if (!pne) return NULL; | |
347 | ||
348 | const TGeoHMatrix *m = pne->GetMatrix(); | |
349 | if (!m) | |
451f5018 | 350 | AliError(Form("TGeoPNEntry (%s) contains no matrix !",pne->GetName())); |
ce886e8e | 351 | |
352 | return m; | |
353 | } | |
354 | ||
355 | //______________________________________________________________________ | |
451f5018 | 356 | Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t index, TGeoHMatrix &m) const |
ce886e8e | 357 | { |
358 | // Get the matrix which transforms from the tracking r.s. to | |
359 | // the global one. | |
360 | // Returns kFALSE in case of error. | |
ce886e8e | 361 | m.Clear(); |
362 | ||
363 | TGeoHMatrix *m1 = GetMatrix(index); | |
364 | if (!m1) return kFALSE; | |
365 | ||
366 | const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index); | |
367 | if (!m2) return kFALSE; | |
368 | ||
369 | m = *m1; | |
370 | m.Multiply(m2); | |
371 | ||
372 | return kTRUE; | |
373 | } | |
374 | ||
375 | //______________________________________________________________________ | |
451f5018 | 376 | TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t lay, Int_t ladd, Int_t detInLad) const |
377 | { | |
378 | // Get the transformation matrix of the SENSOR (not ncessary the same as the module) for a given module 'index' | |
379 | // by quering the TGeoManager | |
380 | const TString kPathBase = Form("/ALIC_1/%s_1/",AliITSUGeomTGeo::GetITSVolPattern()); | |
381 | const TString kNames = Form("%%s%s%%d_1/%s%%d_%%d/%s%%d_%%d/%s%%d_%%d" | |
382 | ,AliITSUGeomTGeo::GetITSLayerPattern() | |
383 | ,AliITSUGeomTGeo::GetITSLadderPattern() | |
384 | ,AliITSUGeomTGeo::GetITSModulePattern() | |
385 | ,AliITSUGeomTGeo::GetITSSensorPattern()); | |
386 | TString path; | |
387 | // | |
388 | path.Form(kNames.Data(),kPathBase.Data(),lay,lay,ladd,lay,detInLad,lay,1); | |
389 | gGeoManager->PushPath(); | |
390 | if (!gGeoManager->cd(path.Data())) { | |
391 | gGeoManager->PopPath(); | |
392 | AliError(Form("Error in cd-ing to %s",path.Data())); | |
393 | return 0; | |
394 | } // end if !gGeoManager | |
395 | TGeoHMatrix* mat = gGeoManager->GetCurrentMatrix(); | |
396 | // Retstore the modeler state. | |
397 | gGeoManager->PopPath(); | |
398 | return mat; | |
399 | } | |
400 | ||
401 | ||
402 | //______________________________________________________________________ | |
403 | TGeoPNEntry* AliITSUGeomTGeo::GetPNEntry(Int_t index) const | |
ce886e8e | 404 | { |
405 | // Get a pointer to the TGeoPNEntry of a module | |
406 | // identified by 'index' | |
407 | // Returns NULL in case of invalid index, | |
408 | // missing TGeoManager or invalid symbolic name | |
ce886e8e | 409 | // |
451f5018 | 410 | if (index >= fNModules) { |
411 | AliError(Form("Invalid ITS module index: %d (0 -> %d) !",index,fNModules)); | |
ce886e8e | 412 | return NULL; |
413 | } | |
414 | ||
415 | if (!gGeoManager || !gGeoManager->IsClosed()) { | |
451f5018 | 416 | AliError("Can't get the matrix! gGeoManager doesn't exist or it is still opened!"); |
ce886e8e | 417 | return NULL; |
418 | } | |
419 | ||
420 | TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(GetSymName(index)); | |
451f5018 | 421 | if (!pne) AliError(Form("The symbolic volume name %s does not correspond to a physical entry!",GetSymName(index))); |
422 | // | |
ce886e8e | 423 | return pne; |
424 | } | |
425 | ||
426 | //______________________________________________________________________ | |
451f5018 | 427 | Bool_t AliITSUGeomTGeo::LocalToGlobal(Int_t index,const Double_t *loc, Double_t *glob) const |
ce886e8e | 428 | { |
429 | // Make the conversion from the local sensitive reference system to the global | |
430 | // reference system, for an arbitrary local position. The input is the pointer | |
431 | // to the array of local coordinates, the result is sent to the glob pointer. | |
432 | // | |
433 | // Please don't use this method to get the global coordinates of clusters, use | |
434 | // the direct method of AliCluster instead. | |
ce886e8e | 435 | // |
436 | const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index); | |
437 | if (!m2) return kFALSE; | |
438 | ||
439 | // The shift (in local y only) between alignable and sensitive volume | |
440 | // is extracted directly from the Tracking2Local matrix | |
441 | Double_t locSens[] = {loc[0], loc[1]+m2->GetTranslation()[1], loc[2]}; | |
442 | ||
443 | TGeoHMatrix *ml = GetMatrix(index); | |
444 | if (!ml) return kFALSE; | |
445 | ml->LocalToMaster(locSens,glob); | |
446 | return kTRUE; | |
447 | } | |
448 | ||
449 | //______________________________________________________________________ | |
451f5018 | 450 | Bool_t AliITSUGeomTGeo::GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc) const |
ce886e8e | 451 | { |
452 | // Make the conversion from the global reference system to the sensitive local | |
453 | // reference system, for an arbitrary global position. The input is the pointer | |
454 | // to the array of global coordinates, the result is sent to the loc pointer. | |
ce886e8e | 455 | // |
456 | TGeoHMatrix *ml = GetMatrix(index); | |
457 | if (!ml) return kFALSE; | |
458 | ||
459 | const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index); | |
460 | if (!m2) return kFALSE; | |
461 | ml->MasterToLocal(glob,loc); | |
462 | // The shift (in local y only) between alignable and sensitive volume | |
463 | // is extracted directly from the Tracking2Local matrix | |
464 | loc[1] -= m2->GetTranslation()[1]; | |
465 | ||
466 | return kTRUE; | |
467 | } | |
468 | ||
469 | //______________________________________________________________________ | |
451f5018 | 470 | Bool_t AliITSUGeomTGeo::LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob) const |
ce886e8e | 471 | { |
472 | // Make the conversion from the local sensitive reference system to the global | |
473 | // reference system, for an arbitrary vector. The input is the pointer to the | |
474 | // array of local coordinates, the result is sent to the glob pointer. | |
ce886e8e | 475 | // |
476 | TGeoHMatrix *ml = GetMatrix(index); | |
477 | if (!ml) return kFALSE; | |
478 | ml->LocalToMasterVect(loc,glob); | |
479 | return kTRUE; | |
480 | } | |
481 | ||
482 | //______________________________________________________________________ | |
451f5018 | 483 | Bool_t AliITSUGeomTGeo::GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc) const |
ce886e8e | 484 | { |
485 | // Make the conversion from the global reference system to the sensitive local | |
486 | // reference system, for an arbitrary vector. The input is the pointer to the | |
487 | // array of global coordinates, the result is sent to the loc pointer. | |
ce886e8e | 488 | TGeoHMatrix *ml = GetMatrix(index); |
489 | if (!ml) return kFALSE; | |
490 | ml->MasterToLocalVect(glob,loc); | |
ce886e8e | 491 | return kTRUE; |
492 | } | |
493 | ||
494 | //______________________________________________________________________ | |
451f5018 | 495 | void AliITSUGeomTGeo::BuildITS() |
ce886e8e | 496 | { |
497 | // exract upg ITS parameters from TGeo | |
451f5018 | 498 | if (fVersion!=kITSVNA) {AliWarning("Already built"); return; // already initialized} |
499 | if (!gGeoManager) AliFatal("Geometry is not loaded"); | |
ce886e8e | 500 | } |
451f5018 | 501 | fNLayers = ExtractNumberOfLayers(); |
502 | if (!fNLayers) return; | |
503 | // | |
504 | fNLadders = new Int_t[fNLayers]; | |
505 | fNDetectors = new Int_t[fNLayers]; | |
506 | fLrDetType = new Int_t[fNLayers]; | |
507 | fLastModIndex = new Int_t[fNLayers]; | |
508 | fNModules = 0; | |
509 | for (int i=0;i<fNLayers;i++) { | |
510 | fNLadders[i] = ExtractNumberOfLadders(i); | |
511 | fNDetectors[i] = ExtractNumberOfDetectors(i); | |
512 | fLrDetType[i] = ExtractLayerDetType(i); | |
513 | fNModules += fNLadders[i]*fNDetectors[i]; | |
514 | fLastModIndex[i] = fNModules-1; | |
515 | } | |
516 | // | |
517 | fVersion = kITSVUpg; | |
ce886e8e | 518 | // |
519 | } | |
520 | ||
521 | //______________________________________________________________________ | |
451f5018 | 522 | Int_t AliITSUGeomTGeo::ExtractNumberOfLayers() const |
ce886e8e | 523 | { |
524 | // Determines the number of layers in the Upgrade Geometry | |
525 | // | |
ce886e8e | 526 | Int_t numberOfLayers = 0; |
527 | // | |
528 | TGeoVolume *itsV = gGeoManager->GetVolume(fgkITSVolName); | |
451f5018 | 529 | if (!itsV) AliFatal(Form("ITS volume %s is not in the geometry",fgkITSVolName)); |
ce886e8e | 530 | // |
531 | // Loop on all ITSV nodes, count Layer volumes by checking names | |
532 | Int_t nNodes = itsV->GetNodes()->GetEntries(); | |
533 | for (Int_t j=0; j<nNodes; j++) if (strstr(itsV->GetNodes()->At(j)->GetName(),fgkITSLrName)) numberOfLayers++; | |
534 | // | |
535 | return numberOfLayers; | |
536 | } | |
537 | ||
538 | //______________________________________________________________________ | |
451f5018 | 539 | Int_t AliITSUGeomTGeo::ExtractNumberOfLadders(Int_t lay) const |
ce886e8e | 540 | { |
541 | // Determines the number of layers in the Upgrade Geometry | |
542 | // | |
543 | // Inputs: | |
451f5018 | 544 | // lay: layer number, starting from 0 |
545 | // | |
ce886e8e | 546 | // MS |
547 | Int_t numberOfLadders = 0; | |
548 | char laynam[30]; | |
549 | snprintf(laynam, 30, "%s%d",fgkITSLrName,lay); | |
550 | TGeoVolume* volLr = gGeoManager->GetVolume(laynam); | |
451f5018 | 551 | if (!volLr) AliFatal(Form("can't find %s volume",laynam)); |
ce886e8e | 552 | // |
553 | // Loop on all layer nodes, count Ladder volumes by checking names | |
554 | Int_t nNodes = volLr->GetNodes()->GetEntries(); | |
555 | for (Int_t j=0; j<nNodes; j++) if (strstr(volLr->GetNodes()->At(j)->GetName(),fgkITSLadName)) numberOfLadders++; | |
556 | // | |
557 | return numberOfLadders; | |
558 | // | |
559 | } | |
560 | ||
561 | //______________________________________________________________________ | |
451f5018 | 562 | Int_t AliITSUGeomTGeo::ExtractNumberOfDetectors(Int_t lay) const |
ce886e8e | 563 | { |
564 | // Determines the number of detectors per ladder in the Upgrade Geometry | |
565 | // | |
566 | // Inputs: | |
451f5018 | 567 | // lay: layer number from 0 |
ce886e8e | 568 | // MS |
569 | Int_t numberOfModules = 0; | |
570 | char laddnam[30]; | |
571 | snprintf(laddnam, 30, "%s%d", fgkITSLadName,lay); | |
572 | TGeoVolume* volLd = gGeoManager->GetVolume(laddnam); | |
451f5018 | 573 | if (!volLd) AliFatal(Form("can't find %s volume",laddnam)); |
ce886e8e | 574 | // |
575 | // Loop on all ladder nodes, count Module volumes by checking names | |
576 | Int_t nNodes = volLd->GetNodes()->GetEntries(); | |
535d15f5 | 577 | for (Int_t j=0; j<nNodes; j++) if (strstr(volLd->GetNodes()->At(j)->GetName(),fgkITSModName)) numberOfModules++; |
ce886e8e | 578 | // |
579 | return numberOfModules; | |
580 | // | |
581 | } | |
535d15f5 | 582 | |
583 | //______________________________________________________________________ | |
451f5018 | 584 | Int_t AliITSUGeomTGeo::ExtractLayerDetType(Int_t lay) const |
535d15f5 | 585 | { |
586 | // Determines the layer detector type the Upgrade Geometry | |
587 | // | |
588 | // Inputs: | |
589 | // lay: layer number from 1 | |
590 | // Outputs: | |
591 | // none | |
592 | // Return: | |
593 | // detector type id for the layer | |
594 | // MS | |
595 | char laddnam[30]; | |
596 | snprintf(laddnam, 30, "%s%d", fgkITSLrName,lay); | |
597 | TGeoVolume* volLd = gGeoManager->GetVolume(laddnam); | |
451f5018 | 598 | if (!volLd) {AliFatal(Form("can't find %s volume",laddnam)); return -1;} |
535d15f5 | 599 | // |
600 | return volLd->GetUniqueID(); | |
601 | // | |
602 | } | |
451f5018 | 603 | |
604 | //______________________________________________________________________ | |
605 | UInt_t AliITSUGeomTGeo::ComposeDetTypeID(UInt_t segmId) | |
606 | { | |
607 | if (segmId>=kMaxSegmPerDetType) AliFatalClass(Form("Id=%d is >= max.allowed %d",segmId,kMaxSegmPerDetType)); | |
608 | return segmId + kDetTypePixUpg*kMaxSegmPerDetType; | |
609 | } |