]>
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 | /////////////////////////////////////////////////////////////////////////// | |
17 | // AliITSgeomTGeoUpg is a simple interface class to TGeoManager // | |
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 | // // | |
25 | /////////////////////////////////////////////////////////////////////////// | |
26 | ||
27 | #include <TClass.h> | |
28 | #include <TString.h> | |
29 | #include <TGeoManager.h> | |
30 | #include <TGeoPhysicalNode.h> | |
31 | #include <TDatime.h> | |
32 | ||
33 | #include "AliITSgeomTGeoUpg.h" | |
34 | #include "AliLog.h" | |
35 | #include "AliAlignObj.h" | |
36 | ||
37 | ClassImp(AliITSgeomTGeoUpg) | |
38 | ||
39 | ||
40 | const char* AliITSgeomTGeoUpg::fgkITSVolName = "ITSV"; | |
41 | const char* AliITSgeomTGeoUpg::fgkITSLrName = "ITSupgLayer"; | |
42 | const char* AliITSgeomTGeoUpg::fgkITSLadName = "ITSupgLadder"; | |
43 | const char* AliITSgeomTGeoUpg::fgkITSModName = "ITSupgModule"; | |
535d15f5 | 44 | const char* AliITSgeomTGeoUpg::fgkITSSensName ="ITSupgSensor"; |
ce886e8e | 45 | |
46 | const Int_t AliITSgeomTGeoUpg::fgkNModulesOld = 2198; | |
47 | const Int_t AliITSgeomTGeoUpg::fgkNLaddersOld[AliITSgeomTGeoUpg::kNLayersOld] = {20,40,14,22,34,38}; | |
48 | const Int_t AliITSgeomTGeoUpg::fgkNDetectorsOld[AliITSgeomTGeoUpg::kNLayersOld] = {4,4,6,8,22,25}; | |
49 | ||
50 | Int_t AliITSgeomTGeoUpg::fgVersion = 0; | |
51 | Int_t AliITSgeomTGeoUpg::fgNLayers = 0; | |
52 | Int_t AliITSgeomTGeoUpg::fgNModules = 0; | |
53 | Int_t* AliITSgeomTGeoUpg::fgNLadders = 0; | |
54 | Int_t* AliITSgeomTGeoUpg::fgNDetectors = 0; | |
535d15f5 | 55 | Int_t* AliITSgeomTGeoUpg::fgLrDetType = 0; |
ce886e8e | 56 | |
57 | ||
58 | //______________________________________________________________________ | |
59 | Int_t AliITSgeomTGeoUpg::GetModuleIndex(Int_t lay,Int_t lad,Int_t det) | |
60 | { | |
61 | // The method is taken from the old AliITSgeom class by Bjorn Nilsen | |
62 | // | |
63 | // This routine computes the module index number from the layer, | |
64 | // ladder, and detector numbers. The number of ladders and detectors | |
65 | // per layer is set statically | |
66 | // see above for details. | |
67 | // Inputs: | |
68 | // Int_t lay The layer number. Starting from 1. | |
69 | // Int_t lad The ladder number. Starting from 1. | |
70 | // Int_t det The detector number. Starting from 1. | |
71 | // Return: | |
72 | // the module index number, starting from zero. | |
73 | // -1 in case of error | |
74 | CheckInit(); | |
75 | // | |
76 | if (lay < 1 || lay > fgNLayers) { | |
77 | AliErrorClass(Form("Invalid layer: %d (1 -> %d",lay,fgNLayers)); | |
78 | return -1; | |
79 | } | |
80 | ||
81 | if (lad < 1 || lad > fgNLadders[lay-1] || | |
82 | det < 1 || det > fgNDetectors[lay-1]) { | |
83 | AliErrorClass(Form("Invalid layer,ladder,detector combination: %d, %d, %d",lay,lad,det)); | |
84 | return -1; | |
85 | } | |
86 | ||
87 | Int_t index = fgNDetectors[lay-1] * (lad-1) + (det-1); | |
88 | for(Int_t iLayer=0;iLayer < (lay-1); iLayer++) | |
89 | index += fgNDetectors[iLayer]*fgNLadders[iLayer]; | |
90 | ||
91 | return index; | |
92 | } | |
93 | ||
94 | //______________________________________________________________________ | |
95 | Bool_t AliITSgeomTGeoUpg::GetLayer(Int_t index,Int_t &lay,Int_t &index2) | |
96 | { | |
97 | // The method is taken from the old AliITSgeom class by Bjorn Nilsen | |
98 | // | |
99 | // This routine computes the layer number for a | |
100 | // given the module index. The number of ladders and detectors | |
101 | // per layer is defined statically, | |
102 | // see above for details. | |
103 | // Inputs: | |
104 | // Int_t index The module index number, starting from zero. | |
105 | // Outputs: | |
106 | // Int_t index2 The module index inside a layer, starting from zero. | |
107 | // Int_t lay The layer number. Starting from 1. | |
108 | // Return: | |
109 | // kTRUE in case of valid index | |
110 | // kFALSE in case of error | |
111 | CheckInit(); | |
112 | // | |
113 | if (index < 0 || index >= fgNModules) { | |
114 | index2 = -1; | |
115 | AliErrorClass(Form("Invalid module index: %d (0 -> %d)",index,fgNModules)); | |
116 | return -1; | |
117 | } | |
118 | ||
119 | lay = 0; | |
120 | index2 = 0; | |
121 | do { | |
122 | index2 += fgNLadders[lay]*fgNDetectors[lay]; | |
123 | lay++; | |
124 | } while(index2 <= index); | |
125 | index2 -= fgNLadders[lay-1]*fgNDetectors[lay-1]; | |
126 | index2 = index - index2; | |
127 | ||
128 | return lay; | |
129 | } | |
130 | ||
131 | //______________________________________________________________________ | |
132 | Bool_t AliITSgeomTGeoUpg::GetModuleId(Int_t index,Int_t &lay,Int_t &lad,Int_t &det) | |
133 | { | |
134 | // The method is taken from the old AliITSgeom class by Bjorn Nilsen | |
135 | // | |
136 | // This routine computes the layer, ladder and detector number | |
137 | // given the module index number. The number of ladders and detectors | |
138 | // per layer is defined statically, | |
139 | // see above for details. | |
140 | // Inputs: | |
141 | // Int_t index The module index number, starting from zero. | |
142 | // Outputs: | |
143 | // Int_t lay The layer number. Starting from 1. | |
144 | // Int_t lad The ladder number. Starting from 1. | |
145 | // Int_t det The detector number. Starting from 1. | |
146 | // Return: | |
147 | // kTRUE in case of valid index | |
148 | // kFALSE in case of error | |
149 | CheckInit(); | |
150 | // | |
151 | if (index < 0 || index >= fgNModules) { | |
152 | lay = lad = det = -1; | |
153 | AliErrorClass(Form("Invalid module index: %d (0 -> %d)",index,fgNModules)); | |
154 | return kFALSE; | |
155 | } | |
156 | ||
157 | lay = lad = det = 0; | |
158 | Int_t index2 = 0; | |
159 | do { | |
160 | index2 += fgNLadders[lay]*fgNDetectors[lay]; | |
161 | lay++; | |
162 | } while(index2 <= index); | |
163 | index2 -= fgNLadders[lay-1]*fgNDetectors[lay-1]; | |
164 | ||
165 | do { | |
166 | index2 += fgNDetectors[lay-1]; | |
167 | lad++; | |
168 | } while(index2 <= index); | |
169 | index2 -= fgNDetectors[lay-1]; | |
170 | ||
171 | det = index-index2+1; | |
172 | ||
173 | return kTRUE; | |
174 | } | |
175 | ||
176 | //______________________________________________________________________ | |
177 | const char* AliITSgeomTGeoUpg::GetSymName(Int_t index) | |
178 | { | |
179 | // Get the TGeoPNEntry symbolic name | |
180 | // for a given module identified by 'index' | |
181 | CheckInit(); | |
182 | // | |
183 | if (index < 0 || index >= fgNModules) { | |
184 | AliErrorClass(Form("Invalid ITS module index: %d (0 -> %d) !",index,fgNModules)); | |
185 | return NULL; | |
186 | } | |
187 | ||
188 | Int_t lay, index2; | |
189 | if (!GetLayer(index,lay,index2)) return NULL; | |
190 | if (fgVersion == kITSVOld) return AliGeomManager::SymName((AliGeomManager::ELayerID)((lay-1)+AliGeomManager::kSPD1),index2); | |
191 | else { | |
192 | // RS: this is not optimal, but we cannod access directly AliGeomManager, since the latter has hardwired layers | |
193 | TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID( AliGeomManager::LayerToVolUID(lay,index2) ); | |
194 | if (!pne) { | |
195 | AliErrorClass(Form("Failed to find alignable entry with index %d: (Lr%d Mod:%d) !",index,lay,index2)); | |
196 | return NULL; | |
197 | } | |
198 | return pne->GetName(); | |
199 | } | |
200 | } | |
201 | ||
202 | //______________________________________________________________________ | |
203 | TGeoHMatrix* AliITSgeomTGeoUpg::GetMatrix(Int_t index) | |
204 | { | |
205 | // Get the transformation matrix for a given module 'index' | |
206 | // by quering the TGeoManager | |
207 | CheckInit(); | |
208 | // | |
209 | TGeoPNEntry *pne = GetPNEntry(index); | |
210 | if (!pne) return NULL; | |
211 | ||
212 | TGeoPhysicalNode *pnode = pne->GetPhysicalNode(); | |
213 | if (pnode) return pnode->GetMatrix(); | |
214 | ||
215 | const char* path = pne->GetTitle(); | |
216 | if (!gGeoManager->cd(path)) { | |
217 | AliErrorClass(Form("Volume path %s not valid!",path)); | |
218 | return NULL; | |
219 | } | |
220 | return gGeoManager->GetCurrentMatrix(); | |
221 | } | |
222 | ||
223 | //______________________________________________________________________ | |
224 | Bool_t AliITSgeomTGeoUpg::GetTranslation(Int_t index, Double_t t[3]) | |
225 | { | |
226 | // Get the translation vector for a given module 'index' | |
227 | // by quering the TGeoManager | |
228 | CheckInit(); | |
229 | // | |
230 | TGeoHMatrix *m = GetMatrix(index); | |
231 | if (!m) return kFALSE; | |
232 | ||
233 | Double_t *trans = m->GetTranslation(); | |
234 | for (Int_t i = 0; i < 3; i++) t[i] = trans[i]; | |
235 | ||
236 | return kTRUE; | |
237 | } | |
238 | ||
239 | //______________________________________________________________________ | |
240 | Bool_t AliITSgeomTGeoUpg::GetRotation(Int_t index, Double_t r[9]) | |
241 | { | |
242 | // Get the rotation matrix for a given module 'index' | |
243 | // by quering the TGeoManager | |
244 | CheckInit(); | |
245 | // | |
246 | TGeoHMatrix *m = GetMatrix(index); | |
247 | if (!m) return kFALSE; | |
248 | ||
249 | Double_t *rot = m->GetRotationMatrix(); | |
250 | for (Int_t i = 0; i < 9; i++) r[i] = rot[i]; | |
251 | ||
252 | return kTRUE; | |
253 | } | |
254 | ||
255 | //______________________________________________________________________ | |
256 | Bool_t AliITSgeomTGeoUpg::GetOrigMatrix(Int_t index, TGeoHMatrix &m) | |
257 | { | |
258 | // Get the original (ideal geometry) TGeo matrix for | |
259 | // a given module identified by 'index'. | |
260 | // The method is slow, so it should be used | |
261 | // with great care. | |
262 | CheckInit(); | |
263 | // | |
264 | m.Clear(); | |
265 | ||
266 | const char *symname = GetSymName(index); | |
267 | if (!symname) return kFALSE; | |
268 | ||
269 | return AliGeomManager::GetOrigGlobalMatrix(symname,m); | |
270 | } | |
271 | ||
272 | //______________________________________________________________________ | |
273 | Bool_t AliITSgeomTGeoUpg::GetOrigTranslation(Int_t index, Double_t t[3]) | |
274 | { | |
275 | // Get the original translation vector (ideal geometry) | |
276 | // for a given module 'index' by quering the TGeoManager | |
277 | CheckInit(); | |
278 | // | |
279 | TGeoHMatrix m; | |
280 | if (!GetOrigMatrix(index,m)) return kFALSE; | |
281 | ||
282 | Double_t *trans = m.GetTranslation(); | |
283 | for (Int_t i = 0; i < 3; i++) t[i] = trans[i]; | |
284 | ||
285 | return kTRUE; | |
286 | } | |
287 | ||
288 | //______________________________________________________________________ | |
289 | Bool_t AliITSgeomTGeoUpg::GetOrigRotation(Int_t index, Double_t r[9]) | |
290 | { | |
291 | // Get the original rotation matrix (ideal geometry) | |
292 | // for a given module 'index' by quering the TGeoManager | |
293 | CheckInit(); | |
294 | // | |
295 | TGeoHMatrix m; | |
296 | if (!GetOrigMatrix(index,m)) return kFALSE; | |
297 | ||
298 | Double_t *rot = m.GetRotationMatrix(); | |
299 | for (Int_t i = 0; i < 9; i++) r[i] = rot[i]; | |
300 | ||
301 | return kTRUE; | |
302 | } | |
303 | ||
304 | //______________________________________________________________________ | |
305 | const TGeoHMatrix* AliITSgeomTGeoUpg::GetTracking2LocalMatrix(Int_t index) | |
306 | { | |
307 | // Get the matrix which transforms from the tracking to local r.s. | |
308 | // The method queries directly the TGeoPNEntry | |
309 | CheckInit(); | |
310 | // | |
311 | TGeoPNEntry *pne = GetPNEntry(index); | |
312 | if (!pne) return NULL; | |
313 | ||
314 | const TGeoHMatrix *m = pne->GetMatrix(); | |
315 | if (!m) | |
316 | AliErrorClass(Form("TGeoPNEntry (%s) contains no matrix !",pne->GetName())); | |
317 | ||
318 | return m; | |
319 | } | |
320 | ||
321 | //______________________________________________________________________ | |
322 | Bool_t AliITSgeomTGeoUpg::GetTrackingMatrix(Int_t index, TGeoHMatrix &m) | |
323 | { | |
324 | // Get the matrix which transforms from the tracking r.s. to | |
325 | // the global one. | |
326 | // Returns kFALSE in case of error. | |
327 | CheckInit(); | |
328 | // | |
329 | m.Clear(); | |
330 | ||
331 | TGeoHMatrix *m1 = GetMatrix(index); | |
332 | if (!m1) return kFALSE; | |
333 | ||
334 | const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index); | |
335 | if (!m2) return kFALSE; | |
336 | ||
337 | m = *m1; | |
338 | m.Multiply(m2); | |
339 | ||
340 | return kTRUE; | |
341 | } | |
342 | ||
343 | //______________________________________________________________________ | |
344 | TGeoPNEntry* AliITSgeomTGeoUpg::GetPNEntry(Int_t index) | |
345 | { | |
346 | // Get a pointer to the TGeoPNEntry of a module | |
347 | // identified by 'index' | |
348 | // Returns NULL in case of invalid index, | |
349 | // missing TGeoManager or invalid symbolic name | |
350 | CheckInit(); | |
351 | // | |
352 | if (index < 0 || index >= fgNModules) { | |
353 | AliErrorClass(Form("Invalid ITS module index: %d (0 -> %d) !",index,fgNModules)); | |
354 | return NULL; | |
355 | } | |
356 | ||
357 | if (!gGeoManager || !gGeoManager->IsClosed()) { | |
358 | AliErrorClass("Can't get the matrix! gGeoManager doesn't exist or it is still opened!"); | |
359 | return NULL; | |
360 | } | |
361 | ||
362 | TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(GetSymName(index)); | |
363 | if (!pne) | |
364 | AliErrorClass(Form("The symbolic volume name %s does not correspond to a physical entry!", | |
365 | GetSymName(index))); | |
366 | ||
367 | return pne; | |
368 | } | |
369 | ||
370 | //______________________________________________________________________ | |
371 | Bool_t AliITSgeomTGeoUpg::LocalToGlobal(Int_t index, | |
372 | const Double_t *loc, Double_t *glob) | |
373 | { | |
374 | // Make the conversion from the local sensitive reference system to the global | |
375 | // reference system, for an arbitrary local position. The input is the pointer | |
376 | // to the array of local coordinates, the result is sent to the glob pointer. | |
377 | // | |
378 | // Please don't use this method to get the global coordinates of clusters, use | |
379 | // the direct method of AliCluster instead. | |
380 | CheckInit(); | |
381 | // | |
382 | const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index); | |
383 | if (!m2) return kFALSE; | |
384 | ||
385 | // The shift (in local y only) between alignable and sensitive volume | |
386 | // is extracted directly from the Tracking2Local matrix | |
387 | Double_t locSens[] = {loc[0], loc[1]+m2->GetTranslation()[1], loc[2]}; | |
388 | ||
389 | TGeoHMatrix *ml = GetMatrix(index); | |
390 | if (!ml) return kFALSE; | |
391 | ml->LocalToMaster(locSens,glob); | |
392 | return kTRUE; | |
393 | } | |
394 | ||
395 | //______________________________________________________________________ | |
396 | Bool_t AliITSgeomTGeoUpg::GlobalToLocal(Int_t index, | |
397 | const Double_t *glob, Double_t *loc) | |
398 | { | |
399 | // Make the conversion from the global reference system to the sensitive local | |
400 | // reference system, for an arbitrary global position. The input is the pointer | |
401 | // to the array of global coordinates, the result is sent to the loc pointer. | |
402 | CheckInit(); | |
403 | // | |
404 | TGeoHMatrix *ml = GetMatrix(index); | |
405 | if (!ml) return kFALSE; | |
406 | ||
407 | const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index); | |
408 | if (!m2) return kFALSE; | |
409 | ml->MasterToLocal(glob,loc); | |
410 | // The shift (in local y only) between alignable and sensitive volume | |
411 | // is extracted directly from the Tracking2Local matrix | |
412 | loc[1] -= m2->GetTranslation()[1]; | |
413 | ||
414 | return kTRUE; | |
415 | } | |
416 | ||
417 | //______________________________________________________________________ | |
418 | Bool_t AliITSgeomTGeoUpg::LocalToGlobalVect(Int_t index, | |
419 | const Double_t *loc, Double_t *glob) | |
420 | { | |
421 | // Make the conversion from the local sensitive reference system to the global | |
422 | // reference system, for an arbitrary vector. The input is the pointer to the | |
423 | // array of local coordinates, the result is sent to the glob pointer. | |
424 | CheckInit(); | |
425 | // | |
426 | TGeoHMatrix *ml = GetMatrix(index); | |
427 | if (!ml) return kFALSE; | |
428 | ml->LocalToMasterVect(loc,glob); | |
429 | return kTRUE; | |
430 | } | |
431 | ||
432 | //______________________________________________________________________ | |
433 | Bool_t AliITSgeomTGeoUpg::GlobalToLocalVect(Int_t index, | |
434 | const Double_t *glob, Double_t *loc) | |
435 | { | |
436 | // Make the conversion from the global reference system to the sensitive local | |
437 | // reference system, for an arbitrary vector. The input is the pointer to the | |
438 | // array of global coordinates, the result is sent to the loc pointer. | |
439 | CheckInit(); | |
440 | // | |
441 | TGeoHMatrix *ml = GetMatrix(index); | |
442 | if (!ml) return kFALSE; | |
443 | ml->MasterToLocalVect(glob,loc); | |
444 | ||
445 | return kTRUE; | |
446 | } | |
447 | ||
448 | //______________________________________________________________________ | |
449 | void AliITSgeomTGeoUpg::BuildITS() | |
450 | { | |
451 | // build ITS info from TGeo | |
452 | if (fgVersion!=kITSVNA) return; // already initialized | |
453 | // | |
454 | if (!gGeoManager) AliFatalClass("Geometry is not loaded"); | |
455 | // | |
456 | // get ITS version | |
457 | TGeoVolume *itsV = gGeoManager->GetVolume(fgkITSVolName); | |
458 | if (!gGeoManager) AliFatalClass(Form("ITS volume %s is not in the geometry",fgkITSVolName)); | |
459 | // | |
460 | Int_t minor = 0; | |
461 | TDatime datetime; | |
462 | const Char_t *title = itsV->GetTitle(); | |
463 | if(!ReadVersionString(title,fgVersion,minor,datetime)) | |
464 | AliFatalClass(Form("Can't read title %s to extract version",title)); | |
465 | // | |
466 | if (fgVersion==kITSVNA) AliFatalClass(Form("Failed to detrmine ITS version from title %s",title)); | |
467 | // | |
468 | (fgVersion==kITSVOld) ? BuildITSOld() : BuildITSUpg(); | |
469 | // | |
470 | } | |
471 | ||
472 | //______________________________________________________________________ | |
473 | void AliITSgeomTGeoUpg::BuildITSOld() | |
474 | { | |
475 | // assign old ITS | |
476 | fgNLayers = kNLayersOld; | |
477 | fgNModules = fgkNModulesOld; | |
478 | fgNLadders = (Int_t*)fgkNLaddersOld; | |
479 | fgNDetectors = (Int_t*)fgkNDetectorsOld; | |
535d15f5 | 480 | fgLrDetType = 0; |
ce886e8e | 481 | } |
482 | ||
483 | //______________________________________________________________________ | |
484 | void AliITSgeomTGeoUpg::BuildITSUpg() | |
485 | { | |
486 | // exract upg ITS parameters from TGeo | |
487 | fgNLayers = ExtractNumberOfLayers(); | |
488 | if (!fgNLayers) return; | |
489 | // | |
490 | fgNLadders = new Int_t[fgNLayers]; | |
491 | fgNDetectors = new Int_t[fgNLayers]; | |
535d15f5 | 492 | fgLrDetType = new Int_t[fgNLayers]; |
ce886e8e | 493 | fgNModules = 0; |
494 | for (int i=0;i<fgNLayers;i++) { | |
91fc36e5 | 495 | fgNLadders[i] = ExtractNumberOfLadders(i+1); |
496 | fgNDetectors[i] = ExtractNumberOfDetectors(i+1); | |
535d15f5 | 497 | fgLrDetType[i] = ExtractLayerDetType(i+1); |
ce886e8e | 498 | fgNModules += fgNLadders[i]*fgNDetectors[i]; |
499 | } | |
500 | // | |
501 | } | |
502 | ||
503 | //______________________________________________________________________ | |
504 | Bool_t AliITSgeomTGeoUpg::ReadVersionString(const Char_t *str, | |
505 | Int_t &maj,Int_t &min, | |
506 | TDatime &dt) | |
507 | { | |
508 | // fills the string str with the major and minor version number | |
509 | // Inputs: | |
510 | // Char_t *str The character string to holding the major and minor | |
511 | // version numbers in | |
512 | // Outputs: | |
513 | // Int_t maj The major number | |
514 | // Int_t min The minor number | |
515 | // TDatime dt The date and time of the cvs commit | |
516 | // Return: | |
517 | // kTRUE if no errors | |
2695e019 | 518 | enum {kv11=11,kv110=110,kvUpgrade=20}; // RS: to make consistent global numbering scheme |
ce886e8e | 519 | |
520 | Bool_t ok; | |
521 | Char_t cvsRevision[10],cvsDate[11],cvsTime[9]; | |
522 | Int_t i,m,n=strlen(str),year,month,day,hours,minuts,seconds; | |
523 | memset(cvsRevision,0,10*sizeof(Char_t)); | |
524 | memset(cvsDate,0,11*sizeof(Char_t)); | |
525 | memset(cvsTime,0,9*sizeof(Char_t)); | |
526 | ||
527 | if(n<35) return kFALSE; // not enough space for numbers | |
528 | m = sscanf(str,"Major Version= %d Minor Version= %d Revision: %9s " | |
529 | "Date: %10s %8s",&i,&min,cvsRevision,cvsDate,cvsTime); | |
530 | ok = m==5; | |
531 | if(!ok) return !ok; | |
532 | m = sscanf(cvsDate,"%d/%d/%d",&year,&month,&day); | |
533 | ok = m==3; | |
534 | if(!ok) return !ok; | |
535 | m = sscanf(cvsTime,"%d:%d:%d",&hours,&minuts,&seconds); | |
536 | ok = m==3; | |
537 | if(!ok) return !ok; | |
538 | dt.Set(year,month,day,hours,minuts,seconds); | |
539 | // | |
540 | switch (i){ | |
2695e019 | 541 | case kv110: |
ce886e8e | 542 | case kv11:{ |
543 | maj = kITSVOld; | |
544 | } break; | |
545 | case kvUpgrade:{ | |
546 | maj = kITSVUpg; | |
547 | } break; | |
548 | default:{ | |
549 | maj = kITSVNA; | |
550 | } break; | |
551 | } // end switch | |
552 | return ok; | |
553 | } | |
554 | ||
555 | //______________________________________________________________________ | |
556 | Int_t AliITSgeomTGeoUpg::ExtractNumberOfLayers() | |
557 | { | |
558 | // Determines the number of layers in the Upgrade Geometry | |
559 | // | |
560 | // Inputs: | |
561 | // none | |
562 | // Outputs: | |
563 | // none | |
564 | // Return: | |
565 | // the number of layers in the current geometry | |
566 | // -1 if not Upgrade Geometry | |
567 | // MS | |
568 | // | |
569 | Int_t numberOfLayers = 0; | |
570 | // | |
571 | TGeoVolume *itsV = gGeoManager->GetVolume(fgkITSVolName); | |
572 | if (!itsV) AliFatalClass(Form("ITS volume %s is not in the geometry",fgkITSVolName)); | |
573 | // | |
574 | // Loop on all ITSV nodes, count Layer volumes by checking names | |
575 | Int_t nNodes = itsV->GetNodes()->GetEntries(); | |
576 | for (Int_t j=0; j<nNodes; j++) if (strstr(itsV->GetNodes()->At(j)->GetName(),fgkITSLrName)) numberOfLayers++; | |
577 | // | |
578 | return numberOfLayers; | |
579 | } | |
580 | ||
581 | //______________________________________________________________________ | |
582 | Int_t AliITSgeomTGeoUpg::ExtractNumberOfLadders(const Int_t lay) | |
583 | { | |
584 | // Determines the number of layers in the Upgrade Geometry | |
585 | // | |
586 | // Inputs: | |
91fc36e5 | 587 | // lay: layer number, starting from 1 |
ce886e8e | 588 | // Outputs: |
589 | // none | |
590 | // Return: | |
591 | // the number of ladders in layer lay | |
592 | // -1 if not Upgrade Geometry | |
593 | // MS | |
594 | Int_t numberOfLadders = 0; | |
595 | char laynam[30]; | |
596 | snprintf(laynam, 30, "%s%d",fgkITSLrName,lay); | |
597 | TGeoVolume* volLr = gGeoManager->GetVolume(laynam); | |
598 | if (!volLr) AliFatalClass(Form("can't find %s volume",laynam)); | |
599 | // | |
600 | // Loop on all layer nodes, count Ladder volumes by checking names | |
601 | Int_t nNodes = volLr->GetNodes()->GetEntries(); | |
602 | for (Int_t j=0; j<nNodes; j++) if (strstr(volLr->GetNodes()->At(j)->GetName(),fgkITSLadName)) numberOfLadders++; | |
603 | // | |
604 | return numberOfLadders; | |
605 | // | |
606 | } | |
607 | ||
608 | //______________________________________________________________________ | |
609 | Int_t AliITSgeomTGeoUpg::ExtractNumberOfDetectors(const Int_t lay) | |
610 | { | |
611 | // Determines the number of detectors per ladder in the Upgrade Geometry | |
612 | // | |
613 | // Inputs: | |
91fc36e5 | 614 | // lay: layer number from 1 |
ce886e8e | 615 | // Outputs: |
616 | // none | |
617 | // Return: | |
618 | // the number of modules per ladder in layer lay | |
619 | // -1 if not Upgrade Geometry | |
620 | // MS | |
621 | Int_t numberOfModules = 0; | |
622 | char laddnam[30]; | |
623 | snprintf(laddnam, 30, "%s%d", fgkITSLadName,lay); | |
624 | TGeoVolume* volLd = gGeoManager->GetVolume(laddnam); | |
625 | if (!volLd) AliFatalClass(Form("can't find %s volume",laddnam)); | |
626 | // | |
627 | // Loop on all ladder nodes, count Module volumes by checking names | |
628 | Int_t nNodes = volLd->GetNodes()->GetEntries(); | |
535d15f5 | 629 | for (Int_t j=0; j<nNodes; j++) if (strstr(volLd->GetNodes()->At(j)->GetName(),fgkITSModName)) numberOfModules++; |
ce886e8e | 630 | // |
631 | return numberOfModules; | |
632 | // | |
633 | } | |
535d15f5 | 634 | |
635 | //______________________________________________________________________ | |
636 | Int_t AliITSgeomTGeoUpg::ExtractLayerDetType(const Int_t lay) | |
637 | { | |
638 | // Determines the layer detector type the Upgrade Geometry | |
639 | // | |
640 | // Inputs: | |
641 | // lay: layer number from 1 | |
642 | // Outputs: | |
643 | // none | |
644 | // Return: | |
645 | // detector type id for the layer | |
646 | // MS | |
647 | char laddnam[30]; | |
648 | snprintf(laddnam, 30, "%s%d", fgkITSLrName,lay); | |
649 | TGeoVolume* volLd = gGeoManager->GetVolume(laddnam); | |
650 | if (!volLd) {AliFatalClass(Form("can't find %s volume",laddnam)); return -1;} | |
651 | // | |
652 | return volLd->GetUniqueID(); | |
653 | // | |
654 | } |