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