1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 ///////////////////////////////////////////////////////////////
28 #include <TStopwatch.h>
29 #include <TGeoManager.h>
30 #include <TGeoMatrix.h>
31 #include <TGeoVolume.h>
32 #include <TGeoShape.h>
39 #include <TGeoSphere.h>
48 #include "AliITSsegmentationSPD.h"
49 #include "AliITSsegmentationSDD.h"
50 #include "AliITSsegmentationSSD.h"
51 #include "AliITSInitGeometry.h"
54 ClassImp(AliITSInitGeometry)
56 const Bool_t AliITSInitGeometry::fgkOldSPDbarrel = kFALSE;
57 const Bool_t AliITSInitGeometry::fgkOldSDDbarrel = kFALSE;
58 const Bool_t AliITSInitGeometry::fgkOldSSDbarrel = kFALSE;
59 const Bool_t AliITSInitGeometry::fgkOldSDDcone = kFALSE;
60 const Bool_t AliITSInitGeometry::fgkOldSSDcone = kFALSE;
61 const Bool_t AliITSInitGeometry::fgkOldSPDshield = kFALSE;
62 const Bool_t AliITSInitGeometry::fgkOldSDDshield = kTRUE;
63 const Bool_t AliITSInitGeometry::fgkOldSSDshield = kTRUE;
64 const Bool_t AliITSInitGeometry::fgkOldServices = kFALSE;
65 const Bool_t AliITSInitGeometry::fgkOldSupports = kFALSE;
66 //______________________________________________________________________
67 AliITSInitGeometry::AliITSInitGeometry():
68 TObject(), // Base Class
69 fName(0), // Geometry name
70 fMinorVersion(-1), // Minor version number/type
71 fMajorVersion(kvDefault), // Major versin number
72 fTiming(kFALSE), // Flag to start inilization timing
73 fSegGeom(kFALSE), // Flag to switch between the old use of
74 // AliITSgeomS?D class, or AliITSsegmentation
75 // class in fShape of AliITSgeom class.
76 fDecode(kFALSE), // Flag for new/old decoding
77 fDebug(0){ // Debug flag
84 // A default inilized AliITSInitGeometry object
88 //______________________________________________________________________
89 AliITSInitGeometry::AliITSInitGeometry(AliITSVersion_t version,
91 TObject(), // Base Class
92 fName(0), // Geometry name
93 fMinorVersion(minorversion), // Minor version number/type
94 fMajorVersion(version), // Major versin number
95 fTiming(kFALSE), // Flag to start inilization timing
96 fSegGeom(kFALSE), // Flag to switch between the old use of
97 // AliITSgeomS?D class, or AliITSsegmentation
98 // class in fShape of AliITSgeom class.
99 fDecode(kFALSE), // Flag for new/old decoding
100 fDebug(0){ // Debug flag
107 // A default inilized AliITSInitGeometry object
109 if(version == kv11Hybrid){
110 fName="AliITSv11Hybrid";
112 AliFatal(Form("Undefined geometry: fMajorVersion=%d, "
113 "fMinorVersion= %d",(Int_t)fMajorVersion,fMinorVersion));
118 //______________________________________________________________________
119 AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(){
120 // Creates and Initilizes the geometry transformation class AliITSgeom
121 // to values appropreate to this specific geometry. Now that
122 // the segmentation is part of AliITSgeom, the detector
123 // segmentations are also defined here.
129 // A pointer to a new properly inilized AliITSgeom class. If
130 // pointer = 0 then failed to init.
133 AliITSVersion_t version = kvDefault;
136 TGeoVolume *itsV = gGeoManager->GetVolume("ITSV");
138 Error("CreateAliITSgeom","Can't find ITS volume ITSV, aborting");
141 const Char_t *title = itsV->GetTitle();
142 if(!ReadVersionString(title,(Int_t)strlen(title),version,minor,
144 Warning("UpdateInternalGeometry","Can't read title=%s\n",title);
148 AliITSgeom *geom = CreateAliITSgeom(version,minor);
149 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
152 //______________________________________________________________________
153 AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(Int_t major,Int_t minor){
154 // Creates and Initilizes the geometry transformation class AliITSgeom
155 // to values appropreate to this specific geometry. Now that
156 // the segmentation is part of AliITSgeom, the detector
157 // segmentations are also defined here.
159 // Int_t major major version, see AliITSVersion_t
160 // Int_t minor minor version
164 // A pointer to a new properly inilized AliITSgeom class. If
165 // pointer = 0 then failed to init.
169 SetGeometryName("AliITSv11");
170 SetVersion(kv11,minor);
173 SetGeometryName("AliITSv11Hybrid");
174 SetVersion(kv11Hybrid,minor);
178 SetGeometryName("Undefined");
179 SetVersion(kvDefault,minor);
182 AliITSgeom *geom = new AliITSgeom();
183 if(!InitAliITSgeom(geom)){ // Error initilization failed
189 //______________________________________________________________________
190 Bool_t AliITSInitGeometry::InitAliITSgeom(AliITSgeom *geom){
191 // Initilizes the geometry transformation class AliITSgeom
192 // to values appropreate to this specific geometry. Now that
193 // the segmentation is part of AliITSgeom, the detector
194 // segmentations are also defined here.
196 // AliITSgeom *geom A pointer to the AliITSgeom class
198 // AliITSgeom *geom This pointer recreated and properly inilized.
203 AliFatal("The geometry manager has not been initialized (e.g. "
204 "TGeoManager::Import(\"geometry.root\")should be "
205 "called in advance) - exit forced");
208 switch(fMajorVersion) {
210 return InitAliITSgeomV11Hybrid(geom);
213 return InitAliITSgeomV11(geom);
215 case kvDefault: default: {
216 AliFatal("Undefined geometry");
222 //______________________________________________________________________
223 void AliITSInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
224 // Transpose the rotation matrix part of a TGeoHMatrix. This
225 // is needed because TGeo stores the transpose of the rotation
226 // matrix as compared to what AliITSgeomMatrix uses (and Geant3).
228 // TGeoHMatrix *m The matrix to be transposed
230 // TGEoHMatrix *m The transposed matrix
236 if(m==0) return; // no matrix to transpose.
237 for(i=0;i<9;i += 4) r[i] = m->GetRotationMatrix()[i]; // diagonals
238 r[1] = m->GetRotationMatrix()[3];
239 r[2] = m->GetRotationMatrix()[6];
240 r[3] = m->GetRotationMatrix()[1];
241 r[5] = m->GetRotationMatrix()[7];
242 r[6] = m->GetRotationMatrix()[2];
243 r[7] = m->GetRotationMatrix()[5];
249 //______________________________________________________________________
250 Bool_t AliITSInitGeometry::InitAliITSgeomV11Hybrid(AliITSgeom *geom){
251 // Initilizes the geometry transformation class AliITSgeom
252 // to values appropreate to this specific geometry. Now that
253 // the segmentation is part of AliITSgeom, the detector
254 // segmentations are also defined here.
256 // AliITSgeom *geom A pointer to the AliITSgeom class
258 // AliITSgeom *geom This pointer recreated and properly inilized.
262 const Int_t kItype = 0; // Type of transformation defined 0=> Geant
263 const Int_t klayers = 6; // number of layers in the ITS
264 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
265 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
266 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
267 const TString kPathbase = "/ALIC_1/ITSV_1/";
269 const char *pathSPDsens1, *pathSPDsens2;
270 if (SPDIsTGeoNative()) {
271 pathSPDsens1="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay1-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay1-Ladder_%d/ITSSPDlay1-sensor_1";
272 pathSPDsens2="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay2-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay2-Ladder_%d/ITSSPDlay2-sensor_1";
274 pathSPDsens1 = "%sITSD_1/IT12_1/I12B_%d/I10B_%d/L1H-STAVE%d_1/I107_%d/I101_1/ITS1_1";
275 pathSPDsens2 = "%sITSD_1/IT12_1/I12B_%d/I20B_%d/L2H-STAVE%d_1/I1D7_%d/I1D1_1/ITS2_1";
278 const char *pathSDDsens1, *pathSDDsens2;
279 if (SDDIsTGeoNative()) {
280 pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
281 pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
283 pathSDDsens1 = "%sITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d";
284 pathSDDsens2 = "%sITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d";
287 const char *pathSSDsens1, *pathSSDsens2;
288 if (SSDIsTGeoNative()) {
289 pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSssdSensor5_%d/ITSssdSensitivL5_1";
290 pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSssdSensor6_%d/ITSssdSensitivL6_1";
292 pathSSDsens1 = "%sITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d";
293 pathSSDsens2 = "%sITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d";
296 const TString kNames[klayers] = {
297 pathSPDsens1, // lay=1
298 pathSPDsens2, // lay=2
299 pathSDDsens1, // lay=3
300 pathSDDsens2, // lay=4
301 pathSSDsens1, // lay=5
302 pathSSDsens2};// Lay=6
304 Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1;
305 Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
307 TString path, shapeName;
309 Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
310 TStopwatch *time = 0x0;
311 if(fTiming) time = new TStopwatch();
313 if(fTiming) time->Start();
314 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
315 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
317 for(mod=0; mod<nmods; mod++) {
319 DecodeDetectorLayers(mod,lay,lad,det);
320 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
321 RecodeDetectorv11Hybrid(mod,cpn0,cpn1,cpn2);
323 // if (SPDIsTGeoNative())
324 // if (kIdet[lay-1]==kSPD) {
329 // if (SDDIsTGeoNative())
330 // if (kIdet[lay-1]==kSDD) {
335 // if (SSDIsTGeoNative())
336 // if (kIdet[lay-1]==kSSD) {
342 if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
343 if (det<3) cpnHS = 0; else cpnHS = 1;
344 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2);
346 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2);
349 geom->GetGeomMatrix(mod)->SetPath(path);
350 GetTransformation(path.Data(),matrix);
351 geom->SetTrans(mod,matrix.GetTranslation());
352 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
353 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
354 if(initSeg[kIdet[lay-1]]) continue;
355 GetShape(path,shapeName,shapePar);
356 if(shapeName.CompareTo("BOX")){
357 Error("InitITSgeom","Geometry changed without proper code update"
358 "or error in reading geometry. Shape is not BOX.");
370 //______________________________________________________________________
371 Bool_t AliITSInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
372 // Initilizes the geometry transformation class AliITSgeom
373 // Now that the segmentation is part of AliITSgeom, the detector
374 // segmentations are also defined here.
377 // AliITSgeom *geom A pointer to the AliITSgeom class
379 // AliITSgeom *geom This pointer recreated and properly inilized.
383 const Int_t kItype=0; // Type of transormation defined 0=> Geant
384 const Int_t klayers = 6; // number of layers in the ITS
385 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
386 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
387 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
389 const TString kPathbase = "/ALIC_1/ITSV_1/";
390 const TString kNames[klayers] =
391 {"AliITSInitGeometry:spd missing", // lay=1
392 "AliITSInitGeometry:spd missing", // lay=2
393 "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_1/ITSsddSensitiv_1", // lay=3
394 "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_1/ITSsddSensitiv_1", // lay=4
395 "AliITSInitGeometry:ssd missing", // lay=5
396 "AliITSInitGeometry:ssd missing"};// lay=6
398 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2;
399 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
401 TString path,shapeName;
403 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
404 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
406 if(fTiming) time->Start();
407 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
409 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
410 for(mod=0;mod<nmods;mod++) {
412 DecodeDetectorLayers(mod,lay,lad,det); // Write
413 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
414 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
415 path.Form(kNames[lay-1].Data(),
416 kPathbase.Data(),cpn0,cpn1,cpn2);
417 geom->GetGeomMatrix(mod)->SetPath(path);
418 if (GetTransformation(path.Data(),matrix)) {
419 geom->SetTrans(mod,matrix.GetTranslation());
420 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
421 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
424 if(initSeg[kIdet[lay-1]]) continue;
425 GetShape(path,shapeName,shapePar);
426 if(shapeName.CompareTo("BOX")){
427 Error("InitAliITSgeomV11","Geometry changed without proper code update"
428 "or error in reading geometry. Shape is not BOX.");
442 //_______________________________________________________________________
443 Bool_t AliITSInitGeometry::GetTransformation(const TString &volumePath,
445 // Returns the Transformation matrix between the volume specified
446 // by the path volumePath and the Top or mater volume. The format
447 // of the path volumePath is as follows (assuming ALIC is the Top volume)
448 // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
449 // or master volume which has only 1 instance of. Of all of the daughter
450 // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
451 // the daughter volume of DDIP is S05I copy #2 and so on.
453 // TString& volumePath The volume path to the specific volume
454 // for which you want the matrix. Volume name
455 // hierarchy is separated by "/" while the
456 // copy number is appended using a "_".
458 // TGeoHMatrix &mat A matrix with its values set to those
459 // appropriate to the Local to Master transformation
461 // A logical value if kFALSE then an error occurred and no change to
464 // We have to preserve the modeler state
466 // Preserve the modeler state.
467 gGeoManager->PushPath();
468 if (!gGeoManager->cd(volumePath.Data())) {
469 gGeoManager->PopPath();
470 Error("GetTransformation","Error in cd-ing to %s",volumePath.Data());
472 } // end if !gGeoManager
473 mat = *gGeoManager->GetCurrentMatrix();
474 // Retstore the modeler state.
475 gGeoManager->PopPath();
478 //______________________________________________________________________
479 Bool_t AliITSInitGeometry::GetShape(const TString &volumePath,
480 TString &shapeType,TArrayD &par){
481 // Returns the shape and its parameters for the volume specified
484 // TString& volumeName The volume name
486 // TString &shapeType Shape type
487 // TArrayD &par A TArrayD of parameters with all of the
488 // parameters of the specified shape.
490 // A logical indicating whether there was an error in getting this
493 gGeoManager->PushPath();
494 if (!gGeoManager->cd(volumePath.Data())) {
495 gGeoManager->PopPath();
498 TGeoVolume * vol = gGeoManager->GetCurrentVolume();
499 gGeoManager->PopPath();
500 if (!vol) return kFALSE;
501 TGeoShape *shape = vol->GetShape();
502 TClass *classType = shape->IsA();
503 if (classType==TGeoBBox::Class()) {
507 TGeoBBox *box = (TGeoBBox*)shape;
508 par.AddAt(box->GetDX(),0);
509 par.AddAt(box->GetDY(),1);
510 par.AddAt(box->GetDZ(),2);
513 if (classType==TGeoTrd1::Class()) {
517 TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
518 par.AddAt(trd1->GetDx1(),0);
519 par.AddAt(trd1->GetDx2(),1);
520 par.AddAt(trd1->GetDy(), 2);
521 par.AddAt(trd1->GetDz(), 3);
524 if (classType==TGeoTrd2::Class()) {
528 TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
529 par.AddAt(trd2->GetDx1(),0);
530 par.AddAt(trd2->GetDx2(),1);
531 par.AddAt(trd2->GetDy1(),2);
532 par.AddAt(trd2->GetDy2(),3);
533 par.AddAt(trd2->GetDz(), 4);
536 if (classType==TGeoTrap::Class()) {
540 TGeoTrap *trap = (TGeoTrap*)shape;
541 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
542 par.AddAt(trap->GetDz(),0);
543 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
544 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
545 par.AddAt(trap->GetH1(),3);
546 par.AddAt(trap->GetBl1(),4);
547 par.AddAt(trap->GetTl1(),5);
548 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
549 par.AddAt(trap->GetH2(),7);
550 par.AddAt(trap->GetBl2(),8);
551 par.AddAt(trap->GetTl2(),9);
552 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
555 if (classType==TGeoTube::Class()) {
559 TGeoTube *tube = (TGeoTube*)shape;
560 par.AddAt(tube->GetRmin(),0);
561 par.AddAt(tube->GetRmax(),1);
562 par.AddAt(tube->GetDz(),2);
565 if (classType==TGeoTubeSeg::Class()) {
569 TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
570 par.AddAt(tubs->GetRmin(),0);
571 par.AddAt(tubs->GetRmax(),1);
572 par.AddAt(tubs->GetDz(),2);
573 par.AddAt(tubs->GetPhi1(),3);
574 par.AddAt(tubs->GetPhi2(),4);
577 if (classType==TGeoCone::Class()) {
581 TGeoCone *cone = (TGeoCone*)shape;
582 par.AddAt(cone->GetDz(),0);
583 par.AddAt(cone->GetRmin1(),1);
584 par.AddAt(cone->GetRmax1(),2);
585 par.AddAt(cone->GetRmin2(),3);
586 par.AddAt(cone->GetRmax2(),4);
589 if (classType==TGeoConeSeg::Class()) {
593 TGeoConeSeg *cons = (TGeoConeSeg*)shape;
594 par.AddAt(cons->GetDz(),0);
595 par.AddAt(cons->GetRmin1(),1);
596 par.AddAt(cons->GetRmax1(),2);
597 par.AddAt(cons->GetRmin2(),3);
598 par.AddAt(cons->GetRmax2(),4);
599 par.AddAt(cons->GetPhi1(),5);
600 par.AddAt(cons->GetPhi2(),6);
603 if (classType==TGeoSphere::Class()) {
608 TGeoSphere *sphe = (TGeoSphere*)shape;
609 par.AddAt(sphe->GetRmin(),0);
610 par.AddAt(sphe->GetRmax(),1);
611 par.AddAt(sphe->GetTheta1(),2);
612 par.AddAt(sphe->GetTheta2(),3);
613 par.AddAt(sphe->GetPhi1(),4);
614 par.AddAt(sphe->GetPhi2(),5);
617 if (classType==TGeoPara::Class()) {
621 TGeoPara *para = (TGeoPara*)shape;
622 par.AddAt(para->GetX(),0);
623 par.AddAt(para->GetY(),1);
624 par.AddAt(para->GetZ(),2);
625 par.AddAt(para->GetTxy(),3);
626 par.AddAt(para->GetTxz(),4);
627 par.AddAt(para->GetTyz(),5);
630 if (classType==TGeoPgon::Class()) {
632 TGeoPgon *pgon = (TGeoPgon*)shape;
633 Int_t nz = pgon->GetNz();
634 const Double_t *rmin = pgon->GetRmin();
635 const Double_t *rmax = pgon->GetRmax();
636 const Double_t *z = pgon->GetZ();
639 par.AddAt(pgon->GetPhi1(),0);
640 par.AddAt(pgon->GetDphi(),1);
641 par.AddAt(pgon->GetNedges(),2);
642 par.AddAt(pgon->GetNz(),3);
643 for (Int_t i=0; i<nz; i++) {
644 par.AddAt(z[i], 4+3*i);
645 par.AddAt(rmin[i], 4+3*i+1);
646 par.AddAt(rmax[i], 4+3*i+2);
650 if (classType==TGeoPcon::Class()) {
652 TGeoPcon *pcon = (TGeoPcon*)shape;
653 Int_t nz = pcon->GetNz();
654 const Double_t *rmin = pcon->GetRmin();
655 const Double_t *rmax = pcon->GetRmax();
656 const Double_t *z = pcon->GetZ();
659 par.AddAt(pcon->GetPhi1(),0);
660 par.AddAt(pcon->GetDphi(),1);
661 par.AddAt(pcon->GetNz(),2);
662 for (Int_t i=0; i<nz; i++) {
663 par.AddAt(z[i], 3+3*i);
665 par.AddAt(rmin[i], 3+3*i+1);
666 par.AddAt(rmax[i], 3+3*i+2);
670 if (classType==TGeoEltu::Class()) {
674 TGeoEltu *eltu = (TGeoEltu*)shape;
675 par.AddAt(eltu->GetA(),0);
676 par.AddAt(eltu->GetB(),1);
677 par.AddAt(eltu->GetDz(),2);
680 if (classType==TGeoHype::Class()) {
684 TGeoHype *hype = (TGeoHype*)shape;
685 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
686 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
687 par.AddAt(hype->GetDZ(),2);
688 par.AddAt(hype->GetStIn(),3);
689 par.AddAt(hype->GetStOut(),4);
692 if (classType==TGeoGtra::Class()) {
696 TGeoGtra *trap = (TGeoGtra*)shape;
697 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
698 par.AddAt(trap->GetDz(),0);
699 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
700 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
701 par.AddAt(trap->GetH1(),3);
702 par.AddAt(trap->GetBl1(),4);
703 par.AddAt(trap->GetTl1(),5);
704 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
705 par.AddAt(trap->GetH2(),7);
706 par.AddAt(trap->GetBl2(),8);
707 par.AddAt(trap->GetTl2(),9);
708 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
709 par.AddAt(trap->GetTwistAngle(),11);
712 if (classType==TGeoCtub::Class()) {
716 TGeoCtub *ctub = (TGeoCtub*)shape;
717 const Double_t *lx = ctub->GetNlow();
718 const Double_t *tx = ctub->GetNhigh();
719 par.AddAt(ctub->GetRmin(),0);
720 par.AddAt(ctub->GetRmax(),1);
721 par.AddAt(ctub->GetDz(),2);
722 par.AddAt(ctub->GetPhi1(),3);
723 par.AddAt(ctub->GetPhi2(),4);
732 Error("GetShape","Getting shape parameters for shape %s not implemented",
734 shapeType = "Unknown";
737 //______________________________________________________________________
738 void AliITSInitGeometry::DecodeDetector(
739 Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
740 // decode geometry into detector module number. There are two decoding
741 // Scheams. Old which does not follow the ALICE coordinate system
742 // requirements, and New which dose.
744 // Int_t layer The ITS layer
745 // Int_t cpn0 The lowest copy number
746 // Int_t cpn1 The middle copy number
747 // Int_t cpn2 the highest copy number
749 // Int_t &mod The module number assoicated with this set
754 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
755 // like them but I see not better way for the moment.
756 switch (fMajorVersion){
758 Error("DecodeDetector","Major version = kvDefault, not supported");
761 return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2);
764 return DecodeDetectorv11Hybrid(mod,layer,cpn0,cpn1,cpn2);
767 Error("DecodeDetector","Major version = %d, not supported",
768 (Int_t)fMajorVersion);
774 //______________________________________________________________________
775 void AliITSInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
776 Int_t &cpn1,Int_t &cpn2){
777 // decode geometry into detector module number. There are two decoding
778 // Scheams. Old which does not follow the ALICE coordinate system
779 // requirements, and New which dose.
781 // Int_t mod The module number assoicated with this set
784 // Int_t cpn0 The lowest copy number
785 // Int_t cpn1 The middle copy number
786 // Int_t cpn2 the highest copy number
790 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
791 // like them but I see not better way for the moment.
792 switch (fMajorVersion){
794 Error("RecodeDetector","Major version = kvDefault, not supported");
798 return RecodeDetectorv11(mod,cpn0,cpn1,cpn2);
801 return RecodeDetectorv11Hybrid(mod,cpn0,cpn1,cpn2);
804 Error("RecodeDetector","Major version = %d, not supported",
805 (Int_t)fMajorVersion);
811 //______________________________________________________________________
812 void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
813 Int_t &lad,Int_t &det){
814 // decode geometry into detector module number. There are two decoding
815 // Scheams. Old which does not follow the ALICE coordinate system
816 // requirements, and New which dose. Note, this use of layer ladder
817 // and detector numbers are strictly for internal use of this
818 // specific code. They do not represent the "standard" layer ladder
819 // or detector numbering except in a very old and obsoleate sence.
821 // Int_t mod The module number assoicated with this set
824 // Int_t lay The layer number
825 // Int_t lad The ladder number
826 // Int_t det the dettector number
830 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
831 // like them but I see not better way for the moment.
832 switch (fMajorVersion) {
834 Error("DecodeDetectorLayers",
835 "Major version = kvDefault, not supported");
839 return DecodeDetectorLayersv11(mod,layer,lad,det);
842 return DecodeDetectorLayersv11Hybrid(mod,layer,lad,det);
845 Error("DecodeDetectorLayers","Major version = %d, not supported",
846 (Int_t)fMajorVersion);
854 //______________________________________________________________________
855 void AliITSInitGeometry::DecodeDetectorv11Hybrid(Int_t &mod,Int_t layer,
856 Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
857 // decode geometry into detector module number
859 // Int_t layer The ITS layer
860 // Int_t cpn0 The lowest copy number
861 // Int_t cpn1 The middle copy number
862 // Int_t cpn2 the highest copy number
864 // Int_t &mod The module number assoicated with this set
868 const Int_t kDetPerLadderSPD[2]={2,4};
869 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
870 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
875 if (SPDIsTGeoNative()) {
876 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
879 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
884 if (SDDIsTGeoNative()) {
893 if (SSDIsTGeoNative()) {
905 for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
906 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
912 //______________________________________________________________________
913 void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
914 Int_t &cpn1,Int_t &cpn2) {
915 // decode geometry into detector module number. There are two decoding
916 // Scheams. Old which does not follow the ALICE coordinate system
917 // requirements, and New which does.
919 // Int_t mod The module number assoicated with this set
922 // Int_t cpn0 The lowest copy number (SPD sector or SDD/SSD ladder)
923 // Int_t cpn1 The middle copy number (SPD stave or SDD/SSD module)
924 // Int_t cpn2 the highest copy number (SPD ladder or 1 for SDD/SSD)
927 const Int_t kDetPerLadderSPD[2]={2,4};
930 DecodeDetectorLayersv11Hybrid(mod,lay,lad,det);
932 cpn2 = det; // Detector 1-4
933 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
934 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
935 //if (SPDIsTGeoNative()) {
939 } else { // SDD and SSD
944 if (SDDIsTGeoNative()) {
947 } // end if SDDIsTGeoNative()
949 if (SSDIsTGeoNative()) {
952 }// end if SSDIsTGeoNative()
953 } // end if Lay<5/else
954 } // end if lay<3/else
955 /*printf("AliITSInitGeometry::RecodeDetectorv11Hybrid:"
956 "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n",
957 mod,lay,lad,det,cpn0,cpn1,cpn2);*/
960 //______________________________________________________________________
961 void AliITSInitGeometry::DecodeDetectorLayersv11Hybrid(Int_t mod,Int_t &lay,
962 Int_t &lad,Int_t &det) {
964 // decode module number into detector indices for v11Hybrid
966 // lay, lad, det start from 1
969 // Int_t mod The module number associated with this set
972 // Int_t lay The layer number
973 // Int_t lad The ladder number
974 // Int_t det the dettector number
976 const Int_t kDetPerLadder[6] = {4,4,6,8,22,25};
977 const Int_t kLadPerLayer[6] = {20,40,14,22,34,38};
983 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
985 } while(mod2<=mod); // end while
986 if(lay>6) Error("DecodeDetectorLayers","lay=%d>6",lay);
988 mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod;
989 lad = mod2/kDetPerLadder[lay-1];
991 if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers",
992 "lad=%d not in the correct range",lad);
993 det = (mod2 - lad*kDetPerLadder[lay-1])+1;
994 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
995 "det=%d not in the correct range",det);
999 //______________________________________________________________________
1000 Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,
1001 AliITSVersion_t maj,Int_t min,
1002 const Char_t *cvsDate,const Char_t *cvsRevision)const{
1003 // fills the string str with the major and minor version number
1005 // Char_t *str The character string to hold the major
1006 // and minor version numbers in
1007 // Int_t length The maximum number of characters which
1008 // can be accomidated by this string.
1009 // str[length-1] must exist and will be set to zero
1010 // AliITSVersion_t maj The major number
1011 // Int_t min The minor number
1012 // Char_t *cvsDate The date string from cvs
1013 // Char_t *cvsRevision The Revision string from cvs
1015 // Char_t *str The character string holding the major and minor
1016 // version numbers. str[length-1] must exist
1017 // and will be set to zero
1019 // kTRUE if no errors
1020 Char_t cvslikedate[30];
1021 Int_t i,n,cvsDateLength,cvsRevisionLength;
1023 cvsDateLength = (Int_t)strlen(cvsDate);
1024 if(cvsDateLength>30){ // svn string, make a cvs like string
1027 cvslikedate[i] = cvsDate[i];
1028 if(cvsDate[i]=='+' || cvsDate[i++]=='-'){
1029 n++; // count number of -
1030 cvslikedate[i-1] = '/'; // replace -'s by /'s.
1032 } while(n<3&&i<30); // once additonal - of time zone reach exit
1033 cvslikedate[i-1] = '$'; // put $ at end then zero.
1034 for(;i<30;i++) cvslikedate[i]=0;// i starts wher do loop left off.
1036 for(i=0;i<cvsDateLength&&i<30;i++) cvslikedate[i]=cvsDate[i];
1038 cvsDateLength = (Int_t)strlen(cvslikedate);
1039 cvsRevisionLength = (Int_t)strlen(cvsRevision);
1041 n = 50+(Int_t)(TMath::Log10(TMath::Abs((Double_t)i)))+1+
1042 (Int_t)(TMath::Log10(TMath::Abs((Double_t)min)))+1
1043 +cvsDateLength-6+cvsRevisionLength-10;
1044 if(GetDebug()>1) printf("AliITSInitGeometry::WriteVersionString:"
1045 "length=%d major=%d minor=%d cvsDate=%s[%d] "
1046 "cvsRevision=%s[%d] n=%d\n",length,i,min,cvslikedate,
1047 cvsDateLength,cvsRevision,cvsRevisionLength,n);
1050 if(length<n){// not enough space to write in output string.
1051 Warning("WriteVersionString","Output string not long enough "
1052 "lenght=%d must be at least %d long\n",length,n);
1054 } // end if length<n
1055 char *cvsrevision = new char[cvsRevisionLength-10];
1056 char *cvsdate = new char[cvsDateLength-6];
1057 for(i=0;i<cvsRevisionLength-10;i++)
1058 if(10+i<cvsRevisionLength-1)
1059 cvsrevision[i] = cvsRevision[10+i]; else cvsrevision[i] = 0;
1060 for(i=0;i<cvsDateLength-6;i++) if(6+i<cvsDateLength-1)
1061 cvsdate[i] = cvslikedate[6+i]; else cvsdate[i] = 0;
1062 for(i=0;i<length;i++) str[i] = 0; // zero it out for now.
1064 snprintf(str,length-1,"Major Version= %d Minor Version= %d Revision: %s Date: %s",i,min,cvsrevision,cvsdate);
1065 /* this gives compilation warnings on some compilers: descriptor zu
1066 if(GetDebug()>1)printf("AliITSInitGeometry::WriteVersionString: "
1067 "n=%d str=%s revision[%zu] date[%zu]\n",
1068 n,str,strlen(cvsrevision),strlen(cvsdate));
1070 delete[] cvsrevision;
1074 //______________________________________________________________________
1075 Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,Int_t length,
1076 AliITSVersion_t &maj,Int_t &min,
1078 // fills the string str with the major and minor version number
1080 // Char_t *str The character string to holding the major and minor
1081 // version numbers in
1082 // Int_t length The maximum number of characters which can be
1083 // accomidated by this string. str[length-1] must exist
1085 // Char_t *str The character string holding the major and minor
1086 // version numbers unchanged. str[length-1] must exist.
1087 // AliITSVersion_t maj The major number
1088 // Int_t min The minor number
1089 // TDatime dt The date and time of the cvs commit
1091 // kTRUE if no errors
1093 Char_t cvsRevision[10],cvsDate[11],cvsTime[9];
1094 Int_t i,m,n=strlen(str),year,month,day,hours,minuits,seconds;
1096 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString:"
1097 "str=%s length=%d\n",
1099 if(n<35) return kFALSE; // not enough space for numbers
1100 m = sscanf(str,"Major Version= %d Minor Version= %d Revision: %9s "
1101 "Date: %10s %8s",&i,&min,cvsRevision,cvsDate,cvsTime);
1104 m = sscanf(cvsDate,"%d/%d/%d",&year,&month,&day);
1107 m = sscanf(cvsTime,"%d:%d:%d",&hours,&minuits,&seconds);
1110 dt.Set(year,month,day,hours,minuits,seconds);
1111 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: i=%d "
1112 "min=%d cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
1113 i,min,cvsRevision,cvsDate,cvsTime,m);
1114 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: year=%d"
1115 " month=%d day=%d hours=%d minuits=%d seconds=%d\n",
1116 year,month,day,hours,minuits,seconds);