File indexing completed on 2025-10-13 08:28:02
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 #include "DetectorMessenger.hh"
0042
0043 #include "G4RunManager.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4VisAttributes.hh"
0046 #include "G4Tubs.hh"
0047
0048
0049
0050 DetectorConstruction::DetectorConstruction(PhysicsList* pl)
0051 {
0052
0053 fDetectorMessenger = new DetectorMessenger(this, pl);
0054
0055
0056 fWorldRadius = 1*um;
0057 fWorldLength = 10*um;
0058
0059
0060 fThicknessCylinders = 1*nm;
0061 fMinRadiusCylinders = 0;
0062
0063 fNumberCylinders = (fWorldRadius-fMinRadiusCylinders) / fThicknessCylinders;
0064
0065
0066 G4NistManager* man = G4NistManager::Instance();
0067 G4Material* H2O = man->FindOrBuildMaterial("G4_WATER");
0068 G4Material* galactic = man->FindOrBuildMaterial("G4_Galactic");
0069
0070 fWaterMaterial = H2O;
0071 fVacuumMaterial = galactic;
0072 }
0073
0074
0075
0076 DetectorConstruction::~DetectorConstruction()
0077 {
0078 delete fDetectorMessenger;
0079 }
0080
0081
0082
0083 void DetectorConstruction::DefineMaterials()
0084 {
0085
0086 G4NistManager* man = G4NistManager::Instance();
0087
0088 G4Material* H2O = man->FindOrBuildMaterial("G4_WATER");
0089 G4Material* galactic = man->FindOrBuildMaterial("G4_Galactic");
0090
0091 fWaterMaterial = H2O;
0092 fVacuumMaterial = galactic;
0093
0094 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0095 }
0096
0097
0098
0099 G4VPhysicalVolume* DetectorConstruction::Construct()
0100 {
0101 if (fPhysiWorld) return fPhysiWorld;
0102
0103
0104
0105 G4Tubs* solidWorld =
0106 new G4Tubs("World", 0., fWorldRadius, fWorldLength / 2, 0., 360*deg);
0107
0108 fLogicWorld = new G4LogicalVolume(solidWorld,
0109 fVacuumMaterial,
0110 "World");
0111
0112 fPhysiWorld = new G4PVPlacement(0,
0113 G4ThreeVector(),
0114 "World",
0115 fLogicWorld,
0116 0,
0117 false,
0118 0);
0119
0120
0121 G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0122 worldVisAtt->SetVisibility(true);
0123 fLogicWorld->SetVisAttributes(worldVisAtt);
0124
0125
0126
0127 fNumberCylinders = (fWorldRadius-fMinRadiusCylinders) / fThicknessCylinders;
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 G4cout << G4endl;
0138 G4cout
0139 << "*******************************************************************"
0140 << G4endl;
0141 G4cout << "*** NUMBER OF HOLLOW CYLINDERS = "<< fNumberCylinders << G4endl;
0142 G4cout
0143 << "*******************************************************************"
0144 << G4endl;
0145 G4cout << G4endl;
0146
0147 for (G4int i = 0; i < fNumberCylinders; i++) {
0148
0149 G4double rIn = i*fThicknessCylinders;
0150 G4double rOut = (i+1) * fThicknessCylinders;
0151
0152 G4Tubs* solidCylinder =
0153 new G4Tubs("Cylinder", rIn, rOut, fWorldLength / 2, 0., 360*deg);
0154
0155 G4LogicalVolume* logicCylinder =
0156 new G4LogicalVolume(solidCylinder, fWaterMaterial, "Cylinder");
0157
0158 new G4PVPlacement(nullptr, G4ThreeVector(0, 0, 0), logicCylinder,
0159 "Cylinder", fLogicWorld, false, i, true);
0160
0161 logicCylinder->SetVisAttributes(worldVisAtt);
0162 }
0163
0164
0165
0166
0167 return fPhysiWorld;
0168 }
0169
0170
0171
0172 void DetectorConstruction::SetMaterial(const G4String& materialChoice)
0173 {
0174 G4Material* pttoMaterial =
0175 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0176
0177 if (pttoMaterial) {
0178 fWaterMaterial = pttoMaterial;
0179 if (fLogicWorld) fLogicWorld->SetMaterial(fWaterMaterial);
0180 }
0181 }
0182
0183
0184
0185 void DetectorConstruction::SetWorldRadius(const G4double& value)
0186 {
0187 fWorldRadius = value;
0188 }
0189
0190
0191
0192 void DetectorConstruction::SetWorldLength(const G4double& value)
0193 {
0194 fWorldLength = value;
0195 }
0196
0197
0198
0199 void DetectorConstruction::SetThicknessCylinders(const G4double& value)
0200 {
0201 fThicknessCylinders = value;
0202 }
0203
0204
0205
0206 void DetectorConstruction::SetMinRadiusCylinders(const G4double& value)
0207 {
0208 fMinRadiusCylinders = value;
0209 }