| 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
|
|---|
| 31 | //
|
|---|
| 32 | //
|
|---|
| 33 | // ****************************************
|
|---|
| 34 | // * *
|
|---|
| 35 | // * BrachyDetectorConstruction.cc *
|
|---|
| 36 | // * *
|
|---|
| 37 | // ****************************************
|
|---|
| 38 | //
|
|---|
| 39 | // $Id: BrachyDetectorConstruction.cc,v 1.3 2006/06/29 17:32:51 gunter Exp $
|
|---|
| 40 | // GEANT4 tag $Name: $
|
|---|
| 41 | //
|
|---|
| 42 | #include "BrachyPhantomROGeometry.hh"
|
|---|
| 43 | #include "BrachyPhantomSD.hh"
|
|---|
| 44 | #include "BrachyDetectorMessenger.hh"
|
|---|
| 45 | #include "BrachyDetectorConstruction.hh"
|
|---|
| 46 | #include "G4CSGSolid.hh"
|
|---|
| 47 | #include "G4Sphere.hh"
|
|---|
| 48 | #include "G4MaterialPropertyVector.hh"
|
|---|
| 49 | #include "G4SDManager.hh"
|
|---|
| 50 | #include "G4SubtractionSolid.hh"
|
|---|
| 51 | #include "G4RunManager.hh"
|
|---|
| 52 | #include "G4MaterialPropertiesTable.hh"
|
|---|
| 53 | #include "G4Material.hh"
|
|---|
| 54 | #include "G4Box.hh"
|
|---|
| 55 | #include "G4Tubs.hh"
|
|---|
| 56 | #include "G4LogicalVolume.hh"
|
|---|
| 57 | #include "G4ThreeVector.hh"
|
|---|
| 58 | #include "G4PVPlacement.hh"
|
|---|
| 59 | #include "globals.hh"
|
|---|
| 60 | #include "G4MaterialTable.hh"
|
|---|
| 61 | #include "Randomize.hh"
|
|---|
| 62 | #include "G4RunManager.hh"
|
|---|
| 63 | #include "G4Element.hh"
|
|---|
| 64 | #include "G4ElementTable.hh"
|
|---|
| 65 | #include "G4PVParameterised.hh"
|
|---|
| 66 | #include "G4Transform3D.hh"
|
|---|
| 67 | #include "G4RotationMatrix.hh"
|
|---|
| 68 | #include "G4FieldManager.hh"
|
|---|
| 69 | #include "G4TransportationManager.hh"
|
|---|
| 70 | #include "G4SDManager.hh"
|
|---|
| 71 | #include "G4Colour.hh"
|
|---|
| 72 | #include "G4UserLimits.hh"
|
|---|
| 73 | #include "G4UnionSolid.hh"
|
|---|
| 74 | #include "G4VisAttributes.hh"
|
|---|
| 75 | #include "G4Colour.hh"
|
|---|
| 76 | #include "BrachyMaterial.hh"
|
|---|
| 77 | #include "BrachyFactoryLeipzig.hh"
|
|---|
| 78 | #include "BrachyFactoryIr.hh"
|
|---|
| 79 | #include "BrachyFactoryI.hh"
|
|---|
| 80 |
|
|---|
| 81 | BrachyDetectorConstruction::BrachyDetectorConstruction(G4String &SDName)
|
|---|
| 82 | : detectorChoice(0), phantomSD(0), phantomROGeometry(0), factory(0),
|
|---|
| 83 | World(0), WorldLog(0), WorldPhys(0),
|
|---|
| 84 | Phantom(0), PhantomLog(0), PhantomPhys(0),
|
|---|
| 85 | phantomAbsorberMaterial(0)
|
|---|
| 86 | {
|
|---|
| 87 | phantomDimensionX = 15.*cm ;
|
|---|
| 88 | phantomDimensionY = 15.*cm;
|
|---|
| 89 | phantomDimensionZ = 15.*cm;
|
|---|
| 90 |
|
|---|
| 91 | numberOfVoxelsAlongX = 300;
|
|---|
| 92 | numberOfVoxelsAlongZ = 300;
|
|---|
| 93 |
|
|---|
| 94 | ComputeDimVoxel();
|
|---|
| 95 |
|
|---|
| 96 | Worldx = 4.0*m;
|
|---|
| 97 | Worldy = 4.0*m;
|
|---|
| 98 | Worldz = 4.0*m;
|
|---|
| 99 |
|
|---|
| 100 | sensitiveDetectorName = SDName;
|
|---|
| 101 |
|
|---|
| 102 | detectorMessenger = new BrachyDetectorMessenger(this);
|
|---|
| 103 |
|
|---|
| 104 | factory = new BrachyFactoryIr();
|
|---|
| 105 |
|
|---|
| 106 | pMaterial = new BrachyMaterial();
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 | BrachyDetectorConstruction::~BrachyDetectorConstruction()
|
|---|
| 111 | {
|
|---|
| 112 | delete pMaterial;
|
|---|
| 113 | delete factory;
|
|---|
| 114 | delete detectorMessenger;
|
|---|
| 115 | if (phantomROGeometry) delete phantomROGeometry;
|
|---|
| 116 | }
|
|---|
| 117 |
|
|---|
| 118 | G4VPhysicalVolume* BrachyDetectorConstruction::Construct()
|
|---|
| 119 | {
|
|---|
| 120 | pMaterial -> DefineMaterials();
|
|---|
| 121 | ConstructPhantom();
|
|---|
| 122 | factory ->CreateSource(PhantomPhys);
|
|---|
| 123 | ConstructSensitiveDetector();
|
|---|
| 124 |
|
|---|
| 125 | return WorldPhys;
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | void BrachyDetectorConstruction::SwitchBrachytherapicSeed()
|
|---|
| 129 | {
|
|---|
| 130 | factory -> CleanSource();
|
|---|
| 131 | delete factory;
|
|---|
| 132 | switch(detectorChoice)
|
|---|
| 133 | {
|
|---|
| 134 | case 1:
|
|---|
| 135 | factory = new BrachyFactoryI();
|
|---|
| 136 | break;
|
|---|
| 137 | case 2:
|
|---|
| 138 | factory = new BrachyFactoryLeipzig();
|
|---|
| 139 | break;
|
|---|
| 140 | case 3:
|
|---|
| 141 | factory = new BrachyFactoryIr();
|
|---|
| 142 | break;
|
|---|
| 143 | default:
|
|---|
| 144 | factory = new BrachyFactoryIr();
|
|---|
| 145 | break;
|
|---|
| 146 | }
|
|---|
| 147 | factory -> CreateSource(PhantomPhys);
|
|---|
| 148 |
|
|---|
| 149 | // Notify run manager that the new geometry has been built
|
|---|
| 150 |
|
|---|
| 151 | G4RunManager::GetRunManager()->DefineWorldVolume( WorldPhys );
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | void BrachyDetectorConstruction::SelectBrachytherapicSeed(G4String val)
|
|---|
| 155 | {
|
|---|
| 156 | if(val=="Iodium")
|
|---|
| 157 | {
|
|---|
| 158 | detectorChoice = 1;
|
|---|
| 159 | }
|
|---|
| 160 | else
|
|---|
| 161 | {
|
|---|
| 162 | if(val=="Leipzig")
|
|---|
| 163 | {
|
|---|
| 164 | detectorChoice = 2;
|
|---|
| 165 | }
|
|---|
| 166 | else
|
|---|
| 167 | {
|
|---|
| 168 | if(val=="Iridium")
|
|---|
| 169 | {
|
|---|
| 170 | detectorChoice = 3;
|
|---|
| 171 | }
|
|---|
| 172 | }
|
|---|
| 173 | }
|
|---|
| 174 | G4cout << "Now Detector is " << val << G4endl;
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | void BrachyDetectorConstruction::ConstructPhantom()
|
|---|
| 178 | {
|
|---|
| 179 | G4Colour lblue (0.0, 0.0, .75);
|
|---|
| 180 |
|
|---|
| 181 | G4Material* air = pMaterial -> GetMat("Air") ;
|
|---|
| 182 | G4Material* water = pMaterial -> GetMat("Water");
|
|---|
| 183 |
|
|---|
| 184 | ComputeDimVoxel();
|
|---|
| 185 |
|
|---|
| 186 | // World volume
|
|---|
| 187 | World = new G4Box("World",Worldx,Worldy,Worldz);
|
|---|
| 188 | WorldLog = new G4LogicalVolume(World,air,"WorldLog",0,0,0);
|
|---|
| 189 | WorldPhys = new G4PVPlacement(0,G4ThreeVector(),"WorldPhys",WorldLog,0,false,0);
|
|---|
| 190 |
|
|---|
| 191 | // Water Box
|
|---|
| 192 | Phantom = new G4Box("Phantom",phantomDimensionX,phantomDimensionY,phantomDimensionZ);
|
|---|
| 193 | PhantomLog = new G4LogicalVolume(Phantom,water,"PhantomLog",0,0,0);
|
|---|
| 194 | PhantomPhys = new G4PVPlacement(0,G4ThreeVector(),"PhantomPhys",PhantomLog,WorldPhys,false,0);
|
|---|
| 195 |
|
|---|
| 196 | WorldLog->SetVisAttributes (G4VisAttributes::Invisible);
|
|---|
| 197 |
|
|---|
| 198 | G4VisAttributes* simpleBoxVisAtt = new G4VisAttributes(lblue);
|
|---|
| 199 | simpleBoxVisAtt -> SetVisibility(true);
|
|---|
| 200 | simpleBoxVisAtt -> SetForceWireframe(true);
|
|---|
| 201 | PhantomLog -> SetVisAttributes(simpleBoxVisAtt);
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | void BrachyDetectorConstruction::ConstructSensitiveDetector()
|
|---|
| 205 | // Sensitive Detector and ReadOut geometry definition
|
|---|
| 206 | {
|
|---|
| 207 | G4SDManager* pSDManager = G4SDManager::GetSDMpointer();
|
|---|
| 208 |
|
|---|
| 209 | if(!phantomSD)
|
|---|
| 210 | {
|
|---|
| 211 | phantomSD = new BrachyPhantomSD(sensitiveDetectorName,
|
|---|
| 212 | numberOfVoxelsAlongX,
|
|---|
| 213 | numberOfVoxelsAlongZ);
|
|---|
| 214 | G4String ROGeometryName = "PhantomROGeometry";
|
|---|
| 215 | phantomROGeometry = new BrachyPhantomROGeometry(ROGeometryName,
|
|---|
| 216 | phantomDimensionX,
|
|---|
| 217 | phantomDimensionZ,
|
|---|
| 218 | numberOfVoxelsAlongX,
|
|---|
| 219 | numberOfVoxelsAlongZ);
|
|---|
| 220 | phantomROGeometry -> BuildROGeometry();
|
|---|
| 221 | phantomSD -> SetROgeometry(phantomROGeometry);
|
|---|
| 222 | pSDManager -> AddNewDetector(phantomSD);
|
|---|
| 223 | PhantomLog -> SetSensitiveDetector(phantomSD);
|
|---|
| 224 | }
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | void BrachyDetectorConstruction::PrintDetectorParameters()
|
|---|
| 228 | {
|
|---|
| 229 | G4cout << "-----------------------------------------------------------------------"
|
|---|
| 230 | << G4endl
|
|---|
| 231 | << "the detector is a box whose size is: " << G4endl
|
|---|
| 232 | << phantomDimensionX/cm
|
|---|
| 233 | << " cm * "
|
|---|
| 234 | << phantomDimensionY/cm
|
|---|
| 235 | << " cm * "
|
|---|
| 236 | << phantomDimensionZ/cm
|
|---|
| 237 | << " cm" << G4endl
|
|---|
| 238 | << "numVoxel: "
|
|---|
| 239 | << numberOfVoxelsAlongX <<G4endl
|
|---|
| 240 | << "dim voxel: "
|
|---|
| 241 | << dimVoxel/mm
|
|---|
| 242 | << "mm" << G4endl
|
|---|
| 243 | << "material of the box : "
|
|---|
| 244 | << phantomAbsorberMaterial -> GetName() <<G4endl
|
|---|
| 245 | << "the source is at the center of the detector" << G4endl
|
|---|
| 246 | << "-------------------------------------------------------------------------"
|
|---|
| 247 | << G4endl;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 | void BrachyDetectorConstruction::SetPhantomMaterial(G4String materialChoice)
|
|---|
| 252 | {
|
|---|
| 253 | // search the material by its name
|
|---|
| 254 | G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
|
|---|
| 255 | if (pttoMaterial)
|
|---|
| 256 | {
|
|---|
| 257 | phantomAbsorberMaterial = pttoMaterial;
|
|---|
| 258 | PhantomLog -> SetMaterial(pttoMaterial);
|
|---|
| 259 | PrintDetectorParameters();
|
|---|
| 260 | }
|
|---|
| 261 | else
|
|---|
| 262 | G4cout << "WARNING: material '" << materialChoice
|
|---|
| 263 | << "' not available!" << G4endl;
|
|---|
| 264 | }
|
|---|