ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GB03DetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file GB03DetectorConstruction.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 
32 #include "G4RunManager.hh"
33 
34 #include "G4Material.hh"
35 #include "G4Box.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4PVPlacement.hh"
38 #include "G4PVReplica.hh"
39 
40 #include "G4VisAttributes.hh"
41 #include "G4Colour.hh"
42 
43 #include "G4SDManager.hh"
45 #include "G4PSEnergyDeposit.hh"
46 #include "G4PSFlatSurfaceFlux.hh"
47 #include "G4SDNeutralFilter.hh"
48 #include "G4SDChargedFilter.hh"
49 #include "G4ios.hh"
50 
51 #include "GB03DetectorMessenger.hh"
52 
54 
55 #include "G4PhysicalConstants.hh"
56 #include "G4SystemOfUnits.hh"
57 
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
65  fTotalThickness (2.0*m), fLayerThickness(0.),
66  fConstructed(false),
67  fWorldMaterial(0), fAbsorberMaterial(0), fGapMaterial(0),
68  fLayerSolid(0), fGapSolid(0),
69  fWorldLogical(0), fCalorLogical(0), fLayerLogical(0), fGapLogical(0),
70  fWorldPhysical(0), fCalorPhysical(0), fLayerPhysical(0), fGapPhysical(0),
71  fDetectorMessenger(0), fVerboseLevel(1)
72 {
74  fCalName = "Calor";
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81 { delete fDetectorMessenger;}
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
86 {
87  if(!fConstructed)
88  {
89  fConstructed = true;
91  SetupGeometry();
92  }
93  if (GetVerboseLevel()>0)
95 
96  return fWorldPhysical;
97 }
98 
99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100 
102 {
104  {
105  fConstructedSDandField = true;
106  SetupDetectors();
107  SetupBiasing();
108  }
109 }
110 
111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112 
114 {
115  G4String name, symbol; //a=mass of a mole;
116  G4double a, z, density; //z=mean number of protons;
117  G4int iz; //iz=number of protons in an isotope;
118  G4int n; // n=number of nucleons in an isotope;
119 
120  G4int ncomponents, natoms;
121  G4double abundance, fractionmass;
122  G4double temperature, pressure;
123 
124  //
125  // define Elements
126  //
127 
128  a = 1.01*g/mole;
129  G4Element* H = new G4Element(name="Hydrogen",symbol="H" , z= 1., a);
130 
131  a = 12.01*g/mole;
132  G4Element* C = new G4Element(name="Carbon" ,symbol="C" , z= 6., a);
133 
134  a = 14.01*g/mole;
135  G4Element* N = new G4Element(name="Nitrogen",symbol="N" , z= 7., a);
136 
137  a = 16.00*g/mole;
138  G4Element* O = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a);
139 
140  //
141  // define an Element from isotopes, by relative abundance
142  //
143 
144  G4Isotope* U5 = new G4Isotope(name="U235", iz=92, n=235, a=235.01*g/mole);
145  G4Isotope* U8 = new G4Isotope(name="U238", iz=92, n=238, a=238.03*g/mole);
146 
147  G4Element* U = new G4Element(name="enriched Uranium",symbol="U",ncomponents=2);
148  U->AddIsotope(U5, abundance= 90.*perCent);
149  U->AddIsotope(U8, abundance= 10.*perCent);
150 
151  //
152  // define simple materials
153  //
154 
155  new G4Material(name="Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3);
156  new G4Material(name="Silicon", z=14., a= 28.09*g/mole, density= 2.33*g/cm3);
157  new G4Material(name="Iron", z=26., a=55.85*g/mole, density=7.87*g/cm3);
158  new G4Material(name="ArgonGas",z=18., a= 39.95*g/mole, density=1.782*mg/cm3);
159  new G4Material(name="He", z=2., a=4.0*g/mole, density=0.1786e-03*g/cm3);
160 
161  density = 1.390*g/cm3;
162  a = 39.95*g/mole;
163  new G4Material(name="liquidArgon", z=18., a, density);
164 
165  density = 11.35*g/cm3;
166  a = 207.19*g/mole;
167  G4Material* Pb = new G4Material(name="Lead" , z=82., a, density);
168 
169  //
170  // define a material from elements. case 1: chemical molecule
171  //
172 
173  density = 1.000*g/cm3;
174  G4Material* H2O = new G4Material(name="Water", density, ncomponents=2);
175  H2O->AddElement(H, natoms=2);
176  H2O->AddElement(O, natoms=1);
177 
178  density = 1.032*g/cm3;
179  G4Material* Sci = new G4Material(name="Scintillator", density, ncomponents=2);
180  Sci->AddElement(C, natoms=9);
181  Sci->AddElement(H, natoms=10);
182 
183  //
184  // define a material from elements. case 2: mixture by fractional mass
185  //
186 
187  density = 1.290*mg/cm3;
188  G4Material* Air = new G4Material(name="Air" , density, ncomponents=2);
189  Air->AddElement(N, fractionmass=0.7);
190  Air->AddElement(O, fractionmass=0.3);
191 
192  //
193  // examples of vacuum
194  //
195 
196  density = universe_mean_density;
197  pressure = 3.e-18*pascal;
198  temperature = 2.73*kelvin;
199  G4Material* Vacuum = new G4Material(name="Galactic", z=1., a=1.01*g/mole,
200  density,kStateGas,temperature,pressure);
201 
202  if (GetVerboseLevel()>1) {
204  }
205 
206  //default materials of the calorimeter
207  fWorldMaterial = Vacuum;
208  fAbsorberMaterial = Pb;
209  fGapMaterial = Sci;
210 }
211 
212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
213 
215 {
216  //
217  // World
218  //
219  G4VSolid* worldSolid = new G4Box("World",2.*m,2.*m,fTotalThickness*2.);
220  fWorldLogical = new G4LogicalVolume(worldSolid,fWorldMaterial,"World");
222  0,false,0);
223 
224  //
225  // Calorimeter
226  //
227  G4VSolid* calorSolid = new G4Box("Calor",0.5*m,0.5*m,fTotalThickness/2.);
229  fCalorPhysical = new G4PVPlacement(0, G4ThreeVector(0.,0.,0.),
231 
232  //
233  // Layers --- as absorbers
234  //
235  fLayerSolid = new G4Box("Layer",0.5*m,0.5*m,fLayerThickness/2.);
241 
242  //
243  // Gap
244  //
245  fGapSolid = new G4Box("Gap",0.5*m,0.5*m,fLayerThickness/4.);
248  fGapLogical,fCalName+"_gap",fLayerLogical,false,0);
249 
250  //
251  // Visualization attributes
252  //
254  G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
255  simpleBoxVisAtt->SetVisibility(true);
256  fCalorLogical->SetVisAttributes(simpleBoxVisAtt);
257  fLayerLogical->SetVisAttributes(simpleBoxVisAtt);
258  fGapLogical->SetVisAttributes(simpleBoxVisAtt);
259 
260 }
261 
262 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
263 
265 {
267  G4String filterName;
268 
269  G4SDNeutralFilter* neutralFilter
270  = new G4SDNeutralFilter(filterName="neutralFilter");
271  G4SDChargedFilter* chargedFilter
272  = new G4SDChargedFilter(filterName="chargedFilter");
273 
274  for(G4int j=0;j<2;j++)
275  {
276  // Loop counter j = 0 : absorber
277  // = 1 : gap
278  G4String detName = fCalName;
279  if(j==0)
280  { detName += "_abs"; }
281  else
282  { detName += "_gap"; }
285  // The second argument in each primitive means the "level" of geometrical
286  // hierarchy, the copy number of that level is used as the key of the
287  // G4THitsMap.
288  // For absorber (j = 0), the copy number of its own physical volume is used.
289  // For gap (j = 1), the copy number of its mother physical volume is used,
290  // since there is only one physical volume of gap is placed with respect
291  // to its mother.
292  G4VPrimitiveScorer* primitive;
293  primitive = new G4PSEnergyDeposit("eDep",j);
294  det->RegisterPrimitive(primitive);
295  primitive = new G4PSFlatSurfaceFlux("nNeutral",1,j);
296  primitive->SetFilter(neutralFilter);
297  det->RegisterPrimitive(primitive);
298  primitive = new G4PSFlatSurfaceFlux("nCharged",1,j);
299  primitive->SetFilter(chargedFilter);
300  det->RegisterPrimitive(primitive);
301 
302  if(j==0)
304  else
306 
307  }
309 }
310 
311 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
312 
314 {
316  biasingOperator->AttachTo(fLayerLogical);
317 }
318 
319 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320 
322 {
323  G4cout
324  << "--------------------------------------------------------" << G4endl;
325  G4cout
326  << " Absorber is made of " << fAbsorberMaterial->GetName() << G4endl
327  << " Gap is made of " << fGapMaterial->GetName() << G4endl
328  << "--------------------------------------------------------" << G4endl;
329 }
330 
331 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
332 
334 {
335  // search the material by its name
336  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
337  if(pttoMaterial)
338  {
339  fAbsorberMaterial = pttoMaterial;
340  if(fConstructed)
341  {
344  }
346  if (GetVerboseLevel()>1) {
348  }
349  }
350  else
351  {
352  G4cerr
353  << materialChoice << " is not defined. - Command is ignored." << G4endl;
354  }
355 }
356 
357 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
358 
360 { return fAbsorberMaterial->GetName(); }
361 
362 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
363 
365 {
366  // search the material by its name
367  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
368  if(pttoMaterial)
369  {
370  fGapMaterial = pttoMaterial;
371  if(fConstructed)
374  if (GetVerboseLevel()>1) {
376  }
377  }
378  else
379  {
380  G4cerr
381  << materialChoice << " is not defined. - Command is ignored." << G4endl;
382  }
383 }
384 
385 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
386 
388 { return fGapMaterial->GetName(); }
389 
390 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
391 
393 {
394  fNumberOfLayers = nl;
396  if(!fConstructed) return;
397 
400 
402  delete fLayerPhysical;
407 
409 }
410 
411 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......