Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/hadronic/Hadr05/src/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 /// \file hadronic/Hadr00/src/DetectorConstruction.cc
27 /// \brief Implementation of the DetectorConstruction class
28 //
29 // $Id: DetectorConstruction.cc 77210 2013-11-22 01:58:38Z adotti $
30 //
31 /////////////////////////////////////////////////////////////////////////
32 //
33 // DetectorConstruction
34 //
35 // Created: 20.06.2008 V.Ivanchenko
36 //
37 // Modified:
38 //
39 ////////////////////////////////////////////////////////////////////////
40 //
41 
42 #include "DetectorConstruction.hh"
43 #include "DetectorMessenger.hh"
44 
45 #include "G4Tubs.hh"
46 #include "G4LogicalVolume.hh"
47 #include "G4PVPlacement.hh"
48 
49 #include "G4RunManager.hh"
50 
51 #include "G4GeometryManager.hh"
52 #include "G4PhysicalVolumeStore.hh"
53 #include "G4LogicalVolumeStore.hh"
54 #include "G4SolidStore.hh"
55 
56 #include "G4VisAttributes.hh"
57 #include "G4Colour.hh"
58 
59 #include "G4UnitsTable.hh"
60 #include "G4ios.hh"
61 
62 #include "G4NistManager.hh"
63 
64 #include "G4PhysicalConstants.hh"
65 #include "G4SystemOfUnits.hh"
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
71  fTargetMaterial(0), fWorldMaterial(0),
72  fLogicTarget(0), fLogicWorld(0),
73  fDetectorMessenger(0)
74 {
75  fDetectorMessenger = new DetectorMessenger(this);
76 
77  fRadius = 5.*cm;
78  fLength = 10.*cm;
79 
80  fTargetMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
81  fWorldMaterial =
83 }
84 
85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 
88 {
89  delete fDetectorMessenger;
90 }
91 
93 {
94  // Cleanup old geometry
95 
100 
101  // Sizes
102  G4double worldR = fRadius + cm;
103  G4double worldZ = fLength + cm;
104 
105  //
106  // World
107  //
108  G4Tubs* solidW = new G4Tubs("World", 0., worldR, 0.5*worldZ, 0., twopi);
109  fLogicWorld = new G4LogicalVolume(solidW, fWorldMaterial,"World");
111  fLogicWorld, "World",
112  0, false, 0);
113 
114  //
115  // Target volume
116  //
117  G4Tubs* solidA = new G4Tubs("Target", 0., fRadius, 0.5*fLength, 0.,twopi);
118  fLogicTarget = new G4LogicalVolume( solidA, fTargetMaterial, "Target");
119  new G4PVPlacement(0, G4ThreeVector(), fLogicTarget, "Target",
120  fLogicWorld, false, 0);
121 
122  G4cout << "### Target consist of "
123  << fTargetMaterial->GetName()
124  << " disks with R(mm)= " << fRadius/mm
125  << " fLength(mm)= " << fLength/mm
126  << " ###" << G4endl;
127 
128  // colors
130 
131  G4VisAttributes* regCcolor = new G4VisAttributes(G4Colour(0., 0.3, 0.7));
132  fLogicTarget->SetVisAttributes(regCcolor);
133 
134  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
135 
136  return world;
137 }
138 
139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
140 
142 {
143  // search the material by its name
145 
146  if (material && material != fTargetMaterial) {
147  fTargetMaterial = material;
148  if(fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
150  }
151 }
152 
153 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
154 
156 {
157  // search the material by its name
159 
160  if (material && material != fWorldMaterial) {
161  fWorldMaterial = material;
162  if(fLogicWorld) fLogicWorld->SetMaterial(fWorldMaterial);
164  }
165 }
166 
168 {
169  if(val > 0.0 && val != fRadius) {
170  fRadius = val;
172  }
173 }
174 
175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
176 
178 {
179  if(val > 0.0 && val != fLength) {
180  fLength = val;
182  }
183 }
184 
185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
const G4String & GetName() const
Definition: G4Material.hh:176
Definition: G4Tubs.hh:84
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
static void Clean()
Definition: G4SolidStore.cc:79
static G4NistManager * Instance()
static G4PhysicalVolumeStore * GetInstance()
string material
Definition: eplot.py:19
G4GLOB_DLL std::ostream G4cout
void PhysicsHasBeenModified()
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
static const G4VisAttributes Invisible
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
void SetVisAttributes(const G4VisAttributes *pVA)