source: trunk/examples/advanced/hadrontherapy/src/HadrontherapyPhantomROGeometry.cc @ 1317

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

update

File size: 7.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// $Id: HadrontherapyPhantomROGeometry.cc; May 2005
27// ----------------------------------------------------------------------------
28//                 GEANT 4 - Hadrontherapy example
29// ----------------------------------------------------------------------------
30// Code developed by:
31//
32// G.A.P. Cirrone(a)*, F. Di Rosa(a), S. Guatelli(b), G. Russo(a)
33//
34// (a) Laboratori Nazionali del Sud
35//     of the National Institute for Nuclear Physics, Catania, Italy
36// (b) National Institute for Nuclear Physics Section of Genova, genova, Italy
37//
38// * cirrone@lns.infn.it
39// ----------------------------------------------------------------------------
40
41#include "HadrontherapyPhantomROGeometry.hh"
42#include "HadrontherapyDummySD.hh"
43#include "G4LogicalVolume.hh"
44#include "G4VPhysicalVolume.hh"
45#include "G4PVPlacement.hh"
46#include "G4PVReplica.hh"
47#include "G4Box.hh"
48#include "G4ThreeVector.hh"
49#include "G4Material.hh"
50
51HadrontherapyPhantomROGeometry::HadrontherapyPhantomROGeometry(G4String aString,
52                                                               G4double phantomDimX,
53                                                               G4double phantomDimY,
54                                                               G4double phantomDimZ,
55                                                               G4int numberOfVoxelsX,
56                                                               G4int numberOfVoxelsY,
57                                                               G4int numberOfVoxelsZ):
58  G4VReadOutGeometry(aString),
59  phantomSizeX(phantomDimX),
60  phantomSizeY(phantomDimY),
61  phantomSizeZ(phantomDimZ),
62  numberOfVoxelsAlongX(numberOfVoxelsX),
63  numberOfVoxelsAlongY(numberOfVoxelsY),
64  numberOfVoxelsAlongZ(numberOfVoxelsZ)
65{
66}
67
68HadrontherapyPhantomROGeometry::~HadrontherapyPhantomROGeometry()
69{
70}
71
72G4VPhysicalVolume* HadrontherapyPhantomROGeometry::Build()
73{
74  // A dummy material is used to fill the volumes of the readout geometry.
75  // (It will be allowed to set a NULL pointer in volumes of such virtual
76  // division in future, since this material is irrelevant for tracking.)
77
78  G4Material* dummyMat = new G4Material(name="dummyMat", 1., 1.*g/mole, 1.*g/cm3);
79
80  G4double worldSizeX = 200.0 *cm;
81  G4double worldSizeY = 200.0 *cm;
82  G4double worldSizeZ = 200.0 *cm;
83
84  G4double halfPhantomSizeX = phantomSizeX;
85  G4double halfPhantomSizeY = phantomSizeY;
86  G4double halfPhantomSizeZ = phantomSizeZ;
87
88  // World volume of ROGeometry ...
89  G4Box* ROWorld = new G4Box("ROWorld",
90                             worldSizeX,
91                             worldSizeY,
92                             worldSizeZ);
93
94  G4LogicalVolume* ROWorldLog = new G4LogicalVolume(ROWorld, dummyMat, 
95                                                    "ROWorldLog", 0,0,0);
96
97  G4VPhysicalVolume* ROWorldPhys = new G4PVPlacement(0,G4ThreeVector(), 
98                                                     "ROWorldPhys", 
99                                                     ROWorldLog, 
100                                                     0,false,0);
101
102  // Phantom ROGeometry
103  G4Box *ROPhantom = new G4Box("ROPhantom", 
104                               halfPhantomSizeX, 
105                               halfPhantomSizeY, 
106                               halfPhantomSizeZ);
107
108  G4LogicalVolume *ROPhantomLog = new G4LogicalVolume(ROPhantom,
109                                                      dummyMat,
110                                                      "ROPhantomLog",
111                                                      0,0,0);
112 
113  G4VPhysicalVolume *ROPhantomPhys = new G4PVPlacement(0,
114                                                       G4ThreeVector(-180.0 *mm,
115                                                                     0.0 *mm, 
116                                                                     0.0 *mm),
117                                                       "PhantomPhys",
118                                                       ROPhantomLog,
119                                                       ROWorldPhys,
120                                                       false,0);
121
122
123  // ROGeomtry: the phantom is divided in voxels along the axis X, Y, Z
124
125  // Division along X axis: the phantom is devided in slices along the X axis
126
127  G4double halfXVoxelSizeX = halfPhantomSizeX/numberOfVoxelsAlongX;
128  G4double halfXVoxelSizeY = halfPhantomSizeY;
129  G4double halfXVoxelSizeZ = halfPhantomSizeZ;
130  G4double voxelXThickness = 2*halfXVoxelSizeX;
131
132  G4Box *ROPhantomXDivision = new G4Box("ROPhantomXDivision",
133                                        halfXVoxelSizeX,
134                                        halfXVoxelSizeY,
135                                        halfXVoxelSizeZ);
136
137  G4LogicalVolume *ROPhantomXDivisionLog = new G4LogicalVolume(ROPhantomXDivision,
138                                                               dummyMat,
139                                                               "ROPhantomXDivisionLog",
140                                                               0,0,0);
141
142  G4VPhysicalVolume *ROPhantomXDivisionPhys = new G4PVReplica("ROPhantomXDivisionPhys",
143                                                              ROPhantomXDivisionLog,
144                                                              ROPhantomPhys,
145                                                              kXAxis,
146                                                              numberOfVoxelsAlongX,
147                                                              voxelXThickness);
148
149  // Division along Y axis: the slices along the X axis are devided along the Y axis
150
151  G4double halfYVoxelSizeX =  halfXVoxelSizeX;
152  G4double halfYVoxelSizeY = halfPhantomSizeY/numberOfVoxelsAlongY;
153  G4double halfYVoxelSizeZ = halfPhantomSizeZ;
154  G4double voxelYThickness = 2*halfYVoxelSizeY;
155
156  G4Box *ROPhantomYDivision = new G4Box("ROPhantomYDivision",
157                                        halfYVoxelSizeX, 
158                                        halfYVoxelSizeY,
159                                        halfYVoxelSizeZ);
160
161  G4LogicalVolume *ROPhantomYDivisionLog = new G4LogicalVolume(ROPhantomYDivision,
162                                                               dummyMat,
163                                                               "ROPhantomYDivisionLog",
164                                                               0,0,0);
165 
166  G4VPhysicalVolume *ROPhantomYDivisionPhys = new G4PVReplica("ROPhantomYDivisionPhys",
167                                                              ROPhantomYDivisionLog,
168                                                              ROPhantomXDivisionPhys,
169                                                              kYAxis,
170                                                              numberOfVoxelsAlongY,
171                                                              voxelYThickness);
172 
173  // Division along Z axis: the slices along the Y axis are devided along the Z axis
174
175  G4double halfZVoxelSizeX = halfXVoxelSizeX;
176  G4double halfZVoxelSizeY = halfYVoxelSizeY;
177  G4double halfZVoxelSizeZ = halfPhantomSizeZ/numberOfVoxelsAlongZ;
178  G4double voxelZThickness = 2*halfZVoxelSizeZ;
179 
180  G4Box *ROPhantomZDivision = new G4Box("ROPhantomZDivision",
181                                        halfZVoxelSizeX,
182                                        halfZVoxelSizeY, 
183                                        halfZVoxelSizeZ);
184 
185  G4LogicalVolume *ROPhantomZDivisionLog = new G4LogicalVolume(ROPhantomZDivision,
186                                                               dummyMat,
187                                                               "ROPhantomZDivisionLog",
188                                                               0,0,0);
189 
190  ROPhantomZDivisionPhys = new G4PVReplica("ROPhantomZDivisionPhys",
191                                           ROPhantomZDivisionLog,
192                                           ROPhantomYDivisionPhys,
193                                           kZAxis,
194                                           numberOfVoxelsAlongZ,
195                                           voxelZThickness);
196
197  HadrontherapyDummySD *dummySD = new HadrontherapyDummySD;
198  ROPhantomZDivisionLog -> SetSensitiveDetector(dummySD);
199
200  return ROWorldPhys;
201}
202
203
204
Note: See TracBrowser for help on using the repository browser.