File indexing completed on 2025-04-02 08:02:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 #include "BrachyFactoryLeipzig.hh"
0041 #include "BrachyFactoryTG186.hh"
0042 #include "BrachyFactoryI.hh"
0043 #include "BrachyFactoryFlexi.hh"
0044 #include "BrachyFactoryOncura6711.hh"
0045 #include "BrachyDetectorMessenger.hh"
0046 #include "BrachyDetectorConstruction.hh"
0047 #include "G4SystemOfUnits.hh"
0048 #include "G4CSGSolid.hh"
0049 #include "G4MaterialPropertyVector.hh"
0050 #include "G4SDManager.hh"
0051 #include "G4RunManager.hh"
0052 #include "G4Box.hh"
0053 #include "G4LogicalVolume.hh"
0054 #include "G4ThreeVector.hh"
0055 #include "G4PVPlacement.hh"
0056 #include "globals.hh"
0057 #include "G4MaterialTable.hh"
0058 #include "G4TransportationManager.hh"
0059 #include "G4Colour.hh"
0060 #include "G4UserLimits.hh"
0061 #include "G4VisAttributes.hh"
0062 #include "G4NistManager.hh"
0063
0064 BrachyDetectorConstruction::BrachyDetectorConstruction():
0065 fFactory(nullptr), fWorld(nullptr), fWorldLog(nullptr), fWorldPhys(nullptr),
0066 fPhantom(nullptr), fPhantomLog(nullptr), fPhantomPhys(nullptr),
0067 fDetectorChoice(0)
0068 {
0069
0070 fDetectorMessenger = new BrachyDetectorMessenger(this);
0071
0072
0073 fPhantomSizeX = 15.*cm;
0074 fPhantomSizeY = 15.*cm;
0075 fPhantomSizeZ = 15.*cm;
0076
0077
0078 fWorldSizeX = 4.0*m;
0079 fWorldSizeY = 4.0*m;
0080 fWorldSizeZ = 4.0*m;
0081
0082
0083 fFactory = new BrachyFactoryFlexi();
0084 }
0085
0086 BrachyDetectorConstruction::~BrachyDetectorConstruction()
0087 {
0088 delete fDetectorMessenger;
0089 delete fFactory;
0090 }
0091
0092 G4VPhysicalVolume* BrachyDetectorConstruction::Construct()
0093 {
0094
0095 ConstructPhantom();
0096
0097
0098 fFactory -> CreateSource(fPhantomPhys);
0099
0100 return fWorldPhys;
0101 }
0102
0103 void BrachyDetectorConstruction::SwitchBrachytherapicSeed()
0104 {
0105
0106 fFactory -> CleanSource();
0107 G4cout << "Old brachy source is deleted ..." << G4endl;
0108 delete fFactory;
0109
0110 switch(fDetectorChoice)
0111 {
0112 case 1:
0113 fFactory = new BrachyFactoryI();
0114 break;
0115 case 2:
0116 fFactory = new BrachyFactoryLeipzig();
0117 break;
0118 case 3:
0119 fFactory = new BrachyFactoryTG186();
0120 break;
0121 case 4:
0122 fFactory = new BrachyFactoryFlexi();
0123 break;
0124 case 5:
0125 fFactory = new BrachyFactoryOncura6711();
0126 break;
0127 default:
0128 fFactory = new BrachyFactoryFlexi();
0129 break;
0130 }
0131
0132 fFactory -> CreateSource(fPhantomPhys);
0133 G4cout << "New brachy source is created ..." << G4endl;
0134
0135
0136 G4RunManager::GetRunManager() -> GeometryHasBeenModified();
0137 }
0138
0139 void BrachyDetectorConstruction::SelectBrachytherapicSeed(G4String val)
0140 {
0141 if (val == "Iodine")
0142 fDetectorChoice = 1;
0143 else
0144 {
0145 if(val=="Leipzig")
0146 fDetectorChoice = 2;
0147 else
0148 {
0149 if(val=="TG186")
0150 fDetectorChoice = 3;
0151 else
0152 {
0153 if(val=="Flexi")
0154 fDetectorChoice = 4;
0155 else
0156 {
0157 if(val=="Oncura")
0158 fDetectorChoice = 5;
0159 else
0160 G4cout << val << "is not available!!!!" << G4endl;
0161 }
0162 }
0163 }
0164 }
0165 G4cout << "Now the brachy source is " << val << G4endl;
0166 }
0167
0168 void BrachyDetectorConstruction::ConstructPhantom()
0169 {
0170
0171
0172
0173 G4Colour lblue (0.0, 0.0, .75);
0174
0175
0176 G4NistManager* nist = G4NistManager::Instance();
0177 G4Material* air = nist -> FindOrBuildMaterial("G4_AIR");
0178 G4Material* water = nist -> FindOrBuildMaterial("G4_WATER");
0179
0180
0181 fWorld = new G4Box("World", fWorldSizeX, fWorldSizeY, fWorldSizeZ);
0182 fWorldLog = new G4LogicalVolume(fWorld,air,"WorldLog",nullptr,nullptr,nullptr);
0183 fWorldPhys = new G4PVPlacement(nullptr,G4ThreeVector(),"WorldPhys",fWorldLog,nullptr,false,0);
0184
0185
0186 fPhantom = new G4Box("Phantom", fPhantomSizeX, fPhantomSizeY, fPhantomSizeZ);
0187
0188
0189 fPhantomLog = new G4LogicalVolume(fPhantom,water,"PhantomLog",nullptr,nullptr,nullptr);
0190
0191
0192 fPhantomPhys = new G4PVPlacement(nullptr,G4ThreeVector(),
0193 "PhantomPhys",
0194 fPhantomLog,
0195 fWorldPhys,
0196 false,0);
0197
0198 fWorldLog -> SetVisAttributes (G4VisAttributes::GetInvisible());
0199
0200
0201 auto simpleBoxVisAtt = new G4VisAttributes(lblue);
0202 simpleBoxVisAtt -> SetVisibility(true);
0203 simpleBoxVisAtt -> SetForceWireframe(true);
0204 fPhantomLog -> SetVisAttributes(simpleBoxVisAtt);
0205 }
0206
0207 void BrachyDetectorConstruction::PrintDetectorParameters()
0208 {
0209 G4cout << "----------------" << G4endl
0210 << "the phantom is a water box whose size is: " << G4endl
0211 << fPhantomSizeX *2./cm
0212 << " cm * "
0213 << fPhantomSizeY *2./cm
0214 << " cm * "
0215 << fPhantomSizeZ *2./cm
0216 << " cm" << G4endl
0217 << "The phantom is made of "
0218 << fPhantomLog -> GetMaterial() -> GetName() <<G4endl
0219 << "the source is at the center of the phantom" << G4endl
0220 << "----------------"
0221 << G4endl;
0222 }
0223
0224 void BrachyDetectorConstruction::SetPhantomMaterial(G4String materialChoice)
0225 {
0226
0227
0228 G4NistManager* nist = G4NistManager::Instance();
0229
0230
0231 G4Material* pttoMaterial = nist -> FindOrBuildMaterial(materialChoice);
0232
0233 if (pttoMaterial)
0234 {
0235 fPhantomLog -> SetMaterial(pttoMaterial);
0236 PrintDetectorParameters();
0237 } else G4cout << "WARNING: material '" << materialChoice << "' not available!" << G4endl;
0238 }