Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
BrachyDetectorConstruction.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 //
26 // --------------------------------------------------------------
27 // GEANT 4 - Brachytherapy example
28 // --------------------------------------------------------------
29 //
30 // Code developed by:S. Guatelli, D. Cutajar
31 // Past developers: S. Agostinelli, F. Foppiano, S. Garelli , M. Tropeano
32 //
33 //
34 // ****************************************
35 // * *
36 // * BrachyDetectorConstruction.cc *
37 // * *
38 // ****************************************
39 //
40 #include "G4SystemOfUnits.hh"
41 #include "G4CSGSolid.hh"
43 #include "G4SDManager.hh"
44 #include "G4RunManager.hh"
45 #include "G4Box.hh"
46 #include "G4LogicalVolume.hh"
47 #include "G4ThreeVector.hh"
48 #include "G4PVPlacement.hh"
49 #include "globals.hh"
50 #include "G4MaterialTable.hh"
52 #include "G4Colour.hh"
53 #include "G4UserLimits.hh"
54 #include "G4VisAttributes.hh"
55 #include "BrachyMaterial.hh"
56 #include "BrachyFactoryLeipzig.hh"
57 #include "BrachyFactoryTG186.hh"
58 #include "BrachyFactoryI.hh"
59 #include "BrachyFactoryFlexi.hh"
62 
64  detectorChoice(0), factory(0),
65  World(0), WorldLog(0), WorldPhys(0),
66  Phantom(0), PhantomLog(0), PhantomPhys(0),
67  phantomAbsorberMaterial(0)
68 {
69  // Define half size of the phantom along the x, y, z axis
70  phantomSizeX = 15.*cm;
71  phantomSizeY = 15.*cm;
72  phantomSizeZ = 15.*cm;
73 
74  // Define the sizes of the World volume containing the phantom
75  worldSizeX = 4.0*m;
76  worldSizeY = 4.0*m;
77  worldSizeZ = 4.0*m;
78 
79  // Define the messenger of the Detector component
80  // It is possible to modify geometrical parameters through UI
82 
83  // Define the Flexi source as default source modelled in the geometry
85 
86  // BrachyMaterial defined the all the materials necessary
87  // for the experimental set-up
88  pMaterial = new BrachyMaterial();
89 }
90 
92 {
93  delete pMaterial;
94  delete factory;
95  delete detectorMessenger;
96 }
97 
99 {
100  pMaterial -> DefineMaterials();
101 
102  // Model the phantom (water box)
104 
105  // Model the source in the phantom
106  factory -> CreateSource(PhantomPhys);
107 
108  return WorldPhys;
109 }
110 
112 {
113  // Change the source in the water phantom
114  factory -> CleanSource();
115  G4cout << "Old Source is deleted ..." << G4endl;
116  delete factory;
117 
118  switch(detectorChoice)
119  {
120  case 1:
121  factory = new BrachyFactoryI();
122  break;
123  case 2:
125  break;
126  case 3:
127  factory = new BrachyFactoryTG186();
128  break;
129  case 4:
130  factory = new BrachyFactoryFlexi();
131  break;
132  default:
133  factory = new BrachyFactoryFlexi();
134  break;
135  }
136 
137  factory -> CreateSource(PhantomPhys);
138  G4cout << "... New source is created ..." << G4endl;
139 
140  // Notify run manager that the new geometry has been built
142  G4cout << "... Geometry is notified .... THAT'S IT!!!!!" << G4endl;
143 }
144 
146 {
147  if (val == "Iodine") detectorChoice = 1;
148  else{
149  if(val=="Leipzig") detectorChoice = 2;
150  else{
151  if(val=="TG186") detectorChoice = 3;
152  else{
153  if(val=="Flexi") detectorChoice = 4;
154  else G4cout << val << "is not available!!!!" <<G4endl;
155  }
156  }
157  }
158  G4cout << "Now the source is " << val << G4endl;
159 }
160 
162 {
163  // Model the water phantom
164 
165  // Define the light blue color
166  G4Colour lblue (0.0, 0.0, .75);
167 
168  G4Material* air = pMaterial -> GetMat("Air") ;
169  G4Material* water = pMaterial -> GetMat("Water");
170 
171  // World volume
172  World = new G4Box("World",worldSizeX,worldSizeY,worldSizeZ);
173  WorldLog = new G4LogicalVolume(World,air,"WorldLog",0,0,0);
174  WorldPhys = new G4PVPlacement(0,G4ThreeVector(),"WorldPhys",WorldLog,0,false,0);
175 
176  // Water Box
178 
179  // Logical volume
180  PhantomLog = new G4LogicalVolume(Phantom,water,"PhantomLog",0,0,0);
181 
182  // Physical volume
183  PhantomPhys = new G4PVPlacement(0,G4ThreeVector(), // Position: rotation and translation
184  "PhantomPhys", // Name
185  PhantomLog, // Associated logical volume
186  WorldPhys, // Mother volume
187  false,0);
188  WorldLog -> SetVisAttributes (G4VisAttributes::GetInvisible());
189 
190  // Visualization attributes of the phantom
191  G4VisAttributes* simpleBoxVisAtt = new G4VisAttributes(lblue);
192  simpleBoxVisAtt -> SetVisibility(true);
193  simpleBoxVisAtt -> SetForceWireframe(true);
194  PhantomLog -> SetVisAttributes(simpleBoxVisAtt);
195 }
196 
198 {
199  G4cout << "----------------" << G4endl
200  << "the phantom is a water box whose size is: " << G4endl
201  << phantomSizeX *2./cm
202  << " cm * "
203  << phantomSizeY *2./cm
204  << " cm * "
205  << phantomSizeZ *2./cm
206  << " cm" << G4endl
207  << "The phantom is made of "
208  << phantomAbsorberMaterial -> GetName() <<G4endl
209  << "the source is at the center of the phantom" << G4endl
210  << "----------------"
211  << G4endl;
212 }
213 
215 {
216  // It is possible to change the material of the phantom
217  // interactively
218 
219  // Search the material by its name
220  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
221 
222  if (pttoMaterial)
223  {
224  phantomAbsorberMaterial = pttoMaterial;
225  PhantomLog -> SetMaterial(pttoMaterial);
227  } else
228  { G4cout << "WARNING: material '" << materialChoice << "' not available!" << G4endl;}
229 }
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
CLHEP::Hep3Vector G4ThreeVector
#define G4endl
Definition: G4ios.hh:61
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:608
static const G4VisAttributes & GetInvisible()
static constexpr double m
Definition: G4SIunits.hh:129
Definition: G4Box.hh:64
BrachyDetectorMessenger * detectorMessenger
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119