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 //______________________________________________________________________
57 AliITSInitGeometry::AliITSInitGeometry():
58 TObject(), // Base Class
59 fName(0), // Geometry name
60 fMajorVersion(kvDefault), // Major versin number
61 fTiming(kFALSE), // Flag to start inilization timing
62 fSegGeom(kFALSE), // Flag to switch between the old use of
63 // AliITSgeomS?D class, or AliITSsegmentation
64 // class in fShape of AliITSgeom class.
65 fDecode(kFALSE), // Flag for new/old decoding
66 fDebug(0){ // Debug flag
73 // A default inilized AliITSInitGeometry object
77 //______________________________________________________________________
78 AliITSInitGeometry::AliITSInitGeometry(AliITSVersion_t version):
79 TObject(), // Base Class
80 fName(0), // Geometry name
81 fMajorVersion(version), // Major version number
82 fTiming(kFALSE), // Flag to start inilization timing
83 fSegGeom(kFALSE), // Flag to switch between the old use of
84 // AliITSgeomS?D class, or AliITSsegmentation
85 // class in fShape of AliITSgeom class.
86 fDecode(kFALSE), // Flag for new/old decoding
87 fDebug(0){ // Debug flag
94 // A default inilized AliITSInitGeometry object
102 AliFatal(Form("Undefined geometry: fMajorVersion=%d, ",(Int_t)fMajorVersion));
107 //______________________________________________________________________
108 AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(){
109 // Creates and Initilizes the geometry transformation class AliITSgeom
110 // to values appropreate to this specific geometry. Now that
111 // the segmentation is part of AliITSgeom, the detector
112 // segmentations are also defined here.
118 // A pointer to a new properly inilized AliITSgeom class. If
119 // pointer = 0 then failed to init.
122 AliITSVersion_t version = kvDefault;
124 TGeoVolume *itsV = gGeoManager->GetVolume("ITSV");
126 AliError("Can't find ITS volume ITSV, exiting - nothing done!");
129 const Char_t *title = itsV->GetTitle();
130 if(!ReadVersionString(title,version))
131 Warning("UpdateInternalGeometry","Can't read title=%s\n",title);
135 AliITSgeom *geom = CreateAliITSgeom(version);
136 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
139 //______________________________________________________________________
140 AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(Int_t major){
141 // Creates and Initilizes the geometry transformation class AliITSgeom
142 // to values appropreate to this specific geometry. Now that
143 // the segmentation is part of AliITSgeom, the detector
144 // segmentations are also defined here.
146 // Int_t major major version, see AliITSVersion_t
151 // A pointer to a new properly inilized AliITSgeom class. If
152 // pointer = 0 then failed to init.
156 SetGeometryName("AliITSv11");
161 SetGeometryName("Undefined");
162 SetVersion(kvDefault);
165 AliITSgeom *geom = new AliITSgeom();
166 if(!InitAliITSgeom(geom)){ // Error initilization failed
172 //______________________________________________________________________
173 Bool_t AliITSInitGeometry::InitAliITSgeom(AliITSgeom *geom){
174 // Initilizes the geometry transformation class AliITSgeom
175 // to values appropreate to this specific geometry. Now that
176 // the segmentation is part of AliITSgeom, the detector
177 // segmentations are also defined here.
179 // AliITSgeom *geom A pointer to the AliITSgeom class
181 // AliITSgeom *geom This pointer recreated and properly inilized.
186 AliFatal("The geometry manager has not been initialized (e.g. "
187 "TGeoManager::Import(\"geometry.root\")should be "
188 "called in advance) - exit forced");
191 switch(fMajorVersion) {
193 return InitAliITSgeomV11(geom);
195 case kvDefault: default: {
196 AliFatal("Undefined geometry");
202 //______________________________________________________________________
203 void AliITSInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
204 // Transpose the rotation matrix part of a TGeoHMatrix. This
205 // is needed because TGeo stores the transpose of the rotation
206 // matrix as compared to what AliITSgeomMatrix uses (and Geant3).
208 // TGeoHMatrix *m The matrix to be transposed
210 // TGEoHMatrix *m The transposed matrix
216 if(m==0) return; // no matrix to transpose.
217 for(i=0;i<9;i += 4) r[i] = m->GetRotationMatrix()[i]; // diagonals
218 r[1] = m->GetRotationMatrix()[3];
219 r[2] = m->GetRotationMatrix()[6];
220 r[3] = m->GetRotationMatrix()[1];
221 r[5] = m->GetRotationMatrix()[7];
222 r[6] = m->GetRotationMatrix()[2];
223 r[7] = m->GetRotationMatrix()[5];
229 //______________________________________________________________________
230 Bool_t AliITSInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
231 // Initilizes the geometry transformation class AliITSgeom
232 // Now that the segmentation is part of AliITSgeom, the detector
233 // segmentations are also defined here.
236 // AliITSgeom *geom A pointer to the AliITSgeom class
238 // AliITSgeom *geom This pointer recreated and properly inilized.
241 const Int_t kItype = 0; // Type of transformation defined 0=> Geant
242 const Int_t klayers = 6; // number of layers in the ITS
243 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
244 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
245 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
246 const TString kPathbase = "/ALIC_1/ITSV_1/";
248 const char *pathSPDsens1, *pathSPDsens2;
249 pathSPDsens1="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay1-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay1-Ladder_%d/ITSSPDlay1-sensor_1";
250 pathSPDsens2="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay2-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay2-Ladder_%d/ITSSPDlay2-sensor_1";
252 const char *pathSDDsens1, *pathSDDsens2;
253 pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
254 pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
256 const char *pathSSDsens1, *pathSSDsens2;
257 pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSssdSensor5_%d/ITSssdSensitivL5_1";
258 pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSssdSensor6_%d/ITSssdSensitivL6_1";
260 const TString kNames[klayers] = {
261 pathSPDsens1, // lay=1
262 pathSPDsens2, // lay=2
263 pathSDDsens1, // lay=3
264 pathSDDsens2, // lay=4
265 pathSSDsens1, // lay=5
266 pathSSDsens2};// Lay=6
268 Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1;
269 Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
271 TString path, shapeName;
273 Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
274 TStopwatch *time = 0x0;
275 if(fTiming) time = new TStopwatch();
277 if(fTiming) time->Start();
278 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
279 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
281 for(mod=0; mod<nmods; mod++) {
283 DecodeDetectorLayers(mod,lay,lad,det);
284 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
285 RecodeDetector(mod,cpn0,cpn1,cpn2);
287 if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
288 if (det<3) cpnHS = 0; else cpnHS = 1;
289 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2);
291 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2);
294 geom->GetGeomMatrix(mod)->SetPath(path);
295 GetTransformation(path.Data(),matrix);
296 geom->SetTrans(mod,matrix.GetTranslation());
297 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
298 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
299 if(initSeg[kIdet[lay-1]]) continue;
300 GetShape(path,shapeName,shapePar);
301 if(shapeName.CompareTo("BOX")){
302 Error("InitITSgeom","Geometry changed without proper code update"
303 "or error in reading geometry. Shape is not BOX.");
316 //_______________________________________________________________________
317 Bool_t AliITSInitGeometry::GetTransformation(const TString &volumePath,
319 // Returns the Transformation matrix between the volume specified
320 // by the path volumePath and the Top or mater volume. The format
321 // of the path volumePath is as follows (assuming ALIC is the Top volume)
322 // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
323 // or master volume which has only 1 instance of. Of all of the daughter
324 // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
325 // the daughter volume of DDIP is S05I copy #2 and so on.
327 // TString& volumePath The volume path to the specific volume
328 // for which you want the matrix. Volume name
329 // hierarchy is separated by "/" while the
330 // copy number is appended using a "_".
332 // TGeoHMatrix &mat A matrix with its values set to those
333 // appropriate to the Local to Master transformation
335 // A logical value if kFALSE then an error occurred and no change to
338 // We have to preserve the modeler state
340 // Preserve the modeler state.
341 gGeoManager->PushPath();
342 if (!gGeoManager->cd(volumePath.Data())) {
343 gGeoManager->PopPath();
344 Error("GetTransformation","Error in cd-ing to %s",volumePath.Data());
346 } // end if !gGeoManager
347 mat = *gGeoManager->GetCurrentMatrix();
348 // Retstore the modeler state.
349 gGeoManager->PopPath();
352 //______________________________________________________________________
353 Bool_t AliITSInitGeometry::GetShape(const TString &volumePath,
354 TString &shapeType,TArrayD &par){
355 // Returns the shape and its parameters for the volume specified
358 // TString& volumeName The volume name
360 // TString &shapeType Shape type
361 // TArrayD &par A TArrayD of parameters with all of the
362 // parameters of the specified shape.
364 // A logical indicating whether there was an error in getting this
367 gGeoManager->PushPath();
368 if (!gGeoManager->cd(volumePath.Data())) {
369 gGeoManager->PopPath();
372 TGeoVolume * vol = gGeoManager->GetCurrentVolume();
373 gGeoManager->PopPath();
374 if (!vol) return kFALSE;
375 TGeoShape *shape = vol->GetShape();
376 TClass *classType = shape->IsA();
377 if (classType==TGeoBBox::Class()) {
381 TGeoBBox *box = (TGeoBBox*)shape;
382 par.AddAt(box->GetDX(),0);
383 par.AddAt(box->GetDY(),1);
384 par.AddAt(box->GetDZ(),2);
387 if (classType==TGeoTrd1::Class()) {
391 TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
392 par.AddAt(trd1->GetDx1(),0);
393 par.AddAt(trd1->GetDx2(),1);
394 par.AddAt(trd1->GetDy(), 2);
395 par.AddAt(trd1->GetDz(), 3);
398 if (classType==TGeoTrd2::Class()) {
402 TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
403 par.AddAt(trd2->GetDx1(),0);
404 par.AddAt(trd2->GetDx2(),1);
405 par.AddAt(trd2->GetDy1(),2);
406 par.AddAt(trd2->GetDy2(),3);
407 par.AddAt(trd2->GetDz(), 4);
410 if (classType==TGeoTrap::Class()) {
414 TGeoTrap *trap = (TGeoTrap*)shape;
415 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
416 par.AddAt(trap->GetDz(),0);
417 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
418 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
419 par.AddAt(trap->GetH1(),3);
420 par.AddAt(trap->GetBl1(),4);
421 par.AddAt(trap->GetTl1(),5);
422 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
423 par.AddAt(trap->GetH2(),7);
424 par.AddAt(trap->GetBl2(),8);
425 par.AddAt(trap->GetTl2(),9);
426 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
429 if (classType==TGeoTube::Class()) {
433 TGeoTube *tube = (TGeoTube*)shape;
434 par.AddAt(tube->GetRmin(),0);
435 par.AddAt(tube->GetRmax(),1);
436 par.AddAt(tube->GetDz(),2);
439 if (classType==TGeoTubeSeg::Class()) {
443 TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
444 par.AddAt(tubs->GetRmin(),0);
445 par.AddAt(tubs->GetRmax(),1);
446 par.AddAt(tubs->GetDz(),2);
447 par.AddAt(tubs->GetPhi1(),3);
448 par.AddAt(tubs->GetPhi2(),4);
451 if (classType==TGeoCone::Class()) {
455 TGeoCone *cone = (TGeoCone*)shape;
456 par.AddAt(cone->GetDz(),0);
457 par.AddAt(cone->GetRmin1(),1);
458 par.AddAt(cone->GetRmax1(),2);
459 par.AddAt(cone->GetRmin2(),3);
460 par.AddAt(cone->GetRmax2(),4);
463 if (classType==TGeoConeSeg::Class()) {
467 TGeoConeSeg *cons = (TGeoConeSeg*)shape;
468 par.AddAt(cons->GetDz(),0);
469 par.AddAt(cons->GetRmin1(),1);
470 par.AddAt(cons->GetRmax1(),2);
471 par.AddAt(cons->GetRmin2(),3);
472 par.AddAt(cons->GetRmax2(),4);
473 par.AddAt(cons->GetPhi1(),5);
474 par.AddAt(cons->GetPhi2(),6);
477 if (classType==TGeoSphere::Class()) {
482 TGeoSphere *sphe = (TGeoSphere*)shape;
483 par.AddAt(sphe->GetRmin(),0);
484 par.AddAt(sphe->GetRmax(),1);
485 par.AddAt(sphe->GetTheta1(),2);
486 par.AddAt(sphe->GetTheta2(),3);
487 par.AddAt(sphe->GetPhi1(),4);
488 par.AddAt(sphe->GetPhi2(),5);
491 if (classType==TGeoPara::Class()) {
495 TGeoPara *para = (TGeoPara*)shape;
496 par.AddAt(para->GetX(),0);
497 par.AddAt(para->GetY(),1);
498 par.AddAt(para->GetZ(),2);
499 par.AddAt(para->GetTxy(),3);
500 par.AddAt(para->GetTxz(),4);
501 par.AddAt(para->GetTyz(),5);
504 if (classType==TGeoPgon::Class()) {
506 TGeoPgon *pgon = (TGeoPgon*)shape;
507 Int_t nz = pgon->GetNz();
508 const Double_t *rmin = pgon->GetRmin();
509 const Double_t *rmax = pgon->GetRmax();
510 const Double_t *z = pgon->GetZ();
513 par.AddAt(pgon->GetPhi1(),0);
514 par.AddAt(pgon->GetDphi(),1);
515 par.AddAt(pgon->GetNedges(),2);
516 par.AddAt(pgon->GetNz(),3);
517 for (Int_t i=0; i<nz; i++) {
518 par.AddAt(z[i], 4+3*i);
519 par.AddAt(rmin[i], 4+3*i+1);
520 par.AddAt(rmax[i], 4+3*i+2);
524 if (classType==TGeoPcon::Class()) {
526 TGeoPcon *pcon = (TGeoPcon*)shape;
527 Int_t nz = pcon->GetNz();
528 const Double_t *rmin = pcon->GetRmin();
529 const Double_t *rmax = pcon->GetRmax();
530 const Double_t *z = pcon->GetZ();
533 par.AddAt(pcon->GetPhi1(),0);
534 par.AddAt(pcon->GetDphi(),1);
535 par.AddAt(pcon->GetNz(),2);
536 for (Int_t i=0; i<nz; i++) {
537 par.AddAt(z[i], 3+3*i);
539 par.AddAt(rmin[i], 3+3*i+1);
540 par.AddAt(rmax[i], 3+3*i+2);
544 if (classType==TGeoEltu::Class()) {
548 TGeoEltu *eltu = (TGeoEltu*)shape;
549 par.AddAt(eltu->GetA(),0);
550 par.AddAt(eltu->GetB(),1);
551 par.AddAt(eltu->GetDz(),2);
554 if (classType==TGeoHype::Class()) {
558 TGeoHype *hype = (TGeoHype*)shape;
559 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
560 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
561 par.AddAt(hype->GetDZ(),2);
562 par.AddAt(hype->GetStIn(),3);
563 par.AddAt(hype->GetStOut(),4);
566 if (classType==TGeoGtra::Class()) {
570 TGeoGtra *trap = (TGeoGtra*)shape;
571 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
572 par.AddAt(trap->GetDz(),0);
573 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
574 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
575 par.AddAt(trap->GetH1(),3);
576 par.AddAt(trap->GetBl1(),4);
577 par.AddAt(trap->GetTl1(),5);
578 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
579 par.AddAt(trap->GetH2(),7);
580 par.AddAt(trap->GetBl2(),8);
581 par.AddAt(trap->GetTl2(),9);
582 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
583 par.AddAt(trap->GetTwistAngle(),11);
586 if (classType==TGeoCtub::Class()) {
590 TGeoCtub *ctub = (TGeoCtub*)shape;
591 const Double_t *lx = ctub->GetNlow();
592 const Double_t *tx = ctub->GetNhigh();
593 par.AddAt(ctub->GetRmin(),0);
594 par.AddAt(ctub->GetRmax(),1);
595 par.AddAt(ctub->GetDz(),2);
596 par.AddAt(ctub->GetPhi1(),3);
597 par.AddAt(ctub->GetPhi2(),4);
606 Error("GetShape","Getting shape parameters for shape %s not implemented",
608 shapeType = "Unknown";
611 //______________________________________________________________________
612 void AliITSInitGeometry::DecodeDetector(
613 Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
614 // decode geometry into detector module number. There are two decoding
615 // Scheams. Old which does not follow the ALICE coordinate system
616 // requirements, and New which dose.
618 // Int_t layer The ITS layer
619 // Int_t cpn0 The lowest copy number
620 // Int_t cpn1 The middle copy number
621 // Int_t cpn2 the highest copy number
623 // Int_t &mod The module number assoicated with this set
628 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
629 // like them but I see not better way for the moment.
630 switch (fMajorVersion){
632 Error("DecodeDetector","Major version = kvDefault, not supported");
635 return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2);
638 Error("DecodeDetector","Major version = %d, not supported",
639 (Int_t)fMajorVersion);
645 //______________________________________________________________________
646 void AliITSInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
647 Int_t &cpn1,Int_t &cpn2){
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.
652 // Int_t mod The module number assoicated with this set
655 // Int_t cpn0 The lowest copy number
656 // Int_t cpn1 The middle copy number
657 // Int_t cpn2 the highest copy number
661 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
662 // like them but I see not better way for the moment.
663 switch (fMajorVersion){
665 Error("RecodeDetector","Major version = kvDefault, not supported");
669 return RecodeDetectorv11(mod,cpn0,cpn1,cpn2);
672 Error("RecodeDetector","Major version = %d, not supported",
673 (Int_t)fMajorVersion);
679 //______________________________________________________________________
680 void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
681 Int_t &lad,Int_t &det){
682 // decode geometry into detector module number. There are two decoding
683 // Scheams. Old which does not follow the ALICE coordinate system
684 // requirements, and New which dose. Note, this use of layer ladder
685 // and detector numbers are strictly for internal use of this
686 // specific code. They do not represent the "standard" layer ladder
687 // or detector numbering except in a very old and obsoleate sence.
689 // Int_t mod The module number assoicated with this set
692 // Int_t lay The layer number
693 // Int_t lad The ladder number
694 // Int_t det the dettector number
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) {
702 Error("DecodeDetectorLayers",
703 "Major version = kvDefault, not supported");
707 return DecodeDetectorLayersv11(mod,layer,lad,det);
710 Error("DecodeDetectorLayers","Major version = %d, not supported",
711 (Int_t)fMajorVersion);
718 //______________________________________________________________________
719 void AliITSInitGeometry::DecodeDetectorv11(Int_t &mod,Int_t layer,
720 Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
721 // decode geometry into detector module number
723 // Int_t layer The ITS layer
724 // Int_t cpn0 The lowest copy number
725 // Int_t cpn1 The middle copy number
726 // Int_t cpn2 the highest copy number
728 // Int_t &mod The module number assoicated with this set
732 const Int_t kDetPerLadderSPD[2]={2,4};
733 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
734 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
739 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
754 for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
755 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
760 //______________________________________________________________________
761 void AliITSInitGeometry::RecodeDetectorv11(Int_t mod,Int_t &cpn0,
762 Int_t &cpn1,Int_t &cpn2) {
763 // decode geometry into detector module number using the new decoding
766 // Int_t mod The module number assoicated with this set
769 // Int_t cpn0 The lowest copy number (SPD sector or SDD/SSD ladder)
770 // Int_t cpn1 The middle copy number (SPD stave or SDD/SSD module)
771 // Int_t cpn2 the highest copy number (SPD ladder or 1 for SDD/SSD)
774 const Int_t kDetPerLadderSPD[2]={2,4};
777 DecodeDetectorLayersv11(mod,lay,lad,det);
779 cpn2 = det; // Detector 1-4
780 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
781 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
782 } else { // SDD and SSD
792 } // end if Lay<5/else
793 } // end if lay<3/else
798 //______________________________________________________________________
799 void AliITSInitGeometry::DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
800 Int_t &lad,Int_t &det) {
802 // decode module number into detector indices for v11
804 // lay, lad, det start from 1
807 // Int_t mod The module number associated with this set
810 // Int_t lay The layer number
811 // Int_t lad The ladder number
812 // Int_t det the dettector number
814 const Int_t kDetPerLadder[6] = {4,4,6,8,22,25};
815 const Int_t kLadPerLayer[6] = {20,40,14,22,34,38};
821 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
823 } while(mod2<=mod); // end while
824 if(lay>6) Error("DecodeDetectorLayers","lay=%d>6",lay);
826 mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod;
827 lad = mod2/kDetPerLadder[lay-1];
829 if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers",
830 "lad=%d not in the correct range",lad);
831 det = (mod2 - lad*kDetPerLadder[lay-1])+1;
832 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
833 "det=%d not in the correct range",det);
837 //______________________________________________________________________
838 Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,AliITSVersion_t maj)const{
839 // fills the string str with the major version number
841 // Char_t *str The character string to hold the major version number
842 // Int_t length The maximum number of characters which
843 // can be accommodated by this string.
844 // str[length-1] must exist
845 // AliITSVersion_t maj The major number
848 Int_t i = (Int_t)maj;
850 snprintf(str,length-1,"Major Version= %d",i);
853 //______________________________________________________________________
854 Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,AliITSVersion_t &maj)const{
855 // fills the string str with the major and minor version number
857 // Char_t *str The character string to holding the major version number
858 // Int_t length The maximum number of characters which can be
859 // accommodated by this string. str[length-1] must exist
861 // AliITSVersion_t maj The major number
864 // kTRUE if no errors
866 Bool_t retcode=kFALSE;
868 if(n<15) return retcode; // not enough space for numbers
870 m = sscanf(str,"Major Version= %2d",&i);