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: DetectorConstruction.cc,v 1.3 2007/10/08 12:05:02 maire Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
28 | |
---|
29 | // |
---|
30 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
31 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
32 | |
---|
33 | #include "DetectorConstruction.hh" |
---|
34 | #include "DetectorMessenger.hh" |
---|
35 | |
---|
36 | #include "G4Material.hh" |
---|
37 | #include "G4Tubs.hh" |
---|
38 | #include "G4LogicalVolume.hh" |
---|
39 | #include "G4VPhysicalVolume.hh" |
---|
40 | #include "G4PVPlacement.hh" |
---|
41 | |
---|
42 | #include "G4GeometryManager.hh" |
---|
43 | #include "G4PhysicalVolumeStore.hh" |
---|
44 | #include "G4LogicalVolumeStore.hh" |
---|
45 | #include "G4SolidStore.hh" |
---|
46 | |
---|
47 | #include "G4UnitsTable.hh" |
---|
48 | |
---|
49 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
50 | |
---|
51 | DetectorConstruction::DetectorConstruction() |
---|
52 | :pWall(0), pCavity(0) |
---|
53 | { |
---|
54 | // default parameter values |
---|
55 | cavityThickness = 2*mm; |
---|
56 | cavityRadius = 1*cm; |
---|
57 | |
---|
58 | wallThickness = 5*mm; |
---|
59 | |
---|
60 | DefineMaterials(); |
---|
61 | SetWallMaterial("Water"); |
---|
62 | SetCavityMaterial("Water_vapor"); |
---|
63 | |
---|
64 | // create commands for interactive definition of the detector |
---|
65 | detectorMessenger = new DetectorMessenger(this); |
---|
66 | } |
---|
67 | |
---|
68 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
69 | |
---|
70 | DetectorConstruction::~DetectorConstruction() |
---|
71 | { delete detectorMessenger;} |
---|
72 | |
---|
73 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
74 | |
---|
75 | G4VPhysicalVolume* DetectorConstruction::Construct() |
---|
76 | { |
---|
77 | return ConstructVolumes(); |
---|
78 | } |
---|
79 | |
---|
80 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
81 | |
---|
82 | void DetectorConstruction::DefineMaterials() |
---|
83 | { |
---|
84 | // |
---|
85 | // define Elements |
---|
86 | // |
---|
87 | G4double z,a; |
---|
88 | |
---|
89 | G4Element* H = new G4Element("Hydrogen" ,"H" , z= 1., a= 1.01*g/mole); |
---|
90 | G4Element* N = new G4Element("Nitrogen" ,"N" , z= 7., a= 14.01*g/mole); |
---|
91 | G4Element* O = new G4Element("Oxygen" ,"O" , z= 8., a= 16.00*g/mole); |
---|
92 | |
---|
93 | // |
---|
94 | // define materials |
---|
95 | // |
---|
96 | G4Material* H2O = |
---|
97 | new G4Material("Water", 1.0*g/cm3, 2); |
---|
98 | H2O->AddElement(H, 2); |
---|
99 | H2O->AddElement(O, 1); |
---|
100 | H2O->GetIonisation()->SetMeanExcitationEnergy(75.0*eV); |
---|
101 | |
---|
102 | G4Material* vapor = |
---|
103 | new G4Material("Water_vapor", 1.0*mg/cm3, 2); |
---|
104 | vapor->AddElement(H, 2); |
---|
105 | vapor->AddElement(O, 1); |
---|
106 | vapor->GetIonisation()->SetMeanExcitationEnergy(75.0*eV); |
---|
107 | |
---|
108 | G4Material* Air = |
---|
109 | new G4Material("Air", 1.290*mg/cm3, 2); |
---|
110 | Air->AddElement(N, 70.*perCent); |
---|
111 | Air->AddElement(O, 30.*perCent); |
---|
112 | |
---|
113 | new G4Material("Graphite", 6, 12.01*g/mole, 2.265*g/cm3); |
---|
114 | new G4Material("Graphite_gas", 6, 12.01*g/mole, 2.265*mg/cm3); |
---|
115 | |
---|
116 | new G4Material("Aluminium", 13, 26.98*g/mole, 2.700*g/cm3); |
---|
117 | new G4Material("Aluminium_gas", 13, 26.98*g/mole, 2.700*mg/cm3); |
---|
118 | |
---|
119 | G4cout << *(G4Material::GetMaterialTable()) << G4endl; |
---|
120 | } |
---|
121 | |
---|
122 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
123 | |
---|
124 | G4VPhysicalVolume* DetectorConstruction::ConstructVolumes() |
---|
125 | { |
---|
126 | G4GeometryManager::GetInstance()->OpenGeometry(); |
---|
127 | G4PhysicalVolumeStore::GetInstance()->Clean(); |
---|
128 | G4LogicalVolumeStore::GetInstance()->Clean(); |
---|
129 | G4SolidStore::GetInstance()->Clean(); |
---|
130 | |
---|
131 | // Chamber |
---|
132 | // |
---|
133 | totalThickness = cavityThickness + 2*wallThickness; |
---|
134 | wallRadius = cavityRadius + wallThickness; |
---|
135 | |
---|
136 | G4Tubs* |
---|
137 | sChamber = new G4Tubs("Chamber", //name |
---|
138 | 0.,wallRadius,0.5*totalThickness,0.,twopi); //size |
---|
139 | |
---|
140 | G4LogicalVolume* |
---|
141 | lChamber = new G4LogicalVolume(sChamber, //solid |
---|
142 | wallMaterial, //material |
---|
143 | "Chamber"); //name |
---|
144 | |
---|
145 | pWall = new G4PVPlacement(0, //no rotation |
---|
146 | G4ThreeVector(), //at (0,0,0) |
---|
147 | lChamber, //logical volume |
---|
148 | "Wall", //name |
---|
149 | 0, //mother volume |
---|
150 | false, //no boolean operation |
---|
151 | 0); //copy number |
---|
152 | |
---|
153 | // Cavity |
---|
154 | // |
---|
155 | G4Tubs* |
---|
156 | sCavity = new G4Tubs("Cavity", |
---|
157 | 0.,cavityRadius,0.5*cavityThickness,0.,twopi); |
---|
158 | |
---|
159 | G4LogicalVolume* |
---|
160 | lCavity = new G4LogicalVolume(sCavity, //shape |
---|
161 | cavityMaterial, //material |
---|
162 | "Cavity"); //name |
---|
163 | |
---|
164 | pCavity = new G4PVPlacement(0, //no rotation |
---|
165 | G4ThreeVector(), //at (0,0,0) |
---|
166 | lCavity, //logical volume |
---|
167 | "Cavity", //name |
---|
168 | lChamber, //mother volume |
---|
169 | false, //no boolean operation |
---|
170 | 1); //copy number |
---|
171 | |
---|
172 | PrintParameters(); |
---|
173 | |
---|
174 | // |
---|
175 | //always return the root volume |
---|
176 | // |
---|
177 | return pWall; |
---|
178 | } |
---|
179 | |
---|
180 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
181 | |
---|
182 | void DetectorConstruction::PrintParameters() |
---|
183 | { |
---|
184 | G4cout << "\n---------------------------------------------------------\n"; |
---|
185 | G4cout << "---> The Wall is " << G4BestUnit(wallThickness,"Length") |
---|
186 | << " of " << wallMaterial->GetName() << " ( " |
---|
187 | << G4BestUnit(wallMaterial->GetDensity(),"Volumic Mass") << " )\n"; |
---|
188 | G4cout << " The Cavity is " << G4BestUnit(cavityThickness,"Length") |
---|
189 | << " of " << cavityMaterial->GetName() << " ( " |
---|
190 | << G4BestUnit(cavityMaterial->GetDensity(),"Volumic Mass") << " )"; |
---|
191 | G4cout << "\n---------------------------------------------------------\n"; |
---|
192 | G4cout << G4endl; |
---|
193 | } |
---|
194 | |
---|
195 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
196 | |
---|
197 | void DetectorConstruction::SetWallThickness(G4double value) |
---|
198 | { |
---|
199 | wallThickness = value; |
---|
200 | } |
---|
201 | |
---|
202 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
203 | |
---|
204 | void DetectorConstruction::SetWallMaterial(G4String materialChoice) |
---|
205 | { |
---|
206 | // search the material by its name |
---|
207 | G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); |
---|
208 | if (pttoMaterial) wallMaterial = pttoMaterial; |
---|
209 | } |
---|
210 | |
---|
211 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
212 | |
---|
213 | void DetectorConstruction::SetCavityThickness(G4double value) |
---|
214 | { |
---|
215 | cavityThickness = value; |
---|
216 | } |
---|
217 | |
---|
218 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
219 | |
---|
220 | void DetectorConstruction::SetCavityRadius(G4double value) |
---|
221 | { |
---|
222 | cavityRadius = value; |
---|
223 | } |
---|
224 | |
---|
225 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
226 | |
---|
227 | void DetectorConstruction::SetCavityMaterial(G4String materialChoice) |
---|
228 | { |
---|
229 | // search the material by its name |
---|
230 | G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); |
---|
231 | if (pttoMaterial) cavityMaterial = pttoMaterial; |
---|
232 | } |
---|
233 | |
---|
234 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
235 | |
---|
236 | #include "G4RunManager.hh" |
---|
237 | |
---|
238 | void DetectorConstruction::UpdateGeometry() |
---|
239 | { |
---|
240 | G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes()); |
---|
241 | } |
---|
242 | |
---|
243 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|