Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
TSDetectorConstruction Class Reference

#include <Doxymodules_parallel.h>

Inheritance diagram for TSDetectorConstruction:
G4VUserDetectorConstruction

Public Types

typedef std::map< G4String, G4Material * > MaterialCollection_t
 
typedef std::set< G4LogicalVolume * > ScoringVolumes_t
 

Public Member Functions

 TSDetectorConstruction ()
 
virtual ~TSDetectorConstruction ()
 
G4VPhysicalVolumeConstruct ()
 
const G4ThreeVector & GetWorldDimensions () const
 
const ScoringVolumes_tGetScoringVolumes () const
 
const G4StringGetMFDName () const
 
G4int GetTotalTargets () const
 

Static Public Member Functions

static TSDetectorConstructionInstance ()
 

Protected Member Functions

virtual MaterialCollection_t ConstructMaterials ()
 
virtual G4VPhysicalVolumeConstructWorld (const MaterialCollection_t &)
 
virtual void ConstructSDandField ()
 

Private Attributes

G4VPhysicalVolumefWorldPhys
 
ScoringVolumes_t fScoringVolumes
 
G4String fWorldMaterialName
 
G4String fTargetMaterialName
 
G4String fCasingMaterialName
 
G4ThreeVector fWorldDim
 
G4ThreeVector fTargetDim
 
G4ThreeVector fTargetSections
 
G4String fMfdName
 

Static Private Attributes

static TSDetectorConstructionfgInstance = 0
 

Detailed Description

Definition at line 146 of file Doxymodules_parallel.h.

Member Typedef Documentation

◆ MaterialCollection_t

Definition at line 74 of file TSDetectorConstruction.hh.

◆ ScoringVolumes_t

Definition at line 75 of file TSDetectorConstruction.hh.

Constructor & Destructor Documentation

◆ TSDetectorConstruction()

TSDetectorConstruction::TSDetectorConstruction ( )

Definition at line 88 of file TSDetectorConstruction.cc.

89 : fWorldPhys(0)
90 , fWorldMaterialName("G4_Galactic")
91 , fTargetMaterialName("G4_B")
92 , fCasingMaterialName("G4_WATER")
93 , fWorldDim(G4ThreeVector(0.5 * m, 0.5 * m, 0.5 * m))
94 , fTargetDim(G4ThreeVector(0.5 * m, 0.5 * m, 0.5 * m))
95 , fTargetSections(G4ThreeVector(5, 5, 5))
96 , fMfdName("Target_MFD")
97{
98 fgInstance = this;
99}
static TSDetectorConstruction * fgInstance

◆ ~TSDetectorConstruction()

TSDetectorConstruction::~TSDetectorConstruction ( )
virtual

Definition at line 103 of file TSDetectorConstruction.cc.

103{ fgInstance = 0; }

Member Function Documentation

◆ Instance()

TSDetectorConstruction * TSDetectorConstruction::Instance ( )
static

Definition at line 81 of file TSDetectorConstruction.cc.

82{
83 return fgInstance;
84}

◆ Construct()

G4VPhysicalVolume * TSDetectorConstruction::Construct ( )

Definition at line 107 of file TSDetectorConstruction.cc.

108{
110}
virtual G4VPhysicalVolume * ConstructWorld(const MaterialCollection_t &)
virtual MaterialCollection_t ConstructMaterials()

◆ GetWorldDimensions()

const G4ThreeVector & TSDetectorConstruction::GetWorldDimensions ( ) const
inline

Definition at line 85 of file TSDetectorConstruction.hh.

85{ return fWorldDim; }

◆ GetScoringVolumes()

const ScoringVolumes_t & TSDetectorConstruction::GetScoringVolumes ( ) const
inline

Definition at line 86 of file TSDetectorConstruction.hh.

87 {
88 return fScoringVolumes;
89 }

◆ GetMFDName()

const G4String & TSDetectorConstruction::GetMFDName ( ) const
inline

Definition at line 90 of file TSDetectorConstruction.hh.

90{ return fMfdName; }

◆ GetTotalTargets()

G4int TSDetectorConstruction::GetTotalTargets ( ) const
inline

