Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4tgrLineProcessor.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// class G4tgrLineProcessor
29
30// History:
31// - Created. P.Arce, CIEMAT (November 2007)
32// -------------------------------------------------------------------------
33
34#include "G4tgrLineProcessor.hh"
35
36#include "G4SystemOfUnits.hh"
37#include "G4tgrParameterMgr.hh"
38#include "G4tgrFileIn.hh"
39#include "G4tgrElementSimple.hh"
41#include "G4tgrVolume.hh"
44#include "G4tgrPlaceDivRep.hh"
46#include "G4tgrVolumeMgr.hh"
47#include "G4tgrUtils.hh"
50#include "G4tgrMessenger.hh"
51
52
53//---------------------------------------------------------------
55{
57}
58
59
60//---------------------------------------------------------------
62{
63}
64
65
66//---------------------------------------------------------------
67G4bool G4tgrLineProcessor::ProcessLine( const std::vector<G4String>& wl )
68{
69#ifdef G4VERBOSE
71 {
72 G4tgrUtils::DumpVS(wl, "@@@ Processing input line");
73 }
74#endif
75
76 G4String wl0 = wl[0];
77 for( size_t ii = 0; ii < wl0.length(); ii++ )
78 {
79 wl0[ii] = toupper( wl0[ii] );
80 }
81
82 //------------------------------- parameter number
83 if( wl0 == ":P" )
84 {
86
87 //------------------------------- parameter string
88 }
89 else if( wl0 == ":PS" )
90 {
92
93 //------------------------------- isotope
94 }
95 else if( wl0 == ":ISOT" )
96 {
98 ->AddIsotope( wl );
99 volmgr->RegisterMe( isot );
100
101 //------------------------------- element
102 }
103 else if( wl0 == ":ELEM" )
104 {
106 ->AddElementSimple( wl );
107 volmgr->RegisterMe( elem );
108
109 //------------------------------- element from isotopes
110 }
111 else if( wl0 == ":ELEM_FROM_ISOT" )
112 {
113 //:ELEM_FROM_ISOT NAME SYMBOL N_ISOT (ISOT_NAME ISOT_ABUNDANCE)
116 volmgr->RegisterMe( elem );
117
118 //------------------------------- material
119 }
120 else if( wl0 == ":MATE" )
121 {
122
124 ->AddMaterialSimple( wl );
125 volmgr->RegisterMe( mate );
126
127 //------------------------------- material mixtures & by weight
128 }
129 else if( (wl0 == ":MIXT") || (wl0 == ":MIXT_BY_WEIGHT") )
130 {
132 ->AddMaterialMixture( wl, "MaterialMixtureByWeight" );
133 volmgr->RegisterMe( mate );
134
135 //------------------------------- material mixture by number of atoms
136 }
137 else if( wl0 == ":MIXT_BY_NATOMS" )
138 {
140 ->AddMaterialMixture(wl, "MaterialMixtureByNoAtoms");
141 volmgr->RegisterMe( mate );
142
143 //------------------------------- material mixture by volume
144 }
145 else if( wl0 == ":MIXT_BY_VOLUME" )
146 {
148 ->AddMaterialMixture( wl, "MaterialMixtureByVolume" );
149 volmgr->RegisterMe( mate );
150
151 //------------------------------- material Mean Excitation Energy of
152 // Ionisation Potential
153 }
154 else if( wl0 == ":MATE_MEE" )
155 {
158 if( mate == 0 )
159 {
160 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found",
162 return false;
163 }
165
166 //------------------------------- material
167 }
168 else if( wl0 == ":MATE_STATE" )
169 {
172 if( mate == 0 )
173 {
174 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found",
175 FatalException, wl[1] );
176 }
177 mate->SetState( wl[2] );
178
179 //------------------------------- material
180 }
181 else if( wl0 == ":MATE_TEMPERATURE" )
182 {
185 if( mate == 0 )
186 {
187 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found",
188 FatalException, wl[1] );
189 }
190 mate->SetTemperature( G4tgrUtils::GetDouble( wl[2], kelvin ) );
191
192 //------------------------------- material
193 }
194 else if( wl0 == ":MATE_PRESSURE" )
195 {
198 if( mate == 0 )
199 {
200 G4Exception("G4tgrLineProcessor::ProcessLine()", "Material not found",
201 FatalException, wl[1] );
202 }
203 mate->SetPressure( G4tgrUtils::GetDouble( wl[2], atmosphere ) );
204
205 //------------------------------- solid
206 }
207 else if( wl0 == ":SOLID" )
208 { // called from here or from G4tgrVolume::G4tgrVolume
209 volmgr->CreateSolid( wl, 0 );
210
211 //------------------------------- volume
212 }
213 else if( wl0 == ":VOLU" )
214 {
215 G4tgrVolume* vol = new G4tgrVolume( wl );
216 volmgr->RegisterMe( vol );
217
218 //--------------------------------- single placement
219 }
220 else if( wl0 == ":PLACE" )
221 {
223 G4tgrPlace* vpl = vol->AddPlace( wl );
224 volmgr->RegisterMe( vpl );
225
226 //--------------------------------- parameterisation
227 }
228 else if( wl0 == ":PLACE_PARAM" )
229 {
232 volmgr->RegisterMe( vpl );
233
234 //--------------------------------- division
235 }
236 else if( (wl0 == ":DIV_NDIV") || (wl0 == ":DIV_WIDTH")
237 || (wl0 == ":DIV_NDIV_WIDTH") )
238 {
239 //---------- Create G4tgrVolumeDivision and fill the volume params
241 volmgr->RegisterMe( vol );
242
243 //--------------------------------- replica
244 }
245 else if( wl0 == ":REPL" )
246 {
248 G4tgrPlaceDivRep* vpl = vol->AddPlaceReplica( wl );
249 volmgr->RegisterMe( vpl );
250
251 //----------------------------- assembly volume: definition of components
252 }
253 else if( wl0 == ":VOLU_ASSEMBLY" )
254 {
256 volmgr->RegisterMe( vol );
257
258 //----------------------------- assembly volume: definition of components
259 }
260 else if( wl0 == ":PLACE_ASSEMBLY" )
261 {
263 G4tgrPlace* vpl = vol->AddPlace( wl );
264 volmgr->RegisterMe( vpl );
265
266 //--------------------------------- rotation matrix
267 }
268 else if( wl0 == ":ROTM" )
269 {
270 //---------- When second word is ':NEXT/:MNXT' it is used for defining a
271 // rotation matrix that will be used for the next placement/s
273 ->AddRotMatrix( wl );
274 volmgr->RegisterMe( rm );
275
276 //------------------------------- visualisation
277 }
278 else if( wl0 == ":VIS" )
279 {
280 std::vector<G4tgrVolume*> vols =
281 volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
282 for( size_t ii = 0; ii < vols.size(); ii++ )
283 {
284 vols[ii]->AddVisibility( wl );
285 }
286
287 //--------------------------------- colour
288 }
289 else if( (wl0 == ":COLOUR") || (wl0 == ":COLOR") )
290 {
291 std::vector<G4tgrVolume*> vols =
292 volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
293 for( size_t ii = 0; ii < vols.size(); ii++ )
294 {
295 vols[ii]->AddRGBColour( wl );
296 }
297
298 //--------------------------------- check overlaps
299 }
300 else if( wl0 == ":CHECK_OVERLAPS" )
301 {
302 std::vector<G4tgrVolume*> vols =
303 volmgr->FindVolumes( G4tgrUtils::GetString( wl[1] ), 1 );
304 for( size_t ii = 0; ii < vols.size(); ii++ )
305 {
306 vols[ii]->AddCheckOverlaps( wl );
307 }
308 //--------------------------------- ERROR
309 }
310 else
311 {
312 return 0;
313 }
314
315 return 1;
316}
317
318
319//---------------------------------------------------------------
321{
322 G4tgrVolume* vol = volmgr->FindVolume( volname, 1);
323
324 if( vol->GetType() == "VOLDivision" )
325 {
326 G4Exception("G4tgrLineProcessor::FindVolume()",
327 "InvalidSetup", FatalException,
328 "Using 'PLACE' for a volume created by a division !");
329 }
330
331 return vol;
332}
@ FatalException
bool G4bool
Definition: G4Types.hh:67
virtual G4bool ProcessLine(const std::vector< G4String > &wl)
G4tgrVolume * FindVolume(const G4String &volname)
G4tgrMaterial * FindMaterial(const G4String &name) const
static G4tgrMaterialFactory * GetInstance()
G4tgrElementFromIsotopes * AddElementFromIsotopes(const std::vector< G4String > &wl)
G4tgrElementSimple * AddElementSimple(const std::vector< G4String > &wl)
G4tgrMaterialMixture * AddMaterialMixture(const std::vector< G4String > &wl, const G4String &mixtType)
G4tgrIsotope * AddIsotope(const std::vector< G4String > &wl)
G4tgrMaterialSimple * AddMaterialSimple(const std::vector< G4String > &wl)
void SetState(G4String val)
void SetTemperature(G4double val)
void SetPressure(G4double val)
void SetIonisationMeanExcitationEnergy(G4double mee)
static G4int GetVerboseLevel()
void AddParameterNumber(const std::vector< G4String > &wl, G4bool mustBeNew=0)
void AddParameterString(const std::vector< G4String > &wl, G4bool mustBeNew=0)
static G4tgrParameterMgr * GetInstance()
G4tgrRotationMatrix * AddRotMatrix(const std::vector< G4String > &wl)
static G4tgrRotationMatrixFactory * GetInstance()
static G4String GetString(const G4String &str)
Definition: G4tgrUtils.cc:178
static void DumpVS(const std::vector< G4String > &wl, const char *msg)
Definition: G4tgrUtils.cc:156
static G4double GetDouble(const G4String &str, G4double unitval=1.)
Definition: G4tgrUtils.cc:203
std::vector< G4tgrVolume * > FindVolumes(const G4String &volname, G4bool exists)
G4tgrVolume * FindVolume(const G4String &volname, G4bool exists=false)
void RegisterMe(G4tgrSolid *vol)
G4tgrSolid * CreateSolid(const std::vector< G4String > &wl, G4bool bVOLUtag)
static G4tgrVolumeMgr * GetInstance()
virtual G4tgrPlace * AddPlace(const std::vector< G4String > &wl)
Definition: G4tgrVolume.cc:138
G4tgrPlaceParameterisation * AddPlaceParam(const std::vector< G4String > &wl)
Definition: G4tgrVolume.cc:218
G4tgrPlaceDivRep * AddPlaceReplica(const std::vector< G4String > &wl)
Definition: G4tgrVolume.cc:180
const G4String & GetType() const
Definition: G4tgrVolume.hh:91
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41