]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUGeomTGeo.cxx
Lot of update + directory with test setup
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUGeomTGeo.cxx
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 //    AliITSUGeomTGeo 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 //    ATTENTION: In opposite to ols AliITSgeomTGeo, all indices start    //
26 //    from 0, not from 1!!!                                              //
27 //                                                                       //
28 ///////////////////////////////////////////////////////////////////////////
29
30 #include <TClass.h>
31 #include <TString.h>
32 #include <TGeoManager.h>
33 #include <TGeoPhysicalNode.h>
34 #include <TDatime.h>
35
36 #include "AliITSUGeomTGeo.h"
37 #include "AliLog.h"
38 #include "AliAlignObj.h"
39
40 ClassImp(AliITSUGeomTGeo)
41
42
43 const char* AliITSUGeomTGeo::fgkITSVolName = "ITSV";
44 const char* AliITSUGeomTGeo::fgkITSLrName  = "ITSULayer";
45 const char* AliITSUGeomTGeo::fgkITSLadName = "ITSULadder";
46 const char* AliITSUGeomTGeo::fgkITSModName = "ITSUModule";
47 const char* AliITSUGeomTGeo::fgkITSSensName ="ITSUSensor";
48 const char* AliITSUGeomTGeo::fgkITSDetTypeName[AliITSUGeomTGeo::kNDetTypes] = {"Pix"};
49 //
50 TString     AliITSUGeomTGeo::fgITSsegmFileName = "itsSegmentations.root";
51
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 }
65
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 }
91
92 //______________________________________________________________________
93 AliITSUGeomTGeo::~AliITSUGeomTGeo()
94 {
95   //d-tor
96   delete[] fNLadders;
97   delete[] fLrDetType;
98   delete[] fNDetectors;
99   delete[] fLastModIndex;
100 }
101
102
103 //______________________________________________________________________
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
134 {
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:
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
143   //
144   return GetFirstModIndex(lay) + fNDetectors[lay]*lad + det;
145 }
146
147 //______________________________________________________________________
148 Bool_t AliITSUGeomTGeo::GetLayer(Int_t index,Int_t &lay,Int_t &index2)  const
149 {
150   // This routine computes the layer number for a
151   // given the module index. The 
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.
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 }
163
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 }
173
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];
183 }
184
185 //______________________________________________________________________
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
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 
213   // given the module index number. 
214   // Inputs:
215   //     Int_t index  The module index number, starting from zero.
216   // Outputs:
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];
225   return kTRUE;
226 }
227
228 //______________________________________________________________________
229 const char* AliITSUGeomTGeo::GetSymName(Int_t index)  const
230 {
231   // Get the TGeoPNEntry symbolic name
232   // for a given module identified by 'index'
233   //
234   Int_t lay, index2;
235   if (!GetLayer(index,lay,index2)) return NULL;
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   TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID( ModuleVolUID(index) );
240   if (!pne) {
241     AliError(Form("Failed to find alignable entry with index %d: (Lr%d Mod:%d) !",index,lay,index2));
242     return NULL;
243   }
244   return pne->GetName();
245 }
246
247 //______________________________________________________________________
248 TGeoHMatrix* AliITSUGeomTGeo::GetMatrix(Int_t index)  const
249 {
250   // Get the transformation matrix for a given module 'index'
251   // by quering the TGeoManager
252   TGeoPNEntry *pne = GetPNEntry(index);
253   if (!pne) return NULL;
254
255   TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
256   if (pnode) return pnode->GetMatrix();
257
258   const char* path = pne->GetTitle();
259   gGeoManager->PushPath(); // Preserve the modeler state.
260   if (!gGeoManager->cd(path)) {
261     gGeoManager->PopPath();
262     AliError(Form("Volume path %s not valid!",path));
263     return NULL;
264   }
265   TGeoHMatrix *mat = gGeoManager->GetCurrentMatrix();
266   gGeoManager->PopPath();
267   return mat;
268 }
269
270 //______________________________________________________________________
271 Bool_t AliITSUGeomTGeo::GetTranslation(Int_t index, Double_t t[3])  const
272 {
273   // Get the translation vector for a given module 'index'
274   // by quering the TGeoManager
275   TGeoHMatrix *m = GetMatrix(index);
276   if (!m) return kFALSE;
277
278   Double_t *trans = m->GetTranslation();
279   for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
280
281   return kTRUE;
282 }
283
284 //______________________________________________________________________
285 Bool_t AliITSUGeomTGeo::GetRotation(Int_t index, Double_t r[9])  const
286 {
287   // Get the rotation matrix for a given module 'index'
288   // by quering the TGeoManager
289   TGeoHMatrix *m = GetMatrix(index);
290   if (!m) return kFALSE;
291
292   Double_t *rot = m->GetRotationMatrix();
293   for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
294
295   return kTRUE;
296 }
297
298 //______________________________________________________________________
299 Bool_t AliITSUGeomTGeo::GetOrigMatrix(Int_t index, TGeoHMatrix &m) const
300 {
301   // Get the original (ideal geometry) TGeo matrix for
302   // a given module identified by 'index'.
303   // The method is slow, so it should be used
304   // with great care.
305   m.Clear();
306
307   const char *symname = GetSymName(index);
308   if (!symname) return kFALSE;
309
310   return AliGeomManager::GetOrigGlobalMatrix(symname,m);
311 }
312
313 //______________________________________________________________________
314 Bool_t AliITSUGeomTGeo::GetOrigTranslation(Int_t index, Double_t t[3])  const
315 {
316   // Get the original translation vector (ideal geometry)
317   // for a given module 'index' by quering the TGeoManager
318   TGeoHMatrix m;
319   if (!GetOrigMatrix(index,m)) return kFALSE;
320
321   Double_t *trans = m.GetTranslation();
322   for (Int_t i = 0; i < 3; i++) t[i] = trans[i];
323
324   return kTRUE;
325 }
326
327 //______________________________________________________________________
328 Bool_t AliITSUGeomTGeo::GetOrigRotation(Int_t index, Double_t r[9])  const
329 {
330   // Get the original rotation matrix (ideal geometry)
331   // for a given module 'index' by quering the TGeoManager
332   TGeoHMatrix m;
333   if (!GetOrigMatrix(index,m)) return kFALSE;
334
335   Double_t *rot = m.GetRotationMatrix();
336   for (Int_t i = 0; i < 9; i++) r[i] = rot[i];
337
338   return kTRUE;
339 }
340
341 //______________________________________________________________________
342 const TGeoHMatrix* AliITSUGeomTGeo::GetTracking2LocalMatrix(Int_t index) const
343 {
344   // Get the matrix which transforms from the tracking to local r.s.
345   // The method queries directly the TGeoPNEntry
346   TGeoPNEntry *pne = GetPNEntry(index);
347   if (!pne) return NULL;
348
349   const TGeoHMatrix *m = pne->GetMatrix();
350   if (!m)
351     AliError(Form("TGeoPNEntry (%s) contains no matrix !",pne->GetName()));
352
353   return m;
354 }
355
356 //______________________________________________________________________
357 Bool_t AliITSUGeomTGeo::GetTrackingMatrix(Int_t index, TGeoHMatrix &m) const
358 {
359   // Get the matrix which transforms from the tracking r.s. to
360   // the global one.
361   // Returns kFALSE in case of error.
362   m.Clear();
363
364   TGeoHMatrix *m1 = GetMatrix(index);
365   if (!m1) return kFALSE;
366
367   const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
368   if (!m2) return kFALSE;
369
370   m = *m1;
371   m.Multiply(m2);
372
373   return kTRUE;
374 }
375
376 //______________________________________________________________________
377 TGeoHMatrix* AliITSUGeomTGeo::GetMatrixSens(Int_t lay, Int_t ladd, Int_t detInLad)  const
378 {
379   // Get the transformation matrix of the SENSOR (not ncessary the same as the module) for a given module 'index'
380   // by quering the TGeoManager
381   const TString kPathBase = Form("/ALIC_1/%s_2/",AliITSUGeomTGeo::GetITSVolPattern());
382   const TString kNames = Form("%%s%s%%d_1/%s%%d_%%d/%s%%d_%%d/%s%%d_%%d"
383                               ,AliITSUGeomTGeo::GetITSLayerPattern()
384                               ,AliITSUGeomTGeo::GetITSLadderPattern()
385                               ,AliITSUGeomTGeo::GetITSModulePattern()
386                               ,AliITSUGeomTGeo::GetITSSensorPattern());
387   TString path;
388   //
389   path.Form(kNames.Data(),kPathBase.Data(),lay,lay,ladd,lay,detInLad,lay,1);
390   gGeoManager->PushPath();
391   if (!gGeoManager->cd(path.Data())) {
392     gGeoManager->PopPath();
393     AliError(Form("Error in cd-ing to %s",path.Data()));
394     return 0;
395   } // end if !gGeoManager
396   TGeoHMatrix* mat = gGeoManager->GetCurrentMatrix();
397   // Retstore the modeler state.
398   gGeoManager->PopPath();
399   return mat;
400 }
401
402
403 //______________________________________________________________________
404 TGeoPNEntry* AliITSUGeomTGeo::GetPNEntry(Int_t index) const
405 {
406   // Get a pointer to the TGeoPNEntry of a module
407   // identified by 'index'
408   // Returns NULL in case of invalid index,
409   // missing TGeoManager or invalid symbolic name
410   //
411   if (index >= fNModules) {
412     AliError(Form("Invalid ITS module index: %d (0 -> %d) !",index,fNModules));
413     return NULL;
414   }
415   
416   if (!gGeoManager || !gGeoManager->IsClosed()) {
417     AliError("Can't get the matrix! gGeoManager doesn't exist or it is still opened!");
418     return NULL;
419   }
420
421   TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(GetSymName(index));
422   if (!pne) AliError(Form("The symbolic volume name %s does not correspond to a physical entry!",GetSymName(index)));
423   //
424   return pne;
425 }
426
427 //______________________________________________________________________
428 Bool_t AliITSUGeomTGeo::LocalToGlobal(Int_t index,const Double_t *loc, Double_t *glob) const
429 {
430   // Make the conversion from the local sensitive reference system to the global
431   // reference system, for an arbitrary local position. The input is the pointer
432   // to the array of local coordinates, the result is sent to the glob pointer.
433   //
434   // Please don't use this method to get the global coordinates of clusters, use
435   // the direct method of AliCluster instead.
436   //
437   const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
438   if (!m2) return kFALSE;
439
440   // The shift (in local y only) between alignable and sensitive volume
441   // is extracted directly from the Tracking2Local matrix
442   Double_t locSens[] = {loc[0], loc[1]+m2->GetTranslation()[1], loc[2]};
443
444   TGeoHMatrix *ml = GetMatrix(index);
445   if (!ml) return kFALSE;
446   ml->LocalToMaster(locSens,glob);
447   return kTRUE;
448 }
449
450 //______________________________________________________________________
451 Bool_t AliITSUGeomTGeo::GlobalToLocal(Int_t index, const Double_t *glob, Double_t *loc) const
452 {
453   // Make the conversion from the global reference system to the sensitive local
454   // reference system, for an arbitrary global position. The input is the pointer
455   // to the array of global coordinates, the result is sent to the loc pointer.
456   //
457   TGeoHMatrix *ml = GetMatrix(index);
458   if (!ml) return kFALSE;
459
460   const TGeoHMatrix *m2 = GetTracking2LocalMatrix(index);
461   if (!m2) return kFALSE;
462   ml->MasterToLocal(glob,loc);
463   // The shift (in local y only) between alignable and sensitive volume
464   // is extracted directly from the Tracking2Local matrix
465   loc[1] -= m2->GetTranslation()[1];
466
467   return kTRUE;
468 }
469
470 //______________________________________________________________________
471 Bool_t AliITSUGeomTGeo::LocalToGlobalVect(Int_t index, const Double_t *loc, Double_t *glob) const
472 {
473   // Make the conversion from the local sensitive reference system to the global
474   // reference system, for an arbitrary vector. The input is the pointer to the
475   // array of local coordinates, the result is sent to the glob pointer.
476   //
477   TGeoHMatrix *ml = GetMatrix(index);
478   if (!ml) return kFALSE;
479   ml->LocalToMasterVect(loc,glob);
480   return kTRUE;
481 }
482
483 //______________________________________________________________________
484 Bool_t AliITSUGeomTGeo::GlobalToLocalVect(Int_t index, const Double_t *glob, Double_t *loc) const
485 {
486   // Make the conversion from the global reference system to the sensitive local
487   // reference system, for an arbitrary vector. The input is the pointer to the
488   // array of global coordinates, the result is sent to the loc pointer.
489   TGeoHMatrix *ml = GetMatrix(index);
490   if (!ml) return kFALSE;
491   ml->MasterToLocalVect(glob,loc);
492   return kTRUE;
493 }
494
495 //______________________________________________________________________
496 void AliITSUGeomTGeo::BuildITS()
497 {
498   // exract upg ITS parameters from TGeo
499   if (fVersion!=kITSVNA) {AliWarning("Already built"); return; // already initialized}
500     if (!gGeoManager) AliFatal("Geometry is not loaded");
501   }
502   fNLayers    = ExtractNumberOfLayers();
503   if (!fNLayers) return;
504   //
505   fNLadders   = new Int_t[fNLayers];
506   fNDetectors = new Int_t[fNLayers];
507   fLrDetType  = new Int_t[fNLayers];
508   fLastModIndex   = new Int_t[fNLayers];
509   fNModules = 0;
510   for (int i=0;i<fNLayers;i++) {
511     fNLadders[i]   = ExtractNumberOfLadders(i);
512     fNDetectors[i] = ExtractNumberOfDetectors(i);
513     fLrDetType[i]  = ExtractLayerDetType(i);
514     fNModules     += fNLadders[i]*fNDetectors[i];
515     fLastModIndex[i]   = fNModules-1;
516   }
517   //
518   fVersion = kITSVUpg;
519   //
520 }
521
522 //______________________________________________________________________
523 Int_t AliITSUGeomTGeo::ExtractNumberOfLayers() const
524 {
525   // Determines the number of layers in the Upgrade Geometry
526   //
527   Int_t numberOfLayers = 0;
528   //
529   TGeoVolume *itsV = gGeoManager->GetVolume(fgkITSVolName);
530   if (!itsV) AliFatal(Form("ITS volume %s is not in the geometry",fgkITSVolName));
531   //
532   // Loop on all ITSV nodes, count Layer volumes by checking names
533   Int_t nNodes = itsV->GetNodes()->GetEntries();
534   for (Int_t j=0; j<nNodes; j++) if (strstr(itsV->GetNodes()->At(j)->GetName(),fgkITSLrName)) numberOfLayers++;
535   //  
536   return numberOfLayers;
537 }
538
539 //______________________________________________________________________
540 Int_t AliITSUGeomTGeo::ExtractNumberOfLadders(Int_t lay) const
541 {
542   // Determines the number of layers in the Upgrade Geometry
543   //
544   // Inputs:
545   //   lay: layer number, starting from 0
546   //
547   // MS
548   Int_t numberOfLadders = 0;
549   char laynam[30];
550   snprintf(laynam, 30, "%s%d",fgkITSLrName,lay);
551   TGeoVolume* volLr = gGeoManager->GetVolume(laynam);
552   if (!volLr) AliFatal(Form("can't find %s volume",laynam));
553   //
554   // Loop on all layer nodes, count Ladder volumes by checking names
555   Int_t nNodes = volLr->GetNodes()->GetEntries();
556   for (Int_t j=0; j<nNodes; j++) if (strstr(volLr->GetNodes()->At(j)->GetName(),fgkITSLadName)) numberOfLadders++;
557   //
558   return numberOfLadders;
559   //
560 }
561
562 //______________________________________________________________________
563 Int_t AliITSUGeomTGeo::ExtractNumberOfDetectors(Int_t lay)  const
564 {
565   // Determines the number of detectors per ladder in the Upgrade Geometry
566   //
567   // Inputs:
568   //   lay: layer number from 0
569   // MS
570   Int_t numberOfModules = 0;
571   char laddnam[30];
572   snprintf(laddnam, 30, "%s%d", fgkITSLadName,lay);
573   TGeoVolume* volLd = gGeoManager->GetVolume(laddnam);
574   if (!volLd) AliFatal(Form("can't find %s volume",laddnam));
575   //
576   // Loop on all ladder nodes, count Module volumes by checking names
577   Int_t nNodes = volLd->GetNodes()->GetEntries();
578   for (Int_t j=0; j<nNodes; j++) if (strstr(volLd->GetNodes()->At(j)->GetName(),fgkITSModName)) numberOfModules++;
579   //
580   return numberOfModules;
581   //
582 }
583
584 //______________________________________________________________________
585 Int_t AliITSUGeomTGeo::ExtractLayerDetType(Int_t lay)  const
586 {
587   // Determines the layer detector type the Upgrade Geometry
588   //
589   // Inputs:
590   //   lay: layer number from 1
591   // Outputs:
592   //   none
593   // Return:
594   //   detector type id for the layer
595   // MS
596   char laddnam[30];
597   snprintf(laddnam, 30, "%s%d", fgkITSLrName,lay);
598   TGeoVolume* volLd = gGeoManager->GetVolume(laddnam);
599   if (!volLd) {AliFatal(Form("can't find %s volume",laddnam)); return -1;}
600   //
601   return volLd->GetUniqueID();
602   //
603 }
604
605 //______________________________________________________________________
606 UInt_t AliITSUGeomTGeo::ComposeDetTypeID(UInt_t segmId)
607 {
608   if (segmId>=kMaxSegmPerDetType) AliFatalClass(Form("Id=%d is >= max.allowed %d",segmId,kMaxSegmPerDetType));
609   return segmId + kDetTypePix*kMaxSegmPerDetType;
610 }
611
612 //______________________________________________________________________
613 void AliITSUGeomTGeo::Print(Option_t *) const
614 {
615   // print
616   printf("Geometry version %d, NLayers:%d NModules:%d\n",fVersion,fNLayers,fNModules);
617   if (fVersion==kITSVNA) return;
618   for (int i=0;i<fNLayers;i++) {
619     printf("Lr%2d\tNLadd:%2d\tNDet:%2d\tDetType:%3d\tMod#:%4d:%4d\n",
620            i,fNLadders[i],fNDetectors[i],fLrDetType[i],GetFirstModIndex(i),GetLastModIndex(i));
621   }
622 }