Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // $Id: G4EzWorld.cc,v 1.1 2008-12-01 07:07:34 kmura Exp $
27 // $Name: not supported by cvs2svn $
28 // ====================================================================
29 // G4EzWorld.cc
30 //
31 // 2005 Q
32 // ====================================================================
33 #include "G4EzWorld.hh"
34 #include "G4Element.hh"
35 #include "G4Material.hh"
36 #include "G4Box.hh"
37 #include "G4LogicalVolume.hh"
38 #include "G4PVPlacement.hh"
39 #include "G4VisAttributes.hh"
40 #include "G4RunManager.hh"
41 #include "G4PhysicalConstants.hh"
42 
44 
45 // ====================================================================
46 //
47 // class description
48 //
49 // ====================================================================
50 
54 {
55 }
56 
60 {
61  world= 0;
62 }
63 
64 
67  (G4double dx, G4double dy, G4double dz)
69 {
70  // default matetial is "vacuum"
71  G4Material* vacuum= G4Material::GetMaterial("_Vacuum", false);
72 
73  if(vacuum==0) {
74  G4Element* elN= new G4Element("_N", "", 7., 14.00674*g/mole);
75  G4Element* elO= new G4Element("_O", "", 8., 15.9994*g/mole);
76 
77  vacuum= new G4Material("_Vacuum", universe_mean_density, 2);
78  vacuum-> AddElement(elN, 0.7);
79  vacuum-> AddElement(elO, 0.3);
80  }
81 
82  G4Box* sdworld= new G4Box("world", dx/2., dy/2., dz/2.);
83  G4LogicalVolume* lvworld= new G4LogicalVolume(sdworld, vacuum, "word");
84  G4PVPlacement* aworld= new G4PVPlacement(0, G4ThreeVector(), "world",
85  lvworld, 0, false, 0);
86 
87  // vis. attributes
88  G4VisAttributes* vaworld= new G4VisAttributes(G4Color(1.,1.,1.));
89  vaworld-> SetForceWireframe(true);
90  lvworld-> SetVisAttributes(vaworld);
91 
92  return aworld;
93 
94 }
95 
96 
100 {
101  delete world;
102  world= CreateWorld(dx, dy, dz);
103 
105  runManager-> DefineWorldVolume(world);
106 }
107 
108 
112 {
113  G4Box* box= dynamic_cast<G4Box*>(world-> GetLogicalVolume()-> GetSolid());
114  box-> SetXHalfLength(dx/2.);
115  box-> SetYHalfLength(dy/2.);
116  box-> SetZHalfLength(dz/2.);
117 
119  runManager-> GeometryHasBeenModified();
120 }
121 
122 
126 {
127  world-> GetLogicalVolume()-> SetMaterial(amaterial);
128 }
129 
130 
134 {
135  G4VisAttributes* vaworld= const_cast<G4VisAttributes*>(
136  world-> GetLogicalVolume()-> GetVisAttributes());
137  vaworld-> SetVisibility(qvis);
138 }
139