ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorConstruction.cc
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 //
31 //
32 
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
36 #include "DetectorConstruction.hh"
37 #include "DetectorMessenger.hh"
38 
39 #include "G4Material.hh"
40 #include "G4NistManager.hh"
41 
42 #include "G4Box.hh"
43 #include "G4LogicalVolume.hh"
44 #include "G4PVPlacement.hh"
45 #include "G4PVReplica.hh"
46 
47 #include "G4StateManager.hh"
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 #include "G4RunManager.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
62  fAbsorberMaterial(0),fGapMaterial(0),fDefaultMaterial(0),
63  fSolidWorld(0),fLogicWorld(0),fPhysiWorld(0),
64  fSolidCalor(0),fLogicCalor(0),fPhysiCalor(0),
65  fSolidLayer(0),fLogicLayer(0),fPhysiLayer(0),
66  fSolidAbsorber(0),fLogicAbsorber(0),fPhysiAbsorber(0),
67  fSolidGap (0),fLogicGap (0),fPhysiGap (0),
68  fDetectorMessenger(0)
69 {
70  // default parameter values of the calorimeter
71  fAbsorberThickness = 10.*mm;
72  fGapThickness = 5.*mm;
73  fNbOfLayers = 10;
74  fCalorSizeYZ = 10.*cm;
76 
77  // materials
79  SetAbsorberMaterial("G4_Pb");
80  SetGapMaterial("G4_lAr");
81 
82  // create commands for interactive definition of the calorimeter
84 }
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 
89 { delete fDetectorMessenger;}
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
94 {
95  return ConstructCalorimeter();
96 }
97 
98 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
99 
101 {
102 // use G4-NIST materials data base
103 //
105 fDefaultMaterial = man->FindOrBuildMaterial("G4_Galactic");
106 man->FindOrBuildMaterial("G4_Pb");
107 man->FindOrBuildMaterial("G4_lAr");
108 
109 // print table
110 //
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
115 
117 {
118 
119  // Clean old geometry, if any
120  //
125 
126  // complete the Calor parameters definition
128 
129  //
130  // World
131  //
132  fSolidWorld = new G4Box("World", //its name
133  fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size
134 
135  fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
136  fDefaultMaterial, //its material
137  "World"); //its name
138 
139  fPhysiWorld = new G4PVPlacement(0, //no rotation
140  G4ThreeVector(), //at (0,0,0)
141  fLogicWorld, //its logical volume
142  "World", //its name
143  0, //its mother volume
144  false, //no boolean operation
145  0); //copy number
146 
147  //
148  // Calorimeter
149  //
152 
153  if (fCalorThickness > 0.)
154  { fSolidCalor = new G4Box("Calorimeter", //its name
156 
157  fLogicCalor = new G4LogicalVolume(fSolidCalor, //its solid
158  fDefaultMaterial, //its material
159  "Calorimeter"); //its name
160 
161  fPhysiCalor = new G4PVPlacement(0, //no rotation
162  G4ThreeVector(), //at (0,0,0)
163  fLogicCalor, //its logical volume
164  "Calorimeter", //its name
165  fLogicWorld, //its mother volume
166  false, //no boolean operation
167  0); //copy number
168 
169  //
170  // Layer
171  //
172  fSolidLayer = new G4Box("Layer", //its name
174 
175  fLogicLayer = new G4LogicalVolume(fSolidLayer, //its solid
176  fDefaultMaterial, //its material
177  "Layer"); //its name
178  if (fNbOfLayers > 1)
179  fPhysiLayer = new G4PVReplica("Layer", //its name
180  fLogicLayer, //its logical volume
181  fLogicCalor, //its mother
182  kXAxis, //axis of replication
183  fNbOfLayers, //number of replica
184  fLayerThickness); //witdth of replica
185  else
186  fPhysiLayer = new G4PVPlacement(0, //no rotation
187  G4ThreeVector(), //at (0,0,0)
188  fLogicLayer, //its logical volume
189  "Layer", //its name
190  fLogicCalor, //its mother volume
191  false, //no boolean operation
192  0); //copy number
193  }
194 
195  //
196  // Absorber
197  //
199 
200  if (fAbsorberThickness > 0.)
201  { fSolidAbsorber = new G4Box("Absorber", //its name
203 
205  fAbsorberMaterial, //its material
206  fAbsorberMaterial->GetName());//name
207 
208  fPhysiAbsorber = new G4PVPlacement(0, //no rotation
209  G4ThreeVector(-fGapThickness/2,0.,0.), //its position
210  fLogicAbsorber, //its logical volume
211  fAbsorberMaterial->GetName(), //its name
212  fLogicLayer, //its mother
213  false, //no boulean operat
214  0); //copy number
215 
216  }
217 
218  //
219  // Gap
220  //
221  fSolidGap=0; fLogicGap=0; fPhysiGap=0;
222 
223  if (fGapThickness > 0.)
224  { fSolidGap = new G4Box("Gap",
226 
228  fGapMaterial,
229  fGapMaterial->GetName());
230 
231  fPhysiGap = new G4PVPlacement(0, //no rotation
232  G4ThreeVector(fAbsorberThickness/2,0.,0.), //its position
233  fLogicGap, //its logical volume
234  fGapMaterial->GetName(), //its name
235  fLogicLayer, //its mother
236  false, //no boulean operat
237  0); //copy number
238  }
239 
241 
242  //
243  // Visualization attributes
244  //
246 
247  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
248  simpleBoxVisAtt->SetVisibility(true);
249  fLogicCalor->SetVisAttributes(simpleBoxVisAtt);
250 
251  //
252  //always return the physical World
253  //
254  return fPhysiWorld;
255 }
256 
257 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
258 
260 {
261  G4cout << "\n------------------------------------------------------------"
262  << "\n---> The calorimeter is " << fNbOfLayers << " layers of: [ "
263  << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName()
264  << " + "
265  << fGapThickness/mm << "mm of " << fGapMaterial->GetName() << " ] "
266  << "\n------------------------------------------------------------\n";
267 }
268 
269 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
270 
272 {
273  // search the material by its name
274  G4Material* pttoMaterial =
275  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
276  if (pttoMaterial)
277  {
278  fAbsorberMaterial = pttoMaterial;
279  if ( fLogicAbsorber )
280  {
283  }
284  }
285 }
286 
287 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
288 
290 {
291  // search the material by its name
292  G4Material* pttoMaterial =
293  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
294  if (pttoMaterial)
295  {
296  fGapMaterial = pttoMaterial;
297  if ( fLogicGap )
298  {
301  }
302  }
303 }
304 
305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
306 
308 {
309  // change Absorber thickness and recompute the calorimeter parameters
310  fAbsorberThickness = val;
311  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
313  }
314 }
315 
316 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
317 
319 {
320  // change Gap thickness and recompute the calorimeter parameters
321  fGapThickness = val;
322  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
324  }
325 }
326 
327 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
328 
330 {
331  // change the transverse size and recompute the calorimeter parameters
332  fCalorSizeYZ = val;
333  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
335  }
336 }
337 
338 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
339 
341 {
342  fNbOfLayers = val;
343  if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
345  }
346 }
347 
348 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......