]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSInitGeometry.cxx
Additional protection (Alberto)
[u/mrichter/AliRoot.git] / ITS / AliITSInitGeometry.cxx
CommitLineData
023ae34b 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/*
17$Id$
18*/
6b0f3880 19////////////////////////////////////////////////////////////////
20// This class initializes the class AliITSgeom
21// The initialization is done starting from
22// a geometry coded by means of the ROOT geometrical modeler
23// This initialization can be used both for simulation and reconstruction
24///////////////////////////////////////////////////////////////
25
023ae34b 26#include <TArrayD.h>
27#include <TArrayF.h>
28#include <TStopwatch.h>
023ae34b 29#include <TGeoManager.h>
30#include <TGeoVolume.h>
31#include <TGeoShape.h>
32#include <TGeoBBox.h>
33#include <TGeoTrd1.h>
34#include <TGeoTrd2.h>
35#include <TGeoArb8.h>
36#include <TGeoTube.h>
37#include <TGeoCone.h>
38#include <TGeoSphere.h>
39#include <TGeoPara.h>
40#include <TGeoPgon.h>
41#include <TGeoPcon.h>
42#include <TGeoEltu.h>
43#include <TGeoHype.h>
023ae34b 44
6def2bd2 45#include "AliLog.h"
46#include "AliITSgeomSPD.h"
47#include "AliITSgeomSDD.h"
48#include "AliITSgeomSSD.h"
49#include "AliITSsegmentationSPD.h"
50#include "AliITSsegmentationSDD.h"
51#include "AliITSsegmentationSSD.h"
023ae34b 52#include "AliITSgeom.h"
53#include "AliITSInitGeometry.h"
54
55ClassImp(AliITSInitGeometry)
56//______________________________________________________________________
57AliITSInitGeometry::AliITSInitGeometry():
58TObject(),
59fName(),
60fMinorVersion(0),
61fMajorVersion(0),
62fTiming(kFALSE),
63fSegGeom(kFALSE),
64fDecode(kFALSE){
65 // Default Creator
66 // Inputs:
67 // none.
68 // Outputs:
69 // none.
70 // Return:
71 // A default inilized AliITSInitGeometry object
72}
73//______________________________________________________________________
74AliITSInitGeometry::AliITSInitGeometry(const Char_t *name,Int_t minorversion):
75TObject(),
76fName(name),
77fMinorVersion(minorversion),
78fMajorVersion(0),
79fTiming(kFALSE),
80fSegGeom(kFALSE),
81fDecode(kFALSE){
82 // Default Creator
83 // Inputs:
84 // none.
85 // Outputs:
86 // none.
87 // Return:
88 // A default inilized AliITSInitGeometry object
89
90 if(fName.CompareTo("AliITSvPPRasymmFMD")==0)if(fMinorVersion==1||
91 fMinorVersion==2){
92 fMajorVersion=10;
93 return;
94 } // end if
95 // if not defined geometry error
96 Error("AliITSInitGeometry(name,version)"," Name must be AliITSvPPRasymmFMD"
97 " and version must be 1 or 2 for now.");
98 fMinorVersion = 0;
99 fName = "";
100 return;
101}
102//______________________________________________________________________
103AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(){
104 // Creates and Initilizes the geometry transformation class AliITSgeom
105 // to values appropreate to this specific geometry. Now that
106 // the segmentation is part of AliITSgeom, the detector
107 // segmentations are also defined here.
108 // Inputs:
109 // none.
110 // Outputs:
111 // none.
112 // Return:
113 // A pointer to a new properly inilized AliITSgeom class. If
114 // pointer = 0 then failed to init.
115
116 AliITSgeom *geom = new AliITSgeom();
117 if(!InitAliITSgeom(geom)){ // Error initilization failed
118 delete geom;
119 geom = 0;
120 } // end if
121 return geom;
122}
123//______________________________________________________________________
124Bool_t AliITSInitGeometry::InitAliITSgeom(AliITSgeom *geom){
6def2bd2 125 // Initilizes the geometry transformation class AliITSgeom
126 // to values appropreate to this specific geometry. Now that
127 // the segmentation is part of AliITSgeom, the detector
128 // segmentations are also defined here.
129 // Inputs:
130 // AliITSgeom *geom A pointer to the AliITSgeom class
131 // Outputs:
132 // AliITSgeom *geom This pointer recreated and properly inilized.
133 // Return:
134 // none.
023ae34b 135
6def2bd2 136 if(!gGeoManager){
137 AliFatal("The geometry manager has not been initialized (e.g. TGeoManager::Import(\"geometry.root\")should be called in advance) - exit forced");
138 return kFALSE;
139 }
140 switch(fMajorVersion){
141 case 10:{ // only case defined so far
142 return InitAliITSgeomPPRasymmFMD(geom);
143 }break; // end case
144 default:{
145 Error("InitAliITSgeom","Undefined geomtery");
023ae34b 146 return kFALSE;
6def2bd2 147 } break; // end case
148 } // end switch
149 return kFALSE;
023ae34b 150}
151//______________________________________________________________________
152Bool_t AliITSInitGeometry::InitAliITSgeomPPRasymmFMD(AliITSgeom *geom){
153 // Initilizes the geometry transformation class AliITSgeom
154 // to values appropreate to this specific geometry. Now that
155 // the segmentation is part of AliITSgeom, the detector
156 // segmentations are also defined here.
157 // Inputs:
158 // AliITSgeom *geom A pointer to the AliITSgeom class
159 // Outputs:
160 // AliITSgeom *geom This pointer recreated and properly inilized.
161 // Return:
162 // none.
163 // const Double_t kcm2micron = 1.0E4;
164 const Int_t kItype=0; // Type of transormation defined 0=> Geant
165 const Int_t klayers = 6; // number of layers in the ITS
166 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
167 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
6b0f3880 168 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
169 const TString kPathbase = "/ALIC_1/ITSV_1/ITSD_1/";
170 const TString kNames[2][klayers] = {
023ae34b 171 {"%sIT12_1/I12A_%d/I10A_%d/I103_%d/I101_1/ITS1_1", // lay=1
172 "%sIT12_1/I12A_%d/I20A_%d/I1D3_%d/I1D1_1/ITS2_1", // lay=2
173 "%sIT34_1/I004_%d/I302_%d/ITS3_%d/", // lay=3
174 "%sIT34_1/I005_%d/I402_%d/ITS4_%d/", // lay=4
175 "%sIT56_1/I565_%d/I562_%d/ITS5_%d/", // lay=5
176 "%sIT56_1/I569_%d/I566_%d/ITS6_%d/"},// lay=6
177 {"%sIT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
178 "%sIT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
179 "%sIT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
180 "%sIT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
181 "%sIT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
182 "%sIT56_1/I569_%d/I566_%d/ITS6_%d"}};// Lay=6
183 /*
184 Int_t itsGeomTreeCopys[knlayers][3]= {{10, 2, 4},// lay=1
185 {10, 4, 4},// lay=2
186 {14, 6, 1},// lay=3
187 {22, 8, 1},// lay=4
188 {34,22, 1},// lay=5
189 {38,25, 1}};//lay=6
190 */
191 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2;
192 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
193 TArrayD shapePar;
194 TString path,shapeName;
195 TGeoHMatrix materix;
196 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
24e270ad 197 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
023ae34b 198
199 if(fTiming) time->Start();
200 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
201 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
202 for(mod=0;mod<nmods;mod++){
203 DecodeDetectorLayers(mod,lay,lad,det); // Write
6b0f3880 204 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
023ae34b 205 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
6b0f3880 206 path.Form(kNames[fMinorVersion-1][lay-1].Data(),
207 kPathbase.Data(),cpn0,cpn1,cpn2);
023ae34b 208 geom->GetGeomMatrix(mod)->SetPath(path);
209 GetTransformation(path.Data(),materix);
210 geom->SetTrans(mod,materix.GetTranslation());
211 geom->SetRotMatrix(mod,materix.GetRotationMatrix());
6b0f3880 212 if(initSeg[kIdet[lay-1]]) continue;
023ae34b 213 GetShape(path,shapeName,shapePar);
214 if(shapeName.CompareTo("BOX")){
215 Error("InitITSgeom","Geometry changed without proper code update"
216 "or error in reading geometry. Shape is not BOX.");
217 return kFALSE;
218 } // end if
6b0f3880 219 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
023ae34b 220 } // end for module
221 if(fTiming){
222 time->Stop();
223 time->Print();
224 delete time;
225 } // end if
226 return kTRUE;
227}
228//______________________________________________________________________
229Bool_t AliITSInitGeometry::InitGeomShapePPRasymmFMD(AliITSDetector idet,
230 Bool_t *initSeg,
231 TArrayD &shapePar,
232 AliITSgeom *geom){
233 // Initilizes the geometry segmentation class AliITSgeomS?D, or
234 // AliITSsegmentationS?D depending on the vaule of fSegGeom,
235 // to values appropreate to this specific geometry. Now that
236 // the segmentation is part of AliITSgeom, the detector
237 // segmentations are also defined here.
238 // Inputs:
239 // Int_t lay The layer number/name.
240 // AliITSgeom *geom A pointer to the AliITSgeom class
241 // Outputs:
242 // AliITSgeom *geom This pointer recreated and properly inilized.
243 // Return:
244 // none.
245 // const Double_t kcm2micron = 1.0E4;
246 const Double_t kmicron2cm = 1.0E-4;
247 Int_t i;
248 TArrayF shapeParF;
249
250 shapeParF.Set(shapePar.GetSize());
251 for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
252 switch (idet){
253 case kSPD:{
254 initSeg[idet] = kTRUE;
255 AliITSgeomSPD *geomSPD = new AliITSgeomSPD425Short();
256 Float_t bx[256],bz[280];
257 for(i=000;i<256;i++) bx[i] = 50.0*kmicron2cm; // in x all are 50 microns.
258 for(i=000;i<160;i++) bz[i] = 425.0*kmicron2cm; // most are 425 microns
259 // except below
260 for(i=160;i<280;i++) bz[i] = 0.0*kmicron2cm; // Outside of detector.
261 bz[ 31] = bz[ 32] = 625.0*kmicron2cm; // first chip boundry
262 bz[ 63] = bz[ 64] = 625.0*kmicron2cm; // first chip boundry
263 bz[ 95] = bz[ 96] = 625.0*kmicron2cm; // first chip boundry
264 bz[127] = bz[128] = 625.0*kmicron2cm; // first chip boundry
265 bz[160] = 425.0*kmicron2cm;// Set so that there is no zero pixel size for fNz.
266 geomSPD->ReSetBins(shapeParF[1],256,bx,160,bz);
267 geom->ReSetShape(idet,geomSPD);
268 }break;
269 case kSDD:{
270 initSeg[idet] = kTRUE;
271 AliITSgeomSDD *geomSDD = new AliITSgeomSDD256(shapeParF.GetSize(),
272 shapeParF.GetArray());
273 geom->ReSetShape(idet,geomSDD);
274 }break;
275 case kSSD:{
276 initSeg[idet] = kTRUE;
277 AliITSgeomSSD *geomSSD = new AliITSgeomSSD275and75(
278 shapeParF.GetSize(),shapeParF.GetArray());
279 geom->ReSetShape(idet,geomSSD);
280 }break;
281 default:{// Others, Note no kSDDp or kSSDp in this geometry.
282 geom->ReSetShape(idet,0);
283 Info("InitGeomShapePPRasymmFMD",
284 "default Dx=%f Dy=%f Dz=%f default=%d",
285 shapePar[0],shapePar[1],shapePar[2],idet);
286 }break;
287 } // end switch
288 return kTRUE;
289}
290//______________________________________________________________________
291Bool_t AliITSInitGeometry::InitSegmentationPPRasymmFMD(AliITSDetector idet,
292 Bool_t *initSeg,
293 TArrayD &shapePar,
294 AliITSgeom *geom){
295 // Initilizes the geometry segmentation class AliITSgeomS?D, or
296 // AliITSsegmentationS?D depending on the vaule of fSegGeom,
297 // to values appropreate to this specific geometry. Now that
298 // the segmentation is part of AliITSgeom, the detector
299 // segmentations are also defined here.
300 // Inputs:
301 // Int_t lay The layer number/name.
302 // AliITSgeom *geom A pointer to the AliITSgeom class
303 // Outputs:
304 // AliITSgeom *geom This pointer recreated and properly inilized.
305 // Return:
306 // none.
307 const Double_t kcm2micron = 1.0E4;
308 Int_t i;
309
310 switch (idet){
311 case kSPD:{
312 initSeg[idet] = kTRUE;
313 AliITSsegmentationSPD *segSPD = new AliITSsegmentationSPD();
314 segSPD->SetDetSize(2.*shapePar[0]*kcm2micron, // X
315 2.*shapePar[2]*kcm2micron, // Z
316 2.*shapePar[1]*kcm2micron);// Y Microns
317 segSPD->SetNPads(256,160);// Number of Bins in x and z
318 Float_t bx[256],bz[280];
319 for(i=000;i<256;i++) bx[i] = 50.0; // in x all are 50 microns.
320 for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns
321 // except below
322 for(i=160;i<280;i++) bz[i] = 0.0; // Outside of detector.
323 bz[ 31] = bz[ 32] = 625.0; // first chip boundry
324 bz[ 63] = bz[ 64] = 625.0; // first chip boundry
325 bz[ 95] = bz[ 96] = 625.0; // first chip boundry
326 bz[127] = bz[128] = 625.0; // first chip boundry
327 bz[160] = 425.0;// Set so that there is no zero pixel size for fNz.
328 segSPD->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
329 geom->ReSetShape(idet,segSPD);
330 }break;
331 case kSDD:{
332 initSeg[idet] = kTRUE;
333 AliITSsegmentationSDD *segSDD = new AliITSsegmentationSDD();
334 segSDD->SetDetSize(shapePar[0]*kcm2micron, // X
335 2.*shapePar[2]*kcm2micron, // Z
336 2.*shapePar[1]*kcm2micron);// Y Microns
337 segSDD->SetNPads(256,256);// Anodes, Samples
338 geom->ReSetShape(idet,segSDD);
339 }break;
340 case kSSD:{
341 initSeg[idet] = kTRUE;
342 AliITSsegmentationSSD *segSSD = new AliITSsegmentationSSD();
343 segSSD->SetDetSize(2.*shapePar[0]*kcm2micron, // X
344 2.*shapePar[2]*kcm2micron, // Z
345 2.*shapePar[1]*kcm2micron);// Y Microns.
346 segSSD->SetPadSize(95.,0.); // strip x pitch in microns
347 segSSD->SetNPads(768,2); // number of strips on each side, sides.
348 segSSD->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
349 segSSD->SetAnglesLay5(0.0075,0.0275);//strip angels rad P and N
350 segSSD->SetAnglesLay6(0.0275,0.0075);//strip angels rad P and N
351 geom->ReSetShape(idet,segSSD);
352 }break;
353 default:{// Others, Note no kSDDp or kSSDp in this geometry.
354 geom->ReSetShape(idet,0);
355 Info("InitSegmentationPPRasymmFMD",
356 "default segmentation Dx=%f Dy=%f Dz=%f default=%d",
357 shapePar[0],shapePar[1],shapePar[2],idet);
358 }break;
359 } // end switch
360 return kTRUE;
361}
362//______________________________________________________________________
363Bool_t AliITSInitGeometry::GetTransformation(const TString &volumePath,
364 TGeoHMatrix &mat){
365 // Returns the Transformation matrix between the volume specified
366 // by the path volumePath and the Top or mater volume. The format
367 // of the path volumePath is as follows (assuming ALIC is the Top volume)
368 // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
369 // or master volume which has only 1 instance of. Of all of the daughter
370 // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
371 // the daughter volume of DDIP is S05I copy #2 and so on.
372 // Inputs:
373 // TString& volumePath The volume path to the specific volume
374 // for which you want the matrix. Volume name
375 // hierarchy is separated by "/" while the
376 // copy number is appended using a "_".
377 // Outputs:
378 // TGeoHMatrix &mat A matrix with its values set to those
379 // appropriate to the Local to Master transformation
380 // Return:
381 // A logical value if kFALSE then an error occurred and no change to
382 // mat was made.
383
384 // We have to preserve the modeler state
385
386 // Preserve the modeler state.
387 gGeoManager->PushPath();
388 if (!gGeoManager->cd(volumePath.Data())) {
389 gGeoManager->PopPath();
390 Error("GetTransformation","Error in cd-ing to ",volumePath.Data());
391 return kFALSE;
392 } // end if !gGeoManager
393 mat = *gGeoManager->GetCurrentMatrix();
394 // Retstore the modeler state.
395 gGeoManager->PopPath();
396 return kTRUE;
397}
398//______________________________________________________________________
399Bool_t AliITSInitGeometry::GetShape(const TString &volumePath,
400 TString &shapeType,TArrayD &par){
401 // Returns the shape and its parameters for the volume specified
402 // by volumeName.
403 // Inputs:
404 // TString& volumeName The volume name
405 // Outputs:
406 // TString &shapeType Shape type
407 // TArrayD &par A TArrayD of parameters with all of the
408 // parameters of the specified shape.
409 // Return:
410 // A logical indicating whether there was an error in getting this
411 // information
412 Int_t npar;
413 gGeoManager->PushPath();
414 if (!gGeoManager->cd(volumePath.Data())) {
415 gGeoManager->PopPath();
416 return kFALSE;
417 }
418 TGeoVolume * vol = gGeoManager->GetCurrentVolume();
419 gGeoManager->PopPath();
420 if (!vol) return kFALSE;
421 TGeoShape *shape = vol->GetShape();
6b0f3880 422 TClass *classType = shape->IsA();
423 if (classType==TGeoBBox::Class()) {
023ae34b 424 shapeType = "BOX";
425 npar = 3;
426 par.Set(npar);
427 TGeoBBox *box = (TGeoBBox*)shape;
428 par.AddAt(box->GetDX(),0);
429 par.AddAt(box->GetDY(),1);
430 par.AddAt(box->GetDZ(),2);
431 return kTRUE;
432 }
6b0f3880 433 if (classType==TGeoTrd1::Class()) {
023ae34b 434 shapeType = "TRD1";
435 npar = 4;
436 par.Set(npar);
437 TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
438 par.AddAt(trd1->GetDx1(),0);
439 par.AddAt(trd1->GetDx2(),1);
440 par.AddAt(trd1->GetDy(), 2);
441 par.AddAt(trd1->GetDz(), 3);
442 return kTRUE;
443 }
6b0f3880 444 if (classType==TGeoTrd2::Class()) {
023ae34b 445 shapeType = "TRD2";
446 npar = 5;
447 par.Set(npar);
448 TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
449 par.AddAt(trd2->GetDx1(),0);
450 par.AddAt(trd2->GetDx2(),1);
451 par.AddAt(trd2->GetDy1(),2);
452 par.AddAt(trd2->GetDy2(),3);
453 par.AddAt(trd2->GetDz(), 4);
454 return kTRUE;
455 }
6b0f3880 456 if (classType==TGeoTrap::Class()) {
023ae34b 457 shapeType = "TRAP";
458 npar = 11;
459 par.Set(npar);
460 TGeoTrap *trap = (TGeoTrap*)shape;
461 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
462 par.AddAt(trap->GetDz(),0);
463 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
464 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
465 par.AddAt(trap->GetH1(),3);
466 par.AddAt(trap->GetBl1(),4);
467 par.AddAt(trap->GetTl1(),5);
468 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
469 par.AddAt(trap->GetH2(),7);
470 par.AddAt(trap->GetBl2(),8);
471 par.AddAt(trap->GetTl2(),9);
472 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
473 return kTRUE;
474 }
6b0f3880 475 if (classType==TGeoTube::Class()) {
023ae34b 476 shapeType = "TUBE";
477 npar = 3;
478 par.Set(npar);
479 TGeoTube *tube = (TGeoTube*)shape;
480 par.AddAt(tube->GetRmin(),0);
481 par.AddAt(tube->GetRmax(),1);
482 par.AddAt(tube->GetDz(),2);
483 return kTRUE;
484 }
6b0f3880 485 if (classType==TGeoTubeSeg::Class()) {
023ae34b 486 shapeType = "TUBS";
487 npar = 5;
488 par.Set(npar);
489 TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
490 par.AddAt(tubs->GetRmin(),0);
491 par.AddAt(tubs->GetRmax(),1);
492 par.AddAt(tubs->GetDz(),2);
493 par.AddAt(tubs->GetPhi1(),3);
494 par.AddAt(tubs->GetPhi2(),4);
495 return kTRUE;
496 }
6b0f3880 497 if (classType==TGeoCone::Class()) {
023ae34b 498 shapeType = "CONE";
499 npar = 5;
500 par.Set(npar);
501 TGeoCone *cone = (TGeoCone*)shape;
502 par.AddAt(cone->GetDz(),0);
503 par.AddAt(cone->GetRmin1(),1);
504 par.AddAt(cone->GetRmax1(),2);
505 par.AddAt(cone->GetRmin2(),3);
506 par.AddAt(cone->GetRmax2(),4);
507 return kTRUE;
508 }
6b0f3880 509 if (classType==TGeoConeSeg::Class()) {
023ae34b 510 shapeType = "CONS";
511 npar = 7;
512 par.Set(npar);
513 TGeoConeSeg *cons = (TGeoConeSeg*)shape;
514 par.AddAt(cons->GetDz(),0);
515 par.AddAt(cons->GetRmin1(),1);
516 par.AddAt(cons->GetRmax1(),2);
517 par.AddAt(cons->GetRmin2(),3);
518 par.AddAt(cons->GetRmax2(),4);
519 par.AddAt(cons->GetPhi1(),5);
520 par.AddAt(cons->GetPhi2(),6);
521 return kTRUE;
522 }
6b0f3880 523 if (classType==TGeoSphere::Class()) {
023ae34b 524 shapeType = "SPHE";
525 npar = 6;
526 par.Set(npar);
527
528 TGeoSphere *sphe = (TGeoSphere*)shape;
529 par.AddAt(sphe->GetRmin(),0);
530 par.AddAt(sphe->GetRmax(),1);
531 par.AddAt(sphe->GetTheta1(),2);
532 par.AddAt(sphe->GetTheta2(),3);
533 par.AddAt(sphe->GetPhi1(),4);
534 par.AddAt(sphe->GetPhi2(),5);
535 return kTRUE;
536 }
6b0f3880 537 if (classType==TGeoPara::Class()) {
023ae34b 538 shapeType = "PARA";
539 npar = 6;
540 par.Set(npar);
541 TGeoPara *para = (TGeoPara*)shape;
542 par.AddAt(para->GetX(),0);
543 par.AddAt(para->GetY(),1);
544 par.AddAt(para->GetZ(),2);
545 par.AddAt(para->GetTxy(),3);
546 par.AddAt(para->GetTxz(),4);
547 par.AddAt(para->GetTyz(),5);
548 return kTRUE;
549 }
6b0f3880 550 if (classType==TGeoPgon::Class()) {
023ae34b 551 shapeType = "PGON";
552 TGeoPgon *pgon = (TGeoPgon*)shape;
553 Int_t nz = pgon->GetNz();
554 const Double_t *rmin = pgon->GetRmin();
555 const Double_t *rmax = pgon->GetRmax();
556 const Double_t *z = pgon->GetZ();
557 npar = 4 + 3*nz;
558 par.Set(npar);
559 par.AddAt(pgon->GetPhi1(),0);
560 par.AddAt(pgon->GetDphi(),1);
561 par.AddAt(pgon->GetNedges(),2);
562 par.AddAt(pgon->GetNz(),3);
563 for (Int_t i=0; i<nz; i++) {
564 par.AddAt(z[i], 4+3*i);
565 par.AddAt(rmin[i], 4+3*i+1);
566 par.AddAt(rmax[i], 4+3*i+2);
567 }
568 return kTRUE;
569 }
6b0f3880 570 if (classType==TGeoPcon::Class()) {
023ae34b 571 shapeType = "PCON";
572 TGeoPcon *pcon = (TGeoPcon*)shape;
573 Int_t nz = pcon->GetNz();
574 const Double_t *rmin = pcon->GetRmin();
575 const Double_t *rmax = pcon->GetRmax();
576 const Double_t *z = pcon->GetZ();
577 npar = 3 + 3*nz;
578 par.Set(npar);
579 par.AddAt(pcon->GetPhi1(),0);
580 par.AddAt(pcon->GetDphi(),1);
581 par.AddAt(pcon->GetNz(),2);
582 for (Int_t i=0; i<nz; i++) {
583 par.AddAt(z[i], 3+3*i);
584
585 par.AddAt(rmin[i], 3+3*i+1);
586 par.AddAt(rmax[i], 3+3*i+2);
587 }
588 return kTRUE;
589 }
6b0f3880 590 if (classType==TGeoEltu::Class()) {
023ae34b 591 shapeType = "ELTU";
592 npar = 3;
593 par.Set(npar);
594 TGeoEltu *eltu = (TGeoEltu*)shape;
595 par.AddAt(eltu->GetA(),0);
596 par.AddAt(eltu->GetB(),1);
597 par.AddAt(eltu->GetDz(),2);
598 return kTRUE;
599 }
6b0f3880 600 if (classType==TGeoHype::Class()) {
023ae34b 601 shapeType = "HYPE";
602 npar = 5;
603 par.Set(npar);
604 TGeoHype *hype = (TGeoHype*)shape;
605 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
606 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
607 par.AddAt(hype->GetDZ(),2);
608 par.AddAt(hype->GetStIn(),3);
609 par.AddAt(hype->GetStOut(),4);
610 return kTRUE;
611 }
6b0f3880 612 if (classType==TGeoGtra::Class()) {
023ae34b 613 shapeType = "GTRA";
614 npar = 12;
615 par.Set(npar);
616 TGeoGtra *trap = (TGeoGtra*)shape;
617 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
618 par.AddAt(trap->GetDz(),0);
619 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
620 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
621 par.AddAt(trap->GetH1(),3);
622 par.AddAt(trap->GetBl1(),4);
623 par.AddAt(trap->GetTl1(),5);
624 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
625 par.AddAt(trap->GetH2(),7);
626 par.AddAt(trap->GetBl2(),8);
627 par.AddAt(trap->GetTl2(),9);
628 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
629 par.AddAt(trap->GetTwistAngle(),11);
630 return kTRUE;
631 }
6b0f3880 632 if (classType==TGeoCtub::Class()) {
023ae34b 633 shapeType = "CTUB";
634 npar = 11;
635 par.Set(npar);
636 TGeoCtub *ctub = (TGeoCtub*)shape;
637 const Double_t *lx = ctub->GetNlow();
638 const Double_t *tx = ctub->GetNhigh();
639 par.AddAt(ctub->GetRmin(),0);
640 par.AddAt(ctub->GetRmax(),1);
641 par.AddAt(ctub->GetDz(),2);
642 par.AddAt(ctub->GetPhi1(),3);
643 par.AddAt(ctub->GetPhi2(),4);
644 par.AddAt(lx[0],5);
645 par.AddAt(lx[1],6);
646 par.AddAt(lx[2],7);
647 par.AddAt(tx[0],8);
648 par.AddAt(tx[1],9);
649 par.AddAt(tx[2],10);
650 return kTRUE;
651 }
652 Error("GetShape","Getting shape parameters for shape %s not implemented",
653 shape->ClassName());
654 return kFALSE;
655}
656//______________________________________________________________________
657void AliITSInitGeometry::DecodeDetector(Int_t &mod,Int_t layer,Int_t cpn0,
6b0f3880 658 Int_t cpn1,Int_t cpn2) const {
023ae34b 659 // decode geometry into detector module number. There are two decoding
660 // Scheams. Old which does not follow the ALICE coordinate system
661 // requirements, and New which dose.
662 // Inputs:
663 // Int_t layer The ITS layer
664 // Int_t cpn0 The lowest copy number
665 // Int_t cpn1 The middle copy number
666 // Int_t cpn2 the highest copy number
667 // Output:
668 // Int_t &mod The module number assoicated with this set
669 // of copy numbers.
670 // Return:
671 // none.
6b0f3880 672 const Int_t kDetPerLadderSPD[2]={2,4};
673 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
674 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
24e270ad 675 Int_t lay=-1,lad=-1,det=-1,i;
023ae34b 676
677 if(fDecode){ // New decoding scheam
678 switch (layer){
679 case 1:{
680 lay = layer;
681 det = 5-cpn2;
682 if(cpn0==4&&cpn1==1) lad=1;
683 else if(cpn0==4&&cpn1==2) lad=20;
684 else if(cpn0<4){
6b0f3880 685 lad = 8-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 686 }else{ // cpn0>4
6b0f3880 687 lad = 28-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 688 } // end if
689 } break;
690 case 2:{
691 lay = layer;
692 det = 5-cpn2;
693 if(cpn0==4&&cpn1==1) lad=1;
694 else if(cpn0<4){
6b0f3880 695 lad = 14-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 696 }else{ // cpn0>4
6b0f3880 697 lad = 54-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 698 } // end if
699 } break;
700 case 3:{
701 lay = layer;
702 if(cpn0<5) lad = 5-cpn0;
703 else lad = 19-cpn0;
704 det = 7-cpn1;
705 } break;
706 case 4:{
707 lay = layer;
708 if(cpn0<7) lad = 7-cpn0;
709 else lad = 29-cpn0;
710 det = 9-cpn1;
711 } break;
712 case 5:{
713 lay = layer;
714 if(cpn0<10) lad = 10-cpn0;
715 else lad = 44-cpn0;
716 det = 23-cpn1;
717 } break;
718 case 6:{
719 lay = layer;
720 if(cpn0<9) lad = 9-cpn0;
721 else lad = 47-cpn0;
722 det = 26-cpn1;
723 } break;
724 } // end switch
725 mod = 0;
6b0f3880 726 for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
727 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
023ae34b 728 return;
729 } // end if
730 // Old decoding scheam
731 switch(layer){
732 case 1: case 2:{
733 lay = layer;
6b0f3880 734 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 735 det = cpn2;
736 }break;
737 case 3: case 4:{
738 lay = layer;
739 lad = cpn0;
740 det = cpn1;
741 }break;
742 case 5: case 6:{
743 lay = layer;
744 lad = cpn0;
745 det = cpn1;
746 }break;
747 default:{
748 }break;
749 } // end switch
750 mod = 0;
6b0f3880 751 for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
752 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
023ae34b 753 return;
754}
755//______________________________________________________________________
756void AliITSInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
757 Int_t &cpn1,Int_t &cpn2){
758 // decode geometry into detector module number. There are two decoding
759 // Scheams. Old which does not follow the ALICE coordinate system
760 // requirements, and New which dose.
761 // Inputs:
762 // Int_t mod The module number assoicated with this set
763 // of copy numbers.
764 // Output:
765 // Int_t cpn0 The lowest copy number
766 // Int_t cpn1 The middle copy number
767 // Int_t cpn2 the highest copy number
768 // Return:
769 // none.
6b0f3880 770 const Int_t kITSgeoTreeCopys[6][3]= {{10, 2, 4},// lay=1
023ae34b 771 {10, 4, 4},// lay=2
772 {14, 6, 1},// lay=3
773 {22, 8, 1},// lay=4
774 {34,22, 1},// lay=5
775 {38,25, 1}};//lay=6
6b0f3880 776 const Int_t kDetPerLadderSPD[2]={2,4};
777 // const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
778 // const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
023ae34b 779 Int_t lay,lad,det;
780
781 cpn0 = cpn1 = cpn2 = 0;
782 DecodeDetectorLayers(mod,lay,lad,det);
783 if(fDecode){ // New decoding scheam
784 switch (lay){
785 case 1:{
786 cpn2 = 5-det; // Detector 1-4
6b0f3880 787 cpn1 = 1+(lad-1)%kDetPerLadderSPD[lay-1];
788 cpn0 = 5-(lad+kDetPerLadderSPD[lay-1])/kDetPerLadderSPD[lay-1];
789 if(mod>27) cpn0 = 15-(lad+kDetPerLadderSPD[lay-1])/
790 kDetPerLadderSPD[lay-1];
023ae34b 791 } break;
792 case 2:{
793 cpn2 = 5-det; // Detector 1-4
6b0f3880 794 cpn1 = 4-(lad+2)%kDetPerLadderSPD[lay-1];
795 cpn0 = 1+(14-cpn1-lad)/kDetPerLadderSPD[lay-1];
796 if(mod>131) cpn0 = 1+(54-lad-cpn1)/kDetPerLadderSPD[lay-1];
023ae34b 797 } break;
798 case 3:{
799 cpn2 = 1;
800 if(lad<5) cpn0 = 5-lad;
801 else cpn0 = 19-lad;
802 cpn1 = 7-det;
803 } break;
804 case 4:{
805 cpn2 = 1;
806 if(lad<7) cpn0 = 7-lad;
807 else cpn0 = 29-lad;
808 cpn1 = 9-det;
809 } break;
810 case 5:{
811 cpn2 = 1;
812 if(lad<10) cpn0 = 10-lad;
813 else cpn0 = 44-lad;
814 cpn1 = 23-det;
815 } break;
816 case 6:{
817 cpn2 = 1;
818 if(lad<9) cpn0 = 9-lad;
819 else cpn0 = 47-lad;
820 cpn1 = 26-det;
821 } break;
822 default:{
823 Error("RecodeDetector","New: mod=%d lay=%d not 1-6.");
824 return;
825 } break;
826 } // end switch
827 if(cpn0<1||cpn1<1||cpn2<1||
6b0f3880 828 cpn0>kITSgeoTreeCopys[lay-1][0]||
829 cpn1>kITSgeoTreeCopys[lay-1][1]||
830 cpn2>kITSgeoTreeCopys[lay-1][2])
023ae34b 831 Error("RecodeDetector",
832 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
833 cpn0,cpn1,cpn2,mod,lay,lad,det);
834 return;
835 } // end if
836 // Old encoding
837 switch (lay){
838 case 1: case 2:{
839 cpn2 = det; // Detector 1-4
6b0f3880 840 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
841 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
023ae34b 842 } break;
843 case 3: case 4: case 5 : case 6:{
844 cpn2 = 1;
845 cpn1 = det;
846 cpn0 = lad;
847 } break;
848 default:{
849 Error("RecodeDetector","Old: mod=%d lay=%d not 1-6.");
850 return;
851 } break;
852 } // end switch
853 if(cpn0<1||cpn1<1||cpn2<1||
6b0f3880 854 cpn0>kITSgeoTreeCopys[lay-1][0]||
855 cpn1>kITSgeoTreeCopys[lay-1][1]||
856 cpn2>kITSgeoTreeCopys[lay-1][2])
023ae34b 857 Error("RecodeDetector",
858 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
859 cpn0,cpn1,cpn2,mod,lay,lad,det);
860 return;
861}
862//______________________________________________________________________
863void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &lay,
864 Int_t &lad,Int_t &det){
865 // decode geometry into detector module number. There are two decoding
866 // Scheams. Old which does not follow the ALICE coordinate system
867 // requirements, and New which dose. Note, this use of layer ladder
868 // and detector numbers are strictly for internal use of this
869 // specific code. They do not represent the "standard" layer ladder
870 // or detector numbering except in a very old and obsoleate sence.
871 // Inputs:
872 // Int_t mod The module number assoicated with this set
873 // of copy numbers.
874 // Output:
875 // Int_t lay The layer number
876 // Int_t lad The ladder number
877 // Int_t det the dettector number
878 // Return:
879 // none.
6b0f3880 880 // const Int_t kDetPerLadderSPD[2]={2,4};
881 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
882 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
023ae34b 883 Int_t mod2;
884
885 det = 0;
886 lad = 0;
887 lay = 0;
888 mod2 = 0;
889 do{
6b0f3880 890 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
023ae34b 891 lay++;
892 }while(mod2<=mod); // end while
893 if(lay>6||lay<1) Error("DecodeDetectorLayers","0<lay=%d>6",lay);
6b0f3880 894 mod2 -= kLadPerLayer[lay-1]*kDetPerLadder[lay-1];
023ae34b 895 do{
896 lad++;
6b0f3880 897 mod2 += kDetPerLadder[lay-1];
023ae34b 898 }while(mod2<=mod); // end while
6b0f3880 899 if(lad>kLadPerLayer[lay-1]||lad<1) Error("DecodeDetectorLayera",
900 "lad=%d>kLadPerLayer[lay-1=%d]=%d mod=%d mod2=%d",lad,lay-1,
901 kLadPerLayer[lay-1],mod,mod2);
902 mod2 -= kDetPerLadder[lay-1];
023ae34b 903 det = mod-mod2+1;
6b0f3880 904 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
023ae34b 905 "det=%d>detPerLayer[lay-1=%d]=%d mod=%d mod2=%d lad=%d",det,
6b0f3880 906 lay-1,kDetPerLadder[lay-1],mod,mod2,lad);
023ae34b 907 return;
908}
909