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 <TGeoVolume.h>
31 #include <TGeoShape.h>
38 #include <TGeoSphere.h>
47 #include "AliITSgeomSPD.h"
48 #include "AliITSgeomSDD.h"
49 #include "AliITSgeomSSD.h"
50 #include "AliITSsegmentationSPD.h"
51 #include "AliITSsegmentationSDD.h"
52 #include "AliITSsegmentationSSD.h"
53 #include "AliITSInitGeometry.h"
56 ClassImp(AliITSInitGeometry)
58 const Bool_t AliITSInitGeometry::fgkOldSPDbarrel = kFALSE;
59 const Bool_t AliITSInitGeometry::fgkOldSDDbarrel = kFALSE;
60 const Bool_t AliITSInitGeometry::fgkOldSSDbarrel = kFALSE;
61 const Bool_t AliITSInitGeometry::fgkOldSDDcone = kTRUE;
62 const Bool_t AliITSInitGeometry::fgkOldSSDcone = kTRUE;
63 const Bool_t AliITSInitGeometry::fgkOldSPDshield = kTRUE;
64 const Bool_t AliITSInitGeometry::fgkOldSDDshield = kTRUE;
65 const Bool_t AliITSInitGeometry::fgkOldSSDshield = kTRUE;
66 const Bool_t AliITSInitGeometry::fgkOldServices = kTRUE;
67 const Bool_t AliITSInitGeometry::fgkOldSupports = kTRUE;
68 //______________________________________________________________________
69 AliITSInitGeometry::AliITSInitGeometry():
70 TObject(), // Base Class
71 fName(0), // Geometry name
72 fMinorVersion(-1), // Minor version number/type
73 fMajorVersion(kvDefault), // Major versin number
74 fTiming(kFALSE), // Flag to start inilization timing
75 fSegGeom(kFALSE), // Flag to switch between the old use of
76 // AliITSgeomS?D class, or AliITSsegmentation
77 // class in fShape of AliITSgeom class.
78 fDecode(kFALSE), // Flag for new/old decoding
79 fDebug(0){ // Debug flag
86 // A default inilized AliITSInitGeometry object
90 //______________________________________________________________________
91 AliITSInitGeometry::AliITSInitGeometry(AliITSVersion_t version,
93 TObject(), // Base Class
94 fName(0), // Geometry name
95 fMinorVersion(minorversion), // Minor version number/type
96 fMajorVersion(version), // Major versin number
97 fTiming(kFALSE), // Flag to start inilization timing
98 fSegGeom(kFALSE), // Flag to switch between the old use of
99 // AliITSgeomS?D class, or AliITSsegmentation
100 // class in fShape of AliITSgeom class.
101 fDecode(kFALSE), // Flag for new/old decoding
102 fDebug(0){ // Debug flag
109 // A default inilized AliITSInitGeometry object
111 if(version == kvPPRasymmFMD && (fMinorVersion==1|| fMinorVersion==2)){
112 fName="AliITSvPPRasymmFMD";
113 }else if(version == kv11Hybrid){
114 fName="AliITSv11Hybrid";
116 AliFatal(Form("Undefined geometry: fMajorVersion=%d, "
117 "fMinorVersion= %d",(Int_t)fMajorVersion,fMinorVersion));
122 //______________________________________________________________________
123 AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(){
124 // Creates and Initilizes the geometry transformation class AliITSgeom
125 // to values appropreate to this specific geometry. Now that
126 // the segmentation is part of AliITSgeom, the detector
127 // segmentations are also defined here.
133 // A pointer to a new properly inilized AliITSgeom class. If
134 // pointer = 0 then failed to init.
137 AliITSVersion_t version = kvDefault;
140 TGeoVolume *itsV = gGeoManager->GetVolume("ITSV");
142 Error("CreateAliITSgeom","Can't find ITS volume ITSV, aborting");
145 const Char_t *title = itsV->GetTitle();
146 if(!ReadVersionString(title,(Int_t)strlen(title),version,minor,
148 Warning("UpdateInternalGeometry","Can't read title=%s\n",title);
152 AliITSgeom *geom = CreateAliITSgeom(version,minor);
153 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
156 //______________________________________________________________________
157 AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(Int_t major,Int_t minor){
158 // Creates and Initilizes the geometry transformation class AliITSgeom
159 // to values appropreate to this specific geometry. Now that
160 // the segmentation is part of AliITSgeom, the detector
161 // segmentations are also defined here.
163 // Int_t major major version, see AliITSVersion_t
164 // Int_t minor minor version
168 // A pointer to a new properly inilized AliITSgeom class. If
169 // pointer = 0 then failed to init.
173 SetGeometryName("AliITSvtest");
174 SetVersion(kvtest,minor);
177 SetGeometryName("AliITSvSPD02");
178 SetVersion(kvSPD02,minor);
181 SetGeometryName("AliITSvSDD03");
182 SetVersion(kvSDD03,minor);
185 SetGeometryName("AliITSvSSD03");
186 SetVersion(kvSSD03,minor);
189 SetGeometryName("AliITSvBeamTest03");
190 SetVersion(kvITS04,minor);
192 case kvPPRcourseasymm:
193 SetGeometryName("AliITSvPPRcourseasymm");
194 SetVersion(kvPPRcourseasymm,minor);
197 SetGeometryName("AliITSvPPRasymmFMD");
198 SetVersion(kvPPRasymmFMD,minor);
201 SetGeometryName("AliITSv11");
202 SetVersion(kv11,minor);
205 SetGeometryName("AliITSv11Hybrid");
206 SetVersion(kv11Hybrid,minor);
210 SetGeometryName("Undefined");
211 SetVersion(kvDefault,minor);
214 AliITSgeom *geom = new AliITSgeom();
215 if(!InitAliITSgeom(geom)){ // Error initilization failed
221 //______________________________________________________________________
222 Bool_t AliITSInitGeometry::InitAliITSgeom(AliITSgeom *geom){
223 // Initilizes the geometry transformation class AliITSgeom
224 // to values appropreate to this specific geometry. Now that
225 // the segmentation is part of AliITSgeom, the detector
226 // segmentations are also defined here.
228 // AliITSgeom *geom A pointer to the AliITSgeom class
230 // AliITSgeom *geom This pointer recreated and properly inilized.
235 AliFatal("The geometry manager has not been initialized (e.g. "
236 "TGeoManager::Import(\"geometry.root\")should be "
237 "called in advance) - exit forced");
240 switch(fMajorVersion) {
242 if(GetMinorVersion()==1) return InitAliITSgeomPPRasymmFMD(geom);
243 else if(GetMinorVersion()==2) return InitAliITSgeomtest2(geom);
246 return InitAliITSgeomSPD02(geom);
249 return InitAliITSgeomSDD03(geom);
252 return InitAliITSgeomSSD03(geom);
255 return InitAliITSgeomITS04(geom);
257 case kvPPRasymmFMD: {
258 return InitAliITSgeomPPRasymmFMD(geom);
260 case kvPPRcourseasymm: {
261 return kTRUE; // No sensitive detectors in course geometry
264 return InitAliITSgeomV11Hybrid(geom);
267 return InitAliITSgeomV11(geom);
269 case kvDefault: default: {
270 AliFatal("Undefined geometry");
276 //______________________________________________________________________
277 void AliITSInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
278 // Transpose the rotation matrix part of a TGeoHMatrix. This
279 // is needed because TGeo stores the transpose of the rotation
280 // matrix as compared to what AliITSgeomMatrix uses (and Geant3).
282 // TGeoHMatrix *m The matrix to be transposed
284 // TGEoHMatrix *m The transposed matrix
290 if(m==0) return; // no matrix to transpose.
291 for(i=0;i<9;i += 4) r[i] = m->GetRotationMatrix()[i]; // diagonals
292 r[1] = m->GetRotationMatrix()[3];
293 r[2] = m->GetRotationMatrix()[6];
294 r[3] = m->GetRotationMatrix()[1];
295 r[5] = m->GetRotationMatrix()[7];
296 r[6] = m->GetRotationMatrix()[2];
297 r[7] = m->GetRotationMatrix()[5];
301 //______________________________________________________________________
302 Bool_t AliITSInitGeometry::InitAliITSgeomtest2(AliITSgeom *geom){
303 // Initilizes the geometry transformation class AliITSgeom
304 // to values appropreate to this specific geometry. Now that
305 // the segmentation is part of AliITSgeom, the detector
306 // segmentations are also defined here.
308 // AliITSgeom *geom A pointer to the AliITSgeom class
310 // AliITSgeom *geom This pointer recreated and properly inilized.
313 // const Double_t kcm2micron = 1.0E4;
314 const Int_t kItype=0; // Type of transormation defined 0=> Geant
315 const Int_t klayers = 6; // number of layers in the ITS
316 const Int_t kladders[klayers] = {1,1,1,1,1,1}; // Number of ladders
317 const Int_t kdetectors[klayers] = {1,1,1,1,1,1};// number of detector/lad
318 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
319 const TString kNames[klayers] = {
320 "/ALIC_1/ITSV_1/ITSspd1_1/ITS1_1", // lay=1
321 "/ALIC_1/ITSV_1/ITSspd2_1/ITS2_1", // lay=2
322 "/ALIC_1/ITSV_1/ITSsdd1_1/ITS3_1", // lay=3
323 "/ALIC_1/ITSV_1/ITSsdd2_1/ITS4_1", // lay=4
324 "/ALIC_1/ITSV_1/ITSssd1_1/ITS5_1", // lay=5
325 "/ALIC_1/ITSV_1/ITSssd2_1/ITS6_1"};// Lay=6
326 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2;
327 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
331 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
332 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
334 if(fTiming) time->Start();
335 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
336 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
337 for(mod=0;mod<nmods;mod++){
338 DecodeDetectorLayers(mod,lay,lad,det); // Write
339 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
340 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
341 geom->GetGeomMatrix(mod)->SetPath(kNames[lay-1]);
342 GetTransformation(kNames[lay-1].Data(),matrix);
343 geom->SetTrans(mod,matrix.GetTranslation());
344 TransposeTGeoHMatrix(&matrix); // Transpose TGeo's rotation matrixes
345 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
346 if(initSeg[kIdet[lay-1]]) continue;
347 GetShape(kNames[lay-1],shapeName,shapePar);
348 if(shapeName.CompareTo("BOX")){
349 Error("InitITSgeom2","Geometry changed without proper code update"
350 "or error in reading geometry. Shape is not BOX shape is %s",
354 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
363 //______________________________________________________________________
364 Bool_t AliITSInitGeometry::InitAliITSgeomSPD02(AliITSgeom *geom){
365 // Initilizes the geometry transformation class AliITSgeom
366 // to values appropreate to this specific geometry. Now that
367 // the segmentation is part of AliITSgeom, the detector
368 // segmentations are also defined here.
370 // AliITSgeom *geom A pointer to the AliITSgeom class
372 // AliITSgeom *geom This pointer recreated and properly inilized.
375 const Int_t kltypess=2;
376 const Int_t knlayers=5;
377 const TString knames[kltypess]=
378 {"ALIC_1/ITSV_1/ITEL_%d/IMB0_1/IMBS_1",//lay=1,2,4,5
379 "ALIC_1/ITSV_1/IDET_%d/ITS0_1/ITST_1"};// lay=3
380 const Int_t kitsGeomTreeCopys[2]={4,1};
381 const Int_t knlad[knlayers]={knlayers*1},kndet[knlayers]={knlayers*1};
382 TString path,shapeName;
386 Double_t trans[3]={3*0.0},rot[10]={10*0.0};
387 Int_t npar=3,mod,i,j,lay,lad,det,cpy;
389 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
391 par[0]=0.64;par[1]=0.5*300.0E-4;par[2]=3.48;
393 geom->Init(0,knlayers,knlad,kndet,mod);
395 if(fTiming) time->Start();
396 for(i=0;i<kltypess;i++)for(cpy=1;cpy<=kitsGeomTreeCopys[i];cpy++){
397 path.Form(knames[i].Data(),cpy);
398 GetTransformation(path.Data(),matrix);
399 GetShape(path.Data(),shapeName,shapePar);
400 shapeParF.Set(shapePar.GetSize());
401 for(j=0;j<shapePar.GetSize();j++) shapeParF[j]=shapePar[j];
403 if(i==0&&cpy>2) lay=cpy+1;
405 DecodeDetector(mod,kitsGeomTreeCopys[i],1,cpy,0);
406 DecodeDetectorLayers(mod,lay,lad,det);
407 geom->CreateMatrix(mod,lay,lad,det,kSPD,trans,rot);
408 geom->SetTrans(mod,matrix.GetTranslation());
409 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
410 geom->GetGeomMatrix(mod)->SetPath(path.Data());
411 if(!(geom->IsShapeDefined((Int_t)kSPD)))
412 geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(npar,par));
421 //______________________________________________________________________
422 Bool_t AliITSInitGeometry::InitAliITSgeomSDD03(AliITSgeom *geom){
423 // Initilizes the geometry transformation class AliITSgeom
424 // to values appropreate to this specific geometry. Now that
425 // the segmentation is part of AliITSgeom, the detector
426 // segmentations are also defined here.
428 // AliITSgeom *geom A pointer to the AliITSgeom class
430 // AliITSgeom *geom This pointer recreated and properly inilized.
433 const Int_t knlayers=12;
434 // const Int_t kndeep=6;
435 const Int_t kltypess=2;
436 const AliITSDetector kidet[knlayers]={kSSD,kSDD};
437 const TString knames[kltypess]={
438 "/ALIC_1/ITSV_1/ITEL_%d/ITAI_1/IMB0_1/IMBS_1",
439 "/ALIC_1/ITSV_1/IDET_%d/IDAI_1/ITS0_1/ITST_1"};
440 const Int_t kitsGeomTreeCopys[kltypess]={10,2};
442 const Float_t kpitch=50.E-4;/*cm*/
443 Float_t box[3]={0.5*kpitch*(Float_t)knp,150.E-4,1.0},p[knp+1],n[knp+1];
444 Int_t nlad[knlayers]={knlayers*1};
445 Int_t ndet[knlayers]={knlayers*1};
446 Int_t mod=knlayers,lay=0,lad=0,det=0,i,j,cp0;
447 TString path,shapeName;
449 Double_t trans[3]={3*0.0},rot[10]={10*0.0};
452 Bool_t isShapeDefined[kltypess]={kltypess*kFALSE};
454 geom->Init(0,knlayers,nlad,ndet,mod);
457 // Fill in anode and cathode strip locations (lower edge)
464 for(i=0;i<kltypess;i++)for(cp0=1;cp0<=kitsGeomTreeCopys[i];cp0++){
465 DecodeDetector(mod,kitsGeomTreeCopys[i],cp0,1,2);
466 DecodeDetectorLayers(mod,lay,lad,det);
467 path.Form(knames[i].Data(),cp0);
468 GetTransformation(path.Data(),matrix);
469 GetShape(path.Data(),shapeName,shapePar);
470 shapeParF.Set(shapePar.GetSize());
471 for(j=0;j<shapePar.GetSize();j++)shapeParF[j]=shapePar[j];
472 geom->CreateMatrix(mod,lay,lad,det,kidet[i],trans,rot);
473 geom->SetTrans(mod,matrix.GetTranslation());
474 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
475 geom->GetGeomMatrix(mod)->SetPath(path.Data());
477 case kSDD: if(!(geom->IsShapeDefined((Int_t)kSDD))){
478 geom->ReSetShape(kSDD,new AliITSgeomSDD256(shapeParF.GetSize(),
479 shapeParF.GetArray()));
480 isShapeDefined[i]=kTRUE;
482 case kSSD:if(!(geom->IsShapeDefined((Int_t)kSSD))){
483 geom->ReSetShape(kSSD,new AliITSgeomSSD(box,0.0,0.0,
485 isShapeDefined[i]=kTRUE;
493 //______________________________________________________________________
494 Bool_t AliITSInitGeometry::InitAliITSgeomSSD03(AliITSgeom *geom){
495 // Initilizes the geometry transformation class AliITSgeom
496 // to values appropreate to this specific geometry. Now that
497 // the segmentation is part of AliITSgeom, the detector
498 // segmentations are also defined here.
500 // AliITSgeom *geom A pointer to the AliITSgeom class
502 // AliITSgeom *geom This pointer recreated and properly inilized.
505 const Int_t knlayers=5;
506 // const Int_t kndeep=6;
507 const Int_t kltypess=3;
508 const AliITSDetector kIdet[knlayers]={kND,kSSD,kND};
509 const TString knames[kltypess]={
510 "/ALIC_1/ITSV_1/ITSA_%d/ITSS_1",
511 "/ALIC_1/ITSV_1/IGAR_%d/IAIR_1/ITST_1",
512 "/ALIC_1/ITSV_1/IFRA_%d/IFRS_1"};
513 const Int_t kitsGeomTreeCopys[kltypess]={3,1,1};
514 const Int_t kitsGeomDetTypes[kltypess]={1,2,3};
516 const Float_t kpitch=50.E-4;//cm
517 Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
518 Float_t box[3]={0.5*kpitch*(Float_t)knp,150.E-4,1.0},p[knp+1],n[knp+1];
519 Int_t nlad[knlayers]={knlayers*1};
520 Int_t ndet[knlayers]={knlayers*1};
521 Int_t mod=knlayers,lay=0,lad=0,det=0,i,j,cp0;
522 TString path,shapeName;
524 Double_t trans[3]={3*0.0},rot[10]={10*0.0};
527 Bool_t isShapeDefined[kltypess]={kltypess*kFALSE};
529 geom->Init(0,knlayers,nlad,ndet,mod);
532 // Fill in anode and cathode strip locations (lower edge)
539 for(i=0;i<kltypess;i++)for(cp0=1;cp0<=kitsGeomTreeCopys[i];cp0++){
540 DecodeDetector(mod,kitsGeomDetTypes[i],cp0,1,0);
541 DecodeDetectorLayers(mod,lay,lad,det);
542 path.Form(knames[i].Data(),cp0);
543 GetTransformation(path.Data(),matrix);
544 GetShape(path.Data(),shapeName,shapePar);
545 shapeParF.Set(shapePar.GetSize());
546 for(j=0;j<shapePar.GetSize();j++)shapeParF[j]=shapePar[j];
547 geom->CreateMatrix(mod,lay,lad,det,kIdet[i],trans,rot);
548 geom->SetTrans(mod,matrix.GetTranslation());
549 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
550 geom->GetGeomMatrix(mod)->SetPath(path.Data());
552 case kSSD:if(!(geom->IsShapeDefined((Int_t)kSSD))){
553 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
554 isShapeDefined[i]=kTRUE;
562 //______________________________________________________________________
563 Bool_t AliITSInitGeometry::InitAliITSgeomITS04(AliITSgeom *geom) const{
564 // Initilizes the geometry transformation class AliITSgeom
565 // to values appropreate to this specific geometry. Now that
566 // the segmentation is part of AliITSgeom, the detector
567 // segmentations are also defined here.
569 // AliITSgeom *geom A pointer to the AliITSgeom class
571 // AliITSgeom *geom This pointer recreated and properly inilized.
575 // We can not use AliITSvBeamTestITS04::fgk... data members because
576 // AliITSInitGeometry is part of the base library while AliITSvBeamTestITS04
577 // is part of the simulation library. This would introduce a dependance
578 // between the 2 libraries
581 const Int_t knlayers = 6;
582 Int_t nlad[knlayers], ndet[knlayers];
584 nlad[0] = 1; ndet[0] = 2;
585 nlad[1] = 1; ndet[1] = 2;
586 nlad[2] = 1; ndet[2] = 1;
587 nlad[3] = 1; ndet[3] = 1;
588 nlad[4] = 1; ndet[4] = 2;
589 nlad[5] = 1; ndet[5] = 2;
592 geom->Init(0,knlayers,nlad,ndet,nModTot);
595 //=== Set default shapes
596 const Float_t kDxyzSPD[] = {AliITSvBeamTestITS04::fgkSPDwidthSens/2,
597 AliITSvBeamTestITS04::fgkSPDthickSens/2,
598 AliITSvBeamTestITS04::fgkSPDlengthSens/2};
599 if(!(geom->IsShapeDefined(kSPD)))
600 geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(3,(Float_t *)kDxyzSPD));
602 const Float_t kDxyzSDD[] = {AliITSvBeamTestITS04::fgkSDDwidthSens/2.,
603 AliITSvBeamTestITS04::fgkSDDthickSens/2.,
604 AliITSvBeamTestITS04::fgkSDDlengthSens/2.};
605 if(!(geom->IsShapeDefined(kSDD)))
606 geom->ReSetShape(kSDD, new AliITSgeomSDD256(3,(Float_t *)kDxyzSDD));
608 const Float_t kDxyzSSD[] = {AliITSvBeamTestITS04::fgkSSDlengthSens/2,
609 AliITSvBeamTestITS04::fgkSSDthickSens/2,
610 AliITSvBeamTestITS04::fgkSSDwidthSens/2};
611 if(!(geom->IsShapeDefined(kSSD)))
612 geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(3,(Float_t *)kDxyzSSD));
614 // Creating the matrices in AliITSgeom for each sensitive volume
615 // (like in AliITSv11GeometrySDD) mln
616 // Here, each layer is one detector
619 Int_t startMod = 0,mod;
620 TGeoVolume *itsmotherVolume = gGeoManager->GetVolume("ITSV");
622 for (Int_t i=0; i<4;i++) {
623 sprintf(layerName, "ITSspdWafer_%i",i+1);
624 TGeoNode *layNode = itsmotherVolume->GetNode(layerName);
626 TGeoHMatrix layMatrix(*layNode->GetMatrix());
627 Double_t *trans = layMatrix.GetTranslation();
628 Double_t *r = layMatrix.GetRotationMatrix();
629 Double_t rot[10] = {r[0],r[1],r[2],
631 r[6],r[7],r[8], 1.0};
635 DecodeDetector(mod,layNode->GetNumber(),i+1,0,0);
636 DecodeDetectorLayers(mod,iLay,iLad,iDet);
637 geom->CreateMatrix(startMod,iLay,iLad,iDet,kSPD,trans,rot);
643 for (Int_t i=0; i<2;i++) {
644 sprintf(layerName, "ITSsddWafer_%i",i+4+1);
645 TGeoNode *layNode = itsmotherVolume->GetNode(layerName);
647 TGeoHMatrix layMatrix(*layNode->GetMatrix());
648 Double_t *trans = layMatrix.GetTranslation();
649 Double_t *r = layMatrix.GetRotationMatrix();
650 Double_t rot[10] = {r[0],r[1],r[2],
652 r[6],r[7],r[8], 1.0};
656 DecodeDetector(mod,layNode->GetNumber(),i+1,0,0);
657 DecodeDetectorLayers(mod,iLay,iLad,iDet);
658 geom->CreateMatrix(startMod,iLay,iLad,iDet,kSDD,trans,rot);
664 for (Int_t i=0; i<4;i++) {
665 sprintf(layerName, "ITSssdWafer_%i",i+4+2+1);
666 TGeoNode *layNode = itsmotherVolume->GetNode(layerName);
668 TGeoHMatrix layMatrix(*layNode->GetMatrix());
669 Double_t *trans = layMatrix.GetTranslation();
670 Double_t *r = layMatrix.GetRotationMatrix();
671 Double_t rot[10] = {r[0],r[1],r[2],
673 r[6],r[7],r[8], 1.0};
677 DecodeDetector(mod,layNode->GetNumber(),i+1,0,0);
678 DecodeDetectorLayers(mod,iLay,iLad,iDet);
679 geom->CreateMatrix(startMod,iLay,iLad,iDet,kSSD,trans,rot);
688 //______________________________________________________________________
689 Bool_t AliITSInitGeometry::InitAliITSgeomPPRasymmFMD(AliITSgeom *geom){
690 // Initilizes the geometry transformation class AliITSgeom
691 // to values appropreate to this specific geometry. Now that
692 // the segmentation is part of AliITSgeom, the detector
693 // segmentations are also defined here.
695 // AliITSgeom *geom A pointer to the AliITSgeom class
697 // AliITSgeom *geom This pointer recreated and properly inilized.
700 // const Double_t kcm2micron = 1.0E4;
701 const Int_t kItype=0; // Type of transormation defined 0=> Geant
702 const Int_t klayers = 6; // number of layers in the ITS
703 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
704 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
705 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
706 const TString kPathbase = "/ALIC_1/ITSV_1/ITSD_1/";
707 const TString kNames[2][klayers] = {
708 {"%sIT12_1/I12A_%d/I10A_%d/I103_%d/I101_1/ITS1_1", // lay=1
709 "%sIT12_1/I12A_%d/I20A_%d/I1D3_%d/I1D1_1/ITS2_1", // lay=2
710 "%sIT34_1/I004_%d/I302_%d/ITS3_%d/", // lay=3
711 "%sIT34_1/I005_%d/I402_%d/ITS4_%d/", // lay=4
712 "%sIT56_1/I565_%d/I562_%d/ITS5_%d/", // lay=5
713 "%sIT56_1/I569_%d/I566_%d/ITS6_%d/"},// lay=6
714 // {"%sIT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
715 // "%sIT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
716 {"%sIT12_1/I12B_%d/I10B_%d/L1H-STAVE%d_1/I107_%d/I101_1/ITS1_1", // lay=1
717 "%sIT12_1/I12B_%d/I20B_%d/L2H-STAVE%d_1/I1D7_%d/I1D1_1/ITS2_1", // lay=2
718 "%sIT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
719 "%sIT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
720 "%sIT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
721 "%sIT56_1/I569_%d/I566_%d/ITS6_%d"}};// Lay=6
723 Int_t itsGeomTreeCopys[knlayers][3]= {{10, 2, 4},// lay=1
730 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2, cpnHS;
731 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
733 TString path,shapeName;
735 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
736 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
738 if(fTiming) time->Start();
739 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
740 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
741 for(mod=0;mod<nmods;mod++){
742 DecodeDetectorLayers(mod,lay,lad,det); // Write
743 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
744 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
746 if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
747 if (det<3) cpnHS = 0; else cpnHS = 1;
748 path.Form(kNames[fMinorVersion-1][lay-1].Data(),kPathbase.Data(),
749 cpn0,cpn1,cpnHS,cpn2);
751 path.Form(kNames[fMinorVersion-1][lay-1].Data(),kPathbase.Data(),
754 // path.Form(kNames[fMinorVersion-1][lay-1].Data(),
755 // kPathbase.Data(),cpn0,cpn1,cpn2);
757 geom->GetGeomMatrix(mod)->SetPath(path);
758 GetTransformation(path.Data(),matrix);
759 geom->SetTrans(mod,matrix.GetTranslation());
760 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
761 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
762 if(initSeg[kIdet[lay-1]]) continue;
763 GetShape(path,shapeName,shapePar);
764 if(shapeName.CompareTo("BOX")){
765 Error("InitITSgeomPPRasymmFMD",
766 "Geometry changed without proper code update or error "
767 "in reading geometry. Shape is not BOX. Shape is %s",
771 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
780 //______________________________________________________________________
781 Bool_t AliITSInitGeometry::InitAliITSgeomV11Hybrid(AliITSgeom *geom){
782 // Initilizes the geometry transformation class AliITSgeom
783 // to values appropreate to this specific geometry. Now that
784 // the segmentation is part of AliITSgeom, the detector
785 // segmentations are also defined here.
787 // AliITSgeom *geom A pointer to the AliITSgeom class
789 // AliITSgeom *geom This pointer recreated and properly inilized.
793 const Int_t kItype = 0; // Type of transformation defined 0=> Geant
794 const Int_t klayers = 6; // number of layers in the ITS
795 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
796 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
797 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
798 const TString kPathbase = "/ALIC_1/ITSV_1/";
800 char *pathSPDsens1, *pathSPDsens2;
801 if (SPDIsTGeoNative()) {
802 pathSPDsens1="%sITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/LAY1_STAVE_%d/HALF-STAVE%d_1/LAY1_LADDER_%d/LAY1_SENSOR_1";
803 pathSPDsens2="%sITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/LAY2_STAVE_%d/HALF-STAVE%d_1/LAY2_LADDER_%d/LAY2_SENSOR_1";
805 pathSPDsens1 = "%sITSD_1/IT12_1/I12B_%d/I10B_%d/L1H-STAVE%d_1/I107_%d/I101_1/ITS1_1";
806 pathSPDsens2 = "%sITSD_1/IT12_1/I12B_%d/I20B_%d/L2H-STAVE%d_1/I1D7_%d/I1D1_1/ITS2_1";
809 char *pathSDDsens1, *pathSDDsens2;
810 if (SDDIsTGeoNative()) {
811 pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
812 pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
814 pathSDDsens1 = "%sITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d";
815 pathSDDsens2 = "%sITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d";
818 char *pathSSDsens1, *pathSSDsens2;
819 if (SSDIsTGeoNative()) {
820 pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSsddSensor5_%d/ITSsddSensitivL5_1";
821 pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSsddSensor6_%d/ITSsddSensitivL6_1";
823 pathSSDsens1 = "%sITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d";
824 pathSSDsens2 = "%sITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d";
827 const TString kNames[klayers] = {
828 pathSPDsens1, // lay=1
829 pathSPDsens2, // lay=2
830 pathSDDsens1, // lay=3
831 pathSDDsens2, // lay=4
832 pathSSDsens1, // lay=5
833 pathSSDsens2};// Lay=6
835 Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1;
836 Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
838 TString path, shapeName;
840 Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
841 TStopwatch *time = 0x0;
842 if(fTiming) time = new TStopwatch();
844 if(fTiming) time->Start();
845 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
846 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
848 for(mod=0; mod<nmods; mod++) {
850 DecodeDetectorLayers(mod,lay,lad,det);
851 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
852 RecodeDetectorv11Hybrid(mod,cpn0,cpn1,cpn2);
854 // if (SPDIsTGeoNative())
855 // if (kIdet[lay-1]==kSPD) {
860 // if (SDDIsTGeoNative())
861 // if (kIdet[lay-1]==kSDD) {
866 // if (SSDIsTGeoNative())
867 // if (kIdet[lay-1]==kSSD) {
873 if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
874 if (det<3) cpnHS = 0; else cpnHS = 1;
875 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2);
877 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2);
880 geom->GetGeomMatrix(mod)->SetPath(path);
881 GetTransformation(path.Data(),matrix);
882 geom->SetTrans(mod,matrix.GetTranslation());
883 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
884 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
885 if(initSeg[kIdet[lay-1]]) continue;
886 GetShape(path,shapeName,shapePar);
887 if(shapeName.CompareTo("BOX")){
888 Error("InitITSgeom","Geometry changed without proper code update"
889 "or error in reading geometry. Shape is not BOX.");
892 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
902 //______________________________________________________________________
903 Bool_t AliITSInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
904 // Initilizes the geometry transformation class AliITSgeom
905 // Now that the segmentation is part of AliITSgeom, the detector
906 // segmentations are also defined here.
909 // AliITSgeom *geom A pointer to the AliITSgeom class
911 // AliITSgeom *geom This pointer recreated and properly inilized.
915 const Int_t kItype=0; // Type of transormation defined 0=> Geant
916 const Int_t klayers = 6; // number of layers in the ITS
917 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
918 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
919 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
921 const TString kPathbase = "/ALIC_1/ITSV_1/";
922 const TString kNames[klayers] =
923 {"AliITSInitGeometry:spd missing", // lay=1
924 "AliITSInitGeometry:spd missing", // lay=2
925 "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_1/ITSsddSensitiv_1", // lay=3
926 "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_1/ITSsddSensitiv_1", // lay=4
927 "AliITSInitGeometry:ssd missing", // lay=5
928 "AliITSInitGeometry:ssd missing"};// lay=6
930 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2;
931 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
933 TString path,shapeName;
935 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
936 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
938 if(fTiming) time->Start();
939 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
941 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
942 for(mod=0;mod<nmods;mod++) {
944 DecodeDetectorLayers(mod,lay,lad,det); // Write
945 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
946 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
947 path.Form(kNames[lay-1].Data(),
948 kPathbase.Data(),cpn0,cpn1,cpn2);
949 geom->GetGeomMatrix(mod)->SetPath(path);
950 if (GetTransformation(path.Data(),matrix)) {
951 geom->SetTrans(mod,matrix.GetTranslation());
952 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
953 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
956 if(initSeg[kIdet[lay-1]]) continue;
957 GetShape(path,shapeName,shapePar);
958 if(shapeName.CompareTo("BOX")){
959 Error("InitAliITSgeomV11","Geometry changed without proper code update"
960 "or error in reading geometry. Shape is not BOX.");
963 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
975 //______________________________________________________________________
976 Bool_t AliITSInitGeometry::InitGeomShapePPRasymmFMD(AliITSDetector idet,
980 // Initilizes the geometry segmentation class AliITSgeomS?D, or
981 // AliITSsegmentationS?D depending on the vaule of fSegGeom,
982 // to values appropreate to this specific geometry. Now that
983 // the segmentation is part of AliITSgeom, the detector
984 // segmentations are also defined here.
986 // Int_t lay The layer number/name.
987 // AliITSgeom *geom A pointer to the AliITSgeom class
989 // AliITSgeom *geom This pointer recreated and properly inilized.
992 // const Double_t kcm2micron = 1.0E4;
993 const Double_t kmicron2cm = 1.0E-4;
997 shapeParF.Set(shapePar.GetSize());
998 for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
1001 initSeg[idet] = kTRUE;
1002 AliITSgeomSPD *geomSPD = new AliITSgeomSPD425Short();
1003 Float_t bx[256],bz[280];
1004 for(i=000;i<256;i++) bx[i] = 50.0*kmicron2cm; // in x all are 50 microns.
1005 for(i=000;i<160;i++) bz[i] = 425.0*kmicron2cm; // most are 425 microns
1007 for(i=160;i<280;i++) bz[i] = 0.0*kmicron2cm; // Outside of detector.
1008 bz[ 31] = bz[ 32] = 625.0*kmicron2cm; // first chip boundry
1009 bz[ 63] = bz[ 64] = 625.0*kmicron2cm; // first chip boundry
1010 bz[ 95] = bz[ 96] = 625.0*kmicron2cm; // first chip boundry
1011 bz[127] = bz[128] = 625.0*kmicron2cm; // first chip boundry
1012 bz[160] = 425.0*kmicron2cm;// Set so that there is no zero pixel size for fNz.
1013 geomSPD->ReSetBins(shapeParF[1],256,bx,160,bz);
1014 geom->ReSetShape(idet,geomSPD);
1017 initSeg[idet] = kTRUE;
1018 AliITSgeomSDD *geomSDD = new AliITSgeomSDD256(shapeParF.GetSize(),
1019 shapeParF.GetArray());
1020 geom->ReSetShape(idet,geomSDD);
1023 initSeg[idet] = kTRUE;
1024 AliITSgeomSSD *geomSSD = new AliITSgeomSSD275and75(
1025 shapeParF.GetSize(),shapeParF.GetArray());
1026 geom->ReSetShape(idet,geomSSD);
1028 default:{// Others, Note no kSDDp or kSSDp in this geometry.
1029 geom->ReSetShape(idet,0);
1030 Info("InitGeomShapePPRasymmFMD",
1031 "default Dx=%f Dy=%f Dz=%f default=%d",
1032 shapePar[0],shapePar[1],shapePar[2],idet);
1037 //______________________________________________________________________
1038 Bool_t AliITSInitGeometry::InitSegmentationPPRasymmFMD(AliITSDetector idet,
1042 // Initilizes the geometry segmentation class AliITSgeomS?D, or
1043 // AliITSsegmentationS?D depending on the vaule of fSegGeom,
1044 // to values appropreate to this specific geometry. Now that
1045 // the segmentation is part of AliITSgeom, the detector
1046 // segmentations are also defined here.
1048 // Int_t lay The layer number/name.
1049 // AliITSgeom *geom A pointer to the AliITSgeom class
1051 // AliITSgeom *geom This pointer recreated and properly inilized.
1054 const Double_t kcm2micron = 1.0E4;
1059 initSeg[idet] = kTRUE;
1060 AliITSsegmentationSPD *segSPD = new AliITSsegmentationSPD();
1061 segSPD->SetDetSize(2.*shapePar[0]*kcm2micron, // X
1062 2.*shapePar[2]*kcm2micron, // Z
1063 2.*shapePar[1]*kcm2micron);// Y Microns
1064 segSPD->SetNPads(256,160);// Number of Bins in x and z
1065 Float_t bx[256],bz[280];
1066 for(i=000;i<256;i++) bx[i] = 50.0; // in x all are 50 microns.
1067 for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns
1069 for(i=160;i<280;i++) bz[i] = 0.0; // Outside of detector.
1070 bz[ 31] = bz[ 32] = 625.0; // first chip boundry
1071 bz[ 63] = bz[ 64] = 625.0; // first chip boundry
1072 bz[ 95] = bz[ 96] = 625.0; // first chip boundry
1073 bz[127] = bz[128] = 625.0; // first chip boundry
1074 bz[160] = 425.0;// Set so that there is no zero pixel size for fNz.
1075 segSPD->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
1076 geom->ReSetShape(idet,segSPD);
1079 initSeg[idet] = kTRUE;
1080 AliITSsegmentationSDD *segSDD = new AliITSsegmentationSDD();
1081 segSDD->SetDetSize(shapePar[0]*kcm2micron, // X
1082 2.*shapePar[2]*kcm2micron, // Z
1083 2.*shapePar[1]*kcm2micron);// Y Microns
1084 segSDD->SetNPads(256,256);// Anodes, Samples
1085 geom->ReSetShape(idet,segSDD);
1088 initSeg[idet] = kTRUE;
1089 AliITSsegmentationSSD *segSSD = new AliITSsegmentationSSD();
1090 segSSD->SetDetSize(2.*shapePar[0]*kcm2micron, // X
1091 2.*shapePar[2]*kcm2micron, // Z
1092 2.*shapePar[1]*kcm2micron);// Y Microns.
1093 segSSD->SetPadSize(95.,0.); // strip x pitch in microns
1094 segSSD->SetNPads(768,2); // number of strips on each side, sides.
1095 segSSD->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
1096 segSSD->SetAnglesLay5(0.0075,0.0275);//strip angels rad P and N
1097 segSSD->SetAnglesLay6(0.0275,0.0075);//strip angels rad P and N
1098 geom->ReSetShape(idet,segSSD);
1100 default:{// Others, Note no kSDDp or kSSDp in this geometry.
1101 geom->ReSetShape(idet,0);
1102 Info("InitSegmentationPPRasymmFMD",
1103 "default segmentation Dx=%f Dy=%f Dz=%f default=%d",
1104 shapePar[0],shapePar[1],shapePar[2],idet);
1109 //______________________________________________________________________
1110 Bool_t AliITSInitGeometry::GetTransformation(const TString &volumePath,
1112 // Returns the Transformation matrix between the volume specified
1113 // by the path volumePath and the Top or mater volume. The format
1114 // of the path volumePath is as follows (assuming ALIC is the Top volume)
1115 // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
1116 // or master volume which has only 1 instance of. Of all of the daughter
1117 // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
1118 // the daughter volume of DDIP is S05I copy #2 and so on.
1120 // TString& volumePath The volume path to the specific volume
1121 // for which you want the matrix. Volume name
1122 // hierarchy is separated by "/" while the
1123 // copy number is appended using a "_".
1125 // TGeoHMatrix &mat A matrix with its values set to those
1126 // appropriate to the Local to Master transformation
1128 // A logical value if kFALSE then an error occurred and no change to
1131 // We have to preserve the modeler state
1133 // Preserve the modeler state.
1134 gGeoManager->PushPath();
1135 if (!gGeoManager->cd(volumePath.Data())) {
1136 gGeoManager->PopPath();
1137 Error("GetTransformation","Error in cd-ing to ",volumePath.Data());
1139 } // end if !gGeoManager
1140 mat = *gGeoManager->GetCurrentMatrix();
1141 // Retstore the modeler state.
1142 gGeoManager->PopPath();
1145 //______________________________________________________________________
1146 Bool_t AliITSInitGeometry::GetShape(const TString &volumePath,
1147 TString &shapeType,TArrayD &par){
1148 // Returns the shape and its parameters for the volume specified
1151 // TString& volumeName The volume name
1153 // TString &shapeType Shape type
1154 // TArrayD &par A TArrayD of parameters with all of the
1155 // parameters of the specified shape.
1157 // A logical indicating whether there was an error in getting this
1160 gGeoManager->PushPath();
1161 if (!gGeoManager->cd(volumePath.Data())) {
1162 gGeoManager->PopPath();
1165 TGeoVolume * vol = gGeoManager->GetCurrentVolume();
1166 gGeoManager->PopPath();
1167 if (!vol) return kFALSE;
1168 TGeoShape *shape = vol->GetShape();
1169 TClass *classType = shape->IsA();
1170 if (classType==TGeoBBox::Class()) {
1174 TGeoBBox *box = (TGeoBBox*)shape;
1175 par.AddAt(box->GetDX(),0);
1176 par.AddAt(box->GetDY(),1);
1177 par.AddAt(box->GetDZ(),2);
1180 if (classType==TGeoTrd1::Class()) {
1184 TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
1185 par.AddAt(trd1->GetDx1(),0);
1186 par.AddAt(trd1->GetDx2(),1);
1187 par.AddAt(trd1->GetDy(), 2);
1188 par.AddAt(trd1->GetDz(), 3);
1191 if (classType==TGeoTrd2::Class()) {
1195 TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
1196 par.AddAt(trd2->GetDx1(),0);
1197 par.AddAt(trd2->GetDx2(),1);
1198 par.AddAt(trd2->GetDy1(),2);
1199 par.AddAt(trd2->GetDy2(),3);
1200 par.AddAt(trd2->GetDz(), 4);
1203 if (classType==TGeoTrap::Class()) {
1207 TGeoTrap *trap = (TGeoTrap*)shape;
1208 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
1209 par.AddAt(trap->GetDz(),0);
1210 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
1211 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
1212 par.AddAt(trap->GetH1(),3);
1213 par.AddAt(trap->GetBl1(),4);
1214 par.AddAt(trap->GetTl1(),5);
1215 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
1216 par.AddAt(trap->GetH2(),7);
1217 par.AddAt(trap->GetBl2(),8);
1218 par.AddAt(trap->GetTl2(),9);
1219 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
1222 if (classType==TGeoTube::Class()) {
1226 TGeoTube *tube = (TGeoTube*)shape;
1227 par.AddAt(tube->GetRmin(),0);
1228 par.AddAt(tube->GetRmax(),1);
1229 par.AddAt(tube->GetDz(),2);
1232 if (classType==TGeoTubeSeg::Class()) {
1236 TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
1237 par.AddAt(tubs->GetRmin(),0);
1238 par.AddAt(tubs->GetRmax(),1);
1239 par.AddAt(tubs->GetDz(),2);
1240 par.AddAt(tubs->GetPhi1(),3);
1241 par.AddAt(tubs->GetPhi2(),4);
1244 if (classType==TGeoCone::Class()) {
1248 TGeoCone *cone = (TGeoCone*)shape;
1249 par.AddAt(cone->GetDz(),0);
1250 par.AddAt(cone->GetRmin1(),1);
1251 par.AddAt(cone->GetRmax1(),2);
1252 par.AddAt(cone->GetRmin2(),3);
1253 par.AddAt(cone->GetRmax2(),4);
1256 if (classType==TGeoConeSeg::Class()) {
1260 TGeoConeSeg *cons = (TGeoConeSeg*)shape;
1261 par.AddAt(cons->GetDz(),0);
1262 par.AddAt(cons->GetRmin1(),1);
1263 par.AddAt(cons->GetRmax1(),2);
1264 par.AddAt(cons->GetRmin2(),3);
1265 par.AddAt(cons->GetRmax2(),4);
1266 par.AddAt(cons->GetPhi1(),5);
1267 par.AddAt(cons->GetPhi2(),6);
1270 if (classType==TGeoSphere::Class()) {
1275 TGeoSphere *sphe = (TGeoSphere*)shape;
1276 par.AddAt(sphe->GetRmin(),0);
1277 par.AddAt(sphe->GetRmax(),1);
1278 par.AddAt(sphe->GetTheta1(),2);
1279 par.AddAt(sphe->GetTheta2(),3);
1280 par.AddAt(sphe->GetPhi1(),4);
1281 par.AddAt(sphe->GetPhi2(),5);
1284 if (classType==TGeoPara::Class()) {
1288 TGeoPara *para = (TGeoPara*)shape;
1289 par.AddAt(para->GetX(),0);
1290 par.AddAt(para->GetY(),1);
1291 par.AddAt(para->GetZ(),2);
1292 par.AddAt(para->GetTxy(),3);
1293 par.AddAt(para->GetTxz(),4);
1294 par.AddAt(para->GetTyz(),5);
1297 if (classType==TGeoPgon::Class()) {
1299 TGeoPgon *pgon = (TGeoPgon*)shape;
1300 Int_t nz = pgon->GetNz();
1301 const Double_t *rmin = pgon->GetRmin();
1302 const Double_t *rmax = pgon->GetRmax();
1303 const Double_t *z = pgon->GetZ();
1306 par.AddAt(pgon->GetPhi1(),0);
1307 par.AddAt(pgon->GetDphi(),1);
1308 par.AddAt(pgon->GetNedges(),2);
1309 par.AddAt(pgon->GetNz(),3);
1310 for (Int_t i=0; i<nz; i++) {
1311 par.AddAt(z[i], 4+3*i);
1312 par.AddAt(rmin[i], 4+3*i+1);
1313 par.AddAt(rmax[i], 4+3*i+2);
1317 if (classType==TGeoPcon::Class()) {
1319 TGeoPcon *pcon = (TGeoPcon*)shape;
1320 Int_t nz = pcon->GetNz();
1321 const Double_t *rmin = pcon->GetRmin();
1322 const Double_t *rmax = pcon->GetRmax();
1323 const Double_t *z = pcon->GetZ();
1326 par.AddAt(pcon->GetPhi1(),0);
1327 par.AddAt(pcon->GetDphi(),1);
1328 par.AddAt(pcon->GetNz(),2);
1329 for (Int_t i=0; i<nz; i++) {
1330 par.AddAt(z[i], 3+3*i);
1332 par.AddAt(rmin[i], 3+3*i+1);
1333 par.AddAt(rmax[i], 3+3*i+2);
1337 if (classType==TGeoEltu::Class()) {
1341 TGeoEltu *eltu = (TGeoEltu*)shape;
1342 par.AddAt(eltu->GetA(),0);
1343 par.AddAt(eltu->GetB(),1);
1344 par.AddAt(eltu->GetDz(),2);
1347 if (classType==TGeoHype::Class()) {
1351 TGeoHype *hype = (TGeoHype*)shape;
1352 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
1353 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
1354 par.AddAt(hype->GetDZ(),2);
1355 par.AddAt(hype->GetStIn(),3);
1356 par.AddAt(hype->GetStOut(),4);
1359 if (classType==TGeoGtra::Class()) {
1363 TGeoGtra *trap = (TGeoGtra*)shape;
1364 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
1365 par.AddAt(trap->GetDz(),0);
1366 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
1367 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
1368 par.AddAt(trap->GetH1(),3);
1369 par.AddAt(trap->GetBl1(),4);
1370 par.AddAt(trap->GetTl1(),5);
1371 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
1372 par.AddAt(trap->GetH2(),7);
1373 par.AddAt(trap->GetBl2(),8);
1374 par.AddAt(trap->GetTl2(),9);
1375 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
1376 par.AddAt(trap->GetTwistAngle(),11);
1379 if (classType==TGeoCtub::Class()) {
1383 TGeoCtub *ctub = (TGeoCtub*)shape;
1384 const Double_t *lx = ctub->GetNlow();
1385 const Double_t *tx = ctub->GetNhigh();
1386 par.AddAt(ctub->GetRmin(),0);
1387 par.AddAt(ctub->GetRmax(),1);
1388 par.AddAt(ctub->GetDz(),2);
1389 par.AddAt(ctub->GetPhi1(),3);
1390 par.AddAt(ctub->GetPhi2(),4);
1396 par.AddAt(tx[2],10);
1399 Error("GetShape","Getting shape parameters for shape %s not implemented",
1400 shape->ClassName());
1401 shapeType = "Unknown";
1404 //______________________________________________________________________
1405 void AliITSInitGeometry::DecodeDetector(
1406 Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
1407 // decode geometry into detector module number. There are two decoding
1408 // Scheams. Old which does not follow the ALICE coordinate system
1409 // requirements, and New which dose.
1411 // Int_t layer The ITS layer
1412 // Int_t cpn0 The lowest copy number
1413 // Int_t cpn1 The middle copy number
1414 // Int_t cpn2 the highest copy number
1416 // Int_t &mod The module number assoicated with this set
1421 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
1422 // like them but I see not better way for the moment.
1423 switch (fMajorVersion){
1425 if(GetMinorVersion()==1)
1426 return DecodeDetectorvPPRasymmFMD(mod,layer,cpn0,cpn1,cpn2);
1427 else if(GetMinorVersion()==2)
1428 return DecodeDetectorvtest2(mod,layer,cpn0,cpn1,cpn2);
1429 Warning("DecodeDetector",
1430 "Geometry is kvtest minor version=%d is not defined",
1434 Error("DecodeDetector","Major version = kvDefault, not supported");
1437 return DecodeDetectorvSPD02(mod,layer,cpn0,cpn1,cpn2);
1440 return DecodeDetectorvSDD03(mod,layer,cpn0,cpn1,cpn2);
1443 return DecodeDetectorvSSD03(mod,layer,cpn0,cpn1,cpn2);
1446 return DecodeDetectorvITS04(mod,layer,cpn0,cpn1,cpn2);
1448 case kvPPRcourseasymm:{
1449 return DecodeDetectorvPPRcourseasymm(mod,layer,cpn0,cpn1,cpn2);
1451 case kvPPRasymmFMD:{
1452 return DecodeDetectorvPPRasymmFMD(mod,layer,cpn0,cpn1,cpn2);
1455 return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2);
1458 return DecodeDetectorv11Hybrid(mod,layer,cpn0,cpn1,cpn2);
1461 Error("DecodeDetector","Major version = %d, not supported",
1462 (Int_t)fMajorVersion);
1468 //______________________________________________________________________
1469 void AliITSInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
1470 Int_t &cpn1,Int_t &cpn2){
1471 // decode geometry into detector module number. There are two decoding
1472 // Scheams. Old which does not follow the ALICE coordinate system
1473 // requirements, and New which dose.
1475 // Int_t mod The module number assoicated with this set
1478 // Int_t cpn0 The lowest copy number
1479 // Int_t cpn1 The middle copy number
1480 // Int_t cpn2 the highest copy number
1484 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
1485 // like them but I see not better way for the moment.
1486 switch (fMajorVersion){
1488 if(GetMinorVersion()==1)
1489 return RecodeDetectorvPPRasymmFMD(mod,cpn0,cpn1,cpn2);
1490 else if(GetMinorVersion()==2)
1491 return RecodeDetectorvtest2(mod,cpn0,cpn1,cpn2);
1492 Warning("RecodeDetector",
1493 "Geometry is kvtest minor version=%d is not defined",
1498 Error("RecodeDetector","Major version = kvDefault, not supported");
1502 return RecodeDetectorvSPD02(mod,cpn0,cpn1,cpn2);
1505 return RecodeDetectorvSDD03(mod,cpn0,cpn1,cpn2);
1508 return RecodeDetectorvSSD03(mod,cpn0,cpn1,cpn2);
1511 return RecodeDetectorvITS04(mod,cpn0,cpn1,cpn2);
1513 case kvPPRcourseasymm:{
1514 return RecodeDetectorvPPRcourseasymm(mod,cpn0,cpn1,cpn2);
1516 case kvPPRasymmFMD:{
1517 return RecodeDetectorvPPRasymmFMD(mod,cpn0,cpn1,cpn2);
1520 return RecodeDetectorv11(mod,cpn0,cpn1,cpn2);
1523 return RecodeDetectorv11Hybrid(mod,cpn0,cpn1,cpn2);
1526 Error("RecodeDetector","Major version = %d, not supported",
1527 (Int_t)fMajorVersion);
1533 //______________________________________________________________________
1534 void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
1535 Int_t &lad,Int_t &det){
1536 // decode geometry into detector module number. There are two decoding
1537 // Scheams. Old which does not follow the ALICE coordinate system
1538 // requirements, and New which dose. Note, this use of layer ladder
1539 // and detector numbers are strictly for internal use of this
1540 // specific code. They do not represent the "standard" layer ladder
1541 // or detector numbering except in a very old and obsoleate sence.
1543 // Int_t mod The module number assoicated with this set
1546 // Int_t lay The layer number
1547 // Int_t lad The ladder number
1548 // Int_t det the dettector number
1552 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
1553 // like them but I see not better way for the moment.
1554 switch (fMajorVersion) {
1556 if(GetMinorVersion()==1)
1557 return DecodeDetectorLayersvPPRasymmFMD(mod,layer,lad,det);
1558 else if(GetMinorVersion()==2)
1559 return DecodeDetectorLayersvtest2(mod,layer,lad,det);
1560 Warning("DecodeDetectorLayers",
1561 "Geometry is kvtest minor version=%d is not defined",
1566 Error("DecodeDetectorLayers",
1567 "Major version = kvDefault, not supported");
1571 return DecodeDetectorLayersvSPD02(mod,layer,lad,det);
1574 return DecodeDetectorLayersvSDD03(mod,layer,lad,det);
1577 return DecodeDetectorLayersvSSD03(mod,layer,lad,det);
1580 return DecodeDetectorLayersvITS04(mod,layer,lad,det);
1582 case kvPPRcourseasymm:{
1583 return DecodeDetectorLayersvPPRcourseasymm(mod,layer,lad,det);
1585 case kvPPRasymmFMD:{
1586 return DecodeDetectorLayersvPPRasymmFMD(mod,layer,lad,det);
1589 return DecodeDetectorLayersv11(mod,layer,lad,det);
1592 return DecodeDetectorLayersv11Hybrid(mod,layer,lad,det);
1595 Error("DecodeDetectorLayers","Major version = %d, not supported",
1596 (Int_t)fMajorVersion);
1602 //______________________________________________________________________
1603 void AliITSInitGeometry::DecodeDetectorvSPD02(
1604 Int_t &mod,Int_t ncpn,Int_t cpy0,Int_t cpy1,Int_t cpy2) const {
1605 // decode geometry into detector module number
1607 // Int_t ncpn The Number of copies of this volume
1608 // Int_t cpy0 The lowest copy number
1609 // Int_t cpy1 The middle copy number
1610 // Int_t cpy2 the highest copy number
1612 // Int_t &mod The module number assoicated with this set
1617 // detector = ladder = 1
1618 if(ncpn==4 && cpy1>2) mod = cpy1; // layer = 1,2
1619 else mod = cpy1-1; // layer = 4,5
1620 if(ncpn==1) mod = 2; // layer=3
1624 //______________________________________________________________________
1625 void AliITSInitGeometry::RecodeDetectorvSPD02(Int_t mod,Int_t &cpn0,
1626 Int_t &cpn1,Int_t &cpn2) const {
1627 // decode geometry into detector module number. There are two decoding
1628 // Scheams. Old which does not follow the ALICE coordinate system
1629 // requirements, and New which dose.
1631 // Int_t mod The module number assoicated with this set
1634 // Int_t cpn0 The lowest copy number
1635 // Int_t cpn1 The middle copy number
1636 // Int_t cpn2 the highest copy number
1654 //______________________________________________________________________
1655 void AliITSInitGeometry::DecodeDetectorLayersvSPD02(Int_t mod,Int_t &lay,
1656 Int_t &lad,Int_t &det) const{
1657 // decode geometry into detector module number. There are two decoding
1658 // Scheams. Old which does not follow the ALICE coordinate system
1659 // requirements, and New which dose. Note, this use of layer ladder
1660 // and detector numbers are strictly for internal use of this
1661 // specific code. They do not represent the "standard" layer ladder
1662 // or detector numbering except in a very old and obsoleate sence.
1664 // Int_t mod The module number assoicated with this set
1667 // Int_t lay The layer number
1668 // Int_t lad The ladder number
1669 // Int_t det the dettector number
1677 //______________________________________________________________________
1678 void AliITSInitGeometry::DecodeDetectorvSDD03(
1679 Int_t &mod,Int_t ncpys,Int_t cpy0,Int_t cpy1,Int_t cpy2) const {
1680 // decode geometry into detector module number. There are two decoding
1681 // Scheams. Old which does not follow the ALICE coordinate system
1682 // requirements, and New which dose.
1684 // Int_t ncpys The number of posible copies cpn1
1685 // Int_t cpy0 The lowest copy number
1686 // Int_t cpy1 The middle copy number
1687 // Int_t cpy2 the highest copy number
1689 // Int_t &mod The module number assoicated with this set
1694 if(ncpys==10){ // ITEL detectors
1695 if(cpy1>4) mod = cpy1+1;
1697 }else{ // IDET detectors
1698 if(cpy1==1) mod = 4;
1704 //______________________________________________________________________
1705 void AliITSInitGeometry::RecodeDetectorvSDD03(Int_t mod,Int_t &cpn0,
1706 Int_t &cpn1,Int_t &cpn2) const{
1707 // decode geometry into detector module number. There are two decoding
1708 // Scheams. Old which does not follow the ALICE coordinate system
1709 // requirements, and New which dose.
1711 // Int_t mod The module number assoicated with this set
1714 // Int_t cpn0 The lowest copy number
1715 // Int_t cpn1 The middle copy number
1716 // Int_t cpn2 the highest copy number
1722 if(mod<4) cpn1 = mod+1;
1723 else if(mod==4||mod==5) cpn1 = mod-3;
1727 //______________________________________________________________________
1728 void AliITSInitGeometry::DecodeDetectorLayersvSDD03(Int_t mod,Int_t &lay,
1729 Int_t &lad,Int_t &det) const{
1730 // decode geometry into detector module number. There are two decoding
1731 // Scheams. Old which does not follow the ALICE coordinate system
1732 // requirements, and New which dose. Note, this use of layer ladder
1733 // and detector numbers are strictly for internal use of this
1734 // specific code. They do not represent the "standard" layer ladder
1735 // or detector numbering except in a very old and obsoleate sence.
1737 // Int_t mod The module number assoicated with this set
1740 // Int_t lay The layer number
1741 // Int_t lad The ladder number
1742 // Int_t det the dettector number
1750 //______________________________________________________________________
1751 void AliITSInitGeometry::DecodeDetectorvSSD03(
1752 Int_t &mod,Int_t dtype,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
1753 // decode geometry into detector module number. There are two decoding
1754 // Scheams. Old which does not follow the ALICE coordinate system
1755 // requirements, and New which dose.
1757 // Int_t dtype The detector type 1=ITSA 2=IGAR 3=IFRA
1758 // Int_t cpn0 The lowest copy number
1759 // Int_t cpn1 The middle copy number
1760 // Int_t cpn2 the highest copy number
1762 // Int_t &mod The module number assoicated with this set
1767 if(dtype==2){mod=2; return;}
1768 if(dtype==3){mod=3; return;}
1770 if(cpn0==3) mod = 4;
1774 //______________________________________________________________________
1775 void AliITSInitGeometry::RecodeDetectorvSSD03(Int_t mod,Int_t &cpn0,
1776 Int_t &cpn1,Int_t &cpn2) const {
1777 // decode geometry into detector module number. There are two decoding
1778 // Scheams. Old which does not follow the ALICE coordinate system
1779 // requirements, and New which dose.
1781 // Int_t mod The module number assoicated with this set
1784 // Int_t cpn0 The lowest copy number
1785 // Int_t cpn1 The middle copy number
1786 // Int_t cpn2 the highest copy number
1792 if(mod<2) cpn0=mod+1;
1793 else if (mod==2||mod==3) cpn0=1;
1797 //______________________________________________________________________
1798 void AliITSInitGeometry::DecodeDetectorLayersvSSD03(Int_t mod,Int_t &lay,
1799 Int_t &lad,Int_t &det) const {
1800 // decode geometry into detector module number. There are two decoding
1801 // Scheams. Old which does not follow the ALICE coordinate system
1802 // requirements, and New which dose. Note, this use of layer ladder
1803 // and detector numbers are strictly for internal use of this
1804 // specific code. They do not represent the "standard" layer ladder
1805 // or detector numbering except in a very old and obsoleate sence.
1807 // Int_t mod The module number assoicated with this set
1810 // Int_t lay The layer number
1811 // Int_t lad The ladder number
1812 // Int_t det the dettector number
1820 //______________________________________________________________________
1821 void AliITSInitGeometry::DecodeDetectorvITS04(
1822 Int_t &mod,Int_t dtype,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
1823 // decode geometry into detector module number. There are two decoding
1824 // Scheams. Old which does not follow the ALICE coordinate system
1825 // requirements, and New which dose.
1827 // Int_t dtype The detector type 1=ITSA 2=IGAR 3=IFRA
1828 // Int_t cpn0 The lowest copy number
1829 // Int_t cpn1 The middle copy number
1830 // Int_t cpn2 the highest copy number
1832 // Int_t &mod The module number assoicated with this set
1841 //______________________________________________________________________
1842 void AliITSInitGeometry::RecodeDetectorvITS04(Int_t mod,Int_t &cpn0,
1843 Int_t &cpn1,Int_t &cpn2) const {
1844 // decode geometry into detector module number. There are two decoding
1845 // Scheams. Old which does not follow the ALICE coordinate system
1846 // requirements, and New which dose.
1848 // Int_t mod The module number assoicated with this set
1851 // Int_t cpn0 The lowest copy number
1852 // Int_t cpn1 The middle copy number
1853 // Int_t cpn2 the highest copy number
1859 case 0:case 1:case 2:case 3:{
1865 case 6:case 7:case 8:case 9:{
1874 //______________________________________________________________________
1875 void AliITSInitGeometry::DecodeDetectorLayersvITS04(Int_t mod,Int_t &lay,
1876 Int_t &lad,Int_t &det) const{
1877 // decode geometry into detector module number. There are two decoding
1878 // Scheams. Old which does not follow the ALICE coordinate system
1879 // requirements, and New which dose. Note, this use of layer ladder
1880 // and detector numbers are strictly for internal use of this
1881 // specific code. They do not represent the "standard" layer ladder
1882 // or detector numbering except in a very old and obsoleate sence.
1884 // Int_t mod The module number assoicated with this set
1887 // Int_t lay The layer number
1888 // Int_t lad The ladder number
1889 // Int_t det the dettector number
1895 case 0:case 1:case 2:case 3:{
1902 case 6:case 7:case 8:case 9:{
1913 //______________________________________________________________________
1914 void AliITSInitGeometry::DecodeDetectorvPPRasymmFMD(Int_t &mod,Int_t layer,Int_t cpn0,
1915 Int_t cpn1,Int_t cpn2) const {
1916 // decode geometry into detector module number. There are two decoding
1917 // Scheams. Old which does not follow the ALICE coordinate system
1918 // requirements, and New which dose.
1920 // Int_t layer The ITS layer
1921 // Int_t cpn0 The lowest copy number
1922 // Int_t cpn1 The middle copy number
1923 // Int_t cpn2 the highest copy number
1925 // Int_t &mod The module number assoicated with this set
1929 const Int_t kDetPerLadderSPD[2]={2,4};
1930 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
1931 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
1932 Int_t lay=-1,lad=-1,det=-1,i;
1934 if(fDecode){ // New decoding scheam
1939 if(cpn0==4&&cpn1==1) lad=1;
1940 else if(cpn0==4&&cpn1==2) lad=20;
1942 lad = 8-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
1944 lad = 28-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
1950 if(cpn0==4&&cpn1==1) lad=1;
1952 lad = 14-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
1954 lad = 54-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
1959 if(cpn0<5) lad = 5-cpn0;
1965 if(cpn0<7) lad = 7-cpn0;
1971 if(cpn0<10) lad = 10-cpn0;
1977 if(cpn0<9) lad = 9-cpn0;
1983 for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
1984 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
1987 // Old decoding scheam
1991 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
2008 for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
2009 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
2012 //______________________________________________________________________
2013 void AliITSInitGeometry::RecodeDetectorvPPRasymmFMD(Int_t mod,Int_t &cpn0,
2014 Int_t &cpn1,Int_t &cpn2){
2015 // decode geometry into detector module number. There are two decoding
2016 // Scheams. Old which does not follow the ALICE coordinate system
2017 // requirements, and New which dose.
2019 // Int_t mod The module number assoicated with this set
2022 // Int_t cpn0 The lowest copy number
2023 // Int_t cpn1 The middle copy number
2024 // Int_t cpn2 the highest copy number
2027 const Int_t kITSgeoTreeCopys[6][3]= {{10, 2, 4},// lay=1
2033 const Int_t kDetPerLadderSPD[2]={2,4};
2034 // const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2035 // const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
2038 cpn0 = cpn1 = cpn2 = 0;
2039 DecodeDetectorLayers(mod,lay,lad,det);
2040 if(fDecode){ // New decoding scheam
2043 cpn2 = 5-det; // Detector 1-4
2044 cpn1 = 1+(lad-1)%kDetPerLadderSPD[lay-1];
2045 cpn0 = 5-(lad+kDetPerLadderSPD[lay-1])/kDetPerLadderSPD[lay-1];
2046 if(mod>27) cpn0 = 15-(lad+kDetPerLadderSPD[lay-1])/
2047 kDetPerLadderSPD[lay-1];
2050 cpn2 = 5-det; // Detector 1-4
2051 cpn1 = 4-(lad+2)%kDetPerLadderSPD[lay-1];
2052 cpn0 = 1+(14-cpn1-lad)/kDetPerLadderSPD[lay-1];
2053 if(mod>131) cpn0 = 1+(54-lad-cpn1)/kDetPerLadderSPD[lay-1];
2057 if(lad<5) cpn0 = 5-lad;
2063 if(lad<7) cpn0 = 7-lad;
2069 if(lad<10) cpn0 = 10-lad;
2075 if(lad<9) cpn0 = 9-lad;
2080 Error("RecodeDetector","New: mod=%d lay=%d not 1-6.");
2084 if(cpn0<1||cpn1<1||cpn2<1||
2085 cpn0>kITSgeoTreeCopys[lay-1][0]||
2086 cpn1>kITSgeoTreeCopys[lay-1][1]||
2087 cpn2>kITSgeoTreeCopys[lay-1][2])
2088 Error("RecodeDetector",
2089 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
2090 cpn0,cpn1,cpn2,mod,lay,lad,det);
2096 cpn2 = det; // Detector 1-4
2097 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
2098 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
2100 case 3: case 4: case 5 : case 6:{
2106 Error("RecodeDetector","Old: mod=%d lay=%d not 1-6.");
2110 if(cpn0<1||cpn1<1||cpn2<1||
2111 cpn0>kITSgeoTreeCopys[lay-1][0]||
2112 cpn1>kITSgeoTreeCopys[lay-1][1]||
2113 cpn2>kITSgeoTreeCopys[lay-1][2])
2114 Error("RecodeDetector",
2115 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
2116 cpn0,cpn1,cpn2,mod,lay,lad,det);
2119 //______________________________________________________________________
2120 void AliITSInitGeometry::DecodeDetectorLayersvPPRasymmFMD(Int_t mod,Int_t &lay,
2121 Int_t &lad,Int_t &det){
2122 // decode geometry into detector module number. There are two decoding
2123 // Scheams. Old which does not follow the ALICE coordinate system
2124 // requirements, and New which dose. Note, this use of layer ladder
2125 // and detector numbers are strictly for internal use of this
2126 // specific code. They do not represent the "standard" layer ladder
2127 // or detector numbering except in a very old and obsoleate sence.
2129 // Int_t mod The module number assoicated with this set
2132 // Int_t lay The layer number
2133 // Int_t lad The ladder number
2134 // Int_t det the dettector number
2137 // const Int_t kDetPerLadderSPD[2]={2,4};
2138 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2139 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
2147 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
2149 }while(mod2<=mod); // end while
2150 if(lay>6||lay<1) Error("DecodeDetectorLayers","0<lay=%d>6",lay);
2151 mod2 -= kLadPerLayer[lay-1]*kDetPerLadder[lay-1];
2154 mod2 += kDetPerLadder[lay-1];
2155 }while(mod2<=mod); // end while
2156 if(lad>kLadPerLayer[lay-1]||lad<1) Error("DecodeDetectorLayers",
2157 "lad=%d>kLadPerLayer[lay-1=%d]=%d mod=%d mod2=%d",lad,lay-1,
2158 kLadPerLayer[lay-1],mod,mod2);
2159 mod2 -= kDetPerLadder[lay-1];
2161 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
2162 "det=%d>detPerLayer[lay-1=%d]=%d mod=%d mod2=%d lad=%d",det,
2163 lay-1,kDetPerLadder[lay-1],mod,mod2,lad);
2166 //______________________________________________________________________
2167 void AliITSInitGeometry::DecodeDetectorv11Hybrid(Int_t &mod,Int_t layer,Int_t cpn0,
2168 Int_t cpn1,Int_t cpn2) const {
2169 // decode geometry into detector module number
2171 // Int_t layer The ITS layer
2172 // Int_t cpn0 The lowest copy number
2173 // Int_t cpn1 The middle copy number
2174 // Int_t cpn2 the highest copy number
2176 // Int_t &mod The module number assoicated with this set
2180 const Int_t kDetPerLadderSPD[2]={2,4};
2181 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2182 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
2183 Int_t lad=-1,det=-1;
2187 if (SPDIsTGeoNative()) {
2188 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1)+1;
2191 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
2196 if (SDDIsTGeoNative()) {
2205 if (SSDIsTGeoNative()) {
2217 for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
2218 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
2223 //______________________________________________________________________
2224 void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
2225 Int_t &cpn1,Int_t &cpn2) {
2226 // decode geometry into detector module number. There are two decoding
2227 // Scheams. Old which does not follow the ALICE coordinate system
2228 // requirements, and New which dose.
2230 // Int_t mod The module number assoicated with this set
2233 // Int_t cpn0 The lowest copy number
2234 // Int_t cpn1 The middle copy number
2235 // Int_t cpn2 the highest copy number
2238 const Int_t kITSgeoTreeCopys[6][3]= {{10, 2, 4},// lay=1
2244 const Int_t kDetPerLadderSPD[2]={2,4};
2247 cpn0 = cpn1 = cpn2 = 0;
2248 DecodeDetectorLayersv11Hybrid(mod,lay,lad,det);
2252 cpn2 = det; // Detector 1-4
2253 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
2254 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
2256 case 3: case 4: case 5 : case 6:{
2262 Error("RecodeDetector","Old: mod=%d lay=%d not 1-6.");
2266 if(cpn0<1||cpn1<1||cpn2<1||
2267 cpn0>kITSgeoTreeCopys[lay-1][0]||
2268 cpn1>kITSgeoTreeCopys[lay-1][1]||
2269 cpn2>kITSgeoTreeCopys[lay-1][2])
2270 Error("RecodeDetector",
2271 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
2272 cpn0,cpn1,cpn2,mod,lay,lad,det);
2278 //______________________________________________________________________
2279 void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
2280 Int_t &cpn1,Int_t &cpn2) {
2281 // decode geometry into detector module number. There are two decoding
2282 // Scheams. Old which does not follow the ALICE coordinate system
2283 // requirements, and New which does.
2285 // Int_t mod The module number assoicated with this set
2288 // Int_t cpn0 The lowest copy number (SPD sector or SDD/SSD ladder)
2289 // Int_t cpn1 The middle copy number (SPD stave or SDD/SSD module)
2290 // Int_t cpn2 the highest copy number (SPD ladder or 1 for SDD/SSD)
2294 const Int_t kDetPerLadderSPD[2]={2,4};
2296 DecodeDetectorLayersv11Hybrid(mod,lay,lad,det);
2299 cpn2 = det; // Detector 1-4
2300 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
2301 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
2302 if (SPDIsTGeoNative()) {
2306 } else { // SDD and SSD
2311 if (SDDIsTGeoNative()) {
2316 if (SSDIsTGeoNative()) {
2327 // //______________________________________________________________________
2328 // void AliITSInitGeometry::DecodeDetectorLayersv11Hybrid(Int_t mod,Int_t &lay,
2329 // Int_t &lad,Int_t &det) {
2331 // // decode module number into detector indices for v11Hybrid
2333 // // Int_t mod The module number associated with this set
2334 // // of copy numbers.
2336 // // Int_t lay The layer number
2337 // // Int_t lad The ladder number
2338 // // Int_t det the dettector number
2342 // const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2343 // const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
2350 // mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
2352 // } while(mod2<=mod); // end while
2353 // if(lay>6||lay<1) Error("DecodeDetectorLayers","0<lay=%d>6",lay);
2354 // mod2 -= kLadPerLayer[lay-1]*kDetPerLadder[lay-1];
2357 // mod2 += kDetPerLadder[lay-1];
2358 // } while(mod2<=mod); // end while
2359 // if(lad>kLadPerLayer[lay-1]||lad<1) Error("DecodeDetectorLayers",
2360 // "lad=%d>kLadPerLayer[lay-1=%d]=%d mod=%d mod2=%d",lad,lay-1,
2361 // kLadPerLayer[lay-1],mod,mod2);
2362 // mod2 -= kDetPerLadder[lay-1];
2363 // det = mod-mod2+1;
2364 // if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
2365 // "det=%d>detPerLayer[lay-1=%d]=%d mod=%d mod2=%d lad=%d",det,
2366 // lay-1,kDetPerLadder[lay-1],mod,mod2,lad);
2370 //______________________________________________________________________
2371 void AliITSInitGeometry::DecodeDetectorLayersv11Hybrid(Int_t mod,Int_t &lay,
2372 Int_t &lad,Int_t &det) {
2374 // decode module number into detector indices for v11Hybrid
2375 // mod starts from 0
2376 // lay, lad, det start from 1
2379 // Int_t mod The module number associated with this set
2382 // Int_t lay The layer number
2383 // Int_t lad The ladder number
2384 // Int_t det the dettector number
2386 const Int_t kDetPerLadder[6] = {4,4,6,8,22,25};
2387 const Int_t kLadPerLayer[6] = {20,40,14,22,34,38};
2393 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
2395 } while(mod2<=mod); // end while
2396 if(lay>6) Error("DecodeDetectorLayers","lay=%d>6",lay);
2398 mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod;
2399 lad = mod2/kDetPerLadder[lay-1];
2401 if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers",
2402 "lad=%d not in the correct range",lad);
2403 det = (mod2 - lad*kDetPerLadder[lay-1])+1;
2404 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
2405 "det=%d not in the correct range",det);
2409 //______________________________________________________________________
2410 Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,
2411 AliITSVersion_t maj,Int_t min,
2412 const Char_t *cvsDate,const Char_t *cvsRevision)const{
2413 // fills the string str with the major and minor version number
2415 // Char_t *str The character string to hold the major
2416 // and minor version numbers in
2417 // Int_t length The maximum number of characters which
2418 // can be accomidated by this string.
2419 // str[length-1] must exist and will be set to zero
2420 // AliITSVersion_t maj The major number
2421 // Int_t min The minor number
2422 // Char_t *cvsDate The date string from cvs
2423 // Char_t *cvsRevision The Revision string from cvs
2425 // Char_t *str The character string holding the major and minor
2426 // version numbers. str[length-1] must exist
2427 // and will be set to zero
2429 // kTRUE if no errors
2430 Int_t i,n,cvsDateLength,cvsRevisionLength;
2432 cvsDateLength = (Int_t)strlen(cvsDate);
2433 cvsRevisionLength = (Int_t)strlen(cvsRevision);
2435 n = 50+(Int_t)(TMath::Log10(TMath::Abs((Double_t)i)))+1+
2436 (Int_t)(TMath::Log10(TMath::Abs((Double_t)min)))+1
2437 +cvsDateLength-6+cvsRevisionLength-10;
2438 if(GetDebug()>1) printf("AliITSInitGeometry::WriteVersionString:"
2439 "length=%d major=%d minor=%d cvsDate=%s[%d] "
2440 "cvsRevision=%s[%d] n=%d\n",length,i,min,cvsDate,
2441 cvsDateLength,cvsRevision,cvsRevisionLength,n);
2444 if(length<n){// not enough space to write in output string.
2445 Warning("WriteVersionString","Output string not long enough "
2446 "lenght=%d must be at least %d long\n",length,n);
2448 } // end if length<n
2449 char *cvsrevision = new char[cvsRevisionLength-10];
2450 char *cvsdate = new char[cvsDateLength-6];
2451 for(i=0;i<cvsRevisionLength-10;i++)
2452 if(10+i<cvsRevisionLength-1)
2453 cvsrevision[i] = cvsRevision[10+i]; else cvsrevision[i] = 0;
2454 for(i=0;i<cvsDateLength-6;i++) if(6+i<cvsDateLength-1)
2455 cvsdate[i] = cvsDate[6+i]; else cvsdate[i] = 0;
2456 for(i=0;i<length;i++) str[i] = 0; // zero it out for now.
2458 sprintf(str,"Major Version= %d Minor Version= %d Revision: %s Date: %s",
2459 i,min,cvsrevision,cvsdate);
2460 if(GetDebug()>1)printf("AliITSInitGeometry::WriteVersionString: "
2461 "n=%d str=%s revision[%zu] date[%zu]\n",
2462 n,str,strlen(cvsrevision),strlen(cvsdate));
2463 delete[] cvsrevision;
2467 //______________________________________________________________________
2468 Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,Int_t length,
2469 AliITSVersion_t &maj,Int_t &min,
2471 // fills the string str with the major and minor version number
2473 // Char_t *str The character string to holding the major and minor
2474 // version numbers in
2475 // Int_t length The maximum number of characters which can be
2476 // accomidated by this string. str[length-1] must exist
2478 // Char_t *str The character string holding the major and minor
2479 // version numbers unchanged. str[length-1] must exist.
2480 // AliITSVersion_t maj The major number
2481 // Int_t min The minor number
2482 // TDatime dt The date and time of the cvs commit
2484 // kTRUE if no errors
2486 Char_t cvsRevision[10],cvsDate[11],cvsTime[9];
2487 Int_t i,m,n=strlen(str),year,month,day,hours,minuits,seconds;
2489 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString:"
2490 "str=%s length=%d\n",
2492 if(n<35) return kFALSE; // not enough space for numbers
2493 m = sscanf(str,"Major Version= %d Minor Version= %d Revision: %s "
2494 "Date: %s %s",&i,&min,cvsRevision,cvsDate,cvsTime);
2497 m = sscanf(cvsDate,"%d/%d/%d",&year,&month,&day);
2500 m = sscanf(cvsTime,"%d:%d:%d",&hours,&minuits,&seconds);
2503 dt.Set(year,month,day,hours,minuits,seconds);
2504 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: i=%d min=%d "
2505 "cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
2506 i,min,cvsRevision,cvsDate,cvsTime,m);
2507 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: year=%d"
2508 " month=%d day=%d hours=%d minuits=%d seconds=%d\n",
2509 year,month,day,hours,minuits,seconds);
2523 case kvPPRasymmFMD:{
2524 maj = kvPPRasymmFMD;