Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
ML2Ph_BoxInBox.cc
이 파일의 문서화 페이지로 가기
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 // The code was written by :
27 // ^Claudio Andenna claudio.andenna@ispesl.it, claudio.andenna@iss.infn.it
28 // *Barbara Caccia barbara.caccia@iss.it
29 // with the support of Pablo Cirrone (LNS, INFN Catania Italy)
30 // with the contribute of Alessandro Occhigrossi*
31 //
32 // ^INAIL DIPIA - ex ISPESL and INFN Roma, gruppo collegato Sanità, Italy
33 // *Istituto Superiore di Sanità and INFN Roma, gruppo collegato Sanità, Italy
34 // Viale Regina Elena 299, 00161 Roma (Italy)
35 // tel (39) 06 49902246
36 // fax (39) 06 49387075
37 //
38 // more information:
39 // http://g4advancedexamples.lngs.infn.it/Examples/medical-linac
40 //
41 //*******************************************************//
42 
43 #include "ML2Ph_BoxInBox.hh"
44 #include "G4SystemOfUnits.hh"
45 
47 {// phantom size
48  halfSize.set(150.*mm,150.*mm,150.*mm);
49 // phantom position
50  centre.set(0.*mm,0.*mm,0.*mm);
51 }
52 
54 {
55 }
57 {
58  std::cout<<"\n\n\tcentre of the inside box: " <<centreBoxInside/mm<<" [mm]"<< G4endl;
59  std::cout<<"\thalf thickness of the inside box: " <<halfBoxInside_Thickness/mm<<" [mm]\n"<< G4endl;
60 }
61 bool CML2Ph_BoxInBox::Construct(G4VPhysicalVolume *PWorld, G4int saving_in_ROG_Voxels_every_events, G4int seed, G4String ROGOutFile, G4bool bSaveROG)
62 {
63  PVWorld=PWorld;
64 
65 
66  G4double A, Z;
67  A = 1.01*g/mole;
68  G4Element* elH = new G4Element ("Hydrogen","H",Z = 1.,A);
69 
70  A = 12.011*g/mole;
71  G4Element* elC = new G4Element("Carbon","C",Z = 6.,A);
72 
73  A = 16.00*g/mole;
74  G4Element* elO = new G4Element("Oxygen","O",Z = 8.,A);
75 
76  G4double d= 1.18*g/cm3;
77  G4int natoms, ncomponents;
78  G4Material* PMMA = new G4Material("Polimetilmetacrilato",d,ncomponents=3);
79  PMMA->AddElement(elC, natoms=5);
80  PMMA->AddElement(elH, natoms=8);
81  PMMA->AddElement(elO, natoms=2);
82 
83  d= 0.1*g/cm3;
84  G4Material* lightWater = new G4Material("lightWater",d,ncomponents=2);
85  lightWater->AddElement(elH, natoms=2);
86  lightWater->AddElement(elO, natoms=1);
87 
88 
89 
90 // BOX INSIDE
91  G4Material *boxInSideMaterial;
92 
93  boxInSideMaterial=PMMA;
94  std::cout <<"boxInSideMaterial name "<<boxInSideMaterial->GetName() <<" density "<< boxInSideMaterial->GetDensity()/(g/cm3) <<" g/cm3"<< G4endl;
95 
96  centreBoxInside.set(0,0,-50); // the centre of the inside box
97  halfBoxInside_Thickness=3.*cm; // the half thickness of the inside box
98 
100  G4LogicalVolume *boxInSideLV=new G4LogicalVolume(boxInSide, boxInSideMaterial, "boxInSideLV");
101  boxInSidePV = new G4PVPlacement(0, centre+centreBoxInside,"BoxInsidePV", boxInSideLV,PVWorld,false,0,0);
102 
103 // layer PMMA
104  G4Material *layerMaterial=G4NistManager::Instance()->FindOrBuildMaterial("G4_PLEXIGLASS"); // changable
105  G4double halfPMMA_Z_Thickness=0.5*cm;
106  G4Box *layer=new G4Box("layer", halfSize.getX(), halfSize.getY(), halfPMMA_Z_Thickness);
107  G4LogicalVolume *layerLV = new G4LogicalVolume(layer, layerMaterial, "layerLV");
108  layerPV = new G4PVPlacement(0, centre+G4ThreeVector(0,0,-halfSize.getZ()+halfPMMA_Z_Thickness),"layerPV", layerLV,PVWorld,false,0,0);
109 
110  std::cout <<"layerMaterial name "<<layerMaterial->GetName() <<" density " << layerMaterial->GetDensity()/(g/cm3) <<" g/cm3"<< G4endl;
111 
112 // BOX OUTSIDE
113  G4Material *boxOutSideMaterial=G4NistManager::Instance()->FindOrBuildMaterial("G4_LUNG_ICRP"); // changable
114  boxOutSideMaterial=lightWater;
115  G4double halfBoxOutSide_Thickness=halfSize.getZ()-halfPMMA_Z_Thickness;
116  G4Box *boxOutSide=new G4Box("BoxOutSide", halfSize.getX(), halfSize.getY(), halfBoxOutSide_Thickness);
117 
118  // boolean logic subtraction between outside box and inside box
119 
120  G4SubtractionSolid* OutMinusInBox = new G4SubtractionSolid("OutMinusInBox", boxOutSide, boxInSide, 0, centreBoxInside-G4ThreeVector(0,0,5));
121  G4LogicalVolume *OutMinusInBoxLV = new G4LogicalVolume(OutMinusInBox, boxOutSideMaterial,"OutMinusInBoxLV",0,0,0);
122  OutMinusInBoxPV = new G4PVPlacement(0, centre+G4ThreeVector(0,0,-halfSize.getZ()+2*halfPMMA_Z_Thickness+halfBoxOutSide_Thickness),
123  "OutMinusInBoxPV",OutMinusInBoxLV,PVWorld,false,0);
124 
125  std::cout <<"boxOutSideMaterial name "<<boxOutSideMaterial->GetName() <<" density "<<boxOutSideMaterial->GetDensity()/(g/cm3) <<" g/cm3"<< G4endl;
126 
127  // Region for cuts
128  G4Region *regVol= new G4Region("BoxInBoxR");
130  cuts->SetProductionCut(0.01*mm);
131  regVol->SetProductionCuts(cuts);
132 
133 
134  OutMinusInBoxLV->SetRegion(regVol);
135  regVol->AddRootLogicalVolume(OutMinusInBoxLV);
136  OutMinusInBoxLV->SetUserLimits(new G4UserLimits(0.01*mm));
137 
138  layerLV->SetRegion(regVol);
139  regVol->AddRootLogicalVolume(layerLV);
140  layerLV->SetUserLimits(new G4UserLimits(0.01*mm));
141 
142  boxInSideLV->SetRegion(regVol);
143  regVol->AddRootLogicalVolume(boxInSideLV);
144  boxInSideLV->SetUserLimits(new G4UserLimits(0.01*mm));
145 
146  // Visibility
147  G4VisAttributes* simple_PMMA_VisAttWalls= new G4VisAttributes(G4Colour::Gray());
148  G4VisAttributes* simple_InBox_VisAttWalls= new G4VisAttributes(G4Colour::Red());
149  G4VisAttributes* simple_OutBox_VisAttWalls= new G4VisAttributes(G4Colour::Blue());
150 
151  simple_OutBox_VisAttWalls->SetVisibility(true);
152 // simple_OutBox_VisAttWalls->SetForceWireframe(true);
153 // simple_OutBox_VisAttWalls->SetForceAuxEdgeVisible(true);
154  simple_OutBox_VisAttWalls->SetLineWidth(2.);
155 // simple_OutBox_VisAttWalls->SetForceSolid(true);
156 
157  simple_PMMA_VisAttWalls->SetVisibility(true);
158 // simple_PMMA_VisAttWalls->SetForceSolid(true);
159 
160  simple_InBox_VisAttWalls->SetVisibility(true);
161 // simple_InBox_VisAttWalls->SetForceSolid(true);
162 
163 
164  OutMinusInBoxLV->SetVisAttributes(simple_OutBox_VisAttWalls);
165  boxInSideLV->SetVisAttributes(simple_InBox_VisAttWalls);
166  layerLV->SetVisAttributes(simple_PMMA_VisAttWalls);
167 
168  // Sensitive detector
169  sensDet=new CML2SDWithVoxels("BoxInBoxPhantom", saving_in_ROG_Voxels_every_events, seed, ROGOutFile, bSaveROG, centre, halfSize, 100, 100, 100);
171  SDManager->AddNewDetector(sensDet);
172 
173  // Read Out Geometry
175  ROG->setBuildData(PVWorld->GetFrameTranslation(), halfSize, 100, 100, 100);
176  ROG->BuildROGeometry();
177  sensDet->SetROgeometry(ROG);
178  OutMinusInBoxLV->SetSensitiveDetector(sensDet);
179  layerLV->SetSensitiveDetector(sensDet);
180  boxInSideLV->SetSensitiveDetector(sensDet);
181 
182  return true;
183 }
void AddRootLogicalVolume(G4LogicalVolume *lv)
Definition: G4Region.cc:290
void set(double x, double y, double z)
void SetProductionCut(G4double cut, G4int index=-1)
CLHEP::Hep3Vector G4ThreeVector
static constexpr double mm
Definition: G4SIunits.hh:115
double getZ() const
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:71
#define G4endl
Definition: G4ios.hh:61
void SetROgeometry(G4VReadOutGeometry *value)
static G4Colour Gray()
Definition: G4Colour.hh:156
bool Construct(G4VPhysicalVolume *PVWorld, G4int saving_in_ROG_Voxels_every_events, G4int seed, G4String ROGOutFile, G4bool bSaveROG)
void SetProductionCuts(G4ProductionCuts *cut)
G4ThreeVector centre
G4ThreeVector halfSize
G4ThreeVector centreBoxInside
void setBuildData(G4ThreeVector centre, G4ThreeVector halfSize, G4int NumberOfVoxelsAlongX, G4int NumberOfVoxelsAlongY, G4int NumberOfVoxelsAlongZ)
G4VPhysicalVolume * layerPV
G4VPhysicalVolume * OutMinusInBoxPV
G4ThreeVector GetFrameTranslation() const
const G4String & GetName() const
Definition: G4Material.hh:179
Float_t Z
G4double halfBoxInside_Thickness
static constexpr double g
Definition: G4SIunits.hh:183
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
static G4Colour Blue()
Definition: G4Colour.hh:162
G4VPhysicalVolume * boxInSidePV
long seed
Definition: chem4.cc:68
Definition: G4Box.hh:64
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4VPhysicalVolume * PVWorld
double getX() const
double A(double temperature)
Float_t d
double getY() const
void SetVisAttributes(const G4VisAttributes *pVA)
void SetRegion(G4Region *reg)
void SetUserLimits(G4UserLimits *pULimits)
void SetVisibility(G4bool=true)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
static G4Colour Red()
Definition: G4Colour.hh:160
void AddElement(G4Element *element, G4int nAtoms)
Definition: G4Material.cc:368
static constexpr double cm
Definition: G4SIunits.hh:119
void SetLineWidth(G4double)
static constexpr double mole
Definition: G4SIunits.hh:286
CML2SDWithVoxels * sensDet
static constexpr double cm3
Definition: G4SIunits.hh:121
static G4NistManager * Instance()
G4double GetDensity() const
Definition: G4Material.hh:181
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)