Geant4  10.01.p03
BrachyDetectorConstruction.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 // --------------------------------------------------------------
27 // GEANT 4 - Brachytherapy example
28 // --------------------------------------------------------------
29 //
30 // Code developed by:
31 // S. Agostinelli, F. Foppiano, S. Garelli , M. Tropeano, S.Guatelli
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 "BrachyFactoryIr.hh"
58 #include "BrachyFactoryI.hh"
61 
63  detectorChoice(0), factory(0),
64  World(0), WorldLog(0), WorldPhys(0),
65  Phantom(0), PhantomLog(0), PhantomPhys(0),
66  phantomAbsorberMaterial(0)
67 {
68  // Define half size of the phantom along the x, y, z axis
69  phantomSizeX = 15.*cm;
70  phantomSizeY = 15.*cm;
71  phantomSizeZ = 15.*cm;
72 
73  // Define the sizes of the World volume containing the phantom
74  worldSizeX = 4.0*m;
75  worldSizeY = 4.0*m;
76  worldSizeZ = 4.0*m;
77 
78  // Define the messenger of the Detector component
79  // It is possible to modify geometrical parameters through UI
81 
82  // Define the Iridium source as default source modelled in the geometry
83  factory = new BrachyFactoryIr();
84 
85  // BrachyMaterial defined the all the materials necessary
86  // for the experimental set-up
87  pMaterial = new BrachyMaterial();
88 }
89 
91 {
92  delete pMaterial;
93  delete factory;
94  delete detectorMessenger;
95 }
96 
98 {
99  pMaterial -> DefineMaterials();
100 
101  // Model the phantom (water box)
103 
104  // Model the source in the phantom
105  factory -> CreateSource(PhantomPhys);
106 
107  return WorldPhys;
108 }
109 
111 {
112  // Change the source in the water phantom
113  factory -> CleanSource();
114  G4cout << "Old Source is deleted ..." << G4endl;
115  delete factory;
116 
117  switch(detectorChoice)
118  {
119  case 1:
120  factory = new BrachyFactoryI();
121  break;
122  case 2:
124  break;
125  case 3:
126  factory = new BrachyFactoryIr();
127  break;
128  default:
129  factory = new BrachyFactoryIr();
130  break;
131  }
132 
133  factory -> CreateSource(PhantomPhys);
134  G4cout << "... New source is created ..." << G4endl;
135 
136  // Notify run manager that the new geometry has been built
138  G4cout << "... Geometry is notified .... THAT'S IT!!!!!" << G4endl;
139 }
140 
142 {
143  if (val == "Iodium") detectorChoice = 1;
144  else{
145  if(val=="Leipzig") detectorChoice = 2;
146  else{
147  if(val=="Iridium") detectorChoice = 3;
148  else G4cout << val << "is not available!!!!" <<G4endl;
149  }
150  }
151  G4cout << "Now the source is " << val << G4endl;
152 }
153 
155 {
156  // Model the water phantom
157 
158  // Define the light blue color
159  G4Colour lblue (0.0, 0.0, .75);
160 
161  G4Material* air = pMaterial -> GetMat("Air") ;
162  G4Material* water = pMaterial -> GetMat("Water");
163 
164  // World volume
165  World = new G4Box("World",worldSizeX,worldSizeY,worldSizeZ);
166  WorldLog = new G4LogicalVolume(World,air,"WorldLog",0,0,0);
167  WorldPhys = new G4PVPlacement(0,G4ThreeVector(),"WorldPhys",WorldLog,0,false,0);
168 
169  // Water Box
171 
172  // Logical volume
173  PhantomLog = new G4LogicalVolume(Phantom,water,"PhantomLog",0,0,0);
174 
175  // Physical volume
176  PhantomPhys = new G4PVPlacement(0,G4ThreeVector(), // Position: rotation and translation
177  "PhantomPhys", // Name
178  PhantomLog, // Associated logical volume
179  WorldPhys, // Mother volume
180  false,0);
181  WorldLog -> SetVisAttributes (G4VisAttributes::Invisible);
182 
183  // Visualization attributes of the phantom
184  G4VisAttributes* simpleBoxVisAtt = new G4VisAttributes(lblue);
185  simpleBoxVisAtt -> SetVisibility(true);
186  simpleBoxVisAtt -> SetForceWireframe(true);
187  PhantomLog -> SetVisAttributes(simpleBoxVisAtt);
188 }
189 
191 {
192  G4cout << "----------------" << G4endl
193  << "the phantom is a water box whose size is: " << G4endl
194  << phantomSizeX *2./cm
195  << " cm * "
196  << phantomSizeY *2./cm
197  << " cm * "
198  << phantomSizeZ *2./cm
199  << " cm" << G4endl
200  << "The phantom is made of "
201  << phantomAbsorberMaterial -> GetName() <<G4endl
202  << "the source is at the center of the phantom" << G4endl
203  << "----------------"
204  << G4endl;
205 }
206 
208 {
209  // It is possible to change the material of the phantom
210  // interactively
211 
212  // Search the material by its name
213  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
214 
215  if (pttoMaterial)
216  {
217  phantomAbsorberMaterial = pttoMaterial;
218  PhantomLog -> SetMaterial(pttoMaterial);
220  } else
221  { G4cout << "WARNING: material '" << materialChoice << "' not available!" << G4endl;}
222 }
static const double cm
Definition: G4SIunits.hh:106
CLHEP::Hep3Vector G4ThreeVector
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:603
Definition: G4Box.hh:64
BrachyDetectorMessenger * detectorMessenger
G4GLOB_DLL std::ostream G4cout
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static const G4VisAttributes Invisible
#define G4endl
Definition: G4ios.hh:61
static const double m
Definition: G4SIunits.hh:110