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