Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // This is the *BASIC* version of Hadrontherap 26 // This is the *BASIC* version of Hadrontherapy, a Geant4-based application 27 // See more at: http://g4advancedexamples.lngs 27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy 28 // 28 // 29 // Visit the Hadrontherapy web site (http://ww 29 // Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request 30 // the *COMPLETE* version of this program, tog 30 // the *COMPLETE* version of this program, together with its documentation; 31 // Hadrontherapy (both basic and full version) 31 // Hadrontherapy (both basic and full version) are supported by the Italian INFN 32 // Institute in the framework of the MC-INFN G 32 // Institute in the framework of the MC-INFN Group 33 // 33 // 34 34 35 #include <fstream> 35 #include <fstream> 36 36 37 #include "globals.hh" 37 #include "globals.hh" 38 #include "G4SystemOfUnits.hh" 38 #include "G4SystemOfUnits.hh" 39 #include "G4Material.hh" 39 #include "G4Material.hh" 40 #include "G4Tubs.hh" 40 #include "G4Tubs.hh" 41 #include "G4Box.hh" 41 #include "G4Box.hh" 42 #include "G4LogicalVolume.hh" 42 #include "G4LogicalVolume.hh" 43 #include "G4VPhysicalVolume.hh" 43 #include "G4VPhysicalVolume.hh" 44 #include "G4ThreeVector.hh" 44 #include "G4ThreeVector.hh" 45 #include "G4PVPlacement.hh" 45 #include "G4PVPlacement.hh" 46 #include "G4Transform3D.hh" 46 #include "G4Transform3D.hh" 47 #include "G4RotationMatrix.hh" 47 #include "G4RotationMatrix.hh" 48 #include "G4VisAttributes.hh" 48 #include "G4VisAttributes.hh" 49 #include "G4Colour.hh" 49 #include "G4Colour.hh" 50 #include "HadrontherapyModulator.hh" 50 #include "HadrontherapyModulator.hh" 51 #include "G4Transform3D.hh" 51 #include "G4Transform3D.hh" 52 #include "G4ios.hh" 52 #include "G4ios.hh" 53 #include "G4RunManager.hh" 53 #include "G4RunManager.hh" 54 #include "G4NistManager.hh" 54 #include "G4NistManager.hh" 55 #include <iostream> 55 #include <iostream> 56 56 >> 57 using namespace std; >> 58 57 HadrontherapyModulator::HadrontherapyModulator 59 HadrontherapyModulator::HadrontherapyModulator(): physiMotherMod(0), 58 solidMod1(0), logicMod1(0 60 solidMod1(0), logicMod1(0), physiMod1(0), 59 solidMod2(0), logicMod2(0 61 solidMod2(0), logicMod2(0), physiMod2(0), 60 solidMod3(0), logicMod3(0 62 solidMod3(0), logicMod3(0), physiMod3(0), 61 solidMod4(0), logicMod4(0 63 solidMod4(0), logicMod4(0), physiMod4(0), 62 FileName("Modulators/Modulator010 64 FileName("Modulators/Modulator010.txt") 63 { 65 { 64 pi=4*std::atan(1.); << 66 pi=4*atan(1.); 65 StepNumbers=22; 67 StepNumbers=22; 66 Weight=new G4double[StepNumbers]; 68 Weight=new G4double[StepNumbers]; 67 StepThickness=new G4double[StepNumbers]; 69 StepThickness=new G4double[StepNumbers]; 68 StartingAngle=new G4double[StepNumbers]; 70 StartingAngle=new G4double[StepNumbers]; 69 SpanningAngle=new G4double[StepNumbers]; 71 SpanningAngle=new G4double[StepNumbers]; 70 PositionMod=new G4ThreeVector[StepNumbers]; 72 PositionMod=new G4ThreeVector[StepNumbers]; 71 73 72 74 73 solidMod=new G4Tubs *[StepNumbers]; 75 solidMod=new G4Tubs *[StepNumbers]; 74 logicMod=new G4LogicalVolume *[StepNumbers] 76 logicMod=new G4LogicalVolume *[StepNumbers]; 75 physiMod=new G4VPhysicalVolume *[(4*(StepNu 77 physiMod=new G4VPhysicalVolume *[(4*(StepNumbers-1)+1)]; 76 78 77 for (G4int i=0;i<StepNumbers;i++) 79 for (G4int i=0;i<StepNumbers;i++) 78 { 80 { 79 Weight[i]=0; 81 Weight[i]=0; 80 StepThickness[i]=0; 82 StepThickness[i]=0; 81 StartingAngle[i]=0; 83 StartingAngle[i]=0; 82 SpanningAngle[i]=0; 84 SpanningAngle[i]=0; 83 PositionMod[i]=G4ThreeVector(0,0,0); 85 PositionMod[i]=G4ThreeVector(0,0,0); 84 solidMod[i]=0; 86 solidMod[i]=0; 85 logicMod[i]=0; 87 logicMod[i]=0; 86 88 87 } 89 } 88 90 89 for (G4int i=0;i<4*(StepNumbers-1)+1;i++) 91 for (G4int i=0;i<4*(StepNumbers-1)+1;i++) 90 { 92 { 91 physiMod[i]=0; 93 physiMod[i]=0; 92 } 94 } 93 95 94 96 95 ModulatorMessenger = new HadrontherapyModul 97 ModulatorMessenger = new HadrontherapyModulatorMessenger(this); 96 ModulatorDefaultProperties(); 98 ModulatorDefaultProperties(); 97 rm = new G4RotationMatrix(); 99 rm = new G4RotationMatrix(); 98 G4double phi = 270. *deg; 100 G4double phi = 270. *deg; 99 rm -> rotateY(phi); 101 rm -> rotateY(phi); 100 } 102 } 101 ////////////////////////////////////////////// 103 ///////////////////////////////////////////////////////////////////////////// 102 HadrontherapyModulator::~HadrontherapyModulato 104 HadrontherapyModulator::~HadrontherapyModulator() 103 { 105 { 104 delete rm; 106 delete rm; 105 delete [] Weight; 107 delete [] Weight; 106 delete [] StepThickness; 108 delete [] StepThickness; 107 delete [] StartingAngle; 109 delete [] StartingAngle; 108 delete [] SpanningAngle; 110 delete [] SpanningAngle; 109 delete [] PositionMod; 111 delete [] PositionMod; 110 delete [] solidMod; 112 delete [] solidMod; 111 delete [] logicMod; 113 delete [] logicMod; 112 delete [] physiMod; 114 delete [] physiMod; 113 delete ModulatorMessenger; 115 delete ModulatorMessenger; 114 } 116 } 115 117 116 ////////////////////////////////////////////// 118 ///////////////////////////////////////////////////////////////////////////// 117 void HadrontherapyModulator::ModulatorDefaultP 119 void HadrontherapyModulator::ModulatorDefaultProperties() 118 { 120 { 119 /* Here we initialize the step properties of M 121 /* Here we initialize the step properties of Modulator wheel, you can create your 120 specific modulator by changing the values in t 122 specific modulator by changing the values in this class or writing them in an external 121 file and activate reading from file via a macr 123 file and activate reading from file via a macrofile. */ 122 124 123 StepThickness[0]=0; Weight[0]=.14445; 125 StepThickness[0]=0; Weight[0]=.14445; 124 StepThickness[1]=.8; Weight[1]=.05665; 126 StepThickness[1]=.8; Weight[1]=.05665; 125 StepThickness[2]=1.6; Weight[2]=.05049; 127 StepThickness[2]=1.6; Weight[2]=.05049; 126 StepThickness[3]=2.4; Weight[3]=.04239; 128 StepThickness[3]=2.4; Weight[3]=.04239; 127 StepThickness[4]=3.2; Weight[4]=.04313; 129 StepThickness[4]=3.2; Weight[4]=.04313; 128 StepThickness[5]=4.0; Weight[5]=.03879; 130 StepThickness[5]=4.0; Weight[5]=.03879; 129 StepThickness[6]=4.8; Weight[6]=.04182; 131 StepThickness[6]=4.8; Weight[6]=.04182; 130 StepThickness[7]=5.6; Weight[7]=.03422; 132 StepThickness[7]=5.6; Weight[7]=.03422; 131 StepThickness[8]=6.4; Weight[8]=.03469; 133 StepThickness[8]=6.4; Weight[8]=.03469; 132 StepThickness[9]=7.2; Weight[9]=.03589; 134 StepThickness[9]=7.2; Weight[9]=.03589; 133 StepThickness[10]=8.0; Weight[10]=.03633; 135 StepThickness[10]=8.0; Weight[10]=.03633; 134 StepThickness[11]=8.8; Weight[11]=.03842; 136 StepThickness[11]=8.8; Weight[11]=.03842; 135 StepThickness[12]=9.6; Weight[12]=.03688; 137 StepThickness[12]=9.6; Weight[12]=.03688; 136 StepThickness[13]=10.4; Weight[13]=.03705; 138 StepThickness[13]=10.4; Weight[13]=.03705; 137 StepThickness[14]=11.2; Weight[14]=.03773; 139 StepThickness[14]=11.2; Weight[14]=.03773; 138 StepThickness[15]=12.0; Weight[15]=.03968; 140 StepThickness[15]=12.0; Weight[15]=.03968; 139 StepThickness[16]=12.8; Weight[16]=.04058; 141 StepThickness[16]=12.8; Weight[16]=.04058; 140 StepThickness[17]=13.6; Weight[17]=.03903; 142 StepThickness[17]=13.6; Weight[17]=.03903; 141 StepThickness[18]=14.4; Weight[18]=.04370; 143 StepThickness[18]=14.4; Weight[18]=.04370; 142 StepThickness[19]=15.2; Weight[19]=.03981; 144 StepThickness[19]=15.2; Weight[19]=.03981; 143 StepThickness[20]=16.0; Weight[20]=.05226; 145 StepThickness[20]=16.0; Weight[20]=.05226; 144 StepThickness[21]=16.8; Weight[21]=.03603; 146 StepThickness[21]=16.8; Weight[21]=.03603; 145 GetStepInformation(); 147 GetStepInformation(); 146 148 147 } 149 } 148 ////////////////////////////////////////////// 150 ///////////////////////////////////////////////////////////////////////////// 149 void HadrontherapyModulator:: ModulatorPropert 151 void HadrontherapyModulator:: ModulatorPropertiesFromFile(G4String Name) 150 { 152 { 151 delete [] Weight; 153 delete [] Weight; 152 delete [] StepThickness; 154 delete [] StepThickness; 153 delete [] StartingAngle; 155 delete [] StartingAngle; 154 delete [] SpanningAngle; 156 delete [] SpanningAngle; 155 delete [] PositionMod; 157 delete [] PositionMod; 156 delete [] solidMod; 158 delete [] solidMod; 157 delete [] logicMod; 159 delete [] logicMod; 158 delete [] physiMod; 160 delete [] physiMod; 159 delete solidMod1; 161 delete solidMod1; 160 delete logicMod1; 162 delete logicMod1; 161 delete physiMod1; 163 delete physiMod1; 162 delete solidMod2; 164 delete solidMod2; 163 delete logicMod2; 165 delete logicMod2; 164 delete physiMod2; 166 delete physiMod2; 165 delete solidMod3; 167 delete solidMod3; 166 delete logicMod3; 168 delete logicMod3; 167 delete physiMod3; 169 delete physiMod3; 168 delete solidMod4; 170 delete solidMod4; 169 delete logicMod4; 171 delete logicMod4; 170 delete physiMod4; 172 delete physiMod4; 171 // The Modulator wheel properties is getting f 173 // The Modulator wheel properties is getting form an external file "ModoulWeight.txt" 172 File.open(Name, std::ios::in); 174 File.open(Name, std::ios::in); 173 if(!File.is_open()) 175 if(!File.is_open()) 174 { 176 { 175 G4cout<<" WARNING: The File with name of "<< 177 G4cout<<" WARNING: The File with name of "<<Name<< 176 " doesn't exist to get modulator step propert 178 " doesn't exist to get modulator step properties. please modify it and try again"<<G4endl; 177 179 178 G4Exception("HadrontherapyModulator::Modulato 180 G4Exception("HadrontherapyModulator::ModulatorPropertiesFromFile( )", "Hadrontherapy0009" 179 , FatalException, "Error: No available extern 181 , FatalException, "Error: No available external file for reading from"); 180 } 182 } 181 183 182 G4String string; 184 G4String string; 183 File >>string>> StepNumbers; 185 File >>string>> StepNumbers; 184 File >>string>>string>>string; 186 File >>string>>string>>string; 185 187 186 188 187 Weight=new G4double[StepNumbers]; 189 Weight=new G4double[StepNumbers]; 188 StepThickness=new G4double[StepNumbers]; 190 StepThickness=new G4double[StepNumbers]; 189 StartingAngle=new G4double[StepNumbers]; 191 StartingAngle=new G4double[StepNumbers]; 190 SpanningAngle=new G4double[StepNumbers]; 192 SpanningAngle=new G4double[StepNumbers]; 191 PositionMod=new G4ThreeVector[StepNumbers]; 193 PositionMod=new G4ThreeVector[StepNumbers]; 192 194 193 195 194 solidMod=new G4Tubs *[StepNumbers]; 196 solidMod=new G4Tubs *[StepNumbers]; 195 logicMod=new G4LogicalVolume *[StepNumbers] 197 logicMod=new G4LogicalVolume *[StepNumbers]; 196 physiMod=new G4VPhysicalVolume *[(4*(StepNu 198 physiMod=new G4VPhysicalVolume *[(4*(StepNumbers-1)+1)]; 197 199 198 for(G4int i=0;i<StepNumbers;i++) 200 for(G4int i=0;i<StepNumbers;i++) 199 { 201 { 200 G4String stringX; 202 G4String stringX; 201 File>>stringX>> StepThickness[i]>>Weight[i] 203 File>>stringX>> StepThickness[i]>>Weight[i]; 202 } 204 } 203 205 204 GetStepInformation(); 206 GetStepInformation(); 205 BuildSteps(); 207 BuildSteps(); 206 208 207 209 208 210 209 } 211 } 210 ////////////////////////////////////////////// 212 //////////////////////////////////////////////////////////////////////////////// 211 void HadrontherapyModulator::GetStepInformatio 213 void HadrontherapyModulator::GetStepInformation() 212 { 214 { 213 215 214 G4double TotalWeight=0; 216 G4double TotalWeight=0; 215 // convert the absolute weight values to rela 217 // convert the absolute weight values to relative ones 216 for(G4int i=0;i<StepNumbers;i++) 218 for(G4int i=0;i<StepNumbers;i++) 217 { 219 { 218 TotalWeight+=Weight[i]; 220 TotalWeight+=Weight[i]; 219 } 221 } 220 222 221 for(G4int i=0;i<StepNumbers;i++) 223 for(G4int i=0;i<StepNumbers;i++) 222 { 224 { 223 Weight[i]=Weight[i]/TotalWeight; 225 Weight[i]=Weight[i]/TotalWeight; 224 } 226 } 225 227 226 // To build the RMW step layers will be put o 228 // To build the RMW step layers will be put one after another 227 229 228 StartingAngle[0]=0 *deg; 230 StartingAngle[0]=0 *deg; 229 SpanningAngle[0]=90 *deg; 231 SpanningAngle[0]=90 *deg; 230 G4double PositionModx; 232 G4double PositionModx; 231 G4double WholeStartingAngle=0 *deg; 233 G4double WholeStartingAngle=0 *deg; 232 G4double WholeThickness=0; 234 G4double WholeThickness=0; 233 for(G4int i=1;i<StepNumbers;i++) 235 for(G4int i=1;i<StepNumbers;i++) 234 { 236 { 235 StartingAngle[i]=WholeStartingAngle+(Weigh 237 StartingAngle[i]=WholeStartingAngle+(Weight[i-1]*(2*pi))/8; 236 SpanningAngle[i]=90* deg -2*StartingAngle[ 238 SpanningAngle[i]=90* deg -2*StartingAngle[i]; 237 StepThickness[i]=StepThickness[i]-WholeThi 239 StepThickness[i]=StepThickness[i]-WholeThickness; 238 PositionModx=WholeThickness+StepThickness[ 240 PositionModx=WholeThickness+StepThickness[i]/2.; 239 PositionMod[i]=G4ThreeVector(0,0,PositionM 241 PositionMod[i]=G4ThreeVector(0,0,PositionModx); 240 WholeThickness+=StepThickness[i]; 242 WholeThickness+=StepThickness[i]; 241 WholeStartingAngle=StartingAngle[i]; 243 WholeStartingAngle=StartingAngle[i]; 242 } 244 } 243 245 244 246 245 } 247 } 246 ////////////////////////////////////////////// 248 ///////////////////////////////////////////////////////////////////////////////// 247 void HadrontherapyModulator::BuildModulator(G4 249 void HadrontherapyModulator::BuildModulator(G4VPhysicalVolume* motherVolume) 248 { 250 { 249 G4bool isotopes = false; 251 G4bool isotopes = false; 250 G4Material* airNist = G4NistManager::Instan 252 G4Material* airNist = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR", isotopes); 251 253 252 254 253 Mod0Mater = airNist; 255 Mod0Mater = airNist; 254 ModMater = airNist; // You have to change m 256 ModMater = airNist; // You have to change modulator material via a macrofile (default is air) 255 257 256 innerRadiusOfTheTube = 2.5 *cm; 258 innerRadiusOfTheTube = 2.5 *cm; 257 outerRadiusOfTheTube = 9.5 *cm; 259 outerRadiusOfTheTube = 9.5 *cm; 258 260 259 // Mother of the modulator wheel 261 // Mother of the modulator wheel 260 G4ThreeVector positionMotherMod = G4ThreeVec 262 G4ThreeVector positionMotherMod = G4ThreeVector(-2160.50 *mm, 30 *mm, 50 *mm); 261 263 262 G4Box* solidMotherMod = new G4Box("MotherMod 264 G4Box* solidMotherMod = new G4Box("MotherMod", 12 *cm, 12 *cm, 12 *cm); 263 265 264 logicMotherMod = new G4LogicalVolume(solidMo 266 logicMotherMod = new G4LogicalVolume(solidMotherMod, Mod0Mater,"MotherMod",0,0,0); 265 267 266 physiMotherMod = new G4PVPlacement(rm,positi 268 physiMotherMod = new G4PVPlacement(rm,positionMotherMod, "MotherMod", 267 logicMotherMod, 269 logicMotherMod, 268 motherVolume, 270 motherVolume, 269 false, 271 false, 270 0); 272 0); 271 BuildSteps(); 273 BuildSteps(); 272 274 273 275 274 276 275 } 277 } 276 ///////////////////////////////////////////// 278 /////////////////////////////////////////////////////////////////////////////////////// 277 void HadrontherapyModulator::BuildSteps() 279 void HadrontherapyModulator::BuildSteps() 278 { 280 { 279 //------------------------------------------ 281 //---------------------------------------------------------- 280 // Mother volume of first quarter of the mod 282 // Mother volume of first quarter of the modulator 281 //------------------------------------------ 283 //---------------------------------------------------------- 282 284 283 G4double hightOfTheTube0 = 10.0 *cm; 285 G4double hightOfTheTube0 = 10.0 *cm; 284 G4double startAngleOfTheTube0 = 0 *deg; 286 G4double startAngleOfTheTube0 = 0 *deg; 285 G4double spanningAngleOfTheTube0 = 90 *deg; 287 G4double spanningAngleOfTheTube0 = 90 *deg; 286 288 287 G4RotationMatrix rm1; 289 G4RotationMatrix rm1; 288 rm1.rotateZ(0 *deg); 290 rm1.rotateZ(0 *deg); 289 291 290 G4ThreeVector positionMod1 = G4ThreeVector(0 292 G4ThreeVector positionMod1 = G4ThreeVector(0*cm,0*cm,0*cm); 291 293 292 solidMod1 = new G4Tubs("Mod1", 294 solidMod1 = new G4Tubs("Mod1", 293 innerRadiusOfTheTube, 295 innerRadiusOfTheTube, 294 outerRadiusOfTheTube, 296 outerRadiusOfTheTube, 295 hightOfTheTube0/2., 297 hightOfTheTube0/2., 296 startAngleOfTheTube0, 298 startAngleOfTheTube0, 297 spanningAngleOfTheTube0); 299 spanningAngleOfTheTube0); 298 300 299 logicMod1 = new G4LogicalVolume(solidMod1, M 301 logicMod1 = new G4LogicalVolume(solidMod1, Mod0Mater, "Mod1",0,0,0); 300 302 301 physiMod1 = new G4PVPlacement(G4Transform3D( 303 physiMod1 = new G4PVPlacement(G4Transform3D(rm1, positionMod1), 302 logicMod1, 304 logicMod1, 303 "Mod1", 305 "Mod1", 304 logicMotherMod, 306 logicMotherMod, 305 false, 307 false, 306 0); 308 0); 307 309 308 310 309 //------------------------------------------ 311 //---------------------------------------------------------- 310 // modulator steps 312 // modulator steps 311 //------------------------------------------ 313 //---------------------------------------------------------- 312 for (G4int i=1;i<StepNumbers;i++) 314 for (G4int i=1;i<StepNumbers;i++) 313 { 315 { 314 316 315 solidMod[i] = new G4Tubs("Modstep", 317 solidMod[i] = new G4Tubs("Modstep", 316 innerRadiusOfTheTube, 318 innerRadiusOfTheTube, 317 outerRadiusOfTheTube, 319 outerRadiusOfTheTube, 318 StepThickness[i]/2., 320 StepThickness[i]/2., 319 StartingAngle[i], 321 StartingAngle[i], 320 SpanningAngle[i]); 322 SpanningAngle[i]); 321 323 322 logicMod[i] = new G4LogicalVolume(solidMod[i 324 logicMod[i] = new G4LogicalVolume(solidMod[i], 323 ModMater, " 325 ModMater, "Modstep",0,0,0); 324 326 325 physiMod[i] = new G4PVPlacement(0, 327 physiMod[i] = new G4PVPlacement(0, 326 PositionMod[i], 328 PositionMod[i], 327 logicMod[i], 329 logicMod[i], 328 "Modstep", 330 "Modstep", 329 logicMod1, 331 logicMod1, 330 false, 332 false, 331 0); 333 0); 332 334 333 335 334 } 336 } 335 337 336 ///////////////////////////////////////////// 338 ///////////////////////////////////////////////////////////////////////////////////////////////// 337 //------------------------------------------ 339 //---------------------------------------------------------- 338 // Mother volume of the second modulator qua 340 // Mother volume of the second modulator quarter 339 //------------------------------------------ 341 //---------------------------------------------------------- 340 342 341 343 342 G4RotationMatrix rm2; 344 G4RotationMatrix rm2; 343 rm2.rotateZ(90 *deg); 345 rm2.rotateZ(90 *deg); 344 346 345 G4ThreeVector positionMod2 = G4ThreeVector(0 347 G4ThreeVector positionMod2 = G4ThreeVector(0*cm,0*cm,0*cm); 346 348 347 solidMod2 = new G4Tubs("Mod2", 349 solidMod2 = new G4Tubs("Mod2", 348 innerRadiusOfTheTube, 350 innerRadiusOfTheTube, 349 outerRadiusOfTheTube, 351 outerRadiusOfTheTube, 350 hightOfTheTube0/2., 352 hightOfTheTube0/2., 351 startAngleOfTheTube0, 353 startAngleOfTheTube0, 352 spanningAngleOfTheTube0); 354 spanningAngleOfTheTube0); 353 355 354 logicMod2 = new G4LogicalVolume(solidMod2, 356 logicMod2 = new G4LogicalVolume(solidMod2, 355 Mod0Mater, " 357 Mod0Mater, "Mod2",0,0,0); 356 358 357 359 358 physiMod2 = new G4PVPlacement(G4Transform3D( 360 physiMod2 = new G4PVPlacement(G4Transform3D(rm2, positionMod2), 359 logicMod2, 361 logicMod2, 360 "Mod2", 362 "Mod2", 361 logicMotherMod, 363 logicMotherMod, 362 false, 364 false, 363 0); 365 0); 364 366 365 367 366 for (G4int i=1;i<StepNumbers;i++) 368 for (G4int i=1;i<StepNumbers;i++) 367 { 369 { 368 370 369 physiMod[StepNumbers+i-1] = new G4PVPlacemen 371 physiMod[StepNumbers+i-1] = new G4PVPlacement(0, 370 PositionMod[i], 372 PositionMod[i], 371 logicMod[i], 373 logicMod[i], 372 "Modstep", 374 "Modstep", 373 logicMod2, 375 logicMod2, 374 false, 376 false, 375 0); 377 0); 376 378 377 } 379 } 378 380 379 381 380 382 381 //------------------------------------------ 383 //---------------------------------------------------------- 382 // Mother volume of the third modulator quar 384 // Mother volume of the third modulator quarter 383 //------------------------------------------ 385 //---------------------------------------------------------- 384 386 385 387 386 G4RotationMatrix rm3; 388 G4RotationMatrix rm3; 387 rm3.rotateZ(180 *deg); 389 rm3.rotateZ(180 *deg); 388 390 389 G4ThreeVector positionMod3 = G4ThreeVector(0 391 G4ThreeVector positionMod3 = G4ThreeVector(0*cm,0*cm,0*cm); 390 392 391 solidMod3 = new G4Tubs("Mod3", 393 solidMod3 = new G4Tubs("Mod3", 392 innerRadiusOfTheTube, 394 innerRadiusOfTheTube, 393 outerRadiusOfTheTube, 395 outerRadiusOfTheTube, 394 hightOfTheTube0, 396 hightOfTheTube0, 395 startAngleOfTheTube0/2., 397 startAngleOfTheTube0/2., 396 spanningAngleOfTheTube0); 398 spanningAngleOfTheTube0); 397 399 398 logicMod3 = new G4LogicalVolume(solidMod3, 400 logicMod3 = new G4LogicalVolume(solidMod3, 399 Mod0Mater, " 401 Mod0Mater, "Mod3",0,0,0); 400 402 401 403 402 physiMod3 = new G4PVPlacement(G4Transform3D( 404 physiMod3 = new G4PVPlacement(G4Transform3D(rm3, positionMod3), 403 logicMod3, // its logical volume 405 logicMod3, // its logical volume 404 "Mod3", // its name 406 "Mod3", // its name 405 logicMotherMod, // its mother volum 407 logicMotherMod, // its mother volume 406 false, // no boolean operatio 408 false, // no boolean operations 407 0); // no particular field 409 0); // no particular field 408 410 409 411 410 412 411 413 412 for (G4int i=1;i<StepNumbers;i++) 414 for (G4int i=1;i<StepNumbers;i++) 413 { 415 { 414 416 415 physiMod[2*(StepNumbers-1)+i] = new G4PVPlac 417 physiMod[2*(StepNumbers-1)+i] = new G4PVPlacement(0, 416 PositionMod[i], 418 PositionMod[i], 417 logicMod[i], 419 logicMod[i], 418 "Modstep", 420 "Modstep", 419 logicMod3, 421 logicMod3, 420 false, 422 false, 421 0); 423 0); 422 424 423 } 425 } 424 426 425 //------------------------------------------ 427 //---------------------------------------------------------- 426 // Mother volume of the fourth modulator qua 428 // Mother volume of the fourth modulator quarter 427 //------------------------------------------ 429 //---------------------------------------------------------- 428 430 429 431 430 G4RotationMatrix rm4; 432 G4RotationMatrix rm4; 431 rm4.rotateZ(270 *deg); 433 rm4.rotateZ(270 *deg); 432 434 433 G4ThreeVector positionMod4 = G4ThreeVector(0 435 G4ThreeVector positionMod4 = G4ThreeVector(0*cm,0*cm,0*cm); 434 436 435 solidMod4 = new G4Tubs("Mod4", 437 solidMod4 = new G4Tubs("Mod4", 436 innerRadiusOfTheTube, 438 innerRadiusOfTheTube, 437 outerRadiusOfTheTube, 439 outerRadiusOfTheTube, 438 hightOfTheTube0, 440 hightOfTheTube0, 439 startAngleOfTheTube0/2., 441 startAngleOfTheTube0/2., 440 spanningAngleOfTheTube0); 442 spanningAngleOfTheTube0); 441 443 442 logicMod4 = new G4LogicalVolume(solidMod4, 444 logicMod4 = new G4LogicalVolume(solidMod4, 443 Mod0Mater, " 445 Mod0Mater, "Mod4",0,0,0); 444 446 445 447 446 physiMod4 = new G4PVPlacement(G4Transform3D( 448 physiMod4 = new G4PVPlacement(G4Transform3D(rm4, positionMod4), 447 logicMod4, 449 logicMod4, 448 "Mod4", 450 "Mod4", 449 logicMotherMod, 451 logicMotherMod, 450 false, 452 false, 451 0); 453 0); 452 454 453 455 454 for (G4int i=1;i<StepNumbers;i++) 456 for (G4int i=1;i<StepNumbers;i++) 455 { 457 { 456 physiMod[3*(StepNumbers-1)+i] = new G4PVPlac 458 physiMod[3*(StepNumbers-1)+i] = new G4PVPlacement(0, 457 PositionMod[i], 459 PositionMod[i], 458 logicMod[i], 460 logicMod[i], 459 "Modstep", 461 "Modstep", 460 logicMod4, 462 logicMod4, 461 false, 463 false, 462 0); 464 0); 463 } 465 } 464 // Inform the kernel about the new geometry 466 // Inform the kernel about the new geometry 465 G4RunManager::GetRunManager() -> GeometryH 467 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 466 G4RunManager::GetRunManager() -> PhysicsHa 468 G4RunManager::GetRunManager() -> PhysicsHasBeenModified(); 467 G4VisAttributes * red = new G4VisAttributes( 469 G4VisAttributes * red = new G4VisAttributes( G4Colour(1. ,0. ,0.)); 468 red-> SetVisibility(true); 470 red-> SetVisibility(true); 469 red-> SetForceSolid(true); 471 red-> SetForceSolid(true); 470 logicMotherMod -> SetVisAttributes(G4VisAttr 472 logicMotherMod -> SetVisAttributes(G4VisAttributes::GetInvisible()); 471 473 472 logicMod1 ->SetVisAttributes(G4VisAttributes 474 logicMod1 ->SetVisAttributes(G4VisAttributes::GetInvisible()); 473 logicMod2 ->SetVisAttributes(G4VisAttributes 475 logicMod2 ->SetVisAttributes(G4VisAttributes::GetInvisible()); 474 logicMod3 ->SetVisAttributes(G4VisAttributes 476 logicMod3 ->SetVisAttributes(G4VisAttributes::GetInvisible()); 475 logicMod4 ->SetVisAttributes(G4VisAttributes 477 logicMod4 ->SetVisAttributes(G4VisAttributes::GetInvisible()); 476 478 477 for (G4int i=1;i<StepNumbers;i++) 479 for (G4int i=1;i<StepNumbers;i++) 478 { 480 { 479 logicMod[i] -> SetVisAttributes(red); 481 logicMod[i] -> SetVisAttributes(red); 480 } 482 } 481 483 482 } 484 } 483 485 484 ////////////////////////////////////////////// 486 ///////////////////////////////////////////////////////////////////////////// 485 // Messenger values 487 // Messenger values 486 ////////////////////////////////////////////// 488 ///////////////////////////////////////////////////////////////////////////// 487 void HadrontherapyModulator::SetModulatorAngle 489 void HadrontherapyModulator::SetModulatorAngle(G4double angle) 488 { 490 { 489 G4double rotationAngle = angle; 491 G4double rotationAngle = angle; 490 rm -> rotateZ(rotationAngle); 492 rm -> rotateZ(rotationAngle); 491 physiMotherMod -> SetRotation(rm); 493 physiMotherMod -> SetRotation(rm); 492 G4cout << "MODULATOR HAS BEEN ROTATED OF " < 494 G4cout << "MODULATOR HAS BEEN ROTATED OF " << rotationAngle/deg 493 << " deg" << G4endl; 495 << " deg" << G4endl; 494 G4RunManager::GetRunManager() -> GeometryHas 496 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 495 } 497 } 496 ////////////////////////////////////////////// 498 ///////////////////////////////////////////////////////////////////////// 497 // Change modulator material 499 // Change modulator material 498 void HadrontherapyModulator::SetModulatorMater 500 void HadrontherapyModulator::SetModulatorMaterial(G4String Material) 499 { 501 { 500 if (G4Material* NewMaterial = G4NistManage 502 if (G4Material* NewMaterial = G4NistManager::Instance()->FindOrBuildMaterial(Material, false) ) 501 { 503 { 502 if (NewMaterial) 504 if (NewMaterial) 503 { 505 { 504 for(G4int i=1;i<StepNumbers;i++) 506 for(G4int i=1;i<StepNumbers;i++) 505 { 507 { 506 logicMod[i] -> SetMaterial(NewMaterial); 508 logicMod[i] -> SetMaterial(NewMaterial); 507 // G4RunManager::GetRunManager() -> Physi 509 // G4RunManager::GetRunManager() -> PhysicsHasBeenModified(); 508 G4RunManager::GetRunManager() -> Geometr 510 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 509 511 510 // G4cout<<(logicMod[i]->GetMaterial()->G 512 // G4cout<<(logicMod[i]->GetMaterial()->GetName())<<G4endl; 511 } 513 } 512 G4cout << "The material of the Modulator whe 514 G4cout << "The material of the Modulator wheel has been changed to " << Material << G4endl; 513 } 515 } 514 } 516 } 515 else 517 else 516 { 518 { 517 G4cout << "WARNING: material \"" << Material 519 G4cout << "WARNING: material \"" << Material << "\" doesn't exist in NIST elements/materials" 518 " table [located in $G4INSTALL/source/ma 520 " table [located in $G4INSTALL/source/materials/src/G4NistMaterialBuilder.cc]" << G4endl; 519 G4cout << "Use command \"/parameter/nist\" t 521 G4cout << "Use command \"/parameter/nist\" to see full materials list!" << G4endl; 520 522 521 523 522 } 524 } 523 } 525 } 524 526 525 ////////////////////////////////////////////// 527 //////////////////////////////////////////////////////////////////////////////// 526 // Change modulator position in the beam line 528 // Change modulator position in the beam line 527 void HadrontherapyModulator::SetModulatorPosit 529 void HadrontherapyModulator::SetModulatorPosition(G4ThreeVector Pos) 528 { 530 { 529 G4ThreeVector NewModulatorPos=Pos; 531 G4ThreeVector NewModulatorPos=Pos; 530 physiMotherMod -> SetTranslation( NewModulat 532 physiMotherMod -> SetTranslation( NewModulatorPos); 531 G4RunManager::GetRunManager() -> GeometryHas 533 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 532 G4cout << "The modulator wheel is translated 534 G4cout << "The modulator wheel is translated to"<< NewModulatorPos/mm <<"mm " <<G4endl; 533 535 534 } 536 } 535 ////////////////////////////////////////////// 537 ///////////////////////////////////////////////////////////////////////////////// 536 //change modulator inner raduis 538 //change modulator inner raduis 537 void HadrontherapyModulator::SetModulatorInner 539 void HadrontherapyModulator::SetModulatorInnerRadius(G4double newvalue) 538 { 540 { 539 solidMod1 -> SetInnerRadius(newvalue); 541 solidMod1 -> SetInnerRadius(newvalue); 540 solidMod2 -> SetInnerRadius(newvalue); 542 solidMod2 -> SetInnerRadius(newvalue); 541 solidMod3 -> SetInnerRadius(newvalue); 543 solidMod3 -> SetInnerRadius(newvalue); 542 solidMod4 -> SetInnerRadius(newvalue); 544 solidMod4 -> SetInnerRadius(newvalue); 543 for(G4int i=1;i<StepNumbers;i++) 545 for(G4int i=1;i<StepNumbers;i++) 544 { 546 { 545 solidMod[i] -> SetInnerRadius(newvalue);} 547 solidMod[i] -> SetInnerRadius(newvalue);} 546 G4RunManager::GetRunManager() -> GeometryHa 548 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 547 G4cout << "InnerRadius of the Modulator Whee 549 G4cout << "InnerRadius of the Modulator Wheel has been changed to :" 548 << newvalue/mm<<" mm"<< G4endl; 550 << newvalue/mm<<" mm"<< G4endl; 549 } 551 } 550 ////////////////////////////////////////////// 552 ///////////////////////////////////////////////////////////////////////////////// 551 //change modulator outer raduis 553 //change modulator outer raduis 552 void HadrontherapyModulator::SetModulatorOuter 554 void HadrontherapyModulator::SetModulatorOuterRadius(G4double newvalue) 553 { 555 { 554 solidMod1 -> SetOuterRadius(newvalue); 556 solidMod1 -> SetOuterRadius(newvalue); 555 solidMod2 -> SetOuterRadius(newvalue); 557 solidMod2 -> SetOuterRadius(newvalue); 556 solidMod3 -> SetOuterRadius(newvalue); 558 solidMod3 -> SetOuterRadius(newvalue); 557 solidMod4 -> SetOuterRadius(newvalue); 559 solidMod4 -> SetOuterRadius(newvalue); 558 for(G4int i=1;i<StepNumbers;i++) 560 for(G4int i=1;i<StepNumbers;i++) 559 { 561 { 560 solidMod[i] -> SetOuterRadius(newvalue);} 562 solidMod[i] -> SetOuterRadius(newvalue);} 561 G4RunManager::GetRunManager() -> GeometryHa 563 G4RunManager::GetRunManager() -> GeometryHasBeenModified(); 562 G4cout << "OuterRadius of the Modulator Whee 564 G4cout << "OuterRadius of the Modulator Wheel has been changed to :" 563 << newvalue/mm<<" mm"<<G4endl; 565 << newvalue/mm<<" mm"<<G4endl; 564 } 566 } 565 ////////////////////////////////////////////// 567 ///////////////////////////////////////////////////////////////////////////////// 566 void HadrontherapyModulator:: GetDataFromFile( 568 void HadrontherapyModulator:: GetDataFromFile(G4String value) 567 569 568 { 570 { 569 G4String Name=value; 571 G4String Name=value; 570 if(value=="default" ) 572 if(value=="default" ) 571 { 573 { 572 Name=FileName; 574 Name=FileName; 573 } 575 } 574 G4cout<<" Step properties of modulator will be 576 G4cout<<" Step properties of modulator will be get out from the external file " 575 <<Name<<G4endl; 577 <<Name<<G4endl; 576 ModulatorPropertiesFromFile(Name); 578 ModulatorPropertiesFromFile(Name); 577 } 579 } 578 580