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;
125 TGeoVolume *itsV = gGeoManager->GetVolume("ITSV");
127 AliError("Can't find ITS volume ITSV, exiting - nothing done!");
130 const Char_t *title = itsV->GetTitle();
131 if(!ReadVersionString(title,version))
132 Warning("UpdateInternalGeometry","Can't read title=%s\n",title);
136 AliITSgeom *geom = CreateAliITSgeom(version);
137 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
140 //______________________________________________________________________
141 AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(Int_t major){
142 // Creates and Initilizes the geometry transformation class AliITSgeom
143 // to values appropreate to this specific geometry. Now that
144 // the segmentation is part of AliITSgeom, the detector
145 // segmentations are also defined here.
147 // Int_t major major version, see AliITSVersion_t
152 // A pointer to a new properly inilized AliITSgeom class. If
153 // pointer = 0 then failed to init.
157 SetGeometryName("AliITSv11");
162 SetGeometryName("Undefined");
163 SetVersion(kvDefault);
166 AliITSgeom *geom = new AliITSgeom();
167 if(!InitAliITSgeom(geom)){ // Error initilization failed
173 //______________________________________________________________________
174 Bool_t AliITSInitGeometry::InitAliITSgeom(AliITSgeom *geom){
175 // Initilizes the geometry transformation class AliITSgeom
176 // to values appropreate to this specific geometry. Now that
177 // the segmentation is part of AliITSgeom, the detector
178 // segmentations are also defined here.
180 // AliITSgeom *geom A pointer to the AliITSgeom class
182 // AliITSgeom *geom This pointer recreated and properly inilized.
187 AliFatal("The geometry manager has not been initialized (e.g. "
188 "TGeoManager::Import(\"geometry.root\")should be "
189 "called in advance) - exit forced");
192 switch(fMajorVersion) {
194 return InitAliITSgeomV11(geom);
196 case kvDefault: default: {
197 AliFatal("Undefined geometry");
203 //______________________________________________________________________
204 void AliITSInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
205 // Transpose the rotation matrix part of a TGeoHMatrix. This
206 // is needed because TGeo stores the transpose of the rotation
207 // matrix as compared to what AliITSgeomMatrix uses (and Geant3).
209 // TGeoHMatrix *m The matrix to be transposed
211 // TGEoHMatrix *m The transposed matrix
217 if(m==0) return; // no matrix to transpose.
218 for(i=0;i<9;i += 4) r[i] = m->GetRotationMatrix()[i]; // diagonals
219 r[1] = m->GetRotationMatrix()[3];
220 r[2] = m->GetRotationMatrix()[6];
221 r[3] = m->GetRotationMatrix()[1];
222 r[5] = m->GetRotationMatrix()[7];
223 r[6] = m->GetRotationMatrix()[2];
224 r[7] = m->GetRotationMatrix()[5];
230 //______________________________________________________________________
231 Bool_t AliITSInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
232 // Initilizes the geometry transformation class AliITSgeom
233 // Now that the segmentation is part of AliITSgeom, the detector
234 // segmentations are also defined here.
237 // AliITSgeom *geom A pointer to the AliITSgeom class
239 // AliITSgeom *geom This pointer recreated and properly inilized.
242 const Int_t kItype = 0; // Type of transformation defined 0=> Geant
243 const Int_t klayers = 6; // number of layers in the ITS
244 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
245 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
246 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
247 const TString kPathbase = "/ALIC_1/ITSV_1/";
249 const char *pathSPDsens1, *pathSPDsens2;
250 pathSPDsens1="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay1-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay1-Ladder_%d/ITSSPDlay1-sensor_1";
251 pathSPDsens2="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay2-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay2-Ladder_%d/ITSSPDlay2-sensor_1";
253 const char *pathSDDsens1, *pathSDDsens2;
254 pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
255 pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
257 const char *pathSSDsens1, *pathSSDsens2;
258 pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSssdSensor5_%d/ITSssdSensitivL5_1";
259 pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSssdSensor6_%d/ITSssdSensitivL6_1";
261 const TString kNames[klayers] = {
262 pathSPDsens1, // lay=1
263 pathSPDsens2, // lay=2
264 pathSDDsens1, // lay=3
265 pathSDDsens2, // lay=4
266 pathSSDsens1, // lay=5
267 pathSSDsens2};// Lay=6
269 Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1;
270 Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
272 TString path, shapeName;
274 Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
275 TStopwatch *time = 0x0;
276 if(fTiming) time = new TStopwatch();
278 if(fTiming) time->Start();
279 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
280 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
282 for(mod=0; mod<nmods; mod++) {
284 DecodeDetectorLayers(mod,lay,lad,det);
285 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
286 RecodeDetector(mod,cpn0,cpn1,cpn2);
288 if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
289 if (det<3) cpnHS = 0; else cpnHS = 1;
290 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2);
292 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2);
295 geom->GetGeomMatrix(mod)->SetPath(path);
296 GetTransformation(path.Data(),matrix);
297 geom->SetTrans(mod,matrix.GetTranslation());
298 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
299 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
300 if(initSeg[kIdet[lay-1]]) continue;
301 GetShape(path,shapeName,shapePar);
302 if(shapeName.CompareTo("BOX")){
303 Error("InitITSgeom","Geometry changed without proper code update"
304 "or error in reading geometry. Shape is not BOX.");
317 //_______________________________________________________________________
318 Bool_t AliITSInitGeometry::GetTransformation(const TString &volumePath,
320 // Returns the Transformation matrix between the volume specified
321 // by the path volumePath and the Top or mater volume. The format
322 // of the path volumePath is as follows (assuming ALIC is the Top volume)
323 // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
324 // or master volume which has only 1 instance of. Of all of the daughter
325 // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
326 // the daughter volume of DDIP is S05I copy #2 and so on.
328 // TString& volumePath The volume path to the specific volume
329 // for which you want the matrix. Volume name
330 // hierarchy is separated by "/" while the
331 // copy number is appended using a "_".
333 // TGeoHMatrix &mat A matrix with its values set to those
334 // appropriate to the Local to Master transformation
336 // A logical value if kFALSE then an error occurred and no change to
339 // We have to preserve the modeler state
341 // Preserve the modeler state.
342 gGeoManager->PushPath();
343 if (!gGeoManager->cd(volumePath.Data())) {
344 gGeoManager->PopPath();
345 Error("GetTransformation","Error in cd-ing to %s",volumePath.Data());
347 } // end if !gGeoManager
348 mat = *gGeoManager->GetCurrentMatrix();
349 // Retstore the modeler state.
350 gGeoManager->PopPath();
353 //______________________________________________________________________
354 Bool_t AliITSInitGeometry::GetShape(const TString &volumePath,
355 TString &shapeType,TArrayD &par){
356 // Returns the shape and its parameters for the volume specified
359 // TString& volumeName The volume name
361 // TString &shapeType Shape type
362 // TArrayD &par A TArrayD of parameters with all of the
363 // parameters of the specified shape.
365 // A logical indicating whether there was an error in getting this
368 gGeoManager->PushPath();
369 if (!gGeoManager->cd(volumePath.Data())) {
370 gGeoManager->PopPath();
373 TGeoVolume * vol = gGeoManager->GetCurrentVolume();
374 gGeoManager->PopPath();
375 if (!vol) return kFALSE;
376 TGeoShape *shape = vol->GetShape();
377 TClass *classType = shape->IsA();
378 if (classType==TGeoBBox::Class()) {
382 TGeoBBox *box = (TGeoBBox*)shape;
383 par.AddAt(box->GetDX(),0);
384 par.AddAt(box->GetDY(),1);
385 par.AddAt(box->GetDZ(),2);
388 if (classType==TGeoTrd1::Class()) {
392 TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
393 par.AddAt(trd1->GetDx1(),0);
394 par.AddAt(trd1->GetDx2(),1);
395 par.AddAt(trd1->GetDy(), 2);
396 par.AddAt(trd1->GetDz(), 3);
399 if (classType==TGeoTrd2::Class()) {
403 TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
404 par.AddAt(trd2->GetDx1(),0);
405 par.AddAt(trd2->GetDx2(),1);
406 par.AddAt(trd2->GetDy1(),2);
407 par.AddAt(trd2->GetDy2(),3);
408 par.AddAt(trd2->GetDz(), 4);
411 if (classType==TGeoTrap::Class()) {
415 TGeoTrap *trap = (TGeoTrap*)shape;
416 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
417 par.AddAt(trap->GetDz(),0);
418 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
419 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
420 par.AddAt(trap->GetH1(),3);
421 par.AddAt(trap->GetBl1(),4);
422 par.AddAt(trap->GetTl1(),5);
423 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
424 par.AddAt(trap->GetH2(),7);
425 par.AddAt(trap->GetBl2(),8);
426 par.AddAt(trap->GetTl2(),9);
427 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
430 if (classType==TGeoTube::Class()) {
434 TGeoTube *tube = (TGeoTube*)shape;
435 par.AddAt(tube->GetRmin(),0);
436 par.AddAt(tube->GetRmax(),1);
437 par.AddAt(tube->GetDz(),2);
440 if (classType==TGeoTubeSeg::Class()) {
444 TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
445 par.AddAt(tubs->GetRmin(),0);
446 par.AddAt(tubs->GetRmax(),1);
447 par.AddAt(tubs->GetDz(),2);
448 par.AddAt(tubs->GetPhi1(),3);
449 par.AddAt(tubs->GetPhi2(),4);
452 if (classType==TGeoCone::Class()) {
456 TGeoCone *cone = (TGeoCone*)shape;
457 par.AddAt(cone->GetDz(),0);
458 par.AddAt(cone->GetRmin1(),1);
459 par.AddAt(cone->GetRmax1(),2);
460 par.AddAt(cone->GetRmin2(),3);
461 par.AddAt(cone->GetRmax2(),4);
464 if (classType==TGeoConeSeg::Class()) {
468 TGeoConeSeg *cons = (TGeoConeSeg*)shape;
469 par.AddAt(cons->GetDz(),0);
470 par.AddAt(cons->GetRmin1(),1);
471 par.AddAt(cons->GetRmax1(),2);
472 par.AddAt(cons->GetRmin2(),3);
473 par.AddAt(cons->GetRmax2(),4);
474 par.AddAt(cons->GetPhi1(),5);
475 par.AddAt(cons->GetPhi2(),6);
478 if (classType==TGeoSphere::Class()) {
483 TGeoSphere *sphe = (TGeoSphere*)shape;
484 par.AddAt(sphe->GetRmin(),0);
485 par.AddAt(sphe->GetRmax(),1);
486 par.AddAt(sphe->GetTheta1(),2);
487 par.AddAt(sphe->GetTheta2(),3);
488 par.AddAt(sphe->GetPhi1(),4);
489 par.AddAt(sphe->GetPhi2(),5);
492 if (classType==TGeoPara::Class()) {
496 TGeoPara *para = (TGeoPara*)shape;
497 par.AddAt(para->GetX(),0);
498 par.AddAt(para->GetY(),1);
499 par.AddAt(para->GetZ(),2);
500 par.AddAt(para->GetTxy(),3);
501 par.AddAt(para->GetTxz(),4);
502 par.AddAt(para->GetTyz(),5);
505 if (classType==TGeoPgon::Class()) {
507 TGeoPgon *pgon = (TGeoPgon*)shape;
508 Int_t nz = pgon->GetNz();
509 const Double_t *rmin = pgon->GetRmin();
510 const Double_t *rmax = pgon->GetRmax();
511 const Double_t *z = pgon->GetZ();
514 par.AddAt(pgon->GetPhi1(),0);
515 par.AddAt(pgon->GetDphi(),1);
516 par.AddAt(pgon->GetNedges(),2);
517 par.AddAt(pgon->GetNz(),3);
518 for (Int_t i=0; i<nz; i++) {
519 par.AddAt(z[i], 4+3*i);
520 par.AddAt(rmin[i], 4+3*i+1);
521 par.AddAt(rmax[i], 4+3*i+2);
525 if (classType==TGeoPcon::Class()) {
527 TGeoPcon *pcon = (TGeoPcon*)shape;
528 Int_t nz = pcon->GetNz();
529 const Double_t *rmin = pcon->GetRmin();
530 const Double_t *rmax = pcon->GetRmax();
531 const Double_t *z = pcon->GetZ();
534 par.AddAt(pcon->GetPhi1(),0);
535 par.AddAt(pcon->GetDphi(),1);
536 par.AddAt(pcon->GetNz(),2);
537 for (Int_t i=0; i<nz; i++) {
538 par.AddAt(z[i], 3+3*i);
540 par.AddAt(rmin[i], 3+3*i+1);
541 par.AddAt(rmax[i], 3+3*i+2);
545 if (classType==TGeoEltu::Class()) {
549 TGeoEltu *eltu = (TGeoEltu*)shape;
550 par.AddAt(eltu->GetA(),0);
551 par.AddAt(eltu->GetB(),1);
552 par.AddAt(eltu->GetDz(),2);
555 if (classType==TGeoHype::Class()) {
559 TGeoHype *hype = (TGeoHype*)shape;
560 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
561 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
562 par.AddAt(hype->GetDZ(),2);
563 par.AddAt(hype->GetStIn(),3);
564 par.AddAt(hype->GetStOut(),4);
567 if (classType==TGeoGtra::Class()) {
571 TGeoGtra *trap = (TGeoGtra*)shape;
572 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
573 par.AddAt(trap->GetDz(),0);
574 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
575 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
576 par.AddAt(trap->GetH1(),3);
577 par.AddAt(trap->GetBl1(),4);
578 par.AddAt(trap->GetTl1(),5);
579 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
580 par.AddAt(trap->GetH2(),7);
581 par.AddAt(trap->GetBl2(),8);
582 par.AddAt(trap->GetTl2(),9);
583 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
584 par.AddAt(trap->GetTwistAngle(),11);
587 if (classType==TGeoCtub::Class()) {
591 TGeoCtub *ctub = (TGeoCtub*)shape;
592 const Double_t *lx = ctub->GetNlow();
593 const Double_t *tx = ctub->GetNhigh();
594 par.AddAt(ctub->GetRmin(),0);
595 par.AddAt(ctub->GetRmax(),1);
596 par.AddAt(ctub->GetDz(),2);
597 par.AddAt(ctub->GetPhi1(),3);
598 par.AddAt(ctub->GetPhi2(),4);
607 Error("GetShape","Getting shape parameters for shape %s not implemented",
609 shapeType = "Unknown";
612 //______________________________________________________________________
613 void AliITSInitGeometry::DecodeDetector(
614 Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
615 // decode geometry into detector module number. There are two decoding
616 // Scheams. Old which does not follow the ALICE coordinate system
617 // requirements, and New which dose.
619 // Int_t layer The ITS layer
620 // Int_t cpn0 The lowest copy number
621 // Int_t cpn1 The middle copy number
622 // Int_t cpn2 the highest copy number
624 // Int_t &mod The module number assoicated with this set
629 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
630 // like them but I see not better way for the moment.
631 switch (fMajorVersion){
633 Error("DecodeDetector","Major version = kvDefault, not supported");
636 return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2);
639 Error("DecodeDetector","Major version = %d, not supported",
640 (Int_t)fMajorVersion);
646 //______________________________________________________________________
647 void AliITSInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
648 Int_t &cpn1,Int_t &cpn2){
649 // decode geometry into detector module number. There are two decoding
650 // Scheams. Old which does not follow the ALICE coordinate system
651 // requirements, and New which dose.
653 // Int_t mod The module number assoicated with this set
656 // Int_t cpn0 The lowest copy number
657 // Int_t cpn1 The middle copy number
658 // Int_t cpn2 the highest copy number
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){
666 Error("RecodeDetector","Major version = kvDefault, not supported");
670 return RecodeDetectorv11(mod,cpn0,cpn1,cpn2);
673 Error("RecodeDetector","Major version = %d, not supported",
674 (Int_t)fMajorVersion);
680 //______________________________________________________________________
681 void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
682 Int_t &lad,Int_t &det){
683 // decode geometry into detector module number. There are two decoding
684 // Scheams. Old which does not follow the ALICE coordinate system
685 // requirements, and New which dose. Note, this use of layer ladder
686 // and detector numbers are strictly for internal use of this
687 // specific code. They do not represent the "standard" layer ladder
688 // or detector numbering except in a very old and obsoleate sence.
690 // Int_t mod The module number assoicated with this set
693 // Int_t lay The layer number
694 // Int_t lad The ladder number
695 // Int_t det the dettector number
699 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
700 // like them but I see not better way for the moment.
701 switch (fMajorVersion) {
703 Error("DecodeDetectorLayers",
704 "Major version = kvDefault, not supported");
708 return DecodeDetectorLayersv11(mod,layer,lad,det);
711 Error("DecodeDetectorLayers","Major version = %d, not supported",
712 (Int_t)fMajorVersion);
719 //______________________________________________________________________
720 void AliITSInitGeometry::DecodeDetectorv11(Int_t &mod,Int_t layer,
721 Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
722 // decode geometry into detector module number
724 // Int_t layer The ITS layer
725 // Int_t cpn0 The lowest copy number
726 // Int_t cpn1 The middle copy number
727 // Int_t cpn2 the highest copy number
729 // Int_t &mod The module number assoicated with this set
733 const Int_t kDetPerLadderSPD[2]={2,4};
734 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
735 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
740 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
755 for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
756 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
761 //______________________________________________________________________
762 void AliITSInitGeometry::RecodeDetectorv11(Int_t mod,Int_t &cpn0,
763 Int_t &cpn1,Int_t &cpn2) {
764 // decode geometry into detector module number using the new decoding
767 // Int_t mod The module number assoicated with this set
770 // Int_t cpn0 The lowest copy number (SPD sector or SDD/SSD ladder)
771 // Int_t cpn1 The middle copy number (SPD stave or SDD/SSD module)
772 // Int_t cpn2 the highest copy number (SPD ladder or 1 for SDD/SSD)
775 const Int_t kDetPerLadderSPD[2]={2,4};
778 DecodeDetectorLayersv11(mod,lay,lad,det);
780 cpn2 = det; // Detector 1-4
781 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
782 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
783 } else { // SDD and SSD
793 } // end if Lay<5/else
794 } // end if lay<3/else
799 //______________________________________________________________________
800 void AliITSInitGeometry::DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
801 Int_t &lad,Int_t &det) {
803 // decode module number into detector indices for v11
805 // lay, lad, det start from 1
808 // Int_t mod The module number associated with this set
811 // Int_t lay The layer number
812 // Int_t lad The ladder number
813 // Int_t det the dettector number
815 const Int_t kDetPerLadder[6] = {4,4,6,8,22,25};
816 const Int_t kLadPerLayer[6] = {20,40,14,22,34,38};
822 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
824 } while(mod2<=mod); // end while
825 if(lay>6) Error("DecodeDetectorLayers","lay=%d>6",lay);
827 mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod;
828 lad = mod2/kDetPerLadder[lay-1];
830 if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers",
831 "lad=%d not in the correct range",lad);
832 det = (mod2 - lad*kDetPerLadder[lay-1])+1;
833 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
834 "det=%d not in the correct range",det);
838 //______________________________________________________________________
839 Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,AliITSVersion_t maj)const{
840 // fills the string str with the major version number
842 // Char_t *str The character string to hold the major version number
843 // Int_t length The maximum number of characters which
844 // can be accommodated by this string.
845 // str[length-1] must exist
846 // AliITSVersion_t maj The major number
849 Int_t i = (Int_t)maj;
851 snprintf(str,length-1,"Major Version= %d",i);
854 //______________________________________________________________________
855 Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,AliITSVersion_t &maj)const{
856 // fills the string str with the major and minor version number
858 // Char_t *str The character string to holding the major version number
859 // Int_t length The maximum number of characters which can be
860 // accommodated by this string. str[length-1] must exist
862 // AliITSVersion_t maj The major number
865 // kTRUE if no errors
867 Bool_t retcode=kFALSE;
869 if(n<15) return retcode; // not enough space for numbers
871 m = sscanf(str,"Major Version= %d",&i);