Geant4_10
HadrontherapyDetectorConstruction.hh
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 
35 #ifndef HadrontherapyDetectorConstruction_H
36 #define HadrontherapyDetectorConstruction_H 1
37 
38 #include "G4Box.hh"
39 #include "globals.hh"
40 #include "G4VisAttributes.hh"
41 #include "G4LogicalVolume.hh"
42 #include "G4UnitsTable.hh"
44 
45 class G4VPhysicalVolume;
46 class G4LogicalVolume;
51 class HadrontherapyLet;
53 {
54 public:
55 
57 
59 
60 public:
63  G4ThreeVector detectorToWorldPosition);
65  HadrontherapyDetectorSD* detectorSD; // Pointer to sensitive detector
66 
67 private:
68 
69  void ConstructPhantom();
70  void ConstructDetector();
71  void ParametersCheck();
72 
73 public:
74 // Get detector position relative to WORLD
76  {
77  return phantomPosition + detectorPosition;
78  }
80 // Get displacement between phantom and detector by detector position (center of), phantom (center of) and detector sizes
82 {
83  return G4ThreeVector(phantomSizeX/2 - detectorSizeX/2 + detectorPosition.getX(),
84  phantomSizeY/2 - detectorSizeY/2 + detectorPosition.getY(),
85  phantomSizeZ/2 - detectorSizeZ/2 + detectorPosition.getZ()
86  );
87 }
88 
90 // Calculate (and set) detector position by displacement, phantom and detector sizes
91 inline void SetDetectorPosition()
92  {
93  // Adjust detector position
94  detectorPosition.setX(detectorToPhantomPosition.getX() - phantomSizeX/2 + detectorSizeX/2);
95  detectorPosition.setY(detectorToPhantomPosition.getY() - phantomSizeY/2 + detectorSizeY/2);
96  detectorPosition.setZ(detectorToPhantomPosition.getZ() - phantomSizeZ/2 + detectorSizeZ/2);
97 
98 
99  }
101 // Check whether detector is inside phantom
102 inline bool IsInside(G4double detectorX,
103  G4double detectorY,
104  G4double detectorZ,
105  G4double phantomX,
106  G4double phantomY,
107  G4double phantomZ,
108  G4ThreeVector pos)
109 {
110 // Dimensions check... X Y and Z
111 // Firstly check what dimension we are modifying
112  {
113  if (detectorX > phantomX)
114  {
115  G4cout << "Error: Detector X dimension must be smaller or equal to the corrispondent of the phantom" << G4endl;
116  return false;
117  }
118  if ( (phantomX - detectorX) < pos.getX())
119  {
120  G4cout << "Error: X dimension doesn't fit with detector to phantom relative position" << G4endl;
121  return false;
122  }
123  }
124 
125  {
126  if (detectorY > phantomY)
127  {
128  G4cout << "Error: Detector Y dimension must be smaller or equal to the corrispondent of the phantom" << G4endl;
129  return false;
130  }
131  if ( (phantomY - detectorY) < pos.getY())
132  {
133  G4cout << "Error: Y dimension doesn't fit with detector to phantom relative position" << G4endl;
134  return false;
135  }
136  }
137 
138  {
139  if (detectorZ > phantomZ)
140  {
141  G4cout << "Error: Detector Z dimension must be smaller or equal to the corrispondent of the phantom" << G4endl;
142  return false;
143  }
144  if ( (phantomZ - detectorZ) < pos.getZ())
145  {
146  G4cout << "Error: Z dimension doesn't fit with detector to phantom relative position" << G4endl;
147  return false;
148  }
149  }
150 
151  return true;
152 }
154 
156  void SetVoxelSize(G4double sizeX, G4double sizeY, G4double sizeZ);
157  void SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ);
158  void SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ);
160  void SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition);
161  void UpdateGeometry();
162  void PrintParameters();
163  G4LogicalVolume* GetDetectorLogicalVolume(){ return detectorLogicalVolume;}
164 
165 
166 private:
167  static HadrontherapyDetectorConstruction* instance;
168  HadrontherapyDetectorMessenger* detectorMessenger;
169 
170  G4VisAttributes* skyBlue;
171  G4VisAttributes* red;
172 
173  HadrontherapyDetectorROGeometry* detectorROGeometry; // Pointer to ROGeometry
174  HadrontherapyMatrix* matrix;
175  HadrontherapyLet* let;
176 
177  G4Box *phantom , *detector;
178  G4LogicalVolume *phantomLogicalVolume, *detectorLogicalVolume;
179  G4VPhysicalVolume *phantomPhysicalVolume, *detectorPhysicalVolume;
180 
181  G4double phantomSizeX;
182  G4double phantomSizeY;
183  G4double phantomSizeZ;
184 
185  G4double detectorSizeX;
186  G4double detectorSizeY;
187  G4double detectorSizeZ;
188 
189  G4ThreeVector phantomPosition, detectorPosition, detectorToPhantomPosition; // phantom center, detector center, detector to phantom relative position
190 
191  G4double sizeOfVoxelAlongX;
192  G4double sizeOfVoxelAlongY;
193  G4double sizeOfVoxelAlongZ;
194 
195  G4int numberOfVoxelsAlongX;
196  G4int numberOfVoxelsAlongY;
197  G4int numberOfVoxelsAlongZ;
198 
199  G4double volumeOfVoxel, massOfVoxel;
200 
201  G4Material *phantomMaterial, *detectorMaterial;
202  G4Region* aRegion;
203 };
204 #endif
void SetPhantomSize(G4double sizeX, G4double sizeY, G4double sizeZ)
CLHEP::Hep3Vector G4ThreeVector
Definition: G4Box.hh:63
double getY() const
static HadrontherapyDetectorConstruction * GetInstance()
void SetDetectorSize(G4double sizeX, G4double sizeY, G4double sizeZ)
int G4int
Definition: G4Types.hh:78
void setY(double)
void setZ(double)
void setX(double)
string material
Definition: eplot.py:19
double getX() const
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
void SetDetectorToPhantomPosition(G4ThreeVector DetectorToPhantomPosition)
bool IsInside(G4double detectorX, G4double detectorY, G4double detectorZ, G4double phantomX, G4double phantomY, G4double phantomZ, G4ThreeVector pos)
double getZ() const
#define G4endl
Definition: G4ios.hh:61
void InitializeDetectorROGeometry(HadrontherapyDetectorROGeometry *, G4ThreeVector detectorToWorldPosition)
double G4double
Definition: G4Types.hh:76
void SetVoxelSize(G4double sizeX, G4double sizeY, G4double sizeZ)