Line data Source code
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 : */
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 :
26 : #include <TArrayD.h>
27 : #include <TArrayF.h>
28 : #include <TStopwatch.h>
29 : #include <TGeoManager.h>
30 : #include <TGeoMatrix.h>
31 : #include <TGeoVolume.h>
32 : #include <TGeoShape.h>
33 : #include <TGeoBBox.h>
34 : #include <TGeoTrd1.h>
35 : #include <TGeoTrd2.h>
36 : #include <TGeoArb8.h>
37 : #include <TGeoTube.h>
38 : #include <TGeoCone.h>
39 : #include <TGeoSphere.h>
40 : #include <TGeoPara.h>
41 : #include <TGeoPgon.h>
42 : #include <TGeoPcon.h>
43 : #include <TGeoEltu.h>
44 : #include <TGeoHype.h>
45 : #include <TMath.h>
46 :
47 : #include "AliLog.h"
48 : #include "AliITSsegmentationSPD.h"
49 : #include "AliITSsegmentationSDD.h"
50 : #include "AliITSsegmentationSSD.h"
51 : #include "AliITSInitGeometry.h"
52 : #include <TDatime.h>
53 :
54 118 : ClassImp(AliITSInitGeometry)
55 :
56 : //______________________________________________________________________
57 : AliITSInitGeometry::AliITSInitGeometry():
58 7 : TObject(), // Base Class
59 7 : fName(0), // Geometry name
60 7 : fMajorVersion(kvDefault), // Major versin number
61 7 : fTiming(kFALSE), // Flag to start inilization timing
62 7 : fSegGeom(kFALSE), // Flag to switch between the old use of
63 : // AliITSgeomS?D class, or AliITSsegmentation
64 : // class in fShape of AliITSgeom class.
65 7 : fDecode(kFALSE), // Flag for new/old decoding
66 42 : fDebug(0){ // Debug flag
67 : // Default Creator
68 : // Inputs:
69 : // none.
70 : // Outputs:
71 : // none.
72 : // Return:
73 : // A default inilized AliITSInitGeometry object
74 :
75 7 : fName = "Undefined";
76 14 : }
77 : //______________________________________________________________________
78 : AliITSInitGeometry::AliITSInitGeometry(AliITSVersion_t version):
79 13 : TObject(), // Base Class
80 13 : fName(0), // Geometry name
81 13 : fMajorVersion(version), // Major version number
82 13 : fTiming(kFALSE), // Flag to start inilization timing
83 13 : fSegGeom(kFALSE), // Flag to switch between the old use of
84 : // AliITSgeomS?D class, or AliITSsegmentation
85 : // class in fShape of AliITSgeom class.
86 13 : fDecode(kFALSE), // Flag for new/old decoding
87 78 : fDebug(0){ // Debug flag
88 : // Default Creator
89 : // Inputs:
90 : // none.
91 : // Outputs:
92 : // none.
93 : // Return:
94 : // A default inilized AliITSInitGeometry object
95 :
96 13 : switch (version) {
97 : case kv11:
98 13 : fName="AliITSv11";
99 : break;
100 : case kvDefault:
101 : default:
102 0 : AliFatal(Form("Undefined geometry: fMajorVersion=%d, ",(Int_t)fMajorVersion));
103 0 : fName = "Undefined";
104 : break;
105 : } // switch
106 26 : }
107 : //______________________________________________________________________
108 : AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(){
109 : // Creates and Initilizes the geometry transformation class AliITSgeom
110 : // to values appropreate to this specific geometry. Now that
111 : // the segmentation is part of AliITSgeom, the detector
112 : // segmentations are also defined here.
113 : // Inputs:
114 : // none.
115 : // Outputs:
116 : // none.
117 : // Return:
118 : // A pointer to a new properly inilized AliITSgeom class. If
119 : // pointer = 0 then failed to init.
120 :
121 :
122 10 : AliITSVersion_t version = kvDefault;
123 5 : TDatime datetime;
124 5 : TGeoVolume *itsV = gGeoManager->GetVolume("ITSV");
125 5 : if(!itsV){
126 0 : AliError("Can't find ITS volume ITSV, exiting - nothing done!");
127 0 : return 0;
128 : }// end if
129 5 : const Char_t *title = itsV->GetTitle();
130 10 : if(!ReadVersionString(title,version))
131 0 : Warning("UpdateInternalGeometry","Can't read title=%s\n",title);
132 5 : SetTiming(kFALSE);
133 5 : SetSegGeom(kFALSE);
134 5 : SetDecoding(kFALSE);
135 5 : AliITSgeom *geom = CreateAliITSgeom(version);
136 25 : AliDebug(1,"AliITSgeom object has been initialized from TGeo\n");
137 : return geom;
138 5 : }
139 : //______________________________________________________________________
140 : AliITSgeom* AliITSInitGeometry::CreateAliITSgeom(Int_t major){
141 : // Creates and Initilizes the geometry transformation class AliITSgeom
142 : // to values appropreate to this specific geometry. Now that
143 : // the segmentation is part of AliITSgeom, the detector
144 : // segmentations are also defined here.
145 : // Inputs:
146 : // Int_t major major version, see AliITSVersion_t
147 : //
148 : // Outputs:
149 : // none.
150 : // Return:
151 : // A pointer to a new properly inilized AliITSgeom class. If
152 : // pointer = 0 then failed to init.
153 :
154 14 : switch(major){
155 : case kv11:
156 7 : SetGeometryName("AliITSv11");
157 7 : SetVersion(kv11);
158 7 : break;
159 : case kvDefault:
160 : default:
161 0 : SetGeometryName("Undefined");
162 0 : SetVersion(kvDefault);
163 0 : break;
164 : } // end switch
165 7 : AliITSgeom *geom = new AliITSgeom();
166 7 : if(!InitAliITSgeom(geom)){ // Error initilization failed
167 0 : delete geom;
168 : geom = 0;
169 0 : } // end if
170 7 : return geom;
171 0 : }
172 : //______________________________________________________________________
173 : Bool_t AliITSInitGeometry::InitAliITSgeom(AliITSgeom *geom){
174 : // Initilizes the geometry transformation class AliITSgeom
175 : // to values appropreate to this specific geometry. Now that
176 : // the segmentation is part of AliITSgeom, the detector
177 : // segmentations are also defined here.
178 : // Inputs:
179 : // AliITSgeom *geom A pointer to the AliITSgeom class
180 : // Outputs:
181 : // AliITSgeom *geom This pointer recreated and properly inilized.
182 : // Return:
183 : // none.
184 :
185 14 : if(!gGeoManager){
186 0 : AliFatal("The geometry manager has not been initialized (e.g. "
187 : "TGeoManager::Import(\"geometry.root\")should be "
188 : "called in advance) - exit forced");
189 0 : return kFALSE;
190 : } // end if
191 7 : switch(fMajorVersion) {
192 : case kv11: {
193 7 : return InitAliITSgeomV11(geom);
194 : } break; // end case
195 : case kvDefault: default: {
196 0 : AliFatal("Undefined geometry");
197 0 : return kFALSE;
198 : } break; // end case
199 : } // end switch
200 : return kFALSE;
201 7 : }
202 : //______________________________________________________________________
203 : void AliITSInitGeometry::TransposeTGeoHMatrix(TGeoHMatrix *m)const{
204 : // Transpose the rotation matrix part of a TGeoHMatrix. This
205 : // is needed because TGeo stores the transpose of the rotation
206 : // matrix as compared to what AliITSgeomMatrix uses (and Geant3).
207 : // Inputs:
208 : // TGeoHMatrix *m The matrix to be transposed
209 : // Outputs:
210 : // TGEoHMatrix *m The transposed matrix
211 : // Return:
212 : // none.
213 : Int_t i;
214 30772 : Double_t r[9];
215 :
216 15386 : if(m==0) return; // no matrix to transpose.
217 123088 : for(i=0;i<9;i += 4) r[i] = m->GetRotationMatrix()[i]; // diagonals
218 15386 : r[1] = m->GetRotationMatrix()[3];
219 15386 : r[2] = m->GetRotationMatrix()[6];
220 15386 : r[3] = m->GetRotationMatrix()[1];
221 15386 : r[5] = m->GetRotationMatrix()[7];
222 15386 : r[6] = m->GetRotationMatrix()[2];
223 15386 : r[7] = m->GetRotationMatrix()[5];
224 15386 : m->SetRotation(r);
225 15386 : return;
226 15386 : }
227 :
228 :
229 : //______________________________________________________________________
230 : Bool_t AliITSInitGeometry::InitAliITSgeomV11(AliITSgeom *geom){
231 : // Initilizes the geometry transformation class AliITSgeom
232 : // Now that the segmentation is part of AliITSgeom, the detector
233 : // segmentations are also defined here.
234 : //
235 : // Inputs:
236 : // AliITSgeom *geom A pointer to the AliITSgeom class
237 : // Outputs:
238 : // AliITSgeom *geom This pointer recreated and properly inilized.
239 : // LG
240 :
241 : const Int_t kItype = 0; // Type of transformation defined 0=> Geant
242 : const Int_t klayers = 6; // number of layers in the ITS
243 : const Int_t kladders[klayers] = {20,40,14,22,34,38}; // Number of ladders
244 : const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
245 : const AliITSDetector kIdet[6] = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
246 14 : const TString kPathbase = "/ALIC_1/ITSV_1/";
247 :
248 : const char *pathSPDsens1, *pathSPDsens2;
249 : pathSPDsens1="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay1-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay1-Ladder_%d/ITSSPDlay1-sensor_1";
250 : pathSPDsens2="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay2-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay2-Ladder_%d/ITSSPDlay2-sensor_1";
251 :
252 : const char *pathSDDsens1, *pathSDDsens2;
253 : pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
254 : pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
255 :
256 : const char *pathSSDsens1, *pathSSDsens2;
257 : pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSssdSensor5_%d/ITSssdSensitivL5_1";
258 : pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSssdSensor6_%d/ITSssdSensitivL6_1";
259 :
260 42 : const TString kNames[klayers] = {
261 7 : pathSPDsens1, // lay=1
262 7 : pathSPDsens2, // lay=2
263 7 : pathSDDsens1, // lay=3
264 7 : pathSDDsens2, // lay=4
265 7 : pathSSDsens1, // lay=5
266 7 : pathSSDsens2};// Lay=6
267 :
268 7 : Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1;
269 7 : Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
270 7 : TArrayD shapePar;
271 14 : TString path, shapeName;
272 7 : TGeoHMatrix matrix;
273 7 : Bool_t initSeg[3]={kFALSE, kFALSE, kFALSE};
274 : TStopwatch *time = 0x0;
275 7 : if(fTiming) time = new TStopwatch();
276 :
277 7 : if(fTiming) time->Start();
278 98 : for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
279 7 : geom->Init(kItype,klayers,kladders,kdetectors,nmods);
280 :
281 30786 : for(mod=0; mod<nmods; mod++) {
282 :
283 15386 : DecodeDetectorLayers(mod,lay,lad,det);
284 15386 : geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
285 15386 : RecodeDetector(mod,cpn0,cpn1,cpn2);
286 :
287 15386 : if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
288 2520 : if (det<3) cpnHS = 0; else cpnHS = 1;
289 5040 : path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2);
290 : } else {
291 41118 : path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2);
292 : };
293 :
294 30772 : geom->GetGeomMatrix(mod)->SetPath(path);
295 61544 : GetTransformation(path.Data(),matrix);
296 15386 : geom->SetTrans(mod,matrix.GetTranslation());
297 15386 : TransposeTGeoHMatrix(&matrix); //Transpose TGeo's rotation matrixes
298 15386 : geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
299 15386 : if(initSeg[kIdet[lay-1]]) continue;
300 15386 : GetShape(path,shapeName,shapePar);
301 30772 : if(shapeName.CompareTo("BOX")){
302 0 : Error("InitITSgeom","Geometry changed without proper code update"
303 : "or error in reading geometry. Shape is not BOX.");
304 0 : return kFALSE;
305 : } // end if
306 : } // end for module
307 :
308 7 : if(fTiming){
309 0 : time->Stop();
310 0 : time->Print();
311 0 : delete time;
312 : } // end if
313 7 : return kTRUE;
314 56 : }
315 :
316 : //_______________________________________________________________________
317 : Bool_t AliITSInitGeometry::GetTransformation(const TString &volumePath,
318 : TGeoHMatrix &mat){
319 : // Returns the Transformation matrix between the volume specified
320 : // by the path volumePath and the Top or mater volume. The format
321 : // of the path volumePath is as follows (assuming ALIC is the Top volume)
322 : // "/ALIC_1/DDIP_1/S05I_2/S05H_1/S05G_3". Here ALIC is the top most
323 : // or master volume which has only 1 instance of. Of all of the daughter
324 : // volumes of ALICE, DDIP volume copy #1 is indicated. Similarly for
325 : // the daughter volume of DDIP is S05I copy #2 and so on.
326 : // Inputs:
327 : // TString& volumePath The volume path to the specific volume
328 : // for which you want the matrix. Volume name
329 : // hierarchy is separated by "/" while the
330 : // copy number is appended using a "_".
331 : // Outputs:
332 : // TGeoHMatrix &mat A matrix with its values set to those
333 : // appropriate to the Local to Master transformation
334 : // Return:
335 : // A logical value if kFALSE then an error occurred and no change to
336 : // mat was made.
337 :
338 : // We have to preserve the modeler state
339 :
340 : // Preserve the modeler state.
341 30772 : gGeoManager->PushPath();
342 15386 : if (!gGeoManager->cd(volumePath.Data())) {
343 0 : gGeoManager->PopPath();
344 0 : Error("GetTransformation","Error in cd-ing to %s",volumePath.Data());
345 0 : return kFALSE;
346 : } // end if !gGeoManager
347 15386 : mat = *gGeoManager->GetCurrentMatrix();
348 : // Retstore the modeler state.
349 15386 : gGeoManager->PopPath();
350 15386 : return kTRUE;
351 15386 : }
352 : //______________________________________________________________________
353 : Bool_t AliITSInitGeometry::GetShape(const TString &volumePath,
354 : TString &shapeType,TArrayD &par){
355 : // Returns the shape and its parameters for the volume specified
356 : // by volumeName.
357 : // Inputs:
358 : // TString& volumeName The volume name
359 : // Outputs:
360 : // TString &shapeType Shape type
361 : // TArrayD &par A TArrayD of parameters with all of the
362 : // parameters of the specified shape.
363 : // Return:
364 : // A logical indicating whether there was an error in getting this
365 : // information
366 : Int_t npar;
367 30772 : gGeoManager->PushPath();
368 15386 : if (!gGeoManager->cd(volumePath.Data())) {
369 0 : gGeoManager->PopPath();
370 0 : return kFALSE;
371 : }
372 15386 : TGeoVolume * vol = gGeoManager->GetCurrentVolume();
373 15386 : gGeoManager->PopPath();
374 15386 : if (!vol) return kFALSE;
375 15386 : TGeoShape *shape = vol->GetShape();
376 15386 : TClass *classType = shape->IsA();
377 15386 : if (classType==TGeoBBox::Class()) {
378 15386 : shapeType = "BOX";
379 : npar = 3;
380 15386 : par.Set(npar);
381 15386 : TGeoBBox *box = (TGeoBBox*)shape;
382 15386 : par.AddAt(box->GetDX(),0);
383 15386 : par.AddAt(box->GetDY(),1);
384 15386 : par.AddAt(box->GetDZ(),2);
385 : return kTRUE;
386 : } // end if
387 0 : if (classType==TGeoTrd1::Class()) {
388 0 : shapeType = "TRD1";
389 : npar = 4;
390 0 : par.Set(npar);
391 0 : TGeoTrd1 *trd1 = (TGeoTrd1*)shape;
392 0 : par.AddAt(trd1->GetDx1(),0);
393 0 : par.AddAt(trd1->GetDx2(),1);
394 0 : par.AddAt(trd1->GetDy(), 2);
395 0 : par.AddAt(trd1->GetDz(), 3);
396 : return kTRUE;
397 : } // end if
398 0 : if (classType==TGeoTrd2::Class()) {
399 0 : shapeType = "TRD2";
400 : npar = 5;
401 0 : par.Set(npar);
402 0 : TGeoTrd2 *trd2 = (TGeoTrd2*)shape;
403 0 : par.AddAt(trd2->GetDx1(),0);
404 0 : par.AddAt(trd2->GetDx2(),1);
405 0 : par.AddAt(trd2->GetDy1(),2);
406 0 : par.AddAt(trd2->GetDy2(),3);
407 0 : par.AddAt(trd2->GetDz(), 4);
408 : return kTRUE;
409 : } // end if
410 0 : if (classType==TGeoTrap::Class()) {
411 0 : shapeType = "TRAP";
412 : npar = 11;
413 0 : par.Set(npar);
414 0 : TGeoTrap *trap = (TGeoTrap*)shape;
415 0 : Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
416 0 : par.AddAt(trap->GetDz(),0);
417 0 : par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
418 0 : par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
419 0 : par.AddAt(trap->GetH1(),3);
420 0 : par.AddAt(trap->GetBl1(),4);
421 0 : par.AddAt(trap->GetTl1(),5);
422 0 : par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
423 0 : par.AddAt(trap->GetH2(),7);
424 0 : par.AddAt(trap->GetBl2(),8);
425 0 : par.AddAt(trap->GetTl2(),9);
426 0 : par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
427 : return kTRUE;
428 : } // end if
429 0 : if (classType==TGeoTube::Class()) {
430 0 : shapeType = "TUBE";
431 : npar = 3;
432 0 : par.Set(npar);
433 0 : TGeoTube *tube = (TGeoTube*)shape;
434 0 : par.AddAt(tube->GetRmin(),0);
435 0 : par.AddAt(tube->GetRmax(),1);
436 0 : par.AddAt(tube->GetDz(),2);
437 : return kTRUE;
438 : } // end if
439 0 : if (classType==TGeoTubeSeg::Class()) {
440 0 : shapeType = "TUBS";
441 : npar = 5;
442 0 : par.Set(npar);
443 0 : TGeoTubeSeg *tubs = (TGeoTubeSeg*)shape;
444 0 : par.AddAt(tubs->GetRmin(),0);
445 0 : par.AddAt(tubs->GetRmax(),1);
446 0 : par.AddAt(tubs->GetDz(),2);
447 0 : par.AddAt(tubs->GetPhi1(),3);
448 0 : par.AddAt(tubs->GetPhi2(),4);
449 : return kTRUE;
450 : } // end if
451 0 : if (classType==TGeoCone::Class()) {
452 0 : shapeType = "CONE";
453 : npar = 5;
454 0 : par.Set(npar);
455 0 : TGeoCone *cone = (TGeoCone*)shape;
456 0 : par.AddAt(cone->GetDz(),0);
457 0 : par.AddAt(cone->GetRmin1(),1);
458 0 : par.AddAt(cone->GetRmax1(),2);
459 0 : par.AddAt(cone->GetRmin2(),3);
460 0 : par.AddAt(cone->GetRmax2(),4);
461 : return kTRUE;
462 : } // end if
463 0 : if (classType==TGeoConeSeg::Class()) {
464 0 : shapeType = "CONS";
465 : npar = 7;
466 0 : par.Set(npar);
467 0 : TGeoConeSeg *cons = (TGeoConeSeg*)shape;
468 0 : par.AddAt(cons->GetDz(),0);
469 0 : par.AddAt(cons->GetRmin1(),1);
470 0 : par.AddAt(cons->GetRmax1(),2);
471 0 : par.AddAt(cons->GetRmin2(),3);
472 0 : par.AddAt(cons->GetRmax2(),4);
473 0 : par.AddAt(cons->GetPhi1(),5);
474 0 : par.AddAt(cons->GetPhi2(),6);
475 : return kTRUE;
476 : } // end if
477 0 : if (classType==TGeoSphere::Class()) {
478 0 : shapeType = "SPHE";
479 : npar = 6;
480 0 : par.Set(npar);
481 :
482 0 : TGeoSphere *sphe = (TGeoSphere*)shape;
483 0 : par.AddAt(sphe->GetRmin(),0);
484 0 : par.AddAt(sphe->GetRmax(),1);
485 0 : par.AddAt(sphe->GetTheta1(),2);
486 0 : par.AddAt(sphe->GetTheta2(),3);
487 0 : par.AddAt(sphe->GetPhi1(),4);
488 0 : par.AddAt(sphe->GetPhi2(),5);
489 : return kTRUE;
490 : } // end if
491 0 : if (classType==TGeoPara::Class()) {
492 0 : shapeType = "PARA";
493 : npar = 6;
494 0 : par.Set(npar);
495 0 : TGeoPara *para = (TGeoPara*)shape;
496 0 : par.AddAt(para->GetX(),0);
497 0 : par.AddAt(para->GetY(),1);
498 0 : par.AddAt(para->GetZ(),2);
499 0 : par.AddAt(para->GetTxy(),3);
500 0 : par.AddAt(para->GetTxz(),4);
501 0 : par.AddAt(para->GetTyz(),5);
502 : return kTRUE;
503 : } // end if
504 0 : if (classType==TGeoPgon::Class()) {
505 0 : shapeType = "PGON";
506 0 : TGeoPgon *pgon = (TGeoPgon*)shape;
507 0 : Int_t nz = pgon->GetNz();
508 0 : const Double_t *rmin = pgon->GetRmin();
509 0 : const Double_t *rmax = pgon->GetRmax();
510 0 : const Double_t *z = pgon->GetZ();
511 0 : npar = 4 + 3*nz;
512 0 : par.Set(npar);
513 0 : par.AddAt(pgon->GetPhi1(),0);
514 0 : par.AddAt(pgon->GetDphi(),1);
515 0 : par.AddAt(pgon->GetNedges(),2);
516 0 : par.AddAt(pgon->GetNz(),3);
517 0 : for (Int_t i=0; i<nz; i++) {
518 0 : par.AddAt(z[i], 4+3*i);
519 0 : par.AddAt(rmin[i], 4+3*i+1);
520 0 : par.AddAt(rmax[i], 4+3*i+2);
521 : }
522 : return kTRUE;
523 : } // end if
524 0 : if (classType==TGeoPcon::Class()) {
525 0 : shapeType = "PCON";
526 0 : TGeoPcon *pcon = (TGeoPcon*)shape;
527 0 : Int_t nz = pcon->GetNz();
528 0 : const Double_t *rmin = pcon->GetRmin();
529 0 : const Double_t *rmax = pcon->GetRmax();
530 0 : const Double_t *z = pcon->GetZ();
531 0 : npar = 3 + 3*nz;
532 0 : par.Set(npar);
533 0 : par.AddAt(pcon->GetPhi1(),0);
534 0 : par.AddAt(pcon->GetDphi(),1);
535 0 : par.AddAt(pcon->GetNz(),2);
536 0 : for (Int_t i=0; i<nz; i++) {
537 0 : par.AddAt(z[i], 3+3*i);
538 :
539 0 : par.AddAt(rmin[i], 3+3*i+1);
540 0 : par.AddAt(rmax[i], 3+3*i+2);
541 : }
542 : return kTRUE;
543 : } // end if
544 0 : if (classType==TGeoEltu::Class()) {
545 0 : shapeType = "ELTU";
546 : npar = 3;
547 0 : par.Set(npar);
548 0 : TGeoEltu *eltu = (TGeoEltu*)shape;
549 0 : par.AddAt(eltu->GetA(),0);
550 0 : par.AddAt(eltu->GetB(),1);
551 0 : par.AddAt(eltu->GetDz(),2);
552 : return kTRUE;
553 : } // end if
554 0 : if (classType==TGeoHype::Class()) {
555 0 : shapeType = "HYPE";
556 : npar = 5;
557 0 : par.Set(npar);
558 0 : TGeoHype *hype = (TGeoHype*)shape;
559 0 : par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kTRUE)),0);
560 0 : par.AddAt(TMath::Sqrt(hype->RadiusHypeSq(0.,kFALSE)),1);
561 0 : par.AddAt(hype->GetDZ(),2);
562 0 : par.AddAt(hype->GetStIn(),3);
563 0 : par.AddAt(hype->GetStOut(),4);
564 : return kTRUE;
565 : } // end if
566 0 : if (classType==TGeoGtra::Class()) {
567 0 : shapeType = "GTRA";
568 : npar = 12;
569 0 : par.Set(npar);
570 0 : TGeoGtra *trap = (TGeoGtra*)shape;
571 0 : Double_t tth = TMath::Tan(trap->GetTheta()*TMath::DegToRad());
572 0 : par.AddAt(trap->GetDz(),0);
573 0 : par.AddAt(tth*TMath::Cos(trap->GetPhi()*TMath::DegToRad()),1);
574 0 : par.AddAt(tth*TMath::Sin(trap->GetPhi()*TMath::DegToRad()),2);
575 0 : par.AddAt(trap->GetH1(),3);
576 0 : par.AddAt(trap->GetBl1(),4);
577 0 : par.AddAt(trap->GetTl1(),5);
578 0 : par.AddAt(TMath::Tan(trap->GetAlpha1()*TMath::DegToRad()),6);
579 0 : par.AddAt(trap->GetH2(),7);
580 0 : par.AddAt(trap->GetBl2(),8);
581 0 : par.AddAt(trap->GetTl2(),9);
582 0 : par.AddAt(TMath::Tan(trap->GetAlpha2()*TMath::DegToRad()),10);
583 0 : par.AddAt(trap->GetTwistAngle(),11);
584 : return kTRUE;
585 : } // end if
586 0 : if (classType==TGeoCtub::Class()) {
587 0 : shapeType = "CTUB";
588 : npar = 11;
589 0 : par.Set(npar);
590 0 : TGeoCtub *ctub = (TGeoCtub*)shape;
591 0 : const Double_t *lx = ctub->GetNlow();
592 0 : const Double_t *tx = ctub->GetNhigh();
593 0 : par.AddAt(ctub->GetRmin(),0);
594 0 : par.AddAt(ctub->GetRmax(),1);
595 0 : par.AddAt(ctub->GetDz(),2);
596 0 : par.AddAt(ctub->GetPhi1(),3);
597 0 : par.AddAt(ctub->GetPhi2(),4);
598 0 : par.AddAt(lx[0],5);
599 0 : par.AddAt(lx[1],6);
600 0 : par.AddAt(lx[2],7);
601 0 : par.AddAt(tx[0],8);
602 0 : par.AddAt(tx[1],9);
603 0 : par.AddAt(tx[2],10);
604 : return kTRUE;
605 : } // end if
606 0 : Error("GetShape","Getting shape parameters for shape %s not implemented",
607 0 : shape->ClassName());
608 0 : shapeType = "Unknown";
609 0 : return kFALSE;
610 15386 : }
611 : //______________________________________________________________________
612 : void AliITSInitGeometry::DecodeDetector(
613 : Int_t &mod,Int_t layer,Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
614 : // decode geometry into detector module number. There are two decoding
615 : // Scheams. Old which does not follow the ALICE coordinate system
616 : // requirements, and New which dose.
617 : // Inputs:
618 : // Int_t layer The ITS layer
619 : // Int_t cpn0 The lowest copy number
620 : // Int_t cpn1 The middle copy number
621 : // Int_t cpn2 the highest copy number
622 : // Output:
623 : // Int_t &mod The module number assoicated with this set
624 : // of copy numbers.
625 : // Return:
626 : // none.
627 :
628 : // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
629 : // like them but I see not better way for the moment.
630 2714 : switch (fMajorVersion){
631 : case kvDefault:{
632 0 : Error("DecodeDetector","Major version = kvDefault, not supported");
633 : }break;
634 : case kv11:{
635 1357 : return DecodeDetectorv11(mod,layer,cpn0,cpn1,cpn2);
636 : }break;
637 : default:{
638 0 : Error("DecodeDetector","Major version = %d, not supported",
639 : (Int_t)fMajorVersion);
640 0 : return;
641 : }break;
642 : } // end switch
643 0 : return;
644 1357 : }
645 : //______________________________________________________________________
646 : void AliITSInitGeometry::RecodeDetector(Int_t mod,Int_t &cpn0,
647 : Int_t &cpn1,Int_t &cpn2){
648 : // decode geometry into detector module number. There are two decoding
649 : // Scheams. Old which does not follow the ALICE coordinate system
650 : // requirements, and New which dose.
651 : // Inputs:
652 : // Int_t mod The module number assoicated with this set
653 : // of copy numbers.
654 : // Output:
655 : // Int_t cpn0 The lowest copy number
656 : // Int_t cpn1 The middle copy number
657 : // Int_t cpn2 the highest copy number
658 : // Return:
659 : // none.
660 :
661 : // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
662 : // like them but I see not better way for the moment.
663 30772 : switch (fMajorVersion){
664 : case kvDefault:{
665 0 : Error("RecodeDetector","Major version = kvDefault, not supported");
666 0 : return;
667 : }
668 : case kv11:{
669 15386 : return RecodeDetectorv11(mod,cpn0,cpn1,cpn2);
670 : }break;
671 : default:{
672 0 : Error("RecodeDetector","Major version = %d, not supported",
673 : (Int_t)fMajorVersion);
674 0 : return;
675 : }break;
676 : } // end switch
677 : return;
678 15386 : }
679 : //______________________________________________________________________
680 : void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
681 : Int_t &lad,Int_t &det){
682 : // decode geometry into detector module number. There are two decoding
683 : // Scheams. Old which does not follow the ALICE coordinate system
684 : // requirements, and New which dose. Note, this use of layer ladder
685 : // and detector numbers are strictly for internal use of this
686 : // specific code. They do not represent the "standard" layer ladder
687 : // or detector numbering except in a very old and obsoleate sence.
688 : // Inputs:
689 : // Int_t mod The module number assoicated with this set
690 : // of copy numbers.
691 : // Output:
692 : // Int_t lay The layer number
693 : // Int_t lad The ladder number
694 : // Int_t det the dettector number
695 : // Return:
696 : // none.
697 :
698 : // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't
699 : // like them but I see not better way for the moment.
700 30772 : switch (fMajorVersion) {
701 : case kvDefault:{
702 0 : Error("DecodeDetectorLayers",
703 : "Major version = kvDefault, not supported");
704 0 : return;
705 : }break;
706 : case kv11:{
707 15386 : return DecodeDetectorLayersv11(mod,layer,lad,det);
708 : }break;
709 : default:{
710 0 : Error("DecodeDetectorLayers","Major version = %d, not supported",
711 : (Int_t)fMajorVersion);
712 0 : return;
713 : }break;
714 : } // end switch
715 : return;
716 15386 : }
717 :
718 : //______________________________________________________________________
719 : void AliITSInitGeometry::DecodeDetectorv11(Int_t &mod,Int_t layer,
720 : Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
721 : // decode geometry into detector module number
722 : // Inputs:
723 : // Int_t layer The ITS layer
724 : // Int_t cpn0 The lowest copy number
725 : // Int_t cpn1 The middle copy number
726 : // Int_t cpn2 the highest copy number
727 : // Output:
728 : // Int_t &mod The module number assoicated with this set
729 : // of copy numbers.
730 : // Return:
731 : // none.
732 : const Int_t kDetPerLadderSPD[2]={2,4};
733 : const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
734 : const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
735 : Int_t lad=-1,det=-1;
736 :
737 4071 : switch(layer) {
738 : case 1: case 2:{
739 220 : lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
740 : det = cpn2;
741 220 : } break;
742 : case 3: case 4:{
743 450 : lad = cpn0+1;
744 450 : det = cpn1+1;
745 450 : } break;
746 : case 5: case 6:{
747 687 : lad = cpn0+1;
748 687 : det = cpn1+1;
749 687 : } break;
750 : default:{
751 : } break;
752 : } // end switch
753 1357 : mod = 0;
754 11498 : for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
755 1357 : mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
756 : return;
757 1357 : }
758 :
759 :
760 : //______________________________________________________________________
761 : void AliITSInitGeometry::RecodeDetectorv11(Int_t mod,Int_t &cpn0,
762 : Int_t &cpn1,Int_t &cpn2) {
763 : // decode geometry into detector module number using the new decoding
764 : // Scheme.
765 : // Inputs:
766 : // Int_t mod The module number assoicated with this set
767 : // of copy numbers.
768 : // Output:
769 : // Int_t cpn0 The lowest copy number (SPD sector or SDD/SSD ladder)
770 : // Int_t cpn1 The middle copy number (SPD stave or SDD/SSD module)
771 : // Int_t cpn2 the highest copy number (SPD ladder or 1 for SDD/SSD)
772 : // Return:
773 : // none.
774 : const Int_t kDetPerLadderSPD[2]={2,4};
775 30772 : Int_t lay,lad,det;
776 :
777 15386 : DecodeDetectorLayersv11(mod,lay,lad,det);
778 15386 : if (lay<3) { // SPD
779 1680 : cpn2 = det; // Detector 1-4
780 1680 : cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
781 1680 : cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
782 1680 : } else { // SDD and SSD
783 13706 : cpn2 = 1;
784 13706 : cpn1 = det;
785 13706 : cpn0 = lad;
786 : if (lay<5) { // SDD
787 13706 : cpn1--;
788 13706 : cpn0--;
789 : } else { //SSD
790 : cpn1--;
791 : cpn0--;
792 : } // end if Lay<5/else
793 : } // end if lay<3/else
794 :
795 15386 : }
796 :
797 :
798 : //______________________________________________________________________
799 : void AliITSInitGeometry::DecodeDetectorLayersv11(Int_t mod,Int_t &lay,
800 : Int_t &lad,Int_t &det) {
801 :
802 : // decode module number into detector indices for v11
803 : // mod starts from 0
804 : // lay, lad, det start from 1
805 :
806 : // Inputs:
807 : // Int_t mod The module number associated with this set
808 : // of copy numbers.
809 : // Output:
810 : // Int_t lay The layer number
811 : // Int_t lad The ladder number
812 : // Int_t det the dettector number
813 :
814 : const Int_t kDetPerLadder[6] = {4,4,6,8,22,25};
815 : const Int_t kLadPerLayer[6] = {20,40,14,22,34,38};
816 :
817 : Int_t mod2 = 0;
818 61544 : lay = 0;
819 :
820 30772 : do {
821 151144 : mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
822 151144 : lay++;
823 151144 : } while(mod2<=mod); // end while
824 30772 : if(lay>6) {
825 0 : AliError(Form("lay=%d>6 - setting ladder and detector number to zero",lay));
826 0 : lad = 0;
827 0 : det = 0;
828 0 : return;
829 : }
830 :
831 30772 : mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod;
832 30772 : lad = mod2/kDetPerLadder[lay-1];
833 :
834 61544 : if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers",
835 0 : "lad=%d not in the correct range",lad);
836 30772 : det = (mod2 - lad*kDetPerLadder[lay-1])+1;
837 61544 : if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
838 0 : "det=%d not in the correct range",det);
839 30772 : lad++;
840 61544 : }
841 :
842 : //______________________________________________________________________
843 : Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,AliITSVersion_t maj)const{
844 : // fills the string str with the major version number
845 : // Inputs:
846 : // Char_t *str The character string to hold the major version number
847 : // Int_t length The maximum number of characters which
848 : // can be accommodated by this string.
849 : // str[length-1] must exist
850 : // AliITSVersion_t maj The major number
851 :
852 :
853 : Int_t i = (Int_t)maj;
854 :
855 2 : snprintf(str,length-1,"Major Version= %d",i);
856 1 : return kTRUE;
857 : }
858 : //______________________________________________________________________
859 : Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,AliITSVersion_t &maj)const{
860 : // fills the string str with the major and minor version number
861 : // Inputs:
862 : // Char_t *str The character string to holding the major version number
863 : // Int_t length The maximum number of characters which can be
864 : // accommodated by this string. str[length-1] must exist
865 : // Outputs:
866 : // AliITSVersion_t maj The major number
867 :
868 : // Return:
869 : // kTRUE if no errors
870 :
871 : Bool_t retcode=kFALSE;
872 10 : Int_t n=strlen(str);
873 5 : if(n<15) return retcode; // not enough space for numbers
874 5 : Int_t m,i;
875 5 : m = sscanf(str,"Major Version= %2d",&i);
876 5 : maj = kvDefault;
877 5 : if(m>0){
878 : retcode = kTRUE;
879 5 : if(i==11){
880 5 : maj = kv11;
881 5 : }
882 : }
883 5 : return retcode;
884 10 : }
885 :
886 :
|