File indexing completed on 2025-11-02 08:58:43
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 #include "DetectorConstruction.hh"
0033
0034 #include "DetectorMessenger.hh"
0035 #include "G4AutoDelete.hh"
0036 #include "G4GlobalMagFieldMessenger.hh"
0037 #include "G4LogicalVolume.hh"
0038 #include "G4LogicalVolumeStore.hh"
0039 #include "G4NistManager.hh"
0040 #include "G4PVPlacement.hh"
0041 #include "G4PhysicalVolumeStore.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4SolidStore.hh"
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4Tubs.hh"
0046 #include "G4UnitsTable.hh"
0047
0048
0049
0050 G4ThreadLocal
0051 G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
0052
0053 DetectorConstruction::DetectorConstruction()
0054 {
0055 DefineMaterials();
0056 SetMaterial("G4_PbWO4");
0057 fDetectorMessenger = new DetectorMessenger(this);
0058 }
0059
0060
0061
0062 DetectorConstruction::~DetectorConstruction()
0063 {
0064 delete fDetectorMessenger;
0065 }
0066
0067
0068
0069 void DetectorConstruction::DefineMaterials()
0070 {
0071
0072
0073
0074 G4double a, z;
0075
0076 G4Element* H = new G4Element("Hydrogen", "H", z = 1., a = 1.01 * g / mole);
0077 G4Element* O = new G4Element("Oxygen", "O", z = 8., a = 16.00 * g / mole);
0078 G4Element* Ge = new G4Element("Germanium", "Ge", z = 32., a = 72.59 * g / mole);
0079 G4Element* Bi = new G4Element("Bismuth", "Bi", z = 83., a = 208.98 * g / mole);
0080
0081
0082
0083
0084 G4double density;
0085 G4int ncomponents, natoms;
0086
0087
0088 G4Material* H2O = new G4Material("Water", density = 1.00 * g / cm3, ncomponents = 2);
0089 H2O->AddElement(H, natoms = 2);
0090 H2O->AddElement(O, natoms = 1);
0091 H2O->GetIonisation()->SetMeanExcitationEnergy(78.0 * eV);
0092
0093
0094 new G4Material("liquidArgon", z = 18., a = 39.95 * g / mole, density = 1.390 * g / cm3);
0095 new G4Material("Aluminium", z = 13., a = 26.98 * g / mole, density = 2.7 * g / cm3);
0096 new G4Material("Iron", z = 26., a = 55.85 * g / mole, density = 7.87 * g / cm3);
0097 new G4Material("Copper", z = 29., a = 63.55 * g / mole, density = 8.960 * g / cm3);
0098 new G4Material("Tungsten", z = 74., a = 183.84 * g / mole, density = 19.35 * g / cm3);
0099 new G4Material("Lead", z = 82., a = 207.19 * g / mole, density = 11.35 * g / cm3);
0100 new G4Material("Uranium", z = 92., a = 238.03 * g / mole, density = 18.95 * g / cm3);
0101
0102
0103 G4Material* BGO = new G4Material("BGO", density = 7.10 * g / cm3, ncomponents = 3);
0104 BGO->AddElement(O, natoms = 12);
0105 BGO->AddElement(Ge, natoms = 3);
0106 BGO->AddElement(Bi, natoms = 4);
0107
0108
0109 }
0110
0111
0112
0113 void DetectorConstruction::UpdateParameters()
0114 {
0115 G4double Radl = fMaterial->GetRadlen();
0116 fDLlength = fDLradl * Radl;
0117 fDRlength = fDRradl * Radl;
0118 fEcalLength = fNLtot * fDLlength;
0119 fEcalRadius = fNRtot * fDRlength;
0120 if (nullptr != fSolidEcal) {
0121 fSolidEcal->SetOuterRadius(fEcalRadius);
0122 fSolidEcal->SetZHalfLength(0.5 * fEcalLength);
0123 }
0124 }
0125
0126
0127
0128 G4VPhysicalVolume* DetectorConstruction::Construct()
0129 {
0130 UpdateParameters();
0131
0132
0133
0134 if (nullptr == fPhysiEcal) {
0135 fSolidEcal = new G4Tubs("Ecal", 0., fEcalRadius, 0.5 * fEcalLength, 0., 360 * deg);
0136 fLogicEcal = new G4LogicalVolume(fSolidEcal, fMaterial, "Ecal", 0, 0, 0);
0137 fPhysiEcal = new G4PVPlacement(0, G4ThreeVector(), fLogicEcal, "Ecal", 0, false, 0);
0138 }
0139 G4cout << "\n Absorber is " << G4BestUnit(fEcalLength, "Length") << " of " << fMaterial->GetName()
0140 << " R= " << fEcalRadius / cm << " cm \n"
0141 << G4endl;
0142 G4cout << fMaterial << G4endl;
0143
0144
0145
0146 return fPhysiEcal;
0147 }
0148
0149
0150
0151 void DetectorConstruction::SetMaterial(const G4String& materialChoice)
0152 {
0153
0154 G4Material* pttoMaterial = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
0155
0156 if (pttoMaterial && fMaterial != pttoMaterial) {
0157 fMaterial = pttoMaterial;
0158 if (nullptr != fLogicEcal) {
0159 fLogicEcal->SetMaterial(fMaterial);
0160 }
0161 G4RunManager::GetRunManager()->PhysicsHasBeenModified();
0162 }
0163 }
0164
0165
0166
0167 void DetectorConstruction::SetLBining(const G4ThreeVector& Value)
0168 {
0169 fNLtot = (G4int)Value(0);
0170 if (fNLtot > kMaxBin) {
0171 G4cout << "\n ---> warning from SetLBining: " << fNLtot << " truncated to " << kMaxBin
0172 << G4endl;
0173 fNLtot = kMaxBin;
0174 }
0175 fDLradl = Value(1);
0176 UpdateParameters();
0177 }
0178
0179
0180
0181 void DetectorConstruction::SetRBining(const G4ThreeVector& Value)
0182 {
0183 fNRtot = (G4int)Value(0);
0184 if (fNRtot > kMaxBin) {
0185 G4cout << "\n ---> warning from SetRBining: " << fNRtot << " truncated to " << kMaxBin
0186 << G4endl;
0187 fNRtot = kMaxBin;
0188 }
0189 fDRradl = Value(1);
0190 UpdateParameters();
0191 }
0192
0193
0194
0195 void DetectorConstruction::ConstructSDandField()
0196 {
0197
0198
0199
0200
0201 G4ThreeVector fieldValue = G4ThreeVector();
0202 fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
0203 fMagFieldMessenger->SetVerboseLevel(1);
0204
0205
0206 G4AutoDelete::Register(fMagFieldMessenger);
0207 }
0208
0209