Geant4  10.02.p01
DetectorConstruction.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 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // shall cite the following Geant4-DNA collaboration publication:
29 // Med. Phys. 37 (2010) 4692-4708
30 // The Geant4-DNA web site is available at http://geant4-dna.org
31 //
32 // $Id$
33 //
36 
37 #include "DetectorConstruction.hh"
38 #include "DetectorMessenger.hh"
39 #include "G4SystemOfUnits.hh"
40 #include "G4UserLimits.hh"
41 #include "G4NistManager.hh"
42 #include "G4RunManager.hh"
43 #include "G4LogicalVolumeStore.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
46 
48  G4VUserDetectorConstruction(), fpWaterMaterial(0)
49 {
50  // create commands for interactive definition of the detector
52 }
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55 
57 {
58  delete fDetectorMessenger;
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62 
64 
65 {
67  return ConstructDetector();
68 }
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
71 
73 {
74 
75  // Water is defined from NIST material database
77 
78  G4Material * H2O = man->FindOrBuildMaterial("G4_WATER");
79 
80  /*
81  If one wishes to test other density value for water material,
82  one should use instead:
83  G4Material * H2O = man->BuildMaterialWithNewDensity("G4_WATER_MODIFIED",
84  "G4_WATER",1.100*g/cm3);
85 
86  Note: any string for "G4_WATER_MODIFIED" parameter is accepted
87  and "G4_WATER" parameter should not be changed
88  Both materials are created and can be selected from dna.mac
89  */
90  fpWaterMaterial = H2O;
91 
92  //G4cout << "-> Density of water material (g/cm3)="
93  // << fpWaterMaterial->GetDensity()/(g/cm/cm/cm) << G4endl;
94 
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
100 {
101 
102  //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
103 
104  // WORLD VOLUME
105 
107  G4double worldSizeY = worldSizeX;
108  G4double worldSizeZ = worldSizeX;
109 
110  G4Box* solidWorld = new G4Box("World", //its name
111  worldSizeX / 2, worldSizeY / 2, worldSizeZ / 2); //its size
112 
113  G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, //its solid
114  fpWaterMaterial, //its material
115  "World"); //its name
116 
117  G4PVPlacement* physiWorld = new G4PVPlacement(0, //no rotation
118  G4ThreeVector(), //at (0,0,0)
119  "World", //its name
120  logicWorld, //its logical volume
121  0, //its mother volume
122  false, //no boolean operation
123  0); //copy number
124 
125  // Visualization attributes
126  G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0)); //White
127  worldVisAtt->SetVisibility(true);
128  logicWorld->SetVisAttributes(worldVisAtt);
129 
130  G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
131  worldVisAtt1->SetVisibility(true);
132 
133  //
134  // Shows how to introduce a 20 eV tracking cut
135  //
136  //logicWorld->SetUserLimits(new G4UserLimits(DBL_MAX,DBL_MAX,DBL_MAX,20*eV));
137 
138  return physiWorld;
139 }
140 
141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
142 
143 void DetectorConstruction::SetMaterial(G4String materialChoice)
144 {
145  // Search the material by its name
147  materialChoice);
148 
149  if (pttoMaterial)
150  {
151  fpWaterMaterial = pttoMaterial;
152  G4LogicalVolume* logicWorld =
154  logicWorld->SetMaterial(fpWaterMaterial);
156  }
157 }
158 
159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
160 
162 {
165 }
void GeometryHasBeenModified(G4bool prop=true)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
Definition: G4Box.hh:64
G4VPhysicalVolume * Construct()
void SetVisibility(G4bool)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
static G4NistManager * Instance()
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
G4GLOB_DLL std::ostream G4cout
static G4LogicalVolumeStore * GetInstance()
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static const double micrometer
Definition: G4SIunits.hh:99
#define G4endl
Definition: G4ios.hh:61
G4VPhysicalVolume * ConstructDetector()
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
Messenger class that defines commands for DetectorConstruction.
void SetVisAttributes(const G4VisAttributes *pVA)
DetectorMessenger * fDetectorMessenger