VMC Examples Version 6.6
Loading...
Searching...
No Matches
B4DetectorConstruction.cxx
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// $Id: B4DetectorConstruction.cc 77601 2013-11-26 17:08:44Z gcosmo $
27//
28/// \file B4DetectorConstruction.cxx
29/// \brief Implementation of the B4DetectorConstruction class
30
31#include "B4DetectorConstruction.hh"
32
33// Added for VMC
34#include "TG4GeometryManager.h"
35
36#include "G4Material.hh"
37#include "G4NistManager.hh"
38
39#include "G4AutoDelete.hh"
40#include "G4Box.hh"
41#include "G4GlobalMagFieldMessenger.hh"
42#include "G4LogicalVolume.hh"
43#include "G4PVPlacement.hh"
44#include "G4PVReplica.hh"
45
46#include "G4GeometryManager.hh"
47#include "G4LogicalVolumeStore.hh"
48#include "G4PhysicalVolumeStore.hh"
49#include "G4SolidStore.hh"
50
51#include "G4Colour.hh"
52#include "G4VisAttributes.hh"
53
54#include "G4PhysicalConstants.hh"
55#include "G4SystemOfUnits.hh"
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58
59G4ThreadLocal G4GlobalMagFieldMessenger*
61
62//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63
66 fAbsorberPV(0),
67 fGapPV(0),
68 fCheckOverlaps(true)
69{}
70
71//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72
74
75//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76
78{
79 // Define materials
81
82 // Define volumes
83 return DefineVolumes();
84}
85
86//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87
89{
90 // Lead material defined using NIST Manager
91 G4NistManager* nistManager = G4NistManager::Instance();
92 nistManager->FindOrBuildMaterial("G4_Pb");
93
94 // Liquid argon material
95 G4double a; // mass of a mole;
96 G4double z; // z=mean number of protons;
97 G4double density;
98 new G4Material(
99 "liquidArgon", z = 18., a = 39.95 * g / mole, density = 1.390 * g / cm3);
100 // The argon by NIST Manager is a gas with a different density
101
102 // Vacuum
103 new G4Material("Galactic", z = 1., a = 1.01 * g / mole,
104 density = universe_mean_density, kStateGas, 2.73 * kelvin, 3.e-18 * pascal);
105
106 // Print materials
107 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
108}
109
110//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
111
113{
114 // Geometry parameters
115 G4int nofLayers = 10;
116 G4double absoThickness = 10. * mm;
117 G4double gapThickness = 5. * mm;
118 G4double calorSizeXY = 10. * cm;
119
120 G4double layerThickness = absoThickness + gapThickness;
121 G4double calorThickness = nofLayers * layerThickness;
122 G4double worldSizeXY = 1.2 * calorSizeXY;
123 G4double worldSizeZ = 1.2 * calorThickness;
124
125 // Get materials
126 G4Material* defaultMaterial = G4Material::GetMaterial("Galactic");
127 G4Material* absorberMaterial = G4Material::GetMaterial("G4_Pb");
128 G4Material* gapMaterial = G4Material::GetMaterial("liquidArgon");
129
130 if (!defaultMaterial || !absorberMaterial || !gapMaterial) {
131 G4ExceptionDescription msg;
132 msg << "Cannot retrieve materials already defined.";
133 G4Exception("B4DetectorConstruction::DefineVolumes()", "MyCode0001",
134 FatalException, msg);
135 }
136
137 //
138 // World
139 //
140 G4VSolid* worldS = new G4Box("World", // its name
141 worldSizeXY / 2, worldSizeXY / 2, worldSizeZ / 2); // its size
142
143 G4LogicalVolume* worldLV = new G4LogicalVolume(worldS, // its solid
144 defaultMaterial, // its material
145 "WRLD"); // its name
146
147 G4VPhysicalVolume* worldPV = new G4PVPlacement(0, // no rotation
148 G4ThreeVector(), // at (0,0,0)
149 worldLV, // its logical volume
150 "WRLD", // its name
151 0, // its mother volume
152 false, // no boolean operation
153 0, // copy number
154 fCheckOverlaps); // checking overlaps
155
156 //
157 // Calorimeter
158 //
159 G4VSolid* calorimeterS = new G4Box("Calorimeter", // its name
160 calorSizeXY / 2, calorSizeXY / 2, calorThickness / 2); // its size
161
162 G4LogicalVolume* calorLV = new G4LogicalVolume(calorimeterS, // its solid
163 defaultMaterial, // its material
164 "CALO"); // its name
165
166 new G4PVPlacement(0, // no rotation
167 G4ThreeVector(), // at (0,0,0)
168 calorLV, // its logical volume
169 "CALO", // its name
170 worldLV, // its mother volume
171 false, // no boolean operation
172 0, // copy number
173 fCheckOverlaps); // checking overlaps
174
175 //
176 // Layer
177 //
178 G4VSolid* layerS = new G4Box("Layer", // its name
179 calorSizeXY / 2, calorSizeXY / 2, layerThickness / 2); // its size
180
181 G4LogicalVolume* layerLV = new G4LogicalVolume(layerS, // its solid
182 defaultMaterial, // its material
183 "LAYE"); // its name
184
185 new G4PVReplica("LAYE", // its name
186 layerLV, // its logical volume
187 calorLV, // its mother
188 kZAxis, // axis of replication
189 nofLayers, // number of replica
190 layerThickness); // witdth of replica
191
192 //
193 // Absorber
194 //
195 G4VSolid* absorberS = new G4Box("Abso", // its name
196 calorSizeXY / 2, calorSizeXY / 2, absoThickness / 2); // its size
197
198 G4LogicalVolume* absorberLV = new G4LogicalVolume(absorberS, // its solid
199 absorberMaterial, // its material
200 "ABSO"); // its name
201
202 fAbsorberPV = new G4PVPlacement(0, // no rotation
203 G4ThreeVector(0., 0., -gapThickness / 2), // its position
204 absorberLV, // its logical volume
205 "ABSO", // its name
206 layerLV, // its mother volume
207 false, // no boolean operation
208 0, // copy number
209 fCheckOverlaps); // checking overlaps
210
211 //
212 // Gap
213 //
214 G4VSolid* gapS = new G4Box("Gap", // its name
215 calorSizeXY / 2, calorSizeXY / 2, gapThickness / 2); // its size
216
217 G4LogicalVolume* gapLV = new G4LogicalVolume(gapS, // its solid
218 gapMaterial, // its material
219 "GAPX"); // its name
220
221 fGapPV = new G4PVPlacement(0, // no rotation
222 G4ThreeVector(0., 0., absoThickness / 2), // its position
223 gapLV, // its logical volume
224 "GAPX", // its name
225 layerLV, // its mother volume
226 false, // no boolean operation
227 0, // copy number
228 fCheckOverlaps); // checking overlaps
229
230 //
231 // print parameters
232 //
233 G4cout << "\n------------------------------------------------------------"
234 << "\n---> The calorimeter is " << nofLayers << " layers of: [ "
235 << absoThickness / mm << "mm of " << absorberMaterial->GetName()
236 << " + " << gapThickness / mm << "mm of " << gapMaterial->GetName()
237 << " ] "
238 << "\n------------------------------------------------------------\n";
239
240 //
241 // Visualization attributes
242 //
243 worldLV->SetVisAttributes(G4VisAttributes::GetInvisible());
244
245 G4VisAttributes* simpleBoxVisAtt =
246 new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
247 simpleBoxVisAtt->SetVisibility(true);
248 calorLV->SetVisAttributes(simpleBoxVisAtt);
249
250 //
251 // Always return the physical World
252 //
253 return worldPV;
254}
255
256//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
257
259{
260 // Added for VMC
261 TG4GeometryManager::Instance()->ConstructSDandField();
262 /*
263 // Create global magnetic field messenger.
264 // Uniform magnetic field is then created automatically if
265 // the field value is not zero.
266 G4ThreeVector fieldValue = G4ThreeVector();
267 fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
268 fMagFieldMessenger->SetVerboseLevel(1);
269
270 // Register the field messenger for deleting
271 G4AutoDelete::Register(fMagFieldMessenger);
272 */
273}
274
275//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume * fAbsorberPV
static G4ThreadLocal G4GlobalMagFieldMessenger * fMagFieldMessenger
G4VPhysicalVolume * DefineVolumes()
virtual G4VPhysicalVolume * Construct()