File indexing completed on 2026-09-23 08:29:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 #include "DetectorConstruction.hh"
0041
0042 #include "DetectorMessenger.hh"
0043
0044 #include "G4NistManager.hh"
0045 #include "G4PVPlacement.hh"
0046 #include "G4PhysicalConstants.hh"
0047 #include "G4RunManager.hh"
0048 #include "G4Sphere.hh"
0049 #include "G4UnitsTable.hh"
0050 #include "G4UserLimits.hh"
0051
0052
0053
0054 DetectorConstruction::DetectorConstruction() : G4VUserDetectorConstruction()
0055 {
0056
0057
0058 fTrackingCut = 7.4 * CLHEP::eV;
0059
0060
0061
0062 fWorldRadius = 10 * CLHEP::m;
0063 fCytoThickness = 20 * CLHEP::nm;
0064 fNuclRadius = 10 * CLHEP::nm;
0065
0066 DefineMaterials();
0067
0068
0069
0070 fDetectorMessenger = new DetectorMessenger(this);
0071 }
0072
0073
0074
0075 DetectorConstruction::~DetectorConstruction()
0076 {
0077 delete fDetectorMessenger;
0078 }
0079
0080
0081
0082 void DetectorConstruction::DefineMaterials()
0083 {
0084 G4NistManager* man = G4NistManager::Instance();
0085
0086 fWorldMaterial = man->FindOrBuildMaterial("G4_WATER");
0087 fCytoMaterial = fNuclMaterial = man->FindOrBuildMaterial("G4_WATER");
0088 }
0089
0090
0091
0092 G4VPhysicalVolume* DetectorConstruction::Construct()
0093 {
0094 if (fWorld) return fWorld;
0095
0096
0097
0098 G4Sphere* sWorld = new G4Sphere("World", 0., 1000 * fNuclRadius, 0., twopi, 0., pi);
0099
0100 fLogicalWorld = new G4LogicalVolume(sWorld, fWorldMaterial, "World");
0101
0102 fWorld = new G4PVPlacement(0, G4ThreeVector(), fLogicalWorld, "World", 0, false, 0);
0103
0104
0105
0106 G4Sphere* sNucl = new G4Sphere("Nucl", 0., fNuclRadius, 0., twopi, 0., pi);
0107
0108 fLogicalNucl = new G4LogicalVolume(sNucl, fNuclMaterial, "Nucl");
0109
0110 fNucl = new G4PVPlacement(0, G4ThreeVector(), "Nucl", fLogicalNucl, fWorld, false, 0);
0111
0112
0113
0114 G4Sphere* sCyto =
0115 new G4Sphere("Cyto", fNuclRadius, fNuclRadius + fCytoThickness, 0., twopi, 0., pi);
0116
0117 fLogicalCyto = new G4LogicalVolume(sCyto, fCytoMaterial, "Cyto");
0118
0119 fCyto = new G4PVPlacement(0, G4ThreeVector(), "Cyto", fLogicalCyto, fWorld, false, 0);
0120
0121
0122 PrintParameters();
0123
0124
0125
0126 fLogicalNucl->SetUserLimits(new G4UserLimits(DBL_MAX, DBL_MAX, DBL_MAX, fTrackingCut));
0127 fLogicalCyto->SetUserLimits(new G4UserLimits(DBL_MAX, DBL_MAX, DBL_MAX, fTrackingCut));
0128 fLogicalWorld->SetUserLimits(new G4UserLimits(DBL_MAX, DBL_MAX, DBL_MAX, fTrackingCut));
0129
0130
0131 return fWorld;
0132 }
0133
0134
0135
0136 void DetectorConstruction::PrintParameters() const
0137 {
0138 G4cout << "\n---------------------------------------------------------\n";
0139 G4cout << "---> The tracking cut is set to " << G4BestUnit(fTrackingCut, "Energy") << G4endl;
0140 G4cout << "---> The World is a sphere of " << G4BestUnit(1000 * fNuclRadius, "Length")
0141 << "radius of " << fWorldMaterial->GetName() << G4endl;
0142 G4cout << "---> The Nucleus is a sphere of " << G4BestUnit(fNuclRadius, "Length") << "radius of "
0143 << fWorldMaterial->GetName() << " of mass " << G4BestUnit(GetNuclMass(), "Mass") << G4endl;
0144 G4cout << "---> The Cytoplasm is a spherical shell of thickness "
0145 << G4BestUnit(fCytoThickness, "Length") << "of " << fWorldMaterial->GetName()
0146 << " of mass " << G4BestUnit(GetCytoMass(), "Mass") << G4endl;
0147 G4cout << "\n---------------------------------------------------------\n";
0148 }
0149
0150
0151
0152 void DetectorConstruction::SetTrackingCut(G4double value)
0153 {
0154 fTrackingCut = value;
0155 }
0156
0157
0158
0159 void DetectorConstruction::SetNuclRadius(G4double value)
0160 {
0161 fNuclRadius = value;
0162 }
0163
0164
0165
0166 void DetectorConstruction::SetCytoThickness(G4double value)
0167 {
0168 fCytoThickness = value;
0169 }
0170
0171
0172
0173 void DetectorConstruction::SetWorldMaterial(const G4String& materialChoice)
0174 {
0175
0176 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0177
0178 if (pttoMaterial && pttoMaterial != fWorldMaterial) {
0179 fWorldMaterial = pttoMaterial;
0180 if (fLogicalWorld) fLogicalWorld->SetMaterial(pttoMaterial);
0181 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0182 }
0183 }
0184
0185
0186
0187 void DetectorConstruction::SetCytoMaterial(const G4String& materialChoice)
0188 {
0189
0190 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0191
0192 if (pttoMaterial && pttoMaterial != fCytoMaterial) {
0193 fCytoMaterial = pttoMaterial;
0194 if (fLogicalCyto) fLogicalCyto->SetMaterial(pttoMaterial);
0195 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0196 }
0197 }
0198
0199
0200
0201 void DetectorConstruction::SetNuclMaterial(const G4String& materialChoice)
0202 {
0203
0204 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0205
0206 if (pttoMaterial && pttoMaterial != fNuclMaterial) {
0207 fNuclMaterial = pttoMaterial;
0208 if (fLogicalNucl) fLogicalNucl->SetMaterial(pttoMaterial);
0209 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0210 }
0211 }