Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4gsposp.cc File Reference
#include "G3G4Interface.hh"
#include "G3toG4.hh"
#include "G3VolTable.hh"
#include "G3toG4MakeSolid.hh"
#include "G3Division.hh"
#include "G4SystemOfUnits.hh"
#include "G4VSolid.hh"
Include dependency graph for G4gsposp.cc:

Go to the source code of this file.

Functions

G4bool G3NegVolPars (G4double pars[], G4int *nparpt, G3VolTableEntry *vte, G3VolTableEntry *mvte, const char routine[])
 
void PG4gsposp (G4String *tokens)
 
void G4ProcessDaughters (G3VolTableEntry *vte)
 
void G4CloneDaughters (G3VolTableEntry *vte, G3VolTableEntry *vteClone)
 
void G4CreateCloneVTE (G3VolTableEntry *vte, G3VolTableEntry *mvte, G4double pars[], G4int npar, G4int num, G4double x, G4double y, G4double z, G4int irot, G4String vonly)
 
void G4gsposp (G4String vname, G4int num, G4String vmoth, G4double x, G4double y, G4double z, G4int irot, G4String vonly, G4double pars[], G4int npar)
 

Function Documentation

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:

void G4CloneDaughters ( G3VolTableEntry vte,
G3VolTableEntry vteClone 
)

Definition at line 127 of file G4gsposp.cc.

131 {
132  G4int nofDaughters = vte->GetNoDaughters();
133  if (nofDaughters>0)
134  for (G4int id=0; id<nofDaughters; id++) {
135  G3VolTableEntry* dvte = vte->GetDaughter(id);
136 
137  if (dvte->HasNegPars() || dvte->GetDivision()){
138  // create new dvteClone with Position/Division
139  // and set it to vteClone
140 
141  // get master of dvte
142  G3VolTableEntry* dvteMaster = dvte->GetMasterClone();
143 
144  // generate vteClone name
145  G4int cloneNo = dvteMaster->GetNoClones();
146  char index[5]; sprintf(index,"%d",cloneNo);
147  G4String newName = dvteMaster->GetName();
148  newName.append(gSeparator); newName = newName + index;
149 
150  // create dvteClone
151  G4String dvteShape = dvte->GetShape();
152  G4double* dvteRpar = dvte->GetRpar();
153  G4int dvteNpar = dvte->GetNpar();
154  G4int dvteNmed = dvte->GetNmed();
155  G4bool hasNegPars = dvte->HasNegPars();
156  G3VolTableEntry* dvteClone
157  = new G3VolTableEntry(newName, dvteShape, dvteRpar, dvteNpar,
158  dvteNmed, 0, hasNegPars);
159 
160  // let dvte master and vol table know about it
161  G3Vol.PutVTE(dvteClone);
162  dvteMaster->AddClone(dvteClone);
163 
164  // set mother daughter
165  vteClone->AddDaughter(dvteClone);
166  dvteClone->AddMother(vteClone);
167 
168  // copy positions
169  G4int nofPositions = dvte->NPCopies();
170  for (G4int ip=0; ip<nofPositions; ip++)
171  dvteClone->AddG3Pos(dvte->GetG3PosCopy(ip));
172 
173  // copy division
174  G3Division* dvteDivision = dvte->GetDivision();
175  if (dvteDivision) {
176  G3Division* dvteCloneDivision
177  = new G3Division(dvteClone, vteClone, *dvteDivision);
178  dvteClone->SetDivision(dvteCloneDivision);
179  dvteCloneDivision->UpdateVTE();
180  }
181 
182  // clone daughters recursively
183  G4CloneDaughters(dvte, dvteClone);
184  }
185  else {
186  // set dvte to vteClone
187  vteClone->AddDaughter(dvte);
188  dvte->AddMother(vteClone);
189  }
190  }
191 }
G3Pos * GetG3PosCopy(G4int copy=0)
void UpdateVTE()
Definition: G3Division.cc:97
G3Division * GetDivision()
G3VolTableEntry * GetMasterClone()
void G4CloneDaughters(G3VolTableEntry *vte, G3VolTableEntry *vteClone)
Definition: G4gsposp.cc:127
void SetDivision(G3Division *division)
G4String GetShape()
G4double * GetRpar()
G4int NPCopies()
int G4int
Definition: G4Types.hh:78
G4int GetNoClones()
G3VolTableEntry * GetDaughter(G4int i)
G4int GetNoDaughters()
G4int GetNpar()
bool G4bool
Definition: G4Types.hh:79
G4int GetNmed()
void AddG3Pos(G3Pos *aG3Pos)
void AddMother(G3VolTableEntry *aDaughter)
G4String & append(const G4String &)
G4String GetName()
G4bool HasNegPars()
void AddClone(G3VolTableEntry *aDaughter)
G3G4DLL_API char gSeparator
G3VolTableEntry * PutVTE(G3VolTableEntry *aVTE)
Definition: G3VolTable.cc:76
double G4double
Definition: G4Types.hh:76
G3G4DLL_API G3VolTable G3Vol
Definition: clparse.cc:54
void AddDaughter(G3VolTableEntry *aDaughter)

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CreateCloneVTE ( G3VolTableEntry vte,
G3VolTableEntry mvte,
G4double  pars[],
G4int  npar,
G4int  num,
G4double  x,
G4double  y,
G4double  z,
G4int  irot,
G4String  vonly 
)

