source: trunk/source/g3tog4/src/G3NegVolPars.cc@ 1253

Last change on this file since 1253 was 1228, checked in by garnier, 16 years ago

update geant4.9.3 tag

File size: 7.2 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G3NegVolPars.cc,v 1.13 2006/06/29 18:13:08 gunter Exp $
28// GEANT4 tag $Name: geant4-09-03 $
29//
30// modified by I. Hrivnacova, 13.10.99
31
32#include "globals.hh"
33#include "G3VolTable.hh"
34#include "G4VSolid.hh"
35#include "G3toG4.hh"
36#include <cmath>
37
38G4bool G3CalcParamsFn(G4double *Rpar, G4int npar, G4double *Rparm,
39 G4String shape, G4String shapem)
40 // Returns true only in case the parameters *after* processing
41 // this method remain negative.
42{
43 G4bool NegPresent = FALSE;
44 // for normal single volume positioning, just substitute for the
45 // negative parameters
46 // treat only the legal cases
47 if (shapem == shape) {
48 if (shape == "BOX" || shape == "TRD1" || shape == "TRD2" ||
49 shape == "ELTU") {
50 for (G4int i=0;i<npar;i++) {
51 if (Rpar[i] < 0) {
52 if (Rparm != 0) Rpar[i] = Rparm[i];
53 if (Rpar[i] < 0) NegPresent = TRUE;
54 }
55 }
56 }
57 if (shape == "TRAP") {
58 for (G4int i=0;i<11;i++) {
59 if (i != 1 && i != 2 && i != 6 && i != 10) {
60 if (Rpar[i]<0) {
61 if (Rparm != 0) Rpar[i] = Rparm[i];
62 if (Rpar[i] < 0) NegPresent = TRUE;
63 }
64 }
65 }
66 }
67 if (shape == "TUBE" || shape == "TUBS" || shape == "PARA") {
68 for (G4int i=0;i<3;i++) {
69 if (Rpar[i] < 0) {
70 if (Rparm != 0) Rpar[i] = Rparm[i];
71 if (Rpar[i] < 0) NegPresent = TRUE;
72 }
73 }
74 }
75 if (shape == "CONE" || shape == "CONS") {
76 for (G4int i=0;i<5;i++) {
77 if (Rpar[i] < 0) {
78 if (Rparm != 0) Rpar[i] = Rparm[i];
79 if (Rpar[i] < 0) NegPresent = TRUE;
80 }
81 }
82 }
83 if (shape == "SPHE") {
84 for (G4int i=0;i<2;i++) {
85 if (Rpar[i] < 0) {
86 if (Rparm != 0) Rpar[i] = Rparm[i];
87 if (Rpar[i] < 0) NegPresent = TRUE;
88 }
89 }
90 }
91 if (shape == "PGON") {
92 G4int nz = int(Rpar[3]);
93 G4int ipl;
94 for (G4int i=0;i<nz;i++) {
95 ipl = 5 + i*3;
96 if (Rpar[ipl] < 0) {
97 if (Rparm != 0) Rpar[ipl] = Rparm[ipl];
98 if (Rpar[ipl] < 0) NegPresent = TRUE;
99 }
100 if (Rpar[ipl+1] < 0) {
101 if (Rparm != 0) Rpar[ipl] = Rparm[ipl];
102 if (Rpar[ipl] < 0) NegPresent = TRUE;
103 }
104 }
105 }
106 if (shape == "PCON") {
107 G4int nz = int(Rpar[2]);
108 G4int ipl;
109 for (G4int i=0;i<nz;i++) {
110 ipl = 4 + i*3;
111 if (Rpar[ipl] < 0) {
112 if (Rparm != 0) Rpar[ipl] = Rparm[ipl];
113 if (Rpar[ipl] < 0) NegPresent = TRUE;
114 }
115 if (Rpar[ipl+1] < 0) {
116 // TO DO
117 // check - folowing argument might be ipl+1
118 if (Rparm != 0) Rpar[ipl] = Rparm[ipl];
119 if (Rpar[ipl] < 0) NegPresent = TRUE;
120 }
121 }
122 }
123 }
124
125 if (shape == "BOX") {
126 if (shapem == "TRD1") {
127 if (Rpar[1] < 0) {
128 if (Rparm != 0) Rpar[1] = Rparm[2];
129 if (Rpar[1] < 0) NegPresent = TRUE;
130 }
131 if (Rpar[2] < 0) {
132 if (Rparm != 0) Rpar[2] = Rparm[3];
133 if (Rpar[2] < 0) NegPresent = TRUE;
134 }
135 if (Rpar[0] < 0) {
136 if (Rparm != 0) Rpar[0] = std::min(Rparm[0],Rparm[1]) +
137 std::abs(Rparm[0]-Rparm[1])*.5*Rpar[2]/Rparm[3];
138 if (Rpar[0] < 0) NegPresent = TRUE;
139 }
140 }
141 if (shapem == "TRD2") {
142 if (Rpar[2] < 0) {
143 if (Rparm != 0) Rpar[2] = Rparm[4];
144 if (Rpar[2]<0) NegPresent = TRUE;
145 }
146 if (Rpar[0] < 0) {
147 if (Rparm != 0) Rpar[0] = std::min(Rparm[0],Rparm[1]) +
148 std::abs(Rparm[0]-Rparm[1])*.5*Rpar[2]/Rparm[4];
149 if (Rpar[0]<0) NegPresent = TRUE;
150 }
151 if (Rpar[1] < 0) {
152 if (Rparm != 0) Rpar[1] = std::min(Rparm[2],Rparm[3]) +
153 std::abs(Rparm[2]-Rparm[3])*.5*Rpar[2]/Rparm[4];
154 if (Rpar[1]<0) NegPresent = TRUE;
155 }
156 }
157 if (shapem == "TRAP") {
158 if (Rpar[2] < 0) {
159 if (Rparm != 0) Rpar[2] = Rparm[0];
160 if (Rpar[2] < 0) NegPresent = TRUE;
161 }
162 if (Rpar[0] < 0) {
163 if (Rparm != 0) {
164 G4double xlo = std::min(Rparm[4],Rparm[8]) +
165 std::abs(Rparm[4]-Rparm[8])*.5*Rpar[2]/Rparm[0];
166 G4double xhi = std::min(Rparm[5],Rparm[9]) +
167 std::abs(Rparm[5]-Rparm[9])*.5*Rpar[2]/Rparm[0];
168 Rpar[0] = std::min(xlo,xhi);
169 }
170 if (Rpar[0] < 0) NegPresent = TRUE;
171 }
172 if (Rpar[1] < 0) {
173 if (Rparm != 0) Rpar[1] = std::min(Rparm[3],Rparm[7]) +
174 std::abs(Rparm[3]-Rparm[7])*.5*Rpar[2]/Rparm[0];
175 if (Rpar[1] < 0) NegPresent = TRUE;
176 }
177 }
178 }
179 return NegPresent;
180}
181
182G4bool G3NegVolPars(G4double pars[], G4int *nparpt,
183 G3VolTableEntry* vte,
184 G3VolTableEntry* mvte, const char routine[])
185{
186 G4bool NegPresent = FALSE;
187
188 // retrieve parameters
189
190 // the volume
191 G4String shape = vte->GetShape();
192 G4double* Rpar = vte->GetRpar();
193 G4int npar = vte->GetNpar();
194 if (npar ==0) {
195 // no solid parameters are defined in vte
196 npar = *nparpt;
197 Rpar = pars;
198 }
199 else {
200 // solid parameters are already defined in vte
201 // pars[], nparpt are ignored
202 // TO DO: check if g3 ignores them too or resets
203 // vte parameters according to this new ones !!
204 }
205
206 // mother
207 G4String shapem = mvte->GetShape();
208 G4double* Rparm = mvte->GetRpar();
209
210 if (strcmp(routine,"GSPOS") == 0 || strcmp(routine,"GSVOLU") == 0) {
211 NegPresent = G3CalcParamsFn(Rpar,npar,Rparm,shape,shapem);
212 }
213 if (strcmp(routine,"GSDVN") == 0) {
214 // just set the flag. The parametrization function figures out
215 // what to do.
216 for (G4int i=0;i<npar;i++) {
217 if (Rpar[i] < 0) {
218 NegPresent = TRUE;
219 }
220 }
221 }
222 return NegPresent;
223}
Note: See TracBrowser for help on using the repository browser.