Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file electromagnetic/TestEm3/src/Detector 26 /// \file electromagnetic/TestEm3/src/DetectorConstruction.cc 27 /// \brief Implementation of the DetectorConst 27 /// \brief Implementation of the DetectorConstruction class 28 // 28 // 29 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 32 33 #include "DetectorConstruction.hh" 33 #include "DetectorConstruction.hh" 34 << 35 #include "DetectorMessenger.hh" 34 #include "DetectorMessenger.hh" 36 35 >> 36 #include "G4NistManager.hh" >> 37 #include "G4Material.hh" 37 #include "G4Box.hh" 38 #include "G4Box.hh" 38 #include "G4GeometryManager.hh" << 39 #include "G4LogicalVolume.hh" 39 #include "G4LogicalVolume.hh" 40 #include "G4LogicalVolumeStore.hh" << 41 #include "G4Material.hh" << 42 #include "G4NistManager.hh" << 43 #include "G4PVPlacement.hh" 40 #include "G4PVPlacement.hh" 44 #include "G4PVReplica.hh" 41 #include "G4PVReplica.hh" 45 #include "G4PhysicalConstants.hh" << 42 >> 43 #include "G4GeometryManager.hh" 46 #include "G4PhysicalVolumeStore.hh" 44 #include "G4PhysicalVolumeStore.hh" 47 #include "G4RunManager.hh" << 45 #include "G4LogicalVolumeStore.hh" 48 #include "G4SolidStore.hh" 46 #include "G4SolidStore.hh" >> 47 >> 48 #include "G4RunManager.hh" 49 #include "G4SystemOfUnits.hh" 49 #include "G4SystemOfUnits.hh" 50 #include "G4UnitsTable.hh" 50 #include "G4UnitsTable.hh" >> 51 #include "G4PhysicalConstants.hh" 51 52 52 #include <iomanip> 53 #include <iomanip> 53 54 54 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 55 56 56 DetectorConstruction::DetectorConstruction() 57 DetectorConstruction::DetectorConstruction() >> 58 :G4VUserDetectorConstruction(), >> 59 fWorldMaterial(nullptr),fSolidWorld(nullptr),fLogicWorld(nullptr), >> 60 fPhysiWorld(nullptr),fSolidCalor(nullptr),fLogicCalor(nullptr), >> 61 fPhysiCalor(nullptr),fSolidLayer(nullptr),fLogicLayer(nullptr), >> 62 fPhysiLayer(nullptr) 57 { 63 { 58 for (G4int i = 0; i < kMaxAbsor; ++i) { << 64 for(G4int i=0; i<kMaxAbsor; ++i) { 59 fAbsorMaterial[i] = nullptr; << 65 fAbsorMaterial[i] = nullptr; 60 fAbsorThickness[i] = 0.0; 66 fAbsorThickness[i] = 0.0; 61 fSolidAbsor[i] = nullptr; 67 fSolidAbsor[i] = nullptr; 62 fLogicAbsor[i] = nullptr; 68 fLogicAbsor[i] = nullptr; 63 fPhysiAbsor[i] = nullptr; 69 fPhysiAbsor[i] = nullptr; 64 } << 70 } 65 71 66 // default parameter values of the calorimet 72 // default parameter values of the calorimeter 67 fNbOfAbsor = 2; 73 fNbOfAbsor = 2; 68 fAbsorThickness[1] = 2.3 * mm; << 74 fAbsorThickness[1] = 2.3*mm; 69 fAbsorThickness[2] = 5.7 * mm; << 75 fAbsorThickness[2] = 5.7*mm; 70 fNbOfLayers = 50; << 76 fNbOfLayers = 50; 71 fCalorSizeYZ = 40. * cm; << 77 fCalorSizeYZ = 40.*cm; 72 ComputeCalorParameters(); 78 ComputeCalorParameters(); 73 79 74 // materials 80 // materials 75 DefineMaterials(); 81 DefineMaterials(); 76 SetWorldMaterial("Galactic"); 82 SetWorldMaterial("Galactic"); 77 SetAbsorMaterial(1, "G4_Pb"); << 83 SetAbsorMaterial(1,"G4_Pb"); 78 SetAbsorMaterial(2, "G4_lAr"); << 84 SetAbsorMaterial(2,"G4_lAr"); 79 85 80 // create commands for interactive definitio 86 // create commands for interactive definition of the calorimeter 81 fDetectorMessenger = new DetectorMessenger(t 87 fDetectorMessenger = new DetectorMessenger(this); 82 } 88 } 83 89 84 //....oooOO0OOooo........oooOO0OOooo........oo 90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 85 91 86 DetectorConstruction::~DetectorConstruction() 92 DetectorConstruction::~DetectorConstruction() 87 { 93 { 88 delete fDetectorMessenger; 94 delete fDetectorMessenger; 89 } 95 } 90 96 91 //....oooOO0OOooo........oooOO0OOooo........oo 97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 92 98 93 void DetectorConstruction::DefineMaterials() 99 void DetectorConstruction::DefineMaterials() 94 { 100 { 95 // This function illustrates the possible wa << 101 // This function illustrates the possible ways to define materials using 96 // G4 database on G4Elements 102 // G4 database on G4Elements 97 G4NistManager* manager = G4NistManager::Inst 103 G4NistManager* manager = G4NistManager::Instance(); 98 manager->SetVerbose(0); 104 manager->SetVerbose(0); 99 // 105 // 100 // define Elements 106 // define Elements 101 // 107 // 102 G4double z, a; << 108 G4double z,a; 103 109 104 G4Element* H = manager->FindOrBuildElement(1 << 110 G4Element* H = manager->FindOrBuildElement(1); 105 G4Element* C = manager->FindOrBuildElement(6 << 111 G4Element* C = manager->FindOrBuildElement(6); 106 G4Element* N = manager->FindOrBuildElement(7 << 112 G4Element* N = manager->FindOrBuildElement(7); 107 G4Element* O = manager->FindOrBuildElement(8 << 113 G4Element* O = manager->FindOrBuildElement(8); 108 G4Element* Si = manager->FindOrBuildElement( 114 G4Element* Si = manager->FindOrBuildElement(14); 109 G4Element* Ge = manager->FindOrBuildElement( 115 G4Element* Ge = manager->FindOrBuildElement(32); 110 G4Element* Sb = manager->FindOrBuildElement( 116 G4Element* Sb = manager->FindOrBuildElement(51); 111 G4Element* I = manager->FindOrBuildElement(5 << 117 G4Element* I = manager->FindOrBuildElement(53); 112 G4Element* Cs = manager->FindOrBuildElement( 118 G4Element* Cs = manager->FindOrBuildElement(55); 113 G4Element* Pb = manager->FindOrBuildElement( 119 G4Element* Pb = manager->FindOrBuildElement(82); 114 G4Element* Bi = manager->FindOrBuildElement( 120 G4Element* Bi = manager->FindOrBuildElement(83); 115 121 116 // 122 // 117 // define an Element from isotopes, by relat 123 // define an Element from isotopes, by relative abundance 118 // 124 // 119 G4int iz, n; // iz=number of protons in an << 125 G4int iz, n; //iz=number of protons in an isotope; 120 // n=number of nucleons in an << 126 // n=number of nucleons in an isotope; 121 G4int ncomponents; << 127 G4int ncomponents; 122 G4double abundance; << 128 G4double abundance; 123 << 129 124 G4Isotope* U5 = new G4Isotope("U235", iz = 9 << 130 G4Isotope* U5 = new G4Isotope("U235", iz=92, n=235, a=235.01*g/mole); 125 G4Isotope* U8 = new G4Isotope("U238", iz = 9 << 131 G4Isotope* U8 = new G4Isotope("U238", iz=92, n=238, a=238.03*g/mole); 126 << 132 127 G4Element* U = new G4Element("enriched Urani << 133 G4Element* U = new G4Element("enriched Uranium", "U", ncomponents=2); 128 U->AddIsotope(U5, abundance = 90. * perCent) << 134 U->AddIsotope(U5, abundance= 90.*perCent); 129 U->AddIsotope(U8, abundance = 10. * perCent) << 135 U->AddIsotope(U8, abundance= 10.*perCent); 130 136 131 // 137 // 132 // define simple materials 138 // define simple materials 133 // 139 // 134 G4double density; 140 G4double density; 135 141 136 new G4Material("liquidH2", z = 1., a = 1.008 << 142 new G4Material("liquidH2", z=1., a= 1.008*g/mole, density= 70.8*mg/cm3); 137 new G4Material("Aluminium", z = 13., a = 26. << 143 new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.700*g/cm3); 138 new G4Material("Titanium", z = 22., a = 47.8 << 144 new G4Material("Titanium", z=22., a= 47.867*g/mole, density= 4.54*g/cm3); 139 new G4Material("Iron", z = 26., a = 55.85 * << 145 new G4Material("Iron", z=26., a= 55.85*g/mole, density= 7.870*g/cm3); 140 new G4Material("Copper", z = 29., a = 63.55 << 146 new G4Material("Copper", z=29., a= 63.55*g/mole, density= 8.960*g/cm3); 141 new G4Material("Tungsten", z = 74., a = 183. << 147 new G4Material("Tungsten", z=74., a= 183.85*g/mole, density= 19.30*g/cm3); 142 new G4Material("Gold", z = 79., a = 196.97 * << 148 new G4Material("Gold", z=79., a= 196.97*g/mole, density= 19.32*g/cm3); 143 new G4Material("Uranium", z = 92., a = 238.0 << 149 new G4Material("Uranium", z=92., a= 238.03*g/mole, density= 18.95*g/cm3); 144 150 145 // 151 // 146 // define a material from elements. case 1 152 // define a material from elements. case 1: chemical molecule 147 // 153 // 148 G4int natoms; 154 G4int natoms; 149 155 150 G4Material* H2O = new G4Material("Water", de << 156 G4Material* H2O = 151 H2O->AddElement(H, natoms = 2); << 157 new G4Material("Water", density= 1.000*g/cm3, ncomponents=2); 152 H2O->AddElement(O, natoms = 1); << 158 H2O->AddElement(H, natoms=2); 153 H2O->GetIonisation()->SetMeanExcitationEnerg << 159 H2O->AddElement(O, natoms=1); >> 160 H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV); 154 H2O->SetChemicalFormula("H_2O"); 161 H2O->SetChemicalFormula("H_2O"); 155 << 162 156 G4Material* CH = new G4Material("Polystyrene << 163 G4Material* CH = 157 CH->AddElement(C, natoms = 1); << 164 new G4Material("Polystyrene", density= 1.032*g/cm3, ncomponents=2); 158 CH->AddElement(H, natoms = 1); << 165 CH->AddElement(C, natoms=1); 159 << 166 CH->AddElement(H, natoms=1); 160 G4Material* Sci = new G4Material("Scintillat << 167 161 Sci->AddElement(C, natoms = 9); << 168 G4Material* Sci = 162 Sci->AddElement(H, natoms = 10); << 169 new G4Material("Scintillator", density= 1.032*g/cm3, ncomponents=2); 163 << 170 Sci->AddElement(C, natoms=9); 164 Sci->GetIonisation()->SetBirksConstant(0.126 << 171 Sci->AddElement(H, natoms=10); 165 << 172 166 G4Material* Lct = new G4Material("Lucite", d << 173 Sci->GetIonisation()->SetBirksConstant(0.126*mm/MeV); 167 Lct->AddElement(C, 59.97 * perCent); << 174 168 Lct->AddElement(H, 8.07 * perCent); << 175 G4Material* Lct = 169 Lct->AddElement(O, 31.96 * perCent); << 176 new G4Material("Lucite", density= 1.185*g/cm3, ncomponents=3); 170 << 177 Lct->AddElement(C, 59.97*perCent); 171 G4Material* Sili = new G4Material("Silicon", << 178 Lct->AddElement(H, 8.07*perCent); 172 Sili->AddElement(Si, natoms = 1); << 179 Lct->AddElement(O, 31.96*perCent); 173 << 180 174 G4Material* SiO2 = new G4Material("quartz", << 181 G4Material* Sili = 175 SiO2->AddElement(Si, natoms = 1); << 182 new G4Material("Silicon", density= 2.330*g/cm3, ncomponents=1); 176 SiO2->AddElement(O, natoms = 2); << 183 Sili->AddElement(Si, natoms=1); 177 << 184 178 G4Material* G10 = new G4Material("NemaG10", << 185 G4Material* SiO2 = 179 G10->AddElement(Si, natoms = 1); << 186 new G4Material("quartz", density= 2.200*g/cm3, ncomponents=2); 180 G10->AddElement(O, natoms = 2); << 187 SiO2->AddElement(Si, natoms=1); 181 G10->AddElement(C, natoms = 3); << 188 SiO2->AddElement(O , natoms=2); 182 G10->AddElement(H, natoms = 3); << 189 183 << 190 G4Material* G10 = 184 G4Material* CsI = new G4Material("CsI", dens << 191 new G4Material("NemaG10", density= 1.700*g/cm3, ncomponents=4); 185 CsI->AddElement(Cs, natoms = 1); << 192 G10->AddElement(Si, natoms=1); 186 CsI->AddElement(I, natoms = 1); << 193 G10->AddElement(O , natoms=2); 187 CsI->GetIonisation()->SetMeanExcitationEnerg << 194 G10->AddElement(C , natoms=3); 188 << 195 G10->AddElement(H , natoms=3); 189 G4Material* BGO = new G4Material("BGO", dens << 196 190 BGO->AddElement(O, natoms = 12); << 197 G4Material* CsI = 191 BGO->AddElement(Ge, natoms = 3); << 198 new G4Material("CsI", density= 4.534*g/cm3, ncomponents=2); 192 BGO->AddElement(Bi, natoms = 4); << 199 CsI->AddElement(Cs, natoms=1); 193 << 200 CsI->AddElement(I , natoms=1); 194 // SiNx << 201 CsI->GetIonisation()->SetMeanExcitationEnergy(553.1*eV); 195 density = 3.1 * g / cm3; << 202 196 G4Material* SiNx = new G4Material("SiNx", de << 203 G4Material* BGO = 197 SiNx->AddElement(Si, 300); << 204 new G4Material("BGO", density= 7.10*g/cm3, ncomponents=3); 198 SiNx->AddElement(N, 310); << 205 BGO->AddElement(O , natoms=12); 199 SiNx->AddElement(H, 6); << 206 BGO->AddElement(Ge, natoms= 3); >> 207 BGO->AddElement(Bi, natoms= 4); >> 208 >> 209 //SiNx >> 210 density= 3.1 *g/cm3; >> 211 G4Material* SiNx= new G4Material("SiNx", density, ncomponents=3); >> 212 SiNx-> AddElement(Si, 300); >> 213 SiNx-> AddElement(N, 310); >> 214 SiNx-> AddElement(H, 6); 200 215 201 // 216 // 202 // define gaseous materials using G4 NIST da << 217 // define gaseous materials using G4 NIST database 203 // 218 // 204 G4double fractionmass; 219 G4double fractionmass; 205 << 220 206 G4Material* Air = manager->FindOrBuildMateri 221 G4Material* Air = manager->FindOrBuildMaterial("G4_AIR"); 207 manager->ConstructNewGasMaterial("Air20", "G << 222 manager->ConstructNewGasMaterial("Air20","G4_AIR",293.*kelvin,1.*atmosphere); 208 223 209 G4Material* lAr = manager->FindOrBuildMateri 224 G4Material* lAr = manager->FindOrBuildMaterial("G4_lAr"); 210 G4Material* lArEm3 = new G4Material("liquidA << 225 G4Material* lArEm3 = new G4Material("liquidArgon", density= 1.390*g/cm3, 211 lArEm3->AddMaterial(lAr, fractionmass = 1.0) << 226 ncomponents=1); >> 227 lArEm3->AddMaterial(lAr, fractionmass=1.0); 212 228 213 // 229 // 214 // define a material from elements and other 230 // define a material from elements and others materials (mixture of mixtures) 215 // 231 // 216 232 217 G4Material* Lead = new G4Material("Lead", de << 233 G4Material* Lead = new G4Material("Lead",density=11.35*g/cm3,ncomponents=1); 218 Lead->AddElement(Pb, fractionmass = 1.0); << 234 Lead->AddElement(Pb, fractionmass=1.0); 219 235 220 G4Material* LeadSb = new G4Material("LeadSb" << 236 G4Material* LeadSb = new G4Material("LeadSb", density=11.35*g/cm3, 221 LeadSb->AddElement(Sb, fractionmass = 4. * p << 237 ncomponents=2); 222 LeadSb->AddElement(Pb, fractionmass = 96. * << 238 LeadSb->AddElement(Sb, fractionmass=4.*perCent); 223 << 239 LeadSb->AddElement(Pb, fractionmass=96.*perCent); 224 G4Material* Aerog = new G4Material("Aerogel" << 240 225 Aerog->AddMaterial(SiO2, fractionmass = 62.5 << 241 G4Material* Aerog = new G4Material("Aerogel", density= 0.200*g/cm3, 226 Aerog->AddMaterial(H2O, fractionmass = 37.4 << 242 ncomponents=3); 227 Aerog->AddElement(C, fractionmass = 0.1 * pe << 243 Aerog->AddMaterial(SiO2, fractionmass=62.5*perCent); >> 244 Aerog->AddMaterial(H2O , fractionmass=37.4*perCent); >> 245 Aerog->AddElement (C , fractionmass= 0.1*perCent); 228 246 229 // 247 // 230 // examples of gas in non STP conditions 248 // examples of gas in non STP conditions 231 // 249 // 232 G4double temperature, pressure; 250 G4double temperature, pressure; 233 << 251 234 G4Material* CO2 = << 252 G4Material* CO2 = 235 new G4Material("CarbonicGas", density = 27 << 253 new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2, 236 temperature = 325. * kelvin << 254 kStateGas, temperature= 325.*kelvin, pressure= 50.*atmosphere); 237 CO2->AddElement(C, natoms = 1); << 255 CO2->AddElement(C, natoms=1); 238 CO2->AddElement(O, natoms = 2); << 256 CO2->AddElement(O, natoms=2); 239 << 257 240 G4Material* steam = << 258 G4Material* steam = 241 new G4Material("WaterSteam", density = 1.0 << 259 new G4Material("WaterSteam", density= 1.0*mg/cm3, ncomponents=1, 242 temperature = 273 * kelvin, << 260 kStateGas, temperature= 273*kelvin, pressure= 1*atmosphere); 243 steam->AddMaterial(H2O, fractionmass = 1.); << 261 steam->AddMaterial(H2O, fractionmass=1.); 244 << 262 245 new G4Material("ArgonGas", z = 18, a = 39.94 << 263 new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3, 246 273.15 * kelvin, 1 * atmosphe << 264 kStateGas, 273.15*kelvin, 1*atmosphere); 247 // 265 // 248 // examples of vacuum 266 // examples of vacuum 249 // 267 // 250 268 251 density = universe_mean_density; // from Ph << 269 density = universe_mean_density; //from PhysicalConstants.h 252 pressure = 3.e-18 * pascal; << 270 pressure = 3.e-18*pascal; 253 temperature = 2.73 * kelvin; << 271 temperature = 2.73*kelvin; 254 new G4Material("Galactic", z = 1., a = 1.008 << 272 new G4Material("Galactic", z=1., a=1.008*g/mole, density, 255 pressure); << 273 kStateGas,temperature,pressure); 256 << 274 257 density = 1.e-5 * g / cm3; << 275 density = 1.e-5*g/cm3; 258 pressure = 2.e-2 * bar; << 276 pressure = 2.e-2*bar; 259 temperature = STP_Temperature; // from Phys << 277 temperature = STP_Temperature; //from PhysicalConstants.h 260 G4Material* beam = << 278 G4Material* beam = 261 new G4Material("Beam", density, ncomponent << 279 new G4Material("Beam", density, ncomponents=1, 262 beam->AddMaterial(Air, fractionmass = 1.); << 280 kStateGas,temperature,pressure); >> 281 beam->AddMaterial(Air, fractionmass=1.); 263 282 264 // G4cout << *(G4Material::GetMaterialTable 283 // G4cout << *(G4Material::GetMaterialTable()) << G4endl; 265 } 284 } 266 285 267 //....oooOO0OOooo........oooOO0OOooo........oo 286 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 268 287 269 void DetectorConstruction::ComputeCalorParamet 288 void DetectorConstruction::ComputeCalorParameters() 270 { 289 { 271 // Compute derived parameters of the calorim 290 // Compute derived parameters of the calorimeter 272 fLayerThickness = 0.; 291 fLayerThickness = 0.; 273 for (G4int iAbs = 1; iAbs <= fNbOfAbsor; iAb << 292 for (G4int iAbs=1; iAbs<=fNbOfAbsor; iAbs++) { 274 fLayerThickness += fAbsorThickness[iAbs]; 293 fLayerThickness += fAbsorThickness[iAbs]; 275 } 294 } 276 fCalorThickness = fNbOfLayers * fLayerThickn << 295 fCalorThickness = fNbOfLayers*fLayerThickness; 277 fWorldSizeX = 1.2 * fCalorThickness; << 296 fWorldSizeX = 1.2*fCalorThickness; 278 fWorldSizeYZ = 1.2 * fCalorSizeYZ; << 297 fWorldSizeYZ = 1.2*fCalorSizeYZ; 279 } 298 } 280 299 281 //....oooOO0OOooo........oooOO0OOooo........oo 300 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 282 301 283 G4VPhysicalVolume* DetectorConstruction::Const 302 G4VPhysicalVolume* DetectorConstruction::Construct() 284 { 303 { 285 if (fPhysiWorld) { << 304 if(fPhysiWorld) { return fPhysiWorld; } 286 return fPhysiWorld; << 287 } << 288 // complete the Calor parameters definition 305 // complete the Calor parameters definition 289 ComputeCalorParameters(); 306 ComputeCalorParameters(); 290 307 291 // 308 // 292 // World 309 // World 293 // 310 // 294 fSolidWorld = new G4Box("World", // its nam << 311 fSolidWorld = new G4Box("World", //its name 295 fWorldSizeX / 2, fWo << 312 fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size 296 313 297 fLogicWorld = new G4LogicalVolume(fSolidWorl << 314 fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid 298 fWorldMate << 315 fWorldMaterial, //its material 299 "World"); << 316 "World"); //its name 300 << 317 301 fPhysiWorld = new G4PVPlacement(0, // no ro << 318 fPhysiWorld = new G4PVPlacement(0, //no rotation 302 G4ThreeVecto << 319 G4ThreeVector(), //at (0,0,0) 303 fLogicWorld, << 320 fLogicWorld, //its fLogical volume 304 "World", // << 321 "World", //its name 305 0, // its m << 322 0, //its mother volume 306 false, // n << 323 false, //no boolean operation 307 0); // copy << 324 0); //copy number 308 // 325 // 309 // Calorimeter 326 // Calorimeter 310 // 327 // 311 328 312 fSolidCalor = new G4Box("Calorimeter", fCalo << 329 fSolidCalor = new G4Box("Calorimeter", >> 330 fCalorThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2); 313 331 314 fLogicCalor = new G4LogicalVolume(fSolidCalo << 332 fLogicCalor = new G4LogicalVolume(fSolidCalor, 315 << 333 fWorldMaterial, 316 fPhysiCalor = new G4PVPlacement(0, // no ro << 334 "Calorimeter"); 317 G4ThreeVecto << 335 318 fLogicCalor, << 336 fPhysiCalor = new G4PVPlacement(0, //no rotation 319 "Calorimeter << 337 G4ThreeVector(), //at (0,0,0) 320 fLogicWorld, << 338 fLogicCalor, //its fLogical volume 321 false, // n << 339 "Calorimeter", //its name 322 0); // copy << 340 fLogicWorld, //its mother volume >> 341 false, //no boolean operation >> 342 0); //copy number 323 343 324 // 344 // 325 // Layers 345 // Layers 326 // 346 // 327 347 328 fSolidLayer = new G4Box("Layer", fLayerThick << 348 fSolidLayer = new G4Box("Layer", >> 349 fLayerThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2); 329 350 330 fLogicLayer = new G4LogicalVolume(fSolidLaye << 351 fLogicLayer = new G4LogicalVolume(fSolidLayer, >> 352 fWorldMaterial, >> 353 "Layer"); 331 if (fNbOfLayers > 1) { 354 if (fNbOfLayers > 1) { 332 fPhysiLayer = << 355 fPhysiLayer = new G4PVReplica("Layer", 333 new G4PVReplica("Layer", fLogicLayer, fL << 356 fLogicLayer, 334 } << 357 fLogicCalor, 335 else { << 358 kXAxis, 336 fPhysiLayer = << 359 fNbOfLayers, 337 new G4PVPlacement(0, G4ThreeVector(), fL << 360 fLayerThickness); >> 361 } else { >> 362 fPhysiLayer = new G4PVPlacement(0, >> 363 G4ThreeVector(), >> 364 fLogicLayer, >> 365 "Layer", >> 366 fLogicCalor, >> 367 false, >> 368 0); 338 } 369 } 339 // 370 // 340 // Absorbers 371 // Absorbers 341 // 372 // 342 373 343 G4double xfront = -0.5 * fLayerThickness; << 374 G4double xfront = -0.5*fLayerThickness; 344 for (G4int k = 1; k <= fNbOfAbsor; ++k) { << 375 for (G4int k=1; k<=fNbOfAbsor; ++k) { 345 fSolidAbsor[k] = new G4Box("Absorber", // << 376 fSolidAbsor[k] = new G4Box("Absorber", //its name 346 fAbsorThickness << 377 fAbsorThickness[k]/2,fCalorSizeYZ/2,fCalorSizeYZ/2); 347 378 348 fLogicAbsor[k] = new G4LogicalVolume(fSoli << 379 fLogicAbsor[k] = new G4LogicalVolume(fSolidAbsor[k], //its solid 349 fAbso << 380 fAbsorMaterial[k], //its material 350 fAbso 381 fAbsorMaterial[k]->GetName()); 351 382 352 G4double xcenter = xfront + 0.5 * fAbsorTh << 383 G4double xcenter = xfront+0.5*fAbsorThickness[k]; 353 xfront += fAbsorThickness[k]; 384 xfront += fAbsorThickness[k]; 354 fPhysiAbsor[k] = new G4PVPlacement(0, G4Th << 385 fPhysiAbsor[k] = new G4PVPlacement(0, 355 fAbsorM << 386 G4ThreeVector(xcenter,0.,0.), 356 k); // << 387 fLogicAbsor[k], >> 388 fAbsorMaterial[k]->GetName(), >> 389 fLogicLayer, >> 390 false, >> 391 k); //copy number >> 392 357 } 393 } 358 394 359 PrintCalorParameters(); 395 PrintCalorParameters(); 360 396 361 // always return the fPhysical World << 397 //always return the fPhysical World 362 // 398 // 363 return fPhysiWorld; 399 return fPhysiWorld; 364 } 400 } 365 401 366 //....oooOO0OOooo........oooOO0OOooo........oo 402 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 367 403 368 void DetectorConstruction::PrintCalorParameter 404 void DetectorConstruction::PrintCalorParameters() 369 { 405 { 370 G4cout << "\n------------------------------- 406 G4cout << "\n-------------------------------------------------------------" 371 << "\n ---> The calorimeter is " << f 407 << "\n ---> The calorimeter is " << fNbOfLayers << " layers of:"; 372 for (G4int i = 1; i <= fNbOfAbsor; ++i) { << 408 for (G4int i=1; i<=fNbOfAbsor; ++i) { 373 G4cout << "\n \t" << std::setw(12) << fAbs << 409 G4cout << "\n \t" << std::setw(12) << fAbsorMaterial[i]->GetName() <<": " 374 << G4BestUnit(fAbsorThickness[i], " << 410 << std::setw(6) << G4BestUnit(fAbsorThickness[i],"Length"); 375 } 411 } 376 G4cout << "\n------------------------------- 412 G4cout << "\n-------------------------------------------------------------\n"; 377 << 413 378 G4cout << "\n" << fWorldMaterial << G4endl; << 414 G4cout << "\n" << fWorldMaterial << G4endl; 379 for (G4int j = 1; j <= fNbOfAbsor; ++j) { << 415 for (G4int j=1; j<=fNbOfAbsor; ++j) { 380 G4cout << "\n" << fAbsorMaterial[j] << G4e 416 G4cout << "\n" << fAbsorMaterial[j] << G4endl; 381 } 417 } 382 G4cout << "\n------------------------------- 418 G4cout << "\n-------------------------------------------------------------\n"; 383 } 419 } 384 420 385 //....oooOO0OOooo........oooOO0OOooo........oo 421 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 386 422 387 void DetectorConstruction::SetWorldMaterial(co 423 void DetectorConstruction::SetWorldMaterial(const G4String& material) 388 { 424 { 389 // search the material by its name 425 // search the material by its name 390 G4Material* pttoMaterial = G4NistManager::In << 426 G4Material* pttoMaterial = 391 if (pttoMaterial) { << 427 G4NistManager::Instance()->FindOrBuildMaterial(material); >> 428 if(pttoMaterial) { 392 fWorldMaterial = pttoMaterial; 429 fWorldMaterial = pttoMaterial; 393 if (fLogicWorld) { << 430 if(fLogicWorld) { 394 fLogicWorld->SetMaterial(fWorldMaterial) 431 fLogicWorld->SetMaterial(fWorldMaterial); 395 fLogicLayer->SetMaterial(fWorldMaterial) 432 fLogicLayer->SetMaterial(fWorldMaterial); 396 G4RunManager::GetRunManager()->PhysicsHa 433 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 397 } 434 } 398 } 435 } 399 } 436 } 400 437 401 //....oooOO0OOooo........oooOO0OOooo........oo 438 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 402 439 403 void DetectorConstruction::SetNbOfLayers(G4int 440 void DetectorConstruction::SetNbOfLayers(G4int ival) 404 { 441 { 405 // set the number of Layers 442 // set the number of Layers 406 // 443 // 407 if (ival < 1) { << 444 if (ival < 1) 408 G4cout << "\n --->warning from SetfNbOfLay << 445 { G4cout << "\n --->warning from SetfNbOfLayers: " 409 << " must be at least 1. Command re << 446 << ival << " must be at least 1. Command refused" << G4endl; 410 return; << 447 return; 411 } << 448 } 412 fNbOfLayers = ival; 449 fNbOfLayers = ival; 413 } 450 } 414 451 415 //....oooOO0OOooo........oooOO0OOooo........oo 452 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 416 453 417 void DetectorConstruction::SetNbOfAbsor(G4int 454 void DetectorConstruction::SetNbOfAbsor(G4int ival) 418 { 455 { 419 // set the number of Absorbers 456 // set the number of Absorbers 420 // 457 // 421 if (ival < 1 || ival > (kMaxAbsor - 1)) { << 458 if (ival < 1 || ival > (kMaxAbsor-1)) 422 G4cout << "\n ---> warning from SetfNbOfAb << 459 { G4cout << "\n ---> warning from SetfNbOfAbsor: " 423 << kMaxAbsor - 1 << ". Command refu << 460 << ival << " must be at least 1 and and most " << kMaxAbsor-1 424 return; << 461 << ". Command refused" << G4endl; 425 } << 462 return; >> 463 } 426 fNbOfAbsor = ival; 464 fNbOfAbsor = ival; 427 } 465 } 428 466 429 //....oooOO0OOooo........oooOO0OOooo........oo 467 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 430 468 431 void DetectorConstruction::SetAbsorMaterial(G4 << 469 void DetectorConstruction::SetAbsorMaterial(G4int ival, >> 470 const G4String& material) 432 { 471 { 433 // search the material by its name 472 // search the material by its name 434 // 473 // 435 if (ival > fNbOfAbsor || ival <= 0) { << 474 if (ival > fNbOfAbsor || ival <= 0) 436 G4cout << "\n --->warning from SetAbsorMat << 475 { G4cout << "\n --->warning from SetAbsorMaterial: absor number " 437 << " out of range. Command refused" << 476 << ival << " out of range. Command refused" << G4endl; 438 return; << 477 return; 439 } << 478 } 440 479 441 G4Material* pttoMaterial = G4NistManager::In << 480 G4Material* pttoMaterial = >> 481 G4NistManager::Instance()->FindOrBuildMaterial(material); 442 if (pttoMaterial) { 482 if (pttoMaterial) { 443 fAbsorMaterial[ival] = pttoMaterial; 483 fAbsorMaterial[ival] = pttoMaterial; 444 if (fLogicAbsor[ival]) { << 484 if(fLogicAbsor[ival]) { 445 fLogicAbsor[ival]->SetMaterial(pttoMater 485 fLogicAbsor[ival]->SetMaterial(pttoMaterial); 446 G4RunManager::GetRunManager()->PhysicsHa << 486 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 447 } 487 } 448 } 488 } 449 } 489 } 450 490 451 //....oooOO0OOooo........oooOO0OOooo........oo 491 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 452 492 453 void DetectorConstruction::SetAbsorThickness(G 493 void DetectorConstruction::SetAbsorThickness(G4int ival, G4double val) 454 { 494 { 455 // change Absorber thickness 495 // change Absorber thickness 456 // 496 // 457 if (ival > fNbOfAbsor || ival <= 0) { << 497 if (ival > fNbOfAbsor || ival <= 0) 458 G4cout << "\n --->warning from SetAbsorThi << 498 { G4cout << "\n --->warning from SetAbsorThickness: absor number " 459 << " out of range. Command refused" << 499 << ival << " out of range. Command refused" << G4endl; 460 return; << 500 return; 461 } << 501 } 462 if (val <= DBL_MIN) { << 502 if (val <= DBL_MIN) 463 G4cout << "\n --->warning from SetAbsorThi << 503 { G4cout << "\n --->warning from SetAbsorThickness: thickness " 464 << " out of range. Command refused" << 504 << val << " out of range. Command refused" << G4endl; 465 return; << 505 return; 466 } << 506 } 467 fAbsorThickness[ival] = val; 507 fAbsorThickness[ival] = val; 468 } 508 } 469 509 470 //....oooOO0OOooo........oooOO0OOooo........oo 510 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 471 511 472 void DetectorConstruction::SetCalorSizeYZ(G4do 512 void DetectorConstruction::SetCalorSizeYZ(G4double val) 473 { 513 { 474 // change the transverse size 514 // change the transverse size 475 // 515 // 476 if (val <= DBL_MIN) { << 516 if (val <= DBL_MIN) 477 G4cout << "\n --->warning from SetfCalorSi << 517 { G4cout << "\n --->warning from SetfCalorSizeYZ: thickness " 478 << " out of range. Command refused" << 518 << val << " out of range. Command refused" << G4endl; 479 return; << 519 return; 480 } << 520 } 481 fCalorSizeYZ = val; 521 fCalorSizeYZ = val; 482 } 522 } 483 523 484 //....oooOO0OOooo........oooOO0OOooo........oo 524 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 485 525 486 #include "G4AutoDelete.hh" << 487 #include "G4GlobalMagFieldMessenger.hh" 526 #include "G4GlobalMagFieldMessenger.hh" >> 527 #include "G4AutoDelete.hh" 488 528 489 void DetectorConstruction::ConstructSDandField 529 void DetectorConstruction::ConstructSDandField() 490 { 530 { 491 if (fFieldMessenger.Get() == nullptr) { << 531 if ( fFieldMessenger.Get() == nullptr ) { 492 // Create global magnetic field messenger. 532 // Create global magnetic field messenger. 493 // Uniform magnetic field is then created 533 // Uniform magnetic field is then created automatically if 494 // the field value is not zero. 534 // the field value is not zero. 495 G4ThreeVector fieldValue = G4ThreeVector() 535 G4ThreeVector fieldValue = G4ThreeVector(); 496 G4GlobalMagFieldMessenger* msg = new G4Glo << 536 G4GlobalMagFieldMessenger* msg = 497 // msg->SetVerboseLevel(1); << 537 new G4GlobalMagFieldMessenger(fieldValue); >> 538 //msg->SetVerboseLevel(1); 498 G4AutoDelete::Register(msg); 539 G4AutoDelete::Register(msg); 499 fFieldMessenger.Put(msg); << 540 fFieldMessenger.Put( msg ); 500 } 541 } 501 } 542 } 502 543 503 //....oooOO0OOooo........oooOO0OOooo........oo 544 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 504 545