Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4gspos.cc File Reference
#include "G3G4Interface.hh"
#include "G3VolTable.hh"
#include "G3toG4.hh"
#include "G3Pos.hh"
#include "globals.hh"
#include "G4SystemOfUnits.hh"

Go to the source code of this file.

Functions

void G4CreateCloneVTE (G3VolTableEntry *vte, G3VolTableEntry *mvte, G4double pars[], G4int npar, G4int num, G4double x, G4double y, G4double z, G4int irot, G4String vonly)
 
void PG4gspos (G4String *tokens)
 
void G4gspos (G4String vname, G4int num, G4String vmoth, G4double x, G4double y, G4double z, G4int irot, G4String vonly)
 

Function Documentation

◆ G4CreateCloneVTE()

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}
G3G4DLL_API G3VolTable G3Vol
Definition: clparse.cc:54
G4VSolid * G3toG4MakeSolid(const G4String &vname, const G4String &shape, const G4double *Rpar, const G4int npar, G4bool &NegVolPars, G4bool &Deferred, G4bool *OKAxis)
G3G4DLL_API char gSeparator
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
void G4CloneDaughters(G3VolTableEntry *vte, G3VolTableEntry *vteClone)
Definition: G4gsposp.cc:127
G4bool G3NegVolPars(G4double pars[], G4int *nparpt, G3VolTableEntry *vte, G3VolTableEntry *mvte, const char routine[])
void G4ProcessDaughters(G3VolTableEntry *vte)
Definition: G4gsposp.cc:66
Definition: G3Pos.hh:44
void AddClone(G3VolTableEntry *aDaughter)
void AddMother(G3VolTableEntry *aDaughter)
void SetName(G4String name)
G3VolTableEntry * GetClone(G4int i)
void AddG3Pos(G3Pos *aG3Pos)
void SetHasNegPars(G4bool hasNegPars)
G4double * GetRpar()
void AddDaughter(G3VolTableEntry *aDaughter)
void SetSolid(G4VSolid *solid)
G3VolTableEntry * PutVTE(G3VolTableEntry *aVTE)
Definition: G3VolTable.cc:76
G4String & append(const G4String &)

Referenced by G4gspos(), and G4gsposp().

◆ G4gspos()

void G4gspos ( G4String  vname,
G4int  num,
G4String  vmoth,
G4double  x,
G4double  y,
G4double  z,
G4int  irot,
G4String  vonly 
)

Definition at line 65 of file G4gspos.cc.

67{
68 // find VTEs
69 G3VolTableEntry* vte = G3Vol.GetVTE(vname);
70 G3VolTableEntry* mvte = G3Vol.GetVTE(vmoth);
71
72 if (vte == 0) {
73 G4String text = "G4gspos: '" + vname + "' has no VolTableEntry";
74 G4Exception("G4gspos()", "G3toG40017", FatalException, text);
75 return;
76 }
77 else if (mvte == 0) {
78 G4String text = "G4gspos: '" + vmoth + "' has no VolTableEntry";
79 G4Exception("G4gspos()", "G3toG40018", FatalException, text);
80 return;
81 }
82 else {
83 if (!vte->HasNegPars()) {
84 // position vector
85 G4ThreeVector* offset = new G4ThreeVector(x*cm, y*cm, z*cm);
86
87 // create a G3Pos object and add it to the vte
88 G3Pos* aG3Pos = new G3Pos(vmoth, num, offset, irot, vonly);
89 vte->AddG3Pos(aG3Pos);
90
91 // loop over all mothers
92 for (G4int i=0; i<mvte->GetNoClones(); i++) {
93 // (mvte is retrieved from its "master" name
94 // -> there is no need to call GetMasterClone()
95 G3VolTableEntry* mvteClone = mvte->GetClone(i);
96 vte->AddMother(mvteClone);
97 mvteClone->AddDaughter(vte);
98 }
99 }
100 else {
101 // if vte has neg parameters
102 // a new vte clone copy is created for each mother (clone copy)
103 // and its parameters are derived from it if possible
104
105 G4CreateCloneVTE(vte, mvte, vte->GetRpar(), vte->GetNpar(), num,
106 x, y, z, irot, vonly);
107 }
108 }
109}
@ FatalException
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
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

Referenced by PG4gspos().

◆ PG4gspos()

void PG4gspos ( G4String tokens)

Definition at line 42 of file G4gspos.cc.

43{
44 // fill the parameter containers
45 G3fillParams(tokens,PTgspos);
46
47 // interpret the parameters
48 G4String name = Spar[0];
49 G4String moth = Spar[1];
50 G4String only = Spar[2];
51 G4int num = Ipar[0];
52 G4int irot = Ipar[1];
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
62 G4gspos(name, num, moth, x, y, z, irot, only);
63}
G3G4DLL_API G4int Ipar[1000]
Definition: clparse.cc:66
void G3fillParams(G4String *tokens, const char *ptypes)
Definition: clparse.cc:219
G3G4DLL_API G4double Rpar[1000]
Definition: clparse.cc:67
G3G4DLL_API G4String Spar[1000]
Definition: clparse.cc:68
#define PTgspos
Definition: G3toG4.hh:53
void G4gspos(G4String vname, G4int num, G4String vmoth, G4double x, G4double y, G4double z, G4int irot, G4String vonly)
Definition: G4gspos.cc:65

Referenced by G3CLEval().