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