Geant4-11
G4EzWorld.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// G4EzWorld.cc
28//
29// 2005 Q
30// ====================================================================
31#include "G4EzWorld.hh"
32#include "G4Element.hh"
33#include "G4Material.hh"
34#include "G4Box.hh"
35#include "G4LogicalVolume.hh"
36#include "G4PVPlacement.hh"
37#include "G4VisAttributes.hh"
38#include "G4RunManager.hh"
40
42
43// ====================================================================
44//
45// class description
46//
47// ====================================================================
48
52{
53}
54
58{
59 world= 0;
60}
61
62
65 (G4double dx, G4double dy, G4double dz)
67{
68 // default matetial is "vacuum"
69 G4Material* vacuum= G4Material::GetMaterial("_Vacuum", false);
70
71 if(vacuum==0) {
72 G4Element* elN= new G4Element("_N", "", 7., 14.00674*g/mole);
73 G4Element* elO= new G4Element("_O", "", 8., 15.9994*g/mole);
74
75 vacuum= new G4Material("_Vacuum", universe_mean_density, 2);
76 vacuum-> AddElement(elN, 0.7);
77 vacuum-> AddElement(elO, 0.3);
78 }
79
80 G4Box* sdworld= new G4Box("world", dx/2., dy/2., dz/2.);
81 G4LogicalVolume* lvworld= new G4LogicalVolume(sdworld, vacuum, "word");
82 G4PVPlacement* aworld= new G4PVPlacement(0, G4ThreeVector(), "world",
83 lvworld, 0, false, 0);
84
85 // vis. attributes
86 G4VisAttributes* vaworld= new G4VisAttributes(G4Color(1.,1.,1.));
87 vaworld-> SetForceWireframe(true);
88 lvworld-> SetVisAttributes(vaworld);
89
90 return aworld;
91
92}
93
94
98{
99 delete world;
100 world= CreateWorld(dx, dy, dz);
101
103 runManager-> DefineWorldVolume(world);
104}
105
106
110{
111 G4Box* box= dynamic_cast<G4Box*>(world-> GetLogicalVolume()-> GetSolid());
112 box-> SetXHalfLength(dx/2.);
113 box-> SetYHalfLength(dy/2.);
114 box-> SetZHalfLength(dz/2.);
115
117 runManager-> GeometryHasBeenModified();
118}
119
120
124{
125 world-> GetLogicalVolume()-> SetMaterial(amaterial);
126}
127
128
132{
133 G4VisAttributes* vaworld= const_cast<G4VisAttributes*>(
134 world-> GetLogicalVolume()-> GetVisAttributes());
135 vaworld-> SetVisibility(qvis);
136}
137
G4Colour G4Color
Definition: G4Color.hh:41
static constexpr double mole
Definition: G4SIunits.hh:279
static constexpr double g
Definition: G4SIunits.hh:168
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
Definition: G4Box.hh:56
static G4VPhysicalVolume * CreateWorld(G4double dx=1.*m, G4double dy=1.*m, G4double dz=1.*m)
Definition: G4EzWorld.cc:65
static void SetVisibility(G4bool qvis)
Definition: G4EzWorld.cc:130
~G4EzWorld()
Definition: G4EzWorld.cc:56
static void Resize(G4double dx, G4double dy, G4double dz)
Definition: G4EzWorld.cc:108
static void SetMaterial(G4Material *amaterial)
Definition: G4EzWorld.cc:122
static void Reset(G4double dx, G4double dy, G4double dz)
Definition: G4EzWorld.cc:96
static G4VPhysicalVolume * world
Definition: G4EzWorld.hh:52
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:686
static G4RunManager * GetRunManager()
int universe_mean_density
Definition: hepunit.py:306