Loading...
Searching...
No Matches
GB03DetectorConstruction.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//
27/// \file GB03DetectorConstruction.cc
28/// \brief Implementation of the GB03DetectorConstruction class
29
31
32#include "G4RunManager.hh"
33
34#include "G4Material.hh"
35#include "G4Box.hh"
36#include "G4LogicalVolume.hh"
37#include "G4PVPlacement.hh"
38#include "G4PVReplica.hh"
39
40#include "G4VisAttributes.hh"
41#include "G4Colour.hh"
42
43#include "G4SDManager.hh"
44#include "G4MultiFunctionalDetector.hh"
45#include "G4PSEnergyDeposit.hh"
46#include "G4PSFlatSurfaceFlux.hh"
47#include "G4SDNeutralFilter.hh"
48#include "G4SDChargedFilter.hh"
49#include "G4ios.hh"
50
52
54
55#include "G4PhysicalConstants.hh"
56#include "G4SystemOfUnits.hh"
57
59G4ThreadLocal G4bool GB03DetectorConstruction::fConstructedSDandField = false;
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62
65 fTotalThickness (2.0*m), fLayerThickness(0.),
66 fConstructed(false),
67 fWorldMaterial(0), fAbsorberMaterial(0), fGapMaterial(0),
68 fLayerSolid(0), fGapSolid(0),
69 fWorldLogical(0), fCalorLogical(0), fLayerLogical(0), fGapLogical(0),
70 fWorldPhysical(0), fCalorPhysical(0), fLayerPhysical(0), fGapPhysical(0),
71 fDetectorMessenger(0), fVerboseLevel(1)
72{
74 fCalName = "Calor";
76}
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79
82
83//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84
98
99//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100
110
111//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112
114{
115 G4String name, symbol; //a=mass of a mole;
116 G4double a, z, density; //z=mean number of protons;
117 G4int iz; //iz=number of protons in an isotope;
118 G4int n; // n=number of nucleons in an isotope;
119
120 G4int ncomponents, natoms;
121 G4double abundance, fractionmass;
122 G4double temperature, pressure;
123
124 //
125 // define Elements
126 //
127
128 a = 1.01*g/mole;
129 G4Element* H = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
130
131 a = 12.01*g/mole;
132 G4Element* C = new G4Element(name="Carbon" ,symbol="C" , z= 6., a);
133
134 a = 14.01*g/mole;
135 G4Element* N = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
136
137 a = 16.00*g/mole;
138 G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
139
140 //
141 // define an Element from isotopes, by relative abundance
142 //
143
144 G4Isotope* U5 = new G4Isotope(name="U235", iz=92, n=235, a=235.01*g/mole);
145 G4Isotope* U8 = new G4Isotope(name="U238", iz=92, n=238, a=238.03*g/mole);
146
147 G4Element* U = new G4Element(name="enriched Uranium",symbol="U",ncomponents=2);
148 U->AddIsotope(U5, abundance= 90.*perCent);
149 U->AddIsotope(U8, abundance= 10.*perCent);
150
151 //
152 // define simple materials
153 //
154
155 new G4Material(name="Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3);
156 new G4Material(name="Silicon", z=14., a= 28.09*g/mole, density= 2.33*g/cm3);
157 new G4Material(name="Iron", z=26., a=55.85*g/mole, density=7.87*g/cm3);
158 new G4Material(name="ArgonGas",z=18., a= 39.95*g/mole, density=1.782*mg/cm3);
159 new G4Material(name="He", z=2., a=4.0*g/mole, density=0.1786e-03*g/cm3);
160
161 density = 1.390*g/cm3;
162 a = 39.95*g/mole;
163 new G4Material(name="liquidArgon", z=18., a, density);
164
165 density = 11.35*g/cm3;
166 a = 207.19*g/mole;
167 G4Material* Pb = new G4Material(name="Lead" , z=82., a, density);
168
169 //
170 // define a material from elements. case 1: chemical molecule
171 //
172
173 density = 1.000*g/cm3;
174 G4Material* H2O = new G4Material(name="Water", density, ncomponents=2);
175 H2O->AddElement(H, natoms=2);
176 H2O->AddElement(O, natoms=1);
177
178 density = 1.032*g/cm3;
179 G4Material* Sci = new G4Material(name="Scintillator", density, ncomponents=2);
180 Sci->AddElement(C, natoms=9);
181 Sci->AddElement(H, natoms=10);
182
183 //
184 // define a material from elements. case 2: mixture by fractional mass
185 //
186
187 density = 1.290*mg/cm3;
188 G4Material* Air = new G4Material(name="Air" , density, ncomponents=2);
189 Air->AddElement(N, fractionmass=0.7);
190 Air->AddElement(O, fractionmass=0.3);
191
192 //
193 // examples of vacuum
194 //
195
196 density = universe_mean_density;
197 pressure = 3.e-18*pascal;
198 temperature = 2.73*kelvin;
199 G4Material* Vacuum = new G4Material(name="Galactic", z=1., a=1.01*g/mole,
200 density,kStateGas,temperature,pressure);
201
202 if (GetVerboseLevel()>1) {
203 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
204 }
205
206 //default materials of the calorimeter
207 fWorldMaterial = Vacuum;
209 fGapMaterial = Sci;
210}
211
212//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
213
215{
216 //
217 // World
218 //
219 G4VSolid* worldSolid = new G4Box("World",2.*m,2.*m,fTotalThickness*2.);
220 fWorldLogical = new G4LogicalVolume(worldSolid,fWorldMaterial,"World");
221 fWorldPhysical = new G4PVPlacement(0,G4ThreeVector(),fWorldLogical,"World",
222 0,false,0);
223
224 //
225 // Calorimeter
226 //
227 G4VSolid* calorSolid = new G4Box("Calor",0.5*m,0.5*m,fTotalThickness/2.);
229 fCalorPhysical = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),
231
232 //
233 // Layers --- as absorbers
234 //
235 fLayerSolid = new G4Box("Layer",0.5*m,0.5*m,fLayerThickness/2.);
241
242 //
243 // Gap
244 //
245 fGapSolid = new G4Box("Gap",0.5*m,0.5*m,fLayerThickness/4.);
247 fGapPhysical = new G4PVPlacement(0,G4ThreeVector(0.,0.,fLayerThickness/4.),
248 fGapLogical,fCalName+"_gap",fLayerLogical,false,0);
249
250 //
251 // Visualization attributes
252 //
253 fWorldLogical->SetVisAttributes(G4VisAttributes::GetInvisible());
254 G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
255 simpleBoxVisAtt->SetVisibility(true);
256 fCalorLogical->SetVisAttributes(simpleBoxVisAtt);
257 fLayerLogical->SetVisAttributes(simpleBoxVisAtt);
258 fGapLogical->SetVisAttributes(simpleBoxVisAtt);
259
260}
261
262//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
263
265{
266 G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
267 G4String filterName;
268
269 G4SDNeutralFilter* neutralFilter
270 = new G4SDNeutralFilter(filterName="neutralFilter");
271 G4SDChargedFilter* chargedFilter
272 = new G4SDChargedFilter(filterName="chargedFilter");
273
274 for(G4int j=0;j<2;j++)
275 {
276 // Loop counter j = 0 : absorber
277 // = 1 : gap
278 G4String detName = fCalName;
279 if(j==0)
280 { detName += "_abs"; }
281 else
282 { detName += "_gap"; }
284 G4SDManager::GetSDMpointer()->AddNewDetector(det);
285 // The second argument in each primitive means the "level" of geometrical
286 // hierarchy, the copy number of that level is used as the key of the
287 // G4THitsMap.
288 // For absorber (j = 0), the copy number of its own physical volume is used.
289 // For gap (j = 1), the copy number of its mother physical volume is used,
290 // since there is only one physical volume of gap is placed with respect
291 // to its mother.
292 G4VPrimitiveScorer* primitive;
293 primitive = new G4PSEnergyDeposit("eDep",j);
294 det->RegisterPrimitive(primitive);
295 primitive = new G4PSFlatSurfaceFlux("nNeutral",1,j);
296 primitive->SetFilter(neutralFilter);
297 det->RegisterPrimitive(primitive);
298 primitive = new G4PSFlatSurfaceFlux("nCharged",1,j);
299 primitive->SetFilter(chargedFilter);
300 det->RegisterPrimitive(primitive);
301
302 if(j==0)
303 { SetSensitiveDetector(fLayerLogical, det); }
304 else
305 { SetSensitiveDetector(fGapLogical, det);}
306
307 }
308 G4SDManager::GetSDMpointer()->SetVerboseLevel(0);
309}
310
311//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
312
314{
316 biasingOperator->AttachTo(fLayerLogical);
317}
318
319//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320
322{
323 G4cout
324 << "--------------------------------------------------------" << G4endl;
325 G4cout
326 << " Absorber is made of " << fAbsorberMaterial->GetName() << G4endl
327 << " Gap is made of " << fGapMaterial->GetName() << G4endl
328 << "--------------------------------------------------------" << G4endl;
329}
330
331//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
332
334{
335 // search the material by its name
336 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
337 if(pttoMaterial)
338 {
339 fAbsorberMaterial = pttoMaterial;
340 if(fConstructed)
341 {
342 fCalorLogical->SetMaterial(fAbsorberMaterial);
343 fLayerLogical->SetMaterial(fAbsorberMaterial);
344 }
345 G4RunManager::GetRunManager()->GeometryHasBeenModified();
346 if (GetVerboseLevel()>1) {
348 }
349 }
350 else
351 {
352 G4cerr
353 << materialChoice << " is not defined. - Command is ignored." << G4endl;
354 }
355}
356
357//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
358
361
362//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
363
365{
366 // search the material by its name
367 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
368 if(pttoMaterial)
369 {
370 fGapMaterial = pttoMaterial;
371 if(fConstructed)
372 { fGapLogical->SetMaterial(fGapMaterial); }
373 G4RunManager::GetRunManager()->GeometryHasBeenModified();
374 if (GetVerboseLevel()>1) {
376 }
377 }
378 else
379 {
380 G4cerr
381 << materialChoice << " is not defined. - Command is ignored." << G4endl;
382 }
383}
384
385//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
386
389
390//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
391
393{
394 fNumberOfLayers = nl;
396 if(!fConstructed) return;
397
398 fLayerSolid->SetZHalfLength(fLayerThickness/2.);
399 fGapSolid->SetZHalfLength(fLayerThickness/4.);
400
401 fCalorLogical->RemoveDaughter(fLayerPhysical);
402 delete fLayerPhysical;
406 fGapPhysical->SetTranslation(G4ThreeVector(0.,0.,fLayerThickness/4.));
407
408 G4RunManager::GetRunManager()->GeometryHasBeenModified();
409}
410
411//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector< ExP01TrackerHit * > a
Definition of the GB03BOptrGeometryBasedBiasing class.
Definition of the GB03DetectorConstruction class.
Definition of the GB03DetectorMessenger class.
static G4ThreadLocal G4bool fConstructedSDandField
void SetAbsorberMaterial(G4String materialChoice)
G4double fLayerThickness
total thinkness of one calorimeter
G4bool fConstructed
= fTotalThickness / fNumberOfLayers
virtual G4VPhysicalVolume * Construct()
GB03DetectorMessenger * fDetectorMessenger
void SetGapMaterial(G4String materialChoice)

Applications | User Support | Publications | Collaboration