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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 
32 #include "DetectorConstruction.hh"
33 #include "DetectorMessenger.hh"
34 
35 #include "G4Tubs.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4PVPlacement.hh"
38 
39 #include "G4GeometryManager.hh"
40 #include "G4PhysicalVolumeStore.hh"
41 #include "G4LogicalVolumeStore.hh"
42 #include "G4SolidStore.hh"
43 
45 
46 #include "G4NistManager.hh"
47 #include "G4RunManager.hh"
48 
49 #include "G4SystemOfUnits.hh"
50 #include "G4UnitsTable.hh"
51 
52 #include "G4AutoDelete.hh"
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
57  fNLtot(40),fNRtot(50),fDLradl(0.5),fDRradl(0.1),
58  fDLlength(0.),fDRlength(0.),fMaterial(nullptr),
59  fEcalLength(0.),fEcalRadius(0.),
60  fSolidEcal(nullptr),fLogicEcal(nullptr),fPhysiEcal(nullptr)
61 {
63  SetMaterial("G4_PbWO4");
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
70 {
71  delete fDetectorMessenger;
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
77 {
78  //
79  // define few Elements by hand
80  //
81  G4double a, z;
82 
83  G4Element* H = new G4Element("Hydrogen", "H", z= 1., a= 1.01*g/mole);
84  G4Element* O = new G4Element("Oxygen" , "O", z= 8., a= 16.00*g/mole);
85  G4Element* Ge = new G4Element("Germanium", "Ge",z=32., a= 72.59*g/mole);
86  G4Element* Bi = new G4Element("Bismuth", "Bi",z=83., a= 208.98*g/mole);
87 
88  //
89  // define materials
90  //
91  G4double density;
92  G4int ncomponents, natoms;
93 
94  // water with ionisation potential 78 eV
95  G4Material* H2O =
96  new G4Material("Water", density= 1.00*g/cm3, ncomponents=2);
97  H2O->AddElement(H, natoms=2);
98  H2O->AddElement(O, natoms=1);
100 
101  // pure materails
102  new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
103  new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.7*g/cm3);
104  new G4Material("Iron", z=26., a= 55.85*g/mole, density= 7.87*g/cm3);
105  new G4Material("Copper", z=29., a= 63.55*g/mole, density= 8.960*g/cm3);
106  new G4Material("Tungsten", z=74., a=183.84*g/mole, density=19.35*g/cm3);
107  new G4Material("Lead", z=82., a=207.19*g/mole, density=11.35*g/cm3);
108  new G4Material("Uranium" , z=92., a=238.03*g/mole, density= 18.95*g/cm3);
109 
110  // compound material
111  G4Material* BGO =
112  new G4Material("BGO", density= 7.10*g/cm3, ncomponents=3);
113  BGO->AddElement(O , natoms=12);
114  BGO->AddElement(Ge, natoms= 3);
115  BGO->AddElement(Bi, natoms= 4);
116 
118 }
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
123 {
124  G4double Radl = fMaterial->GetRadlen();
125  fDLlength = fDLradl*Radl; fDRlength = fDRradl*Radl;
127  if(fSolidEcal) {
130  }
131 }
132 
133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
134 
136 {
138  //
139  // Ecal
140  //
141  if(!fPhysiEcal) {
142  fSolidEcal = new G4Tubs("Ecal",0.,fEcalRadius,0.5*fEcalLength,0.,360*deg);
143  fLogicEcal = new G4LogicalVolume( fSolidEcal,fMaterial,"Ecal",0,0,0);
145  fLogicEcal,"Ecal",0,false,0);
146  }
147  G4cout << "Absorber is " << G4BestUnit(fEcalLength,"Length")
148  << " of " << fMaterial->GetName()
149  << " R= " << fEcalRadius/cm << " cm" << G4endl;
150  //
151  //always return the physical World
152  //
153  return fPhysiEcal;
154 }
155 
156 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
157 
158 void DetectorConstruction::SetMaterial(const G4String& materialChoice)
159 {
160  // search the material by its name
161  G4Material* pttoMaterial =
162  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
163 
164  if(pttoMaterial && fMaterial != pttoMaterial) {
165  fMaterial = pttoMaterial;
168  }
169 }
170 
171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
172 
174 {
175  fNLtot = (G4int)Value(0);
176  if (fNLtot > kMaxBin) {
177  G4cout << "\n ---> warning from SetLBining: "
178  << fNLtot << " truncated to " << kMaxBin << G4endl;
179  fNLtot = kMaxBin;
180  }
181  fDLradl = Value(1);
183 }
184 
185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
186 
188 {
189  fNRtot = (G4int)Value(0);
190  if (fNRtot > kMaxBin) {
191  G4cout << "\n ---> warning from SetRBining: "
192  << fNRtot << " truncated to " << kMaxBin << G4endl;
193  fNRtot = kMaxBin;
194  }
195  fDRradl = Value(1);
197 }
198 
199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
200 
202 {
203  if ( fFieldMessenger.Get() == nullptr ) {
204  // Create global magnetic field messenger.
205  // Uniform magnetic field is then created automatically if
206  // the field value is not zero.
207  G4ThreeVector fieldValue = G4ThreeVector();
209  new G4GlobalMagFieldMessenger(fieldValue);
210  //msg->SetVerboseLevel(1);
212  fFieldMessenger.Put( msg );
213  }
214 }
215 
216 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......