ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BrachyDetectorConstruction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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, A. Le
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"
63 
65  detectorChoice(0), factory(0),
66  World(0), WorldLog(0), WorldPhys(0),
67  Phantom(0), PhantomLog(0), PhantomPhys(0),
68  phantomAbsorberMaterial(0)
69 {
70  // Define half size of the phantom along the x, y, z axis
71  phantomSizeX = 15.*cm;
72  phantomSizeY = 15.*cm;
73  phantomSizeZ = 15.*cm;
74 
75  // Define the sizes of the World volume containing the phantom
76  worldSizeX = 4.0*m;
77  worldSizeY = 4.0*m;
78  worldSizeZ = 4.0*m;
79 
80  // Define the messenger of the Detector component
81  // It is possible to modify geometrical parameters through UI
83 
84  // Define the Flexi source as default source modelled in the geometry
86 
87  // BrachyMaterial defined the all the materials necessary
88  // for the experimental set-up
89  pMaterial = new BrachyMaterial();
90 }
91 
93 {
94  delete pMaterial;
95  delete factory;
96  delete detectorMessenger;
97 }
98 
100 {
101  pMaterial -> DefineMaterials();
102 
103  // Model the phantom (water box)
105 
106  // Model the source in the phantom
107  factory -> CreateSource(PhantomPhys);
108 
109  return WorldPhys;
110 }
111 
113 {
114  // Change the source in the water phantom
115  factory -> CleanSource();
116  G4cout << "Old Source is deleted ..." << G4endl;
117  delete factory;
118 
119  switch(detectorChoice)
120  {
121  case 1:
122  factory = new BrachyFactoryI();
123  break;
124  case 2:
126  break;
127  case 3:
128  factory = new BrachyFactoryTG186();
129  break;
130  case 4:
131  factory = new BrachyFactoryFlexi();
132  break;
133  case 5:
135  break;
136  default:
137  factory = new BrachyFactoryFlexi();
138  break;
139  }
140 
141  factory -> CreateSource(PhantomPhys);
142  G4cout << "... New source is created ..." << G4endl;
143 
144  // Notify run manager that the new geometry has been built
146  G4cout << "... Geometry is notified .... THAT'S IT!!!!!" << G4endl;
147 }
148 
150 {
151  if (val == "Iodine")
152  detectorChoice = 1;
153  else
154  {
155  if(val=="Leipzig")
156  detectorChoice = 2;
157  else
158  {
159  if(val=="TG186")
160  detectorChoice = 3;
161  else
162  {
163  if(val=="Flexi")
164  detectorChoice = 4;
165  else
166  {
167  if(val=="Oncura")
168  detectorChoice = 5;
169  else
170  G4cout << val << "is not available!!!!" << G4endl;
171  }
172  }
173  }
174  }
175  G4cout << "Now the source is " << val << G4endl;
176 }
177 
179 {
180  // Model the water phantom
181 
182  // Define the light blue color
183  G4Colour lblue (0.0, 0.0, .75);
184 
185  G4Material* air = pMaterial -> GetMat("Air") ;
186  G4Material* water = pMaterial -> GetMat("Water");
187 
188  // World volume
189  World = new G4Box("World",worldSizeX,worldSizeY,worldSizeZ);
190  WorldLog = new G4LogicalVolume(World,air,"WorldLog",0,0,0);
191  WorldPhys = new G4PVPlacement(0,G4ThreeVector(),"WorldPhys",WorldLog,0,false,0);
192 
193  // Water Box
195 
196  // Logical volume
197  PhantomLog = new G4LogicalVolume(Phantom,water,"PhantomLog",0,0,0);
198 
199  // Physical volume
200  PhantomPhys = new G4PVPlacement(0,G4ThreeVector(), // Position: rotation and translation
201  "PhantomPhys", // Name
202  PhantomLog, // Associated logical volume
203  WorldPhys, // Mother volume
204  false,0);
205  WorldLog -> SetVisAttributes (G4VisAttributes::GetInvisible());
206 
207  // Visualization attributes of the phantom
208  G4VisAttributes* simpleBoxVisAtt = new G4VisAttributes(lblue);
209  simpleBoxVisAtt -> SetVisibility(true);
210  simpleBoxVisAtt -> SetForceWireframe(true);
211  PhantomLog -> SetVisAttributes(simpleBoxVisAtt);
212 }
213 
215 {
216  G4cout << "----------------" << G4endl
217  << "the phantom is a water box whose size is: " << G4endl
218  << phantomSizeX *2./cm
219  << " cm * "
220  << phantomSizeY *2./cm
221  << " cm * "
222  << phantomSizeZ *2./cm
223  << " cm" << G4endl
224  << "The phantom is made of "
225  << phantomAbsorberMaterial -> GetName() <<G4endl
226  << "the source is at the center of the phantom" << G4endl
227  << "----------------"
228  << G4endl;
229 }
230 
232 {
233  // It is possible to change the material of the phantom
234  // interactively
235 
236  // Search the material by its name
237  G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
238 
239  if (pttoMaterial)
240  {
241  phantomAbsorberMaterial = pttoMaterial;
242  PhantomLog -> SetMaterial(pttoMaterial);
244  } else
245  { G4cout << "WARNING: material '" << materialChoice << "' not available!" << G4endl;}
246 }