Loading...
Searching...
No Matches
F03DetectorConstruction.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/field03/src/F03DetectorConstruction.cc
27/// \brief Implementation of the F03DetectorConstruction class
28//
29//
30//
31//
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34
37
38#include "F03CalorimeterSD.hh"
39#include "F03FieldSetup.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
67
68//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69
74
75//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76
81
82//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
83
85{
86 //This function illustrates the possible ways to define materials
87
88 G4String name, symbol; // a=mass of a mole;
89 G4double a, z, density; // z=mean number of protons;
90 G4int nel;
91 G4int ncomponents;
92 G4double fractionmass, pressure, temperature;
93
94 //
95 // define Elements
96 //
97
98 a = 1.01*g/mole;
99 auto elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
100
101 a = 12.01*g/mole;
102 auto elC = new G4Element(name="Carbon", symbol="C", z=6., a);
103
104 a = 14.01*g/mole;
105 auto elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
106
107 a = 16.00*g/mole;
108 auto elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
109
110 a = 39.948*g/mole;
111 auto elAr = new G4Element(name="Argon", symbol="Ar", z=18., a);
112
113 //
114 // define simple materials
115 //
116
117 // Mylar
118
119 density = 1.39*g/cm3;
120 auto mylar = new G4Material(name="Mylar", density, nel=3);
121 mylar->AddElement(elO,2);
122 mylar->AddElement(elC,5);
123 mylar->AddElement(elH,4);
124
125 // Polypropelene
126
127 auto CH2 = new G4Material ("Polypropelene" , 0.91*g/cm3, 2);
128 CH2->AddElement(elH,2);
129 CH2->AddElement(elC,1);
130
131 // Krypton as detector gas, STP
132
133 density = 3.700*mg/cm3;
134 a = 83.80*g/mole;
135 auto Kr = new G4Material(name="Kr",z=36., a, density );
136
137 // Dry air (average composition)
138
139 density = 1.7836*mg/cm3; // STP
140 auto argon = new G4Material(name="Argon" , density, ncomponents=1);
141 argon->AddElement(elAr, 1);
142
143 density = 1.25053*mg/cm3; // STP
144 auto nitrogen = new G4Material(name="N2" , density, ncomponents=1);
145 nitrogen->AddElement(elN, 2);
146
147 density = 1.4289*mg/cm3; // STP
148 auto oxygen = new G4Material(name="O2" , density, ncomponents=1);
149 oxygen->AddElement(elO, 2);
150
151 density = 1.2928*mg/cm3; // STP
152 density *= 1.0e-8; // pumped vacuum
153 temperature = STP_Temperature;
154 pressure = 1.0e-8*STP_Pressure;
155
156 auto air = new G4Material(name="Air" , density, ncomponents=3,
157 kStateGas,temperature,pressure);
158 air->AddMaterial( nitrogen, fractionmass = 0.7557 );
159 air->AddMaterial( oxygen, fractionmass = 0.2315 );
160 air->AddMaterial( argon, fractionmass = 0.0128 );
161
162 // Xenon as detector gas, STP
163
164 density = 5.858*mg/cm3;
165 a = 131.29*g/mole;
166 auto Xe = new G4Material(name="Xenon",z=54., a, density );
167
168 // Carbon dioxide, STP
169
170 density = 1.842*mg/cm3;
171 auto CarbonDioxide = new G4Material(name="CO2", density, nel=2);
172 CarbonDioxide->AddElement(elC,1);
173 CarbonDioxide->AddElement(elO,2);
174
175 // 80% Xe + 20% CO2, STP
176
177 density = 5.0818*mg/cm3;
178 auto Xe20CO2 = new G4Material(name="Xe20CO2", density, ncomponents=2);
179 Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 );
180 Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 );
181
182 // 80% Kr + 20% CO2, STP
183
184 density = 3.601*mg/cm3;
185 auto Kr20CO2 = new G4Material(name="Kr20CO2", density, ncomponents=2);
186 Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 );
187 Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 );
188
189 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
190
191 //default materials of the calorimeter and TR radiator
192
193 fRadiatorMat = air; // CH2 ; // mylar;
194
195 fAbsorberMaterial = air; // Kr20CO2; // XeCO2CF4;
196
197 fWorldMaterial = air;
198}
199
200//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
201
203{
204 // Cleanup old geometry
205
206 if (fPhysiWorld)
207 {
208 G4GeometryManager::GetInstance()->OpenGeometry();
209 G4PhysicalVolumeStore::GetInstance()->Clean();
210 G4LogicalVolumeStore::GetInstance()->Clean();
211 G4SolidStore::GetInstance()->Clean();
212 }
213
214 // complete the Calor parameters definition and Print
215
218
219 G4bool checkOverlaps = true;
220
221 fSolidWorld = new G4Tubs("World", // its name
222 0.,fWorldSizeR,fWorldSizeZ/2.,0.,twopi);// its size
223
224 fLogicWorld = new G4LogicalVolume(fSolidWorld, // its solid
225 fWorldMaterial, // its material
226 "World"); // its name
227
228 fPhysiWorld = new G4PVPlacement(nullptr, // no rotation
229 G4ThreeVector(), // at (0,0,0)
230 "World", // its name
231 fLogicWorld, // its logical volume
232 nullptr, // its mother volume
233 false, // no boolean op.
234 0, // copy number
235 checkOverlaps); // checkOverlaps
236
237 // TR radiator envelope
238 G4double radThick = fFoilNumber*(fRadThickness + fGasGap) + fDetGap;
239 G4double zRad = fZAbsorber - 0.5*(radThick + fAbsorberThickness);
240
241 G4cout << "zRad = " << zRad/mm << " mm" << G4endl;
242 G4cout << "radThick = " << radThick/mm << " mm" << G4endl;
243 G4cout << "fFoilNumber = " << fFoilNumber << G4endl;
244 G4cout << "fRadiatorMat = " << fRadiatorMat->GetName() << G4endl;
245 G4cout << "WorldMaterial = " << fWorldMaterial->GetName() << G4endl;
246
247 fSolidRadiator = new G4Tubs("Radiator", 0.0, fAbsorberRadius, 0.5*radThick,
248 0.0, twopi);
249
251 "Radiator");
252
253 fPhysiRadiator = new G4PVPlacement(nullptr, G4ThreeVector(0,0,zRad),
254 "Radiator", fLogicRadiator, fPhysiWorld, false, 0,
255 checkOverlaps);
256
257
258 fSolidRadSlice = new G4Tubs("RadSlice",0.0, fAbsorberRadius, 0.5*fRadThickness,
259 0.0, twopi);
260
262
263 // Radiator slice
264 G4double radSliceThick = fRadThickness +fGasGap;
265 G4double zStart = 0.5*(-radThick + radSliceThick) + fDetGap;
266 // start on the board of radiator enevelope + det gap
267
268 for (G4int j=0;j<fFoilNumber;j++)
269 {
270 G4double zSlice = zStart + j*radSliceThick;
271 G4cout << zSlice/mm << " mm" << "\t";
272
273 fPhysiRadSlice = new G4PVPlacement(nullptr,G4ThreeVector(0.,0., zSlice),
274 "RadSlice",fLogicRadSlice,
275 fPhysiRadiator,false,j, checkOverlaps);
276 }
277 G4cout << G4endl;
278
279 // Absorber
280
281 fSolidAbsorber = new G4Tubs("Absorber", 1.0*mm,
284 0.0,twopi);
285
288 "Absorber");
289
290 fPhysiAbsorber = new G4PVPlacement(nullptr,
291 G4ThreeVector(0.,0.,fZAbsorber),
292 "Absorber",
295 false,
296 0,
297 checkOverlaps);
298
299 return fPhysiWorld;
300}
301
302//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
303
305{
306 G4cout << "\n The WORLD is made of "
307 << fWorldSizeZ/mm << "mm of " << fWorldMaterial->GetName();
308 G4cout << ", the transverse size (R) of the world is "
309 << fWorldSizeR/mm << " mm. " << G4endl;
310 G4cout << " The ABSORBER is made of "
311 << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName();
312 G4cout << ", the transverse size (R) is " << fAbsorberRadius/mm
313 << " mm. " << G4endl;
314 G4cout << " Z position of the (middle of the) absorber "
315 << fZAbsorber/mm << " mm." << G4endl;
316 G4cout << G4endl;
317}
318
319//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320
322{
323 // get the pointer to the material table
324 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
325
326 // search the material by its name
327 G4Material* material;
328 for (size_t j=0 ; j<theMaterialTable->size() ; j++)
329 { material = (*theMaterialTable)[j];
330 if (material->GetName() == materialChoice)
331 {
332 fAbsorberMaterial = material;
333 fLogicAbsorber->SetMaterial(material);
334 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
335 }
336 }
337}
338
339//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
340
342{
343 // get the pointer to the material table
344 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
345
346 // search the material by its name
347 G4Material* material;
348 for (size_t j=0 ; j<theMaterialTable->size() ; j++)
349 { material = (*theMaterialTable)[j];
350 if(material->GetName() == materialChoice)
351 {
352 fWorldMaterial = material;
353 fLogicWorld->SetMaterial(material);
354 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
355 }
356 }
357}
358
359//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
360
362{
363 // change Absorber thickness and recompute the calorimeter parameters
364 fAbsorberThickness = val;
366 G4RunManager::GetRunManager()->ReinitializeGeometry();
367}
368
369//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
370
372{
373 // change the transverse size and recompute the calorimeter parameters
374 fAbsorberRadius = val;
376 G4RunManager::GetRunManager()->ReinitializeGeometry();
377}
378
379//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
380
382{
383 fWorldSizeZ = val;
385 G4RunManager::GetRunManager()->ReinitializeGeometry();
386}
387
388//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
389
391{
392 fWorldSizeR = val;
394 G4RunManager::GetRunManager()->ReinitializeGeometry();
395}
396
397//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
398
400{
401 fZAbsorber = val;
403 G4RunManager::GetRunManager()->ReinitializeGeometry();
404}
405
406//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
407
409{
410 // Sensitive Detectors: Absorber
411
412 if (!fCalorimeterSD.Get()) {
413 auto calorimeterSD = new F03CalorimeterSD("CalorSD",this);
414 fCalorimeterSD.Put(calorimeterSD);
415 }
416 G4SDManager::GetSDMpointer()->AddNewDetector(fCalorimeterSD.Get());
417 SetSensitiveDetector(fLogicAbsorber, fCalorimeterSD.Get());
418
419 // Construct the field creator - this will register the field it creates
420
421 if (!fEmFieldSetup.Get()) {
422 auto emFieldSetup = new F03FieldSetup();
423
424 fEmFieldSetup.Put(emFieldSetup);
425 G4AutoDelete::Register(emFieldSetup); //Kernel will delete the messenger
426 }
427 // Set local field manager and local field in radiator and its daughters:
428 G4bool allLocal = true;
429 fLogicRadiator->SetFieldManager(fEmFieldSetup.Get()->GetLocalFieldManager(),
430 allLocal );
431}
432
433//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector< ExP01TrackerHit * > a
Definition of the F03CalorimeterSD class.
Definition of the F03DetectorConstruction class.
Definition of the F03DetectorMessenger class.
Definition of the F03FieldSetup class.
F03DetectorMessenger * fDetectorMessenger
G4VPhysicalVolume * Construct() override
G4Cache< F03CalorimeterSD * > fCalorimeterSD
G4VPhysicalVolume * ConstructCalorimeter()
G4Cache< F03FieldSetup * > fEmFieldSetup
A class for setting up the Magnetic Field.

Applications | User Support | Publications | Collaboration