Definition at line 91 of file TSDetectorConstruction.hh.

92 {
93 return fTargetSections.x() * fTargetSections.y() * fTargetSections.z();
94 }

◆ ConstructMaterials()

TSDetectorConstruction::MaterialCollection_t TSDetectorConstruction::ConstructMaterials ( )
protectedvirtual

Definition at line 115 of file TSDetectorConstruction.cc.

116{
117 MaterialCollection_t materials;
118 G4NistManager* nist = G4NistManager::Instance();
119
120 materials["World"] = nist->FindOrBuildMaterial(fWorldMaterialName);
121 materials["Target"] = nist->FindOrBuildMaterial(fTargetMaterialName);
122 materials["Casing"] = nist->FindOrBuildMaterial(fCasingMaterialName);
123
124 return materials;
125}
std::map< G4String, G4Material * > MaterialCollection_t

◆ ConstructWorld()

G4VPhysicalVolume * TSDetectorConstruction::ConstructWorld ( const MaterialCollection_t materials)
protectedvirtual

Definition at line 129 of file TSDetectorConstruction.cc.

131{
132 G4UserLimits* steplimit =
133 new G4UserLimits(0.1 * (fTargetDim.z() / fTargetSections.z()));
134 G4bool check_overlap = false;
135
136 G4Box* world_solid = new G4Box("World", 0.5 * fWorldDim.x(),
137 0.5 * fWorldDim.y(), 0.5 * fWorldDim.z());
138 G4LogicalVolume* world_log =
139 new G4LogicalVolume(world_solid, materials.find("World")->second, "World");
140 fWorldPhys = new G4PVPlacement(0, G4ThreeVector(0.), "World", world_log, 0,
141 false, 0, check_overlap);
142
143 G4int nz = fTargetSections.z();
144 G4int ny = fTargetSections.y();
145 G4int nx = fTargetSections.x();
146
147 // spacing between sections
148 G4double sx = fTargetDim.x() / fTargetSections.x();
149 G4double sy = fTargetDim.y() / fTargetSections.y();
150 G4double sz = fTargetDim.z() / fTargetSections.z();
151
152 // G4cout << "World has dimensions : "
153 //<< G4BestUnit(fWorldDim, "Length") << G4endl;
154
155 //------------------------------------------------------------------------//
156 // Set Visual Attributes
157 //------------------------------------------------------------------------//
158 G4VisAttributes* red = new G4VisAttributes(G4Color(1., 0., 0., 1.0));
159 G4VisAttributes* green = new G4VisAttributes(G4Color(0., 1., 0., 0.25));
160 G4VisAttributes* blue = new G4VisAttributes(G4Color(0., 0., 1., 0.1));
161 G4VisAttributes* white = new G4VisAttributes(G4Color(1., 1., 1., 1.));
162
163 white->SetVisibility(true);
164 red->SetVisibility(true);
165 green->SetVisibility(true);
166 blue->SetVisibility(true);
167
168 white->SetForceWireframe(true);
169 red->SetForceSolid(true);
170 green->SetForceSolid(true);
171 blue->SetForceSolid(true);
172
173 world_log->SetVisAttributes(white);
174
175 for(G4int k = 0; k < nz; ++k)
176 for(G4int j = 0; j < ny; ++j)
177 for(G4int i = 0; i < nx; ++i)
178 {
179 // displacement of section
180 G4double dx =
181 0.5 * sx + static_cast<G4double>(i) * sx - 0.5 * fWorldDim.x();
182 G4double dy =
183 0.5 * sy + static_cast<G4double>(j) * sy - 0.5 * fWorldDim.y();
184 G4double dz =
185 0.5 * sz + static_cast<G4double>(k) * sz - 0.5 * fWorldDim.z();
186 G4ThreeVector td = G4ThreeVector(dx, dy, -dz);
187 // make unique name
188 std::stringstream ss_name;
189 ss_name << "Target_" << i << "_" << j << "_" << k;
190
191 G4Box* target_solid =
192 new G4Box(ss_name.str(), 0.5 * sx, 0.5 * sy, 0.5 * sz);
193
194 G4Material* target_material = 0;
195 G4bool is_casing = true;
196
197 if(j == 0 || j + 1 == ny || i == 0 || i + 1 == nx ||
198 (nz > 1 && (k == 0 || k + 1 == nz)))
199 target_material = materials.find("Casing")->second;
200 else
201 {
202 target_material = materials.find("Target")->second;
203 is_casing = false;
204 }
205
206 G4LogicalVolume* target_log =
207 new G4LogicalVolume(target_solid, target_material, ss_name.str());
208
209 target_log->SetUserLimits(steplimit);
210
211 new G4PVPlacement(0, td, ss_name.str(), target_log, fWorldPhys, true,
212 k * nx * ny + j * nx + i, check_overlap);
213
214 fScoringVolumes.insert(target_log);
215
216 if(is_casing)
217 target_log->SetVisAttributes(blue);
218 else
219 {
220 // making a checkerboard for kicks...
221 G4bool even_z = (k % 2 == 0) ? true : false;
222 G4bool even_y = (j % 2 == 0) ? true : false;
223 G4bool even_x = (i % 2 == 0) ? true : false;
224
225 G4VisAttributes* theColor = nullptr;
226
227 if((even_z))
228 {
229 if((even_y && even_x) || (!even_y && !even_x))
230 theColor = red;
231 else
232 theColor = green;
233 }
234 else // ! even_z
235 {
236 if((!even_y && even_x) || (even_y && !even_x))
237 theColor = red;
238 else
239 theColor = green;
240 }
241
242 target_log->SetVisAttributes(theColor);
243 }
244 }
245
246 return fWorldPhys;
247}

