Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
HadrontherapyDetectorROGeometry Class Reference

#include <HadrontherapyDetectorROGeometry.hh>

Inheritance diagram for HadrontherapyDetectorROGeometry:
G4VUserParallelWorld

Public Member Functions

 HadrontherapyDetectorROGeometry (G4String)
 
 ~HadrontherapyDetectorROGeometry ()
 
void Initialize (G4ThreeVector detectorPos, G4double detectorDimX, G4double detectorDimY, G4double detectorDimZ, G4int numberOfVoxelsX, G4int numberOfVoxelsY, G4int numberOfVoxelsZ)
 
void UpdateROGeometry ()
 
virtual void Construct ()
 
virtual void ConstructSD ()
 
- Public Member Functions inherited from G4VUserParallelWorld
 G4VUserParallelWorld (G4String worldName)
 
virtual ~G4VUserParallelWorld ()
 
G4String GetName ()
 

Additional Inherited Members

- Protected Member Functions inherited from G4VUserParallelWorld
G4VPhysicalVolumeGetWorld ()
 
void SetSensitiveDetector (const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
 
void SetSensitiveDetector (G4LogicalVolume *logVol, G4VSensitiveDetector *aSD)
 
- Protected Attributes inherited from G4VUserParallelWorld
G4String fWorldName
 

Detailed Description

Definition at line 46 of file HadrontherapyDetectorROGeometry.hh.

Constructor & Destructor Documentation

HadrontherapyDetectorROGeometry::HadrontherapyDetectorROGeometry ( G4String  aString)

Definition at line 70 of file HadrontherapyDetectorROGeometry.cc.

71  : G4VUserParallelWorld(aString),RODetector(0),RODetectorXDivision(0),
72  RODetectorYDivision(0),RODetectorZDivision(0),worldLogical(0),RODetectorLog(0),
73  RODetectorXDivisionLog(0),RODetectorYDivisionLog(0),RODetectorZDivisionLog(0),
74  sensitiveLogicalVolume(0)
75 {
76  isBuilt = false;
77  isInitialized = false;
78 }
G4VUserParallelWorld(G4String worldName)
G4bool isInitialized()
HadrontherapyDetectorROGeometry::~HadrontherapyDetectorROGeometry ( )

Definition at line 196 of file HadrontherapyDetectorROGeometry.cc.

197 {;}

Member Function Documentation

void HadrontherapyDetectorROGeometry::Construct ( void  )
virtual

Implements G4VUserParallelWorld.

Definition at line 200 of file HadrontherapyDetectorROGeometry.cc.

References FatalException, G4Exception(), G4VPhysicalVolume::GetLogicalVolume(), G4VUserParallelWorld::GetWorld(), kXAxis, kYAxis, and kZAxis.

201 {
202  // A dummy material is used to fill the volumes of the readout geometry.
203  // (It will be allowed to set a NULL pointer in volumes of such virtual
204  // division in future, since this material is irrelevant for tracking.)
205 
206 
207  //
208  // World
209  //
210  G4VPhysicalVolume* ghostWorld = GetWorld();
211  worldLogical = ghostWorld->GetLogicalVolume();
212 
213  if (!isInitialized)
214  {
215  G4Exception("HadrontherapyDetectorROGeometry::Construct","had001",
216  FatalException,"Parameters of the RO geometry are not initialized");
217  return;
218  }
219 
220 
221  G4double halfDetectorSizeX = detectorSizeX;
222  G4double halfDetectorSizeY = detectorSizeY;
223  G4double halfDetectorSizeZ = detectorSizeZ;
224 
225  // World volume of ROGeometry ... SERVE SOLO PER LA ROG
226 
227  // Detector ROGeometry
228  RODetector = new G4Box("RODetector",
229  halfDetectorSizeX,
230  halfDetectorSizeY,
231  halfDetectorSizeZ);
232 
233  RODetectorLog = new G4LogicalVolume(RODetector,
234  0,
235  "RODetectorLog",
236  0,0,0);
237 
238 
239 
240  G4VPhysicalVolume *RODetectorPhys = new G4PVPlacement(0,
241  detectorToWorldPosition,RODetectorLog,
242  "RODetectorPhys",
243  worldLogical,
244  false,0);
245 
246 
247 
248 
249  // Division along X axis: the detector is divided in slices along the X axis
250 
251  G4double halfXVoxelSizeX = halfDetectorSizeX/numberOfVoxelsAlongX;
252  G4double halfXVoxelSizeY = halfDetectorSizeY;
253  G4double halfXVoxelSizeZ = halfDetectorSizeZ;
254  G4double voxelXThickness = 2*halfXVoxelSizeX;
255 
256 
257  RODetectorXDivision = new G4Box("RODetectorXDivision",
258  halfXVoxelSizeX,
259  halfXVoxelSizeY,
260  halfXVoxelSizeZ);
261 
262  RODetectorXDivisionLog = new G4LogicalVolume(RODetectorXDivision,
263  0,
264  "RODetectorXDivisionLog",
265  0,0,0);
266 
267  G4VPhysicalVolume *RODetectorXDivisionPhys = new G4PVReplica("RODetectorXDivisionPhys",
268  RODetectorXDivisionLog,
269  RODetectorPhys,
270  kXAxis,
271  numberOfVoxelsAlongX,
272  voxelXThickness);
273 
274  // Division along Y axis: the slices along the X axis are divided along the Y axis
275 
276  G4double halfYVoxelSizeX = halfXVoxelSizeX;
277  G4double halfYVoxelSizeY = halfDetectorSizeY/numberOfVoxelsAlongY;
278  G4double halfYVoxelSizeZ = halfDetectorSizeZ;
279  G4double voxelYThickness = 2*halfYVoxelSizeY;
280 
281  RODetectorYDivision = new G4Box("RODetectorYDivision",
282  halfYVoxelSizeX,
283  halfYVoxelSizeY,
284  halfYVoxelSizeZ);
285 
286  RODetectorYDivisionLog = new G4LogicalVolume(RODetectorYDivision,
287  0,
288  "RODetectorYDivisionLog",
289  0,0,0);
290 
291  G4VPhysicalVolume *RODetectorYDivisionPhys = new G4PVReplica("RODetectorYDivisionPhys",
292  RODetectorYDivisionLog,
293  RODetectorXDivisionPhys,
294  kYAxis,
295  numberOfVoxelsAlongY,
296  voxelYThickness);
297 
298  // Division along Z axis: the slices along the Y axis are divided along the Z axis
299 
300  G4double halfZVoxelSizeX = halfXVoxelSizeX;
301  G4double halfZVoxelSizeY = halfYVoxelSizeY;
302  G4double halfZVoxelSizeZ = halfDetectorSizeZ/numberOfVoxelsAlongZ;
303  G4double voxelZThickness = 2*halfZVoxelSizeZ;
304 
305  RODetectorZDivision = new G4Box("RODetectorZDivision",
306  halfZVoxelSizeX,
307  halfZVoxelSizeY,
308  halfZVoxelSizeZ);
309 
310  RODetectorZDivisionLog = new G4LogicalVolume(RODetectorZDivision,
311  0,
312  "RODetectorZDivisionLog",
313  0,0,0);
314 
315  new G4PVReplica("RODetectorZDivisionPhys",
316  RODetectorZDivisionLog,
317  RODetectorYDivisionPhys,
318  kZAxis,
319  numberOfVoxelsAlongZ,
320  voxelZThickness);
321 
322  sensitiveLogicalVolume = RODetectorZDivisionLog;
323  isBuilt = true;
324 }
G4VPhysicalVolume * GetWorld()
Definition: G4Box.hh:63
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4LogicalVolume * GetLogicalVolume() const
double G4double
Definition: G4Types.hh:76
G4bool isInitialized()
void HadrontherapyDetectorROGeometry::ConstructSD ( )
virtual

Reimplemented from G4VUserParallelWorld.

Definition at line 326 of file HadrontherapyDetectorROGeometry.cc.

References G4VUserParallelWorld::SetSensitiveDetector().

327 {
328 
329  G4String sensitiveDetectorName = "RODetector";
330 
331  HadrontherapyDetectorSD* detectorSD = new HadrontherapyDetectorSD(sensitiveDetectorName);
332 
333  SetSensitiveDetector(sensitiveLogicalVolume,detectorSD);
334 
335 
336 }
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
void HadrontherapyDetectorROGeometry::Initialize ( G4ThreeVector  detectorPos,
G4double  detectorDimX,
G4double  detectorDimY,
G4double  detectorDimZ,
G4int  numberOfVoxelsX,
G4int  numberOfVoxelsY,
G4int  numberOfVoxelsZ 
)

Definition at line 82 of file HadrontherapyDetectorROGeometry.cc.

Referenced by HadrontherapyDetectorConstruction::InitializeDetectorROGeometry(), and HadrontherapyDetectorConstruction::UpdateGeometry().

89 {
90  detectorToWorldPosition = pos;
91  detectorSizeX = detectorDimX;
92  detectorSizeY= detectorDimY;
93  detectorSizeZ=detectorDimZ;
94  numberOfVoxelsAlongX=numberOfVoxelsX;
95  numberOfVoxelsAlongY=numberOfVoxelsY;
96  numberOfVoxelsAlongZ=numberOfVoxelsZ;
97 
98  isInitialized = true;
99 
100 
101 
102 }
G4bool isInitialized()
void HadrontherapyDetectorROGeometry::UpdateROGeometry ( )

Definition at line 104 of file HadrontherapyDetectorROGeometry.cc.

References G4PhysicalVolumeStore::DeRegister(), G4PhysicalVolumeStore::GetInstance(), G4PhysicalVolumeStore::GetVolume(), kXAxis, kYAxis, kZAxis, G4Box::SetXHalfLength(), G4Box::SetYHalfLength(), and G4Box::SetZHalfLength().

Referenced by HadrontherapyDetectorConstruction::UpdateGeometry().

105 {
106  //Nothing happens if the RO geometry is not built. But parameters are properly set.
107  if (!isBuilt)
108  {
109  //G4Exception("HadrontherapyDetectorROGeometry::UpdateROGeometry","had001",
110  // JustWarning,"Cannot update geometry before it is built");
111  return;
112  }
113 
114  //1) Update the dimensions of the G4Boxes
115  G4double halfDetectorSizeX = detectorSizeX;
116  G4double halfDetectorSizeY = detectorSizeY;
117  G4double halfDetectorSizeZ = detectorSizeZ;
118 
119  RODetector->SetXHalfLength(halfDetectorSizeX);
120  RODetector->SetYHalfLength(halfDetectorSizeY);
121  RODetector->SetZHalfLength(halfDetectorSizeZ);
122 
123  G4double halfXVoxelSizeX = halfDetectorSizeX/numberOfVoxelsAlongX;
124  G4double halfXVoxelSizeY = halfDetectorSizeY;
125  G4double halfXVoxelSizeZ = halfDetectorSizeZ;
126  G4double voxelXThickness = 2*halfXVoxelSizeX;
127 
128  RODetectorXDivision->SetXHalfLength(halfXVoxelSizeX);
129  RODetectorXDivision->SetYHalfLength(halfXVoxelSizeY);
130  RODetectorXDivision->SetZHalfLength(halfXVoxelSizeZ);
131 
132  G4double halfYVoxelSizeX = halfXVoxelSizeX;
133  G4double halfYVoxelSizeY = halfDetectorSizeY/numberOfVoxelsAlongY;
134  G4double halfYVoxelSizeZ = halfDetectorSizeZ;
135  G4double voxelYThickness = 2*halfYVoxelSizeY;
136 
137  RODetectorYDivision->SetXHalfLength(halfYVoxelSizeX);
138  RODetectorYDivision->SetYHalfLength(halfYVoxelSizeY);
139  RODetectorYDivision->SetZHalfLength(halfYVoxelSizeZ);
140 
141  G4double halfZVoxelSizeX = halfXVoxelSizeX;
142  G4double halfZVoxelSizeY = halfYVoxelSizeY;
143  G4double halfZVoxelSizeZ = halfDetectorSizeZ/numberOfVoxelsAlongZ;
144  G4double voxelZThickness = 2*halfZVoxelSizeZ;
145 
146  RODetectorZDivision->SetXHalfLength(halfZVoxelSizeX);
147  RODetectorZDivision->SetYHalfLength(halfZVoxelSizeY);
148  RODetectorZDivision->SetZHalfLength(halfZVoxelSizeZ);
149 
150  //Delete and re-build the relevant physical volumes
151  G4PhysicalVolumeStore* store =
153 
154  //Delete...
155  G4VPhysicalVolume* myVol = store->GetVolume("RODetectorPhys");
156  store->DeRegister(myVol);
157  //..and rebuild
158  G4VPhysicalVolume *RODetectorPhys = new G4PVPlacement(0,
159  detectorToWorldPosition,
160  RODetectorLog,
161  "RODetectorPhys",
162  worldLogical,
163  false,0);
164 
165  myVol = store->GetVolume("RODetectorXDivisionPhys");
166  store->DeRegister(myVol);
167  G4VPhysicalVolume *RODetectorXDivisionPhys = new G4PVReplica("RODetectorXDivisionPhys",
168  RODetectorXDivisionLog,
169  RODetectorPhys,
170  kXAxis,
171  numberOfVoxelsAlongX,
172  voxelXThickness);
173  myVol = store->GetVolume("RODetectorYDivisionPhys");
174  store->DeRegister(myVol);
175  G4VPhysicalVolume *RODetectorYDivisionPhys = new G4PVReplica("RODetectorYDivisionPhys",
176  RODetectorYDivisionLog,
177  RODetectorXDivisionPhys,
178  kYAxis,
179  numberOfVoxelsAlongY,
180  voxelYThickness);
181 
182  myVol = store->GetVolume("RODetectorZDivisionPhys");
183  store->DeRegister(myVol);
184  new G4PVReplica("RODetectorZDivisionPhys",
185  RODetectorZDivisionLog,
186  RODetectorYDivisionPhys,
187  kZAxis,
188  numberOfVoxelsAlongZ,
189  voxelZThickness);
190 
191  return;
192 
193 }
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:172
static void DeRegister(G4VPhysicalVolume *pSolid)
static G4PhysicalVolumeStore * GetInstance()
void SetYHalfLength(G4double dy)
Definition: G4Box.cc:152
void SetXHalfLength(G4double dx)
Definition: G4Box.cc:132
double G4double
Definition: G4Types.hh:76
G4VPhysicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const

The documentation for this class was generated from the following files: