geant4-B1-example  1.0
 All Classes Files Functions Variables Pages
B1DetectorConstruction.cc
Go to the documentation of this file.
1 /// \file B1DetectorConstruction.cc
2 /// \brief Implementation of the B1DetectorConstruction class
3 
5 
6 #include "G4RunManager.hh"
7 #include "G4NistManager.hh"
8 #include "G4Box.hh"
9 #include "G4Cons.hh"
10 #include "G4Orb.hh"
11 #include "G4Sphere.hh"
12 #include "G4Trd.hh"
13 #include "G4LogicalVolume.hh"
14 #include "G4PVPlacement.hh"
15 #include "G4SystemOfUnits.hh"
16 
17 
18 /// iniitalize fScoringVolume to 0
20 : G4VUserDetectorConstruction(),
21  fScoringVolume(0)
22 { }
23 
24 
25 /// do nothing.
27 { }
28 
29 /*!
30  @brief the main place for geometry setting.
31  the scoring volume is set to shape2 (bone)
32 */
34 {
35 
36  // Get nist material manager
37  G4NistManager* nist = G4NistManager::Instance();
38 
39 
40  // Envelope parameters
41  G4double env_sizeXY = 20*cm, env_sizeZ = 30*cm;
42  G4Material* env_mat = nist->FindOrBuildMaterial("G4_WATER");
43 
44  // Option to switch on/off checking of volumes overlaps
45  G4bool checkOverlaps = true;
46 
47 
48  /*! ###create a world
49  world is the largest object.
50  1. box shape ==> x={-24, 24}, y={-24,24}, z={-18,18} cm.
51  2. material=> air.
52  3. objects=> solidWorld, logicWorld, physWorld.
53  */
54  G4double world_sizeXY = 1.2*env_sizeXY;
55  G4double world_sizeZ = 1.2*env_sizeZ;
56  G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR");
57 
58  G4Box* solidWorld =
59  new G4Box("World", //its name
60  0.5*world_sizeXY, 0.5*world_sizeXY, 0.5*world_sizeZ); //its size
61 
62  G4LogicalVolume* logicWorld =
63  new G4LogicalVolume(solidWorld, //its solid
64  world_mat, //its material
65  "World"); //its name
66 
67  G4VPhysicalVolume* physWorld =
68  new G4PVPlacement(0, //no rotation
69  G4ThreeVector(), //at (0,0,0)
70  logicWorld, //its logical volume
71  "World", //its name
72  0, //its mother volume
73  false, //no boolean operation
74  0, //copy number
75  checkOverlaps); //overlaps checking
76 
77 
78 
79 
80  /*!
81  ### create an envelope
82  1. box shape ==> x={-20, 20}, y={-20,20}, z={-15,15} cm. <br>
83  2. center ==> {0,0,0} <br>
84  3. material=> water. <br>
85  4. objects=> solidEnv, logicEnv, (no variable for phyEnv) <br>
86  */
87 
88  G4Box* solidEnv =
89  new G4Box("Envelope", //its name
90  0.5*env_sizeXY, 0.5*env_sizeXY, 0.5*env_sizeZ); //its size
91 
92  G4LogicalVolume* logicEnv =
93  new G4LogicalVolume(solidEnv, //its solid
94  env_mat, //its material
95  "Envelope"); //its name
96 
97  new G4PVPlacement(0, //no rotation
98  G4ThreeVector(), //at (0,0,0)
99  logicEnv, //its logical volume
100  "Envelope", //its name
101  logicWorld, //its mother volume
102  false, //no boolean operation
103  0, //copy number
104  checkOverlaps); //overlaps checking
105 
106 
107  /*! ### create "shape1" to represent tissue
108  1. cone shape ==> r1 = {0,2}cm, r2 ={0,2}cm, height=3cm, phi= 360 deg
109  2. center ==> {0,+2,-7} cm
110  3. material=> G4_A-150_TISSUE.
111  4. objects=> solidShape1, logicShape1, (no variable for phyShape1)
112  */
113  G4Material* shape1_mat = nist->FindOrBuildMaterial("G4_A-150_TISSUE");
114  G4ThreeVector pos1 = G4ThreeVector(0, 2*cm, -7*cm);
115 
116  // Conical section shape
117  G4double shape1_rmina = 0.*cm, shape1_rmaxa = 2.*cm;
118  G4double shape1_rminb = 0.*cm, shape1_rmaxb = 4.*cm;
119  G4double shape1_hz = 3.*cm;
120  G4double shape1_phimin = 0.*deg, shape1_phimax = 360.*deg;
121  G4Cons* solidShape1 =
122  new G4Cons("Shape1",
123  shape1_rmina, shape1_rmaxa, shape1_rminb, shape1_rmaxb, shape1_hz,
124  shape1_phimin, shape1_phimax);
125 
126  G4LogicalVolume* logicShape1 =
127  new G4LogicalVolume(solidShape1, //its solid
128  shape1_mat, //its material
129  "Shape1"); //its name
130 
131  new G4PVPlacement(0, //no rotation
132  pos1, //at position
133  logicShape1, //its logical volume
134  "Shape1", //its name
135  logicEnv, //its mother volume
136  false, //no boolean operation
137  0, //copy number
138  checkOverlaps); //overlaps checking
139 
140  /*! ### create "shape2" to represent bone
141  1. Trapezoid shape ==> area1 = 12x10, area2=12x16, height=6cm
142  2. center ==> {0,-1,-7} cm
143  3. material=> G4_BONE_COMPACT_ICRU
144  4. objects=> solidShape2, logicShape2, (no variable for phyShape2)
145  */
146  G4Material* shape2_mat = nist->FindOrBuildMaterial("G4_BONE_COMPACT_ICRU");
147  G4ThreeVector pos2 = G4ThreeVector(0, -1*cm, 7*cm);
148 
149  // Trapezoid shape
150  G4double shape2_dxa = 12*cm, shape2_dxb = 12*cm;
151  G4double shape2_dya = 10*cm, shape2_dyb = 16*cm;
152  G4double shape2_dz = 6*cm;
153  G4Trd* solidShape2 =
154  new G4Trd("Shape2", //its name
155  0.5*shape2_dxa, 0.5*shape2_dxb,
156  0.5*shape2_dya, 0.5*shape2_dyb, 0.5*shape2_dz); //its size
157 
158  G4LogicalVolume* logicShape2 =
159  new G4LogicalVolume(solidShape2, //its solid
160  shape2_mat, //its material
161  "Shape2"); //its name
162 
163  new G4PVPlacement(0, //no rotation
164  pos2, //at position
165  logicShape2, //its logical volume
166  "Shape2", //its name
167  logicEnv, //its mother volume
168  false, //no boolean operation
169  0, //copy number
170  checkOverlaps); //overlaps checking
171 
172 
173  /// Set __logicShape2__ as scoring volume (fScoringVolume) <br>
174  fScoringVolume = logicShape2;
175 
176 
177  ///always return the __physical World__
178  return physWorld;
179 }
180 
181 
virtual ~B1DetectorConstruction()
do nothing.
Definition of the B1DetectorConstruction class.
B1DetectorConstruction()
iniitalize fScoringVolume to 0
G4LogicalVolume * fScoringVolume
virtual G4VPhysicalVolume * Construct()
the main place for geometry setting. the scoring volume is set to shape2 (bone)