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