File indexing completed on 2025-02-23 09:21:46
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 #include "DetectorConstruction.hh"
0035
0036 #include "DetectorMessenger.hh"
0037
0038 #include "G4Colour.hh"
0039 #include "G4GeometryManager.hh"
0040 #include "G4LogicalVolume.hh"
0041 #include "G4LogicalVolumeStore.hh"
0042 #include "G4MultiFunctionalDetector.hh"
0043 #include "G4NistManager.hh"
0044 #include "G4PSDoseDeposit.hh"
0045 #include "G4PSEnergyDeposit.hh"
0046 #include "G4PVParameterised.hh"
0047 #include "G4PVPlacement.hh"
0048 #include "G4PVReplica.hh"
0049 #include "G4PhysicalConstants.hh"
0050 #include "G4PhysicalVolumeStore.hh"
0051 #include "G4ProductionCuts.hh"
0052 #include "G4RunManager.hh"
0053 #include "G4SDManager.hh"
0054 #include "G4SolidStore.hh"
0055 #include "G4Sphere.hh"
0056 #include "G4SubtractionSolid.hh"
0057 #include "G4SystemOfUnits.hh"
0058 #include "G4Tubs.hh"
0059 #include "G4UnitsTable.hh"
0060 #include "G4UserLimits.hh"
0061 #include "G4VPhysicalVolume.hh"
0062 #include "G4VPrimitiveScorer.hh"
0063 #include "G4VSensitiveDetector.hh"
0064 #include "G4VisAttributes.hh"
0065
0066
0067
0068 DetectorConstruction::DetectorConstruction()
0069 : G4VUserDetectorConstruction(),
0070 fNPRadius(0),
0071 fAbsRadius(0),
0072 fNPMaterial(0),
0073 fAbsMaterial(0),
0074 pWorld(0),
0075 fNP(0),
0076 fAbs(0),
0077 fDetectorMessenger(0),
0078 fRegion(0)
0079 {
0080
0081 fTrackingCut = 10.0 * eV;
0082
0083
0084 fNPRadius = 50 * nm;
0085 fAbsRadius = 100000 * nm + fNPRadius;
0086
0087 fNreplicaR = 1000;
0088 fNreplicaAzm = 360;
0089
0090 DefineMaterials();
0091 SetNPMaterial("G4_Au");
0092 SetAbsMaterial("G4_WATER");
0093
0094
0095 fDetectorMessenger = new DetectorMessenger(this);
0096 }
0097
0098
0099
0100 DetectorConstruction::~DetectorConstruction()
0101 {
0102 delete fDetectorMessenger;
0103 }
0104
0105
0106
0107 G4VPhysicalVolume* DetectorConstruction::Construct()
0108 {
0109 return ConstructVolumes();
0110 }
0111
0112
0113
0114 void DetectorConstruction::DefineMaterials()
0115 {
0116 G4NistManager* man = G4NistManager::Instance();
0117
0118 man->FindOrBuildMaterial("G4_Au");
0119 man->FindOrBuildMaterial("G4_WATER");
0120 }
0121
0122
0123
0124 G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
0125 {
0126 const G4bool check_overlap = false;
0127 G4GeometryManager::GetInstance()->OpenGeometry();
0128 G4PhysicalVolumeStore::GetInstance()->Clean();
0129 G4LogicalVolumeStore::GetInstance()->Clean();
0130 G4SolidStore::GetInstance()->Clean();
0131
0132
0133 G4Material* Vacuum = new G4Material("Galactic", 1., 1.01 * g / mole, universe_mean_density,
0134 kStateGas, 2.73 * kelvin, 3.e-18 * pascal);
0135
0136 G4Sphere* sWorld = new G4Sphere("World", 0., fAbsRadius * 1.5, 0., 2 * pi * rad, 0., pi);
0137 G4LogicalVolume* lWorld = new G4LogicalVolume(sWorld, Vacuum, "World");
0138 pWorld = new G4PVPlacement(0, G4ThreeVector(), lWorld, "World", 0, false, 0);
0139
0140
0141 G4Sphere* sNP = new G4Sphere("NanoParticle", 0., fNPRadius, 0., 2 * pi * rad, 0., pi);
0142
0143 fLogicalNP = new G4LogicalVolume(sNP, fNPMaterial, "NanoParticle");
0144
0145 fNP = new G4PVPlacement(0, G4ThreeVector(), fLogicalNP, "NanoParticle", lWorld, false, 0,
0146 check_overlap);
0147
0148
0149
0150
0151 G4Sphere* sAbsorber0 = new G4Sphere("Absorber0", 0., fAbsRadius * 1.2, 0., 2 * pi * rad, 0., pi);
0152 G4VSolid* sAbsorber = new G4SubtractionSolid("Absorber", sAbsorber0, sNP, 0, G4ThreeVector());
0153
0154 fLogicalAbs = new G4LogicalVolume(sAbsorber, fAbsMaterial, "Absorber");
0155 fAbs =
0156 new G4PVPlacement(0, G4ThreeVector(), fLogicalAbs, "Absorber", lWorld, false, 0, check_overlap);
0157
0158
0159 G4VisAttributes* visWorld = new G4VisAttributes(true, G4Colour::Gray());
0160 G4VisAttributes* visNP = new G4VisAttributes(true, G4Colour::Yellow());
0161 G4VisAttributes* visAbs = new G4VisAttributes(true, G4Colour::Cyan());
0162
0163 lWorld->SetVisAttributes(visWorld);
0164 fLogicalNP->SetVisAttributes(visNP);
0165 fLogicalAbs->SetVisAttributes(visAbs);
0166
0167 PrintParameters();
0168
0169 G4double maxStep = fNPRadius / 2.;
0170 fLogicalNP->SetUserLimits(new G4UserLimits(maxStep, DBL_MAX, DBL_MAX, fTrackingCut));
0171
0172 fRegion = new G4Region("NP");
0173
0174 G4ProductionCuts* cuts = new G4ProductionCuts();
0175 G4double defCut = 0.1 * nm;
0176 cuts->SetProductionCut(defCut, "gamma");
0177 cuts->SetProductionCut(defCut, "e-");
0178 cuts->SetProductionCut(defCut, "e+");
0179 cuts->SetProductionCut(defCut, "proton");
0180 fRegion->SetProductionCuts(cuts);
0181 fRegion->AddRootLogicalVolume(fLogicalNP);
0182
0183 return pWorld;
0184 }
0185
0186
0187
0188 void DetectorConstruction::PrintParameters() const
0189 {
0190 G4cout << "\n=========================================================\n";
0191 G4cout << "---> The tracking cut to all particles is set to "
0192 << G4BestUnit(fTrackingCut, "Energy") << G4endl;
0193 G4cout << "\n---------------------------------------------------------\n";
0194 G4cout << "---> The Nano-Particle is a sphere of " << G4BestUnit(fNPRadius, "Length")
0195 << " radius of " << fNPMaterial->GetName() << " made of"
0196 << "\n \n"
0197 << fNPMaterial << G4endl;
0198 G4cout << "\n---------------------------------------------------------\n";
0199 G4cout << "---> The Absorber is a sphere of " << G4BestUnit(fAbsRadius, "Length") << " radius of "
0200 << fAbsMaterial->GetName() << " made of"
0201 << "\n \n"
0202 << fAbsMaterial << G4endl;
0203 G4cout << "\n=========================================================\n";
0204 }
0205
0206
0207
0208 void DetectorConstruction::SetTrackingCut(G4double value)
0209 {
0210 fTrackingCut = value;
0211 G4RunManager::GetRunManager()->ReinitializeGeometry();
0212 }
0213
0214
0215
0216 void DetectorConstruction::SetAbsRadius(G4double value)
0217 {
0218 fAbsRadius = value;
0219 G4RunManager::GetRunManager()->ReinitializeGeometry();
0220 }
0221
0222 void DetectorConstruction::SetNPRadius(G4double value)
0223 {
0224 fNPRadius = value;
0225 G4RunManager::GetRunManager()->ReinitializeGeometry();
0226 }
0227
0228
0229
0230 void DetectorConstruction::SetAbsMaterial(G4String materialChoice)
0231 {
0232 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
0233 if (pttoMaterial) fAbsMaterial = pttoMaterial;
0234 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0235 }
0236
0237 void DetectorConstruction::SetNPMaterial(G4String materialChoice)
0238 {
0239 G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
0240 if (pttoMaterial) fNPMaterial = pttoMaterial;
0241 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0242 }
0243
0244
0245
0246 void DetectorConstruction::SetNReplicaR(G4int value)
0247 {
0248 fNreplicaR = value;
0249 G4RunManager::GetRunManager()->ReinitializeGeometry();
0250 }
0251 void DetectorConstruction::SetNReplicaAzm(G4int value)
0252 {
0253 fNreplicaAzm = value;
0254 G4RunManager::GetRunManager()->ReinitializeGeometry();
0255 }