Loading...
Searching...
No Matches
F01DetectorConstruction.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/// \file field/field01/src/F01DetectorConstruction.cc
27/// \brief Implementation of the F01DetectorConstruction class
28//
29//
30//
31//
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34
37
38#include "F01CalorimeterSD.hh"
39#include "F01FieldSetup.hh"
40
41#include "G4GeometryManager.hh"
42#include "G4PhysicalVolumeStore.hh"
43#include "G4LogicalVolumeStore.hh"
44#include "G4SolidStore.hh"
45#include "G4SDManager.hh"
46
47#include "G4Material.hh"
48#include "G4Tubs.hh"
49#include "G4LogicalVolume.hh"
50#include "G4PVPlacement.hh"
51#include "G4RunManager.hh"
52#include "G4AutoDelete.hh"
53
54#include "G4PhysicalConstants.hh"
55#include "G4SystemOfUnits.hh"
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58
60{
61 // create commands for interactive definition of the calorimeter
62
64
65 // create materials
66
68
69}
70
71//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79
84
85//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86
88{
89 //This function illustrates the possible ways to define materials
90
91 G4String name, symbol; // a=mass of a mole;
92 G4double a, z, density; // z=mean number of protons;
93 G4int nel;
94 G4int ncomponents;
95 G4double fractionmass, pressure, temperature;
96
97 //
98 // define Elements
99 //
100
101 a = 1.01*g/mole;
102 auto elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
103
104 a = 12.01*g/mole;
105 auto elC = new G4Element(name="Carbon", symbol="C", z=6., a);
106
107 a = 14.01*g/mole;
108 auto elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
109
110 a = 16.00*g/mole;
111 auto elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
112
113 a = 39.948*g/mole;
114 auto elAr = new G4Element(name="Argon", symbol="Ar", z=18., a);
115
116 //
117 // define simple materials
118 //
119
120 // Mylar
121
122 density = 1.39*g/cm3;
123 auto mylar = new G4Material(name="Mylar", density, nel=3);
124 mylar->AddElement(elO,2);
125 mylar->AddElement(elC,5);
126 mylar->AddElement(elH,4);
127
128 // Polypropelene
129
130 auto CH2 = new G4Material ("Polypropelene" , 0.91*g/cm3, 2);
131 CH2->AddElement(elH,2);
132 CH2->AddElement(elC,1);
133
134 // Krypton as detector gas, STP
135
136 density = 3.700*mg/cm3;
137 a = 83.80*g/mole;
138 auto Kr = new G4Material(name="Kr",z=36., a, density );
139
140 // Dry air (average composition)
141
142 density = 1.7836*mg/cm3; // STP
143 auto argon = new G4Material(name="Argon" , density, ncomponents=1);
144 argon->AddElement(elAr, 1);
145
146 density = 1.25053*mg/cm3; // STP
147 auto nitrogen = new G4Material(name="N2" , density, ncomponents=1);
148 nitrogen->AddElement(elN, 2);
149
150 density = 1.4289*mg/cm3; // STP
151 auto oxygen = new G4Material(name="O2" , density, ncomponents=1);
152 oxygen->AddElement(elO, 2);
153
154 density = 1.2928*mg/cm3; // STP
155 density *= 1.0e-8; // pumped vacuum
156
157 temperature = STP_Temperature;
158 pressure = 1.0e-8*STP_Pressure;
159
160 auto air = new G4Material(name="Air" , density, ncomponents=3,
161 kStateGas,temperature,pressure);
162 air->AddMaterial( nitrogen, fractionmass = 0.7557 );
163 air->AddMaterial( oxygen, fractionmass = 0.2315 );
164
165 air->AddMaterial( argon, fractionmass = 0.0128 );
166
167 // Xenon as detector gas, STP
168
169 density = 5.858*mg/cm3;
170 a = 131.29*g/mole;
171 auto Xe = new G4Material(name="Xenon",z=54., a, density );
172
173 // Carbon dioxide, STP
174
175 density = 1.842*mg/cm3;
176 auto CarbonDioxide = new G4Material(name="CO2", density, nel=2);
177 CarbonDioxide->AddElement(elC,1);
178 CarbonDioxide->AddElement(elO,2);
179
180 // 80% Xe + 20% CO2, STP
181
182 density = 5.0818*mg/cm3;
183 auto Xe20CO2 = new G4Material(name="Xe20CO2", density, ncomponents=2);
184 Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 );
185 Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 );
186
187 // 80% Kr + 20% CO2, STP
188
189 density = 3.601*mg/cm3;
190 auto Kr20CO2 = new G4Material(name="Kr20CO2", density, ncomponents=2);
191 Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 );
192 Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 );
193
194 // Print material table -- silence it for now
195 // G4cout << *(G4Material::GetMaterialTable()) << G4endl;
196 G4cout << "F01DetectorConstruction: not printing material table - to see it edit the source."
197 << G4endl;
198
199 // default materials of the calorimeter
200
201 fAbsorberMaterial = air; // Kr20CO2; // XeCO2CF4;
202
203 fWorldMaterial = air;
204}
205
206//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
207
209{
210 // Cleanup old geometry
211
212 if (fPhysiWorld)
213 {
214 G4GeometryManager::GetInstance()->OpenGeometry();
215 G4PhysicalVolumeStore::GetInstance()->Clean();
216 G4LogicalVolumeStore::GetInstance()->Clean();
217 G4SolidStore::GetInstance()->Clean();
218 }
219
220 // complete the Calor parameters definition and Print
221
224
225 // World
226
227 fSolidWorld = new G4Tubs("World", // its name
228 0.,fWorldSizeR,fWorldSizeZ/2.,0.,twopi);// its size
229
230 fLogicWorld = new G4LogicalVolume(fSolidWorld, // its solid
231 fWorldMaterial, // its material
232 "World"); // its name
233
234 fPhysiWorld = new G4PVPlacement(nullptr, // no rotation
235 G4ThreeVector(), // at (0,0,0)
236 "World", // its name
237 fLogicWorld, // its logical volume
238 nullptr, // its mother volume
239 false, // no boolean op.
240 0); // copy number
241 // Absorber
242
243 fSolidAbsorber = new G4Tubs("Absorber", 1.0*mm,
246 0.0,twopi);
247
250 "Absorber");
251
252 fPhysiAbsorber = new G4PVPlacement(nullptr,
253 G4ThreeVector(0.,0.,fZAbsorber),
254 "Absorber",
257 false,
258 0);
259
260 return fPhysiWorld;
261}
262
263//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
264
266{
267 G4cout << "\n The WORLD is made of "
268 << fWorldSizeZ/mm << "mm of " << fWorldMaterial->GetName();
269 G4cout << ", the transverse size (R) of the world is "
270 << fWorldSizeR/mm << " mm. " << G4endl;
271 G4cout << " The ABSORBER is made of "
272 << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName();
273 G4cout << ", the transverse size (R) is " << fAbsorberRadius/mm
274 << " mm. " << G4endl;
275 G4cout << " Z position of the (middle of the) absorber "
276 << fZAbsorber/mm << " mm." << G4endl;
277 G4cout << G4endl;
278}
279
280//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
281
283{
284 // get the pointer to the material table
285 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
286
287 // search the material by its name
288 G4Material* material;
289 for (size_t j=0 ; j<theMaterialTable->size() ; j++)
290 { material = (*theMaterialTable)[j];
291 if (material->GetName() == materialChoice)
292 {
293 fAbsorberMaterial = material;
294 fLogicAbsorber->SetMaterial(material);
295 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
296 }
297 }
298}
299
300//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
301
303{
304 // get the pointer to the material table
305 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
306
307 // search the material by its name
308 G4Material* material;
309 for (size_t j=0 ; j<theMaterialTable->size() ; j++)
310 { material = (*theMaterialTable)[j];
311 if(material->GetName() == materialChoice)
312 {
313 fWorldMaterial = material;
314 fLogicWorld->SetMaterial(material);
315 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
316 }
317 }
318}
319
320//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
321
323{
324 // change Absorber thickness and recompute the calorimeter parameters
325 fAbsorberThickness = val;
327 G4RunManager::GetRunManager()->ReinitializeGeometry();
328}
329
330//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
331
333{
334 // change the transverse size and recompute the calorimeter parameters
335 fAbsorberRadius = val;
337 G4RunManager::GetRunManager()->ReinitializeGeometry();
338}
339
340//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
341
343{
344 fWorldSizeZ = val;
346 G4RunManager::GetRunManager()->ReinitializeGeometry();
347}
348
349//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
350
352{
353 fWorldSizeR = val;
355 G4RunManager::GetRunManager()->ReinitializeGeometry();
356}
357
358//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
359
361{
362 fZAbsorber = val;
364 G4RunManager::GetRunManager()->ReinitializeGeometry();
365}
366
367//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
368#include "G4FieldManager.hh"
369
371{
372 // Sensitive Detectors: Absorber
373
374 if (!fCalorimeterSD.Get()) {
375 auto calorimeterSD = new F01CalorimeterSD("CalorSD",this);
376 fCalorimeterSD.Put(calorimeterSD);
377 }
378 G4SDManager::GetSDMpointer()->AddNewDetector(fCalorimeterSD.Get());
379 SetSensitiveDetector(fLogicAbsorber, fCalorimeterSD.Get());
380
381 // Construct the field creator - this will register the field it creates
382 if (!fEmFieldSetup.Get()) {
383 auto fieldSetup
384 = new F01FieldSetup(G4ThreeVector( 0.0, 0.0, 3.3*tesla ),
386 G4AutoDelete::Register(fieldSetup); // Kernel will delete the F01FieldSetup
387 fEmFieldSetup.Put(fieldSetup);
388 }
389}
390
391//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector< ExP01TrackerHit * > a
Definition of the F01CalorimeterSD class.
Definition of the F01DetectorConstruction class.
Definition of the F01DetectorMessenger class.
Definition of the F01FieldSetup class.
G4VPhysicalVolume * ConstructCalorimeter()
G4Cache< F01FieldSetup * > fEmFieldSetup
G4VPhysicalVolume * Construct() override
F01DetectorMessenger * fDetectorMessenger
G4Cache< F01CalorimeterSD * > fCalorimeterSD

Applications | User Support | Publications | Collaboration