A "mean vertexer" to measure the average vertex position during a run.
[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
dbfc6ce6 59const Bool_t AliITSInitGeometry::fgkOldSPDbarrel = kFALSE;
108bd0fe 60const Bool_t AliITSInitGeometry::fgkOldSDDbarrel = kFALSE;
bf210566 61const Bool_t AliITSInitGeometry::fgkOldSSDbarrel = kFALSE;
108bd0fe 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
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";
023ae34b 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];
108bd0fe 290
012f0f4c 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();
108bd0fe 334
012f0f4c 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};
108bd0fe 454
012f0f4c 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
108bd0fe 491
012f0f4c 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
581
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;
591
592 Int_t nModTot = 10;
593 geom->Init(0,knlayers,nlad,ndet,nModTot);
594
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 };
684
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
8f8273a4 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 {"%sIT12_1/I12B_%d/I10B_%d/L1H-STAVE%d_1/I107_%d/I101_1/ITS1_1", // lay=1
718 "%sIT12_1/I12B_%d/I20B_%d/L2H-STAVE%d_1/I1D7_%d/I1D1_1/ITS2_1", // lay=2
023ae34b 719 "%sIT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
720 "%sIT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
721 "%sIT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
722 "%sIT56_1/I569_%d/I566_%d/ITS6_%d"}};// Lay=6
723 /*
724 Int_t itsGeomTreeCopys[knlayers][3]= {{10, 2, 4},// lay=1
725 {10, 4, 4},// lay=2
726 {14, 6, 1},// lay=3
727 {22, 8, 1},// lay=4
728 {34,22, 1},// lay=5
729 {38,25, 1}};//lay=6
730 */
8f8273a4 731 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2, cpnHS;
023ae34b 732 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
733 TArrayD shapePar;
734 TString path,shapeName;
012f0f4c 735 TGeoHMatrix matrix;
023ae34b 736 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
24e270ad 737 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
023ae34b 738
739 if(fTiming) time->Start();
740 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
741 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
742 for(mod=0;mod<nmods;mod++){
743 DecodeDetectorLayers(mod,lay,lad,det); // Write
6b0f3880 744 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
023ae34b 745 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
8f8273a4 746
747 if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
748 if (det<3) cpnHS = 0; else cpnHS = 1;
749 path.Form(kNames[fMinorVersion-1][lay-1].Data(),kPathbase.Data(),
750 cpn0,cpn1,cpnHS,cpn2);
751 } else {
752 path.Form(kNames[fMinorVersion-1][lay-1].Data(),kPathbase.Data(),
753 cpn0,cpn1,cpn2);
754 };
755// path.Form(kNames[fMinorVersion-1][lay-1].Data(),
756// kPathbase.Data(),cpn0,cpn1,cpn2);
757
023ae34b 758 geom->GetGeomMatrix(mod)->SetPath(path);
012f0f4c 759 GetTransformation(path.Data(),matrix);
760 geom->SetTrans(mod,matrix.GetTranslation());
761 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
762 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
6b0f3880 763 if(initSeg[kIdet[lay-1]]) continue;
023ae34b 764 GetShape(path,shapeName,shapePar);
765 if(shapeName.CompareTo("BOX")){
012f0f4c 766 Error("InitITSgeomPPRasymmFMD",
767 "Geometry changed without proper code update or error "
768 "in reading geometry. Shape is not BOX. Shape is %s",
769 shapeName.Data());
770 return kFALSE;
023ae34b 771 } // end if
6b0f3880 772 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
023ae34b 773 } // end for module
774 if(fTiming){
775 time->Stop();
776 time->Print();
777 delete time;
778 } // end if
779 return kTRUE;
780}
108bd0fe 781//______________________________________________________________________
782Bool_t AliITSInitGeometry::InitAliITSgeomV11Hybrid(AliITSgeom *geom){
783 // Initilizes the geometry transformation class AliITSgeom
784 // to values appropreate to this specific geometry. Now that
785 // the segmentation is part of AliITSgeom, the detector
786 // segmentations are also defined here.
787 // Inputs:
788 // AliITSgeom *geom A pointer to the AliITSgeom class
789 // Outputs:
790 // AliITSgeom *geom This pointer recreated and properly inilized.
791 // Return:
792 // none.
793
794 const Int_t kItype = 0; // Type of transformation defined 0=> Geant
795 const Int_t klayers = 6; // number of layers in the ITS
796 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
797 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
798 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
799 const TString kPathbase = "/ALIC_1/ITSV_1/";
8f8273a4 800
801 char *pathSPDsens1, *pathSPDsens2;
802 if (SPDIsTGeoNative()) {
803 pathSPDsens1="%sITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/LAY1_STAVE_%d/HALF-STAVE%d_1/LAY1_LADDER_%d/LAY1_SENSOR_1";
804 pathSPDsens2="%sITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/LAY2_STAVE_%d/HALF-STAVE%d_1/LAY2_LADDER_%d/LAY2_SENSOR_1";
805 } else{
806 pathSPDsens1 = "%sITSD_1/IT12_1/I12B_%d/I10B_%d/L1H-STAVE%d_1/I107_%d/I101_1/ITS1_1";
807 pathSPDsens2 = "%sITSD_1/IT12_1/I12B_%d/I20B_%d/L2H-STAVE%d_1/I1D7_%d/I1D1_1/ITS2_1";
808 }
809
108bd0fe 810 char *pathSDDsens1, *pathSDDsens2;
811 if (SDDIsTGeoNative()) {
812 pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
813 pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
814 } else{
815 pathSDDsens1 = "%sITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d";
816 pathSDDsens2 = "%sITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d";
817 }
bf210566 818
819 char *pathSSDsens1, *pathSSDsens2;
820 if (SSDIsTGeoNative()) {
821 pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSsddSensor5_%d/ITSsddSensitivL5_1";
822 pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSsddSensor6_%d/ITSsddSensitivL6_1";
823 } else{
824 pathSSDsens1 = "%sITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d";
825 pathSSDsens2 = "%sITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d";
826 }
827
108bd0fe 828 const TString kNames[klayers] = {
8f8273a4 829 pathSPDsens1, // lay=1
830 pathSPDsens2, // lay=2
108bd0fe 831 pathSDDsens1, // lay=3
832 pathSDDsens2, // lay=4
bf210566 833 pathSSDsens1, // lay=5
834 pathSSDsens2};// Lay=6
108bd0fe 835
8f8273a4 836 Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1;
108bd0fe 837 Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
838 TArrayD shapePar;
839 TString path, shapeName;
840 TGeoHMatrix matrix;
841 Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
842 TStopwatch *time = 0x0;
843 if(fTiming) time = new TStopwatch();
844
845 if(fTiming) time->Start();
846 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
847 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
848
8f8273a4 849 for(mod=0; mod<nmods; mod++) {
108bd0fe 850
8f8273a4 851 DecodeDetectorLayers(mod,lay,lad,det);
108bd0fe 852 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
8f8273a4 853 RecodeDetectorv11Hybrid(mod,cpn0,cpn1,cpn2);
854
855// if (SPDIsTGeoNative())
856// if (kIdet[lay-1]==kSPD) {
857// cpn0 = lad-1;
858// cpn1 = det-1;
859// cpn2 = 1;
860// }
861// if (SDDIsTGeoNative())
862// if (kIdet[lay-1]==kSDD) {
863// cpn0 = lad-1;
864// cpn1 = det-1;
865// cpn2 = 1;
866// }
867// if (SSDIsTGeoNative())
868// if (kIdet[lay-1]==kSSD) {
869// cpn0 = lad-1;
870// cpn1 = det-1;
871// cpn2 = 1;
872// }
873
874 if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
875 if (det<3) cpnHS = 0; else cpnHS = 1;
876 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2);
877 } else {
878 path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2);
879 };
108bd0fe 880
108bd0fe 881 geom->GetGeomMatrix(mod)->SetPath(path);
882 GetTransformation(path.Data(),matrix);
883 geom->SetTrans(mod,matrix.GetTranslation());
012f0f4c 884 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
108bd0fe 885 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
886 if(initSeg[kIdet[lay-1]]) continue;
887 GetShape(path,shapeName,shapePar);
888 if(shapeName.CompareTo("BOX")){
889 Error("InitITSgeom","Geometry changed without proper code update"
890 "or error in reading geometry. Shape is not BOX.");
891 return kFALSE;
892 } // end if
893 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
894 } // end for module
895
896 if(fTiming){
897 time->Stop();
898 time->Print();
899 delete time;
900 } // end if
901 return kTRUE;
902}
108bd0fe 903//______________________________________________________________________
904Bool_t AliITSInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
905 // Initilizes the geometry transformation class AliITSgeom
906 // Now that the segmentation is part of AliITSgeom, the detector
907 // segmentations are also defined here.
908 //
909 // Inputs:
910 // AliITSgeom *geom A pointer to the AliITSgeom class
911 // Outputs:
912 // AliITSgeom *geom This pointer recreated and properly inilized.
913 // LG
914
915
916 const Int_t kItype=0; // Type of transormation defined 0=> Geant
917 const Int_t klayers = 6; // number of layers in the ITS
918 const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
919 const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
920 const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
921
922 const TString kPathbase = "/ALIC_1/ITSV_1/";
923 const TString kNames[klayers] =
924 {"AliITSInitGeometry:spd missing", // lay=1
925 "AliITSInitGeometry:spd missing", // lay=2
926 "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_1/ITSsddSensitiv_1", // lay=3
927 "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_1/ITSsddSensitiv_1", // lay=4
928 "AliITSInitGeometry:ssd missing", // lay=5
929 "AliITSInitGeometry:ssd missing"};// lay=6
930
931 Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2;
932 Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
933 TArrayD shapePar;
934 TString path,shapeName;
935 TGeoHMatrix matrix;
936 Bool_t initSeg[3]={kFALSE,kFALSE,kFALSE};
937 TStopwatch *time = 0x0;if(fTiming) time=new TStopwatch();
938
939 if(fTiming) time->Start();
940 for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
941
942 geom->Init(kItype,klayers,kladders,kdetectors,nmods);
943 for(mod=0;mod<nmods;mod++) {
944
945 DecodeDetectorLayers(mod,lay,lad,det); // Write
946 geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
947 RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
948 path.Form(kNames[lay-1].Data(),
949 kPathbase.Data(),cpn0,cpn1,cpn2);
950 geom->GetGeomMatrix(mod)->SetPath(path);
951 if (GetTransformation(path.Data(),matrix)) {
952 geom->SetTrans(mod,matrix.GetTranslation());
012f0f4c 953 TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
108bd0fe 954 geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
955 }
956
957 if(initSeg[kIdet[lay-1]]) continue;
958 GetShape(path,shapeName,shapePar);
959 if(shapeName.CompareTo("BOX")){
960 Error("InitAliITSgeomV11","Geometry changed without proper code update"
961 "or error in reading geometry. Shape is not BOX.");
962 return kFALSE;
963 } // end if
964 InitGeomShapePPRasymmFMD(kIdet[lay-1],initSeg,shapePar,geom);
965
966 } // end for module
967
968 if(fTiming){
969 time->Stop();
970 time->Print();
971 delete time;
972 } // end if
973 return kTRUE;
974}
975
023ae34b 976//______________________________________________________________________
977Bool_t AliITSInitGeometry::InitGeomShapePPRasymmFMD(AliITSDetector idet,
978 Bool_t *initSeg,
979 TArrayD &shapePar,
980 AliITSgeom *geom){
981 // Initilizes the geometry segmentation class AliITSgeomS?D, or
982 // AliITSsegmentationS?D depending on the vaule of fSegGeom,
983 // to values appropreate to this specific geometry. Now that
984 // the segmentation is part of AliITSgeom, the detector
985 // segmentations are also defined here.
986 // Inputs:
987 // Int_t lay The layer number/name.
988 // AliITSgeom *geom A pointer to the AliITSgeom class
989 // Outputs:
990 // AliITSgeom *geom This pointer recreated and properly inilized.
991 // Return:
992 // none.
993 // const Double_t kcm2micron = 1.0E4;
994 const Double_t kmicron2cm = 1.0E-4;
995 Int_t i;
996 TArrayF shapeParF;
997
998 shapeParF.Set(shapePar.GetSize());
999 for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
1000 switch (idet){
1001 case kSPD:{
1002 initSeg[idet] = kTRUE;
1003 AliITSgeomSPD *geomSPD = new AliITSgeomSPD425Short();
1004 Float_t bx[256],bz[280];
1005 for(i=000;i<256;i++) bx[i] = 50.0*kmicron2cm; // in x all are 50 microns.
1006 for(i=000;i<160;i++) bz[i] = 425.0*kmicron2cm; // most are 425 microns
1007 // except below
1008 for(i=160;i<280;i++) bz[i] = 0.0*kmicron2cm; // Outside of detector.
1009 bz[ 31] = bz[ 32] = 625.0*kmicron2cm; // first chip boundry
1010 bz[ 63] = bz[ 64] = 625.0*kmicron2cm; // first chip boundry
1011 bz[ 95] = bz[ 96] = 625.0*kmicron2cm; // first chip boundry
1012 bz[127] = bz[128] = 625.0*kmicron2cm; // first chip boundry
1013 bz[160] = 425.0*kmicron2cm;// Set so that there is no zero pixel size for fNz.
1014 geomSPD->ReSetBins(shapeParF[1],256,bx,160,bz);
1015 geom->ReSetShape(idet,geomSPD);
1016 }break;
1017 case kSDD:{
1018 initSeg[idet] = kTRUE;
1019 AliITSgeomSDD *geomSDD = new AliITSgeomSDD256(shapeParF.GetSize(),
1020 shapeParF.GetArray());
1021 geom->ReSetShape(idet,geomSDD);
1022 }break;
1023 case kSSD:{
1024 initSeg[idet] = kTRUE;
1025 AliITSgeomSSD *geomSSD = new AliITSgeomSSD275and75(
1026 shapeParF.GetSize(),shapeParF.GetArray());
1027 geom->ReSetShape(idet,geomSSD);
1028 }break;
1029 default:{// Others, Note no kSDDp or kSSDp in this geometry.
1030 geom->ReSetShape(idet,0);
1031 Info("InitGeomShapePPRasymmFMD",
1032 "default Dx=%f Dy=%f Dz=%f default=%d",
1033 shapePar[0],shapePar[1],shapePar[2],idet);
1034 }break;
1035 } // end switch
1036 return kTRUE;
1037}
1038//______________________________________________________________________
1039Bool_t AliITSInitGeometry::InitSegmentationPPRasymmFMD(AliITSDetector idet,
1040 Bool_t *initSeg,
1041 TArrayD &shapePar,
1042 AliITSgeom *geom){
1043 // Initilizes the geometry segmentation class AliITSgeomS?D, or
1044 // AliITSsegmentationS?D depending on the vaule of fSegGeom,
1045 // to values appropreate to this specific geometry. Now that
1046 // the segmentation is part of AliITSgeom, the detector
1047 // segmentations are also defined here.
1048 // Inputs:
1049 // Int_t lay The layer number/name.
1050 // AliITSgeom *geom A pointer to the AliITSgeom class
1051 // Outputs:
1052 // AliITSgeom *geom This pointer recreated and properly inilized.
1053 // Return:
1054 // none.
1055 const Double_t kcm2micron = 1.0E4;
1056 Int_t i;
1057
1058 switch (idet){
1059 case kSPD:{
1060 initSeg[idet] = kTRUE;
1061 AliITSsegmentationSPD *segSPD = new AliITSsegmentationSPD();
1062 segSPD->SetDetSize(2.*shapePar[0]*kcm2micron, // X
1063 2.*shapePar[2]*kcm2micron, // Z
1064 2.*shapePar[1]*kcm2micron);// Y Microns
1065 segSPD->SetNPads(256,160);// Number of Bins in x and z
1066 Float_t bx[256],bz[280];
1067 for(i=000;i<256;i++) bx[i] = 50.0; // in x all are 50 microns.
1068 for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns
1069 // except below
1070 for(i=160;i<280;i++) bz[i] = 0.0; // Outside of detector.
1071 bz[ 31] = bz[ 32] = 625.0; // first chip boundry
1072 bz[ 63] = bz[ 64] = 625.0; // first chip boundry
1073 bz[ 95] = bz[ 96] = 625.0; // first chip boundry
1074 bz[127] = bz[128] = 625.0; // first chip boundry
1075 bz[160] = 425.0;// Set so that there is no zero pixel size for fNz.
1076 segSPD->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
1077 geom->ReSetShape(idet,segSPD);
1078 }break;
1079 case kSDD:{
1080 initSeg[idet] = kTRUE;
1081 AliITSsegmentationSDD *segSDD = new AliITSsegmentationSDD();
1082 segSDD->SetDetSize(shapePar[0]*kcm2micron, // X
1083 2.*shapePar[2]*kcm2micron, // Z
1084 2.*shapePar[1]*kcm2micron);// Y Microns
1085 segSDD->SetNPads(256,256);// Anodes, Samples
1086 geom->ReSetShape(idet,segSDD);
1087 }break;
1088 case kSSD:{
1089 initSeg[idet] = kTRUE;
1090 AliITSsegmentationSSD *segSSD = new AliITSsegmentationSSD();
1091 segSSD->SetDetSize(2.*shapePar[0]*kcm2micron, // X
1092 2.*shapePar[2]*kcm2micron, // Z
1093 2.*shapePar[1]*kcm2micron);// Y Microns.
1094 segSSD->SetPadSize(95.,0.); // strip x pitch in microns
1095 segSSD->SetNPads(768,2); // number of strips on each side, sides.
1096 segSSD->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
1097 segSSD->SetAnglesLay5(0.0075,0.0275);//strip angels rad P and N
1098 segSSD->SetAnglesLay6(0.0275,0.0075);//strip angels rad P and N
1099 geom->ReSetShape(idet,segSSD);
1100 }break;
1101 default:{// Others, Note no kSDDp or kSSDp in this geometry.
1102 geom->ReSetShape(idet,0);
1103 Info("InitSegmentationPPRasymmFMD",
1104 "default segmentation Dx=%f Dy=%f Dz=%f default=%d",
1105 shapePar[0],shapePar[1],shapePar[2],idet);
1106 }break;
1107 } // end switch
1108 return kTRUE;
1109}
1110//______________________________________________________________________
1111Bool_t AliITSInitGeometry::GetTransformation(const TString &volumePath,
1112 TGeoHMatrix &mat){
1113 // Returns the Transformation matrix between the volume specified
1114 // by the path volumePath and the Top or mater volume. The format
1115 // of the path volumePath is as follows (assuming ALIC is the Top volume)
1116 // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
1117 // or master volume which has only 1 instance of. Of all of the daughter
1118 // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
1119 // the daughter volume of DDIP is S05I copy #2 and so on.
1120 // Inputs:
1121 // TString& volumePath The volume path to the specific volume
1122 // for which you want the matrix. Volume name
1123 // hierarchy is separated by "/" while the
1124 // copy number is appended using a "_".
1125 // Outputs:
1126 // TGeoHMatrix &mat A matrix with its values set to those
1127 // appropriate to the Local to Master transformation
1128 // Return:
1129 // A logical value if kFALSE then an error occurred and no change to
1130 // mat was made.
1131
1132 // We have to preserve the modeler state
1133
1134 // Preserve the modeler state.
1135 gGeoManager->PushPath();
1136 if (!gGeoManager->cd(volumePath.Data())) {
108bd0fe 1137 gGeoManager->PopPath();
1138 Error("GetTransformation","Error in cd-ing to ",volumePath.Data());
1139 return kFALSE;
023ae34b 1140 } // end if !gGeoManager
1141 mat = *gGeoManager->GetCurrentMatrix();
1142 // Retstore the modeler state.
1143 gGeoManager->PopPath();
1144 return kTRUE;
1145}
1146//______________________________________________________________________
1147Bool_t AliITSInitGeometry::GetShape(const TString &volumePath,
1148 TString &shapeType,TArrayD &par){
1149 // Returns the shape and its parameters for the volume specified
1150 // by volumeName.
1151 // Inputs:
1152 // TString& volumeName The volume name
1153 // Outputs:
1154 // TString &shapeType Shape type
1155 // TArrayD &par A TArrayD of parameters with all of the
1156 // parameters of the specified shape.
1157 // Return:
1158 // A logical indicating whether there was an error in getting this
1159 // information
1160 Int_t npar;
1161 gGeoManager->PushPath();
1162 if (!gGeoManager->cd(volumePath.Data())) {
1163 gGeoManager->PopPath();
1164 return kFALSE;
1165 }
1166 TGeoVolume * vol = gGeoManager->GetCurrentVolume();
1167 gGeoManager->PopPath();
1168 if (!vol) return kFALSE;
1169 TGeoShape *shape = vol->GetShape();
6b0f3880 1170 TClass *classType = shape->IsA();
1171 if (classType==TGeoBBox::Class()) {
023ae34b 1172 shapeType = "BOX";
1173 npar = 3;
1174 par.Set(npar);
1175 TGeoBBox *box = (TGeoBBox*)shape;
1176 par.AddAt(box->GetDX(),0);
1177 par.AddAt(box->GetDY(),1);
1178 par.AddAt(box->GetDZ(),2);
1179 return kTRUE;
012f0f4c 1180 } // end if
6b0f3880 1181 if (classType==TGeoTrd1::Class()) {
023ae34b 1182 shapeType = "TRD1";
1183 npar = 4;
1184 par.Set(npar);
1185 TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
1186 par.AddAt(trd1->GetDx1(),0);
1187 par.AddAt(trd1->GetDx2(),1);
1188 par.AddAt(trd1->GetDy(), 2);
1189 par.AddAt(trd1->GetDz(), 3);
1190 return kTRUE;
012f0f4c 1191 } // end if
6b0f3880 1192 if (classType==TGeoTrd2::Class()) {
023ae34b 1193 shapeType = "TRD2";
1194 npar = 5;
1195 par.Set(npar);
1196 TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
1197 par.AddAt(trd2->GetDx1(),0);
1198 par.AddAt(trd2->GetDx2(),1);
1199 par.AddAt(trd2->GetDy1(),2);
1200 par.AddAt(trd2->GetDy2(),3);
1201 par.AddAt(trd2->GetDz(), 4);
1202 return kTRUE;
012f0f4c 1203 } // end if
6b0f3880 1204 if (classType==TGeoTrap::Class()) {
023ae34b 1205 shapeType = "TRAP";
1206 npar = 11;
1207 par.Set(npar);
1208 TGeoTrap *trap = (TGeoTrap*)shape;
1209 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
1210 par.AddAt(trap->GetDz(),0);
1211 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
1212 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
1213 par.AddAt(trap->GetH1(),3);
1214 par.AddAt(trap->GetBl1(),4);
1215 par.AddAt(trap->GetTl1(),5);
1216 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
1217 par.AddAt(trap->GetH2(),7);
1218 par.AddAt(trap->GetBl2(),8);
1219 par.AddAt(trap->GetTl2(),9);
1220 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
1221 return kTRUE;
012f0f4c 1222 } // end if
6b0f3880 1223 if (classType==TGeoTube::Class()) {
023ae34b 1224 shapeType = "TUBE";
1225 npar = 3;
1226 par.Set(npar);
1227 TGeoTube *tube = (TGeoTube*)shape;
1228 par.AddAt(tube->GetRmin(),0);
1229 par.AddAt(tube->GetRmax(),1);
1230 par.AddAt(tube->GetDz(),2);
1231 return kTRUE;
012f0f4c 1232 } // end if
6b0f3880 1233 if (classType==TGeoTubeSeg::Class()) {
023ae34b 1234 shapeType = "TUBS";
1235 npar = 5;
1236 par.Set(npar);
1237 TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
1238 par.AddAt(tubs->GetRmin(),0);
1239 par.AddAt(tubs->GetRmax(),1);
1240 par.AddAt(tubs->GetDz(),2);
1241 par.AddAt(tubs->GetPhi1(),3);
1242 par.AddAt(tubs->GetPhi2(),4);
1243 return kTRUE;
012f0f4c 1244 } // end if
6b0f3880 1245 if (classType==TGeoCone::Class()) {
023ae34b 1246 shapeType = "CONE";
1247 npar = 5;
1248 par.Set(npar);
1249 TGeoCone *cone = (TGeoCone*)shape;
1250 par.AddAt(cone->GetDz(),0);
1251 par.AddAt(cone->GetRmin1(),1);
1252 par.AddAt(cone->GetRmax1(),2);
1253 par.AddAt(cone->GetRmin2(),3);
1254 par.AddAt(cone->GetRmax2(),4);
1255 return kTRUE;
012f0f4c 1256 } // end if
6b0f3880 1257 if (classType==TGeoConeSeg::Class()) {
023ae34b 1258 shapeType = "CONS";
1259 npar = 7;
1260 par.Set(npar);
1261 TGeoConeSeg *cons = (TGeoConeSeg*)shape;
1262 par.AddAt(cons->GetDz(),0);
1263 par.AddAt(cons->GetRmin1(),1);
1264 par.AddAt(cons->GetRmax1(),2);
1265 par.AddAt(cons->GetRmin2(),3);
1266 par.AddAt(cons->GetRmax2(),4);
1267 par.AddAt(cons->GetPhi1(),5);
1268 par.AddAt(cons->GetPhi2(),6);
1269 return kTRUE;
012f0f4c 1270 } // end if
6b0f3880 1271 if (classType==TGeoSphere::Class()) {
023ae34b 1272 shapeType = "SPHE";
1273 npar = 6;
1274 par.Set(npar);
1275
1276 TGeoSphere *sphe = (TGeoSphere*)shape;
1277 par.AddAt(sphe->GetRmin(),0);
1278 par.AddAt(sphe->GetRmax(),1);
1279 par.AddAt(sphe->GetTheta1(),2);
1280 par.AddAt(sphe->GetTheta2(),3);
1281 par.AddAt(sphe->GetPhi1(),4);
1282 par.AddAt(sphe->GetPhi2(),5);
1283 return kTRUE;
012f0f4c 1284 } // end if
6b0f3880 1285 if (classType==TGeoPara::Class()) {
023ae34b 1286 shapeType = "PARA";
1287 npar = 6;
1288 par.Set(npar);
1289 TGeoPara *para = (TGeoPara*)shape;
1290 par.AddAt(para->GetX(),0);
1291 par.AddAt(para->GetY(),1);
1292 par.AddAt(para->GetZ(),2);
1293 par.AddAt(para->GetTxy(),3);
1294 par.AddAt(para->GetTxz(),4);
1295 par.AddAt(para->GetTyz(),5);
1296 return kTRUE;
012f0f4c 1297 } // end if
6b0f3880 1298 if (classType==TGeoPgon::Class()) {
023ae34b 1299 shapeType = "PGON";
1300 TGeoPgon *pgon = (TGeoPgon*)shape;
1301 Int_t nz = pgon->GetNz();
1302 const Double_t *rmin = pgon->GetRmin();
1303 const Double_t *rmax = pgon->GetRmax();
1304 const Double_t *z = pgon->GetZ();
1305 npar = 4 + 3*nz;
1306 par.Set(npar);
1307 par.AddAt(pgon->GetPhi1(),0);
1308 par.AddAt(pgon->GetDphi(),1);
1309 par.AddAt(pgon->GetNedges(),2);
1310 par.AddAt(pgon->GetNz(),3);
1311 for (Int_t i=0; i<nz; i++) {
1312 par.AddAt(z[i], 4+3*i);
1313 par.AddAt(rmin[i], 4+3*i+1);
1314 par.AddAt(rmax[i], 4+3*i+2);
1315 }
1316 return kTRUE;
012f0f4c 1317 } // end if
6b0f3880 1318 if (classType==TGeoPcon::Class()) {
023ae34b 1319 shapeType = "PCON";
1320 TGeoPcon *pcon = (TGeoPcon*)shape;
1321 Int_t nz = pcon->GetNz();
1322 const Double_t *rmin = pcon->GetRmin();
1323 const Double_t *rmax = pcon->GetRmax();
1324 const Double_t *z = pcon->GetZ();
1325 npar = 3 + 3*nz;
1326 par.Set(npar);
1327 par.AddAt(pcon->GetPhi1(),0);
1328 par.AddAt(pcon->GetDphi(),1);
1329 par.AddAt(pcon->GetNz(),2);
1330 for (Int_t i=0; i<nz; i++) {
1331 par.AddAt(z[i], 3+3*i);
1332
1333 par.AddAt(rmin[i], 3+3*i+1);
1334 par.AddAt(rmax[i], 3+3*i+2);
1335 }
1336 return kTRUE;
012f0f4c 1337 } // end if
6b0f3880 1338 if (classType==TGeoEltu::Class()) {
023ae34b 1339 shapeType = "ELTU";
1340 npar = 3;
1341 par.Set(npar);
1342 TGeoEltu *eltu = (TGeoEltu*)shape;
1343 par.AddAt(eltu->GetA(),0);
1344 par.AddAt(eltu->GetB(),1);
1345 par.AddAt(eltu->GetDz(),2);
1346 return kTRUE;
012f0f4c 1347 } // end if
6b0f3880 1348 if (classType==TGeoHype::Class()) {
023ae34b 1349 shapeType = "HYPE";
1350 npar = 5;
1351 par.Set(npar);
1352 TGeoHype *hype = (TGeoHype*)shape;
1353 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
1354 par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
1355 par.AddAt(hype->GetDZ(),2);
1356 par.AddAt(hype->GetStIn(),3);
1357 par.AddAt(hype->GetStOut(),4);
1358 return kTRUE;
012f0f4c 1359 } // end if
6b0f3880 1360 if (classType==TGeoGtra::Class()) {
023ae34b 1361 shapeType = "GTRA";
1362 npar = 12;
1363 par.Set(npar);
1364 TGeoGtra *trap = (TGeoGtra*)shape;
1365 Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
1366 par.AddAt(trap->GetDz(),0);
1367 par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
1368 par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
1369 par.AddAt(trap->GetH1(),3);
1370 par.AddAt(trap->GetBl1(),4);
1371 par.AddAt(trap->GetTl1(),5);
1372 par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
1373 par.AddAt(trap->GetH2(),7);
1374 par.AddAt(trap->GetBl2(),8);
1375 par.AddAt(trap->GetTl2(),9);
1376 par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
1377 par.AddAt(trap->GetTwistAngle(),11);
1378 return kTRUE;
012f0f4c 1379 } // end if
6b0f3880 1380 if (classType==TGeoCtub::Class()) {
023ae34b 1381 shapeType = "CTUB";
1382 npar = 11;
1383 par.Set(npar);
1384 TGeoCtub *ctub = (TGeoCtub*)shape;
1385 const Double_t *lx = ctub->GetNlow();
1386 const Double_t *tx = ctub->GetNhigh();
1387 par.AddAt(ctub->GetRmin(),0);
1388 par.AddAt(ctub->GetRmax(),1);
1389 par.AddAt(ctub->GetDz(),2);
1390 par.AddAt(ctub->GetPhi1(),3);
1391 par.AddAt(ctub->GetPhi2(),4);
1392 par.AddAt(lx[0],5);
1393 par.AddAt(lx[1],6);
1394 par.AddAt(lx[2],7);
1395 par.AddAt(tx[0],8);
1396 par.AddAt(tx[1],9);
1397 par.AddAt(tx[2],10);
1398 return kTRUE;
012f0f4c 1399 } // end if
023ae34b 1400 Error("GetShape","Getting shape parameters for shape %s not implemented",
1401 shape->ClassName());
012f0f4c 1402 shapeType = "Unknown";
023ae34b 1403 return kFALSE;
1404}
1405//______________________________________________________________________
012f0f4c 1406void AliITSInitGeometry::DecodeDetector(
1407 Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
1408 // decode geometry into detector module number. There are two decoding
1409 // Scheams. Old which does not follow the ALICE coordinate system
1410 // requirements, and New which dose.
1411 // Inputs:
1412 // Int_t layer The ITS layer
1413 // Int_t cpn0 The lowest copy number
1414 // Int_t cpn1 The middle copy number
1415 // Int_t cpn2 the highest copy number
1416 // Output:
1417 // Int_t &mod The module number assoicated with this set
1418 // of copy numbers.
1419 // Return:
1420 // none.
1421
1422 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
1423 // like them but I see not better way for the moment.
1424 switch (fMajorVersion){
1425 case kvtest:{
1426 if(GetMinorVersion()==1)
1427 return DecodeDetectorvPPRasymmFMD(mod,layer,cpn0,cpn1,cpn2);
1428 else if(GetMinorVersion()==2)
1429 return DecodeDetectorvtest2(mod,layer,cpn0,cpn1,cpn2);
1430 Warning("DecodeDetector",
1431 "Geometry is kvtest minor version=%d is not defined",
1432 GetMinorVersion());
1433 }break;
1434 case kvDefault:{
1435 Error("DecodeDetector","Major version = kvDefault, not supported");
1436 }break;
1437 case kvSPD02:{
1438 return DecodeDetectorvSPD02(mod,layer,cpn0,cpn1,cpn2);
1439 }break;
1440 case kvSDD03:{
1441 return DecodeDetectorvSDD03(mod,layer,cpn0,cpn1,cpn2);
1442 }break;
1443 case kvSSD03:{
1444 return DecodeDetectorvSSD03(mod,layer,cpn0,cpn1,cpn2);
1445 }break;
1446 case kvITS04:{
1447 return DecodeDetectorvITS04(mod,layer,cpn0,cpn1,cpn2);
1448 }break;
1449 case kvPPRcourseasymm:{
1450 return DecodeDetectorvPPRcourseasymm(mod,layer,cpn0,cpn1,cpn2);
1451 }break;
1452 case kvPPRasymmFMD:{
1453 return DecodeDetectorvPPRasymmFMD(mod,layer,cpn0,cpn1,cpn2);
1454 }break;
1455 case kv11:{
1456 return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2);
1457 }break;
1458 case kv11Hybrid:{
1459 return DecodeDetectorv11Hybrid(mod,layer,cpn0,cpn1,cpn2);
1460 }break;
1461 default:{
1462 Error("DecodeDetector","Major version = %d, not supported",
1463 (Int_t)fMajorVersion);
1464 return;
1465 }break;
1466 } // end switch
1467 return;
1468}
1469//______________________________________________________________________
1470void AliITSInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
1471 Int_t &cpn1,Int_t &cpn2){
1472 // decode geometry into detector module number. There are two decoding
1473 // Scheams. Old which does not follow the ALICE coordinate system
1474 // requirements, and New which dose.
1475 // Inputs:
1476 // Int_t mod The module number assoicated with this set
1477 // of copy numbers.
1478 // Output:
1479 // Int_t cpn0 The lowest copy number
1480 // Int_t cpn1 The middle copy number
1481 // Int_t cpn2 the highest copy number
1482 // Return:
1483 // none.
1484
1485 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
1486 // like them but I see not better way for the moment.
1487 switch (fMajorVersion){
1488 case kvtest:{
1489 if(GetMinorVersion()==1)
1490 return RecodeDetectorvPPRasymmFMD(mod,cpn0,cpn1,cpn2);
1491 else if(GetMinorVersion()==2)
1492 return RecodeDetectorvtest2(mod,cpn0,cpn1,cpn2);
1493 Warning("RecodeDetector",
1494 "Geometry is kvtest minor version=%d is not defined",
1495 GetMinorVersion());
1496 return;
1497 }break;
1498 case kvDefault:{
1499 Error("RecodeDetector","Major version = kvDefault, not supported");
1500 return;
1501 }break;
1502 case kvSPD02:{
1503 return RecodeDetectorvSPD02(mod,cpn0,cpn1,cpn2);
1504 }break;
1505 case kvSDD03:{
1506 return RecodeDetectorvSDD03(mod,cpn0,cpn1,cpn2);
1507 }break;
1508 case kvSSD03:{
1509 return RecodeDetectorvSSD03(mod,cpn0,cpn1,cpn2);
1510 }break;
1511 case kvITS04:{
1512 return RecodeDetectorvITS04(mod,cpn0,cpn1,cpn2);
1513 }break;
1514 case kvPPRcourseasymm:{
1515 return RecodeDetectorvPPRcourseasymm(mod,cpn0,cpn1,cpn2);
1516 }break;
1517 case kvPPRasymmFMD:{
1518 return RecodeDetectorvPPRasymmFMD(mod,cpn0,cpn1,cpn2);
1519 }break;
1520 case kv11:{
1521 return RecodeDetectorv11(mod,cpn0,cpn1,cpn2);
1522 }break;
1523 case kv11Hybrid:{
1524 return RecodeDetectorv11Hybrid(mod,cpn0,cpn1,cpn2);
1525 }break;
1526 default:{
1527 Error("RecodeDetector","Major version = %d, not supported",
1528 (Int_t)fMajorVersion);
1529 return;
1530 }break;
1531 } // end switch
1532 return;
1533}
1534//______________________________________________________________________
1535void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
1536 Int_t &lad,Int_t &det){
1537 // decode geometry into detector module number. There are two decoding
1538 // Scheams. Old which does not follow the ALICE coordinate system
1539 // requirements, and New which dose. Note, this use of layer ladder
1540 // and detector numbers are strictly for internal use of this
1541 // specific code. They do not represent the "standard" layer ladder
1542 // or detector numbering except in a very old and obsoleate sence.
1543 // Inputs:
1544 // Int_t mod The module number assoicated with this set
1545 // of copy numbers.
1546 // Output:
1547 // Int_t lay The layer number
1548 // Int_t lad The ladder number
1549 // Int_t det the dettector number
1550 // Return:
1551 // none.
1552
1553 // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
1554 // like them but I see not better way for the moment.
8f8273a4 1555 switch (fMajorVersion) {
012f0f4c 1556 case kvtest:{
1557 if(GetMinorVersion()==1)
1558 return DecodeDetectorLayersvPPRasymmFMD(mod,layer,lad,det);
1559 else if(GetMinorVersion()==2)
1560 return DecodeDetectorLayersvtest2(mod,layer,lad,det);
1561 Warning("DecodeDetectorLayers",
1562 "Geometry is kvtest minor version=%d is not defined",
1563 GetMinorVersion());
1564 return;
8f8273a4 1565 } break;
012f0f4c 1566 case kvDefault:{
1567 Error("DecodeDetectorLayers",
1568 "Major version = kvDefault, not supported");
1569 return;
1570 }break;
1571 case kvSPD02:{
1572 return DecodeDetectorLayersvSPD02(mod,layer,lad,det);
1573 }break;
1574 case kvSDD03:{
1575 return DecodeDetectorLayersvSDD03(mod,layer,lad,det);
1576 }break;
1577 case kvSSD03:{
1578 return DecodeDetectorLayersvSSD03(mod,layer,lad,det);
1579 }break;
1580 case kvITS04:{
1581 return DecodeDetectorLayersvITS04(mod,layer,lad,det);
1582 }break;
1583 case kvPPRcourseasymm:{
1584 return DecodeDetectorLayersvPPRcourseasymm(mod,layer,lad,det);
1585 }break;
1586 case kvPPRasymmFMD:{
1587 return DecodeDetectorLayersvPPRasymmFMD(mod,layer,lad,det);
1588 }break;
1589 case kv11:{
1590 return DecodeDetectorLayersv11(mod,layer,lad,det);
1591 }break;
1592 case kv11Hybrid:{
1593 return DecodeDetectorLayersv11Hybrid(mod,layer,lad,det);
1594 }break;
1595 default:{
1596 Error("DecodeDetectorLayers","Major version = %d, not supported",
1597 (Int_t)fMajorVersion);
1598 return;
1599 }break;
1600 } // end switch
1601 return;
1602}
1603//______________________________________________________________________
1604void AliITSInitGeometry::DecodeDetectorvSPD02(
1605 Int_t &mod,Int_t ncpn,Int_t cpy0,Int_t cpy1,Int_t cpy2) const {
1606 // decode geometry into detector module number
1607 // Inputs:
1608 // Int_t ncpn The Number of copies of this volume
1609 // Int_t cpy0 The lowest copy number
1610 // Int_t cpy1 The middle copy number
1611 // Int_t cpy2 the highest copy number
1612 // Output:
1613 // Int_t &mod The module number assoicated with this set
1614 // of copy numbers.
1615 // Return:
1616 // none.
1617
1618 // detector = ladder = 1
1619 if(ncpn==4 && cpy1>2) mod = cpy1; // layer = 1,2
1620 else mod = cpy1-1; // layer = 4,5
1621 if(ncpn==1) mod = 2; // layer=3
1622 cpy0 = cpy2;
1623 return;
1624}
1625//______________________________________________________________________
1626void AliITSInitGeometry::RecodeDetectorvSPD02(Int_t mod,Int_t &cpn0,
1627 Int_t &cpn1,Int_t &cpn2){
1628 // decode geometry into detector module number. There are two decoding
1629 // Scheams. Old which does not follow the ALICE coordinate system
1630 // requirements, and New which dose.
1631 // Inputs:
1632 // Int_t mod The module number assoicated with this set
1633 // of copy numbers.
1634 // Output:
1635 // Int_t cpn0 The lowest copy number
1636 // Int_t cpn1 The middle copy number
1637 // Int_t cpn2 the highest copy number
1638 // Return:
1639 // none.
1640
1641 cpn2 = 0;
1642 if(mod==2){
1643 cpn0 = 1;
1644 cpn1 = 1;
1645 return;
1646 } else if(mod<2){
1647 cpn0 = 1;
1648 cpn1 = mod+1;
1649 }else{
1650 cpn0 = 1;
1651 cpn1 = mod;
1652 } // end if
1653 return;
1654}
1655//______________________________________________________________________
1656void AliITSInitGeometry::DecodeDetectorLayersvSPD02(Int_t mod,Int_t &lay,
1657 Int_t &lad,Int_t &det){
1658 // decode geometry into detector module number. There are two decoding
1659 // Scheams. Old which does not follow the ALICE coordinate system
1660 // requirements, and New which dose. Note, this use of layer ladder
1661 // and detector numbers are strictly for internal use of this
1662 // specific code. They do not represent the "standard" layer ladder
1663 // or detector numbering except in a very old and obsoleate sence.
1664 // Inputs:
1665 // Int_t mod The module number assoicated with this set
1666 // of copy numbers.
1667 // Output:
1668 // Int_t lay The layer number
1669 // Int_t lad The ladder number
1670 // Int_t det the dettector number
1671 // Return:
1672 // none.
1673
1674 lay = mod+1;
1675 lad = det = 1;
1676 return;
1677}
1678//______________________________________________________________________
1679void AliITSInitGeometry::DecodeDetectorvSDD03(
1680 Int_t &mod,Int_t ncpys,Int_t cpy0,Int_t cpy1,Int_t cpy2) const {
1681 // decode geometry into detector module number. There are two decoding
1682 // Scheams. Old which does not follow the ALICE coordinate system
1683 // requirements, and New which dose.
1684 // Inputs:
1685 // Int_t ncpys The number of posible copies cpn1
1686 // Int_t cpy0 The lowest copy number
1687 // Int_t cpy1 The middle copy number
1688 // Int_t cpy2 the highest copy number
1689 // Output:
1690 // Int_t &mod The module number assoicated with this set
1691 // of copy numbers.
1692 // Return:
1693 // none.
1694
1695 if(ncpys==10){ // ITEL detectors
1696 if(cpy1>4) mod = cpy1+1;
1697 else mod = cpy1-1;
1698 }else{ // IDET detectors
1699 if(cpy1==1) mod = 4;
1700 else mod = 5;
1701 } // end if
1702 cpy0=cpy2;
1703 return;
1704}
1705//______________________________________________________________________
1706void AliITSInitGeometry::RecodeDetectorvSDD03(Int_t mod,Int_t &cpn0,
1707 Int_t &cpn1,Int_t &cpn2){
1708 // decode geometry into detector module number. There are two decoding
1709 // Scheams. Old which does not follow the ALICE coordinate system
1710 // requirements, and New which dose.
1711 // Inputs:
1712 // Int_t mod The module number assoicated with this set
1713 // of copy numbers.
1714 // Output:
1715 // Int_t cpn0 The lowest copy number
1716 // Int_t cpn1 The middle copy number
1717 // Int_t cpn2 the highest copy number
1718 // Return:
1719 // none.
1720
1721 cpn0 = 1;
1722 cpn2 = 0;
1723 if(mod<4) cpn1 = mod+1;
1724 else if(mod==4||mod==5) cpn1 = mod-3;
1725 else cpn1 = mod-1;
1726 return;
1727}
1728//______________________________________________________________________
1729void AliITSInitGeometry::DecodeDetectorLayersvSDD03(Int_t mod,Int_t &lay,
1730 Int_t &lad,Int_t &det){
1731 // decode geometry into detector module number. There are two decoding
1732 // Scheams. Old which does not follow the ALICE coordinate system
1733 // requirements, and New which dose. Note, this use of layer ladder
1734 // and detector numbers are strictly for internal use of this
1735 // specific code. They do not represent the "standard" layer ladder
1736 // or detector numbering except in a very old and obsoleate sence.
1737 // Inputs:
1738 // Int_t mod The module number assoicated with this set
1739 // of copy numbers.
1740 // Output:
1741 // Int_t lay The layer number
1742 // Int_t lad The ladder number
1743 // Int_t det the dettector number
1744 // Return:
1745 // none.
1746
1747 lad = det = 1;
1748 lay = mod+1;
1749 return;
1750}
1751//______________________________________________________________________
1752void AliITSInitGeometry::DecodeDetectorvSSD03(
1753 Int_t &mod,Int_t dtype,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
1754 // decode geometry into detector module number. There are two decoding
1755 // Scheams. Old which does not follow the ALICE coordinate system
1756 // requirements, and New which dose.
1757 // Inputs:
1758 // Int_t dtype The detector type 1=ITSA 2=IGAR 3=IFRA
1759 // Int_t cpn0 The lowest copy number
1760 // Int_t cpn1 The middle copy number
1761 // Int_t cpn2 the highest copy number
1762 // Output:
1763 // Int_t &mod The module number assoicated with this set
1764 // of copy numbers.
1765 // Return:
1766 // none.
1767
1768 if(dtype==2){mod=2; return;}
1769 if(dtype==3){mod=3; return;}
1770 mod = cpn0-1;
1771 if(cpn0==3) mod = 4;
1772 cpn1=cpn2;
1773 return;
1774}
1775//______________________________________________________________________
1776void AliITSInitGeometry::RecodeDetectorvSSD03(Int_t mod,Int_t &cpn0,
1777 Int_t &cpn1,Int_t &cpn2){
1778 // decode geometry into detector module number. There are two decoding
1779 // Scheams. Old which does not follow the ALICE coordinate system
1780 // requirements, and New which dose.
1781 // Inputs:
1782 // Int_t mod The module number assoicated with this set
1783 // of copy numbers.
1784 // Output:
1785 // Int_t cpn0 The lowest copy number
1786 // Int_t cpn1 The middle copy number
1787 // Int_t cpn2 the highest copy number
1788 // Return:
1789 // none.
1790
1791 cpn1=1;
1792 cpn2=0;
1793 if(mod<2) cpn0=mod+1;
1794 else if (mod==2||mod==3) cpn0=1;
1795 else cpn0 = 3;
1796 return;
1797}
1798//______________________________________________________________________
1799void AliITSInitGeometry::DecodeDetectorLayersvSSD03(Int_t mod,Int_t &lay,
1800 Int_t &lad,Int_t &det){
1801 // decode geometry into detector module number. There are two decoding
1802 // Scheams. Old which does not follow the ALICE coordinate system
1803 // requirements, and New which dose. Note, this use of layer ladder
1804 // and detector numbers are strictly for internal use of this
1805 // specific code. They do not represent the "standard" layer ladder
1806 // or detector numbering except in a very old and obsoleate sence.
1807 // Inputs:
1808 // Int_t mod The module number assoicated with this set
1809 // of copy numbers.
1810 // Output:
1811 // Int_t lay The layer number
1812 // Int_t lad The ladder number
1813 // Int_t det the dettector number
1814 // Return:
1815 // none.
1816
1817 lad = det = 1;
1818 lay = mod+1;
1819 return;
1820}
1821//______________________________________________________________________
1822void AliITSInitGeometry::DecodeDetectorvITS04(
1823 Int_t &mod,Int_t dtype,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
1824 // decode geometry into detector module number. There are two decoding
1825 // Scheams. Old which does not follow the ALICE coordinate system
1826 // requirements, and New which dose.
1827 // Inputs:
1828 // Int_t dtype The detector type 1=ITSA 2=IGAR 3=IFRA
1829 // Int_t cpn0 The lowest copy number
1830 // Int_t cpn1 The middle copy number
1831 // Int_t cpn2 the highest copy number
1832 // Output:
1833 // Int_t &mod The module number assoicated with this set
1834 // of copy numbers.
1835 // Return:
1836 // none.
1837
1838 mod = dtype-1;
1839 cpn0 = cpn1 = cpn2;
1840 return;
1841}
1842//______________________________________________________________________
1843void AliITSInitGeometry::RecodeDetectorvITS04(Int_t mod,Int_t &cpn0,
1844 Int_t &cpn1,Int_t &cpn2){
1845 // decode geometry into detector module number. There are two decoding
1846 // Scheams. Old which does not follow the ALICE coordinate system
1847 // requirements, and New which dose.
1848 // Inputs:
1849 // Int_t mod The module number assoicated with this set
1850 // of copy numbers.
1851 // Output:
1852 // Int_t cpn0 The lowest copy number
1853 // Int_t cpn1 The middle copy number
1854 // Int_t cpn2 the highest copy number
1855 // Return:
1856 // none.
1857
1858 cpn1 = cpn2 = 0;
1859 switch(mod){
1860 case 0:case 1:case 2:case 3:{
1861 cpn0 = mod+1;
1862 }break;
1863 case 4: case 5:{
1864 cpn0 = mod-3;
1865 }break;
1866 case 6:case 7:case 8:case 9:{
1867 cpn0 = mod-5;
1868 } break;
1869 default:
1870 cpn0 = 0;
1871 break;
1872 }// end switch
1873 return;
1874}
1875//______________________________________________________________________
1876void AliITSInitGeometry::DecodeDetectorLayersvITS04(Int_t mod,Int_t &lay,
1877 Int_t &lad,Int_t &det){
1878 // decode geometry into detector module number. There are two decoding
1879 // Scheams. Old which does not follow the ALICE coordinate system
1880 // requirements, and New which dose. Note, this use of layer ladder
1881 // and detector numbers are strictly for internal use of this
1882 // specific code. They do not represent the "standard" layer ladder
1883 // or detector numbering except in a very old and obsoleate sence.
1884 // Inputs:
1885 // Int_t mod The module number assoicated with this set
1886 // of copy numbers.
1887 // Output:
1888 // Int_t lay The layer number
1889 // Int_t lad The ladder number
1890 // Int_t det the dettector number
1891 // Return:
1892 // none.
1893
1894 lad = 1;
1895 switch(mod){
1896 case 0:case 1:case 2:case 3:{
1897 lay = mod/2 +1;
1898 det = mod%2 +1;
1899 }break;
1900 case 4: case 5:{
1901 lay = mod -1;
1902 }break;
1903 case 6:case 7:case 8:case 9:{
1904 lay = mod/2 +2;
1905 det = mod%2 +1;
1906 }break;
1907 default:
1908 lay = 0;
1909 det = 0;
1910 break;
1911 } // end switch
1912 return;
1913}
1914//______________________________________________________________________
1915void AliITSInitGeometry::DecodeDetectorvPPRasymmFMD(Int_t &mod,Int_t layer,Int_t cpn0,
6b0f3880 1916 Int_t cpn1,Int_t cpn2) const {
023ae34b 1917 // decode geometry into detector module number. There are two decoding
1918 // Scheams. Old which does not follow the ALICE coordinate system
1919 // requirements, and New which dose.
1920 // Inputs:
1921 // Int_t layer The ITS layer
1922 // Int_t cpn0 The lowest copy number
1923 // Int_t cpn1 The middle copy number
1924 // Int_t cpn2 the highest copy number
1925 // Output:
1926 // Int_t &mod The module number assoicated with this set
1927 // of copy numbers.
1928 // Return:
1929 // none.
6b0f3880 1930 const Int_t kDetPerLadderSPD[2]={2,4};
1931 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
1932 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
24e270ad 1933 Int_t lay=-1,lad=-1,det=-1,i;
023ae34b 1934
1935 if(fDecode){ // New decoding scheam
1936 switch (layer){
1937 case 1:{
1938 lay = layer;
1939 det = 5-cpn2;
1940 if(cpn0==4&&cpn1==1) lad=1;
1941 else if(cpn0==4&&cpn1==2) lad=20;
1942 else if(cpn0<4){
6b0f3880 1943 lad = 8-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 1944 }else{ // cpn0>4
6b0f3880 1945 lad = 28-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 1946 } // end if
1947 } break;
1948 case 2:{
1949 lay = layer;
1950 det = 5-cpn2;
1951 if(cpn0==4&&cpn1==1) lad=1;
1952 else if(cpn0<4){
6b0f3880 1953 lad = 14-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 1954 }else{ // cpn0>4
6b0f3880 1955 lad = 54-cpn1-kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 1956 } // end if
1957 } break;
1958 case 3:{
1959 lay = layer;
1960 if(cpn0<5) lad = 5-cpn0;
1961 else lad = 19-cpn0;
1962 det = 7-cpn1;
1963 } break;
1964 case 4:{
1965 lay = layer;
1966 if(cpn0<7) lad = 7-cpn0;
1967 else lad = 29-cpn0;
1968 det = 9-cpn1;
1969 } break;
1970 case 5:{
1971 lay = layer;
1972 if(cpn0<10) lad = 10-cpn0;
1973 else lad = 44-cpn0;
1974 det = 23-cpn1;
1975 } break;
1976 case 6:{
1977 lay = layer;
1978 if(cpn0<9) lad = 9-cpn0;
1979 else lad = 47-cpn0;
1980 det = 26-cpn1;
1981 } break;
1982 } // end switch
1983 mod = 0;
6b0f3880 1984 for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
1985 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
023ae34b 1986 return;
1987 } // end if
1988 // Old decoding scheam
1989 switch(layer){
1990 case 1: case 2:{
1991 lay = layer;
6b0f3880 1992 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
023ae34b 1993 det = cpn2;
1994 }break;
1995 case 3: case 4:{
1996 lay = layer;
1997 lad = cpn0;
1998 det = cpn1;
1999 }break;
2000 case 5: case 6:{
2001 lay = layer;
2002 lad = cpn0;
2003 det = cpn1;
2004 }break;
2005 default:{
2006 }break;
2007 } // end switch
2008 mod = 0;
6b0f3880 2009 for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
2010 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
023ae34b 2011 return;
2012}
2013//______________________________________________________________________
012f0f4c 2014void AliITSInitGeometry::RecodeDetectorvPPRasymmFMD(Int_t mod,Int_t &cpn0,
023ae34b 2015 Int_t &cpn1,Int_t &cpn2){
2016 // decode geometry into detector module number. There are two decoding
2017 // Scheams. Old which does not follow the ALICE coordinate system
2018 // requirements, and New which dose.
2019 // Inputs:
2020 // Int_t mod The module number assoicated with this set
2021 // of copy numbers.
2022 // Output:
2023 // Int_t cpn0 The lowest copy number
2024 // Int_t cpn1 The middle copy number
2025 // Int_t cpn2 the highest copy number
2026 // Return:
2027 // none.
6b0f3880 2028 const Int_t kITSgeoTreeCopys[6][3]= {{10, 2, 4},// lay=1
023ae34b 2029 {10, 4, 4},// lay=2
2030 {14, 6, 1},// lay=3
2031 {22, 8, 1},// lay=4
2032 {34,22, 1},// lay=5
2033 {38,25, 1}};//lay=6
6b0f3880 2034 const Int_t kDetPerLadderSPD[2]={2,4};
2035 // const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2036 // const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
023ae34b 2037 Int_t lay,lad,det;
2038
2039 cpn0 = cpn1 = cpn2 = 0;
2040 DecodeDetectorLayers(mod,lay,lad,det);
2041 if(fDecode){ // New decoding scheam
2042 switch (lay){
2043 case 1:{
2044 cpn2 = 5-det; // Detector 1-4
6b0f3880 2045 cpn1 = 1+(lad-1)%kDetPerLadderSPD[lay-1];
2046 cpn0 = 5-(lad+kDetPerLadderSPD[lay-1])/kDetPerLadderSPD[lay-1];
2047 if(mod>27) cpn0 = 15-(lad+kDetPerLadderSPD[lay-1])/
2048 kDetPerLadderSPD[lay-1];
023ae34b 2049 } break;
2050 case 2:{
2051 cpn2 = 5-det; // Detector 1-4
6b0f3880 2052 cpn1 = 4-(lad+2)%kDetPerLadderSPD[lay-1];
2053 cpn0 = 1+(14-cpn1-lad)/kDetPerLadderSPD[lay-1];
2054 if(mod>131) cpn0 = 1+(54-lad-cpn1)/kDetPerLadderSPD[lay-1];
023ae34b 2055 } break;
2056 case 3:{
2057 cpn2 = 1;
2058 if(lad<5) cpn0 = 5-lad;
2059 else cpn0 = 19-lad;
2060 cpn1 = 7-det;
2061 } break;
2062 case 4:{
2063 cpn2 = 1;
2064 if(lad<7) cpn0 = 7-lad;
2065 else cpn0 = 29-lad;
2066 cpn1 = 9-det;
2067 } break;
2068 case 5:{
2069 cpn2 = 1;
2070 if(lad<10) cpn0 = 10-lad;
2071 else cpn0 = 44-lad;
2072 cpn1 = 23-det;
2073 } break;
2074 case 6:{
2075 cpn2 = 1;
2076 if(lad<9) cpn0 = 9-lad;
2077 else cpn0 = 47-lad;
2078 cpn1 = 26-det;
2079 } break;
2080 default:{
2081 Error("RecodeDetector","New: mod=%d lay=%d not 1-6.");
2082 return;
2083 } break;
2084 } // end switch
2085 if(cpn0<1||cpn1<1||cpn2<1||
6b0f3880 2086 cpn0>kITSgeoTreeCopys[lay-1][0]||
2087 cpn1>kITSgeoTreeCopys[lay-1][1]||
2088 cpn2>kITSgeoTreeCopys[lay-1][2])
023ae34b 2089 Error("RecodeDetector",
2090 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
2091 cpn0,cpn1,cpn2,mod,lay,lad,det);
2092 return;
2093 } // end if
2094 // Old encoding
2095 switch (lay){
2096 case 1: case 2:{
2097 cpn2 = det; // Detector 1-4
6b0f3880 2098 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
2099 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
023ae34b 2100 } break;
2101 case 3: case 4: case 5 : case 6:{
2102 cpn2 = 1;
2103 cpn1 = det;
2104 cpn0 = lad;
2105 } break;
2106 default:{
2107 Error("RecodeDetector","Old: mod=%d lay=%d not 1-6.");
2108 return;
2109 } break;
2110 } // end switch
2111 if(cpn0<1||cpn1<1||cpn2<1||
6b0f3880 2112 cpn0>kITSgeoTreeCopys[lay-1][0]||
2113 cpn1>kITSgeoTreeCopys[lay-1][1]||
2114 cpn2>kITSgeoTreeCopys[lay-1][2])
023ae34b 2115 Error("RecodeDetector",
2116 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
2117 cpn0,cpn1,cpn2,mod,lay,lad,det);
2118 return;
2119}
2120//______________________________________________________________________
012f0f4c 2121void AliITSInitGeometry::DecodeDetectorLayersvPPRasymmFMD(Int_t mod,Int_t &lay,
023ae34b 2122 Int_t &lad,Int_t &det){
2123 // decode geometry into detector module number. There are two decoding
2124 // Scheams. Old which does not follow the ALICE coordinate system
2125 // requirements, and New which dose. Note, this use of layer ladder
2126 // and detector numbers are strictly for internal use of this
2127 // specific code. They do not represent the "standard" layer ladder
2128 // or detector numbering except in a very old and obsoleate sence.
2129 // Inputs:
2130 // Int_t mod The module number assoicated with this set
2131 // of copy numbers.
2132 // Output:
2133 // Int_t lay The layer number
2134 // Int_t lad The ladder number
2135 // Int_t det the dettector number
2136 // Return:
2137 // none.
6b0f3880 2138 // const Int_t kDetPerLadderSPD[2]={2,4};
2139 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2140 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
023ae34b 2141 Int_t mod2;
2142
2143 det = 0;
2144 lad = 0;
2145 lay = 0;
2146 mod2 = 0;
2147 do{
6b0f3880 2148 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
023ae34b 2149 lay++;
2150 }while(mod2<=mod); // end while
2151 if(lay>6||lay<1) Error("DecodeDetectorLayers","0<lay=%d>6",lay);
6b0f3880 2152 mod2 -= kLadPerLayer[lay-1]*kDetPerLadder[lay-1];
023ae34b 2153 do{
2154 lad++;
6b0f3880 2155 mod2 += kDetPerLadder[lay-1];
023ae34b 2156 }while(mod2<=mod); // end while
012f0f4c 2157 if(lad>kLadPerLayer[lay-1]||lad<1) Error("DecodeDetectorLayers",
2158 "lad=%d>kLadPerLayer[lay-1=%d]=%d mod=%d mod2=%d",lad,lay-1,
2159 kLadPerLayer[lay-1],mod,mod2);
2160 mod2 -= kDetPerLadder[lay-1];
2161 det = mod-mod2+1;
2162 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
2163 "det=%d>detPerLayer[lay-1=%d]=%d mod=%d mod2=%d lad=%d",det,
2164 lay-1,kDetPerLadder[lay-1],mod,mod2,lad);
2165 return;
2166}
2167//______________________________________________________________________
2168void AliITSInitGeometry::DecodeDetectorv11Hybrid(Int_t &mod,Int_t layer,Int_t cpn0,
2169 Int_t cpn1,Int_t cpn2) const {
2170 // decode geometry into detector module number
2171 // Inputs:
2172 // Int_t layer The ITS layer
2173 // Int_t cpn0 The lowest copy number
2174 // Int_t cpn1 The middle copy number
2175 // Int_t cpn2 the highest copy number
2176 // Output:
2177 // Int_t &mod The module number assoicated with this set
2178 // of copy numbers.
2179 // Return:
2180 // none.
75473741 2181 const Int_t kDetPerLadderSPD[2]={2,4};
2182 const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2183 const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
8f8273a4 2184 Int_t lad=-1,det=-1;
75473741 2185
2186 switch(layer) {
2187 case 1: case 2:{
8f8273a4 2188 if (SPDIsTGeoNative()) {
2189 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1)+1;
2190 det = cpn2 + 1;
2191 } else {
2192 lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
2193 det = cpn2;
2194 }
75473741 2195 } break;
2196 case 3: case 4:{
2197 if (SDDIsTGeoNative()) {
2198 lad = cpn0+1;
2199 det = cpn1+1;
2200 } else {
2201 lad = cpn0;
2202 det = cpn1;
2203 }
2204 } break;
2205 case 5: case 6:{
bf210566 2206 if (SSDIsTGeoNative()) {
2207 lad = cpn0+1;
2208 det = cpn1+1;
2209 } else {
2210 lad = cpn0;
2211 det = cpn1;
2212 }
75473741 2213 } break;
2214 default:{
2215 } break;
2216 } // end switch
2217 mod = 0;
8f8273a4 2218 for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
75473741 2219 mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
2220 return;
012f0f4c 2221}
8f8273a4 2222
2223/*
012f0f4c 2224//______________________________________________________________________
2225void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
2226 Int_t &cpn1,Int_t &cpn2) {
2227 // decode geometry into detector module number. There are two decoding
2228 // Scheams. Old which does not follow the ALICE coordinate system
2229 // requirements, and New which dose.
2230 // Inputs:
2231 // Int_t mod The module number assoicated with this set
2232 // of copy numbers.
2233 // Output:
2234 // Int_t cpn0 The lowest copy number
2235 // Int_t cpn1 The middle copy number
2236 // Int_t cpn2 the highest copy number
2237 // Return:
2238 // none.
2239 const Int_t kITSgeoTreeCopys[6][3]= {{10, 2, 4},// lay=1
2240 {10, 4, 4},// lay=2
2241 {14, 6, 1},// lay=3
2242 {22, 8, 1},// lay=4
2243 {34,22, 1},// lay=5
2244 {38,25, 1}};//lay=6
2245 const Int_t kDetPerLadderSPD[2]={2,4};
012f0f4c 2246 Int_t lay,lad,det;
2247
2248 cpn0 = cpn1 = cpn2 = 0;
8f8273a4 2249 DecodeDetectorLayersv11Hybrid(mod,lay,lad,det);
012f0f4c 2250 // Old encoding
2251 switch (lay){
2252 case 1: case 2:{
2253 cpn2 = det; // Detector 1-4
2254 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
2255 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
2256 } break;
2257 case 3: case 4: case 5 : case 6:{
2258 cpn2 = 1;
2259 cpn1 = det;
2260 cpn0 = lad;
2261 } break;
2262 default:{
2263 Error("RecodeDetector","Old: mod=%d lay=%d not 1-6.");
2264 return;
2265 } break;
2266 } // end switch
2267 if(cpn0<1||cpn1<1||cpn2<1||
2268 cpn0>kITSgeoTreeCopys[lay-1][0]||
2269 cpn1>kITSgeoTreeCopys[lay-1][1]||
2270 cpn2>kITSgeoTreeCopys[lay-1][2])
2271 Error("RecodeDetector",
2272 "cpn0=%d cpn1=%d cpn2=%d mod=%d lay=%d lad=%d det=%d",
2273 cpn0,cpn1,cpn2,mod,lay,lad,det);
2274 return;
2275}
8f8273a4 2276*/
2277
012f0f4c 2278
8f8273a4 2279//______________________________________________________________________
2280void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
2281 Int_t &cpn1,Int_t &cpn2) {
2282 // decode geometry into detector module number. There are two decoding
2283 // Scheams. Old which does not follow the ALICE coordinate system
2284 // requirements, and New which does.
012f0f4c 2285 // Inputs:
2286 // Int_t mod The module number assoicated with this set
2287 // of copy numbers.
2288 // Output:
8f8273a4 2289 // Int_t cpn0 The lowest copy number (SPD sector or SDD/SSD ladder)
2290 // Int_t cpn1 The middle copy number (SPD stave or SDD/SSD module)
2291 // Int_t cpn2 the highest copy number (SPD ladder or 1 for SDD/SSD)
012f0f4c 2292 // Return:
2293 // none.
2294
8f8273a4 2295 const Int_t kDetPerLadderSPD[2]={2,4};
2296 Int_t lay,lad,det;
2297 DecodeDetectorLayersv11Hybrid(mod,lay,lad,det);
2298
2299 if (lay<3) { // SPD
2300 cpn2 = det; // Detector 1-4
2301 cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
2302 cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
2303 if (SPDIsTGeoNative()) {
2304 cpn2--;
2305 cpn1--;
2306 }
2307 } else { // SDD and SSD
2308 cpn2 = 1;
2309 cpn1 = det;
2310 cpn0 = lad;
2311 if (lay<5) { // SDD
2312 if (SDDIsTGeoNative()) {
2313 cpn1--;
2314 cpn0--;
2315 }
2316 } else { //SSD
2317 if (SSDIsTGeoNative()) {
2318 cpn1--;
2319 cpn0--;
2320 }
2321 }
2322 }
2323}
012f0f4c 2324
8f8273a4 2325
2326
2327
2328// //______________________________________________________________________
2329// void AliITSInitGeometry::DecodeDetectorLayersv11Hybrid(Int_t mod,Int_t &lay,
2330// Int_t &lad,Int_t &det) {
2331
2332// // decode module number into detector indices for v11Hybrid
2333// // Inputs:
2334// // Int_t mod The module number associated with this set
2335// // of copy numbers.
2336// // Output:
2337// // Int_t lay The layer number
2338// // Int_t lad The ladder number
2339// // Int_t det the dettector number
2340// // Return:
2341// // none.
2342
2343// const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
2344// const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
2345// Int_t mod2 = 0;
2346// det = 0;
2347// lad = 0;
2348// lay = 0;
2349
2350// do{
2351// mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
2352// lay++;
2353// } while(mod2<=mod); // end while
2354// if(lay>6||lay<1) Error("DecodeDetectorLayers","0<lay=%d>6",lay);
2355// mod2 -= kLadPerLayer[lay-1]*kDetPerLadder[lay-1];
2356// do{
2357// lad++;
2358// mod2 += kDetPerLadder[lay-1];
2359// } while(mod2<=mod); // end while
2360// if(lad>kLadPerLayer[lay-1]||lad<1) Error("DecodeDetectorLayers",
2361// "lad=%d>kLadPerLayer[lay-1=%d]=%d mod=%d mod2=%d",lad,lay-1,
2362// kLadPerLayer[lay-1],mod,mod2);
2363// mod2 -= kDetPerLadder[lay-1];
2364// det = mod-mod2+1;
2365// if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
2366// "det=%d>detPerLayer[lay-1=%d]=%d mod=%d mod2=%d lad=%d",det,
2367// lay-1,kDetPerLadder[lay-1],mod,mod2,lad);
2368// return;
2369// }
2370
2371//______________________________________________________________________
2372void AliITSInitGeometry::DecodeDetectorLayersv11Hybrid(Int_t mod,Int_t &lay,
2373 Int_t &lad,Int_t &det) {
2374
2375 // decode module number into detector indices for v11Hybrid
2376 // mod starts from 0
2377 // lay, lad, det start from 1
2378
2379 // Inputs:
2380 // Int_t mod The module number associated with this set
2381 // of copy numbers.
2382 // Output:
2383 // Int_t lay The layer number
2384 // Int_t lad The ladder number
2385 // Int_t det the dettector number
2386
2387 const Int_t kDetPerLadder[6] = {4,4,6,8,22,25};
2388 const Int_t kLadPerLayer[6] = {20,40,14,22,34,38};
2389
2390 Int_t mod2 = 0;
2391 lay = 0;
2392
2393 do {
2394 mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
2395 lay++;
2396 } while(mod2<=mod); // end while
2397 if(lay>6) Error("DecodeDetectorLayers","lay=%d>6",lay);
2398
2399 mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod;
2400 lad = mod2/kDetPerLadder[lay-1];
2401
2402 if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers",
2403 "lad=%d not in the correct range",lad);
2404 det = (mod2 - lad*kDetPerLadder[lay-1])+1;
2405 if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
2406 "det=%d not in the correct range",det);
2407 lad++;
023ae34b 2408}
2409
012f0f4c 2410//______________________________________________________________________
2411Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,
2412 AliITSVersion_t maj,Int_t min,
2413 const Char_t *cvsDate,const Char_t *cvsRevision)const{
2414 // fills the string str with the major and minor version number
2415 // Inputs:
2416 // Char_t *str The character string to hold the major
2417 // and minor version numbers in
2418 // Int_t length The maximum number of characters which
2419 // can be accomidated by this string.
2420 // str[length-1] must exist and will be set to zero
2421 // AliITSVersion_t maj The major number
2422 // Int_t min The minor number
2423 // Char_t *cvsDate The date string from cvs
2424 // Char_t *cvsRevision The Revision string from cvs
2425 // Outputs:
2426 // Char_t *str The character string holding the major and minor
2427 // version numbers. str[length-1] must exist
2428 // and will be set to zero
2429 // Return:
2430 // kTRUE if no errors
2431 Int_t i,n,cvsDateLength,cvsRevisionLength;
2432
2433 cvsDateLength = (Int_t)strlen(cvsDate);
2434 cvsRevisionLength = (Int_t)strlen(cvsRevision);
2435 i = (Int_t)maj;
2436 n = 50+(Int_t)(TMath::Log10(TMath::Abs((Double_t)i)))+1+
2437 (Int_t)(TMath::Log10(TMath::Abs((Double_t)min)))+1
2438 +cvsDateLength-6+cvsRevisionLength-10;
2439 if(GetDebug()>1) printf("AliITSInitGeometry::WriteVersionString:"
2440 "length=%d major=%d minor=%d cvsDate=%s[%d] "
2441 "cvsRevision=%s[%d] n=%d\n",length,i,min,cvsDate,
2442 cvsDateLength,cvsRevision,cvsRevisionLength,n);
2443 if(i<0) n++;
2444 if(min<0) n++;
2445 if(length<n){// not enough space to write in output string.
2446 Warning("WriteVersionString","Output string not long enough "
2447 "lenght=%d must be at least %d long\n",length,n);
2448 return kFALSE;
2449 } // end if length<n
2450 char *cvsrevision = new char[cvsRevisionLength-10];
2451 char *cvsdate = new char[cvsDateLength-6];
2452 for(i=0;i<cvsRevisionLength-10;i++)
2453 if(10+i<cvsRevisionLength-1)
2454 cvsrevision[i] = cvsRevision[10+i]; else cvsrevision[i] = 0;
2455 for(i=0;i<cvsDateLength-6;i++) if(6+i<cvsDateLength-1)
2456 cvsdate[i] = cvsDate[6+i]; else cvsdate[i] = 0;
2457 for(i=0;i<length;i++) str[i] = 0; // zero it out for now.
2458 i = (Int_t)maj;
2459 sprintf(str,"Major Version= %d Minor Version= %d Revision: %s Date: %s",
2460 i,min,cvsrevision,cvsdate);
2461 if(GetDebug()>1)printf("AliITSInitGeometry::WriteVersionString: "
2462 "n=%d str=%s revision[%zu] date[%zu]\n",
2463 n,str,strlen(cvsrevision),strlen(cvsdate));
2464 delete[] cvsrevision;
2465 delete[] cvsdate;
2466 return kTRUE;
2467}
2468//______________________________________________________________________
2469Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,Int_t length,
2470 AliITSVersion_t &maj,Int_t &min,
2471 TDatime &dt)const{
2472 // fills the string str with the major and minor version number
2473 // Inputs:
2474 // Char_t *str The character string to holding the major and minor
2475 // version numbers in
2476 // Int_t length The maximum number of characters which can be
2477 // accomidated by this string. str[length-1] must exist
2478 // Outputs:
2479 // Char_t *str The character string holding the major and minor
2480 // version numbers unchanged. str[length-1] must exist.
2481 // AliITSVersion_t maj The major number
2482 // Int_t min The minor number
2483 // TDatime dt The date and time of the cvs commit
2484 // Return:
2485 // kTRUE if no errors
2486 Bool_t ok;
2487 Char_t cvsRevision[10],cvsDate[11],cvsTime[9];
2488 Int_t i,m,n=strlen(str),year,month,day,hours,minuits,seconds;
2489
2490 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString:"
2491 "str=%s length=%d\n",
2492 str,length);
2493 if(n<35) return kFALSE; // not enough space for numbers
2494 m = sscanf(str,"Major Version= %d Minor Version= %d Revision: %s "
2495 "Date: %s %s",&i,&min,cvsRevision,cvsDate,cvsTime);
2496 ok = m==5;
2497 if(!ok) return !ok;
2498 m = sscanf(cvsDate,"%d/%d/%d",&year,&month,&day);
2499 ok = m==3;
2500 if(!ok) return !ok;
2501 m = sscanf(cvsTime,"%d:%d:%d",&hours,&minuits,&seconds);
2502 ok = m==3;
2503 if(!ok) return !ok;
2504 dt.Set(year,month,day,hours,minuits,seconds);
2505 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: i=%d min=%d "
2506 "cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
2507 i,min,cvsRevision,cvsDate,cvsTime,m);
2508 if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: year=%d"
2509 " month=%d day=%d hours=%d minuits=%d seconds=%d\n",
2510 year,month,day,hours,minuits,seconds);
2511 switch (i){
2512 case kvITS04:{
2513 maj = kvITS04;
2514 } break;
2515 case kvSPD02:{
2516 maj = kvSPD02;
2517 } break;
2518 case kvSDD03:{
2519 maj = kvSDD03;
2520 } break;
2521 case kvSSD03:{
2522 maj = kvSSD03;
2523 } break;
2524 case kvPPRasymmFMD:{
2525 maj = kvPPRasymmFMD;
2526 } break;
2527 case kv11:{
2528 maj = kv11;
2529 } break;
2530 case kv11Hybrid:{
2531 maj = kv11Hybrid;
2532 } break;
2533 default:{
2534 maj = kvDefault;
2535 } break;
2536 } // end switch
2537 return ok;
2538}