Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorConstruction.cc
Go to the documentation of this file.
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 // $Id$
31 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "DetectorConstruction.hh"
36 #include "DetectorMessenger.hh"
37 
38 #include "G4Tubs.hh"
39 #include "G4LogicalVolume.hh"
40 #include "G4PVPlacement.hh"
41 #include "G4UniformMagField.hh"
42 
43 #include "G4GeometryManager.hh"
44 #include "G4PhysicalVolumeStore.hh"
45 #include "G4LogicalVolumeStore.hh"
46 #include "G4SolidStore.hh"
47 
48 #include "G4FieldManager.hh"
50 
51 #include "G4NistManager.hh"
52 #include "G4RunManager.hh"
53 
54 #include "G4UnitsTable.hh"
55 #include "G4SystemOfUnits.hh"
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 :fNLtot(40),fNRtot(50),fDLradl(0.5),fDRradl(0.1),
61  fDLlength(0.),fDRlength(0.),
62  fMaterial(0),fMagField(0),
63  fEcalLength(0.),fEcalRadius(0.),
64  fSolidEcal(0),fLogicEcal(0),fPhysiEcal(0)
65 {
66  DefineMaterials();
67  SetMaterial("G4_PbWO4");
68  fDetectorMessenger = new DetectorMessenger(this);
69 }
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 { delete fDetectorMessenger;}
75 
76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
77 
79 {
80  return ConstructVolumes();
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
84 
85 void DetectorConstruction::DefineMaterials()
86 {
87  //
88  // define few Elements by hand
89  //
90  G4double a, z;
91 
92  G4Element* H = new G4Element("Hydrogen", "H", z= 1., a= 1.01*g/mole);
93  G4Element* O = new G4Element("Oxygen" , "O", z= 8., a= 16.00*g/mole);
94  G4Element* Ge = new G4Element("Germanium", "Ge",z=32., a= 72.59*g/mole);
95  G4Element* Bi = new G4Element("Bismuth", "Bi",z=83., a= 208.98*g/mole);
96 
97  //
98  // define materials
99  //
101  G4int ncomponents, natoms;
102 
103  // water with ionisation potential 78 eV
104  G4Material* H2O =
105  new G4Material("Water", density= 1.00*g/cm3, ncomponents=2);
106  H2O->AddElement(H, natoms=2);
107  H2O->AddElement(O, natoms=1);
109 
110  // pure materails
111  new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
112  new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.7*g/cm3);
113  new G4Material("Iron", z=26., a= 55.85*g/mole, density= 7.87*g/cm3);
114  new G4Material("Copper", z=29., a= 63.55*g/mole, density= 8.960*g/cm3);
115  new G4Material("Tungsten", z=74., a=183.84*g/mole, density=19.35*g/cm3);
116  new G4Material("Lead", z=82., a=207.19*g/mole, density=11.35*g/cm3);
117  new G4Material("Uranium" , z=92., a=238.03*g/mole, density= 18.95*g/cm3);
118 
119  // compound material
120  G4Material* BGO =
121  new G4Material("BGO", density= 7.10*g/cm3, ncomponents=3);
122  BGO->AddElement(O , natoms=12);
123  BGO->AddElement(Ge, natoms= 3);
124  BGO->AddElement(Bi, natoms= 4);
125 
127 }
128 
129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
130 
131 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
132 {
133  G4double Radl = fMaterial->GetRadlen();
134 
135  fDLlength = fDLradl*Radl; fDRlength = fDRradl*Radl;
136  fEcalLength = fNLtot*fDLlength; fEcalRadius = fNRtot*fDRlength;
137 
138  // Cleanup old geometry
143 
144  //
145  // Ecal
146  //
147  fSolidEcal = new G4Tubs("Ecal",0.,fEcalRadius,0.5*fEcalLength,0.,360*deg);
148  fLogicEcal = new G4LogicalVolume( fSolidEcal,fMaterial,"Ecal",0,0,0);
149  fPhysiEcal = new G4PVPlacement(0,G4ThreeVector(),
150  fLogicEcal,"Ecal",0,false,0);
151 
152  G4cout << "Absorber is " << G4BestUnit(fEcalLength,"Length")
153  << " of " << fMaterial->GetName() << G4endl;
154  G4cout << fMaterial << G4endl;
155 
156  //
157  //always return the physical World
158  //
159  return fPhysiEcal;
160 }
161 
162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
163 
164 void DetectorConstruction::SetMaterial(const G4String& materialChoice)
165 {
166  // search the material by its name
167  G4Material* pttoMaterial =
168  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
169 
170  if (pttoMaterial) {
171  fMaterial = pttoMaterial;
172  if(fLogicEcal) fLogicEcal->SetMaterial(fMaterial);
174  }
175 }
176 
177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
178 
180 {
181  fNLtot = (G4int)Value(0);
182  if (fNLtot > MaxBin) {
183  G4cout << "\n ---> warning from SetLBining: "
184  << fNLtot << " truncated to " << MaxBin << G4endl;
185  fNLtot = MaxBin;
186  }
187  fDLradl = Value(1);
188 }
189 
190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
191 
193 {
194  fNRtot = (G4int)Value(0);
195  if (fNRtot > MaxBin) {
196  G4cout << "\n ---> warning from SetRBining: "
197  << fNRtot << " truncated to " << MaxBin << G4endl;
198  fNRtot = MaxBin;
199  }
200  fDRradl = Value(1);
201 }
202 
203 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204 
206 {
207  //apply a global uniform magnetic field along Z axis
208  G4FieldManager* fieldMgr
210 
211  if(fMagField) delete fMagField; //delete the existing magn field
212 
213  if(fieldValue!=0.) // create a new one if non nul
214  { fMagField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
215  fieldMgr->SetDetectorField(fMagField);
216  fieldMgr->CreateChordFinder(fMagField);
217  } else {
218  fMagField = 0;
219  fieldMgr->SetDetectorField(fMagField);
220  }
221 }
222 
223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
224 
226 {
227  G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
228 }
229 
230 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......