Definition at line 193 of file G4gsposp.cc.

199 {
200  // create a G3Pos
201  G4ThreeVector* offset = new G4ThreeVector(x*cm, y*cm, z*cm);
202  G3Pos* aG3Pos = new G3Pos(mvte->GetName(), num, offset, irot, vonly);
203 
204  // loop over all mothers
205  for (G4int i=0; i<mvte->GetNoClones(); i++) {
206  // mvte was retrieved from its "master" name
207  // -> there is no need to call GetMasterClone()
208  G3VolTableEntry* mvteClone = mvte->GetClone(i);
209 
210  G4String tmpName = "TRY";
211  G4String vteShape = vte->GetShape();
212  G3VolTableEntry* vteClone
213  = new G3VolTableEntry(tmpName, vteShape, pars, npar, vte->GetNmed(),
214  0, true);
215 
216  // negative parameters will be updated only
217  // for vteClone, pars are unchanged
218  G4double* clonePars = vteClone->GetRpar();
219  G4int cloneNpar = vteClone->GetNpar();
220  G4bool negpars
221  = G3NegVolPars(clonePars, &cloneNpar, vteClone, mvteClone, "GSPOS");
222  vteClone->SetHasNegPars(negpars);
223 
224  G3VolTableEntry* vteSameClone = 0;
225  G4VSolid* solid = 0;
226  if (!negpars) {
227  // check if vteClone with the same parameters exist
228  for (G4int ic=0; ic<vte->GetNoClones(); ic++) {
229  G3VolTableEntry* checkClone = vte->GetClone(ic);
230  G4int checkNpar = checkClone->GetNpar();
231  G4double* checkPars = checkClone->GetRpar();
232 
233  G4bool isSame;
234  if (checkNpar != cloneNpar)
235  isSame = false;
236  else {
237  isSame = true;
238  for (G4int ip=0; ip<cloneNpar; ip++)
239  if (checkPars[ip] != clonePars[ip]) {
240  isSame = false;
241  break;
242  }
243  }
244  if (isSame) { vteSameClone = checkClone; break; }
245  }
246 
247  if (vteSameClone) {
248  delete vteClone;
249 
250  // add aG3Pos to the vteClone
251  vteSameClone->AddG3Pos(aG3Pos);
252  mvteClone->AddDaughter(vteSameClone);
253  vteSameClone->AddMother(mvteClone);
254  }
255  else {
256  // create the solid
257  G4bool hasNegPars;
258  G4bool deferred;
259  G4bool okAxis[3];
260  G4String vteName = vte->GetName();
261  G4String cloneShape = vteClone->GetShape();
262  solid = G3toG4MakeSolid(vteName, cloneShape, clonePars, cloneNpar,
263  hasNegPars, deferred, okAxis);
264  }
265  }
266 
267  if ( negpars || !(vteSameClone)) {
268  // generate vteClone name
269  G4int cloneNo = vte->GetNoClones();
270  char index[5]; sprintf(index,"%d",cloneNo);
271  G4String newName = vte->GetName();
272  newName.append(gSeparator); newName = newName + index;
273 
274  // update vteClone
275  vteClone->SetName(newName);
276  vteClone->SetSolid(solid);
277  vteClone->SetHasNegPars(negpars);
278 
279  // let vte and vol table know about it
280  G3Vol.PutVTE(vteClone);
281  vte->AddClone(vteClone);
282 
283  // add aG3Pos to the vteClone
284  vteClone->AddG3Pos(aG3Pos);
285  mvteClone->AddDaughter(vteClone);
286  vteClone->AddMother(mvteClone);
287 
288  // copy all daughters
289  G4CloneDaughters(vte, vteClone);
290 
291  // retrieve daughters parameters
292  if (!negpars) G4ProcessDaughters(vteClone);
293  }
294  }
295 }
CLHEP::Hep3Vector G4ThreeVector
G4bool G3NegVolPars(G4double pars[], G4int *nparpt, G3VolTableEntry *vte, G3VolTableEntry *mvte, const char routine[])
Definition: G3Pos.hh:43
void G4CloneDaughters(G3VolTableEntry *vte, G3VolTableEntry *vteClone)
Definition: G4gsposp.cc:127
void G4ProcessDaughters(G3VolTableEntry *vte)
Definition: G4gsposp.cc:66
G4String GetShape()
G4double * GetRpar()
tuple x
Definition: test.py:50
G3VolTableEntry * GetClone(G4int i)
int G4int
Definition: G4Types.hh:78
G4int GetNoClones()
void SetName(G4String name)
G4int GetNpar()
bool G4bool
Definition: G4Types.hh:79
static constexpr double cm
Definition: G4SIunits.hh:119
void SetHasNegPars(G4bool hasNegPars)
void SetSolid(G4VSolid *solid)
G4int GetNmed()
G4VSolid * G3toG4MakeSolid(const G4String &vname, const G4String &shape, const G4double *Rpar, const G4int npar, G4bool &NegVolPars, G4bool &Deferred, G4bool *OKAxis)
void AddG3Pos(G3Pos *aG3Pos)
void AddMother(G3VolTableEntry *aDaughter)
G4String & append(const G4String &)
G4String GetName()
tuple z
Definition: test.py:28
void AddClone(G3VolTableEntry *aDaughter)
G3G4DLL_API char gSeparator
G3VolTableEntry * PutVTE(G3VolTableEntry *aVTE)
Definition: G3VolTable.cc:76
double G4double
Definition: G4Types.hh:76
unsigned offset
Definition: inflate.h:102
G3G4DLL_API G3VolTable G3Vol
Definition: clparse.cc:54
void AddDaughter(G3VolTableEntry *aDaughter)

