Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/polarisation/Pol01/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 98772 2016-08-09 14:25:31Z gcosmo $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorConstruction.hh"
35 #include "DetectorMessenger.hh"
36 
37 #include "G4Material.hh"
38 #include "G4Box.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 
47 #include "G4UnitsTable.hh"
48 
49 #include "G4PolarizationManager.hh"
50 #include "G4NistManager.hh"
51 #include "G4SystemOfUnits.hh"
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
57  fWorld(0), fBox(0), fTargetMaterial(0), fWorldMaterial(0)
58 {
59  fBoxSizeXY = 50*mm;
60  fBoxSizeZ = 5*mm;
61  fWorldSize = 1.*m;
62  SetTargetMaterial("G4_Fe");
63  SetWorldMaterial("G4_Galactic");
64  fMessenger = new DetectorMessenger(this);
65 }
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
70 {
71  delete fMessenger;
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75 
77 {
78  // Cleanup old geometry
83 
85 
86  // World
87  //
88  G4Box*
89  sWorld = new G4Box("World", //name
90  fWorldSize/2,fWorldSize/2,fWorldSize/2); //dimensions
91 
93  lWorld = new G4LogicalVolume(sWorld, //shape
94  fWorldMaterial, //material
95  "World"); //name
96 
97  fWorld = new G4PVPlacement(0, //no rotation
98  G4ThreeVector(), //at (0,0,0)
99  lWorld, //logical volume
100  "World", //name
101  0, //mother volume
102  false, //no boolean operation
103  0); //copy number
104 
105  // Box
106  //
107  G4Box*
108  sBox = new G4Box("Container", //its name
109  fBoxSizeXY/2.,fBoxSizeXY/2.,fBoxSizeZ/2.);//its dimensions
110 
112  lBox = new G4LogicalVolume(sBox, //its shape
113  fTargetMaterial, //its material
114  "theBox"); //its name
115 
116  fBox = new G4PVPlacement(0, //no rotation
117  G4ThreeVector(), //at (0,0,0)
118  lBox, //its logical volume
119  fTargetMaterial->GetName(), //its name
120  lWorld, //its mother volume
121  false, //no boolean operation
122  0); //copy number
123 
124  // register logical Volume in PolarizationManager with zero polarization
126  polMgr->SetVolumePolarization(lBox,G4ThreeVector(0.,0.,0.));
127 
128  PrintParameters();
129 
130  //always return the root volume
131  //
132  return fWorld;
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136 
138 {
139  G4cout << "\n The Box is " << G4BestUnit(fBoxSizeXY,"Length")
140  << " x " << G4BestUnit(fBoxSizeXY,"Length")
141  << " x " << G4BestUnit(fBoxSizeZ,"Length")
142  << " of " << fTargetMaterial->GetName() << G4endl;
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146 
148 {
149  // search the material by its name
150  G4Material* mat =
151  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
152  if (mat != fTargetMaterial) {
153  if(mat) {
155  UpdateGeometry();
156  } else {
157  G4cout << "### Warning! Target material: <"
158  << materialChoice << "> not found" << G4endl;
159  }
160  }
161 }
162 
163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
164 
166 {
167  // search the material by its name
168  G4Material* mat =
169  G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
170  if (mat != fWorldMaterial) {
171  if(mat) {
173  UpdateGeometry();
174  } else {
175  G4cout << "### Warning! World material: <"
176  << materialChoice << "> not found" << G4endl;
177  }
178  }
179 }
180 
181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
182 
184 {
185  fBoxSizeXY = value;
187  UpdateGeometry();
188 }
189 
191 {
192  fBoxSizeZ = value;
194  UpdateGeometry();
195 }
196 
197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
198 
199 #include "G4RunManager.hh"
200 
202 {
203  if (fWorld)
205 }
206 
207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
static void Clean()
Definition: G4SolidStore.cc:73
CLHEP::Hep3Vector G4ThreeVector
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
void SetWorldMaterial(G4Material *amaterial)
Definition: pyEzgeom.cc:69
virtual void DefineWorldVolume(G4VPhysicalVolume *worldVol, G4bool topologyIsChanged=true)
const G4String & GetName() const
Definition: G4Material.hh:179
void SetWorldMaterial(const G4String &materialName)
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)
Float_t mat
void OpenGeometry(G4VPhysicalVolume *vol=0)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
static G4SolidStore * GetInstance()
static G4PhysicalVolumeStore * GetInstance()
G4GLOB_DLL std::ostream G4cout
static G4PolarizationManager * GetInstance()
static G4LogicalVolumeStore * GetInstance()
static G4NistManager * Instance()