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.2 2007/11/05 13:19:16 maire Exp $ |
---|
27 | // GEANT4 tag $Name: $ |
---|
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 | wallThickness = 5*cm; |
---|
56 | cavityThickness = 2*mm; |
---|
57 | worldRadius = 10*m; |
---|
58 | |
---|
59 | DefineMaterials(); |
---|
60 | SetWallMaterial("Water"); |
---|
61 | |
---|
62 | // create commands for interactive definition of the detector |
---|
63 | detectorMessenger = new DetectorMessenger(this); |
---|
64 | } |
---|
65 | |
---|
66 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
67 | |
---|
68 | DetectorConstruction::~DetectorConstruction() |
---|
69 | { delete detectorMessenger;} |
---|
70 | |
---|
71 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
72 | |
---|
73 | G4VPhysicalVolume* DetectorConstruction::Construct() |
---|
74 | { |
---|
75 | return ConstructVolumes(); |
---|
76 | } |
---|
77 | |
---|
78 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
79 | |
---|
80 | void DetectorConstruction::DefineMaterials() |
---|
81 | { |
---|
82 | // |
---|
83 | // define Elements |
---|
84 | // |
---|
85 | G4double z,a; |
---|
86 | |
---|
87 | G4Element* H = new G4Element("Hydrogen" ,"H" , z= 1., a= 1.01*g/mole); |
---|
88 | G4Element* O = new G4Element("Oxygen" ,"O" , z= 8., a= 16.00*g/mole); |
---|
89 | |
---|
90 | // |
---|
91 | // define materials |
---|
92 | // |
---|
93 | G4Material* H2O = |
---|
94 | new G4Material("Water", 1.0*g/cm3, 2); |
---|
95 | H2O->AddElement(H, 2); |
---|
96 | H2O->AddElement(O, 1); |
---|
97 | H2O->GetIonisation()->SetMeanExcitationEnergy(75.0*eV); |
---|
98 | |
---|
99 | G4Material* gas = |
---|
100 | new G4Material("Water_gas", 1.0*mg/cm3, 2); |
---|
101 | gas->AddElement(H, 2); |
---|
102 | gas->AddElement(O, 1); |
---|
103 | gas->GetIonisation()->SetMeanExcitationEnergy(75.0*eV); |
---|
104 | |
---|
105 | new G4Material("Graphite", 6, 12.01*g/mole, 2.265*g/cm3); |
---|
106 | new G4Material("Graphite_gas", 6, 12.01*g/mole, 2.265*mg/cm3); |
---|
107 | |
---|
108 | new G4Material("Aluminium", 13, 26.98*g/mole, 2.700*g/cm3); |
---|
109 | new G4Material("Aluminium_gas", 13, 26.98*g/mole, 2.700*mg/cm3); |
---|
110 | |
---|
111 | G4cout << *(G4Material::GetMaterialTable()) << G4endl; |
---|
112 | } |
---|
113 | |
---|
114 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
115 | |
---|
116 | G4VPhysicalVolume* DetectorConstruction::ConstructVolumes() |
---|
117 | { |
---|
118 | G4GeometryManager::GetInstance()->OpenGeometry(); |
---|
119 | G4PhysicalVolumeStore::GetInstance()->Clean(); |
---|
120 | G4LogicalVolumeStore::GetInstance()->Clean(); |
---|
121 | G4SolidStore::GetInstance()->Clean(); |
---|
122 | |
---|
123 | // Wall |
---|
124 | // |
---|
125 | worldThickness = cavityThickness + 2*wallThickness; |
---|
126 | |
---|
127 | G4Tubs* |
---|
128 | sWall = new G4Tubs("Wall", //name |
---|
129 | 0.,worldRadius,0.5*worldThickness,0.,twopi); //size |
---|
130 | |
---|
131 | G4LogicalVolume* |
---|
132 | lWall = new G4LogicalVolume(sWall, //solid |
---|
133 | wallMaterial, //material |
---|
134 | "Wall"); //name |
---|
135 | |
---|
136 | pWall = new G4PVPlacement(0, //no rotation |
---|
137 | G4ThreeVector(), //at (0,0,0) |
---|
138 | lWall, //logical volume |
---|
139 | "Wall", //name |
---|
140 | 0, //mother volume |
---|
141 | false, //no boolean operation |
---|
142 | 0); //copy number |
---|
143 | |
---|
144 | // Cavity |
---|
145 | // |
---|
146 | G4Tubs* |
---|
147 | sCavity = new G4Tubs("Cavity", |
---|
148 | 0.,worldRadius,0.5*cavityThickness,0.,twopi); |
---|
149 | |
---|
150 | G4LogicalVolume* |
---|
151 | lCavity = new G4LogicalVolume(sCavity, //shape |
---|
152 | cavityMaterial, //material |
---|
153 | "Cavity"); //name |
---|
154 | |
---|
155 | pCavity = new G4PVPlacement(0, //no rotation |
---|
156 | G4ThreeVector(), //at (0,0,0) |
---|
157 | lCavity, //logical volume |
---|
158 | "Cavity", //name |
---|
159 | lWall, //mother volume |
---|
160 | false, //no boolean operation |
---|
161 | 1); //copy number |
---|
162 | |
---|
163 | PrintParameters(); |
---|
164 | |
---|
165 | // |
---|
166 | //always return the root volume |
---|
167 | // |
---|
168 | return pWall; |
---|
169 | } |
---|
170 | |
---|
171 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
172 | |
---|
173 | void DetectorConstruction::PrintParameters() |
---|
174 | { |
---|
175 | G4cout << "\n---------------------------------------------------------\n"; |
---|
176 | G4cout << "---> The Wall is " << G4BestUnit(wallThickness,"Length") |
---|
177 | << " of " << wallMaterial->GetName() << " ( " |
---|
178 | << G4BestUnit(wallMaterial->GetDensity(),"Volumic Mass") << " )\n"; |
---|
179 | G4cout << " The Cavity is " << G4BestUnit(cavityThickness,"Length") |
---|
180 | << " of " << cavityMaterial->GetName() << " ( " |
---|
181 | << G4BestUnit(cavityMaterial->GetDensity(),"Volumic Mass") << " )"; |
---|
182 | G4cout << "\n---------------------------------------------------------\n"; |
---|
183 | G4cout << G4endl; |
---|
184 | } |
---|
185 | |
---|
186 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
187 | |
---|
188 | void DetectorConstruction::SetWallMaterial(G4String materialChoice) |
---|
189 | { |
---|
190 | // search the material by its name |
---|
191 | G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice); |
---|
192 | if (pttoMaterial) wallMaterial = pttoMaterial; |
---|
193 | |
---|
194 | pttoMaterial = G4Material::GetMaterial(materialChoice + "_gas"); |
---|
195 | if (pttoMaterial) cavityMaterial = pttoMaterial; |
---|
196 | } |
---|
197 | |
---|
198 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
199 | |
---|
200 | void DetectorConstruction::SetWallThickness(G4double value) |
---|
201 | { |
---|
202 | wallThickness = value; |
---|
203 | } |
---|
204 | |
---|
205 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
206 | |
---|
207 | void DetectorConstruction::SetCavityThickness(G4double value) |
---|
208 | { |
---|
209 | cavityThickness = value; |
---|
210 | |
---|
211 | } |
---|
212 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
213 | |
---|
214 | void DetectorConstruction::SetWorldRadius(G4double value) |
---|
215 | { |
---|
216 | worldRadius = value; |
---|
217 | } |
---|
218 | |
---|
219 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
220 | |
---|
221 | #include "G4RunManager.hh" |
---|
222 | |
---|
223 | void DetectorConstruction::UpdateGeometry() |
---|
224 | { |
---|
225 | G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes()); |
---|
226 | } |
---|
227 | |
---|
228 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|