File indexing completed on 2026-09-14 08:28:31
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 #include "DetectorConstruction.hh"
0039
0040 #include "DetectorMessenger.hh"
0041
0042 #include "G4ProductionCuts.hh"
0043 #include "G4RunManager.hh"
0044 #include "G4SystemOfUnits.hh"
0045
0046
0047
0048 DetectorConstruction::DetectorConstruction() : G4VUserDetectorConstruction()
0049 {
0050
0051 fDetectorMessenger = new DetectorMessenger(this);
0052 }
0053
0054
0055
0056 DetectorConstruction::~DetectorConstruction()
0057 {
0058 delete fDetectorMessenger;
0059 }
0060
0061
0062
0063 G4VPhysicalVolume* DetectorConstruction::Construct()
0064
0065 {
0066 DefineMaterials();
0067 return ConstructDetector();
0068 }
0069
0070
0071
0072 void DetectorConstruction::DefineMaterials()
0073 {
0074
0075 G4NistManager* man = G4NistManager::Instance();
0076 G4Material* H2O = man->FindOrBuildMaterial("G4_WATER");
0077
0078
0079 fpWaterMaterial = H2O;
0080
0081
0082
0083 G4double z, a, density;
0084 G4String name, symbol;
0085 G4int nComponents, nAtoms;
0086
0087 a = 12.0107 * g / mole;
0088 G4Element* elC = new G4Element(name = "Carbon", symbol = "C", z = 6., a);
0089
0090 a = 1.00794 * g / mole;
0091 G4Element* elH = new G4Element(name = "Hydrogen", symbol = "H", z = 1., a);
0092
0093 a = 15.9994 * g / mole;
0094 G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a);
0095
0096 a = 14.0067 * g / mole;
0097 G4Element* elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a);
0098
0099
0100
0101 density = 1.346 * g / cm3;
0102
0103 fpTHFMaterial = new G4Material("THF", density, nComponents = 3);
0104 fpTHFMaterial->AddElement(elC, nAtoms = 4);
0105 fpTHFMaterial->AddElement(elH, nAtoms = 8);
0106 fpTHFMaterial->AddElement(elO, nAtoms = 1);
0107
0108
0109
0110 density = 0.34e-6 * g / cm3;
0111
0112 fpN2Material = new G4Material("N2", density, nComponents = 1);
0113 fpN2Material->AddElement(elN, nAtoms = 2);
0114 }
0115
0116
0117
0118 G4VPhysicalVolume* DetectorConstruction::ConstructDetector()
0119 {
0120 G4double diameter;
0121 G4double highz;
0122 G4Material* targetMaterial;
0123 G4Material* worldMaterial;
0124
0125 if (fGeomType == "dna") {
0126
0127 fWorldSize = 20. * nm;
0128 diameter = 2.3 * nm;
0129 highz = 3.4 * nm;
0130 targetMaterial = fpTHFMaterial;
0131 worldMaterial = fpWaterMaterial;
0132 }
0133 else {
0134
0135 fWorldSize = 2 * cm;
0136 diameter = 1 * cm;
0137 highz = 1 * cm;
0138 ;
0139 targetMaterial = fpN2Material;
0140 worldMaterial = fpN2Material;
0141 }
0142
0143 fpSolidWorld = new G4Box("World",
0144 fWorldSize / 2, fWorldSize / 2, fWorldSize / 2);
0145
0146 fpLogicWorld = new G4LogicalVolume(fpSolidWorld,
0147 worldMaterial,
0148 "World");
0149
0150 fpPhysiWorld = new G4PVPlacement(0,
0151 G4ThreeVector(),
0152 "World",
0153 fpLogicWorld,
0154 0,
0155 false,
0156 0);
0157
0158 G4Tubs* solidTarget =
0159 new G4Tubs("Target", 0, diameter / 2., highz / 2., 0 * degree, 360 * degree);
0160
0161 G4LogicalVolume* logicTarget = new G4LogicalVolume(solidTarget,
0162 targetMaterial,
0163 "Target");
0164
0165 new G4PVPlacement(0,
0166 G4ThreeVector(),
0167 "Target",
0168 logicTarget,
0169 fpPhysiWorld,
0170 false,
0171 0);
0172
0173
0174 G4VisAttributes* worldVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0175 worldVisAtt->SetVisibility(true);
0176 fpLogicWorld->SetVisAttributes(worldVisAtt);
0177
0178 G4VisAttributes* worldVisAtt1 = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
0179 worldVisAtt1->SetVisibility(true);
0180 logicTarget->SetVisAttributes(worldVisAtt1);
0181
0182 return fpPhysiWorld;
0183 }
0184
0185
0186
0187 void DetectorConstruction::SetGeometry(const G4String& name)
0188 {
0189 fGeomType = name;
0190
0191
0192 G4RunManager::GetRunManager()->GeometryHasBeenModified();
0193 }