Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MIRDRibCage.cc
Go to the documentation of this file.
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 #include "G4MIRDRibCage.hh"
35 
36 #include "globals.hh"
37 #include "G4SystemOfUnits.hh"
38 #include "G4SDManager.hh"
39 #include "G4VisAttributes.hh"
41 #include "G4SubtractionSolid.hh"
42 #include "G4EllipticalTube.hh"
43 #include "G4PVReplica.hh"
44 #include "G4Box.hh"
45 #include "G4PVPlacement.hh"
46 #include "G4HumanPhantomColour.hh"
47 
49 {
50 }
51 
53 {
54  }
55 
57  const G4String& colourName, G4bool wireFrame, G4bool sensitivity)
58 {
60 
61  G4cout << "Construct "<< volumeName <<G4endl;
62 
63  G4Material* skeleton = material -> GetMaterial("skeleton");
64  G4Material* soft = material -> GetMaterial("soft_tissue");
65 
66  delete material;
67 
68  G4double dx= 17. *cm; // a2
69  G4double dy= 9.8 * cm; //b2
70  G4double thickness= 32.4 * cm; // z2/2 of cage
71 
72  G4EllipticalTube* outCage = new G4EllipticalTube("outCage",dx, dy, thickness/2.);
73 
74  dx = 16.4 * cm; // a1
75  dy = 9.2 * cm; // b1
76  G4double dz = 34. *cm; // z2/2
77 
78  G4EllipticalTube* inCage = new G4EllipticalTube("inCage",dx, dy, dz/2.);
79 
80  G4SubtractionSolid* cage = new G4SubtractionSolid("Cage",
81  outCage,
82  inCage, 0, G4ThreeVector(0.*cm, 0.*cm, 0. * cm));
83 
84 
85  G4LogicalVolume* logicRibCage = new G4LogicalVolume(cage, soft, "LogicalCage", 0, 0, 0);
86 
87  G4VPhysicalVolume* physRibCage = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, thickness/2. + 0.1 * cm),
88  // with respect to the trunk
89  "physicalRibCage",
90  logicRibCage,
91  mother,
92  false,
93  0, true);
94 
95 
96  G4double xx = 17.*cm;
97  G4double yy = 9.8*cm;
98  G4double ribThickness = 1.4*cm;
99  G4EllipticalTube* rib_out = new G4EllipticalTube("rib_out",xx, yy, ribThickness/2.);
100 
101  xx = 16.5 *cm;
102  yy = 9.3 * cm;
103  G4double zz = 1.5 * cm;
104  G4EllipticalTube* rib_in = new G4EllipticalTube("rib_in",xx, yy, zz/2.);
105  G4SubtractionSolid* rib = new G4SubtractionSolid("rib",rib_out, rib_in);
106 
107  G4LogicalVolume* logicRib= new G4LogicalVolume(rib, skeleton, "logical" + volumeName, 0, 0, 0);
108 
109  physRib1 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (- 32.2*cm/2. + 0.8 *cm)),
110  // with respect to the trunk
111  "physicalRib",
112  logicRib,
113  physRibCage,
114  false,
115  0, true);
116 
117  physRib2 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, ( - 32.2*cm/2. + 0.8 *cm + 2.8 *cm)),
118  // with respect to the trunk
119  "physicalRib",
120  logicRib,
121  physRibCage,
122  false,
123  0, true);
124 
125  physRib3 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 * cm + 5.6 *cm)),
126  // with respect to the trunk
127  "physicalRib",
128  logicRib,
129  physRibCage,
130  false,
131  0, true);
132 
133  physRib4 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 * cm + 8.4 *cm)),
134  // with respect to the trunk
135  "physicalRib",
136  logicRib,
137  physRibCage,
138  false,
139  0, true);
140 
141  physRib5 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 * cm + 11.2 *cm)),
142  // with respect to the trunk
143  "physicalRib",
144  logicRib,
145  physRibCage,
146  false,
147  0, true);
148 
149  physRib6 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 * cm + 14. *cm)),
150  // with respect to the trunk
151  "physicalRib",
152  logicRib,
153  physRibCage,
154  false,
155  0, true);
156 
157  physRib7 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 *cm + 16.8 *cm)),
158  // with respect to the trunk
159  "physicalRib",
160  logicRib,
161  physRibCage,
162  false,
163  0, true);
164 
165  physRib8 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8 *cm + 19.6 *cm)),
166  // with respect to the trunk
167  "physicalRib",
168  logicRib,
169  physRibCage,
170  false,
171  0, true);
172 
173  physRib9 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8*cm + 22.4 *cm)),
174  // with respect to the trunk
175  "physicalRib",
176  logicRib,
177  physRibCage,
178  false,
179  0, true);
180 
181  physRib10 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8*cm + 25.2 *cm)),
182  // with respect to the trunk
183  "physicalRib",
184  logicRib,
185  physRibCage,
186  false,
187  0, true);
188 
189  physRib11 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8*cm + 28. *cm)),
190  // with respect to the trunk
191  "physicalRib",
192  logicRib,
193  physRibCage,
194  false,
195  0, true);
196 
197  physRib12 = new G4PVPlacement(0,G4ThreeVector(0.0, 0.0, (-thickness/2. + 0.8*cm + 30.8 *cm)),
198  // with respect to the trunk
199  "physicalRib",
200  logicRib,
201  physRibCage,
202  false,
203  0, true);
204 
205  // Sensitive Body Part
206  if (sensitivity==true)
207  {
209  // logicRibCage->SetSensitiveDetector( SDman->FindSensitiveDetector("BodyPartSD") );
210  logicRib->SetSensitiveDetector( SDman->FindSensitiveDetector("BodyPartSD") );
211  }
212 
213  // Visualization Attributes
214  logicRibCage -> SetVisAttributes(G4VisAttributes::Invisible);
215 
216  //G4VisAttributes* RibCageVisAtt = new G4VisAttributes(G4Colour(0.46,0.53,0.6));
217 
218  G4HumanPhantomColour* colourPointer = new G4HumanPhantomColour();
219  G4Colour colour = colourPointer -> GetColour(colourName);
220  G4VisAttributes* RibCageVisAtt = new G4VisAttributes(colour);
221  RibCageVisAtt->SetForceSolid(wireFrame);
222  logicRib->SetVisAttributes(RibCageVisAtt);
223 
224  G4cout << "RibCage created !!!!!!" << G4endl;
225  // Testing Pelvis Volume
226  G4double RibCageVol = logicRib->GetSolid()->GetCubicVolume();
227  G4cout << "Volume of RibCage = " << ((RibCageVol)*12.)/cm3 << " cm^3" << G4endl;
228 
229  // Testing RibCage Material
230  G4String RibCageMat = logicRib->GetMaterial()->GetName();
231  G4cout << "Material of RibCage = " << RibCageMat << G4endl;
232 
233  // Testing Density
234  G4double RibCageDensity = logicRib->GetMaterial()->GetDensity();
235  G4cout << "Density of Material = " << RibCageDensity*cm3/g << " g/cm^3" << G4endl;
236 
237  // Testing Mass
238  G4double RibCageMass = (RibCageVol)* RibCageDensity * 12;// 12 is the total number of ribs;
239  G4cout << "Mass of RibCage = " << (RibCageMass)/gram << " g" << G4endl;
240 
241  return physRibCage;
242 }