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