File indexing completed on 2026-09-13 08:29:12
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 "ExUCNDetectorConstruction.hh"
0030
0031 #include "G4Box.hh"
0032 #include "G4Colour.hh"
0033 #include "G4FieldManager.hh"
0034 #include "G4GeometryManager.hh"
0035 #include "G4LogicalVolume.hh"
0036 #include "G4LogicalVolumeStore.hh"
0037 #include "G4Material.hh"
0038 #include "G4NistManager.hh"
0039 #include "G4PVPlacement.hh"
0040 #include "G4PhysicalConstants.hh"
0041 #include "G4PhysicalVolumeStore.hh"
0042 #include "G4RepleteEofM.hh"
0043 #include "G4SolidStore.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4TransportationManager.hh"
0046 #include "G4Tubs.hh"
0047 #include "G4UCNMaterialPropertiesTable.hh"
0048 #include "G4UniformGravityField.hh"
0049 #include "G4UserLimits.hh"
0050 #include "G4VPhysicalVolume.hh"
0051 #include "G4VisAttributes.hh"
0052
0053
0054 #include "G4ChordFinder.hh"
0055 #include "G4ClassicalRK4.hh"
0056 #include "G4MagIntegratorStepper.hh"
0057 #include "G4PropagatorInField.hh"
0058
0059
0060
0061 ExUCNDetectorConstruction::ExUCNDetectorConstruction() : fVacuum(0), fGuideMaterial(0)
0062 {
0063
0064 DefineMaterials();
0065 }
0066
0067
0068
0069 ExUCNDetectorConstruction::~ExUCNDetectorConstruction()
0070 {
0071 if (fField) delete fField;
0072 }
0073
0074
0075
0076 void ExUCNDetectorConstruction::DefineMaterials()
0077 {
0078 G4NistManager* nistMan = G4NistManager::Instance();
0079
0080 fVacuum = nistMan->FindOrBuildMaterial("G4_Galactic");
0081 fGuideMaterial = nistMan->FindOrBuildMaterial("G4_Ni");
0082
0083
0084
0085 G4UCNMaterialPropertiesTable* MPT = new G4UCNMaterialPropertiesTable();
0086
0087
0088
0089
0090 MPT->AddConstProperty("DIFFUSION", 0.1);
0091 MPT->AddConstProperty("FERMIPOT", 252.0);
0092 MPT->AddConstProperty("SPINFLIP", 0.);
0093 MPT->AddConstProperty("LOSS", 12.5e-5);
0094 MPT->AddConstProperty("LOSSCS", 0.);
0095 MPT->AddConstProperty("ABSCS", 4.49);
0096 MPT->AddConstProperty("SCATCS", 18.5);
0097
0098 G4double neV = 1.e-9 * eV;
0099
0100 MPT->SetMicroRoughnessParameters(30 * nm, 1 * nm, 180, 1000, 0 * degree, 90 * degree, 1 * neV,
0101 1000 * neV, 15, 15, 0.01 * degree);
0102
0103 fGuideMaterial->SetMaterialPropertiesTable(MPT);
0104
0105 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0106 }
0107
0108
0109
0110 G4VPhysicalVolume* ExUCNDetectorConstruction::Construct()
0111 {
0112
0113
0114
0115
0116 G4double worldSizeX = 1. * m;
0117 G4double worldSizeY = 1. * m;
0118 G4double worldSizeZ = 100. * m;
0119
0120 G4Box* solidWorld = new G4Box("World", worldSizeX / 2., worldSizeY / 2., worldSizeZ / 2.);
0121
0122 G4LogicalVolume* logicWorld = new G4LogicalVolume(solidWorld, fVacuum, "World");
0123
0124 G4VPhysicalVolume* physiWorld =
0125 new G4PVPlacement(0, G4ThreeVector(), "World", logicWorld, 0, false, 0);
0126
0127
0128
0129 G4double GuideR = 35. * mm;
0130 G4double GuideW = 2. * mm;
0131 G4double GuideL = 6. * m;
0132
0133 G4Tubs* solidGuide = new G4Tubs("SolidGuide", GuideR, GuideR + GuideW, GuideL / 2., 0., twopi);
0134
0135 G4LogicalVolume* logicGuide = new G4LogicalVolume(solidGuide, fGuideMaterial, "Guide");
0136
0137 new G4PVPlacement(0, G4ThreeVector(), "Guide", logicGuide, physiWorld, false, 0);
0138
0139
0140
0141 G4Tubs* solidEndPlate = new G4Tubs("EndPlate", 0., GuideR, GuideW / 2., 0., twopi);
0142
0143 G4LogicalVolume* logicEndPlate = new G4LogicalVolume(solidEndPlate, fVacuum, "EndPlate");
0144
0145 G4ThreeVector endPlatePos = G4ThreeVector(0., 0., GuideL / 2. + GuideW / 2.);
0146
0147 new G4PVPlacement(0, endPlatePos, "EndPlate", logicEndPlate, physiWorld, false, 0);
0148
0149 G4double maxStep = 1.0 * mm;
0150 G4double maxTime = 100. * s;
0151
0152 G4UserLimits* stepLimit = new G4UserLimits(maxStep, DBL_MAX, maxTime);
0153
0154 logicWorld->SetUserLimits(stepLimit);
0155
0156
0157
0158
0159
0160 G4VisAttributes* guideColor = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
0161 guideColor->SetVisibility(true);
0162 guideColor->SetForceWireframe(true);
0163
0164 G4VisAttributes* endPlateColor = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
0165 endPlateColor->SetVisibility(true);
0166 endPlateColor->SetForceSolid(true);
0167
0168 logicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
0169 logicGuide->SetVisAttributes(guideColor);
0170 logicEndPlate->SetVisAttributes(endPlateColor);
0171
0172
0173
0174
0175 return physiWorld;
0176 }
0177
0178
0179
0180 G4ThreadLocal G4UniformGravityField* ExUCNDetectorConstruction::fField = 0;
0181
0182 void ExUCNDetectorConstruction::ConstructSDandField()
0183 {
0184 if (!fField) {
0185 fField = new G4UniformGravityField();
0186
0187 G4RepleteEofM* equation = new G4RepleteEofM(fField);
0188
0189
0190
0191 G4FieldManager* fieldManager =
0192 G4TransportationManager::GetTransportationManager()->GetFieldManager();
0193 fieldManager->SetDetectorField(fField);
0194
0195 G4MagIntegratorStepper* stepper = new G4ClassicalRK4(equation, 8);
0196
0197
0198 G4double minStep = 0.01 * mm;
0199
0200 G4ChordFinder* chordFinder = new G4ChordFinder((G4MagneticField*)fField, minStep, stepper);
0201
0202
0203 G4double deltaChord = 3.0 * mm;
0204 chordFinder->SetDeltaChord(deltaChord);
0205
0206 G4double deltaOneStep = 0.01 * mm;
0207 fieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep);
0208
0209 G4double deltaIntersection = 0.1 * mm;
0210 fieldManager->SetDeltaIntersection(deltaIntersection);
0211
0212 G4TransportationManager* transportManager = G4TransportationManager::GetTransportationManager();
0213
0214 G4PropagatorInField* fieldPropagator = transportManager->GetPropagatorInField();
0215
0216
0217 G4double epsMin = 2.5e-7;
0218 G4double epsMax = 0.001;
0219
0220
0221
0222
0223
0224 fieldPropagator->SetMinimumEpsilonStep(epsMin);
0225 fieldPropagator->SetMaximumEpsilonStep(epsMax);
0226
0227 fieldManager->SetChordFinder(chordFinder);
0228 }
0229 }
0230
0231