Geant4-11
Functions
G3toG4MakeSolid.hh File Reference

Go to the source code of this file.

Functions

G4VSolidG3toG4MakeSolid (const G4String &vname, const G4String &shape, const G4double *Rpar, const G4int npar, G4bool &NegVolPars, G4bool &Deferred, G4bool *OKAxis)
 

Function Documentation

◆ G3toG4MakeSolid()

G4VSolid * G3toG4MakeSolid ( const G4String vname,
const G4String shape,
const G4double Rpar,
const G4int  npar,
G4bool NegVolPars,
G4bool Deferred,
G4bool OKAxis 
)

Definition at line 46 of file G3toG4MakeSolid.cc.

49 {
50
51 // Create the solid if no negative length parameters
52 G4VSolid *solid = 0;
53
54 NegVolPars = false;
55
56 // if npar = 0 assume LV deferral
57 Deferred = (npar == 0);
58 // modified
59 if (Deferred) return solid;
60
61 for (G4int i=0;i<3;i++){
62 OKAxis[i]=false;
63 };
64
65 if ( shape == "BOX" ) {
66 G4double pX = rpar[0]*cm;
67 G4double pY = rpar[1]*cm;
68 G4double pZ = rpar[2]*cm;
69
70 OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
71
72 NegVolPars = pX<0 || pY<0 || pZ<0;
73
74 if (!(NegVolPars || Deferred)) {
75 solid = new G4Box(vname, pX, pY, pZ);
76 }
77
78 } else if ( shape == "TRD1" ) {
79 G4double pdx1 = rpar[0]*cm;
80 G4double pdx2 = rpar[1]*cm;
81 G4double pdy1 = rpar[2]*cm;
82 G4double pdy2 = pdy1;
83 G4double pdz = rpar[3]*cm;
84
85 OKAxis[1]=OKAxis[2]=true;
86
87 NegVolPars = pdx1<0 || pdx2<0 || pdy1<0 || pdz<0;
88
89 if (!(NegVolPars || Deferred)) {
90 solid = new G4Trd(vname, pdx1, pdx2, pdy1, pdy2, pdz);
91 }
92
93 } else if ( shape == "TRD2" ) {
94 G4double pdx1 = rpar[0]*cm;
95 G4double pdx2 = rpar[1]*cm;
96 G4double pdy1 = rpar[2]*cm;
97 G4double pdy2 = rpar[3]*cm;
98 G4double pdz = rpar[4]*cm;
99
100 OKAxis[2]=true;
101
102 NegVolPars = pdx1<0 || pdx2<0 || pdy1<0 || pdy2<0 || pdz<0;
103
104 if (!(NegVolPars || Deferred)) {
105 solid = new G4Trd(vname, pdx1, pdx2, pdy1, pdy2, pdz);
106 }
107
108 } else if ( shape == "TRAP" ) {
109 G4double pDz = rpar[0]*cm;
110 G4double pTheta = rpar[1]*deg;
111 G4double pPhi = rpar[2]*deg;
112 G4double pDy1 = rpar[3]*cm;
113 G4double pDx1 = rpar[4]*cm;
114 G4double pDx2 = rpar[5]*cm;
115 G4double pAlp1 = rpar[6]*deg;
116 G4double pDy2 = rpar[7]*cm;
117 G4double pDx3 = rpar[8]*cm;
118 G4double pDx4 = rpar[9]*cm;
119 G4double pAlp2 = rpar[10]*deg;
120
121 OKAxis[2]=true;
122
123 NegVolPars= pDz<0 || pDy1<0 || pDx1<0 || pDx2<0 || pDy2<0 || pDx3<0 || pDx4<0;
124
125 if (!(NegVolPars || Deferred)) {
126 // added for test only
127 if (!(pDz>0)) pDz += 0.001*cm;
128 if (!(pDy1>0)) pDy1 += 0.001*cm;
129 if (!(pDx1>0)) pDx1 += 0.001*cm;
130 if (!(pDx2>0)) pDx2 += 0.001*cm;
131 if (!(pDy2>0)) pDy2 += 0.001*cm;
132 if (!(pDx3>0)) pDx3 += 0.001*cm;
133 if (!(pDx4>0)) pDx4 += 0.001*cm;
134
135 solid = new
136 G4Trap(vname, pDz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3,
137 pDx4, pAlp2);
138 }
139
140 } else if ( shape == "TUBE" ) {
141 G4double pRMin = rpar[0]*cm;
142 G4double pRMax = rpar[1]*cm;
143 G4double pDz = rpar[2]*cm;
144 G4double pSPhi = 0.*deg;
145 G4double pDPhi = 360.*deg;
146
147 OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
148
149 NegVolPars = pRMin<0 || pRMax<0 || pDz<0;
150
151 if (!(NegVolPars || Deferred)) {
152 solid = new G4Tubs(vname, pRMin, pRMax, pDz, pSPhi, pDPhi);
153 }
154
155 } else if ( shape == "TUBS" ) {
156 G4double pRMin = rpar[0]*cm;
157 G4double pRMax = rpar[1]*cm;
158 G4double pDz = rpar[2]*cm;
159 G4double pSPhi = rpar[3]*deg;
160 G4double pDPhi = rpar[4]*deg - pSPhi;
161 if ( rpar[4]*deg <= pSPhi ) pDPhi = pDPhi + 360.*deg;
162
163 OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
164
165 NegVolPars = pRMin<0 || pRMax<0 || pDz<0;
166
167 if (!(NegVolPars || Deferred)){
168 solid = new G4Tubs(vname, pRMin, pRMax, pDz, pSPhi, pDPhi);
169 }
170
171 } else if ( shape == "CONE" ) {
172 G4double pDz = rpar[0]*cm;
173 G4double pRmin1 = rpar[1]*cm;
174 G4double pRmax1 = rpar[2]*cm;
175 G4double pRmin2 = rpar[3]*cm;
176 G4double pRmax2 = rpar[4]*cm;
177 G4double pSPhi = 0.*deg;
178 G4double pDPhi = 360.*deg;
179
180 OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
181
182 NegVolPars = pDz<0 || pRmin1<0 || pRmax1<0 || pRmin2<0 || pRmax2<0;
183
184 if (!(NegVolPars || Deferred)){
185 solid = new
186 G4Cons(vname, pRmin1, pRmax1, pRmin2, pRmax2, pDz, pSPhi, pDPhi);
187 }
188
189 } else if ( shape == "CONS" ) {
190 G4double pDz = rpar[0]*cm;
191 G4double pRmin1 = rpar[1]*cm;
192 G4double pRmax1 = rpar[2]*cm;
193 G4double pRmin2 = rpar[3]*cm;
194 G4double pRmax2 = rpar[4]*cm;
195 G4double pSPhi = rpar[5]*deg;
196 G4double pDPhi = rpar[6]*deg - pSPhi;
197 if ( rpar[6]*deg <= pSPhi ) pDPhi = pDPhi + 360.*deg;
198
199 OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
200
201 NegVolPars = pDz<0 || pRmin1<0 || pRmax1<0 || pRmin2<0 || pRmax2<0;
202
203 if (!(NegVolPars || Deferred)){
204 solid = new
205 G4Cons(vname, pRmin1, pRmax1, pRmin2, pRmax2, pDz, pSPhi, pDPhi);
206 }
207
208 } else if ( shape == "SPHE" ) {
209 G4double pRmin = rpar[0]*cm;
210 G4double pRmax = rpar[1]*cm;
211 G4double pThe1 = rpar[2]*deg;
212 G4double pThe2 = rpar[3]*deg;
213 G4double pDThe = pThe2 - pThe1;
214 G4double pPhi1 = rpar[4]*deg;
215 G4double pPhi2 = rpar[5]*deg;
216 G4double pDPhi = pPhi2 - pPhi1;
217
218 NegVolPars = pRmin<0 || pRmax<0;
219
220 if (!(NegVolPars || Deferred)) {
221 solid = new G4Sphere(vname, pRmin, pRmax, pPhi1, pDPhi, pThe1, pDThe);
222 }
223
224 } else if ( shape == "PARA" ) {
225 G4double pDx = rpar[0]*cm;
226 G4double pDy = rpar[1]*cm;
227 G4double pDz = rpar[2]*cm;
228 G4double pAlph = rpar[3]*deg;
229 G4double pThet = rpar[4]*deg;
230 G4double pPhi = rpar[5]*deg;
231
232 OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
233
234 NegVolPars = pDx<0 || pDy<0 || pDz<0;
235
236 if (!(NegVolPars || Deferred)){
237 solid = new G4Para(vname, pDx, pDy, pDz, pAlph, pThet, pPhi);
238 }
239
240 } else if ( shape == "PGON" ) {
241 G4int i;
242 G4int npdv = G4int(rpar[2]);
243 G4int nz = G4int(rpar[3]);
244 G4double pPhi1 = rpar[0]*deg;
245 G4double dPhi = rpar[1]*deg;
246 G4double *DzArray = new G4double[nz];
247 G4double *Rmax = new G4double[nz];
248 G4double *Rmin = new G4double[nz];
249
250 OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
251
252 NegVolPars = 0;
253
254 for(i=0; i<nz; i++) {
255 G4int i4=3*i+4;
256 G4int i5=i4+1;
257 G4int i6=i4+2;
258 DzArray[i] = rpar[i4]*cm;
259 Rmin[i] = rpar[i5]*cm;
260 Rmax[i] = rpar[i6]*cm;
261 }
262 solid = new G4Polyhedra(vname, pPhi1, dPhi, npdv, nz, DzArray, Rmin, Rmax);
263 delete [] DzArray;
264 delete [] Rmin;
265 delete [] Rmax;
266
267 } else if ( shape == "PCON" ) {
268 G4int i;
269 G4double pPhi1 = rpar[0]*deg;
270 G4double dPhi = rpar[1]*deg;
271 G4int nz = G4int(rpar[2]);
272 G4double *DzArray = new G4double[nz];
273 G4double *Rmax = new G4double[nz];
274 G4double *Rmin = new G4double[nz];
275
276 OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
277
278 NegVolPars = 0;
279
280 for(i=0; i<nz; i++){
281 G4int i4=3*i+3;
282 G4int i5=i4+1;
283 G4int i6=i4+2;
284 DzArray[i] = rpar[i4]*cm;
285 Rmin[i] = rpar[i5]*cm;
286 Rmax[i] = rpar[i6]*cm;
287 }
288 solid = new G4Polycone(vname, pPhi1, dPhi, nz, DzArray, Rmin, Rmax);
289 delete [] DzArray;
290 delete [] Rmin;
291 delete [] Rmax;
292
293 } else if ( shape == "ELTU" ) {
294 G4double dX = rpar[0]*cm;
295 G4double dY = rpar[1]*cm;
296 G4double dZ = rpar[2]*cm;
297
298 OKAxis[0]=OKAxis[1]=OKAxis[2]=true;
299
300 NegVolPars = dX<0 || dY<0 || dZ<0;
301
302 if (!(NegVolPars || Deferred)) {
303 solid = new G4EllipticalTube(vname, dX, dY, dZ);
304 }
305
306 } else if ( shape == "HYPE" ) {
307 G4double pRmin = rpar[0]*cm;
308 G4double pRmax = rpar[1]*cm;
309 G4double pDz = rpar[2]*cm;
310 G4double pThet = rpar[3]*deg;
311
312 NegVolPars = pRmin<0 || pRmax<0 || pDz<0;
313
314 if (!(NegVolPars || Deferred)){
315 solid = new G4Hype(vname, pRmin, pRmax, pThet, pThet, pDz);
316 } else {
317 G4cerr << "Negative length parameters not supported for shape "
318 << shape << G4endl;
319 }
320
321 } else if ( shape == "GTRA" ) {
322 // $$$ not implemented.
323 G4cerr << "GTRA not supported" << G4endl;
324
325 } else if ( shape == "CTUB" ) {
326 // $$$ not implemented.
327 G4cerr << "CTUB not supported" << G4endl;
328 }
329 return solid;
330}
static constexpr double cm
Definition: G4SIunits.hh:99
static constexpr double deg
Definition: G4SIunits.hh:132
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
Definition: G4Box.hh:56
Definition: G4Cons.hh:78
Definition: G4Hype.hh:69
Definition: G4Para.hh:79
Definition: G4Trd.hh:63
Definition: G4Tubs.hh:75

References cm, deg, G4cerr, and G4endl.

Referenced by G3Division::CreateSolid(), G4CreateCloneVTE(), G4CreateVTE(), and G4ProcessDaughters().