File indexing completed on 2026-06-22 07:53:42
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 #include "F05DetectorConstruction.hh"
0030
0031 #include "F05Field.hh"
0032
0033 #include "G4Box.hh"
0034 #include "G4Colour.hh"
0035 #include "G4FieldManager.hh"
0036 #include "G4GeometryManager.hh"
0037 #include "G4LogicalVolume.hh"
0038 #include "G4LogicalVolumeStore.hh"
0039 #include "G4Material.hh"
0040 #include "G4NistManager.hh"
0041 #include "G4PVPlacement.hh"
0042 #include "G4PhysicalVolumeStore.hh"
0043 #include "G4SolidStore.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4TransportationManager.hh"
0046 #include "G4UserLimits.hh"
0047 #include "G4VisAttributes.hh"
0048
0049
0050 #include "G4ChordFinder.hh"
0051 #include "G4ClassicalRK4.hh"
0052 #include "G4EqEMFieldWithSpin.hh"
0053 #include "G4MagIntegratorStepper.hh"
0054 #include "G4PropagatorInField.hh"
0055
0056
0057
0058 F05DetectorConstruction::F05DetectorConstruction() : fVacuum(nullptr)
0059 {
0060
0061 DefineMaterials();
0062 }
0063
0064
0065
0066 F05DetectorConstruction::~F05DetectorConstruction()
0067 {
0068 delete fField;
0069 }
0070
0071
0072
0073 void F05DetectorConstruction::DefineMaterials()
0074 {
0075 G4NistManager* nistMan = G4NistManager::Instance();
0076
0077 fVacuum = nistMan->FindOrBuildMaterial("G4_Galactic");
0078
0079 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0080 }
0081
0082
0083
0084 G4VPhysicalVolume* F05DetectorConstruction::Construct()
0085 {
0086
0087
0088
0089
0090 G4double worldSizeXY = 20.0 * m;
0091 G4double worldSizeZ = 1.0 * mm;
0092
0093 auto solidWorld = new G4Box("World",
0094 worldSizeXY / 2, worldSizeXY / 2, worldSizeZ / 2);
0095
0096 auto logicWorld = new G4LogicalVolume(solidWorld,
0097 fVacuum,
0098 "World");
0099
0100 auto physiWorld = new G4PVPlacement(nullptr,
0101 G4ThreeVector(),
0102 logicWorld,
0103 "World",
0104 nullptr,
0105 false,
0106 0);
0107
0108 G4UserLimits* stepLimit;
0109 stepLimit = new G4UserLimits(5 * mm);
0110
0111 logicWorld->SetUserLimits(stepLimit);
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 return physiWorld;
0122 }
0123
0124
0125
0126 G4ThreadLocal F05Field* F05DetectorConstruction::fField = nullptr;
0127
0128 void F05DetectorConstruction::ConstructSDandField()
0129
0130 {
0131 if (!fField) {
0132 fField = new F05Field();
0133
0134
0135 auto equation = new G4EqEMFieldWithSpin(fField);
0136
0137
0138
0139
0140 G4FieldManager* fieldManager =
0141 G4TransportationManager::GetTransportationManager()->GetFieldManager();
0142 fieldManager->SetDetectorField(fField);
0143
0144 G4MagIntegratorStepper* stepper = new G4ClassicalRK4(equation, 12);
0145
0146 G4double minStep = 0.01 * mm;
0147
0148 auto chordFinder = new G4ChordFinder((G4MagneticField*)fField, minStep, stepper);
0149
0150
0151 G4double deltaChord = 3.0 * mm;
0152 chordFinder->SetDeltaChord(deltaChord);
0153
0154
0155 G4double deltaOneStep = 0.01 * mm;
0156 fieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep);
0157
0158 G4double deltaIntersection = 0.1 * mm;
0159 fieldManager->SetDeltaIntersection(deltaIntersection);
0160
0161 G4TransportationManager* transportManager = G4TransportationManager::GetTransportationManager();
0162
0163 G4PropagatorInField* fieldPropagator = transportManager->GetPropagatorInField();
0164
0165
0166 G4double epsMin = 2.5e-7;
0167 G4double epsMax = 0.001;
0168
0169 fieldPropagator->SetMinimumEpsilonStep(epsMin);
0170 fieldPropagator->SetMaximumEpsilonStep(epsMax);
0171
0172 fieldManager->SetChordFinder(chordFinder);
0173 }
0174 }
0175
0176