Loading...
Searching...
No Matches
DetectorConstruction.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//
27/// \file radiobiology/src/DetectorConstruction.cc
28/// \brief Implementation of the RadioBio::DetectorConstruction class
29
30#include "DetectorConstruction.hh"
31
32#include "G4Box.hh"
33#include "G4GeometryManager.hh"
34#include "G4LogicalVolume.hh"
35#include "G4LogicalVolumeStore.hh"
36#include "G4Material.hh"
37#include "G4NistManager.hh"
38#include "G4PVPlacement.hh"
39#include "G4PhysicalVolumeStore.hh"
40#include "G4RunManager.hh"
41#include "G4SolidStore.hh"
42#include "G4SystemOfUnits.hh"
43#include "G4UnitsTable.hh"
44
45#include "DetectorMessenger.hh"
47
48#include <sstream>
49
50namespace RadioBio
51{
52
53//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54
56{
57 // Set the default box material
58 SetMaterial("G4_WATER");
59
60 // Create the messenger
62
63 // Voxelize the detecctor with default size
64 VoxelizedSensitiveDetector::CreateInstance(this, 0.1 * m, 1 * m, 1 * m);
65}
66
67//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68
73
74//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
75
80
81//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82
87
88//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89
91{
92 // Cleanup old geometry
93 G4GeometryManager::GetInstance()->OpenGeometry();
94 G4PhysicalVolumeStore::GetInstance()->Clean();
95 G4LogicalVolumeStore::GetInstance()->Clean();
96 G4SolidStore::GetInstance()->Clean();
97
98 G4Box* sBox = new G4Box("Container", // its name
99 fBoxSizeX / 2, fBoxSizeY / 2, fBoxSizeZ / 2); // its dimensions
100
101 fLBox = new G4LogicalVolume(sBox, // its shape
102 fMaterial, // its material
103 fMaterial->GetName()); // its name
104
105 fPBox = new G4PVPlacement(0, // no rotation
106 G4ThreeVector(), // at (0,0,0)
107 fLBox, // its logical volume
108 fMaterial->GetName(), // its name
109 0, // its mother volume
110 false, // no boolean operation
111 0); // copy number
112
113 // Parameters for the world volume can be printed
114 // PrintParameters();
115
116 // Initialize pointer to world for voxelization
118
119 // Create Voxelized Geometry
121
122 // Always return the root volume
123 return fPBox;
124}
125
126//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127
129{
130 G4cout << "\n The Box dimensions are: " << G4endl << "x: " << G4BestUnit(fBoxSizeX, "Length")
131 << G4endl << "y: " << G4BestUnit(fBoxSizeY, "Length") << G4endl
132 << "z: " << G4BestUnit(fBoxSizeZ, "Length") << G4endl;
133
134 G4cout << "And its volume therefore is: "
135 << fPBox->GetLogicalVolume()->GetSolid()->GetCubicVolume() / m3 << " m3" << G4endl;
136}
137
138//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139
141{
142 // Search the material by its name
143 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
144
145 if (pttoMaterial) {
146 if (fMaterial != pttoMaterial) {
147 fMaterial = pttoMaterial;
148 if (fLBox) {
149 fLBox->SetMaterial(pttoMaterial);
150 }
151 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
152 }
153 }
154 else {
155 // Warning the user this material does not exist
156 std::stringstream sstr;
157 sstr << "material " << +materialChoice << " does not exist, keeping material "
158 << fMaterial->GetName();
159
160 G4Exception("DetectorConstruction::SetMaterial", "NoWorldMat", JustWarning, sstr.str().c_str());
161 }
162}
163
164//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
165
167{
168 SetSizeX(value);
169 SetSizeY(value);
170 SetSizeZ(value);
171}
172
173//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
174
175void DetectorConstruction::SetSize(G4ThreeVector size)
176{
177 SetSizeX(size.getX());
178 SetSizeY(size.getY());
179 SetSizeZ(size.getZ());
180}
181
182//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
183
185{
186 fBoxSizeX = sizeX;
187}
188
189//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
190
192{
193 fBoxSizeY = sizeY;
194}
195
196//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
197
199{
200 fBoxSizeZ = sizeZ;
201}
202
203//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
204
205} // namespace RadioBio
Definition of the RadioBio::VoxelizedSensitiveDetector class.
G4VPhysicalVolume * Construct() override
Method overriding pure virtual G4VUserDetectorConstruction one.
void PrintParameters()
Prints on screen some parameters for this class.
G4VPhysicalVolume * ConstructVolumes()
Private method to construct geometry.
void SetSizeY(G4double y)
Method to set the Y width of the world volume.
void SetSize(G4double)
Method to set the world volume to be cubical with given side.
void SetSizeZ(G4double z)
Method to set the Z width of the world volume.
void SetSizeX(G4double x)
Method to set the X width of the world volume.
void ConstructSDandField() override
Method overriding pure virtual G4VUserDetectorConstruction one.
void SetMaterial(G4String mat)
Method to set the world material.
void InitializeWorldPtr(G4VPhysicalVolume *pWorld)
Method to properly initialize the pointer to the World physical volume.
static VoxelizedSensitiveDetector * GetInstance()
Static method to retrieve a pointer to the only object existing in the simulation.
void ConstructSD()
Method to make the proper volume sensitive to allow scoring.
static VoxelizedSensitiveDetector * CreateInstance(DetectorConstruction *det, double xWidth, double yWidth, double zWidth)
Static method to create the pointer to the only object existing in the simulation.
void Construct()
Method to construct all the volumes for the voxelization of the geometry.

Applications | User Support | Publications | Collaboration