source: trunk/examples/advanced/human_phantom/src/G4HumanPhantomConstruction.cc @ 1319

Last change on this file since 1319 was 807, checked in by garnier, 16 years ago

update

File size: 9.6 KB
Line 
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// Authors: S. Guatelli and M. G. Pia, INFN Genova, Italy
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.
33//
34
35#include "globals.hh"
36#include <map>
37
38#include "G4HumanPhantomConstruction.hh"
39
40#include "G4HumanPhantomSD.hh"
41#include "G4SDManager.hh"
42
43//#include "G4VBodyFactory.hh"
44//#include "G4MIRDBodyFactory.hh"
45//#include "G4ORNLBodyFactory.hh"
46
47#include "G4PhantomBuilder.hh"
48#include "G4FemaleBuilder.hh"
49#include "G4MaleBuilder.hh"
50#include "G4PhantomHeadBuilder.hh"
51#include "G4CustomFemaleBuilder.hh"
52#include "G4RunManager.hh"
53#include "G4HumanPhantomMaterial.hh"
54#include "G4Box.hh"
55#include "G4LogicalVolume.hh"
56#include "G4VPhysicalVolume.hh"
57#include "G4VisAttributes.hh"
58#include "G4Colour.hh"
59#include "G4PVPlacement.hh"
60
61G4HumanPhantomConstruction::G4HumanPhantomConstruction()
62{
63 messenger = new G4HumanPhantomMessenger(this);
64 material = new G4HumanPhantomMaterial();
65}
66
67G4HumanPhantomConstruction::~G4HumanPhantomConstruction()
68{
69 delete material;
70 delete messenger;
71}
72
73G4VPhysicalVolume* G4HumanPhantomConstruction::Construct()
74{
75  material -> DefineMaterials();
76 
77  G4SDManager* SDman = G4SDManager::GetSDMpointer();
78  G4String bodypartSD = "BodyPartSD";
79  G4HumanPhantomSD* userPhantomSD = new G4HumanPhantomSD(bodypartSD);
80  SDman->AddNewDetector(userPhantomSD);
81
82  G4BasePhantomBuilder*  builder = 0;
83
84  if (model == "MIRDHead" || model == "ORNLHead")
85    { 
86      G4cout << "HeadBuilder instantiated" << G4endl;
87      builder = new G4PhantomHeadBuilder;
88      if (model ==  "MIRDHead") builder->SetModel("MIRD");
89      else if (model ==  "ORNLHead") builder->SetModel("ORNLMale");
90    }
91  else
92    { 
93      if (sex =="Female") 
94        { 
95          if (model == "MIX") builder = new G4CustomFemaleBuilder;
96          else {builder = new G4FemaleBuilder;}
97          builder->SetModel(model);
98          G4cout <<model << " "<< sex << G4endl;
99        }
100      else if (sex == "Male") 
101        {
102          builder = new G4MaleBuilder;
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);}
110        }
111    }
112 
113  builder->SetMotherVolume(ConstructWorld());
114
115  // the argument indicates the sensitivity of the volume
116
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")
122    { 
123      //  builder->SetModel(model);
124      builder->BuildTrunk("yellow", false, sensitivities["Trunk"]);
125     
126      builder->BuildLeftLeg("yellow", false,sensitivities["LeftLeg"]);
127      builder->BuildRightLeg("yellow", false,sensitivities["RightLeg"]);
128     
129      builder->BuildLeftArmBone("grey", true,sensitivities["LeftArmBone"]);
130      builder->BuildRightArmBone("grey", true, sensitivities["RightArmBone"]); 
131   
132      builder->BuildLeftLegBone("grey", true,sensitivities["LeftLegBone"]);
133      builder ->BuildRightLegBone("grey", true,sensitivities["RightLegBone"]);
134 
135      builder->BuildUpperSpine("yellow", true,sensitivities["UpperSpine"]); 
136   
137      if (model == "MIRD" || model == "MIX") 
138        {
139          builder->BuildLeftScapula("grey", true, sensitivities["LeftScapula"]); 
140          builder->BuildRightScapula("grey", true, sensitivities["RightScapula"]);
141          builder->BuildLeftAdrenal("yellow", true, sensitivities["LeftAdrenal"]);
142          builder->BuildRightAdrenal("yellow", true, sensitivities["RightAdrenal"]);
143
144        }
145 
146      builder->BuildMiddleLowerSpine("yellow", true,sensitivities["MiddleLowerSpine"]);
147 
148      builder->BuildPelvis("grey", true,sensitivities["Pelvis"]); 
149 
150      builder->BuildStomach("orange", true,sensitivities["Stomach"]); 
151      builder->BuildUpperLargeIntestine("lightBlue", true,sensitivities["UpperLargeIntestine"]);
152      builder->BuildLowerLargeIntestine("lightBlue", true,sensitivities["LowerLargeIntestine"]);
153      if (model == "MIRD" || model == "MIX") builder->BuildRibCage("grey", true,sensitivities["RibCage"]); 
154   
155
156       builder->BuildSpleen("green", true,sensitivities["Spleen"]);
157      builder->BuildPancreas("purple", true,sensitivities["Pancreas"]); 
158      //builder->BuildLiver("orange", true,sensitivities["Liver"]); // da fare MIRD
159
160       builder->BuildLeftKidney("green", true,sensitivities["LeftKidney"]);
161      builder->BuildRightKidney("green", true,sensitivities["RightKidney"]);
162      builder->BuildUrinaryBladder("green", true,sensitivities["UrinaryBladder"]);
163 
164      //builder->BuildHeart("red", true,sensitivities["Hearth"]);//dafare MIRD
165      // builder->BuildLeftLung("blue", true,sensitivities["LeftLung"]);
166      //builder->BuildRightLung("blue", true,sensitivities["RightLung"]);
167      //builder->BuildThyroid("orange", true,sensitivities["Thyroid"]);
168     
169      if(sex=="Female"){
170
171        builder->BuildLeftOvary("purple", true,sensitivities["LeftOvary"]);
172        builder->BuildRightOvary("purple", true,sensitivities["RightOvary"]);
173        builder->BuildUterus("purple", true,sensitivities["Uterus"]);
174
175        if (model == "ORNLFemale" || model == "MIRD")
176          {
177            builder->BuildLeftBreast("purple", true,sensitivities["LeftBreast"]); 
178            builder->BuildRightBreast("purple", true,sensitivities["RightBreast"]);
179          }
180        else if (model == "MIX")
181          {
182            builder->BuildVoxelLeftBreast("purple",false, sensitivities["LeftBreast"]); 
183            builder->BuildVoxelRightBreast("purple", false, sensitivities["RightBreast"]); 
184          } 
185      }
186       
187          if(sex=="Male"){
188          //    builder->BuildMaleGenitalia(sensitivities["MaleGenitalia"]);
189          // builder->BuildTestes(sensitivities["Testes"]);
190          }
191     
192    }
193  return builder->GetPhantom(); 
194  delete builder;
195}
196
197void  G4HumanPhantomConstruction::SetBodyPartSensitivity(G4String bodyPartName, G4bool bodyPartSensitivity)
198{
199  sensitivities[bodyPartName] = bodyPartSensitivity;
200  if(bodyPartSensitivity==true) 
201    G4cout << " >>> " << bodyPartName << " added as sensitive volume." << G4endl;
202}
203
204G4VPhysicalVolume* G4HumanPhantomConstruction::ConstructWorld()
205{
206  G4Material* air = material -> GetMaterial("Air");
207
208  // World Volume
209  // G4double worldSize = 1.*m ;
210 G4double worldSize = 1. *m ;
211  G4Box* world = new G4Box("world", worldSize, worldSize, worldSize);
212
213  G4LogicalVolume* logicWorld = new G4LogicalVolume(world, 
214                                                    air, 
215                                                    "logicalWorld", 0, 0,0);
216
217  G4VPhysicalVolume* motherVolume = new G4PVPlacement(0,G4ThreeVector(),
218                                                      "physicalWorld",
219                                                      logicWorld,
220                                                      0,
221                                                      false,
222                                                      0);
223
224  // Visualization Attributes
225  G4VisAttributes* WorldVisAtt = new G4VisAttributes(G4Colour(0.94,0.5,0.5));
226   
227  WorldVisAtt->SetForceSolid(false);
228  logicWorld->SetVisAttributes(G4VisAttributes::Invisible);
229 
230  return motherVolume;
231}
232
233void G4HumanPhantomConstruction::SetPhantomSex(G4String newSex)
234{
235  sex=newSex;
236
237  if (sex == "Male")
238    {
239      G4cout << ">> Male Phantom will be built." << G4endl;
240    }
241  if (sex == "Female")
242    {
243      G4cout << ">> Female Phantom will be built." << G4endl;
244    }
245  if ((sex != "Female") && (sex != "Male"))
246    G4cout << sex << " can not be defined!" << G4endl;
247}
248
249void G4HumanPhantomConstruction::SetPhantomModel(G4String newModel)
250{
251  model = newModel;
252
253  if (model == "MIRD")
254    {
255      G4cout<<" >> Phantom " << model << " will be built."<<G4endl;
256    }
257  if (model == "ORNLFemale")
258    {
259      G4cout<<" >> Phantom " << model << " will be built."<<G4endl;
260   }
261
262  if (model == "ORNLMale")
263    {
264      G4cout<<" >> Phantom " << model << " will be built."<<G4endl;
265   }
266
267  if (model == "MIX")
268    {
269      G4cout<<" >> Phantom " << model << " will be built."<<G4endl;
270    }
271  if (model == "MIRDHead")
272    {
273      G4cout<<" >> Phantom " << model << " will be built."<<G4endl;
274    }
275
276  if (model == "ORNLHead")
277    {
278      G4cout<<" >> Phantom " << model << " will be built."<<G4endl;
279    }
280}
Note: See TracBrowser for help on using the repository browser.