LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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"
39 #include "G4PhysicalConstants.hh"
40 
41 G4VPhysicalVolume* G4EzWorld::world= G4EzWorld::CreateWorld();
42 
43 // ====================================================================
44 //
45 // class description
46 //
47 // ====================================================================
48 
52 {
53 }
54 
58 {
59  world= 0;
60 }
61 
62 
64 G4VPhysicalVolume* G4EzWorld::CreateWorld
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 
96 void G4EzWorld::Reset(G4double dx, G4double dy, G4double dz)
98 {
99  delete world;
100  world= CreateWorld(dx, dy, dz);
101 
102  G4RunManager* runManager= G4RunManager::GetRunManager();
103  runManager-> DefineWorldVolume(world);
104 }
105 
106 
108 void G4EzWorld::Resize(G4double dx, G4double dy, G4double dz)
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 
116  G4RunManager* runManager= G4RunManager::GetRunManager();
117  runManager-> GeometryHasBeenModified();
118 }
119 
120 
122 void G4EzWorld::SetMaterial(G4Material* amaterial)
124 {
125  world-> GetLogicalVolume()-> SetMaterial(amaterial);
126 }
127 
128 
130 void G4EzWorld::SetVisibility(G4bool qvis)
132 {
133  G4VisAttributes* vaworld= const_cast<G4VisAttributes*>(
134  world-> GetLogicalVolume()-> GetVisAttributes());
135  vaworld-> SetVisibility(qvis);
136 }
137 
static G4VPhysicalVolume * CreateWorld(G4double dx=1.*m, G4double dy=1.*m, G4double dz=1.*m)
Definition: G4EzWorld.cc:65
static void Resize(G4double dx, G4double dy, G4double dz)
Definition: G4EzWorld.cc:108
~G4EzWorld()
Definition: G4EzWorld.cc:56
static void Reset(G4double dx, G4double dy, G4double dz)
Definition: G4EzWorld.cc:96
static G4VPhysicalVolume * world
Definition: G4EzWorld.hh:52
static void SetVisibility(G4bool qvis)
Definition: G4EzWorld.cc:130
static void SetMaterial(G4Material *amaterial)
Definition: G4EzWorld.cc:122