Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 27 #include "G4SDManager.hh" 28 #include "G4RunManager.hh" 29 #include "G4Box.hh" 30 #include "G4Tubs.hh" 31 #include "G4Cons.hh" 32 #include "G4Orb.hh" 33 #include "G4LogicalVolume.hh" 34 #include "G4ThreeVector.hh" 35 #include "G4PVPlacement.hh" 36 #include "globals.hh" 37 #include "G4RotationMatrix.hh" 38 #include "G4Colour.hh" 39 #include "G4UserLimits.hh" 40 #include "G4VisAttributes.hh" 41 #include "G4NistManager.hh" 42 43 #include "GammaKnifeDetectorMessenger.hh" 44 #include "GammaKnifeDetectorConstruction.hh" 45 46 #include "G4SystemOfUnits.hh" 47 48 GammaKnifeDetectorConstruction::GammaKnifeDete 49 : physicalTreatmentRoom(0), 50 patientPhysicalVolume(0), 51 patientLogicalVolume(0), 52 solidColl_helmet(0), 53 helmetSize(4) 54 { 55 // Messenger to change parameters of the geo 56 detectorMessenger = new GammaKnifeDetectorMe 57 } 58 59 GammaKnifeDetectorConstruction::~GammaKnifeDet 60 { 61 delete detectorMessenger; 62 } 63 64 G4VPhysicalVolume* GammaKnifeDetectorConstruct 65 { 66 // Define the geometry components 67 ConstructBeamLine(); 68 69 return physicalTreatmentRoom; 70 } 71 72 void GammaKnifeDetectorConstruction::Construct 73 { 74 // NIST Materials 75 G4Material* air = G4NistManager::Instance( 76 G4Material* water = G4NistManager::Instanc 77 G4Material* cobalt = G4NistManager::Instan 78 G4Material* Pb = G4NistManager::Instance() 79 G4Material* tungsten = G4NistManager::Inst 80 G4Material* Al = G4NistManager::Instance() 81 G4Material* Fe = G4NistManager::Instance() 82 83 // Steel as non-NIST material 84 G4Element* elFe = G4NistManager::Instance( 85 G4Element* elNi = G4NistManager::Instance( 86 G4Element* elCr = G4NistManager::Instance( 87 G4Material* steel = new G4Material("Stainl 88 steel -> AddElement(elFe, 70 * perCent); 89 steel -> AddElement(elCr, 18 * perCent); 90 steel -> AddElement(elNi, 12 * perCent); 91 92 // ----------------------------- 93 // Treatment room - World volume 94 // ----------------------------- 95 96 // Treatment room sizes 97 const G4double worldX = 400.0 *cm; 98 const G4double worldY = 400.0 *cm; 99 const G4double worldZ = 400.0 *cm; 100 101 G4Box* treatmentRoom = new G4Box("TreatmentR 102 103 G4LogicalVolume* logicTreatmentRoom = new G4 104 105 106 0,0,0); 107 108 physicalTreatmentRoom = new G4PVPlacement(0, 109 G4ThreeVector(), 110 "physicalTreatmentRoom", 111 logicTreatmentRoom, 112 0,false,0); 113 114 115 // The treatment room is invisible in the Vi 116 logicTreatmentRoom -> SetVisAttributes (G4Vi 117 118 119 // Visualisation attributes of all elements 120 G4VisAttributes * grayFe = new G4VisAttribut 121 grayFe -> SetVisibility(true); 122 grayFe -> SetForceSolid(true); 123 124 G4VisAttributes * blueCobalt = new G4VisAttr 125 blueCobalt -> SetVisibility(true); 126 blueCobalt -> SetForceSolid(true); 127 128 G4VisAttributes * graySS = new G4VisAttribut 129 graySS -> SetVisibility(true); 130 graySS -> SetForceSolid(true); 131 132 G4VisAttributes * grayAl = new G4VisAttribut 133 grayAl -> SetVisibility(true); 134 grayAl -> SetForceSolid(true); 135 136 G4VisAttributes * blackLead = new G4VisAttri 137 blackLead -> SetVisibility(true); 138 blackLead -> SetForceSolid(true); 139 140 141 G4VisAttributes * colorTungsten = new G4VisA 142 colorTungsten -> SetVisibility(true); 143 colorTungsten -> SetForceSolid(true); 144 145 146 147 148 149 //------------------------------------------ 150 // Cylinder source "Tube_source" 151 //------------------------------------------ 152 G4double innerRadiusOfTheTube_source = 0.; 153 G4double outerRadiusOfTheTube_source = 0.5*m 154 G4double hightOfTheTube_source = 1*cm; 155 G4double startAngleOfTheTube = 0.*deg; 156 G4double spanningAngleOfTheTube = 360.*deg; 157 158 G4ThreeVector positionTube_source = G4ThreeV 159 160 solidTube_source = new G4Tubs("solidTube_sou 161 innerRadiusOfTheTube_source, 162 outerRadiusOfTheTube_source, 163 hightOfTheTube_source, 164 startAngleOfTheTube, 165 spanningAngleOfTheTube); 166 logicTube_source = new G4LogicalVolume(solid 167 physiTube_source = new G4PVPlacement(0, 168 positionTube_source, 169 logicTube_source, 170 "Tube_source", 171 logicTreatmentRoom, 172 false, 173 0); 174 175 logicTube_source -> SetVisAttributes(blueCob 176 177 178 //------------------------------------- 179 // Cylinder covering source "Tube" 180 //------------------------------------- 181 G4double innerRadiusOfTheTube = 0.5*mm; 182 G4double outerRadiusOfTheTube = 4.*mm; 183 G4double hightOfTheTube = 1*cm; 184 185 186 G4ThreeVector positionTube = G4ThreeVector(0 187 188 solidTube = new G4Tubs("solidTube", 189 innerRadiusOfTheTube, 190 outerRadiusOfTheTube, 191 hightOfTheTube, 192 startAngleOfTheTube, 193 spanningAngleOfTheTube); 194 logicTube = new G4LogicalVolume(solidTube,st 195 physiTube = new G4PVPlacement(0, 196 positionTube, 197 logicTube, 198 "Tube", 199 logicTreatmentRoom, 200 false, 201 0); 202 203 logicTube -> SetVisAttributes(graySS); 204 205 //--------------------------------------- 206 // Cylinder covering source "Tube_Al" 207 //--------------------------------------- 208 G4double innerRadiusOfTheTube_Al = 4.*mm; 209 G4double outerRadiusOfTheTube_Al = 15.*mm; 210 G4double hightOfTheTube_Al = 1*cm; 211 212 G4ThreeVector positionTube_Al = G4ThreeVecto 213 214 solidTube_Al = new G4Tubs("solidTube_Al", 215 innerRadiusOfTheTube_Al, 216 outerRadiusOfTheTube_Al, 217 hightOfTheTube_Al, 218 startAngleOfTheTube, 219 spanningAngleOfTheTube); 220 logicTube_Al = new G4LogicalVolume(solidTube 221 physiTube_Al = new G4PVPlacement(0, 222 positionTube_Al, 223 logicTube_Al, 224 "Tube_Al", 225 logicTreatmentRoom, 226 false, 227 0); 228 229 logicTube_Al -> SetVisAttributes(grayAl); 230 231 //------------------------------------------ 232 // Cylinder covering external part of the so 233 //------------------------------------------ 234 G4double innerRadiusOfTheTube_Fe = 15.*mm; 235 G4double outerRadiusOfTheTube_Fe = 50.*mm; 236 G4double hightOfTheTube_Fe = 1*cm; 237 238 239 G4ThreeVector positionTube_Fe = G4ThreeVecto 240 241 solidTube_Fe = new G4Tubs("solidTube_Fe", 242 innerRadiusOfTheTube_Fe, 243 outerRadiusOfTheTube_Fe, 244 hightOfTheTube_Fe, 245 startAngleOfTheTube, 246 spanningAngleOfTheTube); 247 logicTube_Fe = new G4LogicalVolume(solidTube 248 physiTube_Fe = new G4PVPlacement(0, 249 positionTube_Fe, 250 logicTube_Fe, 251 "Tube_Fe", 252 logicTreatmentRoom, 253 false, 254 0); 255 256 logicTube_Fe -> SetVisAttributes(grayFe); 257 258 259 260 261 //------------------------------------------- 262 // Cylinder covering posterior part "Tube_pos 263 //------------------------------------------- 264 265 G4double innerRadiusOfTheTube_post = 0; 266 G4double outerRadiusOfTheTube_post = 50*mm; 267 G4double hightOfTheTube_post = 1*cm; 268 269 G4ThreeVector positionTube_post = G4ThreeVec 270 271 solidTube_post = new G4Tubs("solidTube_post" 272 innerRadiusOfTheTube_post, 273 outerRadiusOfTheTube_post, 274 hightOfTheTube_post, 275 startAngleOfTheTube, 276 spanningAngleOfTheTube); 277 logicTube_post = new G4LogicalVolume(solidTub 278 physiTube_post = new G4PVPlacement(0, 279 positionTube_post, 280 logicTube_post, 281 "Tube_post", 282 logicTreatmentRoom, 283 false, 284 0); 285 286 logicTube_post -> SetVisAttributes(grayFe); 287 288 289 //------------------------------------------- 290 // Fixed cylinder collimator "Tube_coll" 291 //------------------------------------------- 292 293 G4double innerRadiusOfTheTube_coll = 2.5*mm; 294 G4double outerRadiusOfTheTube_coll = 15.*mm; 295 G4double hightOfTheTube_coll = 3.25*cm; 296 297 G4ThreeVector positionTube_coll = G4ThreeVec 298 299 solidTube_coll = new G4Tubs("solidTube_coll" 300 innerRadiusOfTheTube_coll, 301 outerRadiusOfTheTube_coll, 302 hightOfTheTube_coll, 303 startAngleOfTheTube, 304 spanningAngleOfTheTube); 305 logicTube_coll = new G4LogicalVolume(solidTub 306 physiTube_coll = new G4PVPlacement(0, 307 positionTube_coll, 308 logicTube_coll, 309 "Tube_coll", 310 logicTreatmentRoom, 311 false, 312 0); 313 314 logicTube_coll -> SetVisAttributes(colorTungs 315 316 317 //------------------------------------------- 318 // Cylinder covering fixed collimator "Tube_c 319 //------------------------------------------- 320 321 G4double innerRadiusOfTheTube_coll_Fe = 15.* 322 G4double outerRadiusOfTheTube_coll_Fe = 50.* 323 G4double hightOfTheTube_coll_Fe = 3.25*cm; 324 325 G4ThreeVector positionTube_coll_Fe = G4Three 326 327 solidTube_coll_Fe = new G4Tubs("solidTube_co 328 innerRadiusOfTheTube_coll_Fe, 329 outerRadiusOfTheTube_coll_Fe, 330 hightOfTheTube_coll_Fe, 331 startAngleOfTheTube, 332 spanningAngleOfTheTube); 333 logicTube_coll_Fe = new G4LogicalVolume(solid 334 physiTube_coll_Fe = new G4PVPlacement(0, 335 positionTube_coll_Fe, 336 logicTube_coll_Fe, 337 "Tube_coll_Fe", 338 logicTreatmentRoom, 339 false, 340 0); 341 342 logicTube_coll_Fe -> SetVisAttributes(grayFe) 343 344 345 //------------------------------------------- 346 // Fixed truncated cone collimator "Coll_fixe 347 //------------------------------------------- 348 349 G4double Rmin1Coll_fixed = 2.5*mm; 350 G4double Rmax1Coll_fixed = 15.*mm; 351 G4double Rmin2Coll_fixed = 4.25*mm; 352 G4double Rmax2Coll_fixed = 15.*mm; 353 G4double hightColl_fixed = 4.625*cm; 354 355 356 G4ThreeVector positionColl_fixed = G4ThreeVe 357 358 solidColl_fixed = new G4Cons("solidColl_fixe 359 Rmin1Coll_fixed, 360 Rmax1Coll_fixed, 361 Rmin2Coll_fixed, 362 Rmax2Coll_fixed, 363 hightColl_fixed, 364 startAngleOfTheTube, 365 spanningAngleOfTheTube); 366 logicColl_fixed = new G4LogicalVolume(solidC 367 physiColl_fixed = new G4PVPlacement(0, 368 positionColl_fixed, 369 logicColl_fixed, 370 "Coll_fixed", 371 logicTreatmentRoom, 372 false, 373 0); 374 375 logicColl_fixed -> SetVisAttributes(blackLead 376 377 378 //------------------------------------------- 379 // Cilinder covering fixed collimator "Coll_f 380 //------------------------------------------- 381 382 G4double Rmin1Coll_fixed_Fe = 15.*mm; 383 G4double Rmax1Coll_fixed_Fe = 50.*mm; 384 G4double Rmin2Coll_fixed_Fe = 15.*mm; 385 G4double Rmax2Coll_fixed_Fe = 40.*mm; 386 G4double hightColl_fixed_Fe = 4.625*cm; 387 388 389 G4ThreeVector positionColl_fixed_Fe = G4Thre 390 391 solidColl_fixed_Fe = new G4Cons("solidColl_f 392 Rmin1Coll_fixed_Fe, 393 Rmax1Coll_fixed_Fe, 394 Rmin2Coll_fixed_Fe, 395 Rmax2Coll_fixed_Fe, 396 hightColl_fixed_Fe, 397 startAngleOfTheTube, // 398 spanningAngleOfTheTube); 399 logicColl_fixed_Fe = new G4LogicalVolume(sol 400 physiColl_fixed_Fe = new G4PVPlacement(0, 401 positionColl_fixed_Fe, 402 logicColl_fixed_Fe, 403 "Coll_fixed_Fe", 404 logicTreatmentRoom, 405 false, 406 0); 407 408 logicColl_fixed_Fe -> SetVisAttributes(grayF 409 410 411 //------------------------------------------- 412 // Mobile truncate cone collimator "Coll_helm 413 //------------------------------------------- 414 G4double Rmax1Coll_helmet = 15.*mm; 415 G4double Rmax2Coll_helmet = 15.*mm; 416 G4double hightColl_helmet = 3.0*cm; 417 418 419 G4ThreeVector positionColl_helmet = G4ThreeV 420 421 solidColl_helmet = new G4Cons("solidColl_hel 422 0.0, // will b 423 Rmax1Coll_helme 424 0.0, // will b 425 Rmax2Coll_helmet, 426 hightColl_helmet, 427 startAngleOfTheTube, 428 spanningAngleOf 429 UpdateHelmet(); // Set the proper inner radi 430 431 logicColl_helmet = new G4LogicalVolume(solid 432 physiColl_helmet = new G4PVPlacement(0, 433 positionColl_helmet, 434 logicColl_helmet, 435 "Coll_helmet", 436 logicTreatmentRoom, 437 false, 438 0); 439 440 logicColl_helmet -> SetVisAttributes(colorTu 441 442 //------------------------------------------- 443 // Truncated cone covering mobile collimator 444 //------------------------------------------- 445 446 G4double Rmin1Coll_helmet_Fe = 15.*mm; 447 G4double Rmax1Coll_helmet_Fe = 40.*mm; 448 G4double Rmin2Coll_helmet_Fe = 15.*mm; 449 G4double Rmax2Coll_helmet_Fe = 30.*mm; 450 G4double hightColl_helmet_Fe = 3.0*cm; 451 452 G4ThreeVector positionColl_helmet_Fe = G4Thr 453 454 solidColl_helmet_Fe = new G4Cons("solidColl_ 455 Rmin1Coll_helmet_Fe, 456 Rmax1Coll_helmet_Fe, 457 Rmin2Coll_helmet_Fe, 458 Rmax2Coll_helmet_Fe, 459 hightColl_helmet_Fe, 460 startAngleOfTheTube, 461 spanningAngleOfTheTube); 462 logicColl_helmet_Fe = new G4LogicalVolume(so 463 physiColl_helmet_Fe = new G4PVPlacement(0, 464 positionColl_helmet_Fe, 465 logicColl_helmet_Fe, 466 "Coll_helmet_Fe", 467 logicTreatmentRoom, 468 false, 469 0); 470 471 logicColl_helmet_Fe -> SetVisAttributes(gray 472 473 //----------------------------------------- 474 // Patient --> water spherical phantom 475 //----------------------------------------- 476 477 478 G4Orb* patient = new G4Orb("patient",8.*cm); 479 patientLogicalVolume = new G4LogicalVolume(p 480 water, 481 "patientLog", 0, 0, 0); 482 patientPhysicalVolume = new G4PVPlacement( n 483 G4 484 "patientPhys", 485 patientLogicalVolume, 486 physicalTreatmentRoom, 487 false,0); 488 489 // Visualisation attributes of the patient 490 G4VisAttributes * redWire = new G4VisAttribu 491 redWire -> SetVisibility(true); 492 redWire -> SetForceWireframe(true); 493 redWire -> SetForceAuxEdgeVisible(true); 494 patientLogicalVolume -> SetVisAttributes(red 495 496 } 497 498 void GammaKnifeDetectorConstruction::UpdateHel 499 { 500 if (solidColl_helmet) 501 { 502 switch( helmetSize ) 503 { 504 case 18: 505 solidColl_helmet->SetInnerRadiusMi 506 solidColl_helmet->SetInnerRadiusPl 507 break; 508 509 case 14: 510 solidColl_helmet->SetInnerRadiusMi 511 solidColl_helmet->SetInnerRadiusPl 512 break; 513 514 case 8: 515 solidColl_helmet->SetInnerRadiusMi 516 solidColl_helmet->SetInnerRadiusPl 517 break; 518 519 case 4: 520 solidColl_helmet->SetInnerRadiusMi 521 solidColl_helmet->SetInnerRadiusPl 522 break; 523 } 524 // Inform the run manager about change 525 G4RunManager::GetRunManager()->Geometr 526 } 527 } 528 529 void GammaKnifeDetectorConstruction::SetHelmet 530 { 531 if (size != helmetSize) // Only if the siz 532 { 533 // Allow only valid numbers 534 switch( size ) 535 { 536 case 18: 537 case 14: 538 case 8: 539 case 4: 540 helmetSize = size; 541 G4cout << "Helmet size set to " << 542 UpdateHelmet(); 543 break; 544 default: 545 G4Exception("GammaKnifeDetectorConstruct 546 "GammaKnife001", FatalException, 547 "Error: Invalid helmet size."); 548 return; 549 } 550 } 551 } 552 553 554 555