Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 // $Id$
30 //
32 //
33 // DetectorConstruction
34 //
35 // Created: 20.06.2008 V.Ivanchenko
36 //
37 // Modified:
38 //
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 
70 {
71  fLogicTarget = 0;
72  fLogicWorld = 0;
73  fDetectorMessenger = new DetectorMessenger(this);
74 
75  fRadius = 5.*cm;
76  fLength = 10.*cm;
77 
78  fTargetMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Al");
79  fWorldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83 
85 {
86  delete fDetectorMessenger;
87 }
88 
90 {
91  // Cleanup old geometry
92 
97 
98  // Sizes
99  G4double worldR = fRadius + cm;
100  G4double worldZ = fLength + cm;
101 
102  //
103  // World
104  //
105  G4Tubs* solidW = new G4Tubs("World", 0., worldR, 0.5*worldZ, 0., twopi);
106  fLogicWorld = new G4LogicalVolume(solidW, fWorldMaterial,"World");
108  fLogicWorld, "World",
109  0, false, 0);
110 
111  //
112  // Target volume
113  //
114  G4Tubs* solidA = new G4Tubs("Target", 0., fRadius, 0.5*fLength, 0.,twopi);
115  fLogicTarget = new G4LogicalVolume( solidA, fTargetMaterial, "Target");
116  new G4PVPlacement(0, G4ThreeVector(), fLogicTarget, "Target",
117  fLogicWorld, false, 0);
118 
119  G4cout << "### Target consist of "
120  << fTargetMaterial->GetName()
121  << " disks with R(mm)= " << fRadius/mm
122  << " fLength(mm)= " << fLength/mm
123  << " ###" << G4endl;
124 
125  // colors
127 
128  G4VisAttributes* regCcolor = new G4VisAttributes(G4Colour(0., 0.3, 0.7));
129  fLogicTarget->SetVisAttributes(regCcolor);
130 
131  G4cout << *(G4Material::GetMaterialTable()) << G4endl;
132 
133  return world;
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137 
139 {
140  // search the material by its name
142 
143  if (material && material != fTargetMaterial) {
144  fTargetMaterial = material;
145  if(fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
147  }
148 }
149 
150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
151 
153 {
154  // search the material by its name
156 
157  if (material && material != fWorldMaterial) {
158  fWorldMaterial = material;
159  if(fLogicWorld) fLogicWorld->SetMaterial(fWorldMaterial);
161  }
162 }
163 
164 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165 
167 {
169 }
170 
171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
172 
174 {
175  if(val > 0.0 && val != fRadius) {
176  fRadius = val;
178  }
179 }
180 
181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
182 
184 {
185  if(val > 0.0 && val != fLength) {
186  fLength = val;
188  }
189 }
190 
191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......