Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExG4DetectorConstruction01.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$
27 //
30 
31 #include "ExG4DetectorConstruction01.hh"
32 #include "ExG4DetectorConstruction01Messenger.hh"
33 
34 #include "G4Material.hh"
35 #include "G4NistManager.hh"
36 #include "G4Box.hh"
37 #include "G4LogicalVolume.hh"
38 #include "G4PVPlacement.hh"
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
41 
43  const G4String& materialName,
44  G4double hx, G4double hy, G4double hz)
46  fMessenger(this),
47  fMaterialName(materialName),
48  fDimensions(hx, hy, hz),
49  fWorldVolume(0)
50 {
51 }
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
56 {
57 }
58 
59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60 
62 {
63  // Define materials via NIST manager
64  //
65  G4NistManager* nistManager = G4NistManager::Instance();
66 
68  = nistManager->FindOrBuildMaterial(fMaterialName);
69 
70  // World
71  //
72  G4Box* sWorld
73  = new G4Box("World", //name
74  fDimensions.x(), //dimensions (half-lentghs)
75  fDimensions.y(),
76  fDimensions.z());
77 
78  fWorldVolume
79  = new G4LogicalVolume(sWorld, //shape
80  material, //material
81  "World"); //name
82 
83  G4VPhysicalVolume* pWorld
84  = new G4PVPlacement(0, //no rotation
85  G4ThreeVector(), //at (0,0,0)
86  fWorldVolume, //logical volume
87  "World", //name
88  0, //mother volume
89  false, //no boolean operation
90  0); //copy number
91 
92  //always return the root volume
93  //
94  return pWorld;
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 
100 {
101  G4NistManager* nistManager = G4NistManager::Instance();
102 
103  G4Material* newMaterial
104  = nistManager->FindOrBuildMaterial(materialName);
105 
106  if ( ! newMaterial ) {
107  G4cerr << "Material " << materialName << " not found." << G4endl;
108  G4cerr << "The box material was not changed." << G4endl;
109  return;
110  }
111 
112  if ( fWorldVolume ) fWorldVolume->SetMaterial(newMaterial);
113  G4cout << "Material of box changed to " << materialName << G4endl;
114 }
115 
116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
117 
119  G4double hx, G4double hy, G4double hz)
120 {
123 
124  fDimensions = G4ThreeVector(hx, hy, hz);
125 }
126 
127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
double x() const
Definition: G4Box.hh:64
void SetDimensions(G4double hx, G4double hy, G4double hz)
ExG4DetectorConstruction01(const G4String &materialName="G4_AIR", G4double hx=50 *CLHEP::cm, G4double hy=50 *CLHEP::cm, G4double hz=50 *CLHEP::cm)
virtual G4VPhysicalVolume * Construct()
static G4NistManager * Instance()
double z() const
string material
Definition: eplot.py:19
G4GLOB_DLL std::ostream G4cout
void SetMaterial(const G4String &materialName)
double y() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
G4GLOB_DLL std::ostream G4cerr