Geant4  10.02.p01
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: DetectorConstruction.cc 78550 2014-01-07 09:43:41Z 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 
42 #include "G4GeometryManager.hh"
43 #include "G4PhysicalVolumeStore.hh"
44 #include "G4LogicalVolumeStore.hh"
45 #include "G4SolidStore.hh"
46 
48 
49 #include "G4NistManager.hh"
50 #include "G4RunManager.hh"
51 
52 #include "G4SystemOfUnits.hh"
53 #include "G4UnitsTable.hh"
54 
55 #include "G4AutoDelete.hh"
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
60  fNLtot(40),fNRtot(50),fDLradl(0.5),fDRradl(0.1),
61  fDLlength(0.),fDRlength(0.),
62  fMaterial(0),
63  fEcalLength(0.),fEcalRadius(0.),
64  fSolidEcal(0),fLogicEcal(0),fPhysiEcal(0),
65  fDetectorMessenger(0)
66 {
68  SetMaterial("G4_PbWO4");
70 }
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
75 { delete fDetectorMessenger;}
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
80 {
81  return ConstructVolumes();
82 }
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
87 {
88  //
89  // define few Elements by hand
90  //
91  G4double a, z;
92 
93  G4Element* H = new G4Element("Hydrogen", "H", z= 1., a= 1.01*g/mole);
94  G4Element* O = new G4Element("Oxygen" , "O", z= 8., a= 16.00*g/mole);
95  G4Element* Ge = new G4Element("Germanium", "Ge",z=32., a= 72.59*g/mole);
96  G4Element* Bi = new G4Element("Bismuth", "Bi",z=83., a= 208.98*g/mole);
97 
98  //
99  // define materials
100  //
102  G4int ncomponents, natoms;
103 
104  // water with ionisation potential 78 eV
105  G4Material* H2O =
106  new G4Material("Water", density= 1.00*g/cm3, ncomponents=2);
107  H2O->AddElement(H, natoms=2);
108  H2O->AddElement(O, natoms=1);
110 
111  // pure materails
112  new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
113  new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.7*g/cm3);
114  new G4Material("Iron", z=26., a= 55.85*g/mole, density= 7.87*g/cm3);
115  new G4Material("Copper", z=29., a= 63.55*g/mole, density= 8.960*g/cm3);
116  new G4Material("Tungsten", z=74., a=183.84*g/mole, density=19.35*g/cm3);
117  new G4Material("Lead", z=82., a=207.19*g/mole, density=11.35*g/cm3);
118  new G4Material("Uranium" , z=92., a=238.03*g/mole, density= 18.95*g/cm3);
119 
120  // compound material
121  G4Material* BGO =
122  new G4Material("BGO", density= 7.10*g/cm3, ncomponents=3);
123  BGO->AddElement(O , natoms=12);
124  BGO->AddElement(Ge, natoms= 3);
125  BGO->AddElement(Bi, natoms= 4);
126 }
127 
128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
129 
131 {
132  G4double Radl = fMaterial->GetRadlen();
133 
134  fDLlength = fDLradl*Radl; fDRlength = fDRradl*Radl;
136 
137  // Cleanup old geometry
142 
143  //
144  // Ecal
145  //
146  fSolidEcal = new G4Tubs("Ecal",0.,fEcalRadius,0.5*fEcalLength,0.,360*deg);
147  fLogicEcal = new G4LogicalVolume( fSolidEcal,fMaterial,"Ecal",0,0,0);
149  fLogicEcal,"Ecal",0,false,0);
150 
152 
153  G4cout << "Absorber is " << G4BestUnit(fEcalLength,"Length")
154  << " of " << fMaterial->GetName() << G4endl;
155  //
156  //always return the physical World
157  //
158  return fPhysiEcal;
159 }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162 
163 void DetectorConstruction::SetMaterial(const G4String& materialChoice)
164 {
165  // search the material by its name
166  G4Material* pttoMaterial =
167  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
168 
169  if(pttoMaterial && fMaterial != pttoMaterial) {
170  fMaterial = pttoMaterial;
173  }
174 }
175 
176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
177 
179 {
180  fNLtot = (G4int)Value(0);
181  if (fNLtot > MaxBin) {
182  G4cout << "\n ---> warning from SetLBining: "
183  << fNLtot << " truncated to " << MaxBin << G4endl;
184  fNLtot = MaxBin;
185  }
186  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);
202 }
203 
204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
205 
207 {
208  if ( fFieldMessenger.Get() == 0 ) {
209  // Create global magnetic field messenger.
210  // Uniform magnetic field is then created automatically if
211  // the field value is not zero.
212  G4ThreeVector fieldValue = G4ThreeVector();
214  new G4GlobalMagFieldMessenger(fieldValue);
215  //msg->SetVerboseLevel(1);
217  fFieldMessenger.Put( msg );
218 
219  }
220 }
221 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume * fPhysiEcal
G4IonisParamMat * GetIonisation() const
Definition: G4Material.hh:226
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
CLHEP::Hep3Vector G4ThreeVector
G4LogicalVolume * fLogicEcal
G4double z
Definition: TRTMaterials.hh:39
void SetMeanExcitationEnergy(G4double value)
const G4String & GetName() const
Definition: G4Material.hh:178
G4VPhysicalVolume * Construct()
value_type & Get() const
Definition: G4Cache.hh:282
Definition: G4Tubs.hh:85
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
static void Clean()
Definition: G4SolidStore.cc:79
G4double a
Definition: TRTMaterials.hh:39
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetLBining(G4ThreeVector)
int G4int
Definition: G4Types.hh:78
static G4NistManager * Instance()
G4Cache< G4GlobalMagFieldMessenger * > fFieldMessenger
static G4PhysicalVolumeStore * GetInstance()
G4double density
Definition: TRTMaterials.hh:39
virtual void ConstructSDandField()
void Register(T *inst)
Definition: G4AutoDelete.hh:65
G4GLOB_DLL std::ostream G4cout
void PhysicsHasBeenModified()
static const double deg
Definition: G4SIunits.hh:151
const G4int MaxBin
static G4LogicalVolumeStore * GetInstance()
static const double cm3
Definition: G4SIunits.hh:120
static G4SolidStore * GetInstance()
static G4GeometryManager * GetInstance()
G4double GetRadlen() const
Definition: G4Material.hh:220
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static const double eV
Definition: G4SIunits.hh:212
void SetRBining(G4ThreeVector)
static const double g
Definition: G4SIunits.hh:180
static const double mole
Definition: G4SIunits.hh:283
#define G4endl
Definition: G4ios.hh:61
void OpenGeometry(G4VPhysicalVolume *vol=0)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:364
double G4double
Definition: G4Types.hh:76
G4VPhysicalVolume * ConstructVolumes()
void SetMaterial(G4Material *pMaterial)
void Put(const value_type &val) const
Definition: G4Cache.hh:286
Messenger class that defines commands for DetectorConstruction.
DetectorMessenger * fDetectorMessenger