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