Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/electromagnetic/TestEm2/src/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 //
26 /// \file electromagnetic/TestEm2/src/DetectorConstruction.cc
27 /// \brief Implementation of the DetectorConstruction class
28 //
29 //
30 // $Id: DetectorConstruction.cc 77305 2013-11-22 11:16:19Z gcosmo $
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 
49 
50 #include "G4NistManager.hh"
51 #include "G4RunManager.hh"
52 
53 #include "G4UnitsTable.hh"
54 #include "G4SystemOfUnits.hh"
55 
56 #include "G4AutoDelete.hh"
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
61  fNLtot(40),fNRtot(50),fDLradl(0.5),fDRradl(0.1),
62  fDLlength(0.),fDRlength(0.),
63  fMaterial(0),
64  fEcalLength(0.),fEcalRadius(0.),
65  fSolidEcal(0),fLogicEcal(0),fPhysiEcal(0),
66  fDetectorMessenger(0)
67 {
68  DefineMaterials();
69  SetMaterial("G4_PbWO4");
70  fDetectorMessenger = new DetectorMessenger(this);
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 
76 { delete fDetectorMessenger;}
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81 {
82  return ConstructVolumes();
83 }
84 
85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
86 
87 void DetectorConstruction::DefineMaterials()
88 {
89  //
90  // define few Elements by hand
91  //
92  G4double a, z;
93 
94  G4Element* H = new G4Element("Hydrogen", "H", z= 1., a= 1.01*g/mole);
95  G4Element* O = new G4Element("Oxygen" , "O", z= 8., a= 16.00*g/mole);
96  G4Element* Ge = new G4Element("Germanium", "Ge",z=32., a= 72.59*g/mole);
97  G4Element* Bi = new G4Element("Bismuth", "Bi",z=83., a= 208.98*g/mole);
98 
99  //
100  // define materials
101  //
103  G4int ncomponents, natoms;
104 
105  // water with ionisation potential 78 eV
106  G4Material* H2O =
107  new G4Material("Water", density= 1.00*g/cm3, ncomponents=2);
108  H2O->AddElement(H, natoms=2);
109  H2O->AddElement(O, natoms=1);
111 
112  // pure materails
113  new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
114  new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.7*g/cm3);
115  new G4Material("Iron", z=26., a= 55.85*g/mole, density= 7.87*g/cm3);
116  new G4Material("Copper", z=29., a= 63.55*g/mole, density= 8.960*g/cm3);
117  new G4Material("Tungsten", z=74., a=183.84*g/mole, density=19.35*g/cm3);
118  new G4Material("Lead", z=82., a=207.19*g/mole, density=11.35*g/cm3);
119  new G4Material("Uranium" , z=92., a=238.03*g/mole, density= 18.95*g/cm3);
120 
121  // compound material
122  G4Material* BGO =
123  new G4Material("BGO", density= 7.10*g/cm3, ncomponents=3);
124  BGO->AddElement(O , natoms=12);
125  BGO->AddElement(Ge, natoms= 3);
126  BGO->AddElement(Bi, natoms= 4);
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 
153 
154  G4cout << "Absorber is " << G4BestUnit(fEcalLength,"Length")
155  << " of " << fMaterial->GetName() << G4endl;
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 && fMaterial != 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);
189 }
190 
191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
192 
194 {
195  fNRtot = (G4int)Value(0);
196  if (fNRtot > MaxBin) {
197  G4cout << "\n ---> warning from SetRBining: "
198  << fNRtot << " truncated to " << MaxBin << G4endl;
199  fNRtot = MaxBin;
200  }
201  fDRradl = Value(1);
203 }
204 
205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
206 
208 {
209  if ( fFieldMessenger.Get() == 0 ) {
210  // Create global magnetic field messenger.
211  // Uniform magnetic field is then created automatically if
212  // the field value is not zero.
213  G4ThreeVector fieldValue = G4ThreeVector();
215  new G4GlobalMagFieldMessenger(fieldValue);
216  //msg->SetVerboseLevel(1);
218  fFieldMessenger.Put( msg );
219 
220  }
221 }
222 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:224
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
void SetMeanExcitationEnergy(G4double value)
const G4String & GetName() const
Definition: G4Material.hh:176
value_type & Get() const
Definition: G4Cache.hh:253
Definition: G4Tubs.hh:84
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
static void Clean()
Definition: G4SolidStore.cc:79
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
static G4PhysicalVolumeStore * GetInstance()
G4double density
Definition: TRTMaterials.hh:39
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4GLOB_DLL std::ostream G4cout
void PhysicsHasBeenModified()
static G4LogicalVolumeStore * GetInstance()
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
G4double GetRadlen() const
Definition: G4Material.hh:218
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:74
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:345
double G4double
Definition: G4Types.hh:76
void SetMaterial(G4Material *pMaterial)
void Put(const value_type &val) const
Definition: G4Cache.hh:257