Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G3NegVolPars.cc File Reference
#include "globals.hh"
#include "G3VolTable.hh"
#include "G4VSolid.hh"
#include "G3toG4.hh"
#include <cmath>
Include dependency graph for G3NegVolPars.cc:

Go to the source code of this file.

Functions

G4bool G3CalcParamsFn (G4double *rpar, G4int npar, G4double *rparm, G4String shape, G4String shapem)
 
G4bool G3NegVolPars (G4double pars[], G4int *nparpt, G3VolTableEntry *vte, G3VolTableEntry *mvte, const char routine[])
 

Function Documentation

G4bool G3CalcParamsFn ( G4double rpar,
G4int  npar,
G4double rparm,
G4String  shape,
G4String  shapem 
)

Definition at line 37 of file G3NegVolPars.cc.

41 {
42  G4bool NegPresent = FALSE;
43  // for normal single volume positioning, just substitute for the
44  // negative parameters
45  // treat only the legal cases
46  if (shapem == shape) {
47  if (shape == "BOX" || shape == "TRD1" || shape == "TRD2" ||
48  shape == "ELTU") {
49  for (G4int i=0;i<npar;i++) {
50  if (rpar[i] < 0) {
51  if (rparm != 0) rpar[i] = rparm[i];
52  if (rpar[i] < 0) NegPresent = TRUE;
53  }
54  }
55  }
56  if (shape == "TRAP") {
57  for (G4int i=0;i<11;i++) {
58  if (i != 1 && i != 2 && i != 6 && i != 10) {
59  if (rpar[i]<0) {
60  if (rparm != 0) rpar[i] = rparm[i];
61  if (rpar[i] < 0) NegPresent = TRUE;
62  }
63  }
64  }
65  }
66  if (shape == "TUBE" || shape == "TUBS" || shape == "PARA") {
67  for (G4int i=0;i<3;i++) {
68  if (rpar[i] < 0) {
69  if (rparm != 0) rpar[i] = rparm[i];
70  if (rpar[i] < 0) NegPresent = TRUE;
71  }
72  }
73  }
74  if (shape == "CONE" || shape == "CONS") {
75  for (G4int i=0;i<5;i++) {
76  if (rpar[i] < 0) {
77  if (rparm != 0) rpar[i] = rparm[i];
78  if (rpar[i] < 0) NegPresent = TRUE;
79  }
80  }
81  }
82  if (shape == "SPHE") {
83  for (G4int i=0;i<2;i++) {
84  if (rpar[i] < 0) {
85  if (rparm != 0) rpar[i] = rparm[i];
86  if (rpar[i] < 0) NegPresent = TRUE;
87  }
88  }
89  }
90  if (shape == "PGON") {
91  G4int nz = G4int(rpar[3]);
92  G4int ipl;
93  for (G4int i=0;i<nz;i++) {
94  ipl = 5 + i*3;
95  if (rpar[ipl] < 0) {
96  if (rparm != 0) rpar[ipl] = rparm[ipl];
97  if (rpar[ipl] < 0) NegPresent = TRUE;
98  }
99  if (rpar[ipl+1] < 0) {
100  if (rparm != 0) rpar[ipl] = rparm[ipl];
101  if (rpar[ipl] < 0) NegPresent = TRUE;
102  }
103  }
104  }
105  if (shape == "PCON") {
106  G4int nz = G4int(rpar[2]);
107  G4int ipl;
108  for (G4int i=0;i<nz;i++) {
109  ipl = 4 + i*3;
110  if (rpar[ipl] < 0) {
111  if (rparm != 0) rpar[ipl] = rparm[ipl];
112  if (rpar[ipl] < 0) NegPresent = TRUE;
113  }
114  if (rpar[ipl+1] < 0) {
115  // TO DO
116  // check - folowing argument might be ipl+1
117  if (rparm != 0) rpar[ipl] = rparm[ipl];
118  if (rpar[ipl] < 0) NegPresent = TRUE;
119  }
120  }
121  }
122  }
123 
124  if (shape == "BOX") {
125  if (shapem == "TRD1") {
126  if (rpar[1] < 0) {
127  if (rparm != 0) rpar[1] = rparm[2];
128  if (rpar[1] < 0) NegPresent = TRUE;
129  }
130  if (rpar[2] < 0) {
131  if (rparm != 0) rpar[2] = rparm[3];
132  if (rpar[2] < 0) NegPresent = TRUE;
133  }
134  if (rpar[0] < 0) {
135  if (rparm != 0) rpar[0] = std::min(rparm[0],rparm[1]) +
136  std::abs(rparm[0]-rparm[1])*.5*rpar[2]/rparm[3];
137  if (rpar[0] < 0) NegPresent = TRUE;
138  }
139  }
140  if (shapem == "TRD2") {
141  if (rpar[2] < 0) {
142  if (rparm != 0) rpar[2] = rparm[4];
143  if (rpar[2]<0) NegPresent = TRUE;
144  }
145  if (rpar[0] < 0) {
146  if (rparm != 0) rpar[0] = std::min(rparm[0],rparm[1]) +
147  std::abs(rparm[0]-rparm[1])*.5*rpar[2]/rparm[4];
148  if (rpar[0]<0) NegPresent = TRUE;
149  }
150  if (rpar[1] < 0) {
151  if (rparm != 0) rpar[1] = std::min(rparm[2],rparm[3]) +
152  std::abs(rparm[2]-rparm[3])*.5*rpar[2]/rparm[4];
153  if (rpar[1]<0) NegPresent = TRUE;
154  }
155  }
156  if (shapem == "TRAP") {
157  if (rpar[2] < 0) {
158  if (rparm != 0) rpar[2] = rparm[0];
159  if (rpar[2] < 0) NegPresent = TRUE;
160  }
161  if (rpar[0] < 0) {
162  if (rparm != 0) {
163  G4double xlo = std::min(rparm[4],rparm[8]) +
164  std::abs(rparm[4]-rparm[8])*.5*rpar[2]/rparm[0];
165  G4double xhi = std::min(rparm[5],rparm[9]) +
166  std::abs(rparm[5]-rparm[9])*.5*rpar[2]/rparm[0];
167  rpar[0] = std::min(xlo,xhi);
168  }
169  if (rpar[0] < 0) NegPresent = TRUE;
170  }
171  if (rpar[1] < 0) {
172  if (rparm != 0) rpar[1] = std::min(rparm[3],rparm[7]) +
173  std::abs(rparm[3]-rparm[7])*.5*rpar[2]/rparm[0];
174  if (rpar[1] < 0) NegPresent = TRUE;
175  }
176  }
177  }
178  return NegPresent;
179 }
int G4int
Definition: G4Types.hh:78
bool G4bool
Definition: G4Types.hh:79
#define FALSE
Definition: globals.hh:52
#define TRUE
Definition: globals.hh:55
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G3NegVolPars ( G4double  pars[],
G4int nparpt,
G3VolTableEntry vte,
G3VolTableEntry mvte,
const char  routine[] 
)

