Geant4  10.00.p02
G3NegVolPars.cc
Go to the documentation of this file.
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 67982 2013-03-13 10:36:03Z gcosmo $
28 //
29 // modified by I. Hrivnacova, 13.10.99
30 
31 #include "globals.hh"
32 #include "G3VolTable.hh"
33 #include "G4VSolid.hh"
34 #include "G3toG4.hh"
35 #include <cmath>
36 
38  G4String shape, G4String shapem)
39  // Returns true only in case the parameters *after* processing
40  // this method remain negative.
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 }
180 
182  G3VolTableEntry* vte,
183  G3VolTableEntry* mvte, const char routine[])
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 }
G4bool G3NegVolPars(G4double pars[], G4int *nparpt, G3VolTableEntry *vte, G3VolTableEntry *mvte, const char routine[])
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
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4bool G3CalcParamsFn(G4double *rpar, G4int npar, G4double *rparm, G4String shape, G4String shapem)
Definition: G3NegVolPars.cc:37
double G4double
Definition: G4Types.hh:76