ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B4DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file B4DetectorConstruction.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 //
26 //
29 
30 #include "B4DetectorConstruction.hh"
31 
32 #include "G4Material.hh"
33 #include "G4NistManager.hh"
34 
35 #include "G4Box.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4PVPlacement.hh"
38 #include "G4PVReplica.hh"
40 #include "G4AutoDelete.hh"
41 
42 #include "G4GeometryManager.hh"
43 #include "G4PhysicalVolumeStore.hh"
44 #include "G4LogicalVolumeStore.hh"
45 #include "G4SolidStore.hh"
46 
47 #include "G4VisAttributes.hh"
48 #include "G4Colour.hh"
49 
50 #include "G4PhysicalConstants.hh"
51 #include "G4SystemOfUnits.hh"
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
62  fAbsorberPV(nullptr),
63  fGapPV(nullptr),
64  fCheckOverlaps(true)
65 {
66 }
67 
68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
69 
71 {
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
77 {
78  // Define materials
80 
81  // Define volumes
82  return DefineVolumes();
83 }
84 
85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 
88 {
89  // Lead material defined using NIST Manager
90  auto nistManager = G4NistManager::Instance();
91  nistManager->FindOrBuildMaterial("G4_Pb");
92 
93  // Liquid argon material
94  G4double a; // mass of a mole;
95  G4double z; // z=mean number of protons;
96  G4double density;
97  new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
98  // The argon by NIST Manager is a gas with a different density
99 
100  // Vacuum
101  new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density,
102  kStateGas, 2.73*kelvin, 3.e-18*pascal);
103 
104  // Print materials
106 }
107 
108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
109 
111 {
112  // Geometry parameters
113  G4int nofLayers = 10;
114  G4double absoThickness = 10.*mm;
115  G4double gapThickness = 5.*mm;
116  G4double calorSizeXY = 10.*cm;
117 
118  auto layerThickness = absoThickness + gapThickness;
119  auto calorThickness = nofLayers * layerThickness;
120  auto worldSizeXY = 1.2 * calorSizeXY;
121  auto worldSizeZ = 1.2 * calorThickness;
122 
123  // Get materials
124  auto defaultMaterial = G4Material::GetMaterial("Galactic");
125  auto absorberMaterial = G4Material::GetMaterial("G4_Pb");
126  auto gapMaterial = G4Material::GetMaterial("liquidArgon");
127 
128  if ( ! defaultMaterial || ! absorberMaterial || ! gapMaterial ) {
130  msg << "Cannot retrieve materials already defined.";
131  G4Exception("B4DetectorConstruction::DefineVolumes()",
132  "MyCode0001", FatalException, msg);
133  }
134 
135  //
136  // World
137  //
138  auto worldS
139  = new G4Box("World", // its name
140  worldSizeXY/2, worldSizeXY/2, worldSizeZ/2); // its size
141 
142  auto worldLV
143  = new G4LogicalVolume(
144  worldS, // its solid
145  defaultMaterial, // its material
146  "World"); // its name
147 
148  auto worldPV
149  = new G4PVPlacement(
150  0, // no rotation
151  G4ThreeVector(), // at (0,0,0)
152  worldLV, // its logical volume
153  "World", // its name
154  0, // its mother volume
155  false, // no boolean operation
156  0, // copy number
157  fCheckOverlaps); // checking overlaps
158 
159  //
160  // Calorimeter
161  //
162  auto calorimeterS
163  = new G4Box("Calorimeter", // its name
164  calorSizeXY/2, calorSizeXY/2, calorThickness/2); // its size
165 
166  auto calorLV
167  = new G4LogicalVolume(
168  calorimeterS, // its solid
169  defaultMaterial, // its material
170  "Calorimeter"); // its name
171 
172  new G4PVPlacement(
173  0, // no rotation
174  G4ThreeVector(), // at (0,0,0)
175  calorLV, // its logical volume
176  "Calorimeter", // its name
177  worldLV, // its mother volume
178  false, // no boolean operation
179  0, // copy number
180  fCheckOverlaps); // checking overlaps
181 
182  //
183  // Layer
184  //
185  auto layerS
186  = new G4Box("Layer", // its name
187  calorSizeXY/2, calorSizeXY/2, layerThickness/2); // its size
188 
189  auto layerLV
190  = new G4LogicalVolume(
191  layerS, // its solid
192  defaultMaterial, // its material
193  "Layer"); // its name
194 
195  new G4PVReplica(
196  "Layer", // its name
197  layerLV, // its logical volume
198  calorLV, // its mother
199  kZAxis, // axis of replication
200  nofLayers, // number of replica
201  layerThickness); // witdth of replica
202 
203  //
204  // Absorber
205  //
206  auto absorberS
207  = new G4Box("Abso", // its name
208  calorSizeXY/2, calorSizeXY/2, absoThickness/2); // its size
209 
210  auto absorberLV
211  = new G4LogicalVolume(
212  absorberS, // its solid
213  absorberMaterial, // its material
214  "Abso"); // its name
215 
217  = new G4PVPlacement(
218  0, // no rotation
219  G4ThreeVector(0., 0., -gapThickness/2), // its position
220  absorberLV, // its logical volume
221  "Abso", // its name
222  layerLV, // its mother volume
223  false, // no boolean operation
224  0, // copy number
225  fCheckOverlaps); // checking overlaps
226 
227  //
228  // Gap
229  //
230  auto gapS
231  = new G4Box("Gap", // its name
232  calorSizeXY/2, calorSizeXY/2, gapThickness/2); // its size
233 
234  auto gapLV
235  = new G4LogicalVolume(
236  gapS, // its solid
237  gapMaterial, // its material
238  "Gap"); // its name
239 
240  fGapPV
241  = new G4PVPlacement(
242  0, // no rotation
243  G4ThreeVector(0., 0., absoThickness/2), // its position
244  gapLV, // its logical volume
245  "Gap", // its name
246  layerLV, // its mother volume
247  false, // no boolean operation
248  0, // copy number
249  fCheckOverlaps); // checking overlaps
250 
251  //
252  // print parameters
253  //
254  G4cout
255  << G4endl
256  << "------------------------------------------------------------" << G4endl
257  << "---> The calorimeter is " << nofLayers << " layers of: [ "
258  << absoThickness/mm << "mm of " << absorberMaterial->GetName()
259  << " + "
260  << gapThickness/mm << "mm of " << gapMaterial->GetName() << " ] " << G4endl
261  << "------------------------------------------------------------" << G4endl;
262 
263  //
264  // Visualization attributes
265  //
266  worldLV->SetVisAttributes (G4VisAttributes::GetInvisible());
267 
268  auto simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
269  simpleBoxVisAtt->SetVisibility(true);
270  calorLV->SetVisAttributes(simpleBoxVisAtt);
271 
272  //
273  // Always return the physical World
274  //
275  return worldPV;
276 }
277 
278 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
279 
281 {
282  // Create global magnetic field messenger.
283  // Uniform magnetic field is then created automatically if
284  // the field value is not zero.
285  G4ThreeVector fieldValue;
288 
289  // Register the field messenger for deleting
291 }
292 
293 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......