File indexing completed on 2025-04-10 08:06:17
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 "DetectorConstruction.hh"
0035
0036 #include "DetectorMessenger.hh"
0037 #include "PrimaryGeneratorAction.hh"
0038
0039 #include "G4Box.hh"
0040 #include "G4GeometryManager.hh"
0041 #include "G4LogicalVolume.hh"
0042 #include "G4LogicalVolumeStore.hh"
0043 #include "G4Material.hh"
0044 #include "G4NistManager.hh"
0045 #include "G4PVPlacement.hh"
0046 #include "G4PhysicalConstants.hh"
0047 #include "G4PhysicalVolumeStore.hh"
0048 #include "G4RunManager.hh"
0049 #include "G4SolidStore.hh"
0050 #include "G4SystemOfUnits.hh"
0051 #include "G4ThreeVector.hh"
0052 #include "G4Tubs.hh"
0053 #include "globals.hh"
0054
0055
0056
0057 DetectorConstruction::DetectorConstruction()
0058 : fMaterial(nullptr),
0059 fExperimentalHall_log(nullptr),
0060 fExperimentalHall_phys(nullptr),
0061 fLogicLayer(nullptr),
0062 fPhysiLayer(nullptr),
0063 fLogicScoringUpDown(nullptr),
0064 fPhysiScoringUpstream(nullptr),
0065 fPhysiScoringDownstream(nullptr),
0066 fLogicScoringSide(nullptr),
0067 fPhysiScoringSide(nullptr),
0068 fDetectorMessenger(nullptr),
0069 fThickness(2.0 * CLHEP::m),
0070 fDiameter(2.0 * CLHEP::m)
0071 {
0072 fMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Fe");
0073
0074 fDetectorMessenger = new DetectorMessenger(this);
0075 }
0076
0077
0078
0079 DetectorConstruction::~DetectorConstruction()
0080 {
0081 delete fDetectorMessenger;
0082 }
0083
0084
0085
0086 G4VPhysicalVolume* DetectorConstruction::Construct()
0087 {
0088 return ConstructLayer();
0089 }
0090
0091
0092
0093 G4VPhysicalVolume* DetectorConstruction::ConstructLayer()
0094 {
0095
0096 G4GeometryManager::GetInstance()->OpenGeometry();
0097 G4PhysicalVolumeStore::GetInstance()->Clean();
0098 G4LogicalVolumeStore::GetInstance()->Clean();
0099 G4SolidStore::GetInstance()->Clean();
0100
0101
0102
0103
0104
0105
0106 G4double expHall_x = 0.6 * fDiameter;
0107
0108 G4double expHall_y = 0.6 * fDiameter;
0109
0110 G4double expHall_z = 0.6 * fThickness;
0111
0112
0113 G4Material* vacuum = G4NistManager::Instance()->FindOrBuildMaterial("G4_Galactic");
0114
0115
0116 G4Box* experimentalHall_box = new G4Box("expHall_box", expHall_x, expHall_y, expHall_z);
0117 fExperimentalHall_log = new G4LogicalVolume(experimentalHall_box,
0118 vacuum,
0119 "expHall_log",
0120 0,
0121 0,
0122 0);
0123 fExperimentalHall_phys = new G4PVPlacement(0,
0124 G4ThreeVector(),
0125 "expHall",
0126 fExperimentalHall_log,
0127 0,
0128 false,
0129 0);
0130
0131
0132 G4Tubs* solidLayer = new G4Tubs("solidLayer",
0133 0.0,
0134 0.5 * fDiameter,
0135 0.5 * fThickness,
0136 0.0,
0137 2.0 * pi);
0138 fLogicLayer = new G4LogicalVolume(solidLayer,
0139 fMaterial,
0140 "logicLayer",
0141 0,
0142 0,
0143 0);
0144 fPhysiLayer = new G4PVPlacement(0,
0145 G4ThreeVector(),
0146 "physiLayer",
0147 fLogicLayer,
0148 fExperimentalHall_phys,
0149 false,
0150 0);
0151
0152
0153
0154
0155 G4Tubs* solidScoringUpDown = new G4Tubs("solidScoringUpDown",
0156 0.0,
0157 0.5 * fDiameter,
0158 0.5 * fScoringThickness,
0159 0.0,
0160 2.0 * pi);
0161 fLogicScoringUpDown = new G4LogicalVolume(solidScoringUpDown,
0162 vacuum,
0163 "logicScoringUpDown",
0164 0,
0165 0,
0166 0);
0167 G4double zScoringUpDown = 0.5 * (fThickness + fScoringThickness);
0168 fPhysiScoringUpstream = new G4PVPlacement(0,
0169 G4ThreeVector(0.0, 0.0, -zScoringUpDown),
0170
0171 "physiScoringUpstream",
0172 fLogicScoringUpDown,
0173 fExperimentalHall_phys,
0174 false,
0175 0);
0176 fPhysiScoringDownstream = new G4PVPlacement(0,
0177 G4ThreeVector(0.0, 0.0, zScoringUpDown),
0178
0179 "physiScoringDownstream",
0180 fLogicScoringUpDown,
0181 fExperimentalHall_phys,
0182 false,
0183 0);
0184
0185 G4Tubs* solidScoringSide = new G4Tubs("solidScoringSide",
0186 0.5 * fDiameter,
0187 0.5 * fDiameter + fScoringThickness,
0188 0.5 * fThickness,
0189 0.0,
0190 2.0 * pi);
0191 fLogicScoringSide = new G4LogicalVolume(solidScoringSide,
0192 vacuum,
0193 "logicScoringSide",
0194 0,
0195 0,
0196 0);
0197 fPhysiScoringSide = new G4PVPlacement(0,
0198 G4ThreeVector(0.0, 0.0, 0.0),
0199 "physiScoringSide",
0200 fLogicScoringSide,
0201 fExperimentalHall_phys,
0202 false,
0203 0);
0204
0205 G4cout << G4endl << "DetectorConstruction::ConstructLayer() : " << G4endl
0206 << "\t World (box) size: " << G4endl << "\t \t x : -/+ " << expHall_x << " mm ;"
0207 << "\t y : -/+ " << expHall_y << " mm ;"
0208 << "\t z : -/+ " << expHall_z << " mm ;" << G4endl
0209 << "\t Target layer (cylinder) size: " << G4endl << "\t \t x : -/+ " << 0.5 * fDiameter
0210 << " mm ;"
0211 << "\t y : -/+ " << 0.5 * fDiameter << " mm ;"
0212 << "\t z : -/+ " << 0.5 * fThickness << " mm ;" << G4endl << G4endl << G4endl;
0213
0214 return fExperimentalHall_phys;
0215 }
0216
0217
0218
0219 void DetectorConstruction::SetMaterial(const G4String name)
0220 {
0221 fMaterial = G4NistManager::Instance()->FindOrBuildMaterial(name);
0222 if (!fMaterial) {
0223 G4cout << G4endl << G4endl << "WARNING: the name of the material has not been recognized!"
0224 << G4endl << " ===> the default * G4_Fe * will be used." << G4endl << G4endl;
0225 fMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_Fe");
0226 }
0227 if (fLogicLayer) fLogicLayer->SetMaterial(fMaterial);
0228 }
0229
0230
0231
0232 void DetectorConstruction::UpdateGeometry()
0233 {
0234 G4RunManager::GetRunManager()->ReinitializeGeometry();
0235 PrintParameters();
0236
0237 const PrimaryGeneratorAction* pPrimaryAction = dynamic_cast<const PrimaryGeneratorAction*>(
0238 G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
0239 if (pPrimaryAction) pPrimaryAction->SetGunPosition();
0240 }
0241
0242
0243
0244 void DetectorConstruction::PrintParameters()
0245 {
0246 G4cout << G4endl << G4endl << " ------ DetectorConstruction::PrintParameters() ------ " << G4endl
0247 << " Material = " << fMaterial->GetName() << G4endl
0248 << " Thickness = " << fThickness << " mm" << G4endl
0249 << " Diameter = " << fDiameter << " mm" << G4endl
0250 << " ScoringThickness = " << fScoringThickness << " mm" << G4endl
0251 << " ------------------------------------------------------ " << G4endl << G4endl;
0252 }
0253
0254