Geant4  10.02
DetectorConstruction.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 // $Id: DetectorConstruction.cc 83418 2014-08-21 15:30:47Z gcosmo $
27 //
28 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 
31 #include "DetectorConstruction.hh"
32 
33 #include "G4SystemOfUnits.hh"
34 #include "G4PhysicalConstants.hh"
35 #include "G4Material.hh"
36 #include "G4Tubs.hh"
37 #include "G4Box.hh"
38 #include "G4LogicalVolume.hh"
39 #include "G4PVPlacement.hh"
40 #include "G4PVReplica.hh"
41 #include "G4Transform3D.hh"
42 #include "G4RotationMatrix.hh"
43 
44 #include "G4GeometryManager.hh"
45 #include "G4PhysicalVolumeStore.hh"
46 #include "G4LogicalVolumeStore.hh"
47 #include "G4SolidStore.hh"
48 
49 #include "G4VisAttributes.hh"
50 
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 
55 :fiberMat(0),lvol_fiber(0), absorberMat(0),lvol_layer(0),
56  moduleMat(0),lvol_module(0), calorimeterMat(0),lvol_calorimeter(0),
57  worldMat(0),pvol_world(0), defaultMat(0)
58 {
59  // materials
61 
62  // default parameter values of calorimeter
63  //
64  fiberDiameter = 1.13*mm; //1.08*mm
65  nbOfFibers = 490; //490
66  distanceInterFibers = 1.35*mm; //1.35*mm
67  layerThickness = 1.73*mm; //1.68*mm
68  milledLayer = 1.00*mm; //1.40*mm ?
69  nbOfLayers = 10; //10
70  nbOfModules = 9; //9
71 
72  fiberLength = (nbOfFibers+0.5)*distanceInterFibers; //662.175*mm
73 }
74 
75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
76 
78 { }
79 
80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81 
83 {
84  return ConstructCalorimeter();
85 }
86 
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88 
90 {
91  // define Elements
92  //
93  G4Element* H = new G4Element("Hydrogen","H", 1, 1.01*g/mole);
94  G4Element* C = new G4Element("Carbon", "C", 6, 12.01*g/mole);
95  G4Element* N = new G4Element("Nitrogen","N", 7, 14.01*g/mole);
96  G4Element* O = new G4Element("Oxygen", "O", 8, 16.00*g/mole);
97 
98  G4int natoms, ncomponents;
99  G4double density, massfraction;
100 
101  // Lead
102  //
103  G4Material* Pb =
104  new G4Material("Lead", 82., 207.20*g/mole, density= 0.98*11.20*g/cm3);
105 
106  // Scintillator
107  //
108  G4Material* Sci =
109  new G4Material("Scintillator", density= 1.032*g/cm3, ncomponents=2);
110  Sci->AddElement(C, natoms=8);
111  Sci->AddElement(H, natoms=8);
112 
113  Sci->GetIonisation()->SetBirksConstant(0.126*mm/MeV);
114 
115  // Air
116  //
117  G4Material* Air =
118  new G4Material("Air", density= 1.290*mg/cm3, ncomponents=2);
119  Air->AddElement(N, massfraction=70*perCent);
120  Air->AddElement(O, massfraction=30.*perCent);
121 
122  // example of vacuum
123  //
124  density = universe_mean_density; //from PhysicalConstants.h
125  G4double pressure = 3.e-18*pascal;
126  G4double temperature = 2.73*kelvin;
127  G4Material* Vacuum =
128  new G4Material("Galactic", 1., 1.008*g/mole, density,
129  kStateGas,temperature,pressure);
130 
131  //attribute materials
132  //
133  defaultMat = Vacuum;
134  fiberMat = Sci;
135  absorberMat = Pb;
139 
140  // print table
141  //
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146 
148 {
149  // Cleanup old geometry
150  //
155 
156  // fibers
157  //
158  G4Tubs*
159  svol_fiber = new G4Tubs("fiber", //name
160  0*mm, 0.5*fiberDiameter, //r1, r2
161  0.5*fiberLength, //half-length
162  0., twopi); //theta1, theta2
163 
164  lvol_fiber = new G4LogicalVolume(svol_fiber, //solid
165  fiberMat, //material
166  "fiber"); //name
167 
168  // layer
169  //
170  G4double sizeX = layerThickness;
172  G4double sizeZ = fiberLength;
173 
174  G4Box*
175  svol_layer = new G4Box("layer", //name
176  0.5*sizeX, 0.5*sizeY, 0.5*sizeZ); //size
177 
178 
179  lvol_layer = new G4LogicalVolume(svol_layer, //solid
180  absorberMat, //material
181  "layer"); //name
182 
183  // put fibers within layer
184  //
185  G4double Xcenter = 0.;
186  G4double Ycenter = -0.5*(sizeY + distanceInterFibers);
187 
188  for (G4int k=0; k<nbOfFibers; k++) {
189  Ycenter += distanceInterFibers;
190  new G4PVPlacement(0, //no rotation
191  G4ThreeVector(Xcenter,Ycenter,0.), //position
192  lvol_fiber, //logical volume
193  "fiber", //name
194  lvol_layer, //mother
195  false, //no boulean operat
196  k+1); //copy number
197 
198  }
199 
200  // modules
201  //
203  sizeX = moduleThickness;
204  sizeY = fiberLength;
205  sizeZ = fiberLength;
206 
207  G4Box*
208  svol_module = new G4Box("module", //name
209  0.5*sizeX, 0.5*sizeY, 0.5*sizeZ); //size
210 
211  lvol_module = new G4LogicalVolume(svol_module, //solid
212  absorberMat, //material
213  "module"); //name
214 
215  // put layers within module
216  //
217  Xcenter = -0.5*(nbOfLayers+1)*layerThickness;
218  Ycenter = 0.25*distanceInterFibers;
219 
220  for (G4int k=0; k<nbOfLayers; k++) {
221  Xcenter += layerThickness;
222  Ycenter = - Ycenter;
223  new G4PVPlacement(0, //no rotation
224  G4ThreeVector(Xcenter,Ycenter,0.), //position
225  lvol_layer, //logical volume
226  "layer", //name
227  lvol_module, //mother
228  false, //no boulean operat
229  k+1); //copy number
230 
231  }
232 
233  // calorimeter
234  //
236  sizeX = calorThickness;
237  sizeY = fiberLength;
238  sizeZ = fiberLength;
239 
240  G4Box*
241  svol_calorimeter = new G4Box("calorimeter", //name
242  0.5*sizeX, 0.5*sizeY, 0.5*sizeZ); //size
243 
244 
245  lvol_calorimeter = new G4LogicalVolume(svol_calorimeter, //solid
246  calorimeterMat, //material
247  "calorimeter"); //name
248 
249  // put modules inside calorimeter
250  //
251  Xcenter = -0.5*(calorThickness + moduleThickness);
252 
253 
254  for (G4int k=0; k<nbOfModules; k++) {
255  Xcenter += moduleThickness;
256  G4RotationMatrix rotm; //rotation matrix to place modules
257  if ((k+1)%2 == 0) rotm.rotateX(90*deg);
258  G4Transform3D transform(rotm, G4ThreeVector(Xcenter,0.,0.));
259  new G4PVPlacement(transform, //rotation+position
260  lvol_module, //logical volume
261  "module", //name
262  lvol_calorimeter, //mother
263  false, //no boulean operat
264  k+1); //copy number
265  }
266 
267  // world
268  //
269  sizeX = 1.2*calorThickness;
270  sizeY = 1.2*fiberLength;
271  sizeZ = 1.2*fiberLength;
272 
273  worldSizeX = sizeX;
274 
275  G4Box*
276  svol_world = new G4Box("world", //name
277  0.5*sizeX, 0.5*sizeY, 0.5*sizeZ); //size
278 
279  lvol_world = new G4LogicalVolume(svol_world, //solid
280  worldMat, //material
281  "world"); //name
282 
283  pvol_world = new G4PVPlacement(0, //no rotation
284  G4ThreeVector(), //at (0,0,0)
285  lvol_world, //logical volume
286  "world", //name
287  0, //mother volume
288  false, //no boolean operation
289  0); //copy number
290 
291  //put calorimeter in world
292  //
293  new G4PVPlacement(0, //no rotation
294  G4ThreeVector(), //at (0,0,0)
295  lvol_calorimeter, //logical volume
296  "calorimeter", //name
297  lvol_world, //mother volume
298  false, //no boolean operation
299  0); //copy number
300 
302 
303  // Visualization attributes
304  //
308 
309  //always return the physical World
310  //
311  return pvol_world;
312 }
313 
314 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
315 
316 #include "G4UnitsTable.hh"
317 
319 {
320  G4cout << "\n-------------------------------------------------------------"
321  << "\n ---> The calorimeter is " << nbOfModules << " Modules"
322  << "\n ---> A Module is " << nbOfLayers << " Layers + 1 milled Layer";
323 
324  G4cout
325  << "\n ---> A Layer is " << G4BestUnit(layerThickness,"Length")
326  << " thickness of " << absorberMat->GetName();
327 
328  G4cout
329  << "\n ---> A Layer includes " << nbOfFibers << " fibers of "
330  << fiberMat->GetName();
331 
332  G4cout
333  << "\n ---> diameter : " << G4BestUnit(fiberDiameter,"Length")
334  << "\n ---> length : " << G4BestUnit(fiberLength,"Length")
335  << "\n ---> distance : " << G4BestUnit(distanceInterFibers,"Length");
336 
337  G4cout
338  << "\n ---> The milled Layer is " << G4BestUnit(milledLayer,"Length")
339  << " thickness of " << absorberMat->GetName();
340 
341  G4cout
342  << "\n\n ---> Module thickness " << G4BestUnit(moduleThickness,"Length");
343 
344  G4cout
345  << "\n\n ---> Total calor thickness " << G4BestUnit(calorThickness,"Length")
346  << "\n Tranverse size " << G4BestUnit(fiberLength,"Length");
347 
348  G4cout << "\n-------------------------------------------------------------\n";
349  G4cout << G4endl;
350 }
351 
352 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
353 
355 #include "G4AutoDelete.hh"
356 
358 {
359  if ( fFieldMessenger.Get() == 0 ) {
360  // Create global magnetic field messenger.
361  // Uniform magnetic field is then created automatically if
362  // the field value is not zero.
363  G4ThreeVector fieldValue = G4ThreeVector();
365  new G4GlobalMagFieldMessenger(fieldValue);
366  //msg->SetVerboseLevel(1);
368  fFieldMessenger.Put( msg );
369 
370  }
371 }
372 
373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:226
static const double MeV
Definition: G4SIunits.hh:211
G4Material * Air
Definition: TRTMaterials.hh:57
CLHEP::Hep3Vector G4ThreeVector
CLHEP::HepRotation G4RotationMatrix
G4LogicalVolume * lvol_layer
Definition: G4Box.hh:64
const G4String & GetName() const
Definition: G4Material.hh:178
G4VPhysicalVolume * Construct()
void SetBirksConstant(G4double value)
value_type & Get() const
Definition: G4Cache.hh:282
Definition: G4Tubs.hh:85
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
static void Clean()
Definition: G4SolidStore.cc:79
double C(double temp)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static const double mg
Definition: G4SIunits.hh:181
int G4int
Definition: G4Types.hh:78
G4LogicalVolume * lvol_fiber
G4Cache< G4GlobalMagFieldMessenger * > fFieldMessenger
static G4PhysicalVolumeStore * GetInstance()
G4double density
Definition: TRTMaterials.hh:39
virtual void ConstructSDandField()
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4GLOB_DLL std::ostream G4cout
static const double deg
Definition: G4SIunits.hh:151
static const double twopi
Definition: G4SIunits.hh:75
static G4LogicalVolumeStore * GetInstance()
static const double cm3
Definition: G4SIunits.hh:120
static G4SolidStore * GetInstance()
HepGeom::Transform3D G4Transform3D
static const double perCent
Definition: G4SIunits.hh:329
G4LogicalVolume * lvol_module
static G4GeometryManager * GetInstance()
static const double kelvin
Definition: G4SIunits.hh:278
#define pascal
Definition: G4SIunits.hh:231
G4VPhysicalVolume * pvol_world
static const double g
Definition: G4SIunits.hh:180
G4VPhysicalVolume * ConstructCalorimeter()
static const G4VisAttributes Invisible
static const double mole
Definition: G4SIunits.hh:283
#define G4endl
Definition: G4ios.hh:61
G4LogicalVolume * lvol_world
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:364
double G4double
Definition: G4Types.hh:76
G4LogicalVolume * lvol_calorimeter
void Put(const value_type &val) const
Definition: G4Cache.hh:286
static const double mm
Definition: G4SIunits.hh:114
void SetVisAttributes(const G4VisAttributes *pVA)