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