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