Loading...
Searching...
No Matches
F02DetectorConstruction.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/field02/src/F02DetectorConstruction.cc
27/// \brief Implementation of the F02DetectorConstruction class
28//
29//
30//
31//
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34
37
38#include "F02CalorimeterSD.hh"
40
41#include "G4GeometryManager.hh"
42#include "G4PhysicalVolumeStore.hh"
43#include "G4LogicalVolumeStore.hh"
44#include "G4SolidStore.hh"
45
46#include "G4Material.hh"
47#include "G4Tubs.hh"
48#include "G4LogicalVolume.hh"
49#include "G4PVPlacement.hh"
50#include "G4RunManager.hh"
51#include "G4AutoDelete.hh"
52#include "G4SDManager.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
156 temperature = STP_Temperature;
157 pressure = 1.0e-0*STP_Pressure;
158
159 auto air = new G4Material(name="Air" , density, ncomponents=3,
160 kStateGas,temperature,pressure);
161 air->AddMaterial( nitrogen, fractionmass = 0.7557 );
162 air->AddMaterial( oxygen, fractionmass = 0.2315 );
163 air->AddMaterial( argon, fractionmass = 0.0128 );
164
165 // Xenon as detector gas, STP
166
167 density = 5.858*mg/cm3;
168 a = 131.29*g/mole;
169 auto Xe = new G4Material(name="Xenon",z=54., a, density );
170
171 // Carbon dioxide, STP
172
173 density = 1.842*mg/cm3;
174 auto CarbonDioxide = new G4Material(name="CO2", density, nel=2);
175 CarbonDioxide->AddElement(elC,1);
176 CarbonDioxide->AddElement(elO,2);
177
178 // 80% Xe + 20% CO2, STP
179
180 density = 5.0818*mg/cm3;
181 auto Xe20CO2 = new G4Material(name="Xe20CO2", density, ncomponents=2);
182 Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 );
183 Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 );
184
185 // 80% Kr + 20% CO2, STP
186
187 density = 3.601*mg/cm3;
188 auto Kr20CO2 = new G4Material(name="Kr20CO2", density, ncomponents=2);
189 Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 );
190 Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 );
191
192 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
193
194 // default materials of the calorimeter
195
196 fAbsorberMaterial = Kr20CO2; // XeCO2CF4;
197
198 fWorldMaterial = air;
199}
200
201//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
202
204{
205 // Cleanup old geometry
206
207 if (fPhysiWorld)
208 {
209 G4GeometryManager::GetInstance()->OpenGeometry();
210 G4PhysicalVolumeStore::GetInstance()->Clean();
211 G4LogicalVolumeStore::GetInstance()->Clean();
212 G4SolidStore::GetInstance()->Clean();
213 }
214
215 // complete the Calor parameters definition and Print
216
219
220 // World
221
222 fSolidWorld = new G4Tubs("World", // its name
223 0.,fWorldSizeR,fWorldSizeZ/2.,0.,twopi);// its size
224
225 fLogicWorld = new G4LogicalVolume(fSolidWorld, // its solid
226 fWorldMaterial, // its material
227 "World"); // its name
228
229 fPhysiWorld = new G4PVPlacement(nullptr, // no rotation
230 G4ThreeVector(), // at (0,0,0)
231 "World", // its name
232 fLogicWorld, // its logical volume
233 nullptr, // its mother volume
234 false, // no boolean op.
235 0); // copy number
236 // Absorber
237
238 fSolidAbsorber = new G4Tubs("Absorber",0.,
241 0.0,twopi);
242
245 "Absorber");
246
247 fPhysiAbsorber = new G4PVPlacement(nullptr,
248 G4ThreeVector(0.,0.,fZAbsorber),
249 "Absorber",
252 false,
253 0);
254
255 return fPhysiWorld;
256}
257
258//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
259
261{
262 G4cout << "\n The WORLD is made of "
263 << fWorldSizeZ/mm << "mm of " << fWorldMaterial->GetName();
264 G4cout << ", the transverse size (R) of the world is "
265 << fWorldSizeR/mm << " mm. " << G4endl;
266 G4cout << " The ABSORBER is made of "
267 << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName();
268 G4cout << ", the transverse size (R) is " << fAbsorberRadius/mm
269 << " mm. " << G4endl;
270 G4cout << " Z position of the (middle of the) absorber "
271 << fZAbsorber/mm << " mm." << G4endl;
272 G4cout << G4endl;
273}
274
275//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
276
278{
279 // get the pointer to the material table
280 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
281
282 // search the material by its name
283 G4Material* material;
284 for (size_t j=0 ; j<theMaterialTable->size() ; j++)
285 { material = (*theMaterialTable)[j];
286 if (material->GetName() == materialChoice)
287 {
288 fAbsorberMaterial = material;
289 fLogicAbsorber->SetMaterial(material);
290 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
291 }
292 }
293}
294
295//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
296
298{
299 // get the pointer to the material table
300 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
301
302 // search the material by its name
303 G4Material* material;
304 for (size_t j=0 ; j<theMaterialTable->size() ; j++)
305 { material = (*theMaterialTable)[j];
306 if(material->GetName() == materialChoice)
307 {
308 fWorldMaterial = material;
309 fLogicWorld->SetMaterial(material);
310 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
311 }
312 }
313}
314
315//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
316
318{
319 // change Absorber thickness and recompute the calorimeter parameters
320 fAbsorberThickness = val;
322 G4RunManager::GetRunManager()->ReinitializeGeometry();
323}
324
325//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
326
328{
329 // change the transverse size and recompute the calorimeter parameters
330 fAbsorberRadius = val;
332 G4RunManager::GetRunManager()->ReinitializeGeometry();
333}
334
335//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
336
338{
339 fWorldChanged = true;
340 fWorldSizeZ = val;
342 G4RunManager::GetRunManager()->ReinitializeGeometry();
343}
344
345//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
346
348{
349 fWorldChanged = true;
350 fWorldSizeR = val;
352 G4RunManager::GetRunManager()->ReinitializeGeometry();
353}
354
355//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
356
358{
359 fZAbsorber = val;
361 G4RunManager::GetRunManager()->ReinitializeGeometry();
362}
363
364//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
365
367{
368 // Sensitive Detectors: Absorber
369
370 if (!fCalorimeterSD.Get()) {
371 auto calorimeterSD = new F02CalorimeterSD("CalorSD",this);
372 fCalorimeterSD.Put(calorimeterSD);
373 }
374 G4SDManager::GetSDMpointer()->AddNewDetector(fCalorimeterSD.Get());
375 SetSensitiveDetector(fLogicAbsorber, fCalorimeterSD.Get());
376
377 // Construct the field creator - this will register the field it creates
378
379 if (!fEmFieldSetup.Get()) {
380 auto fieldSetup = new F02ElectricFieldSetup();
381 G4AutoDelete::Register(fieldSetup); //Kernel will delete the messenger
382 fEmFieldSetup.Put(fieldSetup);
383 }
384}
385
386//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector< ExP01TrackerHit * > a
Definition of the F02CalorimeterSD class.
Definition of the F02DetectorConstruction class.
Definition of the F02DetectorMessenger class.
Definition of the F02ElectricFieldSetup class.
G4VPhysicalVolume * Construct() override
F02DetectorMessenger * fDetectorMessenger
G4VPhysicalVolume * ConstructCalorimeter()
G4Cache< F02ElectricFieldSetup * > fEmFieldSetup
G4Cache< F02CalorimeterSD * > fCalorimeterSD
A class for control of the Electric Field of the detector.

Applications | User Support | Publications | Collaboration