]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSInitGeometry.cxx
Using references in the arguments of the methods, removing warnings
[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>
3010c308 44#include <TMath.h>
023ae34b 45
6def2bd2 46#include "AliLog.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"
023ae34b 53#include "AliITSgeom.h"
54#include "AliITSInitGeometry.h"
012f0f4c 55#include <TDatime.h>
023ae34b 56
57ClassImp(AliITSInitGeometry)
108bd0fe 58
59const Bool_t AliITSInitGeometry::fgkOldSPDbarrel = kTRUE;
60const Bool_t AliITSInitGeometry::fgkOldSDDbarrel = kFALSE;
61const Bool_t AliITSInitGeometry::fgkOldSSDbarrel = kTRUE;
62const Bool_t AliITSInitGeometry::fgkOldSDDcone = kTRUE;
63const Bool_t AliITSInitGeometry::fgkOldSSDcone = kTRUE;
64const Bool_t AliITSInitGeometry::fgkOldSPDshield = kTRUE;
65const Bool_t AliITSInitGeometry::fgkOldSDDshield = kTRUE;
66const Bool_t AliITSInitGeometry::fgkOldSSDshield = kTRUE;
67const Bool_t AliITSInitGeometry::fgkOldServices = kTRUE;
68const Bool_t AliITSInitGeometry::fgkOldSupports = kTRUE;
023ae34b 69//______________________________________________________________________
70AliITSInitGeometry::AliITSInitGeometry():
012f0f4c 71TObject(), // Base Class
72fName(0), // Geometry name
73fMinorVersion(-1), // Minor version number/type
74fMajorVersion(kvDefault), // Major versin number
75fTiming(kFALSE), // Flag to start inilization timing
76fSegGeom(kFALSE), // Flag to switch between the old use of
77 // AliITSgeomS?D class, or AliITSsegmentation
78 // class in fShape of AliITSgeom class.
79fDecode(kFALSE), // Flag for new/old decoding
80fDebug(0){ // Debug flag
023ae34b 81 // Default Creator
82 // Inputs:
83 // none.
84 // Outputs:
85 // none.
86 // Return:
87 // A default inilized AliITSInitGeometry object
012f0f4c 88
89 fName = "Undefined";
023ae34b 90}
91//______________________________________________________________________
012f0f4c 92AliITSInitGeometry::AliITSInitGeometry(AliITSVersion_t version,
93 Int_t minorversion):
94TObject(), // Base Class
95fName(0), // Geometry name
96fMinorVersion(minorversion), // Minor version number/type
97fMajorVersion(version), // Major versin number
98fTiming(kFALSE), // Flag to start inilization timing
99fSegGeom(kFALSE), // Flag to switch between the old use of
100 // AliITSgeomS?D class, or AliITSsegmentation
101 // class in fShape of AliITSgeom class.
102fDecode(kFALSE), // Flag for new/old decoding
103fDebug(0){ // Debug flag
023ae34b 104 // Default Creator
105 // Inputs:
106 // none.
107 // Outputs:
108 // none.
109 // Return:
110 // A default inilized AliITSInitGeometry object
108bd0fe 111
012f0f4c 112 if(version == kvPPRasymmFMD && (fMinorVersion==1|| fMinorVersion==2)){
113 fName="AliITSvPPRasymmFMD";
114 }else if(version == kv11Hybrid){
115 fName="AliITSv11Hybrid";
116 }else {
117 AliFatal(Form("Undefined geometry: fMajorVersion=%d, "
118 "fMinorVersion= %d",(Int_t)fMajorVersion,fMinorVersion));
119 fName = "Undefined";
108bd0fe 120 } // end if
023ae34b 121 return;
122}
123//______________________________________________________________________
124AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(){
125 // Creates and 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 // none.
131 // Outputs:
132 // none.
133 // Return:
134 // A pointer to a new properly inilized AliITSgeom class. If
135 // pointer = 0 then failed to init.
136
012f0f4c 137
138 AliITSVersion_t version = kvDefault;
139 Int_t minor = 0;
140 TDatime datetime;
141 TGeoVolume *itsV = gGeoManager->GetVolume("ITSV");
142 if(!itsV){
143 Error("CreateAliITSgeom","Can't find ITS volume ITSV, aborting");
144 return 0;
145 }// end if
146 const Char_t *title = itsV->GetTitle();
147 if(!ReadVersionString(title,(Int_t)strlen(title),version,minor,
148 datetime))
149 Warning("UpdateInternalGeometry","Can't read title=%s\n",title);
150 SetTiming(kFALSE);
151 SetSegGeom(kFALSE);
152 SetDecoding(kFALSE);
153 AliITSgeom *geom = CreateAliITSgeom(version,minor);
154 AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
155 return geom;
156}
157//______________________________________________________________________
158AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(Int_t major,Int_t minor){
159 // Creates and Initilizes the geometry transformation class AliITSgeom
160 // to values appropreate to this specific geometry. Now that
161 // the segmentation is part of AliITSgeom, the detector
162 // segmentations are also defined here.
163 // Inputs:
164 // Int_t major major version, see AliITSVersion_t
165 // Int_t minor minor version
166 // Outputs:
167 // none.
168 // Return:
169 // A pointer to a new properly inilized AliITSgeom class. If
170 // pointer = 0 then failed to init.
171
172 switch(major){
173 case kvtest:
174 SetGeometryName("AliITSvtest");
175 SetVersion(kvtest,minor);
176 break;
177 case kvSPD02:
178 SetGeometryName("AliITSvSPD02");
179 SetVersion(kvSPD02,minor);
180 break;
181 case kvSDD03:
182 SetGeometryName("AliITSvSDD03");
183 SetVersion(kvSDD03,minor);
184 break;
185 case kvSSD03:
186 SetGeometryName("AliITSvSSD03");
187 SetVersion(kvSSD03,minor);
188 break;
189 case kvITS04:
190 SetGeometryName("AliITSvBeamTest03");
191 SetVersion(kvITS04,minor);
192 break;
193 case kvPPRcourseasymm:
194 SetGeometryName("AliITSvPPRcourseasymm");
195 SetVersion(kvPPRcourseasymm,minor);
196 break;
197 case kvPPRasymmFMD:
198 SetGeometryName("AliITSvPPRasymmFMD");
199 SetVersion(kvPPRasymmFMD,minor);
200 break;
201 case kv11:
202 SetGeometryName("AliITSv11");
203 SetVersion(kv11,minor);
204 break;
205 case kv11Hybrid:
206 SetGeometryName("AliITSv11Hybrid");
207 SetVersion(kv11Hybrid,minor);
208 break;
209 case kvDefault:
210 default:
211 SetGeometryName("Undefined");
212 SetVersion(kvDefault,minor);
213 break;
214 } // end switch
023ae34b 215 AliITSgeom *geom = new AliITSgeom();
216 if(!InitAliITSgeom(geom)){ // Error initilization failed
217 delete geom;
218 geom = 0;
219 } // end if
220 return geom;
221}
222//______________________________________________________________________
223Bool_t AliITSInitGeometry::InitAliITSgeom(AliITSgeom *geom){
6def2bd2 224 // Initilizes the geometry transformation class AliITSgeom
225 // to values appropreate to this specific geometry. Now that
226 // the segmentation is part of AliITSgeom, the detector
227 // segmentations are also defined here.
228 // Inputs:
229 // AliITSgeom *geom A pointer to the AliITSgeom class
230 // Outputs:
231 // AliITSgeom *geom This pointer recreated and properly inilized.
232 // Return:
233 // none.
023ae34b 234
012f0f4c 235 if(!gGeoManager){
236 AliFatal("The geometry manager has not been initialized (e.g. "
237 "TGeoManager::Import(\"geometry.root\")should be "
238 "called in advance) - exit forced");
239 return kFALSE;
240 } // end if
241 switch(fMajorVersion) {
242 case kvtest: {
243 if(GetMinorVersion()==1) return InitAliITSgeomPPRasymmFMD(geom);
244 else if(GetMinorVersion()==2) return InitAliITSgeomtest2(geom);
245 } break; // end case
246 case kvSPD02: {
247 return InitAliITSgeomSPD02(geom);
248 } break; // end case
249 case kvSDD03: {
250 return InitAliITSgeomSDD03(geom);
251 } break; // end case
252 case kvSSD03: {
253 return InitAliITSgeomSSD03(geom);
254 } break; // end case
255 case kvITS04: {
256 return InitAliITSgeomITS04(geom);
257 } break; // end case
258 case kvPPRasymmFMD: {
259 return InitAliITSgeomPPRasymmFMD(geom);
260 } break; // end case
261 case kvPPRcourseasymm: {
262 return kTRUE; // No sensitive detectors in course geometry
263 } break; // end case
264 case kv11Hybrid: {
265 return InitAliITSgeomV11Hybrid(geom);
266 } break; // end case
267 case kv11: {
268 return InitAliITSgeomV11(geom);
269 } break; // end case
270 case kvDefault: default: {
271 AliFatal("Undefined geometry");
272 return kFALSE;
273 } break; // end case
274 } // end switch
6def2bd2 275 return kFALSE;
012f0f4c 276}
277//______________________________________________________________________
278void AliITSInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
279 // Transpose the rotation matrix part of a TGeoHMatrix. This
280 // is needed because TGeo stores the transpose of the rotation
281 // matrix as compared to what AliITSgeomMatrix uses (and Geant3).
282 // Inputs:
283 // TGeoHMatrix *m The matrix to be transposed
284 // Outputs:
285 // TGEoHMatrix *m The transposed matrix
286 // Return:
287 // none.
288 Int_t i;
289 Double_t r[9];
290
291 if(m==0) return; // no matrix to transpose.
292 for(i=0;i<9;i += 4) r[i] = m->GetRotationMatrix()[i]; // diagonals
293 r[1] = m->GetRotationMatrix()[3];
294 r[2] = m->GetRotationMatrix()[6];
295 r[3] = m->GetRotationMatrix()[1];
296 r[5] = m->GetRotationMatrix()[7];
297 r[6] = m->GetRotationMatrix()[2];
298 r[7] = m->GetRotationMatrix()[5];
299 m->SetRotation(r);
300 return;
301}
302//______________________________________________________________________
303Bool_t AliITSInitGeometry::InitAliITSgeomtest2(AliITSgeom *geom){
304 // Initilizes the geometry transformation class AliITSgeom
305 // to values appropreate to this specific geometry. Now that
306 // the segmentation is part of AliITSgeom, the detector
307 // segmentations are also defined here.
308 // Inputs:
309 // AliITSgeom *geom A pointer to the AliITSgeom class
310 // Outputs:
311 // AliITSgeom *geom This pointer recreated and properly inilized.
312 // Return:
313 // none.
314 // const Double_t kcm2micron = 1.0E4;
315 const Int_t kItype=0; // Type of transormation defined 0=> Geant
316 const Int_t klayers = 6; // number of layers in the ITS
317 const Int_t kladders[klayers] = {1,1,1,1,1,1}; // Number of ladders
318 const Int_t kdetectors[klayers] = {1,1,1,1,1,1};// number of detector/lad
319 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
320 const TString kNames[klayers] = {
321 "/ALIC_1/ITSV_1/ITSspd1_1/ITS1_1", // lay=1
322 "/ALIC_1/ITSV_1/ITSspd2_1/ITS2_1", // lay=2
323 "/ALIC_1/ITSV_1/ITSsdd1_1/ITS3_1", // lay=3
324 "/ALIC_1/ITSV_1/ITSsdd2_1/ITS4_1", // lay=4
325 "/ALIC_1/ITSV_1/ITSssd1_1/ITS5_1", // lay=5
326 "/ALIC_1/ITSV_1/ITSssd2_1/ITS6_1"};// Lay=6
327 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2;
328 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
329 TArrayD shapePar;
330 TString shapeName;
331 TGeoHMatrix matrix;
332 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
333 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
334
335 if(fTiming) time->Start();
336 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
337 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
338 for(mod=0;mod<nmods;mod++){
339 DecodeDetectorLayers(mod,lay,lad,det); // Write
340 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
341 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
342 geom->GetGeomMatrix(mod)->SetPath(kNames[lay-1]);
343 GetTransformation(kNames[lay-1].Data(),matrix);
344 geom->SetTrans(mod,matrix.GetTranslation());
345 TransposeTGeoHMatrix(&matrix); // Transpose TGeo's rotation matrixes
346 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
347 if(initSeg[kIdet[lay-1]]) continue;
348 GetShape(kNames[lay-1],shapeName,shapePar);
349 if(shapeName.CompareTo("BOX")){
350 Error("InitITSgeom2","Geometry changed without proper code update"
351 "or error in reading geometry. Shape is not BOX shape is %s",
352 shapeName.Data());
353 return kFALSE;
354 } // end if
355 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
356 } // end for module
357 if(fTiming){
358 time->Stop();
359 time->Print();
360 delete time;
361 } // end if
362 return kTRUE;
363}
364//______________________________________________________________________
365Bool_t AliITSInitGeometry::InitAliITSgeomSPD02(AliITSgeom *geom){
366 // Initilizes the geometry transformation class AliITSgeom
367 // to values appropreate to this specific geometry. Now that
368 // the segmentation is part of AliITSgeom, the detector
369 // segmentations are also defined here.
370 // Inputs:
371 // AliITSgeom *geom A pointer to the AliITSgeom class
372 // Outputs:
373 // AliITSgeom *geom This pointer recreated and properly inilized.
374 // Return:
375 // none.
376 const Int_t kltypess=2;
377 const Int_t knlayers=5;
378 const TString knames[kltypess]=
379 {"ALIC_1/ITSV_1/ITEL_%d/IMB0_1/IMBS_1",//lay=1,2,4,5
380 "ALIC_1/ITSV_1/IDET_%d/ITS0_1/ITST_1"};// lay=3
381 const Int_t kitsGeomTreeCopys[2]={4,1};
382 const Int_t knlad[knlayers]={knlayers*1},kndet[knlayers]={knlayers*1};
383 TString path,shapeName;
384 TGeoHMatrix matrix;
385 TArrayD shapePar;
386 TArrayF shapeParF;
387 Double_t trans[3]={3*0.0},rot[10]={10*0.0};
388 Int_t npar=3,mod,i,j,lay,lad,det,cpy;
389 Float_t par[20];
390 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
391
392 par[0]=0.64;par[1]=0.5*300.0E-4;par[2]=3.48;
393 mod=5;;
394 geom->Init(0,knlayers,knlad,kndet,mod);
395
396 if(fTiming) time->Start();
397 for(i=0;i<kltypess;i++)for(cpy=1;cpy<=kitsGeomTreeCopys[i];cpy++){
398 path.Form(knames[i].Data(),cpy);
399 GetTransformation(path.Data(),matrix);
400 GetShape(path.Data(),shapeName,shapePar);
401 shapeParF.Set(shapePar.GetSize());
402 for(j=0;j<shapePar.GetSize();j++) shapeParF[j]=shapePar[j];
403 lay = cpy;
404 if(i==0&&cpy>2) lay=cpy+1;
405 if(i==1) lay=3;
406 DecodeDetector(mod,kitsGeomTreeCopys[i],1,cpy,0);
407 DecodeDetectorLayers(mod,lay,lad,det);
408 geom->CreateMatrix(mod,lay,lad,det,kSPD,trans,rot);
409 geom->SetTrans(mod,matrix.GetTranslation());
410 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
411 geom->GetGeomMatrix(mod)->SetPath(path.Data());
412 if(!(geom->IsShapeDefined((Int_t)kSPD)))
413 geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(npar,par));
414 } // end for i,cpy/
415 if(fTiming){
416 time->Stop();
417 time->Print();
418 delete time;
419 } // end if
420 return kTRUE;
421}
422//______________________________________________________________________
423Bool_t AliITSInitGeometry::InitAliITSgeomSDD03(AliITSgeom *geom){
424 // Initilizes the geometry transformation class AliITSgeom
425 // to values appropreate to this specific geometry. Now that
426 // the segmentation is part of AliITSgeom, the detector
427 // segmentations are also defined here.
428 // Inputs:
429 // AliITSgeom *geom A pointer to the AliITSgeom class
430 // Outputs:
431 // AliITSgeom *geom This pointer recreated and properly inilized.
432 // Return:
433 // none
434 const Int_t knlayers=12;
435 // const Int_t kndeep=6;
436 const Int_t kltypess=2;
437 const AliITSDetector kidet[knlayers]={kSSD,kSDD};
438 const TString knames[kltypess]={
439 "/ALIC_1/ITSV_1/ITEL_%d/ITAI_1/IMB0_1/IMBS_1",
440 "/ALIC_1/ITSV_1/IDET_%d/IDAI_1/ITS0_1/ITST_1"};
441 const Int_t kitsGeomTreeCopys[kltypess]={10,2};
442 const Int_t knp=384;
443 const Float_t kpitch=50.E-4;/*cm*/
444 Float_t box[3]={0.5*kpitch*(Float_t)knp,150.E-4,1.0},p[knp+1],n[knp+1];
445 Int_t nlad[knlayers]={knlayers*1};
446 Int_t ndet[knlayers]={knlayers*1};
447 Int_t mod=knlayers,lay=0,lad=0,det=0,i,j,cp0;
448 TString path,shapeName;
449 TGeoHMatrix matrix;
450 Double_t trans[3]={3*0.0},rot[10]={10*0.0};
451 TArrayD shapePar;
452 TArrayF shapeParF;
453 Bool_t isShapeDefined[kltypess]={kltypess*kFALSE};
454
455 geom->Init(0,knlayers,nlad,ndet,mod);
456 p[0]=-box[0];
457 n[0]=box[0];
458 // Fill in anode and cathode strip locations (lower edge)
459 for(i=1;i<knp;i++){
460 p[i] =p[i-1]+kpitch;
461 n[i] =n[i-1]-kpitch;
462 } // end for i
463 p[knp]=box[0];
464 n[knp]=-box[0];
465 for(i=0;i<kltypess;i++)for(cp0=1;cp0<=kitsGeomTreeCopys[i];cp0++){
466 DecodeDetector(mod,kitsGeomTreeCopys[i],cp0,1,2);
467 DecodeDetectorLayers(mod,lay,lad,det);
468 path.Form(knames[i].Data(),cp0);
469 GetTransformation(path.Data(),matrix);
470 GetShape(path.Data(),shapeName,shapePar);
471 shapeParF.Set(shapePar.GetSize());
472 for(j=0;j<shapePar.GetSize();j++)shapeParF[j]=shapePar[j];
473 geom->CreateMatrix(mod,lay,lad,det,kidet[i],trans,rot);
474 geom->SetTrans(mod,matrix.GetTranslation());
475 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
476 geom->GetGeomMatrix(mod)->SetPath(path.Data());
477 switch (kidet[i]){
478 case kSDD: if(!(geom->IsShapeDefined((Int_t)kSDD))){
479 geom->ReSetShape(kSDD,new AliITSgeomSDD256(shapeParF.GetSize(),
480 shapeParF.GetArray()));
481 isShapeDefined[i]=kTRUE;
482 } break;
483 case kSSD:if(!(geom->IsShapeDefined((Int_t)kSSD))){
484 geom->ReSetShape(kSSD,new AliITSgeomSSD(box,0.0,0.0,
485 knp+1,p,knp+1,n));
486 isShapeDefined[i]=kTRUE;
487 } break;
488 default:{} break;
489 } // end switch
490 } // end for i,cp0
491
492 return kTRUE;
493}
494//______________________________________________________________________
495Bool_t AliITSInitGeometry::InitAliITSgeomSSD03(AliITSgeom *geom){
496 // Initilizes the geometry transformation class AliITSgeom
497 // to values appropreate to this specific geometry. Now that
498 // the segmentation is part of AliITSgeom, the detector
499 // segmentations are also defined here.
500 // Inputs:
501 // AliITSgeom *geom A pointer to the AliITSgeom class
502 // Outputs:
503 // AliITSgeom *geom This pointer recreated and properly inilized.
504 // Return:
505 // none.
506 const Int_t knlayers=5;
507 // const Int_t kndeep=6;
508 const Int_t kltypess=3;
509 const AliITSDetector kIdet[knlayers]={kND,kSSD,kND};
510 const TString knames[kltypess]={
511 "/ALIC_1/ITSV_1/ITSA_%d/ITSS_1",
512 "/ALIC_1/ITSV_1/IGAR_%d/IAIR_1/ITST_1",
513 "/ALIC_1/ITSV_1/IFRA_%d/IFRS_1"};
514 const Int_t kitsGeomTreeCopys[kltypess]={3,1,1};
515 const Int_t kitsGeomDetTypes[kltypess]={1,2,3};
516 const Int_t knp=384;
517 const Float_t kpitch=50.E-4;//cm
518 Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
519 Float_t box[3]={0.5*kpitch*(Float_t)knp,150.E-4,1.0},p[knp+1],n[knp+1];
520 Int_t nlad[knlayers]={knlayers*1};
521 Int_t ndet[knlayers]={knlayers*1};
522 Int_t mod=knlayers,lay=0,lad=0,det=0,i,j,cp0;
523 TString path,shapeName;
524 TGeoHMatrix matrix;
525 Double_t trans[3]={3*0.0},rot[10]={10*0.0};
526 TArrayD shapePar;
527 TArrayF shapeParF;
528 Bool_t isShapeDefined[kltypess]={kltypess*kFALSE};
529
530 geom->Init(0,knlayers,nlad,ndet,mod);
531 p[0]=-box[0];
532 n[0]=box[0];
533 // Fill in anode and cathode strip locations (lower edge)
534 for(i=1;i<knp;i++){
535 p[i] =p[i-1]+kpitch;
536 n[i] =n[i-1]-kpitch;
537 } // end for i
538 p[knp]=box[0];
539 n[knp]=-box[0];
540 for(i=0;i<kltypess;i++)for(cp0=1;cp0<=kitsGeomTreeCopys[i];cp0++){
541 DecodeDetector(mod,kitsGeomDetTypes[i],cp0,1,0);
542 DecodeDetectorLayers(mod,lay,lad,det);
543 path.Form(knames[i].Data(),cp0);
544 GetTransformation(path.Data(),matrix);
545 GetShape(path.Data(),shapeName,shapePar);
546 shapeParF.Set(shapePar.GetSize());
547 for(j=0;j<shapePar.GetSize();j++)shapeParF[j]=shapePar[j];
548 geom->CreateMatrix(mod,lay,lad,det,kIdet[i],trans,rot);
549 geom->SetTrans(mod,matrix.GetTranslation());
550 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
551 geom->GetGeomMatrix(mod)->SetPath(path.Data());
552 switch (kIdet[i]){
553 case kSSD:if(!(geom->IsShapeDefined((Int_t)kSSD))){
554 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
555 isShapeDefined[i]=kTRUE;
556 } break;
557 default:{} break;
558 } // end switch
559 } // end for i,cp0
560
561 return kTRUE;
562}
563//______________________________________________________________________
564Bool_t AliITSInitGeometry::InitAliITSgeomITS04(AliITSgeom *geom){
565 // Initilizes the geometry transformation class AliITSgeom
566 // to values appropreate to this specific geometry. Now that
567 // the segmentation is part of AliITSgeom, the detector
568 // segmentations are also defined here.
569 // Inputs:
570 // AliITSgeom *geom A pointer to the AliITSgeom class
571 // Outputs:
572 // AliITSgeom *geom This pointer recreated and properly inilized.
573 // Return:
574 // none.
575
576 // We can not use AliITSvBeamTestITS04::fgk... data members because
577 // AliITSInitGeometry is part of the base library while AliITSvBeamTestITS04
578 // is part of the simulation library. This would introduce a dependance
579 // between the 2 libraries
580
108bd0fe 581
012f0f4c 582 const Int_t knlayers = 6;
583 Int_t nlad[knlayers], ndet[knlayers];
584
585 nlad[0] = 1; ndet[0] = 2;
586 nlad[1] = 1; ndet[1] = 2;
587 nlad[2] = 1; ndet[2] = 1;
588 nlad[3] = 1; ndet[3] = 1;
589 nlad[4] = 1; ndet[4] = 2;
590 nlad[5] = 1; ndet[5] = 2;
108bd0fe 591
012f0f4c 592 Int_t nModTot = 10;
593 geom->Init(0,knlayers,nlad,ndet,nModTot);
108bd0fe 594
012f0f4c 595 /*
596 //=== Set default shapes
597 const Float_t kDxyzSPD[] = {AliITSvBeamTestITS04::fgkSPDwidthSens/2,
598 AliITSvBeamTestITS04::fgkSPDthickSens/2,
599 AliITSvBeamTestITS04::fgkSPDlengthSens/2};
600 if(!(geom->IsShapeDefined(kSPD)))
601 geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(3,(Float_t *)kDxyzSPD));
602
603 const Float_t kDxyzSDD[] = {AliITSvBeamTestITS04::fgkSDDwidthSens/2.,
604 AliITSvBeamTestITS04::fgkSDDthickSens/2.,
605 AliITSvBeamTestITS04::fgkSDDlengthSens/2.};
606 if(!(geom->IsShapeDefined(kSDD)))
607 geom->ReSetShape(kSDD, new AliITSgeomSDD256(3,(Float_t *)kDxyzSDD));
608
609 const Float_t kDxyzSSD[] = {AliITSvBeamTestITS04::fgkSSDlengthSens/2,
610 AliITSvBeamTestITS04::fgkSSDthickSens/2,
611 AliITSvBeamTestITS04::fgkSSDwidthSens/2};
612 if(!(geom->IsShapeDefined(kSSD)))
613 geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(3,(Float_t *)kDxyzSSD));
614
615 // Creating the matrices in AliITSgeom for each sensitive volume
616 // (like in AliITSv11GeometrySDD) mln
617 // Here, each layer is one detector
618
619 char layerName[30];
620 Int_t startMod = 0,mod;
621 TGeoVolume *itsmotherVolume = gGeoManager->GetVolume("ITSV");
622 // SPD
623 for (Int_t i=0; i<4;i++) {
624 sprintf(layerName, "ITSspdWafer_%i",i+1);
625 TGeoNode *layNode = itsmotherVolume->GetNode(layerName);
626 if (layNode) {
627 TGeoHMatrix layMatrix(*layNode->GetMatrix());
628 Double_t *trans = layMatrix.GetTranslation();
629 Double_t *r = layMatrix.GetRotationMatrix();
630 Double_t rot[10] = {r[0],r[1],r[2],
631 r[3],r[4],r[5],
632 r[6],r[7],r[8], 1.0};
633 Int_t iDet = 1;
634 Int_t iLad = 1;
635 Int_t iLay = 1;
636 DecodeDetector(mod,layNode->GetNumber(),i+1,0,0);
637 DecodeDetectorLayers(mod,iLay,iLad,iDet);
638 geom->CreateMatrix(startMod,iLay,iLad,iDet,kSPD,trans,rot);
639 startMod++;
640 };
641 };
642
643 // SDD
644 for (Int_t i=0; i<2;i++) {
645 sprintf(layerName, "ITSsddWafer_%i",i+4+1);
646 TGeoNode *layNode = itsmotherVolume->GetNode(layerName);
647 if (layNode) {
648 TGeoHMatrix layMatrix(*layNode->GetMatrix());
649 Double_t *trans = layMatrix.GetTranslation();
650 Double_t *r = layMatrix.GetRotationMatrix();
651 Double_t rot[10] = {r[0],r[1],r[2],
652 r[3],r[4],r[5],
653 r[6],r[7],r[8], 1.0};
654 Int_t iDet = 1;
655 Int_t iLad = 1;
656 Int_t iLay = 1;
657 DecodeDetector(mod,layNode->GetNumber(),i+1,0,0);
658 DecodeDetectorLayers(mod,iLay,iLad,iDet);
659 geom->CreateMatrix(startMod,iLay,iLad,iDet,kSDD,trans,rot);
660 startMod++;
661 };
662 };
663
664 // SSD
665 for (Int_t i=0; i<4;i++) {
666 sprintf(layerName, "ITSssdWafer_%i",i+4+2+1);
667 TGeoNode *layNode = itsmotherVolume->GetNode(layerName);
668 if (layNode) {
669 TGeoHMatrix layMatrix(*layNode->GetMatrix());
670 Double_t *trans = layMatrix.GetTranslation();
671 Double_t *r = layMatrix.GetRotationMatrix();
672 Double_t rot[10] = {r[0],r[1],r[2],
673 r[3],r[4],r[5],
674 r[6],r[7],r[8], 1.0};
675 Int_t iDet = 1;
676 Int_t iLad = 1;
677 Int_t iLay = 5;
678 DecodeDetector(mod,layNode->GetNumber(),i+1,0,0);
679 DecodeDetectorLayers(mod,iLay,iLad,iDet);
680 geom->CreateMatrix(startMod,iLay,iLad,iDet,kSSD,trans,rot);
681 startMod++;
682 };
683 };
108bd0fe 684
012f0f4c 685 return kTRUE;
686 */
023ae34b 687 return kFALSE;
688}
689//______________________________________________________________________
690Bool_t AliITSInitGeometry::InitAliITSgeomPPRasymmFMD(AliITSgeom *geom){
691 // Initilizes the geometry transformation class AliITSgeom
692 // to values appropreate to this specific geometry. Now that
693 // the segmentation is part of AliITSgeom, the detector
694 // segmentations are also defined here.
695 // Inputs:
696 // AliITSgeom *geom A pointer to the AliITSgeom class
697 // Outputs:
698 // AliITSgeom *geom This pointer recreated and properly inilized.
699 // Return:
700 // none.
701 // const Double_t kcm2micron = 1.0E4;
702 const Int_t kItype=0; // Type of transormation defined 0=> Geant
703 const Int_t klayers = 6; // number of layers in the ITS
704 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
705 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
6b0f3880 706 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
707 const TString kPathbase = "/ALIC_1/ITSV_1/ITSD_1/";
708 const TString kNames[2][klayers] = {
023ae34b 709 {"%sIT12_1/I12A_%d/I10A_%d/I103_%d/I101_1/ITS1_1", // lay=1
710 "%sIT12_1/I12A_%d/I20A_%d/I1D3_%d/I1D1_1/ITS2_1", // lay=2
711 "%sIT34_1/I004_%d/I302_%d/ITS3_%d/", // lay=3
712 "%sIT34_1/I005_%d/I402_%d/ITS4_%d/", // lay=4
713 "%sIT56_1/I565_%d/I562_%d/ITS5_%d/", // lay=5
714 "%sIT56_1/I569_%d/I566_%d/ITS6_%d/"},// lay=6
715 {"%sIT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
716 "%sIT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
717 "%sIT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
718 "%sIT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
719 "%sIT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
720 "%sIT56_1/I569_%d/I566_%d/ITS6_%d"}};// Lay=6
721 /*
722 Int_t itsGeomTreeCopys[knlayers][3]= {{10, 2, 4},// lay=1
723 {10, 4, 4},// lay=2
724 {14, 6, 1},// lay=3
725 {22, 8, 1},// lay=4
726 {34,22, 1},// lay=5
727 {38,25, 1}};//lay=6
728 */
729 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2;
730 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
731 TArrayD shapePar;
732 TString path,shapeName;
012f0f4c 733 TGeoHMatrix matrix;
023ae34b 734 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
24e270ad 735 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
023ae34b 736
737 if(fTiming) time->Start();
738 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
739 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
740 for(mod=0;mod<nmods;mod++){
741 DecodeDetectorLayers(mod,lay,lad,det); // Write
6b0f3880 742 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
023ae34b 743 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
6b0f3880 744 path.Form(kNames[fMinorVersion-1][lay-1].Data(),
745 kPathbase.Data(),cpn0,cpn1,cpn2);
023ae34b 746 geom->GetGeomMatrix(mod)->SetPath(path);
012f0f4c 747 GetTransformation(path.Data(),matrix);
748 geom->SetTrans(mod,matrix.GetTranslation());
749 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
750 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
6b0f3880 751 if(initSeg[kIdet[lay-1]]) continue;
023ae34b 752 GetShape(path,shapeName,shapePar);
753 if(shapeName.CompareTo("BOX")){
012f0f4c 754 Error("InitITSgeomPPRasymmFMD",
755 "Geometry changed without proper code update or error "
756 "in reading geometry. Shape is not BOX. Shape is %s",
757 shapeName.Data());
758 return kFALSE;
023ae34b 759 } // end if
6b0f3880 760 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
023ae34b 761 } // end for module
762 if(fTiming){
763 time->Stop();
764 time->Print();
765 delete time;
766 } // end if
767 return kTRUE;
768}
108bd0fe 769//______________________________________________________________________
770Bool_t AliITSInitGeometry::InitAliITSgeomV11Hybrid(AliITSgeom *geom){
771 // Initilizes the geometry transformation class AliITSgeom
772 // to values appropreate to this specific geometry. Now that
773 // the segmentation is part of AliITSgeom, the detector
774 // segmentations are also defined here.
775 // Inputs:
776 // AliITSgeom *geom A pointer to the AliITSgeom class
777 // Outputs:
778 // AliITSgeom *geom This pointer recreated and properly inilized.
779 // Return:
780 // none.
781
782 const Int_t kItype = 0; // Type of transformation defined 0=> Geant
783 const Int_t klayers = 6; // number of layers in the ITS
784 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
785 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
786 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
787 const TString kPathbase = "/ALIC_1/ITSV_1/";
788
789 char *pathSDDsens1, *pathSDDsens2;
790 if (SDDIsTGeoNative()) {
791 pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
792 pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
793 } else{
794 pathSDDsens1 = "%sITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d";
795 pathSDDsens2 = "%sITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d";
796 }
797
798 const TString kNames[klayers] = {
799 "%sITSD_1/IT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
800 "%sITSD_1/IT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
801 pathSDDsens1, // lay=3
802 pathSDDsens2, // lay=4
803 "%sITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
804 "%sITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d"};// Lay=6
805
806 Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2;
807 Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
808 TArrayD shapePar;
809 TString path, shapeName;
810 TGeoHMatrix matrix;
811 Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
812 TStopwatch *time = 0x0;
813 if(fTiming) time = new TStopwatch();
814
815 if(fTiming) time->Start();
816 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
817 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
818
819 for(mod=0;mod<nmods;mod++) {
820
012f0f4c 821// DecodeDetectorLayers(mod,lay,lad,det); // Write
822// geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
823// RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
108bd0fe 824 DecodeDetectorLayers(mod,lay,lad,det); // Write
825 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
826 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
827
012f0f4c 828
829
108bd0fe 830 if (SDDIsTGeoNative())
831 if (kIdet[lay-1]==kSDD) {
832 cpn0 = lad-1;
833 cpn1 = det-1;
834 cpn2 = 1;
835 }
836
837 path.Form(kNames[lay-1].Data(),
838 kPathbase.Data(),cpn0,cpn1,cpn2);
839 geom->GetGeomMatrix(mod)->SetPath(path);
840 GetTransformation(path.Data(),matrix);
841 geom->SetTrans(mod,matrix.GetTranslation());
012f0f4c 842 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
108bd0fe 843 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
844 if(initSeg[kIdet[lay-1]]) continue;
845 GetShape(path,shapeName,shapePar);
846 if(shapeName.CompareTo("BOX")){
847 Error("InitITSgeom","Geometry changed without proper code update"
848 "or error in reading geometry. Shape is not BOX.");
849 return kFALSE;
850 } // end if
851 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
852 } // end for module
853
854 if(fTiming){
855 time->Stop();
856 time->Print();
857 delete time;
858 } // end if
859 return kTRUE;
860}
108bd0fe 861//______________________________________________________________________
862Bool_t AliITSInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
863 // Initilizes the geometry transformation class AliITSgeom
864 // Now that the segmentation is part of AliITSgeom, the detector
865 // segmentations are also defined here.
866 //
867 // Inputs:
868 // AliITSgeom *geom A pointer to the AliITSgeom class
869 // Outputs:
870 // AliITSgeom *geom This pointer recreated and properly inilized.
871 // LG
872
873
874 const Int_t kItype=0; // Type of transormation defined 0=> Geant
875 const Int_t klayers = 6; // number of layers in the ITS
876 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
877 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
878 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
879
880 const TString kPathbase = "/ALIC_1/ITSV_1/";
881 const TString kNames[klayers] =
882 {"AliITSInitGeometry:spd missing", // lay=1
883 "AliITSInitGeometry:spd missing", // lay=2
884 "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_1/ITSsddSensitiv_1", // lay=3
885 "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_1/ITSsddSensitiv_1", // lay=4
886 "AliITSInitGeometry:ssd missing", // lay=5
887 "AliITSInitGeometry:ssd missing"};// lay=6
888
889 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2;
890 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
891 TArrayD shapePar;
892 TString path,shapeName;
893 TGeoHMatrix matrix;
894 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
895 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
896
897 if(fTiming) time->Start();
898 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
899
900 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
901 for(mod=0;mod<nmods;mod++) {
902
903 DecodeDetectorLayers(mod,lay,lad,det); // Write
904 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
905 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
906 path.Form(kNames[lay-1].Data(),
907 kPathbase.Data(),cpn0,cpn1,cpn2);
908 geom->GetGeomMatrix(mod)->SetPath(path);
909 if (GetTransformation(path.Data(),matrix)) {
910 geom->SetTrans(mod,matrix.GetTranslation());
012f0f4c 911 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
108bd0fe 912 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
913 }
914
915 if(initSeg[kIdet[lay-1]]) continue;
916 GetShape(path,shapeName,shapePar);
917 if(shapeName.CompareTo("BOX")){
918 Error("InitAliITSgeomV11","Geometry changed without proper code update"
919 "or error in reading geometry. Shape is not BOX.");
920 return kFALSE;
921 } // end if
922 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
923
924 } // end for module
925
926 if(fTiming){
927 time->Stop();
928 time->Print();
929 delete time;
930 } // end if
931 return kTRUE;
932}
933
023ae34b 934//______________________________________________________________________
935Bool_t AliITSInitGeometry::InitGeomShapePPRasymmFMD(AliITSDetector idet,
936 Bool_t *initSeg,
937 TArrayD &shapePar,
938 AliITSgeom *geom){
939 // Initilizes the geometry segmentation class AliITSgeomS?D, or
940 // AliITSsegmentationS?D depending on the vaule of fSegGeom,
941 // to values appropreate to this specific geometry. Now that
942 // the segmentation is part of AliITSgeom, the detector
943 // segmentations are also defined here.
944 // Inputs:
945 // Int_t lay The layer number/name.
946 // AliITSgeom *geom A pointer to the AliITSgeom class
947 // Outputs:
948 // AliITSgeom *geom This pointer recreated and properly inilized.
949 // Return:
950 // none.
951 // const Double_t kcm2micron = 1.0E4;
952 const Double_t kmicron2cm = 1.0E-4;
953 Int_t i;
954 TArrayF shapeParF;
955
956 shapeParF.Set(shapePar.GetSize());
957 for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
958 switch (idet){
959 case kSPD:{
960 initSeg[idet] = kTRUE;
961 AliITSgeomSPD *geomSPD = new AliITSgeomSPD425Short();
962 Float_t bx[256],bz[280];
963 for(i=000;i<256;i++) bx[i] = 50.0*kmicron2cm; // in x all are 50 microns.
964 for(i=000;i<160;i++) bz[i] = 425.0*kmicron2cm; // most are 425 microns
965 // except below
966 for(i=160;i<280;i++) bz[i] = 0.0*kmicron2cm; // Outside of detector.
967 bz[ 31] = bz[ 32] = 625.0*kmicron2cm; // first chip boundry
968 bz[ 63] = bz[ 64] = 625.0*kmicron2cm; // first chip boundry
969 bz[ 95] = bz[ 96] = 625.0*kmicron2cm; // first chip boundry
970 bz[127] = bz[128] = 625.0*kmicron2cm; // first chip boundry
971 bz[160] = 425.0*kmicron2cm;// Set so that there is no zero pixel size for fNz.
972 geomSPD->ReSetBins(shapeParF[1],256,bx,160,bz);
973 geom->ReSetShape(idet,geomSPD);
974 }break;
975 case kSDD:{
976 initSeg[idet] = kTRUE;
977 AliITSgeomSDD *geomSDD = new AliITSgeomSDD256(shapeParF.GetSize(),
978 shapeParF.GetArray());
979 geom->ReSetShape(idet,geomSDD);
980 }break;
981 case kSSD:{
982 initSeg[idet] = kTRUE;
983 AliITSgeomSSD *geomSSD = new AliITSgeomSSD275and75(
984 shapeParF.GetSize(),shapeParF.GetArray());
985 geom->ReSetShape(idet,geomSSD);
986 }break;
987 default:{// Others, Note no kSDDp or kSSDp in this geometry.
988 geom->ReSetShape(idet,0);
989 Info("InitGeomShapePPRasymmFMD",
990 "default Dx=%f Dy=%f Dz=%f default=%d",
991 shapePar[0],shapePar[1],shapePar[2],idet);
992 }break;
993 } // end switch
994 return kTRUE;
995}
996//______________________________________________________________________
997Bool_t AliITSInitGeometry::InitSegmentationPPRasymmFMD(AliITSDetector idet,
998 Bool_t *initSeg,
999 TArrayD &shapePar,
1000 AliITSgeom *geom){
1001 // Initilizes the geometry segmentation class AliITSgeomS?D, or
1002 // AliITSsegmentationS?D depending on the vaule of fSegGeom,
1003 // to values appropreate to this specific geometry. Now that
1004 // the segmentation is part of AliITSgeom, the detector
1005 // segmentations are also defined here.
1006 // Inputs:
1007 // Int_t lay The layer number/name.
1008 // AliITSgeom *geom A pointer to the AliITSgeom class
1009 // Outputs:
1010 // AliITSgeom *geom This pointer recreated and properly inilized.
1011 // Return:
1012 // none.
1013 const Double_t kcm2micron = 1.0E4;
1014 Int_t i;
1015
1016 switch (idet){
1017 case kSPD:{
1018 initSeg[idet] = kTRUE;
1019 AliITSsegmentationSPD *segSPD = new AliITSsegmentationSPD();
1020 segSPD->SetDetSize(2.*shapePar[0]*kcm2micron, // X
1021 2.*shapePar[2]*kcm2micron, // Z
1022 2.*shapePar[1]*kcm2micron);// Y Microns
1023 segSPD->SetNPads(256,160);// Number of Bins in x and z
1024 Float_t bx[256],bz[280];
1025 for(i=000;i<256;i++) bx[i] = 50.0; // in x all are 50 microns.
1026 for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns
1027 // except below
1028 for(i=160;i<280;i++) bz[i] = 0.0; // Outside of detector.
1029 bz[ 31] = bz[ 32] = 625.0; // first chip boundry
1030 bz[ 63] = bz[ 64] = 625.0; // first chip boundry
1031 bz[ 95] = bz[ 96] = 625.0; // first chip boundry
1032 bz[127] = bz[128] = 625.0; // first chip boundry
1033 bz[160] = 425.0;// Set so that there is no zero pixel size for fNz.
1034 segSPD->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
1035 geom->ReSetShape(idet,segSPD);
1036 }break;
1037 case kSDD:{
1038 initSeg[idet] = kTRUE;
1039 AliITSsegmentationSDD *segSDD = new AliITSsegmentationSDD();
1040 segSDD->SetDetSize(shapePar[0]*kcm2micron, // X
1041 2.*shapePar[2]*kcm2micron, // Z
1042 2.*shapePar[1]*kcm2micron);// Y Microns
1043 segSDD->SetNPads(256,256);// Anodes, Samples
1044 geom->ReSetShape(idet,segSDD);
1045 }break;
1046 case kSSD:{
1047 initSeg[idet] = kTRUE;
1048 AliITSsegmentationSSD *segSSD = new AliITSsegmentationSSD();
1049 segSSD->SetDetSize(2.*shapePar[0]*kcm2micron, // X
1050 2.*shapePar[2]*kcm2micron, // Z
1051 2.*shapePar[1]*kcm2micron);// Y Microns.
1052 segSSD->SetPadSize(95.,0.); // strip x pitch in microns
1053 segSSD->SetNPads(768,2); // number of strips on each side, sides.
1054 segSSD->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
1055 segSSD->SetAnglesLay5(0.0075,0.0275);//strip angels rad P and N
1056 segSSD->SetAnglesLay6(0.0275,0.0075);//strip angels rad P and N
1057 geom->ReSetShape(idet,segSSD);
1058 }break;
1059 default:{// Others, Note no kSDDp or kSSDp in this geometry.
1060 geom->ReSetShape(idet,0);
1061 Info("InitSegmentationPPRasymmFMD",
1062 "default segmentation Dx=%f Dy=%f Dz=%f default=%d",
1063 shapePar[0],shapePar[1],shapePar[2],idet);
1064 }break;
1065 } // end switch
1066 return kTRUE;
1067}
1068//______________________________________________________________________
1069Bool_t AliITSInitGeometry::GetTransformation(const TString &volumePath,
1070 TGeoHMatrix &mat){
1071 // Returns the Transformation matrix between the volume specified
1072 // by the path volumePath and the Top or mater volume. The format
1073 // of the path volumePath is as follows (assuming ALIC is the Top volume)
1074 // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
1075 // or master volume which has only 1 instance of. Of all of the daughter
1076 // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
1077 // the daughter volume of DDIP is S05I copy #2 and so on.
1078 // Inputs:
1079 // TString& volumePath The volume path to the specific volume
1080 // for which you want the matrix. Volume name
1081 // hierarchy is separated by "/" while the
1082 // copy number is appended using a "_".
1083 // Outputs:
1084 // TGeoHMatrix &mat A matrix with its values set to those
1085 // appropriate to the Local to Master transformation
1086 // Return:
1087 // A logical value if kFALSE then an error occurred and no change to
1088 // mat was made.
1089
1090 // We have to preserve the modeler state
1091
1092 // Preserve the modeler state.
1093 gGeoManager->PushPath();
1094 if (!gGeoManager->cd(volumePath.Data())) {
108bd0fe 1095 gGeoManager->PopPath();
1096 Error("GetTransformation","Error in cd-ing to ",volumePath.Data());
1097 return kFALSE;
023ae34b 1098 } // end if !gGeoManager
1099 mat = *gGeoManager->GetCurrentMatrix();
1100 // Retstore the modeler state.
1101 gGeoManager->PopPath();
1102 return kTRUE;
1103}
1104//______________________________________________________________________
1105Bool_t AliITSInitGeometry::GetShape(const TString &volumePath,
1106 TString &shapeType,TArrayD &par){
1107 // Returns the shape and its parameters for the volume specified
1108 // by volumeName.
1109 // Inputs:
1110 // TString& volumeName The volume name
1111 // Outputs:
1112 // TString &shapeType Shape type
1113 // TArrayD &par A TArrayD of parameters with all of the
1114 // parameters of the specified shape.
1115 // Return:
1116 // A logical indicating whether there was an error in getting this
1117 // information
1118 Int_t npar;
1119 gGeoManager->PushPath();
1120 if (!gGeoManager->cd(volumePath.Data())) {
1121 gGeoManager->PopPath();
1122 return kFALSE;
1123 }
1124 TGeoVolume * vol = gGeoManager->GetCurrentVolume();
1125 gGeoManager->PopPath();
1126 if (!vol) return kFALSE;
1127 TGeoShape *shape = vol->GetShape();
6b0f3880 1128 TClass *classType = shape->IsA();
1129 if (classType==TGeoBBox::Class()) {
023ae34b 1130 shapeType = "BOX";
1131 npar = 3;
1132 par.Set(npar);
1133 TGeoBBox *box = (TGeoBBox*)shape;
1134 par.AddAt(box->GetDX(),0);
1135 par.AddAt(box->GetDY(),1);
1136 par.AddAt(box->GetDZ(),2);
1137 return kTRUE;
012f0f4c 1138 } // end if
6b0f3880 1139 if (classType==TGeoTrd1::Class()) {
023ae34b 1140 shapeType = "TRD1";
1141 npar = 4;
1142 par.Set(npar);
1143 TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
1144 par.AddAt(trd1->GetDx1(),0);
1145 par.AddAt(trd1->GetDx2(),1);
1146 par.AddAt(trd1->GetDy(), 2);
1147 par.AddAt(trd1->GetDz(), 3);
1148 return kTRUE;
012f0f4c 1149 } // end if
6b0f3880 1150 if (classType==TGeoTrd2::Class()) {
023ae34b 1151 shapeType = "TRD2";
1152 npar = 5;
1153 par.Set(npar);
1154 TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
1155 par.AddAt(trd2->GetDx1(),0);
1156 par.AddAt(trd2->GetDx2(),1);
1157 par.AddAt(trd2->GetDy1(),2);
1158 par.AddAt(trd2->GetDy2(),3);
1159 par.AddAt(trd2->GetDz(), 4);
1160 return kTRUE;
012f0f4c 1161 } // end if
6b0f3880 1162 if (classType==TGeoTrap::Class()) {
023ae34b 1163 shapeType = "TRAP";
1164 npar = 11;
1165 par.Set(npar);
1166 TGeoTrap *trap = (TGeoTrap*)shape;
1167 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
1168 par.AddAt(trap->GetDz(),0);
1169 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
1170 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
1171 par.AddAt(trap->GetH1(),3);
1172 par.AddAt(trap->GetBl1(),4);
1173 par.AddAt(trap->GetTl1(),5);
1174 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
1175 par.AddAt(trap->GetH2(),7);
1176 par.AddAt(trap->GetBl2(),8);
1177 par.AddAt(trap->GetTl2(),9);
1178 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
1179 return kTRUE;
012f0f4c 1180 } // end if
6b0f3880 1181 if (classType==TGeoTube::Class()) {
023ae34b 1182 shapeType = "TUBE";
1183 npar = 3;
1184 par.Set(npar);
1185 TGeoTube *tube = (TGeoTube*)shape;
1186 par.AddAt(tube->GetRmin(),0);
1187 par.AddAt(tube->GetRmax(),1);
1188 par.AddAt(tube->GetDz(),2);
1189 return kTRUE;
012f0f4c 1190 } // end if
6b0f3880 1191 if (classType==TGeoTubeSeg::Class()) {
023ae34b 1192 shapeType = "TUBS";
1193 npar = 5;
1194 par.Set(npar);
1195 TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
1196 par.AddAt(tubs->GetRmin(),0);
1197 par.AddAt(tubs->GetRmax(),1);
1198 par.AddAt(tubs->GetDz(),2);
1199 par.AddAt(tubs->GetPhi1(),3);
1200 par.AddAt(tubs->GetPhi2(),4);
1201 return kTRUE;
012f0f4c 1202 } // end if
6b0f3880 1203 if (classType==TGeoCone::Class()) {
023ae34b 1204 shapeType = "CONE";
1205 npar = 5;
1206 par.Set(npar);
1207 TGeoCone *cone = (TGeoCone*)shape;
1208 par.AddAt(cone->GetDz(),0);
1209 par.AddAt(cone->GetRmin1(),1);
1210 par.AddAt(cone->GetRmax1(),2);
1211 par.AddAt(cone->GetRmin2(),3);
1212 par.AddAt(cone->GetRmax2(),4);
1213 return kTRUE;
012f0f4c 1214 } // end if
6b0f3880 1215 if (classType==TGeoConeSeg::Class()) {
023ae34b 1216 shapeType = "CONS";
1217 npar = 7;
1218 par.Set(npar);
1219 TGeoConeSeg *cons = (TGeoConeSeg*)shape;
1220 par.AddAt(cons->GetDz(),0);
1221 par.AddAt(cons->GetRmin1(),1);
1222 par.AddAt(cons->GetRmax1(),2);
1223 par.AddAt(cons->GetRmin2(),3);
1224 par.AddAt(cons->GetRmax2(),4);
1225 par.AddAt(cons->GetPhi1(),5);
1226 par.AddAt(cons->GetPhi2(),6);
1227 return kTRUE;
012f0f4c 1228 } // end if
6b0f3880 1229 if (classType==TGeoSphere::Class()) {
023ae34b 1230 shapeType = "SPHE";
1231 npar = 6;
1232 par.Set(npar);
1233
1234 TGeoSphere *sphe = (TGeoSphere*)shape;
1235 par.AddAt(sphe->GetRmin(),0);
1236 par.AddAt(sphe->GetRmax(),1);
1237 par.AddAt(sphe->GetTheta1(),2);
1238 par.AddAt(sphe->GetTheta2(),3);
1239 par.AddAt(sphe->GetPhi1(),4);
1240 par.AddAt(sphe->GetPhi2(),5);
1241 return kTRUE;
012f0f4c 1242 } // end if
6b0f3880 1243 if (classType==TGeoPara::Class()) {
023ae34b 1244 shapeType = "PARA";
1245 npar = 6;
1246 par.Set(npar);
1247 TGeoPara *para = (TGeoPara*)shape;
1248 par.AddAt(para->GetX(),0);
1249 par.AddAt(para->GetY(),1);
1250 par.AddAt(para->GetZ(),2);
1251 par.AddAt(para->GetTxy(),3);
1252 par.AddAt(para->GetTxz(),4);
1253 par.AddAt(para->GetTyz(),5);
1254 return kTRUE;
012f0f4c 1255 } // end if
6b0f3880 1256 if (classType==TGeoPgon::Class()) {
023ae34b 1257 shapeType = "PGON";
1258 TGeoPgon *pgon = (TGeoPgon*)shape;
1259 Int_t nz = pgon->GetNz();
1260 const Double_t *rmin = pgon->GetRmin();
1261 const Double_t *rmax = pgon->GetRmax();
1262 const Double_t *z = pgon->GetZ();
1263 npar = 4 + 3*nz;
1264 par.Set(npar);
1265 par.AddAt(pgon->GetPhi1(),0);
1266 par.AddAt(pgon->GetDphi(),1);
1267 par.AddAt(pgon->GetNedges(),2);
1268 par.AddAt(pgon->GetNz(),3);
1269 for (Int_t i=0; i<nz; i++) {
1270 par.AddAt(z[i], 4+3*i);
1271 par.AddAt(rmin[i], 4+3*i+1);
1272 par.AddAt(rmax[i], 4+3*i+2);
1273 }
1274 return kTRUE;
012f0f4c 1275 } // end if
6b0f3880 1276 if (classType==TGeoPcon::Class()) {
023ae34b 1277 shapeType = "PCON";
1278 TGeoPcon *pcon = (TGeoPcon*)shape;
1279 Int_t nz = pcon->GetNz();
1280 const Double_t *rmin = pcon->GetRmin();
1281 const Double_t *rmax = pcon->GetRmax();
1282 const Double_t *z = pcon->GetZ();
1283 npar = 3 + 3*nz;
1284 par.Set(npar);
1285 par.AddAt(pcon->GetPhi1(),0);
1286 par.AddAt(pcon->GetDphi(),1);
1287 par.AddAt(pcon->GetNz(),2);
1288 for (Int_t i=0; i<nz; i++) {
1289 par.AddAt(z[i], 3+3*i);
1290
1291 par.AddAt(rmin[i], 3+3*i+1);
1292 par.AddAt(rmax[i], 3+3*i+2);
1293 }
1294 return kTRUE;
012f0f4c 1295 } // end if
6b0f3880 1296 if (classType==TGeoEltu::Class()) {
023ae34b 1297 shapeType = "ELTU";
1298 npar = 3;
1299 par.Set(npar);
1300 TGeoEltu *eltu = (TGeoEltu*)shape;
1301 par.AddAt(eltu->GetA(),0);
1302 par.AddAt(eltu->GetB(),1);
1303 par.AddAt(eltu->GetDz(),2);
1304 return kTRUE;
012f0f4c 1305 } // end if
6b0f3880 1306 if (classType==TGeoHype::Class()) {
023ae34b 1307 shapeType = "HYPE";
1308 npar = 5;
1309 par.Set(npar);
1310 TGeoHype *hype = (TGeoHype*)shape;
1311 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
1312 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
1313 par.AddAt(hype->GetDZ(),2);
1314 par.AddAt(hype->GetStIn(),3);
1315 par.AddAt(hype->GetStOut(),4);
1316 return kTRUE;
012f0f4c 1317 } // end if
6b0f3880 1318 if (classType==TGeoGtra::Class()) {
023ae34b 1319 shapeType = "GTRA";
1320 npar = 12;
1321 par.Set(npar);
1322 TGeoGtra *trap = (TGeoGtra*)shape;
1323 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
1324 par.AddAt(trap->GetDz(),0);
1325 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
1326 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
1327 par.AddAt(trap->GetH1(),3);
1328 par.AddAt(trap->GetBl1(),4);
1329 par.AddAt(trap->GetTl1(),5);
1330 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
1331 par.AddAt(trap->GetH2(),7);
1332 par.AddAt(trap->GetBl2(),8);
1333 par.AddAt(trap->GetTl2(),9);
1334 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
1335 par.AddAt(trap->GetTwistAngle(),11);
1336 return kTRUE;
012f0f4c 1337 } // end if
6b0f3880 1338 if (classType==TGeoCtub::Class()) {
023ae34b 1339 shapeType = "CTUB";
1340 npar = 11;
1341 par.Set(npar);
1342 TGeoCtub *ctub = (TGeoCtub*)shape;
1343 const Double_t *lx = ctub->GetNlow();
1344 const Double_t *tx = ctub->GetNhigh();
1345 par.AddAt(ctub->GetRmin(),0);
1346 par.AddAt(ctub->GetRmax(),1);
1347 par.AddAt(ctub->GetDz(),2);
1348 par.AddAt(ctub->GetPhi1(),3);
1349 par.AddAt(ctub->GetPhi2(),4);
1350 par.AddAt(lx[0],5);
1351 par.AddAt(lx[1],6);
1352 par.AddAt(lx[2],7);
1353 par.AddAt(tx[0],8);
1354 par.AddAt(tx[1],9);
1355 par.AddAt(tx[2],10);
1356 return kTRUE;
012f0f4c 1357 } // end if
023ae34b 1358 Error("GetShape","Getting shape parameters for shape %s not implemented",
1359 shape->ClassName());
012f0f4c 1360 shapeType = "Unknown";
023ae34b 1361 return kFALSE;
1362}
1363//______________________________________________________________________
012f0f4c 1364void AliITSInitGeometry::DecodeDetector(
1365 Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
023ae34b 1366 // decode geometry into detector module number. There are two decoding
1367 // Scheams. Old which does not follow the ALICE coordinate system
1368 // requirements, and New which dose.
1369 // Inputs:
1370 // Int_t layer The ITS layer
1371 // Int_t cpn0 The lowest copy number
1372 // Int_t cpn1 The middle copy number
1373 // Int_t cpn2 the highest copy number
1374 // Output:
1375 // Int_t &mod The module number assoicated with this set
1376 // of copy numbers.
1377 // Return:
1378 // none.
023ae34b 1379
012f0f4c 1380 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
1381 // like them but I see not better way for the moment.
1382 switch (fMajorVersion){
1383 case kvtest:{
1384 if(GetMinorVersion()==1)
1385 return DecodeDetectorvPPRasymmFMD(mod,layer,cpn0,cpn1,cpn2);
1386 else if(GetMinorVersion()==2)
1387 return DecodeDetectorvtest2(mod,layer,cpn0,cpn1,cpn2);
1388 Warning("DecodeDetector",
1389 "Geometry is kvtest minor version=%d is not defined",
1390 GetMinorVersion());
1391 }break;
1392 case kvDefault:{
1393 Error("DecodeDetector","Major version = kvDefault, not supported");
1394 }break;
1395 case kvSPD02:{
1396 return DecodeDetectorvSPD02(mod,layer,cpn0,cpn1,cpn2);
1397 }break;
1398 case kvSDD03:{
1399 return DecodeDetectorvSDD03(mod,layer,cpn0,cpn1,cpn2);
1400 }break;
1401 case kvSSD03:{
1402 return DecodeDetectorvSSD03(mod,layer,cpn0,cpn1,cpn2);
1403 }break;
1404 case kvITS04:{
1405 return DecodeDetectorvITS04(mod,layer,cpn0,cpn1,cpn2);
1406 }break;
1407 case kvPPRcourseasymm:{
1408 return DecodeDetectorvPPRcourseasymm(mod,layer,cpn0,cpn1,cpn2);
1409 }break;
1410 case kvPPRasymmFMD:{
1411 return DecodeDetectorvPPRasymmFMD(mod,layer,cpn0,cpn1,cpn2);
1412 }break;
1413 case kv11:{
1414 return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2);
1415 }break;
1416 case kv11Hybrid:{
1417 return DecodeDetectorv11Hybrid(mod,layer,cpn0,cpn1,cpn2);
1418 }break;
1419 default:{
1420 Error("DecodeDetector","Major version = %d, not supported",
1421 (Int_t)fMajorVersion);
1422 return;
1423 }break;
1424 } // end switch
1425 return;
1426}
1427//______________________________________________________________________
1428void AliITSInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
1429 Int_t &cpn1,Int_t &cpn2){
1430 // decode geometry into detector module number. There are two decoding
1431 // Scheams. Old which does not follow the ALICE coordinate system
1432 // requirements, and New which dose.
1433 // Inputs:
1434 // Int_t mod The module number assoicated with this set
1435 // of copy numbers.
1436 // Output:
1437 // Int_t cpn0 The lowest copy number
1438 // Int_t cpn1 The middle copy number
1439 // Int_t cpn2 the highest copy number
1440 // Return:
1441 // none.
1442
1443 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
1444 // like them but I see not better way for the moment.
1445 switch (fMajorVersion){
1446 case kvtest:{
1447 if(GetMinorVersion()==1)
1448 return RecodeDetectorvPPRasymmFMD(mod,cpn0,cpn1,cpn2);
1449 else if(GetMinorVersion()==2)
1450 return RecodeDetectorvtest2(mod,cpn0,cpn1,cpn2);
1451 Warning("RecodeDetector",
1452 "Geometry is kvtest minor version=%d is not defined",
1453 GetMinorVersion());
1454 return;
1455 }break;
1456 case kvDefault:{
1457 Error("RecodeDetector","Major version = kvDefault, not supported");
1458 return;
1459 }break;
1460 case kvSPD02:{
1461 return RecodeDetectorvSPD02(mod,cpn0,cpn1,cpn2);
1462 }break;
1463 case kvSDD03:{
1464 return RecodeDetectorvSDD03(mod,cpn0,cpn1,cpn2);
1465 }break;
1466 case kvSSD03:{
1467 return RecodeDetectorvSSD03(mod,cpn0,cpn1,cpn2);
1468 }break;
1469 case kvITS04:{
1470 return RecodeDetectorvITS04(mod,cpn0,cpn1,cpn2);
1471 }break;
1472 case kvPPRcourseasymm:{
1473 return RecodeDetectorvPPRcourseasymm(mod,cpn0,cpn1,cpn2);
1474 }break;
1475 case kvPPRasymmFMD:{
1476 return RecodeDetectorvPPRasymmFMD(mod,cpn0,cpn1,cpn2);
1477 }break;
1478 case kv11:{
1479 return RecodeDetectorv11(mod,cpn0,cpn1,cpn2);
1480 }break;
1481 case kv11Hybrid:{
1482 return RecodeDetectorv11Hybrid(mod,cpn0,cpn1,cpn2);
1483 }break;
1484 default:{
1485 Error("RecodeDetector","Major version = %d, not supported",
1486 (Int_t)fMajorVersion);
1487 return;
1488 }break;
1489 } // end switch
1490 return;
1491}
1492//______________________________________________________________________
1493void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
1494 Int_t &lad,Int_t &det){
1495 // decode geometry into detector module number. There are two decoding
1496 // Scheams. Old which does not follow the ALICE coordinate system
1497 // requirements, and New which dose. Note, this use of layer ladder
1498 // and detector numbers are strictly for internal use of this
1499 // specific code. They do not represent the "standard" layer ladder
1500 // or detector numbering except in a very old and obsoleate sence.
1501 // Inputs:
1502 // Int_t mod The module number assoicated with this set
1503 // of copy numbers.
1504 // Output:
1505 // Int_t lay The layer number
1506 // Int_t lad The ladder number
1507 // Int_t det the dettector number
1508 // Return:
1509 // none.
1510
1511 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
1512 // like them but I see not better way for the moment.
1513 switch (fMajorVersion){
1514 case kvtest:{
1515 if(GetMinorVersion()==1)
1516 return DecodeDetectorLayersvPPRasymmFMD(mod,layer,lad,det);
1517 else if(GetMinorVersion()==2)
1518 return DecodeDetectorLayersvtest2(mod,layer,lad,det);
1519 Warning("DecodeDetectorLayers",
1520 "Geometry is kvtest minor version=%d is not defined",
1521 GetMinorVersion());
1522 return;
1523 }break;
1524 case kvDefault:{
1525 Error("DecodeDetectorLayers",
1526 "Major version = kvDefault, not supported");
1527 return;
1528 }break;
1529 case kvSPD02:{
1530 return DecodeDetectorLayersvSPD02(mod,layer,lad,det);
1531 }break;
1532 case kvSDD03:{
1533 return DecodeDetectorLayersvSDD03(mod,layer,lad,det);
1534 }break;
1535 case kvSSD03:{
1536 return DecodeDetectorLayersvSSD03(mod,layer,lad,det);
1537 }break;
1538 case kvITS04:{
1539 return DecodeDetectorLayersvITS04(mod,layer,lad,det);
1540 }break;
1541 case kvPPRcourseasymm:{
1542 return DecodeDetectorLayersvPPRcourseasymm(mod,layer,lad,det);
1543 }break;
1544 case kvPPRasymmFMD:{
1545 return DecodeDetectorLayersvPPRasymmFMD(mod,layer,lad,det);
1546 }break;
1547 case kv11:{
1548 return DecodeDetectorLayersv11(mod,layer,lad,det);
1549 }break;
1550 case kv11Hybrid:{
1551 return DecodeDetectorLayersv11Hybrid(mod,layer,lad,det);
1552 }break;
1553 default:{
1554 Error("DecodeDetectorLayers","Major version = %d, not supported",
1555 (Int_t)fMajorVersion);
1556 return;
1557 }break;
1558 } // end switch
1559 return;
1560}
1561//______________________________________________________________________
1562void AliITSInitGeometry::DecodeDetectorvSPD02(
1563 Int_t &mod,Int_t ncpn,Int_t cpy0,Int_t cpy1,Int_t cpy2) const {
1564 // decode geometry into detector module number
1565 // Inputs:
1566 // Int_t ncpn The Number of copies of this volume
1567 // Int_t cpy0 The lowest copy number
1568 // Int_t cpy1 The middle copy number
1569 // Int_t cpy2 the highest copy number
1570 // Output:
1571 // Int_t &mod The module number assoicated with this set
1572 // of copy numbers.
1573 // Return:
1574 // none.
1575
1576 // detector = ladder = 1
1577 if(ncpn==4 && cpy1>2) mod = cpy1; // layer = 1,2
1578 else mod = cpy1-1; // layer = 4,5
1579 if(ncpn==1) mod = 2; // layer=3
1580 cpy0 = cpy2;
1581 return;
1582}
1583//______________________________________________________________________
1584void AliITSInitGeometry::RecodeDetectorvSPD02(Int_t mod,Int_t &cpn0,
1585 Int_t &cpn1,Int_t &cpn2){
1586 // decode geometry into detector module number. There are two decoding
1587 // Scheams. Old which does not follow the ALICE coordinate system
1588 // requirements, and New which dose.
1589 // Inputs:
1590 // Int_t mod The module number assoicated with this set
1591 // of copy numbers.
1592 // Output:
1593 // Int_t cpn0 The lowest copy number
1594 // Int_t cpn1 The middle copy number
1595 // Int_t cpn2 the highest copy number
1596 // Return:
1597 // none.
1598
1599 cpn2 = 0;
1600 if(mod==2){
1601 cpn0 = 1;
1602 cpn1 = 1;
1603 return;
1604 } else if(mod<2){
1605 cpn0 = 1;
1606 cpn1 = mod+1;
1607 }else{
1608 cpn0 = 1;
1609 cpn1 = mod;
1610 } // end if
1611 return;
1612}
1613//______________________________________________________________________
1614void AliITSInitGeometry::DecodeDetectorLayersvSPD02(Int_t mod,Int_t &lay,
1615 Int_t &lad,Int_t &det){
1616 // decode geometry into detector module number. There are two decoding
1617 // Scheams. Old which does not follow the ALICE coordinate system
1618 // requirements, and New which dose. Note, this use of layer ladder
1619 // and detector numbers are strictly for internal use of this
1620 // specific code. They do not represent the "standard" layer ladder
1621 // or detector numbering except in a very old and obsoleate sence.
1622 // Inputs:
1623 // Int_t mod The module number assoicated with this set
1624 // of copy numbers.
1625 // Output:
1626 // Int_t lay The layer number
1627 // Int_t lad The ladder number
1628 // Int_t det the dettector number
1629 // Return:
1630 // none.
1631
1632 lay = mod+1;
1633 lad = det = 1;
1634 return;
1635}
1636//______________________________________________________________________
1637void AliITSInitGeometry::DecodeDetectorvSDD03(
1638 Int_t &mod,Int_t ncpys,Int_t cpy0,Int_t cpy1,Int_t cpy2) const {
1639 // decode geometry into detector module number. There are two decoding
1640 // Scheams. Old which does not follow the ALICE coordinate system
1641 // requirements, and New which dose.
1642 // Inputs:
1643 // Int_t ncpys The number of posible copies cpn1
1644 // Int_t cpy0 The lowest copy number
1645 // Int_t cpy1 The middle copy number
1646 // Int_t cpy2 the highest copy number
1647 // Output:
1648 // Int_t &mod The module number assoicated with this set
1649 // of copy numbers.
1650 // Return:
1651 // none.
1652
1653 if(ncpys==10){ // ITEL detectors
1654 if(cpy1>4) mod = cpy1+1;
1655 else mod = cpy1-1;
1656 }else{ // IDET detectors
1657 if(cpy1==1) mod = 4;
1658 else mod = 5;
1659 } // end if
1660 cpy0=cpy2;
1661 return;
1662}
1663//______________________________________________________________________
1664void AliITSInitGeometry::RecodeDetectorvSDD03(Int_t mod,Int_t &cpn0,
1665 Int_t &cpn1,Int_t &cpn2){
1666 // decode geometry into detector module number. There are two decoding
1667 // Scheams. Old which does not follow the ALICE coordinate system
1668 // requirements, and New which dose.
1669 // Inputs:
1670 // Int_t mod The module number assoicated with this set
1671 // of copy numbers.
1672 // Output:
1673 // Int_t cpn0 The lowest copy number
1674 // Int_t cpn1 The middle copy number
1675 // Int_t cpn2 the highest copy number
1676 // Return:
1677 // none.
1678
1679 cpn0 = 1;
1680 cpn2 = 0;
1681 if(mod<4) cpn1 = mod+1;
1682 else if(mod==4||mod==5) cpn1 = mod-3;
1683 else cpn1 = mod-1;
1684 return;
1685}
1686//______________________________________________________________________
1687void AliITSInitGeometry::DecodeDetectorLayersvSDD03(Int_t mod,Int_t &lay,
1688 Int_t &lad,Int_t &det){
1689 // decode geometry into detector module number. There are two decoding
1690 // Scheams. Old which does not follow the ALICE coordinate system
1691 // requirements, and New which dose. Note, this use of layer ladder
1692 // and detector numbers are strictly for internal use of this
1693 // specific code. They do not represent the "standard" layer ladder
1694 // or detector numbering except in a very old and obsoleate sence.
1695 // Inputs:
1696 // Int_t mod The module number assoicated with this set
1697 // of copy numbers.
1698 // Output:
1699 // Int_t lay The layer number
1700 // Int_t lad The ladder number
1701 // Int_t det the dettector number
1702 // Return:
1703 // none.
1704
1705 lad = det = 1;
1706 lay = mod+1;
1707 return;
1708}
1709//______________________________________________________________________
1710void AliITSInitGeometry::DecodeDetectorvSSD03(
1711 Int_t &mod,Int_t dtype,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
1712 // decode geometry into detector module number. There are two decoding
1713 // Scheams. Old which does not follow the ALICE coordinate system
1714 // requirements, and New which dose.
1715 // Inputs:
1716 // Int_t dtype The detector type 1=ITSA 2=IGAR 3=IFRA
1717 // Int_t cpn0 The lowest copy number
1718 // Int_t cpn1 The middle copy number
1719 // Int_t cpn2 the highest copy number
1720 // Output:
1721 // Int_t &mod The module number assoicated with this set
1722 // of copy numbers.
1723 // Return:
1724 // none.
1725
1726 if(dtype==2){mod=2; return;}
1727 if(dtype==3){mod=3; return;}
1728 mod = cpn0-1;
1729 if(cpn0==3) mod = 4;
1730 cpn1=cpn2;
1731 return;
1732}
1733//______________________________________________________________________
1734void AliITSInitGeometry::RecodeDetectorvSSD03(Int_t mod,Int_t &cpn0,
1735 Int_t &cpn1,Int_t &cpn2){
1736 // decode geometry into detector module number. There are two decoding
1737 // Scheams. Old which does not follow the ALICE coordinate system
1738 // requirements, and New which dose.
1739 // Inputs:
1740 // Int_t mod The module number assoicated with this set
1741 // of copy numbers.
1742 // Output:
1743 // Int_t cpn0 The lowest copy number
1744 // Int_t cpn1 The middle copy number
1745 // Int_t cpn2 the highest copy number
1746 // Return:
1747 // none.
1748
1749 cpn1=1;
1750 cpn2=0;
1751 if(mod<2) cpn0=mod+1;
1752 else if (mod==2||mod==3) cpn0=1;
1753 else cpn0 = 3;
1754 return;
1755}
1756//______________________________________________________________________
1757void AliITSInitGeometry::DecodeDetectorLayersvSSD03(Int_t mod,Int_t &lay,
1758 Int_t &lad,Int_t &det){
1759 // decode geometry into detector module number. There are two decoding
1760 // Scheams. Old which does not follow the ALICE coordinate system
1761 // requirements, and New which dose. Note, this use of layer ladder
1762 // and detector numbers are strictly for internal use of this
1763 // specific code. They do not represent the "standard" layer ladder
1764 // or detector numbering except in a very old and obsoleate sence.
1765 // Inputs:
1766 // Int_t mod The module number assoicated with this set
1767 // of copy numbers.
1768 // Output:
1769 // Int_t lay The layer number
1770 // Int_t lad The ladder number
1771 // Int_t det the dettector number
1772 // Return:
1773 // none.
1774
1775 lad = det = 1;
1776 lay = mod+1;
1777 return;
1778}
1779//______________________________________________________________________
1780void AliITSInitGeometry::DecodeDetectorvITS04(
1781 Int_t &mod,Int_t dtype,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
1782 // decode geometry into detector module number. There are two decoding
1783 // Scheams. Old which does not follow the ALICE coordinate system
1784 // requirements, and New which dose.
1785 // Inputs:
1786 // Int_t dtype The detector type 1=ITSA 2=IGAR 3=IFRA
1787 // Int_t cpn0 The lowest copy number
1788 // Int_t cpn1 The middle copy number
1789 // Int_t cpn2 the highest copy number
1790 // Output:
1791 // Int_t &mod The module number assoicated with this set
1792 // of copy numbers.
1793 // Return:
1794 // none.
1795
1796 mod = dtype-1;
1797 cpn0 = cpn1 = cpn2;
1798 return;
1799}
1800//______________________________________________________________________
1801void AliITSInitGeometry::RecodeDetectorvITS04(Int_t mod,Int_t &cpn0,
1802 Int_t &cpn1,Int_t &cpn2){
1803 // decode geometry into detector module number. There are two decoding
1804 // Scheams. Old which does not follow the ALICE coordinate system
1805 // requirements, and New which dose.
1806 // Inputs:
1807 // Int_t mod The module number assoicated with this set
1808 // of copy numbers.
1809 // Output:
1810 // Int_t cpn0 The lowest copy number
1811 // Int_t cpn1 The middle copy number
1812 // Int_t cpn2 the highest copy number
1813 // Return:
1814 // none.
1815
1816 cpn1 = cpn2 = 0;
1817 switch(mod){
1818 case 0:case 1:case 2:case 3:{
1819 cpn0 = mod+1;
1820 }break;
1821 case 4: case 5:{
1822 cpn0 = mod-3;
1823 }break;
1824 case 6:case 7:case 8:case 9:{
1825 cpn0 = mod-5;
1826 } break;
1827 default:
1828 cpn0 = 0;
1829 break;
1830 }// end switch
1831 return;
1832}
1833//______________________________________________________________________
1834void AliITSInitGeometry::DecodeDetectorLayersvITS04(Int_t mod,Int_t &lay,
1835 Int_t &lad,Int_t &det){
1836 // decode geometry into detector module number. There are two decoding
1837 // Scheams. Old which does not follow the ALICE coordinate system
1838 // requirements, and New which dose. Note, this use of layer ladder
1839 // and detector numbers are strictly for internal use of this
1840 // specific code. They do not represent the "standard" layer ladder
1841 // or detector numbering except in a very old and obsoleate sence.
1842 // Inputs:
1843 // Int_t mod The module number assoicated with this set
1844 // of copy numbers.
1845 // Output:
1846 // Int_t lay The layer number
1847 // Int_t lad The ladder number
1848 // Int_t det the dettector number
1849 // Return:
1850 // none.
1851
1852 lad = 1;
1853 switch(mod){
1854 case 0:case 1:case 2:case 3:{
1855 lay = mod/2 +1;
1856 det = mod%2 +1;
1857 }break;
1858 case 4: case 5:{
1859 lay = mod -1;
1860 }break;
1861 case 6:case 7:case 8:case 9:{
1862 lay = mod/2 +2;
1863 det = mod%2 +1;
1864 }break;
1865 default:
1866 lay = 0;
1867 det = 0;
1868 break;
1869 } // end switch
1870 return;
1871}
1872//______________________________________________________________________
1873void AliITSInitGeometry::DecodeDetectorvPPRasymmFMD(Int_t &mod,Int_t layer,Int_t cpn0,
1874 Int_t cpn1,Int_t cpn2) const {
1875 // decode geometry into detector module number. There are two decoding
1876 // Scheams. Old which does not follow the ALICE coordinate system
1877 // requirements, and New which dose.
1878 // Inputs:
1879 // Int_t layer The ITS layer
1880 // Int_t cpn0 The lowest copy number
1881 // Int_t cpn1 The middle copy number
1882 // Int_t cpn2 the highest copy number
1883 // Output:
1884 // Int_t &mod The module number assoicated with this set
1885 // of copy numbers.
1886 // Return:
1887 // none.
1888 const Int_t kDetPerLadderSPD[2]={2,4};
1889 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
1890 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
1891 Int_t lay=-1,lad=-1,det=-1,i;
1892
1893 if(fDecode){ // New decoding scheam
1894 switch (layer){
1895 case 1:{
1896 lay = layer;
1897 det = 5-cpn2;
1898 if(cpn0==4&&cpn1==1) lad=1;
1899 else if(cpn0==4&&cpn1==2) lad=20;
1900 else if(cpn0<4){
1901 lad = 8-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
1902 }else{ // cpn0>4
1903 lad = 28-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
1904 } // end if
1905 } break;
1906 case 2:{
1907 lay = layer;
1908 det = 5-cpn2;
1909 if(cpn0==4&&cpn1==1) lad=1;
1910 else if(cpn0<4){
1911 lad = 14-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
1912 }else{ // cpn0>4
1913 lad = 54-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
1914 } // end if
1915 } break;
1916 case 3:{
1917 lay = layer;
1918 if(cpn0<5) lad = 5-cpn0;
1919 else lad = 19-cpn0;
1920 det = 7-cpn1;
1921 } break;
1922 case 4:{
1923 lay = layer;
1924 if(cpn0<7) lad = 7-cpn0;
1925 else lad = 29-cpn0;
1926 det = 9-cpn1;
1927 } break;
1928 case 5:{
1929 lay = layer;
1930 if(cpn0<10) lad = 10-cpn0;
1931 else lad = 44-cpn0;
1932 det = 23-cpn1;
1933 } break;
1934 case 6:{
1935 lay = layer;
1936 if(cpn0<9) lad = 9-cpn0;
1937 else lad = 47-cpn0;
1938 det = 26-cpn1;
1939 } break;
1940 } // end switch
023ae34b 1941 mod = 0;
6b0f3880 1942 for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
1943 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
023ae34b 1944 return;
1945 } // end if
1946 // Old decoding scheam
1947 switch(layer){
1948 case 1: case 2:{
1949 lay = layer;
6b0f3880 1950 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 1951 det = cpn2;
1952 }break;
1953 case 3: case 4:{
1954 lay = layer;
1955 lad = cpn0;
1956 det = cpn1;
1957 }break;
1958 case 5: case 6:{
1959 lay = layer;
1960 lad = cpn0;
1961 det = cpn1;
1962 }break;
1963 default:{
1964 }break;
1965 } // end switch
1966 mod = 0;
6b0f3880 1967 for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
1968 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
023ae34b 1969 return;
1970}
1971//______________________________________________________________________
012f0f4c 1972void AliITSInitGeometry::RecodeDetectorvPPRasymmFMD(Int_t mod,Int_t &cpn0,
023ae34b 1973 Int_t &cpn1,Int_t &cpn2){
1974 // decode geometry into detector module number. There are two decoding
1975 // Scheams. Old which does not follow the ALICE coordinate system
1976 // requirements, and New which dose.
1977 // Inputs:
1978 // Int_t mod The module number assoicated with this set
1979 // of copy numbers.
1980 // Output:
1981 // Int_t cpn0 The lowest copy number
1982 // Int_t cpn1 The middle copy number
1983 // Int_t cpn2 the highest copy number
1984 // Return:
1985 // none.
6b0f3880 1986 const Int_t kITSgeoTreeCopys[6][3]= {{10, 2, 4},// lay=1
023ae34b 1987 {10, 4, 4},// lay=2
1988 {14, 6, 1},// lay=3
1989 {22, 8, 1},// lay=4
1990 {34,22, 1},// lay=5
1991 {38,25, 1}};//lay=6
6b0f3880 1992 const Int_t kDetPerLadderSPD[2]={2,4};
1993 // const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
1994 // const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
023ae34b 1995 Int_t lay,lad,det;
1996
1997 cpn0 = cpn1 = cpn2 = 0;
1998 DecodeDetectorLayers(mod,lay,lad,det);
1999 if(fDecode){ // New decoding scheam
2000 switch (lay){
2001 case 1:{
2002 cpn2 = 5-det; // Detector 1-4
6b0f3880 2003 cpn1 = 1+(lad-1)%kDetPerLadderSPD[lay-1];
2004 cpn0 = 5-(lad+kDetPerLadderSPD[lay-1])/kDetPerLadderSPD[lay-1];
2005 if(mod>27) cpn0 = 15-(lad+kDetPerLadderSPD[lay-1])/
2006 kDetPerLadderSPD[lay-1];
023ae34b 2007 } break;
2008 case 2:{
2009 cpn2 = 5-det; // Detector 1-4
6b0f3880 2010 cpn1 = 4-(lad+2)%kDetPerLadderSPD[lay-1];
2011 cpn0 = 1+(14-cpn1-lad)/kDetPerLadderSPD[lay-1];
2012 if(mod>131) cpn0 = 1+(54-lad-cpn1)/kDetPerLadderSPD[lay-1];
023ae34b 2013 } break;
2014 case 3:{
2015 cpn2 = 1;
2016 if(lad<5) cpn0 = 5-lad;
2017 else cpn0 = 19-lad;
2018 cpn1 = 7-det;
2019 } break;
2020 case 4:{
2021 cpn2 = 1;
2022 if(lad<7) cpn0 = 7-lad;
2023 else cpn0 = 29-lad;
2024 cpn1 = 9-det;
2025 } break;
2026 case 5:{
2027 cpn2 = 1;
2028 if(lad<10) cpn0 = 10-lad;
2029 else cpn0 = 44-lad;
2030 cpn1 = 23-det;
2031 } break;
2032 case 6:{
2033 cpn2 = 1;
2034 if(lad<9) cpn0 = 9-lad;
2035 else cpn0 = 47-lad;
2036 cpn1 = 26-det;
2037 } break;
2038 default:{
2039 Error("RecodeDetector","New: mod=%d lay=%d not 1-6.");
2040 return;
2041 } break;
2042 } // end switch
2043 if(cpn0<1||cpn1<1||cpn2<1||
6b0f3880 2044 cpn0>kITSgeoTreeCopys[lay-1][0]||
2045 cpn1>kITSgeoTreeCopys[lay-1][1]||
2046 cpn2>kITSgeoTreeCopys[lay-1][2])
023ae34b 2047 Error("RecodeDetector",
2048 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
2049 cpn0,cpn1,cpn2,mod,lay,lad,det);
2050 return;
2051 } // end if
2052 // Old encoding
2053 switch (lay){
2054 case 1: case 2:{
2055 cpn2 = det; // Detector 1-4
6b0f3880 2056 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
2057 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
023ae34b 2058 } break;
2059 case 3: case 4: case 5 : case 6:{
2060 cpn2 = 1;
2061 cpn1 = det;
2062 cpn0 = lad;
2063 } break;
2064 default:{
2065 Error("RecodeDetector","Old: mod=%d lay=%d not 1-6.");
2066 return;
2067 } break;
2068 } // end switch
2069 if(cpn0<1||cpn1<1||cpn2<1||
6b0f3880 2070 cpn0>kITSgeoTreeCopys[lay-1][0]||
2071 cpn1>kITSgeoTreeCopys[lay-1][1]||
2072 cpn2>kITSgeoTreeCopys[lay-1][2])
023ae34b 2073 Error("RecodeDetector",
2074 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
2075 cpn0,cpn1,cpn2,mod,lay,lad,det);
2076 return;
2077}
2078//______________________________________________________________________
012f0f4c 2079void AliITSInitGeometry::DecodeDetectorLayersvPPRasymmFMD(Int_t mod,Int_t &lay,
023ae34b 2080 Int_t &lad,Int_t &det){
2081 // decode geometry into detector module number. There are two decoding
2082 // Scheams. Old which does not follow the ALICE coordinate system
2083 // requirements, and New which dose. Note, this use of layer ladder
2084 // and detector numbers are strictly for internal use of this
2085 // specific code. They do not represent the "standard" layer ladder
2086 // or detector numbering except in a very old and obsoleate sence.
2087 // Inputs:
2088 // Int_t mod The module number assoicated with this set
2089 // of copy numbers.
2090 // Output:
2091 // Int_t lay The layer number
2092 // Int_t lad The ladder number
2093 // Int_t det the dettector number
2094 // Return:
2095 // none.
6b0f3880 2096 // const Int_t kDetPerLadderSPD[2]={2,4};
2097 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2098 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
023ae34b 2099 Int_t mod2;
2100
2101 det = 0;
2102 lad = 0;
2103 lay = 0;
2104 mod2 = 0;
2105 do{
6b0f3880 2106 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
023ae34b 2107 lay++;
2108 }while(mod2<=mod); // end while
2109 if(lay>6||lay<1) Error("DecodeDetectorLayers","0<lay=%d>6",lay);
6b0f3880 2110 mod2 -= kLadPerLayer[lay-1]*kDetPerLadder[lay-1];
023ae34b 2111 do{
2112 lad++;
6b0f3880 2113 mod2 += kDetPerLadder[lay-1];
023ae34b 2114 }while(mod2<=mod); // end while
012f0f4c 2115 if(lad>kLadPerLayer[lay-1]||lad<1) Error("DecodeDetectorLayers",
2116 "lad=%d>kLadPerLayer[lay-1=%d]=%d mod=%d mod2=%d",lad,lay-1,
2117 kLadPerLayer[lay-1],mod,mod2);
2118 mod2 -= kDetPerLadder[lay-1];
2119 det = mod-mod2+1;
2120 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
2121 "det=%d>detPerLayer[lay-1=%d]=%d mod=%d mod2=%d lad=%d",det,
2122 lay-1,kDetPerLadder[lay-1],mod,mod2,lad);
2123 return;
2124}
2125//______________________________________________________________________
2126void AliITSInitGeometry::DecodeDetectorv11Hybrid(Int_t &mod,Int_t layer,Int_t cpn0,
2127 Int_t cpn1,Int_t cpn2) const {
2128 // decode geometry into detector module number
2129 // Inputs:
2130 // Int_t layer The ITS layer
2131 // Int_t cpn0 The lowest copy number
2132 // Int_t cpn1 The middle copy number
2133 // Int_t cpn2 the highest copy number
2134 // Output:
2135 // Int_t &mod The module number assoicated with this set
2136 // of copy numbers.
2137 // Return:
2138 // none.
75473741 2139 const Int_t kDetPerLadderSPD[2]={2,4};
2140 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2141 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
2142 Int_t lad=-1,det=-1,i;
2143
2144 switch(layer) {
2145 case 1: case 2:{
2146 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
2147 det = cpn2;
2148 } break;
2149 case 3: case 4:{
2150 if (SDDIsTGeoNative()) {
2151 lad = cpn0+1;
2152 det = cpn1+1;
2153 } else {
2154 lad = cpn0;
2155 det = cpn1;
2156 }
2157 } break;
2158 case 5: case 6:{
2159 lad = cpn0;
2160 det = cpn1;
2161 } break;
2162 default:{
2163 } break;
2164 } // end switch
2165 mod = 0;
2166 for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
2167 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
2168 return;
012f0f4c 2169}
2170//______________________________________________________________________
2171void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
2172 Int_t &cpn1,Int_t &cpn2) {
2173 // decode geometry into detector module number. There are two decoding
2174 // Scheams. Old which does not follow the ALICE coordinate system
2175 // requirements, and New which dose.
2176 // Inputs:
2177 // Int_t mod The module number assoicated with this set
2178 // of copy numbers.
2179 // Output:
2180 // Int_t cpn0 The lowest copy number
2181 // Int_t cpn1 The middle copy number
2182 // Int_t cpn2 the highest copy number
2183 // Return:
2184 // none.
2185 const Int_t kITSgeoTreeCopys[6][3]= {{10, 2, 4},// lay=1
2186 {10, 4, 4},// lay=2
2187 {14, 6, 1},// lay=3
2188 {22, 8, 1},// lay=4
2189 {34,22, 1},// lay=5
2190 {38,25, 1}};//lay=6
2191 const Int_t kDetPerLadderSPD[2]={2,4};
2192 // const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2193 // const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
2194 Int_t lay,lad,det;
2195
2196 cpn0 = cpn1 = cpn2 = 0;
2197 DecodeDetectorLayers(mod,lay,lad,det);
2198 // Old encoding
2199 switch (lay){
2200 case 1: case 2:{
2201 cpn2 = det; // Detector 1-4
2202 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
2203 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
2204 } break;
2205 case 3: case 4: case 5 : case 6:{
2206 cpn2 = 1;
2207 cpn1 = det;
2208 cpn0 = lad;
2209 } break;
2210 default:{
2211 Error("RecodeDetector","Old: mod=%d lay=%d not 1-6.");
2212 return;
2213 } break;
2214 } // end switch
2215 if(cpn0<1||cpn1<1||cpn2<1||
2216 cpn0>kITSgeoTreeCopys[lay-1][0]||
2217 cpn1>kITSgeoTreeCopys[lay-1][1]||
2218 cpn2>kITSgeoTreeCopys[lay-1][2])
2219 Error("RecodeDetector",
2220 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
2221 cpn0,cpn1,cpn2,mod,lay,lad,det);
2222 return;
2223}
2224//______________________________________________________________________
2225void AliITSInitGeometry::DecodeDetectorLayersv11Hybrid(Int_t mod,Int_t &lay,
2226 Int_t &lad,Int_t &det) {
2227
2228 // decode geometry into detector module number for v11Hybrid
2229 // Inputs:
2230 // Int_t mod The module number assoicated with this set
2231 // of copy numbers.
2232 // Output:
2233 // Int_t lay The layer number
2234 // Int_t lad The ladder number
2235 // Int_t det the dettector number
2236 // Return:
2237 // none.
2238
2239 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2240 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
2241 Int_t mod2;
2242
2243 det = 0;
2244 lad = 0;
2245 lay = 0;
2246 mod2 = 0;
2247 do{
2248 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
2249 lay++;
2250 } while(mod2<=mod); // end while
2251 if(lay>6||lay<1) Error("DecodeDetectorLayers","0<lay=%d>6",lay);
2252 mod2 -= kLadPerLayer[lay-1]*kDetPerLadder[lay-1];
2253 do{
2254 lad++;
2255 mod2 += kDetPerLadder[lay-1];
2256 } while(mod2<=mod); // end while
2257 if(lad>kLadPerLayer[lay-1]||lad<1) Error("DecodeDetectorLayers",
6b0f3880 2258 "lad=%d>kLadPerLayer[lay-1=%d]=%d mod=%d mod2=%d",lad,lay-1,
2259 kLadPerLayer[lay-1],mod,mod2);
2260 mod2 -= kDetPerLadder[lay-1];
023ae34b 2261 det = mod-mod2+1;
6b0f3880 2262 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
023ae34b 2263 "det=%d>detPerLayer[lay-1=%d]=%d mod=%d mod2=%d lad=%d",det,
6b0f3880 2264 lay-1,kDetPerLadder[lay-1],mod,mod2,lad);
023ae34b 2265 return;
2266}
2267
012f0f4c 2268//______________________________________________________________________
2269Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,
2270 AliITSVersion_t maj,Int_t min,
2271 const Char_t *cvsDate,const Char_t *cvsRevision)const{
2272 // fills the string str with the major and minor version number
2273 // Inputs:
2274 // Char_t *str The character string to hold the major
2275 // and minor version numbers in
2276 // Int_t length The maximum number of characters which
2277 // can be accomidated by this string.
2278 // str[length-1] must exist and will be set to zero
2279 // AliITSVersion_t maj The major number
2280 // Int_t min The minor number
2281 // Char_t *cvsDate The date string from cvs
2282 // Char_t *cvsRevision The Revision string from cvs
2283 // Outputs:
2284 // Char_t *str The character string holding the major and minor
2285 // version numbers. str[length-1] must exist
2286 // and will be set to zero
2287 // Return:
2288 // kTRUE if no errors
2289 Int_t i,n,cvsDateLength,cvsRevisionLength;
2290
2291 cvsDateLength = (Int_t)strlen(cvsDate);
2292 cvsRevisionLength = (Int_t)strlen(cvsRevision);
2293 i = (Int_t)maj;
2294 n = 50+(Int_t)(TMath::Log10(TMath::Abs((Double_t)i)))+1+
2295 (Int_t)(TMath::Log10(TMath::Abs((Double_t)min)))+1
2296 +cvsDateLength-6+cvsRevisionLength-10;
2297 if(GetDebug()>1) printf("AliITSInitGeometry::WriteVersionString:"
2298 "length=%d major=%d minor=%d cvsDate=%s[%d] "
2299 "cvsRevision=%s[%d] n=%d\n",length,i,min,cvsDate,
2300 cvsDateLength,cvsRevision,cvsRevisionLength,n);
2301 if(i<0) n++;
2302 if(min<0) n++;
2303 if(length<n){// not enough space to write in output string.
2304 Warning("WriteVersionString","Output string not long enough "
2305 "lenght=%d must be at least %d long\n",length,n);
2306 return kFALSE;
2307 } // end if length<n
2308 char *cvsrevision = new char[cvsRevisionLength-10];
2309 char *cvsdate = new char[cvsDateLength-6];
2310 for(i=0;i<cvsRevisionLength-10;i++)
2311 if(10+i<cvsRevisionLength-1)
2312 cvsrevision[i] = cvsRevision[10+i]; else cvsrevision[i] = 0;
2313 for(i=0;i<cvsDateLength-6;i++) if(6+i<cvsDateLength-1)
2314 cvsdate[i] = cvsDate[6+i]; else cvsdate[i] = 0;
2315 for(i=0;i<length;i++) str[i] = 0; // zero it out for now.
2316 i = (Int_t)maj;
2317 sprintf(str,"Major Version= %d Minor Version= %d Revision: %s Date: %s",
2318 i,min,cvsrevision,cvsdate);
2319 if(GetDebug()>1)printf("AliITSInitGeometry::WriteVersionString: "
2320 "n=%d str=%s revision[%zu] date[%zu]\n",
2321 n,str,strlen(cvsrevision),strlen(cvsdate));
2322 delete[] cvsrevision;
2323 delete[] cvsdate;
2324 return kTRUE;
2325}
2326//______________________________________________________________________
2327Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,Int_t length,
2328 AliITSVersion_t &maj,Int_t &min,
2329 TDatime &dt)const{
2330 // fills the string str with the major and minor version number
2331 // Inputs:
2332 // Char_t *str The character string to holding the major and minor
2333 // version numbers in
2334 // Int_t length The maximum number of characters which can be
2335 // accomidated by this string. str[length-1] must exist
2336 // Outputs:
2337 // Char_t *str The character string holding the major and minor
2338 // version numbers unchanged. str[length-1] must exist.
2339 // AliITSVersion_t maj The major number
2340 // Int_t min The minor number
2341 // TDatime dt The date and time of the cvs commit
2342 // Return:
2343 // kTRUE if no errors
2344 Bool_t ok;
2345 Char_t cvsRevision[10],cvsDate[11],cvsTime[9];
2346 Int_t i,m,n=strlen(str),year,month,day,hours,minuits,seconds;
2347
2348 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString:"
2349 "str=%s length=%d\n",
2350 str,length);
2351 if(n<35) return kFALSE; // not enough space for numbers
2352 m = sscanf(str,"Major Version= %d Minor Version= %d Revision: %s "
2353 "Date: %s %s",&i,&min,cvsRevision,cvsDate,cvsTime);
2354 ok = m==5;
2355 if(!ok) return !ok;
2356 m = sscanf(cvsDate,"%d/%d/%d",&year,&month,&day);
2357 ok = m==3;
2358 if(!ok) return !ok;
2359 m = sscanf(cvsTime,"%d:%d:%d",&hours,&minuits,&seconds);
2360 ok = m==3;
2361 if(!ok) return !ok;
2362 dt.Set(year,month,day,hours,minuits,seconds);
2363 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: i=%d min=%d "
2364 "cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
2365 i,min,cvsRevision,cvsDate,cvsTime,m);
2366 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: year=%d"
2367 " month=%d day=%d hours=%d minuits=%d seconds=%d\n",
2368 year,month,day,hours,minuits,seconds);
2369 switch (i){
2370 case kvITS04:{
2371 maj = kvITS04;
2372 } break;
2373 case kvSPD02:{
2374 maj = kvSPD02;
2375 } break;
2376 case kvSDD03:{
2377 maj = kvSDD03;
2378 } break;
2379 case kvSSD03:{
2380 maj = kvSSD03;
2381 } break;
2382 case kvPPRasymmFMD:{
2383 maj = kvPPRasymmFMD;
2384 } break;
2385 case kv11:{
2386 maj = kv11;
2387 } break;
2388 case kv11Hybrid:{
2389 maj = kv11Hybrid;
2390 } break;
2391 default:{
2392 maj = kvDefault;
2393 } break;
2394 } // end switch
2395 return ok;
2396}