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 // Previous authors: G. Guerrieri, S. Guatelli << 26 // Authors: S. Guatelli and M. G. Pia, INFN Genova, Italy 27 // Authors (since 2007): S. Guatelli, Universi << 27 // >> 28 // Based on code developed by the undergraduate student G. Guerrieri >> 29 // Note: this is a preliminary beta-version of the code; an improved >> 30 // version will be distributed in the next Geant4 public release, compliant >> 31 // with the design in a forthcoming publication, and subject to a >> 32 // design and code review. 28 // 33 // 29 34 30 #include <map> << 31 << 32 #include "globals.hh" 35 #include "globals.hh" >> 36 #include <map> 33 37 34 #include "G4HumanPhantomConstruction.hh" 38 #include "G4HumanPhantomConstruction.hh" 35 39 36 #include "G4SystemOfUnits.hh" << 37 #include "G4HumanPhantomSD.hh" 40 #include "G4HumanPhantomSD.hh" 38 #include "G4SDManager.hh" 41 #include "G4SDManager.hh" 39 42 40 //#include "G4VBodyFactory.hh" 43 //#include "G4VBodyFactory.hh" 41 //#include "G4MIRDBodyFactory.hh" 44 //#include "G4MIRDBodyFactory.hh" 42 //#include "G4ORNLBodyFactory.hh" 45 //#include "G4ORNLBodyFactory.hh" 43 46 44 #include "G4PhantomBuilder.hh" 47 #include "G4PhantomBuilder.hh" 45 #include "G4FemaleBuilder.hh" 48 #include "G4FemaleBuilder.hh" 46 #include "G4MaleBuilder.hh" 49 #include "G4MaleBuilder.hh" 47 #include "G4PhantomHeadBuilder.hh" 50 #include "G4PhantomHeadBuilder.hh" >> 51 #include "G4CustomFemaleBuilder.hh" 48 #include "G4RunManager.hh" 52 #include "G4RunManager.hh" 49 #include "G4HumanPhantomMaterial.hh" 53 #include "G4HumanPhantomMaterial.hh" 50 #include "G4Box.hh" 54 #include "G4Box.hh" 51 #include "G4LogicalVolume.hh" 55 #include "G4LogicalVolume.hh" 52 #include "G4VPhysicalVolume.hh" 56 #include "G4VPhysicalVolume.hh" 53 #include "G4VisAttributes.hh" 57 #include "G4VisAttributes.hh" 54 #include "G4Colour.hh" 58 #include "G4Colour.hh" 55 #include "G4PVPlacement.hh" 59 #include "G4PVPlacement.hh" 56 60 57 G4HumanPhantomConstruction::G4HumanPhantomCons 61 G4HumanPhantomConstruction::G4HumanPhantomConstruction() 58 { 62 { 59 fMessenger = new G4HumanPhantomMessenger(thi << 63 messenger = new G4HumanPhantomMessenger(this); 60 fMaterial = new G4HumanPhantomMaterial(); << 64 material = new G4HumanPhantomMaterial(); 61 } 65 } 62 66 63 G4HumanPhantomConstruction::~G4HumanPhantomCon 67 G4HumanPhantomConstruction::~G4HumanPhantomConstruction() 64 { 68 { 65 delete fMaterial; << 69 delete material; 66 delete fMessenger; << 70 delete messenger; 67 } 71 } 68 72 69 G4VPhysicalVolume* G4HumanPhantomConstruction: 73 G4VPhysicalVolume* G4HumanPhantomConstruction::Construct() 70 { 74 { 71 fMaterial -> DefineMaterials(); << 75 material -> DefineMaterials(); 72 76 73 G4BasePhantomBuilder* builder = nullptr; << 77 G4SDManager* SDman = G4SDManager::GetSDMpointer(); >> 78 G4String bodypartSD = "BodyPartSD"; >> 79 G4HumanPhantomSD* userPhantomSD = new G4HumanPhantomSD(bodypartSD); >> 80 SDman->AddNewDetector(userPhantomSD); 74 81 75 if (fModel == "MIRDHead" || fModel == "ORNLH << 82 G4BasePhantomBuilder* builder = 0; >> 83 >> 84 if (model == "MIRDHead" || model == "ORNLHead") 76 { 85 { 77 G4cout << "HeadBuilder instantiated" << 86 G4cout << "HeadBuilder instantiated" << G4endl; 78 builder = new G4PhantomHeadBuilder; 87 builder = new G4PhantomHeadBuilder; 79 if (fModel == "MIRDHead") builder->SetM << 88 if (model == "MIRDHead") builder->SetModel("MIRD"); 80 else if (fModel == "ORNLHead") builder- << 89 else if (model == "ORNLHead") builder->SetModel("ORNLMale"); 81 } 90 } 82 else 91 else 83 { 92 { 84 if (fSex =="Female") << 93 if (sex =="Female") 85 { 94 { 86 builder = new G4FemaleBuilder; << 95 if (model == "MIX") builder = new G4CustomFemaleBuilder; 87 builder->SetModel(fModel); << 96 else {builder = new G4FemaleBuilder;} 88 G4cout << fModel << " "<< fSex << G4endl; << 97 builder->SetModel(model); >> 98 G4cout <<model << " "<< sex << G4endl; 89 } 99 } 90 else if (fSex == "Male") << 100 else if (sex == "Male") 91 { 101 { 92 builder = new G4MaleBuilder; 102 builder = new G4MaleBuilder; 93 builder->SetModel(fModel); << 103 builder->SetModel(model); >> 104 if (model == "MIX") >> 105 { >> 106 G4cout<< "Custom Male is not available!!! MIRD model is selected !" >> 107 << G4endl; >> 108 model = "MIRD"; >> 109 builder->SetModel(model);} 94 } 110 } 95 } 111 } 96 112 97 builder->SetMotherVolume(ConstructWorld()); 113 builder->SetMotherVolume(ConstructWorld()); 98 << 114 99 // the argument indicates the sensitivity of 115 // the argument indicates the sensitivity of the volume 100 << 101 builder->BuildHead("black", false, fSensitiv << 102 builder->BuildSkull("orange", false, fSensit << 103 builder->BuildBrain("yellow", true, fSensiti << 104 116 105 if (fModel != "MIRDHead" && fModel != "ORNLH << 117 builder->BuildHead("black", false, sensitivities["Head"]); >> 118 builder->BuildSkull("orange", false,sensitivities["Skull"]); >> 119 builder->BuildBrain("yellow", true,sensitivities["Brain"]); >> 120 >> 121 if (model != "MIRDHead" && model != "ORNLHead") 106 { 122 { 107 // builder->SetModel(model); 123 // builder->SetModel(model); 108 builder->BuildTrunk("yellow", false, fSe << 124 builder->BuildTrunk("yellow", false, sensitivities["Trunk"]); 109 125 110 builder->BuildLeftLeg("yellow", false, f << 126 builder->BuildLeftLeg("yellow", false,sensitivities["LeftLeg"]); 111 builder->BuildRightLeg("yellow", false, << 127 builder->BuildRightLeg("yellow", false,sensitivities["RightLeg"]); 112 128 113 builder->BuildLeftArmBone("grey", true, << 129 builder->BuildLeftArmBone("grey", true,sensitivities["LeftArmBone"]); 114 builder->BuildRightArmBone("grey", true, << 130 builder->BuildRightArmBone("grey", true, sensitivities["RightArmBone"]); 115 131 116 builder->BuildLeftLegBone("grey", true, << 132 builder->BuildLeftLegBone("grey", true,sensitivities["LeftLegBone"]); 117 builder ->BuildRightLegBone("grey", true << 133 builder ->BuildRightLegBone("grey", true,sensitivities["RightLegBone"]); 118 134 119 builder->BuildUpperSpine("yellow", true, << 135 builder->BuildUpperSpine("yellow", true,sensitivities["UpperSpine"]); 120 << 136 121 if (fModel == "MIRD") << 137 if (model == "MIRD" || model == "MIX") 122 { 138 { 123 builder->BuildLeftScapula("grey", true, fS << 139 builder->BuildLeftScapula("grey", true, sensitivities["LeftScapula"]); 124 builder->BuildRightScapula("grey", true, f << 140 builder->BuildRightScapula("grey", true, sensitivities["RightScapula"]); 125 builder->BuildLeftAdrenal("yellow", true, << 141 builder->BuildLeftAdrenal("yellow", true, sensitivities["LeftAdrenal"]); 126 builder->BuildRightAdrenal("yellow", true, << 142 builder->BuildRightAdrenal("yellow", true, sensitivities["RightAdrenal"]); 127 builder->BuildThymus("orange", true, fSens << 143 128 builder->BuildLeftClavicle("grey", true, f << 129 builder->BuildRightClavicle("grey", true, << 130 builder->BuildSmallIntestine("orange", tru << 131 builder->BuildRibCage("grey", true, fSensi << 132 } 144 } 133 145 134 builder->BuildMiddleLowerSpine("yellow", << 146 builder->BuildMiddleLowerSpine("yellow", true,sensitivities["MiddleLowerSpine"]); 135 147 136 builder->BuildPelvis("grey", true, fSens << 148 builder->BuildPelvis("grey", true,sensitivities["Pelvis"]); 137 149 138 builder->BuildStomach("orange", true, fS << 150 builder->BuildStomach("orange", true,sensitivities["Stomach"]); 139 builder->BuildUpperLargeIntestine("light << 151 builder->BuildUpperLargeIntestine("lightBlue", true,sensitivities["UpperLargeIntestine"]); 140 builder->BuildLowerLargeIntestine("light << 152 builder->BuildLowerLargeIntestine("lightBlue", true,sensitivities["LowerLargeIntestine"]); 141 builder->BuildSpleen("green", true, fSen << 153 if (model == "MIRD" || model == "MIX") builder->BuildRibCage("grey", true,sensitivities["RibCage"]); 142 builder->BuildPancreas("purple", true, f << 154 143 //builder->BuildLiver("orange", true,sen << 155 144 << 156 builder->BuildSpleen("green", true,sensitivities["Spleen"]); 145 builder->BuildLeftKidney("green", true, << 157 builder->BuildPancreas("purple", true,sensitivities["Pancreas"]); 146 builder->BuildRightKidney("green", true, << 158 //builder->BuildLiver("orange", true,sensitivities["Liver"]); // da fare MIRD 147 builder->BuildUrinaryBladder("green", tr << 159 >> 160 builder->BuildLeftKidney("green", true,sensitivities["LeftKidney"]); >> 161 builder->BuildRightKidney("green", true,sensitivities["RightKidney"]); >> 162 builder->BuildUrinaryBladder("green", true,sensitivities["UrinaryBladder"]); 148 163 149 //builder->BuildHeart("red", true,fSensi << 164 //builder->BuildHeart("red", true,sensitivities["Hearth"]);//dafare MIRD 150 // builder->BuildLeftLung("blue", true, f << 165 // builder->BuildLeftLung("blue", true,sensitivities["LeftLung"]); 151 //builder->BuildRightLung("blue", true, << 166 //builder->BuildRightLung("blue", true,sensitivities["RightLung"]); 152 // builder->BuildThyroid("orange", true, << 167 //builder->BuildThyroid("orange", true,sensitivities["Thyroid"]); 153 << 168 154 if(fSex=="Female"){ << 169 if(sex=="Female"){ 155 << 170 156 builder->BuildLeftOvary("purple", true, fSen << 171 builder->BuildLeftOvary("purple", true,sensitivities["LeftOvary"]); 157 builder->BuildRightOvary("purple", true, fSe << 172 builder->BuildRightOvary("purple", true,sensitivities["RightOvary"]); 158 builder->BuildUterus("purple", true, fSensit << 173 builder->BuildUterus("purple", true,sensitivities["Uterus"]); 159 174 160 if (fModel == "ORNLFemale" || fModel == "MIR << 175 if (model == "ORNLFemale" || model == "MIRD") 161 { 176 { 162 builder->BuildLeftBreast("purple", true, << 177 builder->BuildLeftBreast("purple", true,sensitivities["LeftBreast"]); 163 builder->BuildRightBreast("purple", true << 178 builder->BuildRightBreast("purple", true,sensitivities["RightBreast"]); 164 } 179 } >> 180 else if (model == "MIX") >> 181 { >> 182 builder->BuildVoxelLeftBreast("purple",false, sensitivities["LeftBreast"]); >> 183 builder->BuildVoxelRightBreast("purple", false, sensitivities["RightBreast"]); >> 184 } 165 } 185 } 166 << 186 167 if(fSex=="Male"){ << 187 if(sex=="Male"){ 168 << 188 // builder->BuildMaleGenitalia(sensitivities["MaleGenitalia"]); 169 if (fModel == "MIRD"){ << 189 // builder->BuildTestes(sensitivities["Testes"]); 170 builder -> BuildMaleGenitalia("yellow",fal << 190 } 171 builder -> BuildLeftTeste("purple",true, f << 172 builder -> BuildRightTeste("purple",true, << 173 } << 174 else G4cout << "ORNL does not have model fo << 175 } << 176 191 177 } 192 } 178 G4VPhysicalVolume* result=builder->GetPhanto << 193 return builder->GetPhantom(); 179 delete builder; 194 delete builder; 180 return result; << 181 } 195 } 182 196 183 void G4HumanPhantomConstruction::SetBodyPartS << 197 void G4HumanPhantomConstruction::SetBodyPartSensitivity(G4String bodyPartName, G4bool bodyPartSensitivity) 184 { 198 { 185 G4cout << "This method is not currently work << 199 sensitivities[bodyPartName] = bodyPartSensitivity; >> 200 if(bodyPartSensitivity==true) >> 201 G4cout << " >>> " << bodyPartName << " added as sensitive volume." << G4endl; 186 } 202 } 187 203 188 G4VPhysicalVolume* G4HumanPhantomConstruction: 204 G4VPhysicalVolume* G4HumanPhantomConstruction::ConstructWorld() 189 { 205 { 190 G4Material* air = fMaterial -> GetMaterial(" << 206 G4Material* air = material -> GetMaterial("Air"); 191 207 192 // World Volume 208 // World Volume 193 // G4double worldSize = 1.*m ; 209 // G4double worldSize = 1.*m ; 194 G4double worldSize = 1.5 *m ; << 210 G4double worldSize = 1. *m ; 195 G4Box* world = new G4Box("world", worldSize, 211 G4Box* world = new G4Box("world", worldSize, worldSize, worldSize); 196 212 197 auto* logicWorld = new G4LogicalVolume(world << 213 G4LogicalVolume* logicWorld = new G4LogicalVolume(world, 198 air, << 214 air, 199 "logicalWorld", nullptr, nul << 215 "logicalWorld", 0, 0,0); 200 216 201 G4VPhysicalVolume* motherVolume = new G4PVPl << 217 G4VPhysicalVolume* motherVolume = new G4PVPlacement(0,G4ThreeVector(), 202 "physicalWorld", 218 "physicalWorld", 203 logicWorld, 219 logicWorld, 204 nullptr, << 220 0, 205 false, 221 false, 206 0); 222 0); 207 223 208 // Visualization Attributes 224 // Visualization Attributes 209 auto* WorldVisAtt = new G4VisAttributes(G4Co << 225 G4VisAttributes* WorldVisAtt = new G4VisAttributes(G4Colour(0.94,0.5,0.5)); 210 226 211 WorldVisAtt->SetForceSolid(false); 227 WorldVisAtt->SetForceSolid(false); 212 logicWorld->SetVisAttributes(G4VisAttributes << 228 logicWorld->SetVisAttributes(G4VisAttributes::Invisible); 213 229 214 return motherVolume; 230 return motherVolume; 215 } 231 } 216 232 217 void G4HumanPhantomConstruction::SetPhantomSex 233 void G4HumanPhantomConstruction::SetPhantomSex(G4String newSex) 218 { 234 { 219 fSex=newSex; << 235 sex=newSex; 220 236 221 if (fSex == "Male") << 237 if (sex == "Male") 222 { 238 { 223 G4cout << ">> Male Phantom will be built 239 G4cout << ">> Male Phantom will be built." << G4endl; 224 } 240 } 225 if (fSex == "Female") << 241 if (sex == "Female") 226 { 242 { 227 G4cout << ">> Female Phantom will be bui 243 G4cout << ">> Female Phantom will be built." << G4endl; 228 } 244 } 229 if ((fSex != "Female") && (fSex != "Male")) << 245 if ((sex != "Female") && (sex != "Male")) 230 G4cout << fSex << " can not be defined!" < << 246 G4cout << sex << " can not be defined!" << G4endl; 231 } 247 } 232 248 233 void G4HumanPhantomConstruction::SetPhantomMod 249 void G4HumanPhantomConstruction::SetPhantomModel(G4String newModel) 234 { 250 { 235 fModel = newModel; << 251 model = newModel; 236 252 237 if (fModel == "MIRD") << 253 if (model == "MIRD") 238 { 254 { 239 G4cout<<" >> Phantom " << fModel << " wi << 255 G4cout<<" >> Phantom " << model << " will be built."<<G4endl; 240 } 256 } 241 if (fModel == "ORNLFemale") << 257 if (model == "ORNLFemale") 242 { 258 { 243 G4cout<<" >> Phantom " << fModel << " wi << 259 G4cout<<" >> Phantom " << model << " will be built."<<G4endl; 244 } << 260 } 245 261 246 if (fModel == "ORNLMale") << 262 if (model == "ORNLMale") 247 { 263 { 248 G4cout<<" >> Phantom " << fModel << " wi << 264 G4cout<<" >> Phantom " << model << " will be built."<<G4endl; 249 } << 265 } 250 266 251 if (fModel == "MIRDHead") << 267 if (model == "MIX") 252 { 268 { 253 G4cout<<" >> Phantom " << fModel << " wi << 269 G4cout<<" >> Phantom " << model << " will be built."<<G4endl; 254 } 270 } 255 << 271 if (model == "MIRDHead") 256 if (fModel == "ORNLHead") << 257 { 272 { 258 G4cout<<" >> Phantom " << fModel << " wi << 273 G4cout<<" >> Phantom " << model << " will be built."<<G4endl; 259 } 274 } 260 } << 261 << 262 void G4HumanPhantomConstruction::ConstructSDan << 263 { << 264 auto* SD = new G4HumanPhantomSD("SD", "Huma << 265 G4SDManager::GetSDMpointer()->AddNewDetecto << 266 275 267 if (fModel != "ORNLMale" && fModel != "ORNLFem << 276 if (model == "ORNLHead") 268 { << 277 { 269 SetSensitiveDetector("logicalHead",SD); << 278 G4cout<<" >> Phantom " << model << " will be built."<<G4endl; 270 SetSensitiveDetector("logicalSkull",SD); << 279 } 271 SetSensitiveDetector("logicalBrain",SD); << 272 if (fModel != "MIRDHead") << 273 { << 274 SetSensitiveDetector("logicalTrunk",SD); << 275 SetSensitiveDetector("logicalLeftLeg",SD << 276 SetSensitiveDetector("logicalRightLeg",S << 277 SetSensitiveDetector("logicalLeftArmBone << 278 SetSensitiveDetector("logicalRightArmBon << 279 SetSensitiveDetector("logicalLeftLegBone << 280 SetSensitiveDetector("logicalRightLegBon << 281 SetSensitiveDetector("logicalUpperSpine" << 282 SetSensitiveDetector("logicalLeftScapula << 283 SetSensitiveDetector("logicalRightScapul << 284 SetSensitiveDetector("logicalLeftAdrenal << 285 SetSensitiveDetector("logicalRightAdrena << 286 SetSensitiveDetector("logicalThymus",SD) << 287 SetSensitiveDetector("logicalLeftClavicl << 288 SetSensitiveDetector("logicalRightClavic << 289 SetSensitiveDetector("logicalSmallIntest << 290 SetSensitiveDetector("logicalRibCage",SD << 291 SetSensitiveDetector("logicalMiddleLower << 292 SetSensitiveDetector("logicalStomach",SD << 293 SetSensitiveDetector("logicalUpperLargeI << 294 SetSensitiveDetector("logicalLowerLargeI << 295 SetSensitiveDetector("logicalSpleen",SD) << 296 SetSensitiveDetector("logicalPancreas",S << 297 SetSensitiveDetector("logicalLeftKidney" << 298 SetSensitiveDetector("logicalRightKidney << 299 SetSensitiveDetector("logicalUrinaryBlad << 300 << 301 if(fSex=="Female"){ << 302 SetSensitiveDetector("logicalLeftOvary",SD); << 303 SetSensitiveDetector("logicalRightOvar << 304 SetSensitiveDetector("logicalUterus",S << 305 SetSensitiveDetector("logicalLeftBreas << 306 SetSensitiveDetector("logicalRightBrea << 307 } << 308 else if(fSex=="Male"){ << 309 SetSensitiveDetector("logicalMaleGenitalia << 310 SetSensitiveDetector("logicalLeftTes << 311 SetSensitiveDetector("logicalRightTeste",S << 312 } << 313 } << 314 }else << 315 { << 316 SetSensitiveDetector("HeadVolume",SD); << 317 SetSensitiveDetector("SkullVolume",SD); << 318 SetSensitiveDetector("BrainVolume",SD); << 319 G4cout <<"ORNL model!!!! Head is sensitive o << 320 } << 321 } 280 } 322 281