◆ ConstructSDandField()

void TSDetectorConstruction::ConstructSDandField ( )
protectedvirtual

Definition at line 251 of file TSDetectorConstruction.cc.

252{
253 //------------------------------------------------//
254 // MultiFunctionalDetector //
255 //------------------------------------------------//
256 // Define MultiFunctionalDetector with name.
258 G4SDManager::GetSDMpointer()->AddNewDetector(MFDet);
259 G4VPrimitiveScorer* edep = new G4PSEnergyDeposit("EnergyDeposit");
260 MFDet->RegisterPrimitive(edep);
261 G4VPrimitiveScorer* nstep = new G4PSNofStep("NumberOfSteps");
262 MFDet->RegisterPrimitive(nstep);
263
264 // add scoring volumes
265 for(auto ite : fScoringVolumes)
266 {
267 SetSensitiveDetector(ite, MFDet);
268 }
269}

Member Data Documentation

◆ fgInstance

TSDetectorConstruction * TSDetectorConstruction::fgInstance = 0
staticprivate

Definition at line 102 of file TSDetectorConstruction.hh.

◆ fWorldPhys

G4VPhysicalVolume* TSDetectorConstruction::fWorldPhys
private

Definition at line 103 of file TSDetectorConstruction.hh.

◆ fScoringVolumes

ScoringVolumes_t TSDetectorConstruction::fScoringVolumes
private

Definition at line 104 of file TSDetectorConstruction.hh.

◆ fWorldMaterialName

G4String TSDetectorConstruction::fWorldMaterialName
private

Definition at line 105 of file TSDetectorConstruction.hh.

◆ fTargetMaterialName

G4String TSDetectorConstruction::fTargetMaterialName
private

Definition at line 106 of file TSDetectorConstruction.hh.

◆ fCasingMaterialName

G4String TSDetectorConstruction::fCasingMaterialName
private

Definition at line 107 of file TSDetectorConstruction.hh.

◆ fWorldDim

G4ThreeVector TSDetectorConstruction::fWorldDim
private

Definition at line 108 of file TSDetectorConstruction.hh.

◆ fTargetDim

G4ThreeVector TSDetectorConstruction::fTargetDim
private

Definition at line 109 of file TSDetectorConstruction.hh.

◆ fTargetSections

G4ThreeVector TSDetectorConstruction::fTargetSections
private

Definition at line 110 of file TSDetectorConstruction.hh.

◆ fMfdName

G4String TSDetectorConstruction::fMfdName
private

Definition at line 111 of file TSDetectorConstruction.hh.


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

Applications | User Support | Publications | Collaboration