Added classes for geometry - reconstruction interface, minor fixes in other classes
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUInitGeometry.cxx
CommitLineData
29998a6e 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$Id: AliITSUInitGeometry.cxx $
29998a6e 18*/
19////////////////////////////////////////////////////////////////
20// This class initializes the class AliITSgeom
21// The initialization is done starting from
22// a geometry coded by means of the ROOT geometrical modeler
23// This initialization can be used both for simulation and reconstruction
24///////////////////////////////////////////////////////////////
25
26#include <TArrayD.h>
27#include <TArrayF.h>
28#include <TStopwatch.h>
29#include <TGeoManager.h>
30#include <TGeoMatrix.h>
31#include <TGeoVolume.h>
32#include <TGeoShape.h>
33#include <TGeoBBox.h>
34#include <TGeoTrd1.h>
35#include <TGeoTrd2.h>
36#include <TGeoArb8.h>
37#include <TGeoTube.h>
38#include <TGeoCone.h>
39#include <TGeoSphere.h>
40#include <TGeoPara.h>
41#include <TGeoPgon.h>
42#include <TGeoPcon.h>
43#include <TGeoEltu.h>
44#include <TGeoHype.h>
45#include <TMath.h>
46
47#include "AliLog.h"
451f5018 48#include "AliITSUGeomTGeo.h"
49#include "AliITSUInitGeometry.h"
29998a6e 50#include <TDatime.h>
a11ef2e4 51using namespace TMath;
29998a6e 52
451f5018 53ClassImp(AliITSUInitGeometry)
29998a6e 54
55//______________________________________________________________________
451f5018 56AliITSUInitGeometry::AliITSUInitGeometry()
57: TObject()
58 ,fName(0)
59 ,fTiming(kFALSE)
60 ,fDebug(0)
61{
29998a6e 62}
29998a6e 63
29998a6e 64//______________________________________________________________________
451f5018 65AliITSgeom* AliITSUInitGeometry::CreateAliITSgeom()
66{
67 // Creates and Initilizes the geometry transformation class AliITSgeom
68 // to values appropreate to this specific geometry. Now that
69 // the segmentation is part of AliITSgeom, the detector
70 // segmentations are also defined here.
71 //
29998a6e 72
73 AliITSVersion_t version = kvDefault;
74 Int_t minor = 0;
75 TDatime datetime;
451f5018 76 TGeoVolume *itsV = gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern());
29998a6e 77 if(!itsV){
78 Error("CreateAliITSgeom","Can't find ITS volume ITSV, aborting");
79 return 0;
80 }// end if
451f5018 81
29998a6e 82 SetTiming(kFALSE);
83 SetSegGeom(kFALSE);
84 SetDecoding(kFALSE);
85 AliITSgeom *geom = CreateAliITSgeom(version,minor);
86 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
87 return geom;
88}
451f5018 89
29998a6e 90//______________________________________________________________________
451f5018 91AliITSgeom* AliITSUInitGeometry::CreateAliITSgeom(Int_t major,Int_t minor){
29998a6e 92 // Creates and Initilizes the geometry transformation class AliITSgeom
93 // to values appropreate to this specific geometry. Now that
94 // the segmentation is part of AliITSgeom, the detector
95 // segmentations are also defined here.
96 // Inputs:
97 // Int_t major major version, see AliITSVersion_t
98 // Int_t minor minor version
99 // Outputs:
100 // none.
101 // Return:
102 // A pointer to a new properly inilized AliITSgeom class. If
103 // pointer = 0 then failed to init.
104
105 switch(major){
106 case kv11:
107 SetGeometryName("AliITSv11");
108 SetVersion(kv11,minor);
109 break;
110 case kvUpgrade:
451f5018 111 SetGeometryName("AliITSUv11");
29998a6e 112 SetVersion(kvUpgrade,minor);
113 break;
114 case kvDefault:
115 default:
116 SetGeometryName("Undefined");
117 SetVersion(kvDefault,minor);
118 break;
119 } // end switch
120 AliITSgeom *geom = new AliITSgeom();
121 if(!InitAliITSgeom(geom)){ // Error initilization failed
122 delete geom;
123 geom = 0;
124 } // end if
125 return geom;
126}
127//______________________________________________________________________
451f5018 128Bool_t AliITSUInitGeometry::InitAliITSgeom(AliITSgeom *geom){
29998a6e 129 // Initilizes the geometry transformation class AliITSgeom
130 // to values appropreate to this specific geometry. Now that
131 // the segmentation is part of AliITSgeom, the detector
132 // segmentations are also defined here.
133 // Inputs:
134 // AliITSgeom *geom A pointer to the AliITSgeom class
135 // Outputs:
136 // AliITSgeom *geom This pointer recreated and properly inilized.
137 // Return:
138 // none.
139
140 if(!gGeoManager){
141 AliFatal("The geometry manager has not been initialized (e.g. "
142 "TGeoManager::Import(\"geometry.root\")should be "
143 "called in advance) - exit forced");
144 return kFALSE;
145 } // end if
146 switch(fMajorVersion) {
147 case kv11: {
148 return InitAliITSgeomV11(geom);
149 } break; // end case
150 case kvUpgrade: {
151 return InitAliITSgeomVUpgrade(geom);
152 } break; // end case
153 case kvDefault: default: {
154 AliFatal("Undefined geometry");
155 return kFALSE;
156 } break; // end case
157 } // end switch
158 return kFALSE;
159}
160//______________________________________________________________________
451f5018 161void AliITSUInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
29998a6e 162 // Transpose the rotation matrix part of a TGeoHMatrix. This
163 // is needed because TGeo stores the transpose of the rotation
164 // matrix as compared to what AliITSgeomMatrix uses (and Geant3).
165 // Inputs:
166 // TGeoHMatrix *m The matrix to be transposed
167 // Outputs:
168 // TGEoHMatrix *m The transposed matrix
169 // Return:
170 // none.
171 Int_t i;
172 Double_t r[9];
173
174 if(m==0) return; // no matrix to transpose.
175 for(i=0;i<9;i += 4) r[i] = m->GetRotationMatrix()[i]; // diagonals
176 r[1] = m->GetRotationMatrix()[3];
177 r[2] = m->GetRotationMatrix()[6];
178 r[3] = m->GetRotationMatrix()[1];
179 r[5] = m->GetRotationMatrix()[7];
180 r[6] = m->GetRotationMatrix()[2];
181 r[7] = m->GetRotationMatrix()[5];
182 m->SetRotation(r);
183 return;
184}
185
186
187//______________________________________________________________________
451f5018 188Bool_t AliITSUInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
29998a6e 189 // Initilizes the geometry transformation class AliITSgeom
190 // Now that the segmentation is part of AliITSgeom, the detector
191 // segmentations are also defined here.
192 //
193 // Inputs:
194 // AliITSgeom *geom A pointer to the AliITSgeom class
195 // Outputs:
196 // AliITSgeom *geom This pointer recreated and properly inilized.
197 // LG
198
199 const Int_t kItype = 0; // Type of transformation defined 0=> Geant
200 const Int_t klayers = 6; // number of layers in the ITS
201 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
202 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
203 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
204 const TString kPathbase = "/ALIC_1/ITSV_1/";
205
206 const char *pathSPDsens1, *pathSPDsens2;
207 pathSPDsens1="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay1-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay1-Ladder_%d/ITSSPDlay1-sensor_1";
208 pathSPDsens2="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay2-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay2-Ladder_%d/ITSSPDlay2-sensor_1";
209
210 const char *pathSDDsens1, *pathSDDsens2;
211 pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
212 pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
213
214 const char *pathSSDsens1, *pathSSDsens2;
215 pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSssdSensor5_%d/ITSssdSensitivL5_1";
216 pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSssdSensor6_%d/ITSssdSensitivL6_1";
217
218 const TString kNames[klayers] = {
219 pathSPDsens1, // lay=1
220 pathSPDsens2, // lay=2
221 pathSDDsens1, // lay=3
222 pathSDDsens2, // lay=4
223 pathSSDsens1, // lay=5
224 pathSSDsens2};// Lay=6
225
226 Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1;
227 Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
228 TArrayD shapePar;
229 TString path, shapeName;
230 TGeoHMatrix matrix;
231 Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
232 TStopwatch *time = 0x0;
233 if(fTiming) time = new TStopwatch();
234
235 if(fTiming) time->Start();
236 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
237 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
238
239 for(mod=0; mod<nmods; mod++) {
240
241 DecodeDetectorLayers(mod,lay,lad,det);
242 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
243 RecodeDetector(mod,cpn0,cpn1,cpn2);
244
245 if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
246 if (det<3) cpnHS = 0; else cpnHS = 1;
247 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2);
248 } else {
249 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2);
250 };
251
252 geom->GetGeomMatrix(mod)->SetPath(path);
253 GetTransformation(path.Data(),matrix);
254 geom->SetTrans(mod,matrix.GetTranslation());
255 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
256 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
257 if(initSeg[kIdet[lay-1]]) continue;
258 GetShape(path,shapeName,shapePar);
259 if(shapeName.CompareTo("BOX")){
260 Error("InitITSgeom","Geometry changed without proper code update"
261 "or error in reading geometry. Shape is not BOX.");
262 return kFALSE;
263 } // end if
264 } // end for module
265
266 if(fTiming){
267 time->Stop();
268 time->Print();
269 delete time;
270 } // end if
271 return kTRUE;
272}
273//______________________________________________________________________
451f5018 274Bool_t AliITSUInitGeometry::InitAliITSgeomVUpgrade(AliITSgeom *geom){
29998a6e 275 // Initilizes the geometry transformation class AliITSgeom
276 // Now that the segmentation is part of AliITSgeom, the detector
277 // segmentations are also defined here.
278 //
279 // Inputs:
280 // AliITSgeom *geom A pointer to the AliITSgeom class
281 // Outputs:
282 // AliITSgeom *geom This pointer recreated and properly inilized.
283 // LG
284
285 const Int_t kItype = 0; // Type of transformation defined 0=> Geant
286 const Int_t klayers = GetNumberOfLayers(); // Number of layers in the ITS
4cddfe15 287 const AliITSDetector kIdet = AliITSDetector(0); //kUPG; RS temporary
29998a6e 288 if (klayers <= 0) {
289 AliError("No layers found in ITSV");
290 return kFALSE;
291 }
292
293 Int_t *kladders = new Int_t[klayers]; // Number of ladders
294 Int_t *kdetectors = new Int_t[klayers]; // Number of detectors/ladder
295
296 for (Int_t j=0; j<klayers; j++) {
297 kladders[j] = GetNumberOfLadders(j);
298 kdetectors[j] = GetNumberOfModules(j);
299 }
451f5018 300 const TString kPathBase = Form("/ALIC_1/%s_1/",AliITSUGeomTGeo::GetITSVolPattern());
535d15f5 301 const TString kNames = Form("%%s%s%%d_1/%s%%d_%%d/%s%%d_%%d/%s%%d_%%d"
451f5018 302 ,AliITSUGeomTGeo::GetITSLayerPattern()
303 ,AliITSUGeomTGeo::GetITSLadderPattern()
304 ,AliITSUGeomTGeo::GetITSModulePattern()
305 ,AliITSUGeomTGeo::GetITSSensorPattern()
535d15f5 306 );
29998a6e 307 Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2;
308 Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
309 TArrayD shapePar;
310 TString path, shapeName;
311 TGeoHMatrix matrix;
e409171b 312// Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
29998a6e 313 TStopwatch *time = 0x0;
314 if(fTiming) time = new TStopwatch();
315
316 if(fTiming) time->Start();
317 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
318 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
319
320 for(mod=0; mod<nmods; mod++) {
321
322 DecodeDetectorLayers(mod,lay,lad,det);
323 geom->CreateMatrix(mod,lay,lad,det,kIdet,tran,rot);
324 RecodeDetector(mod,cpn0,cpn1,cpn2);
325
535d15f5 326 path.Form(kNames.Data(),kPathBase.Data(),lay,lay,cpn0,lay,cpn1,lay,cpn2);
29998a6e 327
328 geom->GetGeomMatrix(mod)->SetPath(path);
329 GetTransformation(path.Data(),matrix);
330 geom->SetTrans(mod,matrix.GetTranslation());
331 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
332 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
333// if(initSeg[kIdet[lay-1]]) continue;
29998a6e 334 GetShape(path,shapeName,shapePar);
335 if(shapeName.CompareTo("BOX")){
336 Error("InitITSgeom","Geometry changed without proper code update"
337 "or error in reading geometry. Shape is not BOX.");
338 return kFALSE;
339 } // end if
340 } // end for module
341
342 if(fTiming){
343 time->Stop();
344 time->Print();
345 delete time;
346 } // end if
347 return kTRUE;
348}
349
350//_______________________________________________________________________
451f5018 351Bool_t AliITSUInitGeometry::GetTransformation(const TString &volumePath,
29998a6e 352 TGeoHMatrix &mat){
353 // Returns the Transformation matrix between the volume specified
354 // by the path volumePath and the Top or mater volume. The format
355 // of the path volumePath is as follows (assuming ALIC is the Top volume)
356 // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
357 // or master volume which has only 1 instance of. Of all of the daughter
358 // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
359 // the daughter volume of DDIP is S05I copy #2 and so on.
360 // Inputs:
361 // TString& volumePath The volume path to the specific volume
362 // for which you want the matrix. Volume name
363 // hierarchy is separated by "/" while the
364 // copy number is appended using a "_".
365 // Outputs:
366 // TGeoHMatrix &mat A matrix with its values set to those
367 // appropriate to the Local to Master transformation
368 // Return:
369 // A logical value if kFALSE then an error occurred and no change to
370 // mat was made.
371
372 // We have to preserve the modeler state
373
374 // Preserve the modeler state.
375 gGeoManager->PushPath();
376 if (!gGeoManager->cd(volumePath.Data())) {
377 gGeoManager->PopPath();
378 Error("GetTransformation","Error in cd-ing to %s",volumePath.Data());
379 return kFALSE;
380 } // end if !gGeoManager
381 mat = *gGeoManager->GetCurrentMatrix();
382 // Retstore the modeler state.
383 gGeoManager->PopPath();
384 return kTRUE;
385}
386//______________________________________________________________________
451f5018 387Bool_t AliITSUInitGeometry::GetShape(const TString &volumePath,
29998a6e 388 TString &shapeType,TArrayD &par){
389 // Returns the shape and its parameters for the volume specified
390 // by volumeName.
391 // Inputs:
392 // TString& volumeName The volume name
393 // Outputs:
394 // TString &shapeType Shape type
395 // TArrayD &par A TArrayD of parameters with all of the
396 // parameters of the specified shape.
397 // Return:
398 // A logical indicating whether there was an error in getting this
399 // information
400 Int_t npar;
401 gGeoManager->PushPath();
402 if (!gGeoManager->cd(volumePath.Data())) {
403 gGeoManager->PopPath();
404 return kFALSE;
405 }
406 TGeoVolume * vol = gGeoManager->GetCurrentVolume();
407 gGeoManager->PopPath();
408 if (!vol) return kFALSE;
409 TGeoShape *shape = vol->GetShape();
410 TClass *classType = shape->IsA();
411 if (classType==TGeoBBox::Class()) {
412 shapeType = "BOX";
413 npar = 3;
414 par.Set(npar);
415 TGeoBBox *box = (TGeoBBox*)shape;
416 par.AddAt(box->GetDX(),0);
417 par.AddAt(box->GetDY(),1);
418 par.AddAt(box->GetDZ(),2);
419 return kTRUE;
420 } // end if
421 if (classType==TGeoTrd1::Class()) {
422 shapeType = "TRD1";
423 npar = 4;
424 par.Set(npar);
425 TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
426 par.AddAt(trd1->GetDx1(),0);
427 par.AddAt(trd1->GetDx2(),1);
428 par.AddAt(trd1->GetDy(), 2);
429 par.AddAt(trd1->GetDz(), 3);
430 return kTRUE;
431 } // end if
432 if (classType==TGeoTrd2::Class()) {
433 shapeType = "TRD2";
434 npar = 5;
435 par.Set(npar);
436 TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
437 par.AddAt(trd2->GetDx1(),0);
438 par.AddAt(trd2->GetDx2(),1);
439 par.AddAt(trd2->GetDy1(),2);
440 par.AddAt(trd2->GetDy2(),3);
441 par.AddAt(trd2->GetDz(), 4);
442 return kTRUE;
443 } // end if
444 if (classType==TGeoTrap::Class()) {
445 shapeType = "TRAP";
446 npar = 11;
447 par.Set(npar);
448 TGeoTrap *trap = (TGeoTrap*)shape;
a11ef2e4 449 Double_t tth = Tan(trap->GetTheta()*DegToRad());
29998a6e 450 par.AddAt(trap->GetDz(),0);
a11ef2e4 451 par.AddAt(tth*Cos(trap->GetPhi()*DegToRad()),1);
452 par.AddAt(tth*Sin(trap->GetPhi()*DegToRad()),2);
29998a6e 453 par.AddAt(trap->GetH1(),3);
454 par.AddAt(trap->GetBl1(),4);
455 par.AddAt(trap->GetTl1(),5);
a11ef2e4 456 par.AddAt(Tan(trap->GetAlpha1()*DegToRad()),6);
29998a6e 457 par.AddAt(trap->GetH2(),7);
458 par.AddAt(trap->GetBl2(),8);
459 par.AddAt(trap->GetTl2(),9);
a11ef2e4 460 par.AddAt(Tan(trap->GetAlpha2()*DegToRad()),10);
29998a6e 461 return kTRUE;
462 } // end if
463 if (classType==TGeoTube::Class()) {
464 shapeType = "TUBE";
465 npar = 3;
466 par.Set(npar);
467 TGeoTube *tube = (TGeoTube*)shape;
468 par.AddAt(tube->GetRmin(),0);
469 par.AddAt(tube->GetRmax(),1);
470 par.AddAt(tube->GetDz(),2);
471 return kTRUE;
472 } // end if
473 if (classType==TGeoTubeSeg::Class()) {
474 shapeType = "TUBS";
475 npar = 5;
476 par.Set(npar);
477 TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
478 par.AddAt(tubs->GetRmin(),0);
479 par.AddAt(tubs->GetRmax(),1);
480 par.AddAt(tubs->GetDz(),2);
481 par.AddAt(tubs->GetPhi1(),3);
482 par.AddAt(tubs->GetPhi2(),4);
483 return kTRUE;
484 } // end if
485 if (classType==TGeoCone::Class()) {
486 shapeType = "CONE";
487 npar = 5;
488 par.Set(npar);
489 TGeoCone *cone = (TGeoCone*)shape;
490 par.AddAt(cone->GetDz(),0);
491 par.AddAt(cone->GetRmin1(),1);
492 par.AddAt(cone->GetRmax1(),2);
493 par.AddAt(cone->GetRmin2(),3);
494 par.AddAt(cone->GetRmax2(),4);
495 return kTRUE;
496 } // end if
497 if (classType==TGeoConeSeg::Class()) {
498 shapeType = "CONS";
499 npar = 7;
500 par.Set(npar);
501 TGeoConeSeg *cons = (TGeoConeSeg*)shape;
502 par.AddAt(cons->GetDz(),0);
503 par.AddAt(cons->GetRmin1(),1);
504 par.AddAt(cons->GetRmax1(),2);
505 par.AddAt(cons->GetRmin2(),3);
506 par.AddAt(cons->GetRmax2(),4);
507 par.AddAt(cons->GetPhi1(),5);
508 par.AddAt(cons->GetPhi2(),6);
509 return kTRUE;
510 } // end if
511 if (classType==TGeoSphere::Class()) {
512 shapeType = "SPHE";
513 npar = 6;
514 par.Set(npar);
515
516 TGeoSphere *sphe = (TGeoSphere*)shape;
517 par.AddAt(sphe->GetRmin(),0);
518 par.AddAt(sphe->GetRmax(),1);
519 par.AddAt(sphe->GetTheta1(),2);
520 par.AddAt(sphe->GetTheta2(),3);
521 par.AddAt(sphe->GetPhi1(),4);
522 par.AddAt(sphe->GetPhi2(),5);
523 return kTRUE;
524 } // end if
525 if (classType==TGeoPara::Class()) {
526 shapeType = "PARA";
527 npar = 6;
528 par.Set(npar);
529 TGeoPara *para = (TGeoPara*)shape;
530 par.AddAt(para->GetX(),0);
531 par.AddAt(para->GetY(),1);
532 par.AddAt(para->GetZ(),2);
533 par.AddAt(para->GetTxy(),3);
534 par.AddAt(para->GetTxz(),4);
535 par.AddAt(para->GetTyz(),5);
536 return kTRUE;
537 } // end if
538 if (classType==TGeoPgon::Class()) {
539 shapeType = "PGON";
540 TGeoPgon *pgon = (TGeoPgon*)shape;
541 Int_t nz = pgon->GetNz();
542 const Double_t *rmin = pgon->GetRmin();
543 const Double_t *rmax = pgon->GetRmax();
544 const Double_t *z = pgon->GetZ();
545 npar = 4 + 3*nz;
546 par.Set(npar);
547 par.AddAt(pgon->GetPhi1(),0);
548 par.AddAt(pgon->GetDphi(),1);
549 par.AddAt(pgon->GetNedges(),2);
550 par.AddAt(pgon->GetNz(),3);
551 for (Int_t i=0; i<nz; i++) {
552 par.AddAt(z[i], 4+3*i);
553 par.AddAt(rmin[i], 4+3*i+1);
554 par.AddAt(rmax[i], 4+3*i+2);
555 }
556 return kTRUE;
557 } // end if
558 if (classType==TGeoPcon::Class()) {
559 shapeType = "PCON";
560 TGeoPcon *pcon = (TGeoPcon*)shape;
561 Int_t nz = pcon->GetNz();
562 const Double_t *rmin = pcon->GetRmin();
563 const Double_t *rmax = pcon->GetRmax();
564 const Double_t *z = pcon->GetZ();
565 npar = 3 + 3*nz;
566 par.Set(npar);
567 par.AddAt(pcon->GetPhi1(),0);
568 par.AddAt(pcon->GetDphi(),1);
569 par.AddAt(pcon->GetNz(),2);
570 for (Int_t i=0; i<nz; i++) {
571 par.AddAt(z[i], 3+3*i);
572
573 par.AddAt(rmin[i], 3+3*i+1);
574 par.AddAt(rmax[i], 3+3*i+2);
575 }
576 return kTRUE;
577 } // end if
578 if (classType==TGeoEltu::Class()) {
579 shapeType = "ELTU";
580 npar = 3;
581 par.Set(npar);
582 TGeoEltu *eltu = (TGeoEltu*)shape;
583 par.AddAt(eltu->GetA(),0);
584 par.AddAt(eltu->GetB(),1);
585 par.AddAt(eltu->GetDz(),2);
586 return kTRUE;
587 } // end if
588 if (classType==TGeoHype::Class()) {
589 shapeType = "HYPE";
590 npar = 5;
591 par.Set(npar);
592 TGeoHype *hype = (TGeoHype*)shape;
a11ef2e4 593 par.AddAt(Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
594 par.AddAt(Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
29998a6e 595 par.AddAt(hype->GetDZ(),2);
596 par.AddAt(hype->GetStIn(),3);
597 par.AddAt(hype->GetStOut(),4);
598 return kTRUE;
599 } // end if
600 if (classType==TGeoGtra::Class()) {
601 shapeType = "GTRA";
602 npar = 12;
603 par.Set(npar);
604 TGeoGtra *trap = (TGeoGtra*)shape;
a11ef2e4 605 Double_t tth = Tan(trap->GetTheta()*DegToRad());
29998a6e 606 par.AddAt(trap->GetDz(),0);
a11ef2e4 607 par.AddAt(tth*Cos(trap->GetPhi()*DegToRad()),1);
608 par.AddAt(tth*Sin(trap->GetPhi()*DegToRad()),2);
29998a6e 609 par.AddAt(trap->GetH1(),3);
610 par.AddAt(trap->GetBl1(),4);
611 par.AddAt(trap->GetTl1(),5);
a11ef2e4 612 par.AddAt(Tan(trap->GetAlpha1()*DegToRad()),6);
29998a6e 613 par.AddAt(trap->GetH2(),7);
614 par.AddAt(trap->GetBl2(),8);
615 par.AddAt(trap->GetTl2(),9);
a11ef2e4 616 par.AddAt(Tan(trap->GetAlpha2()*DegToRad()),10);
29998a6e 617 par.AddAt(trap->GetTwistAngle(),11);
618 return kTRUE;
619 } // end if
620 if (classType==TGeoCtub::Class()) {
621 shapeType = "CTUB";
622 npar = 11;
623 par.Set(npar);
624 TGeoCtub *ctub = (TGeoCtub*)shape;
625 const Double_t *lx = ctub->GetNlow();
626 const Double_t *tx = ctub->GetNhigh();
627 par.AddAt(ctub->GetRmin(),0);
628 par.AddAt(ctub->GetRmax(),1);
629 par.AddAt(ctub->GetDz(),2);
630 par.AddAt(ctub->GetPhi1(),3);
631 par.AddAt(ctub->GetPhi2(),4);
632 par.AddAt(lx[0],5);
633 par.AddAt(lx[1],6);
634 par.AddAt(lx[2],7);
635 par.AddAt(tx[0],8);
636 par.AddAt(tx[1],9);
637 par.AddAt(tx[2],10);
638 return kTRUE;
639 } // end if
640 Error("GetShape","Getting shape parameters for shape %s not implemented",
641 shape->ClassName());
642 shapeType = "Unknown";
643 return kFALSE;
644}
645//______________________________________________________________________
451f5018 646void AliITSUInitGeometry::DecodeDetector(
29998a6e 647 Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
648 // decode geometry into detector module number. There are two decoding
649 // Scheams. Old which does not follow the ALICE coordinate system
650 // requirements, and New which dose.
651 // Inputs:
652 // Int_t layer The ITS layer
653 // Int_t cpn0 The lowest copy number
654 // Int_t cpn1 The middle copy number
655 // Int_t cpn2 the highest copy number
656 // Output:
657 // Int_t &mod The module number assoicated with this set
658 // of copy numbers.
659 // Return:
660 // none.
661
662 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
663 // like them but I see not better way for the moment.
664 switch (fMajorVersion){
665 case kvDefault:{
666 Error("DecodeDetector","Major version = kvDefault, not supported");
667 }break;
668 case kv11:{
669 return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2);
670 }break;
671 case kvUpgrade:{
672 return DecodeDetectorvUpgrade(mod,layer,cpn0,cpn1,cpn2);
673 }break;
674 default:{
675 Error("DecodeDetector","Major version = %d, not supported",
676 (Int_t)fMajorVersion);
677 return;
678 }break;
679 } // end switch
680 return;
681}
682//______________________________________________________________________
451f5018 683void AliITSUInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
29998a6e 684 Int_t &cpn1,Int_t &cpn2){
685 // decode geometry into detector module number. There are two decoding
686 // Scheams. Old which does not follow the ALICE coordinate system
687 // requirements, and New which dose.
688 // Inputs:
689 // Int_t mod The module number assoicated with this set
690 // of copy numbers.
691 // Output:
692 // Int_t cpn0 The lowest copy number
693 // Int_t cpn1 The middle copy number
694 // Int_t cpn2 the highest copy number
695 // Return:
696 // none.
697
698 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
699 // like them but I see not better way for the moment.
700 switch (fMajorVersion){
701 case kvDefault:{
702 Error("RecodeDetector","Major version = kvDefault, not supported");
703 return;
704 }
705 case kv11:{
706 return RecodeDetectorv11(mod,cpn0,cpn1,cpn2);
707 }break;
708 case kvUpgrade:{
709 return RecodeDetectorvUpgrade(mod,cpn0,cpn1,cpn2);
710 }break;
711 default:{
712 Error("RecodeDetector","Major version = %d, not supported",
713 (Int_t)fMajorVersion);
714 return;
715 }break;
716 } // end switch
717 return;
718}
719//______________________________________________________________________
451f5018 720void AliITSUInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
29998a6e 721 Int_t &lad,Int_t &det){
722 // decode geometry into detector module number. There are two decoding
723 // Scheams. Old which does not follow the ALICE coordinate system
724 // requirements, and New which dose. Note, this use of layer ladder
725 // and detector numbers are strictly for internal use of this
726 // specific code. They do not represent the "standard" layer ladder
727 // or detector numbering except in a very old and obsoleate sence.
728 // Inputs:
729 // Int_t mod The module number assoicated with this set
730 // of copy numbers.
731 // Output:
732 // Int_t lay The layer number
733 // Int_t lad The ladder number
734 // Int_t det the dettector number
735 // Return:
736 // none.
737
738 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
739 // like them but I see not better way for the moment.
740 switch (fMajorVersion) {
741 case kvDefault:{
742 Error("DecodeDetectorLayers",
743 "Major version = kvDefault, not supported");
744 return;
745 }break;
746 case kv11:{
747 return DecodeDetectorLayersv11(mod,layer,lad,det);
748 }break;
749 case kvUpgrade:{
750 return DecodeDetectorLayersvUpgrade(mod,layer,lad,det);
751 }break;
752 default:{
753 Error("DecodeDetectorLayers","Major version = %d, not supported",
754 (Int_t)fMajorVersion);
755 return;
756 }break;
757 } // end switch
758 return;
759}
760
761//______________________________________________________________________
451f5018 762void AliITSUInitGeometry::DecodeDetectorv11(Int_t &mod,Int_t layer,
29998a6e 763 Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
764 // decode geometry into detector module number
765 // Inputs:
766 // Int_t layer The ITS layer
767 // Int_t cpn0 The lowest copy number
768 // Int_t cpn1 The middle copy number
769 // Int_t cpn2 the highest copy number
770 // Output:
771 // Int_t &mod The module number assoicated with this set
772 // of copy numbers.
773 // Return:
774 // none.
775 const Int_t kDetPerLadderSPD[2]={2,4};
776 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
777 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
778 Int_t lad=-1,det=-1;
779
780 switch(layer) {
781 case 1: case 2:{
782 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
783 det = cpn2;
784 } break;
785 case 3: case 4:{
786 lad = cpn0+1;
787 det = cpn1+1;
788 } break;
789 case 5: case 6:{
790 lad = cpn0+1;
791 det = cpn1+1;
792 } break;
793 default:{
794 } break;
795 } // end switch
796 mod = 0;
797 for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
798 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
799 return;
800}
801
802//______________________________________________________________________
451f5018 803void AliITSUInitGeometry::DecodeDetectorvUpgrade(Int_t &mod,Int_t layer,
e409171b 804 Int_t cpn0,Int_t cpn1,Int_t /*cpn2*/) const {
29998a6e 805 // decode geometry into detector module number
806 // Inputs:
807 // Int_t layer The ITS layer
808 // Int_t cpn0 The lowest copy number
809 // Int_t cpn1 The middle copy number
810 // Int_t cpn2 the highest copy number
811 // Output:
812 // Int_t &mod The module number assoicated with this set
813 // of copy numbers.
814 // Return:
815 // none.
816 // MS 23jun11
817 Int_t lad=-1,det=-1;
840da413 818 layer--; // starts from 1!
29998a6e 819 lad = cpn0;
820 det = cpn1;
821 mod = 0;
822 for(Int_t i=0;i<layer;i++) mod += GetNumberOfLadders(i)*GetNumberOfModules(i);
823 mod += GetNumberOfModules(layer)*(lad-1)+det-1;// module start at zero.
824 return;
825}
826
827//______________________________________________________________________
451f5018 828void AliITSUInitGeometry::RecodeDetectorv11(Int_t mod,Int_t &cpn0,
29998a6e 829 Int_t &cpn1,Int_t &cpn2) {
830 // decode geometry into detector module number using the new decoding
831 // Scheme.
832 // Inputs:
833 // Int_t mod The module number assoicated with this set
834 // of copy numbers.
835 // Output:
836 // Int_t cpn0 The lowest copy number (SPD sector or SDD/SSD ladder)
837 // Int_t cpn1 The middle copy number (SPD stave or SDD/SSD module)
838 // Int_t cpn2 the highest copy number (SPD ladder or 1 for SDD/SSD)
839 // Return:
840 // none.
841 const Int_t kDetPerLadderSPD[2]={2,4};
842 Int_t lay,lad,det;
843
844 DecodeDetectorLayersv11(mod,lay,lad,det);
845 if (lay<3) { // SPD
846 cpn2 = det; // Detector 1-4
847 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
848 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
849 } else { // SDD and SSD
850 cpn2 = 1;
851 cpn1 = det;
852 cpn0 = lad;
853 if (lay<5) { // SDD
854 cpn1--;
855 cpn0--;
856 } else { //SSD
857 cpn1--;
858 cpn0--;
859 } // end if Lay<5/else
860 } // end if lay<3/else
451f5018 861 /*printf("AliITSUInitGeometry::RecodeDetectorv11:"
29998a6e 862 "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n",
863 mod,lay,lad,det,cpn0,cpn1,cpn2);*/
864}
865
866//______________________________________________________________________
451f5018 867void AliITSUInitGeometry::RecodeDetectorvUpgrade(Int_t mod,Int_t &cpn0,
29998a6e 868 Int_t &cpn1,Int_t &cpn2) {
869 // decode geometry into detector module number using the new decoding
870 // Scheme.
871 // Inputs:
872 // Int_t mod The module number assoicated with this set
873 // of copy numbers.
874 // Output:
875 // Int_t cpn0 The lowest copy number (ladder)
876 // Int_t cpn1 The middle copy number (module)
877 // Int_t cpn2 the highest copy number (sensor - always 1 for now)
878 // Return:
879 // none.
880 // MS - 23jun11 - cross your fingers and hope for the best
881 Int_t lay,lad,det;
882
883 DecodeDetectorLayersvUpgrade(mod,lay,lad,det);
884 cpn2 = 1;
885 cpn1 = det;
886 cpn0 = lad;
887// cpn1--;
888// cpn0--;
451f5018 889 /*printf("AliITSUInitGeometry::RecodeDetectorv11:"
29998a6e 890 "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n",
891 mod,lay,lad,det,cpn0,cpn1,cpn2);*/
892}
893
894//______________________________________________________________________
451f5018 895void AliITSUInitGeometry::DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
29998a6e 896 Int_t &lad,Int_t &det) {
897
898 // decode module number into detector indices for v11
899 // mod starts from 0
900 // lay, lad, det start from 1
901
902 // Inputs:
903 // Int_t mod The module number associated with this set
904 // of copy numbers.
905 // Output:
906 // Int_t lay The layer number
907 // Int_t lad The ladder number
908 // Int_t det the dettector number
909
910 const Int_t kDetPerLadder[6] = {4,4,6,8,22,25};
911 const Int_t kLadPerLayer[6] = {20,40,14,22,34,38};
912
913 Int_t mod2 = 0;
914 lay = 0;
915
916 do {
917 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
918 lay++;
919 } while(mod2<=mod); // end while
920 if(lay>6) Error("DecodeDetectorLayers","lay=%d>6",lay);
921
922 mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod;
923 lad = mod2/kDetPerLadder[lay-1];
924
925 if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers",
926 "lad=%d not in the correct range",lad);
927 det = (mod2 - lad*kDetPerLadder[lay-1])+1;
928 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
929 "det=%d not in the correct range",det);
930 lad++;
931}
932
933//______________________________________________________________________
451f5018 934void AliITSUInitGeometry::DecodeDetectorLayersvUpgrade(Int_t mod,Int_t &lay,
29998a6e 935 Int_t &lad,Int_t &det){
936
937 // decode module number into detector indices for vUpgrade
938 // mod starts from 0
939 // lay, lad, det start from 1
940
941 // Inputs:
942 // Int_t mod The module number associated with this set
943 // of copy numbers.
944 // Output:
945 // Int_t lay The layer number
946 // Int_t lad The ladder number
947 // Int_t det the dettector number
948 // MS - 22jun11
949
950 const Int_t kLayers = GetNumberOfLayers();
951
952 Int_t mod2 = 0;
953 lay = 0;
954
955 do {
956 mod2 += GetNumberOfLadders(lay)*GetNumberOfModules(lay);
957 lay++;
958 } while(mod2<=mod); // end while
959 if(lay>kLayers) Error("DecodeDetectorLayers","lay=%d>%d",lay,kLayers);
960
961 mod2 = GetNumberOfLadders(lay-1)*GetNumberOfModules(lay-1) - mod2+mod;
962 lad = mod2/GetNumberOfModules(lay-1);
963
964 if(lad>=GetNumberOfLadders(lay-1)||lad<0) Error("DecodeDetectorLayers",
965 "lad=%d not in the correct range",lad);
966 det = (mod2 - lad*GetNumberOfModules(lay-1))+1;
967 if(det>GetNumberOfModules(lay-1)||det<1) Error("DecodeDetectorLayers",
968
969 "det=%d not in the correct range",det);
91fc36e5 970 // lay--;
29998a6e 971 lad++;
972}
973
974//______________________________________________________________________
451f5018 975Bool_t AliITSUInitGeometry::WriteVersionString(Char_t *str,Int_t length,
29998a6e 976 AliITSVersion_t maj,Int_t min,
977 const Char_t *cvsDate,const Char_t *cvsRevision)const{
978 // fills the string str with the major and minor version number
979 // Inputs:
980 // Char_t *str The character string to hold the major
981 // and minor version numbers in
982 // Int_t length The maximum number of characters which
983 // can be accomidated by this string.
984 // str[length-1] must exist and will be set to zero
985 // AliITSVersion_t maj The major number
986 // Int_t min The minor number
987 // Char_t *cvsDate The date string from cvs
988 // Char_t *cvsRevision The Revision string from cvs
989 // Outputs:
990 // Char_t *str The character string holding the major and minor
991 // version numbers. str[length-1] must exist
992 // and will be set to zero
993 // Return:
994 // kTRUE if no errors
995 Char_t cvslikedate[30];
996 Int_t i,n,cvsDateLength,cvsRevisionLength;
997
998 cvsDateLength = (Int_t)strlen(cvsDate);
999 if(cvsDateLength>30){ // svn string, make a cvs like string
1000 i=0;n=0;
1001 do{
1002 cvslikedate[i] = cvsDate[i];
1003 if(cvsDate[i]=='+' || cvsDate[i++]=='-'){
1004 n++; // count number of -
1005 cvslikedate[i-1] = '/'; // replace -'s by /'s.
1006 } // end if
1007 } while(n<3&&i<30); // once additonal - of time zone reach exit
1008 cvslikedate[i-1] = '$'; // put $ at end then zero.
1009 for(;i<30;i++) cvslikedate[i]=0;// i starts wher do loop left off.
1010 }else{
1011 for(i=0;i<cvsDateLength&&i<30;i++) cvslikedate[i]=cvsDate[i];
1012 }// end if
1013 cvsDateLength = (Int_t)strlen(cvslikedate);
1014 cvsRevisionLength = (Int_t)strlen(cvsRevision);
1015 i = (Int_t)maj;
a11ef2e4 1016 n = 50+(Int_t)(Log10(Abs((Double_t)i)))+1+
1017 (Int_t)(Log10(Abs((Double_t)min)))+1
29998a6e 1018 +cvsDateLength-6+cvsRevisionLength-10;
451f5018 1019 if(GetDebug()>1) printf("AliITSUInitGeometry::WriteVersionString:"
29998a6e 1020 "length=%d major=%d minor=%d cvsDate=%s[%d] "
1021 "cvsRevision=%s[%d] n=%d\n",length,i,min,cvslikedate,
1022 cvsDateLength,cvsRevision,cvsRevisionLength,n);
1023 if(i<0) n++;
1024 if(min<0) n++;
1025 if(length<n){// not enough space to write in output string.
1026 Warning("WriteVersionString","Output string not long enough "
1027 "lenght=%d must be at least %d long\n",length,n);
1028 return kFALSE;
1029 } // end if length<n
1030 char *cvsrevision = new char[cvsRevisionLength-10];
1031 char *cvsdate = new char[cvsDateLength-6];
1032 for(i=0;i<cvsRevisionLength-10;i++)
1033 if(10+i<cvsRevisionLength-1)
1034 cvsrevision[i] = cvsRevision[10+i]; else cvsrevision[i] = 0;
1035 for(i=0;i<cvsDateLength-6;i++) if(6+i<cvsDateLength-1)
1036 cvsdate[i] = cvslikedate[6+i]; else cvsdate[i] = 0;
1037 for(i=0;i<length;i++) str[i] = 0; // zero it out for now.
1038 i = (Int_t)maj;
1039 snprintf(str,length-1,"Major Version= %d Minor Version= %d Revision: %s Date: %s",i,min,cvsrevision,cvsdate);
1040 /* this gives compilation warnings on some compilers: descriptor zu
451f5018 1041 if(GetDebug()>1)printf("AliITSUInitGeometry::WriteVersionString: "
29998a6e 1042 "n=%d str=%s revision[%zu] date[%zu]\n",
1043 n,str,strlen(cvsrevision),strlen(cvsdate));
1044 */
1045 delete[] cvsrevision;
1046 delete[] cvsdate;
1047 return kTRUE;
1048}
1049//______________________________________________________________________
451f5018 1050Bool_t AliITSUInitGeometry::ReadVersionString(const Char_t *str,Int_t length,
29998a6e 1051 AliITSVersion_t &maj,Int_t &min,
1052 TDatime &dt)const{
1053 // fills the string str with the major and minor version number
1054 // Inputs:
1055 // Char_t *str The character string to holding the major and minor
1056 // version numbers in
1057 // Int_t length The maximum number of characters which can be
1058 // accomidated by this string. str[length-1] must exist
1059 // Outputs:
1060 // Char_t *str The character string holding the major and minor
1061 // version numbers unchanged. str[length-1] must exist.
1062 // AliITSVersion_t maj The major number
1063 // Int_t min The minor number
1064 // TDatime dt The date and time of the cvs commit
1065 // Return:
1066 // kTRUE if no errors
1067 Bool_t ok;
1068 Char_t cvsRevision[10],cvsDate[11],cvsTime[9];
1069 Int_t i,m,n=strlen(str),year,month,day,hours,minuits,seconds;
1070 memset(cvsRevision,0,10*sizeof(Char_t));
1071 memset(cvsDate,0,11*sizeof(Char_t));
1072 memset(cvsTime,0,9*sizeof(Char_t));
1073
451f5018 1074 if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString:"
29998a6e 1075 "str=%s length=%d\n",
1076 str,length);
1077 if(n<35) return kFALSE; // not enough space for numbers
1078 m = sscanf(str,"Major Version= %d Minor Version= %d Revision: %9s "
1079 "Date: %10s %8s",&i,&min,cvsRevision,cvsDate,cvsTime);
1080 ok = m==5;
1081 if(!ok) return !ok;
1082 m = sscanf(cvsDate,"%d/%d/%d",&year,&month,&day);
1083 ok = m==3;
1084 if(!ok) return !ok;
1085 m = sscanf(cvsTime,"%d:%d:%d",&hours,&minuits,&seconds);
1086 ok = m==3;
1087 if(!ok) return !ok;
1088 dt.Set(year,month,day,hours,minuits,seconds);
451f5018 1089 if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString: i=%d "
29998a6e 1090 "min=%d cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
1091 i,min,cvsRevision,cvsDate,cvsTime,m);
451f5018 1092 if(GetDebug()>1)printf("AliITSUInitGeometry::ReadVersionString: year=%d"
29998a6e 1093 " month=%d day=%d hours=%d minuits=%d seconds=%d\n",
1094 year,month,day,hours,minuits,seconds);
1095 switch (i){
1096 case kv11:{
1097 maj = kv11;
1098 } break;
1099 case kvUpgrade:{
1100 maj = kvUpgrade;
1101 } break;
1102 default:{
1103 maj = kvDefault;
1104 } break;
1105 } // end switch
1106 return ok;
1107}
1108//______________________________________________________________________
451f5018 1109Int_t AliITSUInitGeometry::GetNumberOfLayers(){
29998a6e 1110 // Determines the number of layers in the Upgrade Geometry
1111 //
1112 // Inputs:
1113 // none
1114 // Outputs:
1115 // none
1116 // Return:
1117 // the number of layers in the current geometry
1118 // -1 if not Upgrade Geometry
1119 // MS
1120
1121 Int_t numberOfLayers = 0;
1122
1123 if (fMajorVersion != kvUpgrade) {
1124 AliError("Not Upgrade Geometry!");
1125 return -1;
1126 }
1127
1128 // This checks should be redundant, but let's do things neatly
1129 if (!gGeoManager) {
1130 AliError("gGeoManager is null");
1131 return 0;
1132 }
1133
451f5018 1134 if (!gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())) {
1135 AliError(Form("can't find %s volume",AliITSUGeomTGeo::GetITSVolPattern()));
29998a6e 1136 return 0;
1137 }
1138
1139 // Loop on all ITSV nodes, count Layer volumes by checking names
451f5018 1140 Int_t nNodes = gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())->GetNodes()->GetEntries();
29998a6e 1141
1142 if (nNodes == 0)
1143 return 0;
1144
1145 for (Int_t j=0; j<nNodes; j++)
451f5018 1146 if (strstr(gGeoManager->GetVolume(AliITSUGeomTGeo::GetITSVolPattern())->GetNodes()->At(j)->GetName(),
1147 AliITSUGeomTGeo::GetITSLayerPattern()))
29998a6e 1148 numberOfLayers++;
1149
1150
1151 return numberOfLayers;
1152}
535d15f5 1153
29998a6e 1154//______________________________________________________________________
451f5018 1155Int_t AliITSUInitGeometry::GetNumberOfLadders(const Int_t lay) const {
29998a6e 1156 // Determines the number of layers in the Upgrade Geometry
1157 //
1158 // Inputs:
1159 // lay: layer number
1160 // Outputs:
1161 // none
1162 // Return:
1163 // the number of ladders in layer lay
1164 // -1 if not Upgrade Geometry
1165 // MS
1166
1167 Int_t numberOfLadders = 0;
1168
1169 if (fMajorVersion != kvUpgrade) {
1170 AliError("Not Upgrade Geometry!");
1171 return -1;
1172 }
1173
1174 // This checks should be redundant, but let's do things neatly
1175 if (!gGeoManager) {
1176 AliError("gGeoManager is null");
1177 return 0;
1178 }
1179
1180 char laynam[15];
451f5018 1181 snprintf(laynam, 15, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),lay+1);
29998a6e 1182 if (!gGeoManager->GetVolume(laynam)) {
1183 AliError(Form("can't find %s volume",laynam));
1184 return 0;
1185 }
1186
1187 // Loop on all layer nodes, count Ladder volumes by checking names
1188 Int_t nNodes = gGeoManager->GetVolume(laynam)->GetNodes()->GetEntries();
1189
1190 if (nNodes == 0)
1191 return 0;
1192
1193 for (Int_t j=0; j<nNodes; j++)
1194 if (strstr(gGeoManager->GetVolume(laynam)->GetNodes()->At(j)->GetName(),
451f5018 1195 AliITSUGeomTGeo::GetITSLadderPattern()))
29998a6e 1196 numberOfLadders++;
1197
1198
1199 return numberOfLadders;
1200}
535d15f5 1201
1202//______________________________________________________________________
451f5018 1203Int_t AliITSUInitGeometry::GetLayerDetTypeID(const Int_t lay) const
535d15f5 1204{
1205 // Determines the layers det. type in the Upgrade Geometry
1206 //
1207 // Inputs:
1208 // lay: layer number
1209 // Outputs:
1210 // none
1211 // Return:
1212 // det id
1213 // -1 if not Upgrade Geometry
1214 // MS
1215
1216 if (fMajorVersion != kvUpgrade) {
1217 AliError("Not Upgrade Geometry!");
1218 return -1;
1219 }
1220
1221 // This checks should be redundant, but let's do things neatly
1222 if (!gGeoManager) {
1223 AliError("gGeoManager is null");
1224 return 0;
1225 }
1226
1227 char laynam[15];
451f5018 1228 snprintf(laynam, 15, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),lay+1);
535d15f5 1229 TGeoVolume* volLr = gGeoManager->GetVolume(laynam);
1230 if (!volLr) {
1231 AliError(Form("can't find %s volume",laynam));
1232 return -1;
1233 }
1234 //
1235 return volLr->GetUniqueID();
1236 //
1237}
1238
29998a6e 1239//______________________________________________________________________
451f5018 1240Int_t AliITSUInitGeometry::GetNumberOfModules(const Int_t lay) const {
29998a6e 1241 // Determines the number of layers in the Upgrade Geometry
1242 //
1243 // Inputs:
1244 // lay: layer number
1245 // Outputs:
1246 // none
1247 // Return:
1248 // the number of modules per ladder in layer lay
1249 // -1 if not Upgrade Geometry
1250 // MS
1251
1252 Int_t numberOfModules = 0;
1253
1254 if (fMajorVersion != kvUpgrade) {
1255 AliError("Not Upgrade Geometry!");
1256 return -1;
1257 }
1258
1259 // This checks should be redundant, but let's do things neatly
1260 if (!gGeoManager) {
1261 AliError("gGeoManager is null");
1262 return 0;
1263 }
1264
1265 char laddnam[15];
451f5018 1266 snprintf(laddnam, 15, "%s%d", AliITSUGeomTGeo::GetITSLadderPattern(),lay+1);
29998a6e 1267 if (!gGeoManager->GetVolume(laddnam)) {
1268 AliError(Form("can't find %s volume",laddnam));
1269 return 0;
1270 }
1271
1272 // Loop on all ladder nodes, count Module volumes by checking names
1273 Int_t nNodes = gGeoManager->GetVolume(laddnam)->GetNodes()->GetEntries();
1274
1275 if (nNodes == 0)
1276 return 0;
1277
1278 for (Int_t j=0; j<nNodes; j++)
1279 if (strstr(gGeoManager->GetVolume(laddnam)->GetNodes()->At(j)->GetName(),
451f5018 1280 AliITSUGeomTGeo::GetITSModulePattern()))
29998a6e 1281 numberOfModules++;
1282
1283
1284 return numberOfModules;
1285}