Definition at line 181 of file G3NegVolPars.cc.

184 {
185  G4bool NegPresent = FALSE;
186 
187  // retrieve parameters
188 
189  // the volume
190  G4String shape = vte->GetShape();
191  G4double* rpar = vte->GetRpar();
192  G4int npar = vte->GetNpar();
193  if (npar ==0) {
194  // no solid parameters are defined in vte
195  npar = *nparpt;
196  rpar = pars;
197  }
198  else {
199  // solid parameters are already defined in vte
200  // pars[], nparpt are ignored
201  // TO DO: check if g3 ignores them too or resets
202  // vte parameters according to this new ones !!
203  }
204 
205  // mother
206  G4String shapem = mvte->GetShape();
207  G4double* rparm = mvte->GetRpar();
208 
209  if (strcmp(routine,"GSPOS") == 0 || strcmp(routine,"GSVOLU") == 0) {
210  NegPresent = G3CalcParamsFn(rpar,npar,rparm,shape,shapem);
211  }
212  if (strcmp(routine,"GSDVN") == 0) {
213  // just set the flag. The parametrization function figures out
214  // what to do.
215  for (G4int i=0;i<npar;i++) {
216  if (rpar[i] < 0) {
217  NegPresent = TRUE;
218  }
219  }
220  }
221  return NegPresent;
222 }
G4String GetShape()
G4double * GetRpar()
int G4int
Definition: G4Types.hh:78
G4int GetNpar()
bool G4bool
Definition: G4Types.hh:79
#define FALSE
Definition: globals.hh:52
#define TRUE
Definition: globals.hh:55
G4bool G3CalcParamsFn(G4double *rpar, G4int npar, G4double *rparm, G4String shape, G4String shapem)
Definition: G3NegVolPars.cc:37
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function: