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