Here is the call graph for this function:

Here is the caller graph for this function:

void G4gsposp ( G4String  vname,
G4int  num,
G4String  vmoth,
G4double  x,
G4double  y,
G4double  z,
G4int  irot,
G4String  vonly,
G4double  pars[],
G4int  npar 
)

Definition at line 297 of file G4gsposp.cc.

300 {
301  // find VTEs
302  G3VolTableEntry* vte = G3Vol.GetVTE(vname);
303  G3VolTableEntry* mvte = G3Vol.GetVTE(vmoth);
304 
305  if (vte == 0) {
306  G4String err_message1 = "G4gsposp: '" + vname + "' has no VolTableEntry";
307  G4Exception("G4psposp()", "G3toG40021", FatalException, err_message1);
308  return;
309  }
310  if (mvte == 0) {
311  G4String err_message2 = "G4gsposp: '" + vmoth + "' has no VolTableEntry";
312  G4Exception("G4psposp()", "G3toG40022", FatalException, err_message2);
313  return;
314  }
315  else {
316  // a new vte clone copy is created for each mother (clone copy)
317  // and its parameters are derived from it if possible
318 
319  G4CreateCloneVTE(vte, mvte, pars, npar, num, x, y, z, irot, vonly);
320  }
321 }
tuple x
Definition: test.py:50
G3VolTableEntry * GetVTE(const G4String &Vname)
Definition: G3VolTable.cc:54
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
tuple z
Definition: test.py:28
void G4CreateCloneVTE(G3VolTableEntry *vte, G3VolTableEntry *mvte, G4double pars[], G4int npar, G4int num, G4double x, G4double y, G4double z, G4int irot, G4String vonly)
Definition: G4gsposp.cc:193
G3G4DLL_API G3VolTable G3Vol
Definition: clparse.cc:54

Here is the call graph for this function:

Here is the caller graph for this function:

void G4ProcessDaughters ( G3VolTableEntry vte)

Definition at line 66 of file G4gsposp.cc.

