Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 //
30 // $Id$
31 //
32 //
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
36 
37 #include "DetectorConstruction.hh"
38 #include "DetectorMessenger.hh"
39 
40 #include "G4Material.hh"
41 #include "G4NistManager.hh"
42 
43 #include "G4Box.hh"
44 #include "G4LogicalVolume.hh"
45 #include "G4PVPlacement.hh"
46 #include "G4PVReplica.hh"
47 
48 #include "G4GeometryManager.hh"
49 #include "G4PhysicalVolumeStore.hh"
50 #include "G4LogicalVolumeStore.hh"
51 #include "G4SolidStore.hh"
52 
53 #include "G4VisAttributes.hh"
54 #include "G4Colour.hh"
55 #include "G4SystemOfUnits.hh"
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 :fAbsorberMaterial(0),fGapMaterial(0),fDefaultMaterial(0),
61  fSolidWorld(0),fLogicWorld(0),fPhysiWorld(0),
62  fSolidCalor(0),fLogicCalor(0),fPhysiCalor(0),
63  fSolidLayer(0),fLogicLayer(0),fPhysiLayer(0),
64  fSolidAbsorber(0),fLogicAbsorber(0),fPhysiAbsorber(0),
65  fSolidGap (0),fLogicGap (0),fPhysiGap (0)
66 {
67  // default parameter values of the calorimeter
68  fAbsorberThickness = 10.*mm;
69  fGapThickness = 5.*mm;
70  fNbOfLayers = 10;
71  fCalorSizeYZ = 10.*cm;
72  ComputeCalorParameters();
73 
74  // materials
75  DefineMaterials();
76  SetAbsorberMaterial("G4_Pb");
77  SetGapMaterial("G4_lAr");
78 
79  // create commands for interactive definition of the calorimeter
80  fDetectorMessenger = new DetectorMessenger(this);
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 { delete fDetectorMessenger;}
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
91 {
92  return ConstructCalorimeter();
93 }
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96 
97 void DetectorConstruction::DefineMaterials()
98 {
99 // use G4-NIST materials data base
100 //
102 fDefaultMaterial = man->FindOrBuildMaterial("G4_Galactic");
103 man->FindOrBuildMaterial("G4_Pb");
104 man->FindOrBuildMaterial("G4_lAr");
105 
106 // print table
107 //
109 }
110 
111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112 
113 G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
114 {
115 
116  // Clean old geometry, if any
117  //
122 
123  // complete the Calor parameters definition
124  ComputeCalorParameters();
125 
126  //
127  // World
128  //
129  fSolidWorld = new G4Box("World", //its name
130  fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size
131 
132  fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
133  fDefaultMaterial, //its material
134  "World"); //its name
135 
136  fPhysiWorld = new G4PVPlacement(0, //no rotation
137  G4ThreeVector(), //at (0,0,0)
138  fLogicWorld, //its logical volume
139  "World", //its name
140  0, //its mother volume
141  false, //no boolean operation
142  0); //copy number
143 
144  //
145  // Calorimeter
146  //
147  fSolidCalor=0; fLogicCalor=0; fPhysiCalor=0;
148  fSolidLayer=0; fLogicLayer=0; fPhysiLayer=0;
149 
150  if (fCalorThickness > 0.)
151  { fSolidCalor = new G4Box("Calorimeter", //its name
152  fCalorThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2);//size
153 
154  fLogicCalor = new G4LogicalVolume(fSolidCalor, //its solid
155  fDefaultMaterial, //its material
156  "Calorimeter"); //its name
157 
158  fPhysiCalor = new G4PVPlacement(0, //no rotation
159  G4ThreeVector(), //at (0,0,0)
160  fLogicCalor, //its logical volume
161  "Calorimeter", //its name
162  fLogicWorld, //its mother volume
163  false, //no boolean operation
164  0); //copy number
165 
166  //
167  // Layer
168  //
169  fSolidLayer = new G4Box("Layer", //its name
170  fLayerThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2); //size
171 
172  fLogicLayer = new G4LogicalVolume(fSolidLayer, //its solid
173  fDefaultMaterial, //its material
174  "Layer"); //its name
175  if (fNbOfLayers > 1)
176  fPhysiLayer = new G4PVReplica("Layer", //its name
177  fLogicLayer, //its logical volume
178  fLogicCalor, //its mother
179  kXAxis, //axis of replication
180  fNbOfLayers, //number of replica
181  fLayerThickness); //witdth of replica
182  else
183  fPhysiLayer = new G4PVPlacement(0, //no rotation
184  G4ThreeVector(), //at (0,0,0)
185  fLogicLayer, //its logical volume
186  "Layer", //its name
187  fLogicCalor, //its mother volume
188  false, //no boolean operation
189  0); //copy number
190  }
191 
192  //
193  // Absorber
194  //
195  fSolidAbsorber=0; fLogicAbsorber=0; fPhysiAbsorber=0;
196 
197  if (fAbsorberThickness > 0.)
198  { fSolidAbsorber = new G4Box("Absorber", //its name
199  fAbsorberThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
200 
201  fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber, //its solid
202  fAbsorberMaterial, //its material
203  fAbsorberMaterial->GetName()); //name
204 
205  fPhysiAbsorber = new G4PVPlacement(0, //no rotation
206  G4ThreeVector(-fGapThickness/2,0.,0.), //its position
207  fLogicAbsorber, //its logical volume
208  fAbsorberMaterial->GetName(), //its name
209  fLogicLayer, //its mother
210  false, //no boulean operat
211  0); //copy number
212 
213  }
214 
215  //
216  // Gap
217  //
218  fSolidGap=0; fLogicGap=0; fPhysiGap=0;
219 
220  if (fGapThickness > 0.)
221  { fSolidGap = new G4Box("Gap",
222  fGapThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
223 
224  fLogicGap = new G4LogicalVolume(fSolidGap,
225  fGapMaterial,
226  fGapMaterial->GetName());
227 
228  fPhysiGap = new G4PVPlacement(0, //no rotation
229  G4ThreeVector(fAbsorberThickness/2,0.,0.), //its position
230  fLogicGap, //its logical volume
231  fGapMaterial->GetName(), //its name
232  fLogicLayer, //its mother
233  false, //no boulean operat
234  0); //copy number
235  }
236 
238 
239  //
240  // Visualization attributes
241  //
243 
244  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
245  simpleBoxVisAtt->SetVisibility(true);
246  fLogicCalor->SetVisAttributes(simpleBoxVisAtt);
247 
248  //
249  //always return the physical World
250  //
251  return fPhysiWorld;
252 }
253 
254 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
255 
257 {
258  G4cout << "\n------------------------------------------------------------"
259  << "\n---> The calorimeter is " << fNbOfLayers << " layers of: [ "
260  << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName()
261  << " + "
262  << fGapThickness/mm << "mm of " << fGapMaterial->GetName() << " ] "
263  << "\n------------------------------------------------------------\n";
264 }
265 
266 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
267 
269 {
270  // search the material by its name
271  G4Material* pttoMaterial =
272  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
273  if (pttoMaterial) fAbsorberMaterial = pttoMaterial;
274 }
275 
276 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
277 
279 {
280  // search the material by its name
281  G4Material* pttoMaterial =
282  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
283  if (pttoMaterial) fGapMaterial = pttoMaterial;
284 }
285 
286 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
287 
289 {
290  // change Absorber thickness and recompute the calorimeter parameters
291  fAbsorberThickness = val;
292 }
293 
294 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
295 
297 {
298  // change Gap thickness and recompute the calorimeter parameters
299  fGapThickness = val;
300 }
301 
302 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
303 
305 {
306  // change the transverse size and recompute the calorimeter parameters
307  fCalorSizeYZ = val;
308 }
309 
310 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
311 
313 {
314  fNbOfLayers = val;
315 }
316 
317 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
318 
319 #include "G4RunManager.hh"
320 
322 {
323  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
324 }
325 
326 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......