Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/hadronic/Hadr03/src/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 // $Id: DetectorConstruction.cc 108917 2018-03-16 07:18:27Z gcosmo $
30 //
31 
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 
35 #include "DetectorConstruction.hh"
36 #include "DetectorMessenger.hh"
37 
38 #include "G4Material.hh"
39 #include "G4NistManager.hh"
40 #include "G4Box.hh"
41 #include "G4LogicalVolume.hh"
42 #include "G4PVPlacement.hh"
43 
44 #include "G4GeometryManager.hh"
45 #include "G4PhysicalVolumeStore.hh"
46 #include "G4LogicalVolumeStore.hh"
47 #include "G4SolidStore.hh"
48 
49 #include "G4UnitsTable.hh"
50 #include "G4SystemOfUnits.hh"
51 
52 #include "G4RunManager.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
58  fPBox(0), fLBox(0), fMaterial(0), fDetectorMessenger(0)
59 {
60  fBoxSize = 10*m;
62  SetMaterial("Molybdenum98");
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
67 
69 { delete fDetectorMessenger;}
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
74 {
75  return ConstructVolumes();
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
81 {
82  // define a Material from isotopes
83  //
84  MaterialWithSingleIsotope("Molybdenum98", "Mo98", 10.28*g/cm3, 42, 98);
85 
86  //NE213
87  G4Element* H = new G4Element("Hydrogen" ,"H" , 1., 1.01*g/mole);
88  G4Element* C = new G4Element("Carbon" ,"C" , 6., 12.00*g/mole);
89  G4Material* ne213 =
90  new G4Material("NE213", 0.874*g/cm3, 2);
91  ne213->AddElement(H, 9.2*perCent);
92  ne213->AddElement(C, 90.8*perCent);
93 
94  G4Material* hydrogen =
95  new G4Material("hydrogen", 1.0*g/cm3, 1);
96  hydrogen->AddElement(H, 1);
97 
98  G4Material* carbon =
99  new G4Material("carbon", 1.0*g/cm3, 1);
100  carbon->AddElement(C, 1);
101 
102  G4Material* plastic =
103  new G4Material("plastic", 1.0*g/cm3, 2);
104  plastic->AddElement(H, 1);
105  plastic->AddElement(C, 1);
106 
107  // or use G4-NIST materials data base
108  //
110  man->FindOrBuildMaterial("G4_B");
111 
112  G4Element* O = man->FindOrBuildElement("O");
113  G4Element* Hf = man->FindOrBuildElement("Hf");
114 
115  G4Material* HfO2 = new G4Material("HfO2", 9.68*g/cm3, 2);
116  HfO2->AddElement(Hf, 1);
117  HfO2->AddElement(O , 2);
118 
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
125  G4String symbol, G4double density, G4int Z, G4int A)
126 {
127  // define a material from an isotope
128  //
129  G4int ncomponents;
130  G4double abundance, massfraction;
131 
132  G4Isotope* isotope = new G4Isotope(symbol, Z, A);
133 
134  G4Element* element = new G4Element(name, symbol, ncomponents=1);
135  element->AddIsotope(isotope, abundance= 100.*perCent);
136 
137  G4Material* material = new G4Material(name, density, ncomponents=1);
138  material->AddElement(element, massfraction=100.*perCent);
139 
140  return material;
141 }
142 
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
144 
146 {
147  // Cleanup old geometry
152 
153  G4Box*
154  sBox = new G4Box("Container", //its name
155  fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions
156 
157  fLBox = new G4LogicalVolume(sBox, //its shape
158  fMaterial, //its material
159  fMaterial->GetName()); //its name
160 
161  fPBox = new G4PVPlacement(0, //no rotation
162  G4ThreeVector(), //at (0,0,0)
163  fLBox, //its logical volume
164  fMaterial->GetName(), //its name
165  0, //its mother volume
166  false, //no boolean operation
167  0); //copy number
168 
169  PrintParameters();
170 
171  //always return the root volume
172  //
173  return fPBox;
174 }
175 
176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
177 
179 {
180  G4cout << "\n The Box is " << G4BestUnit(fBoxSize,"Length")
181  << " of " << fMaterial->GetName()
182  << "\n \n" << fMaterial << G4endl;
183 }
184 
185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
186 
187 void DetectorConstruction::SetMaterial(G4String materialChoice)
188 {
189  // search the material by its name
190  G4Material* pttoMaterial =
191  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
192 
193  if (pttoMaterial) {
194  if(fMaterial != pttoMaterial) {
195  fMaterial = pttoMaterial;
196  if(fLBox) { fLBox->SetMaterial(pttoMaterial); }
198  }
199  } else {
200  G4cout << "\n--> warning from DetectorConstruction::SetMaterial : "
201  << materialChoice << " not found" << G4endl;
202  }
203 }
204 
205 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
206 
208 {
209  fBoxSize = value;
211 }
212 
213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
const XML_Char * name
Definition: expat.h:151
static void Clean()
Definition: G4SolidStore.cc:73
CLHEP::Hep3Vector G4ThreeVector
#define G4endl
Definition: G4ios.hh:61
static constexpr double perCent
Definition: G4SIunits.hh:332
const G4String & GetName() const
Definition: G4Material.hh:179
void AddIsotope(G4Isotope *isotope, G4double RelativeAbundance)
Definition: G4Element.cc:152
Float_t Z
G4Element * FindOrBuildElement(G4int Z, G4bool isotopes=true)
static constexpr double g
Definition: G4SIunits.hh:183
static constexpr double m
Definition: G4SIunits.hh:129
double G4double
Definition: G4Types.hh:76
const XML_Char int const XML_Char * value
Definition: expat.h:331
static G4GeometryManager * GetInstance()
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
double A(double temperature)
void OpenGeometry(G4VPhysicalVolume *vol=0)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4SolidStore * GetInstance()
static G4PhysicalVolumeStore * GetInstance()
int G4int
Definition: G4Types.hh:78
void ReinitializeGeometry(G4bool destroyFirst=false, G4bool prop=true)
double C(double temp)
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:368
void PhysicsHasBeenModified()
G4GLOB_DLL std::ostream G4cout
void SetMaterial(G4Material *pMaterial)
static constexpr double mole
Definition: G4SIunits.hh:286
static constexpr double cm3
Definition: G4SIunits.hh:121
static G4LogicalVolumeStore * GetInstance()
static G4NistManager * Instance()
G4Material * MaterialWithSingleIsotope(G4String, G4String, G4double, G4int, G4int)