]>
Commit | Line | Data |
---|---|---|
27f4aa1e | 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 | ||
803d1ab0 | 16 | /* $Id$ */ |
27f4aa1e | 17 | |
18 | /* | |
19 | * Version: 0 | |
20 | * Written by Bjorn S. Nilsen with code stolen from Andreas Morsch's | |
21 | * AliGeant3GeometryGUI class. | |
22 | */ | |
23 | ||
24 | #include <ctype.h> | |
25 | #include "AliITSGeant3Geometry.h" | |
26 | ||
27 | ClassImp(AliITSGeant3Geometry) | |
28 | ||
29 | AliITSGeant3Geometry::AliITSGeant3Geometry(){ | |
30 | // Constructor | |
31 | ||
32 | // Store local copy of zebra bank entries | |
33 | TGeant3 *geant3 = (TGeant3*) gMC; | |
34 | if(geant3){ | |
35 | fZlq = geant3->Lq(); | |
36 | fZq = geant3->Q(); | |
37 | fZiq = geant3->Iq(); | |
38 | fGclink = geant3->Gclink(); | |
39 | fGcnum = geant3->Gcnum(); | |
40 | fGcvolu = geant3->Gcvolu(); | |
41 | } // end if | |
42 | } | |
43 | //---------------------------------------------------------------------- | |
44 | Int_t AliITSGeant3Geometry::NChildren(Int_t idvol){ | |
45 | // | |
46 | // Return number of children for volume idvol | |
47 | Int_t jvo = fZlq[fGclink->jvolum-idvol]; | |
48 | Int_t nin = Int_t(fZq[jvo+3]); | |
49 | return nin; | |
50 | } | |
51 | //---------------------------------------------------------------------- | |
52 | Int_t AliITSGeant3Geometry::GetShape(Int_t idvol,Int_t &npar,Int_t &natt, | |
53 | Float_t *par,Float_t *att){ | |
54 | // Returns the Geant shape number for a given volume | |
55 | Int_t ishape,i; | |
56 | ||
57 | Int_t jvo = fZlq[fGclink->jvolum-idvol]; | |
58 | // Int_t nin = Int_t(fZq[jvo+3]); | |
59 | ishape = Int_t(fZq[jvo+2]); | |
60 | npar = Int_t(fZq[jvo+5]); | |
61 | natt = Int_t(fZq[jvo+6]); | |
62 | for(i=0;i<npar;i++) par[i] = fZq[jvo+7+i]; | |
63 | for(i=0;i<natt;i++) att[i] = fZq[jvo+7+npar+i]; | |
64 | // if(nin<0){ // devided volumes | |
65 | // printf("Divisions nin=%d\n",nin); | |
66 | // }else{ | |
67 | // printf("SubVolumes nin=%d\n",nin); | |
68 | // } // end if | |
69 | return ishape; | |
70 | } | |
71 | //---------------------------------------------------------------------- | |
72 | Int_t AliITSGeant3Geometry::Child(Int_t idvol, Int_t idc){ | |
73 | // | |
74 | // Return GEANT id of child number idc of volume idvol | |
75 | Int_t jvo = fZlq[fGclink->jvolum-idvol]; | |
76 | Int_t nin=idc; | |
77 | Int_t jin = fZlq[jvo-nin]; | |
78 | Int_t numb = Int_t(fZq[jin +3]); | |
79 | if (numb > 1) { | |
80 | return -Int_t(fZq[jin+2]); | |
81 | } else { | |
82 | return Int_t(fZq[jin+2]); | |
83 | } | |
84 | } | |
85 | //---------------------------------------------------------------------- | |
86 | Int_t AliITSGeant3Geometry::Medium(Int_t idvol){ | |
87 | // | |
88 | // Return medium number for volume idvol. | |
89 | // If idvol is negative the volume results from a division. | |
90 | Int_t imed; | |
91 | if (idvol > 0) { | |
92 | Int_t jvo = fZlq[fGclink->jvolum-idvol]; | |
93 | imed = Int_t(fZq[jvo+4]); | |
94 | } else { | |
95 | idvol=-idvol; | |
96 | Int_t jdiv = fZlq[fGclink->jvolum-idvol]; | |
97 | Int_t ivin = Int_t ( fZq[jdiv+2]); | |
98 | Int_t jvin = fZlq[fGclink->jvolum-ivin]; | |
99 | imed = Int_t (fZq[jvin+4]); | |
100 | } | |
101 | return imed; | |
102 | } | |
103 | //---------------------------------------------------------------------- | |
104 | Int_t AliITSGeant3Geometry::Material(Int_t idvol){ | |
105 | // Return material number for volume idvol. | |
106 | // If idvol is negative the volume results from a division. | |
107 | ||
108 | Int_t imed=Medium(idvol); | |
109 | Int_t jtm = fZlq[fGclink->jtmed-imed]; | |
110 | return Int_t (fZq[jtm+6]); | |
111 | } | |
112 | //---------------------------------------------------------------------- | |
113 | void AliITSGeant3Geometry::GetGeometry(Int_t nlevels,Int_t *lnam,Int_t *lnum, | |
114 | Double_t *xt,Double_t *r,Int_t &idshape, | |
115 | Int_t &npar,Int_t &natt,Float_t *par, | |
116 | Float_t *att,Int_t &imat,Int_t &imed){ | |
117 | // Returns the MtoD/DtoM transformation for a given volume in the | |
118 | // volume tree LNAM for the given copy of those volumes in LNUM. | |
119 | // Input: | |
120 | // nlevels the size of the arrays LNAM and LNUM used | |
121 | // lnam the array of volume names through the tree of volumes | |
122 | // lnum the copy number for the volumes above. | |
123 | // Output: | |
124 | // xt Double precition array(3) for the coordiante | |
125 | // translation for the DtoM/MtoD translation. | |
126 | // r Double precition array(10) for the 3x3 rotation | |
127 | // matrix for the DtoM/MtoD transformation. Element | |
128 | // 10 is a flag indicating if this matrix is the unit | |
129 | // matrix | |
130 | // idshape Geant3.21 volume shape index number | |
131 | // npar Geant3.21 the number of shape parameters | |
132 | // natt Geant3.21 the number of attributes | |
133 | // par Geant3.21 an array of shape parameters | |
134 | // att Geant3.21 an array of attributes | |
135 | // imat Geant3.21 matrial index number for this volume | |
136 | // imed Geant3.21 medium index number for this volume | |
137 | // | |
138 | // | |
139 | Int_t ier,idvol,nlevel,i; | |
140 | TGeant3 *geant3 = (TGeant3*) gMC; | |
141 | // | |
142 | fGcvolu->nlevel = 0; | |
143 | ier = geant3->Glvolu(nlevels,lnam,lnum); | |
144 | nlevel = fGcvolu->nlevel; | |
145 | idvol = fGcvolu->lvolum[nlevel-1]; | |
146 | imed = Medium(idvol); | |
147 | imat = Material(idvol); | |
148 | idshape= GetShape(idvol,npar,natt,par,att); | |
149 | for(i=0;i<3;i++) xt[i] = fGcvolu->gtran[nlevel-1][i]; | |
150 | for(i=0;i<10;i++) r[i] = fGcvolu->grmat[nlevel-1][i]; | |
151 | } | |
152 | //---------------------------------------------------------------------- | |
153 | Int_t AliITSGeant3Geometry::StringToInt(char *name){ | |
154 | // converts up to a four letter char string to an equivelant int | |
155 | Int_t i,len = strlen(name); | |
156 | UInt_t iname=0; | |
157 | ||
158 | for(i=0;i<4;i++){ | |
159 | if(i<len) iname += ( toupper(name[i]) << (8*(i)) ); | |
160 | else iname += ( toupper(' ') << (8*(i)) ); | |
161 | } // end for | |
162 | return (Int_t) iname; | |
163 | } |