File indexing completed on 2026-03-28 07:51:10
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 "DetectorConstruction.hh"
0030
0031 #include "ScreenSD.hh"
0032
0033 #include "G4AutoDelete.hh"
0034 #include "G4Box.hh"
0035 #include "G4Colour.hh"
0036 #include "G4GlobalMagFieldMessenger.hh"
0037 #include "G4LogicalVolume.hh"
0038 #include "G4Material.hh"
0039 #include "G4NistManager.hh"
0040 #include "G4PVPlacement.hh"
0041 #include "G4SDManager.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4VisAttributes.hh"
0044
0045
0046
0047 G4ThreadLocal G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
0048
0049
0050
0051 G4VPhysicalVolume* DetectorConstruction::Construct()
0052 {
0053
0054 G4NistManager* nistManager = G4NistManager::Instance();
0055
0056
0057 G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
0058 G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
0059
0060
0061
0062
0063
0064 G4cout << *(G4Material::GetMaterialTable()) << G4endl;
0065
0066
0067 G4bool checkOverlaps = true;
0068
0069
0070
0071
0072
0073
0074 G4double worldHxyz = 2. * m;
0075
0076
0077 auto worldS = new G4Box("World", worldHxyz, worldHxyz, worldHxyz);
0078
0079 auto worldLV = new G4LogicalVolume(worldS, air, "World");
0080
0081 G4VPhysicalVolume* worldPV =
0082 new G4PVPlacement(nullptr, G4ThreeVector(), worldLV, "World", nullptr, false, 0, checkOverlaps);
0083
0084
0085
0086
0087
0088
0089 G4double boxHxy = 1. * m;
0090 G4double boxHz = 10. * cm;
0091
0092
0093 auto boxS = new G4Box("World", boxHxy, boxHxy, boxHz);
0094
0095 auto boxLV = new G4LogicalVolume(boxS, csi, "Box");
0096
0097
0098 G4double posz = 0. * m;
0099
0100 new G4PVPlacement(nullptr, G4ThreeVector(0, 0, posz), boxLV, "Box", worldLV, false, 0,
0101 checkOverlaps);
0102
0103
0104
0105
0106
0107 G4double screenHxy = 1.999 * m;
0108 G4double screenHz = 1. * mm;
0109
0110
0111 auto screenS = new G4Box("World", screenHxy, screenHxy, screenHz);
0112
0113 auto screenLV = new G4LogicalVolume(screenS, air, "Screen");
0114
0115
0116 posz += boxHz + screenHz;
0117
0118 new G4PVPlacement(nullptr, G4ThreeVector(0, 0, posz), screenLV, "Screen", worldLV, false, 0,
0119 checkOverlaps);
0120
0121
0122
0123
0124 worldLV->SetVisAttributes(G4VisAttributes::GetInvisible());
0125
0126 auto simpleBoxVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
0127 simpleBoxVisAtt->SetVisibility(true);
0128 boxLV->SetVisAttributes(simpleBoxVisAtt);
0129 screenLV->SetVisAttributes(simpleBoxVisAtt);
0130
0131
0132
0133
0134 return worldPV;
0135 }
0136
0137
0138
0139 void DetectorConstruction::ConstructSDandField()
0140 {
0141
0142
0143
0144
0145
0146 auto screenSD = new ScreenSD("ScreenSD");
0147 G4SDManager::GetSDMpointer()->AddNewDetector(screenSD);
0148 SetSensitiveDetector("Screen", screenSD);
0149
0150
0151
0152
0153
0154
0155
0156 G4ThreeVector fieldValue;
0157 fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
0158 fMagFieldMessenger->SetVerboseLevel(1);
0159
0160
0161 G4AutoDelete::Register(fMagFieldMessenger);
0162 }
0163
0164