source: trunk/examples/extended/field/field03/src/F03DetectorConstruction.cc@ 807

Last change on this file since 807 was 807, checked in by garnier, 17 years ago

update

File size: 15.1 KB
RevLine 
[807]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// $Id: F03DetectorConstruction.cc,v 1.12 2006/06/29 17:19:23 gunter Exp $
28// GEANT4 tag $Name: $
29//
30//
31
32#include "F03DetectorConstruction.hh"
33#include "F03DetectorMessenger.hh"
34#include "F03CalorimeterSD.hh"
35#include "F03FieldSetup.hh"
36
37#include "G4Material.hh"
38#include "G4Tubs.hh"
39#include "G4LogicalVolume.hh"
40#include "G4PVPlacement.hh"
41#include "G4UniformMagField.hh"
42#include "G4FieldManager.hh"
43#include "G4TransportationManager.hh"
44#include "G4SDManager.hh"
45#include "G4RunManager.hh"
46
47#include "G4GeometryManager.hh"
48#include "G4PhysicalVolumeStore.hh"
49#include "G4LogicalVolumeStore.hh"
50#include "G4SolidStore.hh"
51
52#include "G4ios.hh"
53
54/////////////////////////////////////////////////////////////////////////////
55//
56//
57
58F03DetectorConstruction::F03DetectorConstruction()
59 : solidWorld(0), logicWorld(0), physiWorld(0),
60 solidAbsorber(0),logicAbsorber(0), physiAbsorber(0),
61 magField(0), fEmFieldSetup(0), calorimeterSD(0),
62 AbsorberMaterial(0), fRadiatorMat(0), worldchanged(false), WorldMaterial(0)
63{
64 // default parameter values of the calorimeter
65
66 WorldSizeZ = 44000.*mm;
67 WorldSizeR = 22000.*mm;
68
69 AbsorberThickness = 1.0*mm;
70
71 AbsorberRadius = 20000.*mm;
72
73 zAbsorber = 21990.0*mm ;
74
75 fRadThickness = 100*mm ;
76 fGasGap = 100*mm ;
77 fFoilNumber = 1 ;
78
79 fDetGap = 1.0*mm ;
80
81 fStartR = 40*cm ;
82 fStartZ = 10.0*mm ;
83
84 // create commands for interactive definition of the calorimeter
85
86 detectorMessenger = new F03DetectorMessenger(this);
87
88 DefineMaterials();
89
90 fEmFieldSetup = new F03FieldSetup() ;
91}
92
93//////////////////////////////////////////////////////////////////////////
94//
95//
96
97F03DetectorConstruction::~F03DetectorConstruction()
98{
99 delete detectorMessenger;
100 if (fEmFieldSetup) delete fEmFieldSetup ;
101}
102
103//////////////////////////////////////////////////////////////////////////
104//
105//
106
107G4VPhysicalVolume* F03DetectorConstruction::Construct()
108{
109 return ConstructCalorimeter();
110}
111
112//////////////////////////////////////////////////////////////////////////////
113//
114//
115
116void F03DetectorConstruction::DefineMaterials()
117{
118 // This function illustrates the possible ways to define materials
119
120 G4String name, symbol ; // a=mass of a mole;
121 G4double a, z, density ; // z=mean number of protons;
122 G4int nel ;
123 G4int ncomponents;
124 G4double fractionmass, pressure, temperature;
125
126 //
127 // define Elements
128 //
129
130 a = 1.01*g/mole;
131 G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
132
133 a = 12.01*g/mole;
134 G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a);
135
136 a = 14.01*g/mole;
137 G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
138
139 a = 16.00*g/mole;
140 G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
141
142 a = 39.948*g/mole;
143 G4Element* elAr = new G4Element(name="Argon", symbol="Ar", z=18., a);
144
145 //
146 // define simple materials
147 //
148
149 // Mylar
150
151 density = 1.39*g/cm3;
152 G4Material* Mylar = new G4Material(name="Mylar", density, nel=3);
153 Mylar->AddElement(elO,2);
154 Mylar->AddElement(elC,5);
155 Mylar->AddElement(elH,4);
156
157 // Polypropelene
158
159 G4Material* CH2 = new G4Material ("Polypropelene" , 0.91*g/cm3, 2);
160 CH2->AddElement(elH,2);
161 CH2->AddElement(elC,1);
162
163 // Krypton as detector gas, STP
164
165 density = 3.700*mg/cm3 ;
166 a = 83.80*g/mole ;
167 G4Material* Kr = new G4Material(name="Kr",z=36., a, density );
168
169 // Dry air (average composition)
170
171 density = 1.7836*mg/cm3 ; // STP
172 G4Material* Argon = new G4Material(name="Argon" , density, ncomponents=1);
173 Argon->AddElement(elAr, 1);
174
175 density = 1.25053*mg/cm3 ; // STP
176 G4Material* Nitrogen = new G4Material(name="N2" , density, ncomponents=1);
177 Nitrogen->AddElement(elN, 2);
178
179 density = 1.4289*mg/cm3 ; // STP
180 G4Material* Oxygen = new G4Material(name="O2" , density, ncomponents=1);
181 Oxygen->AddElement(elO, 2);
182
183 density = 1.2928*mg/cm3 ; // STP
184 density *= 1.0e-8 ; // pumped vacuum
185 temperature = STP_Temperature;
186 pressure = 1.0e-8*STP_Pressure;
187
188 G4Material* Air = new G4Material(name="Air" , density, ncomponents=3,
189 kStateGas,temperature,pressure);
190 Air->AddMaterial( Nitrogen, fractionmass = 0.7557 ) ;
191 Air->AddMaterial( Oxygen, fractionmass = 0.2315 ) ;
192 Air->AddMaterial( Argon, fractionmass = 0.0128 ) ;
193
194 // Xenon as detector gas, STP
195
196 density = 5.858*mg/cm3 ;
197 a = 131.29*g/mole ;
198 G4Material* Xe = new G4Material(name="Xenon",z=54., a, density );
199
200 // Carbon dioxide, STP
201
202 density = 1.977*mg/cm3;
203 G4Material* CarbonDioxide = new G4Material(name="CO2", density, nel=2);
204 CarbonDioxide->AddElement(elC,1);
205 CarbonDioxide->AddElement(elO,2);
206
207 // 80% Xe + 20% CO2, STP
208
209 density = 5.0818*mg/cm3 ;
210 G4Material* Xe20CO2 = new G4Material(name="Xe20CO2" , density, ncomponents=2);
211 Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 ) ;
212 Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 ) ;
213
214 // 80% Kr + 20% CO2, STP
215
216 density = 3.601*mg/cm3 ;
217 G4Material* Kr20CO2 = new G4Material(name="Kr20CO2" , density,
218 ncomponents=2);
219 Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 ) ;
220 Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 ) ;
221
222
223 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
224
225 //default materials of the calorimeter and TR radiator
226
227 fRadiatorMat = Air ; // CH2 ; // Mylar ;
228
229 AbsorberMaterial = Air ; // Kr20CO2 ; // XeCO2CF4 ;
230
231 WorldMaterial = Air ;
232}
233
234/////////////////////////////////////////////////////////////////////////
235//
236//
237
238G4VPhysicalVolume* F03DetectorConstruction::ConstructCalorimeter()
239{
240 G4int j ;
241 G4double zModule, zRadiator;
242
243 // complete the Calor parameters definition and Print
244
245 ComputeCalorParameters();
246 PrintCalorParameters();
247
248 // Cleanup old geometry
249
250 if (physiWorld)
251 {
252 G4GeometryManager::GetInstance()->OpenGeometry();
253 G4PhysicalVolumeStore::GetInstance()->Clean();
254 G4LogicalVolumeStore::GetInstance()->Clean();
255 G4SolidStore::GetInstance()->Clean();
256 }
257
258 solidWorld = new G4Tubs("World", // its name
259 0.,WorldSizeR,WorldSizeZ/2.,0.,twopi); // its size
260
261 logicWorld = new G4LogicalVolume(solidWorld, // its solid
262 WorldMaterial, // its material
263 "World"); // its name
264
265 physiWorld = new G4PVPlacement(0, // no rotation
266 G4ThreeVector(), // at (0,0,0)
267 "World", // its name
268 logicWorld, // its logical volume
269 0, // its mother volume
270 false, // no boolean operation
271 0); // copy number
272
273 // TR radiator envelope
274
275 G4double radThick = fFoilNumber*(fRadThickness + fGasGap) + fDetGap ;
276
277 G4double zRad = zAbsorber - 20*cm - 0.5*radThick ;
278 G4cout<<"zRad = "<<zRad/mm<<" mm"<<G4endl ;
279
280 radThick *= 1.02 ;
281 G4cout<<"radThick = "<<radThick/mm<<" mm"<<G4endl ;
282 G4cout<<"fFoilNumber = "<<fFoilNumber<<G4endl ;
283 G4cout<<"fRadiatorMat = "<<fRadiatorMat->GetName()<<G4endl ;
284 G4cout<<"WorldMaterial = "<<WorldMaterial->GetName()<<G4endl ;
285
286 solidRadiator = new G4Tubs("Radiator",0.0,
287 1.01*AbsorberRadius,
288 0.5*radThick,0.0,twopi ) ;
289
290 logicRadiator = new G4LogicalVolume(solidRadiator,
291 WorldMaterial,
292 "Radiator");
293
294 // Set local field manager and local field in radiator and its daughters:
295
296 G4bool allLocal = true ;
297
298 logicRadiator->SetFieldManager( fEmFieldSetup->GetLocalFieldManager(),
299 allLocal ) ;
300
301
302 physiRadiator = new G4PVPlacement(0,
303 G4ThreeVector(0,0,zRad),
304 "Radiator", logicRadiator,
305 physiWorld, false, 0 );
306
307 fSolidRadSlice = new G4Tubs("RadSlice",0.0,
308 AbsorberRadius,0.5*fRadThickness,0.0,twopi ) ;
309
310 fLogicRadSlice = new G4LogicalVolume(fSolidRadSlice,fRadiatorMat,
311 "RadSlice",0,0,0);
312
313 zModule = zRad + 0.5*radThick/1.02 ;
314 G4cout<<"zModule = "<<zModule/mm<<" mm"<<G4endl ;
315
316 for(j=0;j<fFoilNumber;j++)
317 {
318
319 zRadiator = zModule - j*(fRadThickness + fGasGap) ;
320 G4cout<<zRadiator/mm<<" mm"<<"\t" ;
321 // G4cout<<"j = "<<j<<"\t" ;
322
323 fPhysicRadSlice = new G4PVPlacement(0,G4ThreeVector(0.,0.,zRadiator-zRad),
324 "RadSlice",fLogicRadSlice,
325 physiRadiator,false,j);
326 }
327 G4cout<<G4endl ;
328
329 // Absorber
330
331 if (AbsorberThickness > 0.)
332 {
333 solidAbsorber = new G4Tubs("Absorber", 1.0*mm,
334 AbsorberRadius,
335 AbsorberThickness/2.,
336 0.0,twopi);
337
338 logicAbsorber = new G4LogicalVolume(solidAbsorber,
339 AbsorberMaterial,
340 "Absorber");
341
342 physiAbsorber = new G4PVPlacement(0,
343 G4ThreeVector(0.,0.,zAbsorber),
344 "Absorber",
345 logicAbsorber,
346 physiWorld,
347 false,
348 0);
349 }
350
351 // Sensitive Detectors: Absorber
352
353 G4SDManager* SDman = G4SDManager::GetSDMpointer();
354
355 if(!calorimeterSD)
356 {
357 calorimeterSD = new F03CalorimeterSD("CalorSD",this);
358 SDman->AddNewDetector( calorimeterSD );
359 }
360 if (logicAbsorber) logicAbsorber->SetSensitiveDetector(calorimeterSD);
361
362 return physiWorld;
363}
364
365////////////////////////////////////////////////////////////////////////////
366//
367//
368
369void F03DetectorConstruction::PrintCalorParameters()
370{
371 G4cout << "\n The WORLD is made of "
372 << WorldSizeZ/mm << "mm of " << WorldMaterial->GetName() ;
373 G4cout << ", the transverse size (R) of the world is " << WorldSizeR/mm << " mm. " << G4endl;
374 G4cout << " The ABSORBER is made of "
375 << AbsorberThickness/mm << "mm of " << AbsorberMaterial->GetName() ;
376 G4cout << ", the transverse size (R) is " << AbsorberRadius/mm << " mm. " << G4endl;
377 G4cout << " Z position of the (middle of the) absorber " << zAbsorber/mm << " mm." << G4endl;
378 G4cout << G4endl;
379}
380
381///////////////////////////////////////////////////////////////////////////
382//
383//
384
385void F03DetectorConstruction::SetAbsorberMaterial(G4String materialChoice)
386{
387 // get the pointer to the material table
388 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
389
390 // search the material by its name
391 G4Material* pttoMaterial;
392 for (size_t J=0 ; J<theMaterialTable->size() ; J++)
393 {
394 pttoMaterial = (*theMaterialTable)[J];
395 if(pttoMaterial->GetName() == materialChoice)
396 {
397 AbsorberMaterial = pttoMaterial;
398 logicAbsorber->SetMaterial(pttoMaterial);
399 }
400 }
401}
402
403////////////////////////////////////////////////////////////////////////////
404//
405//
406
407void F03DetectorConstruction::SetWorldMaterial(G4String materialChoice)
408{
409 // get the pointer to the material table
410 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
411
412 // search the material by its name
413 G4Material* pttoMaterial;
414 for (size_t J=0 ; J<theMaterialTable->size() ; J++)
415 {
416 pttoMaterial = (*theMaterialTable)[J];
417 if(pttoMaterial->GetName() == materialChoice)
418 {
419 WorldMaterial = pttoMaterial;
420 logicWorld->SetMaterial(pttoMaterial);
421 }
422 }
423}
424
425///////////////////////////////////////////////////////////////////////////
426//
427//
428
429void F03DetectorConstruction::SetAbsorberThickness(G4double val)
430{
431 // change Absorber thickness and recompute the calorimeter parameters
432 AbsorberThickness = val;
433 ComputeCalorParameters();
434}
435
436/////////////////////////////////////////////////////////////////////////////
437//
438//
439
440void F03DetectorConstruction::SetAbsorberRadius(G4double val)
441{
442 // change the transverse size and recompute the calorimeter parameters
443 AbsorberRadius = val;
444 ComputeCalorParameters();
445}
446
447////////////////////////////////////////////////////////////////////////////
448//
449//
450
451void F03DetectorConstruction::SetWorldSizeZ(G4double val)
452{
453 worldchanged=true;
454 WorldSizeZ = val;
455 ComputeCalorParameters();
456}
457
458///////////////////////////////////////////////////////////////////////////
459//
460//
461
462void F03DetectorConstruction::SetWorldSizeR(G4double val)
463{
464 worldchanged=true;
465 WorldSizeR = val;
466 ComputeCalorParameters();
467}
468
469//////////////////////////////////////////////////////////////////////////////
470//
471//
472
473void F03DetectorConstruction::SetAbsorberZpos(G4double val)
474{
475 zAbsorber = val;
476 ComputeCalorParameters();
477}
478
479
480///////////////////////////////////////////////////////////////////////////////
481//
482//
483
484void F03DetectorConstruction::UpdateGeometry()
485{
486 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
487}
488
489//
490//
491////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.