69 {
70  if (vte->HasNegPars()) {
71  G4cerr << " Warning:" << G4endl;
72  G4cerr << " G4ProcessDaughters: Ignored (vte has negative parameters)."
73  << G4endl;
74  }
75  else {
76  for (G4int i=0; i<vte->GetNoDaughters(); i++) {
77 
78  G3VolTableEntry* dvte = vte->GetDaughter(i);
79 
80  if (dvte->HasNegPars()) {
81  if (dvte->GetDivision()) {
82  // call division method for creating solid and updating
83  // dvte parameters
84  dvte->GetDivision()->UpdateVTE();
85  }
86  else {
87  // update negative parameters
88  G4double* pars = dvte->GetRpar();
89  G4int npar = dvte->GetNpar();
90  G4bool negpars
91  = G3NegVolPars(pars,&npar, dvte, vte, "GSPOS");
92 
93  if (negpars) {
94  G4String text = "G3NegVolPars still returns negative parameters!";
95  G4Exception("G4ProcessDaughters()", "G3toG40019",
96  FatalException, text);
97  return;
98  }
99 
100  // create solid
101  G4bool hasNegPars;
102  G4bool deferred;
103  G4bool okAxis[3];
104  G4VSolid* solid
105  = G3toG4MakeSolid(dvte->GetName(), dvte->GetShape(), pars, npar,
106  hasNegPars, deferred, okAxis);
107  if (hasNegPars) {
108  G4String text = "G3toG4MakeSolid still returns negative parameters!";
109  G4Exception("G4ProcessDaughters()", "G3toG40020",
110  FatalException, text);
111  return;
112  }
113 
114  // update dvte
115  dvte->SetNRpar(npar, pars);
116  dvte->SetSolid(solid);
117  dvte->SetHasNegPars(hasNegPars);
118  }
119 
120  // process daughters
121  G4ProcessDaughters(dvte);
122  }
123  }
124  }
125 }
void UpdateVTE()
Definition: G3Division.cc:97
G3Division * GetDivision()
G4bool G3NegVolPars(G4double pars[], G4int *nparpt, G3VolTableEntry *vte, G3VolTableEntry *mvte, const char routine[])
void G4ProcessDaughters(G3VolTableEntry *vte)
Definition: G4gsposp.cc:66
G4String GetShape()
G4double * GetRpar()
int G4int
Definition: G4Types.hh:78
G3VolTableEntry * GetDaughter(G4int i)
G4int GetNoDaughters()
G4int GetNpar()
bool G4bool
Definition: G4Types.hh:79
void SetNRpar(G4int npar, G4double *Rpar)
void SetHasNegPars(G4bool hasNegPars)
void SetSolid(G4VSolid *solid)
G4VSolid * G3toG4MakeSolid(const G4String &vname, const G4String &shape, const G4double *Rpar, const G4int npar, G4bool &NegVolPars, G4bool &Deferred, G4bool *OKAxis)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4String GetName()
G4bool HasNegPars()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

void PG4gsposp ( G4String tokens)

Definition at line 42 of file G4gsposp.cc.

42  {
43  // fill the parameter containers
44  G3fillParams(tokens,PTgsposp);
45 
46  // interpret the parameters
47  G4String name = Spar[0];
48  G4String moth = Spar[1];
49  G4String only = Spar[2];
50  G4int num = Ipar[0];
51  G4int irot = Ipar[1];
52  G4int npar = Ipar[2];
53  // all parameters are passed to G4gsxxx methods
54  // in G3 default units
55  //G4double x = Rpar[0]*cm;
56  //G4double y = Rpar[1]*cm;
57  //G4double z = Rpar[2]*cm;
58  G4double x = Rpar[0];
59  G4double y = Rpar[1];
60  G4double z = Rpar[2];
61  G4double *pars = &Rpar[3];
62 
63  G4gsposp(name, num, moth, x, y, z, irot, only, pars, npar);
64 }
G3G4DLL_API G4double Rpar[1000]
Definition: clparse.cc:67
const XML_Char * name
Definition: expat.h:151
tuple x
Definition: test.py:50
void G3fillParams(G4String *tokens, const char *ptypes)
Definition: clparse.cc:219
int G4int
Definition: G4Types.hh:78
G3G4DLL_API G4String Spar[1000]
Definition: clparse.cc:68
G3G4DLL_API G4int Ipar[1000]
Definition: clparse.cc:66
void G4gsposp(G4String name, G4int num, G4String moth, G4double x, G4double y, G4double z, G4int irot, G4String only, G4double Rpar[], G4int npar)
Definition: G4gsposp.cc:297
tuple z
Definition: test.py:28
#define PTgsposp
Definition: G3toG4.hh:54
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function: