Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G3VolTableEntry.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//
28// modified by I.Hrivnacova, 13.10.99
29
30#include "globals.hh"
31#include "G3VolTableEntry.hh"
32#include "G3VolTable.hh"
33#include "G3RotTable.hh"
34#include "G4LogicalVolume.hh"
35#include "G4SubtractionSolid.hh"
36#include "G3Pos.hh"
37#include "G3toG4.hh"
38
40 G4double* rpar, G4int npar, G4int nmed,
41 G4VSolid* solid, G4bool hasNegPars)
42 : fVname(vname), fShape(shape), fRpar(0), fNpar(npar), fNmed(nmed),
43 fSolid(solid), fLV(0), fHasNegPars(hasNegPars), fHasMANY(false),
44 fDivision(0)
45{
46 if (npar>0 && rpar!=0) {
47 fRpar = new G4double[npar];
48 for (G4int i=0; i<npar; i++) fRpar[i] = rpar[i];
49 }
50 fClones.push_back(this);
51}
52
54 if (fRpar!=0) delete [] fRpar;
55 delete fDivision;
56}
57
60 return (this==&lv) ? true : false;
61}
62
63void
65
66 // insert this position to the vector
68 fG3Pos.push_back(aG3Pos);
69
70 // pass MANY info
71 G4String vonly = aG3Pos->GetOnly();
72 if (vonly == "MANY") SetHasMANY(true);
73}
74
75void
77 if (FindDaughter(aDaughter->GetName()) == 0) {
78 fDaughters.push_back(aDaughter);
79 }
80}
81
82void
84 if (FindMother(itsMother->GetName()) == 0) {
85 fMothers.push_back(itsMother);
86 }
87}
88
89void
91 if (FindClone(itsClone->GetName()) == 0) {
92 fClones.push_back(itsClone);
93 }
94}
95
96void
98 fOverlaps.push_back(overlap);
99}
100
101void
103 G3VolTableEntry* vteNew)
104{
105 G4int index = -1;
106 for (G4int i=0; i<GetNoDaughters(); i++){
107 if (fDaughters[i]->GetName() == vteOld->GetName()) index = i;
108 }
109 if (index<0) {
110 G4String err_message = "Old daughter " + vteOld->GetName()
111 + " does not exist.";
112 G4Exception("G3VolTableEntry::ReplaceDaughter()", "G3toG40007",
113 FatalException, err_message);
114 return;
115 }
116 fDaughters[index] = vteNew;
117}
118
119void
121 G3VolTableEntry* vteNew)
122{
123 G4int index = -1;
124 for (G4int i=0; i<GetNoMothers(); i++){
125 if (fMothers[i]->GetName() == vteOld->GetName()) index = i;
126 }
127 if (index<0) {
128 G4String err_message = "Old mother " + vteOld->GetName()
129 + " does not exist.";
130 G4Exception("G3VolTableEntry::ReplaceMother()", "G3toG40008",
131 FatalException, err_message);
132 return;
133 }
134 fMothers[index] = vteNew;
135}
136
139 for (G4int idau=0; idau<GetNoDaughters(); idau++){
140 if (GetDaughter(idau)->GetName() == Dname) return GetDaughter(idau);
141 }
142 return 0;
143}
144
147 for (G4int i=0; i<GetNoMothers(); i++){
148 G3VolTableEntry* mvte = GetMother(i);
149 if (mvte->GetName() == Mname) return mvte;
150 }
151 return 0;
152}
153
156 for (G4int i=0; i<GetNoClones(); i++){
157 G3VolTableEntry* cvte = GetClone(i);
158 if (cvte->GetName() == Cname) return cvte;
159 }
160 return 0;
161}
162
164// only parameters related to solid definition
165// are printed
166 G4cout << "VTE: " << fVname << " " << this << G4endl;
167 G4cout << "Solid: " << fSolid << G4endl;
168 G4cout << "Parameters (npar = " << fNpar << ") fRpar: ";
169 for (G4int i=0; i<fNpar; i++) G4cout << fRpar[i] << " ";
170 G4cout << G4endl;
171 G4cout << "HasNegPars: " << fHasNegPars << G4endl;
172 G4cout << "HasMANY: " << fHasMANY << G4endl;
173 G4cout << "================================= " << G4endl;
174}
175
176void
178 fVname = name;
179}
180
181void
183 fLV = lv;
184}
185
186void
188 fSolid = solid;
189}
190
192 fNmed = nmed;
193}
194
196 if (npar != fNpar) {
197 fNpar = npar;
198 delete [] fRpar;
199 fRpar = new G4double[fNpar];
200 }
201 for (G4int i=0; i<fNpar; i++) fRpar[i] = rpar[i];
202}
203
205 fHasNegPars = hasNegPars;
206}
207
209 fHasMANY = hasMANY;
210}
211
213 if (fG3Pos.size()>0 && copy>=0 && copy<G4int(fG3Pos.size())) {
214 std::vector<G3Pos*>::iterator it=fG3Pos.begin();
215 for(G4int j=0;j<copy;j++) it++;
216 if(it!=fG3Pos.end()) {
217 fG3Pos.erase(it);
218 }
219 }
220}
221
223 delete fDivision;
224 fDivision = 0;
225}
226
229 return fVname;
230}
231
234 return fShape;
235}
236
237G4int
239 return fNmed;
240}
241
242G4int
244 return fNpar;
245}
246
247G4double*
249 return fRpar;
250}
251
252G4int
254 return (G4int)fG3Pos.size();
255}
256
257G3Pos*
259 if (fG3Pos.size()>0 && copy>=0)
260 return fG3Pos[copy];
261 else
262 return 0;
263}
264
265G4bool
267 return fHasNegPars;
268}
269
270G4bool
272 return fHasMANY;
273}
274
277 return fSolid;
278}
279
282 return fLV;
283}
284
285G4int
287 return (G4int)fDaughters.size();
288}
289
290G4int
292 return (G4int)fMothers.size();
293}
294
295G4int
297 return (G4int)fClones.size();
298}
299
300G4int
302 return (G4int)fOverlaps.size();
303}
304
307 if (i<G4int(fDaughters.size()) && i>=0)
308 return fDaughters[i];
309 else
310 return 0;
311}
312
315 if (i<G4int(fMothers.size()) && i>=0)
316 return fMothers[i];
317 else
318 return 0;
319}
320
321// to be removed
324 if (fMothers.size()>0)
325 return fMothers[0];
326 else
327 return 0;
328}
329
332 if (i<G4int(fClones.size()) && i>=0)
333 return fClones[i];
334 else
335 return 0;
336}
337
340 G3VolTableEntry* master;
341 G4String name = fVname;
342 if (G4StrUtil::contains(name, gSeparator)) {
343 name = name.substr(0, name.find(gSeparator));
344 master = G3Vol.GetVTE(name);
345 }
346 else
347 master = this;
348
349 return master;
350}
351
352std::vector<G3VolTableEntry*>*
354 return &fOverlaps;
355}
G3G4DLL_API G3VolTable G3Vol
Definition: clparse.cc:53
G3G4DLL_API char gSeparator
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
Definition: G3Pos.hh:43
G4String & GetOnly()
Definition: G3Pos.cc:77
void AddClone(G3VolTableEntry *aDaughter)
void AddMother(G3VolTableEntry *aDaughter)
std::vector< G3VolTableEntry * > * GetOverlaps()
void SetName(G4String name)
void SetNmed(G4int nmed)
G3VolTableEntry * FindMother(const G4String &vname)
G3VolTableEntry * GetMasterClone()
G4VSolid * GetSolid()
G3VolTableEntry * FindClone(const G4String &vname)
G3VolTableEntry(G4String &vname, G4String &shape, G4double *rpar, G4int npar, G4int nmed, G4VSolid *solid, G4bool hasNegPars)
G3VolTableEntry * FindDaughter(const G4String &vname)
G3VolTableEntry * GetClone(G4int i)
void ReplaceDaughter(G3VolTableEntry *vteOld, G3VolTableEntry *vteNew)
void ReplaceMother(G3VolTableEntry *vteOld, G3VolTableEntry *vteNew)
void AddG3Pos(G3Pos *aG3Pos)
G4bool operator==(const G3VolTableEntry &vte) const
void SetHasNegPars(G4bool hasNegPars)
G4double * GetRpar()
void SetNRpar(G4int npar, G4double *Rpar)
void AddOverlap(G3VolTableEntry *aOverlap)
void ClearG3PosCopy(G4int copy)
void AddDaughter(G3VolTableEntry *aDaughter)
G4LogicalVolume * GetLV()
virtual ~G3VolTableEntry()
void SetSolid(G4VSolid *solid)
G3VolTableEntry * GetMother()
void SetLV(G4LogicalVolume *lv)
G3Pos * GetG3PosCopy(G4int copy=0)
G3VolTableEntry * GetDaughter(G4int i)
void SetHasMANY(G4bool hasMANY)
void CountG3Pos()
Definition: G3VolTable.cc:91
G3VolTableEntry * GetVTE(const G4String &Vname)
Definition: G3VolTable.cc:53
G4bool contains(const G4String &str, std::string_view ss)
Check if a string contains a given substring.