Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HadrontherapyDetectorROGeometry.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 // This is the *BASIC* version of Hadrontherapy, a Geant4-based application
27 // See more at: http://g4advancedexamples.lngs.infn.it/Examples/hadrontherapy
28 //
29 // Visit the Hadrontherapy web site (http://www.lns.infn.it/link/Hadrontherapy) to request
30 // the *COMPLETE* version of this program, together with its documentation;
31 // Hadrontherapy (both basic and full version) are supported by the Italian INFN
32 // Institute in the framework of the MC-INFN Group
33 //
34 
36 #include "HadrontherapyDummySD.hh"
37 #include "G4SystemOfUnits.hh"
38 #include "G4LogicalVolume.hh"
39 #include "G4VPhysicalVolume.hh"
40 #include "G4PVPlacement.hh"
41 #include "G4PVReplica.hh"
42 #include "G4Box.hh"
43 #include "G4ThreeVector.hh"
44 #include "G4Material.hh"
45 
48  G4ThreeVector pos,
49  G4double detectorDimX,
50  G4double detectorDimY,
51  G4double detectorDimZ,
52  G4int numberOfVoxelsX,
53  G4int numberOfVoxelsY,
54  G4int numberOfVoxelsZ):
55 
56  G4VReadOutGeometry(aString),
57  detectorToWorldPosition(pos),
58  detectorSizeX(detectorDimX),
59  detectorSizeY(detectorDimY),
60  detectorSizeZ(detectorDimZ),
61  numberOfVoxelsAlongX(numberOfVoxelsX),
62  numberOfVoxelsAlongY(numberOfVoxelsY),
63  numberOfVoxelsAlongZ(numberOfVoxelsZ)
64 {
65 }
66 
69 {
70 }
71 
73 G4VPhysicalVolume* HadrontherapyDetectorROGeometry::Build()
74 {
75  // A dummy material is used to fill the volumes of the readout geometry.
76  // (It will be allowed to set a NULL pointer in volumes of such virtual
77  // division in future, since this material is irrelevant for tracking.)
78 
79  G4Material* dummyMat = new G4Material(name="dummyMat", 1., 1.*g/mole, 1.*g/cm3);
80 
81  G4double worldSizeX = 200.0 *cm;
82  G4double worldSizeY = 200.0 *cm;
83  G4double worldSizeZ = 200.0 *cm;
84 
85  G4double halfDetectorSizeX = detectorSizeX;
86  G4double halfDetectorSizeY = detectorSizeY;
87  G4double halfDetectorSizeZ = detectorSizeZ;
88 
89  // World volume of ROGeometry ...
90  G4Box* ROWorld = new G4Box("ROWorld",
91  worldSizeX,
92  worldSizeY,
93  worldSizeZ);
94 
95  G4LogicalVolume* ROWorldLog = new G4LogicalVolume(ROWorld, dummyMat,
96  "ROWorldLog", 0,0,0);
97 
98  G4VPhysicalVolume* ROWorldPhys = new G4PVPlacement(0,G4ThreeVector(),
99  "ROWorldPhys",
100  ROWorldLog,
101  0,false,0);
102 
103  // Detector ROGeometry
104  G4Box *RODetector = new G4Box("RODetector",
105  halfDetectorSizeX,
106  halfDetectorSizeY,
107  halfDetectorSizeZ);
108 
109  G4LogicalVolume *RODetectorLog = new G4LogicalVolume(RODetector,
110  dummyMat,
111  "RODetectorLog",
112  0,0,0);
113 
114  G4VPhysicalVolume *RODetectorPhys = new G4PVPlacement(0,
115  detectorToWorldPosition,
116  "DetectorPhys",
117  RODetectorLog,
118  ROWorldPhys,
119  false,0);
120 
121 
122  // Division along X axis: the detector is divided in slices along the X axis
123 
124  G4double halfXVoxelSizeX = halfDetectorSizeX/numberOfVoxelsAlongX;
125  G4double halfXVoxelSizeY = halfDetectorSizeY;
126  G4double halfXVoxelSizeZ = halfDetectorSizeZ;
127  G4double voxelXThickness = 2*halfXVoxelSizeX;
128 
129  G4Box *RODetectorXDivision = new G4Box("RODetectorXDivision",
130  halfXVoxelSizeX,
131  halfXVoxelSizeY,
132  halfXVoxelSizeZ);
133 
134  G4LogicalVolume *RODetectorXDivisionLog = new G4LogicalVolume(RODetectorXDivision,
135  dummyMat,
136  "RODetectorXDivisionLog",
137  0,0,0);
138 
139  G4VPhysicalVolume *RODetectorXDivisionPhys = new G4PVReplica("RODetectorXDivisionPhys",
140  RODetectorXDivisionLog,
141  RODetectorPhys,
142  kXAxis,
143  numberOfVoxelsAlongX,
144  voxelXThickness);
145 
146  // Division along Y axis: the slices along the X axis are divided along the Y axis
147 
148  G4double halfYVoxelSizeX = halfXVoxelSizeX;
149  G4double halfYVoxelSizeY = halfDetectorSizeY/numberOfVoxelsAlongY;
150  G4double halfYVoxelSizeZ = halfDetectorSizeZ;
151  G4double voxelYThickness = 2*halfYVoxelSizeY;
152 
153  G4Box *RODetectorYDivision = new G4Box("RODetectorYDivision",
154  halfYVoxelSizeX,
155  halfYVoxelSizeY,
156  halfYVoxelSizeZ);
157 
158  G4LogicalVolume *RODetectorYDivisionLog = new G4LogicalVolume(RODetectorYDivision,
159  dummyMat,
160  "RODetectorYDivisionLog",
161  0,0,0);
162 
163  G4VPhysicalVolume *RODetectorYDivisionPhys = new G4PVReplica("RODetectorYDivisionPhys",
164  RODetectorYDivisionLog,
165  RODetectorXDivisionPhys,
166  kYAxis,
167  numberOfVoxelsAlongY,
168  voxelYThickness);
169 
170  // Division along Z axis: the slices along the Y axis are divided along the Z axis
171 
172  G4double halfZVoxelSizeX = halfXVoxelSizeX;
173  G4double halfZVoxelSizeY = halfYVoxelSizeY;
174  G4double halfZVoxelSizeZ = halfDetectorSizeZ/numberOfVoxelsAlongZ;
175  G4double voxelZThickness = 2*halfZVoxelSizeZ;
176 
177  G4Box *RODetectorZDivision = new G4Box("RODetectorZDivision",
178  halfZVoxelSizeX,
179  halfZVoxelSizeY,
180  halfZVoxelSizeZ);
181 
182  G4LogicalVolume *RODetectorZDivisionLog = new G4LogicalVolume(RODetectorZDivision,
183  dummyMat,
184  "RODetectorZDivisionLog",
185  0,0,0);
186 
187  RODetectorZDivisionPhys = new G4PVReplica("RODetectorZDivisionPhys",
188  RODetectorZDivisionLog,
189  RODetectorYDivisionPhys,
190  kZAxis,
191  numberOfVoxelsAlongZ,
192  voxelZThickness);
193 
195  RODetectorZDivisionLog -> SetSensitiveDetector(dummySD);
196 
197  return ROWorldPhys;
198 }
199 
200 
201