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.23 2009-03-04 18:49:17 maire Exp $ 27 /// \brief Implementation of the DetectorConst << 27 // GEANT4 tag $Name: geant4-09-04-patch-01 $ 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; 233 << 243 234 G4Material* CO2 = << 244 G4Material* CO2 = 235 new G4Material("CarbonicGas", density = 27 << 245 new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2, 236 temperature = 325. * kelvin << 246 kStateGas, temperature= 325.*kelvin, pressure= 50.*atmosphere); 237 CO2->AddElement(C, natoms = 1); << 247 CO2->AddElement(C, natoms=1); 238 CO2->AddElement(O, natoms = 2); << 248 CO2->AddElement(O, natoms=2); 239 << 249 240 G4Material* steam = << 250 G4Material* steam = 241 new G4Material("WaterSteam", density = 1.0 << 251 new G4Material("WaterSteam", density= 1.0*mg/cm3, ncomponents=1, 242 temperature = 273 * kelvin, << 252 kStateGas, temperature= 273*kelvin, pressure= 1*atmosphere); 243 steam->AddMaterial(H2O, fractionmass = 1.); << 253 steam->AddMaterial(H2O, fractionmass=1.); 244 << 254 245 new G4Material("ArgonGas", z = 18, a = 39.94 << 255 new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3, 246 273.15 * kelvin, 1 * atmosphe << 256 kStateGas, 273.15*kelvin, 1*atmosphere); 247 // 257 // 248 // examples of vacuum 258 // examples of vacuum 249 // 259 // 250 260 251 density = universe_mean_density; // from Ph << 261 density = universe_mean_density; //from PhysicalConstants.h 252 pressure = 3.e-18 * pascal; << 262 pressure = 3.e-18*pascal; 253 temperature = 2.73 * kelvin; << 263 temperature = 2.73*kelvin; 254 new G4Material("Galactic", z = 1., a = 1.008 << 264 new G4Material("Galactic", z=1., a=1.008*g/mole, density, 255 pressure); << 265 kStateGas,temperature,pressure); 256 << 266 257 density = 1.e-5 * g / cm3; << 267 density = 1.e-5*g/cm3; 258 pressure = 2.e-2 * bar; << 268 pressure = 2.e-2*bar; 259 temperature = STP_Temperature; // from Phys << 269 temperature = STP_Temperature; //from PhysicalConstants.h 260 G4Material* beam = << 270 G4Material* beam = 261 new G4Material("Beam", density, ncomponent << 271 new G4Material("Beam", density, ncomponents=1, 262 beam->AddMaterial(Air, fractionmass = 1.); << 272 kStateGas,temperature,pressure); >> 273 beam->AddMaterial(Air, fractionmass=1.); 263 274 264 // G4cout << *(G4Material::GetMaterialTable 275 // G4cout << *(G4Material::GetMaterialTable()) << G4endl; 265 } 276 } 266 277 267 //....oooOO0OOooo........oooOO0OOooo........oo 278 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 268 279 269 void DetectorConstruction::ComputeCalorParamet 280 void DetectorConstruction::ComputeCalorParameters() 270 { 281 { 271 // Compute derived parameters of the calorim 282 // Compute derived parameters of the calorimeter 272 fLayerThickness = 0.; << 283 LayerThickness = 0.; 273 for (G4int iAbs = 1; iAbs <= fNbOfAbsor; iAb << 284 for (G4int iAbs=1; iAbs<=NbOfAbsor; iAbs++) { 274 fLayerThickness += fAbsorThickness[iAbs]; << 285 LayerThickness += AbsorThickness[iAbs]; 275 } 286 } 276 fCalorThickness = fNbOfLayers * fLayerThickn << 287 CalorThickness = NbOfLayers*LayerThickness; 277 fWorldSizeX = 1.2 * fCalorThickness; << 288 WorldSizeX = 1.2*CalorThickness; 278 fWorldSizeYZ = 1.2 * fCalorSizeYZ; << 289 WorldSizeYZ = 1.2*CalorSizeYZ; 279 } 290 } 280 291 281 //....oooOO0OOooo........oooOO0OOooo........oo 292 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 282 293 283 G4VPhysicalVolume* DetectorConstruction::Const << 294 G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter() 284 { 295 { 285 if (fPhysiWorld) { << 286 return fPhysiWorld; << 287 } << 288 // complete the Calor parameters definition 296 // complete the Calor parameters definition 289 ComputeCalorParameters(); 297 ComputeCalorParameters(); 290 298 >> 299 // Cleanup old geometry >> 300 G4GeometryManager::GetInstance()->OpenGeometry(); >> 301 G4PhysicalVolumeStore::GetInstance()->Clean(); >> 302 G4LogicalVolumeStore::GetInstance()->Clean(); >> 303 G4SolidStore::GetInstance()->Clean(); >> 304 291 // 305 // 292 // World 306 // World 293 // 307 // 294 fSolidWorld = new G4Box("World", // its nam << 295 fWorldSizeX / 2, fWo << 296 308 297 fLogicWorld = new G4LogicalVolume(fSolidWorl << 309 solidWorld = new G4Box("World", //its name 298 fWorldMate << 310 WorldSizeX/2,WorldSizeYZ/2,WorldSizeYZ/2); //its size 299 "World"); << 311 300 << 312 logicWorld = new G4LogicalVolume(solidWorld, //its solid 301 fPhysiWorld = new G4PVPlacement(0, // no ro << 313 defaultMaterial, //its material 302 G4ThreeVecto << 314 "World"); //its name 303 fLogicWorld, << 315 304 "World", // << 316 physiWorld = new G4PVPlacement(0, //no rotation 305 0, // its m << 317 G4ThreeVector(), //at (0,0,0) 306 false, // n << 318 logicWorld, //its logical volume 307 0); // copy << 319 "World", //its name >> 320 0, //its mother volume >> 321 false, //no boolean operation >> 322 0); //copy number 308 // 323 // 309 // Calorimeter 324 // Calorimeter 310 // 325 // 311 326 312 fSolidCalor = new G4Box("Calorimeter", fCalo << 327 solidCalor = new G4Box("Calorimeter", //its name >> 328 CalorThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);//size 313 329 314 fLogicCalor = new G4LogicalVolume(fSolidCalo << 330 logicCalor = new G4LogicalVolume(solidCalor, //its solid 315 << 331 defaultMaterial, //its material 316 fPhysiCalor = new G4PVPlacement(0, // no ro << 332 "Calorimeter"); //its name 317 G4ThreeVecto << 333 318 fLogicCalor, << 334 physiCalor = new G4PVPlacement(0, //no rotation 319 "Calorimeter << 335 G4ThreeVector(), //at (0,0,0) 320 fLogicWorld, << 336 logicCalor, //its logical volume 321 false, // n << 337 "Calorimeter", //its name 322 0); // copy << 338 logicWorld, //its mother volume >> 339 false, //no boolean operation >> 340 0); //copy number 323 341 324 // 342 // 325 // Layers 343 // Layers 326 // 344 // 327 345 328 fSolidLayer = new G4Box("Layer", fLayerThick << 346 solidLayer = new G4Box("Layer", //its name >> 347 LayerThickness/2,CalorSizeYZ/2,CalorSizeYZ/2); //size >> 348 >> 349 logicLayer = new G4LogicalVolume(solidLayer, //its solid >> 350 defaultMaterial, //its material >> 351 "Layer"); //its name >> 352 if (NbOfLayers > 1) >> 353 physiLayer = new G4PVReplica("Layer", //its name >> 354 logicLayer, //its logical volume >> 355 logicCalor, //its mother >> 356 kXAxis, //axis of replication >> 357 NbOfLayers, //number of replica >> 358 LayerThickness); //witdth of replica >> 359 else >> 360 physiLayer = new G4PVPlacement(0, //no rotation >> 361 G4ThreeVector(), //at (0,0,0) >> 362 logicLayer, //its logical volume >> 363 "Layer", //its name >> 364 logicCalor, //its mother volume >> 365 false, //no boolean operation >> 366 0); //copy number 329 367 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 // 368 // 340 // Absorbers 369 // Absorbers 341 // 370 // 342 371 343 G4double xfront = -0.5 * fLayerThickness; << 372 G4double xfront = -0.5*LayerThickness; 344 for (G4int k = 1; k <= fNbOfAbsor; ++k) { << 373 for (G4int k=1; k<=NbOfAbsor; k++) { 345 fSolidAbsor[k] = new G4Box("Absorber", // << 374 solidAbsor[k] = new G4Box("Absorber", //its name 346 fAbsorThickness << 375 AbsorThickness[k]/2,CalorSizeYZ/2,CalorSizeYZ/2); 347 << 376 348 fLogicAbsor[k] = new G4LogicalVolume(fSoli << 377 logicAbsor[k] = new G4LogicalVolume(solidAbsor[k], //its solid 349 fAbso << 378 AbsorMaterial[k], //its material 350 fAbso << 379 AbsorMaterial[k]->GetName()); 351 << 380 352 G4double xcenter = xfront + 0.5 * fAbsorTh << 381 G4double xcenter = xfront+0.5*AbsorThickness[k]; 353 xfront += fAbsorThickness[k]; << 382 xfront += AbsorThickness[k]; 354 fPhysiAbsor[k] = new G4PVPlacement(0, G4Th << 383 physiAbsor[k] = new G4PVPlacement(0, //no rotation 355 fAbsorM << 384 G4ThreeVector(xcenter,0.,0.), //its position 356 k); // << 385 logicAbsor[k], //its logical volume >> 386 AbsorMaterial[k]->GetName(), //its name >> 387 logicLayer, //its mother >> 388 false, //no boulean operat >> 389 k); //copy number >> 390 357 } 391 } 358 392 >> 393 359 PrintCalorParameters(); 394 PrintCalorParameters(); 360 395 361 // always return the fPhysical World << 396 //always return the physical World 362 // 397 // 363 return fPhysiWorld; << 398 return physiWorld; 364 } 399 } 365 400 366 //....oooOO0OOooo........oooOO0OOooo........oo 401 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 367 402 368 void DetectorConstruction::PrintCalorParameter 403 void DetectorConstruction::PrintCalorParameters() 369 { 404 { 370 G4cout << "\n------------------------------- 405 G4cout << "\n-------------------------------------------------------------" 371 << "\n ---> The calorimeter is " << f << 406 << "\n ---> The calorimeter is " << NbOfLayers << " layers of:"; 372 for (G4int i = 1; i <= fNbOfAbsor; ++i) { << 407 for (G4int i=1; i<=NbOfAbsor; i++) 373 G4cout << "\n \t" << std::setw(12) << fAbs << 408 { 374 << G4BestUnit(fAbsorThickness[i], " << 409 G4cout << "\n \t" << std::setw(12) << AbsorMaterial[i]->GetName() <<": " 375 } << 410 << std::setw(6) << G4BestUnit(AbsorThickness[i],"Length"); >> 411 } 376 G4cout << "\n------------------------------- 412 G4cout << "\n-------------------------------------------------------------\n"; >> 413 >> 414 G4cout << "\n" << defaultMaterial << G4endl; >> 415 for (G4int j=1; j<=NbOfAbsor; j++) >> 416 G4cout << "\n" << AbsorMaterial[j] << G4endl; 377 417 378 G4cout << "\n" << fWorldMaterial << G4endl; << 379 for (G4int j = 1; j <= fNbOfAbsor; ++j) { << 380 G4cout << "\n" << fAbsorMaterial[j] << G4e << 381 } << 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); 392 fWorldMaterial = pttoMaterial; << 428 if (pttoMaterial) defaultMaterial = pttoMaterial; 393 if (fLogicWorld) { << 394 fLogicWorld->SetMaterial(fWorldMaterial) << 395 fLogicLayer->SetMaterial(fWorldMaterial) << 396 G4RunManager::GetRunManager()->PhysicsHa << 397 } << 398 } << 399 } 429 } 400 430 401 //....oooOO0OOooo........oooOO0OOooo........oo 431 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 402 432 403 void DetectorConstruction::SetNbOfLayers(G4int 433 void DetectorConstruction::SetNbOfLayers(G4int ival) 404 { 434 { 405 // set the number of Layers 435 // set the number of Layers 406 // 436 // 407 if (ival < 1) { << 437 if (ival < 1) 408 G4cout << "\n --->warning from SetfNbOfLay << 438 { G4cout << "\n --->warning from SetNbOfLayers: " 409 << " must be at least 1. Command re << 439 << ival << " must be at least 1. Command refused" << G4endl; 410 return; << 440 return; 411 } << 441 } 412 fNbOfLayers = ival; << 442 NbOfLayers = ival; 413 } 443 } 414 444 415 //....oooOO0OOooo........oooOO0OOooo........oo 445 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 416 446 417 void DetectorConstruction::SetNbOfAbsor(G4int 447 void DetectorConstruction::SetNbOfAbsor(G4int ival) 418 { 448 { 419 // set the number of Absorbers 449 // set the number of Absorbers 420 // 450 // 421 if (ival < 1 || ival > (kMaxAbsor - 1)) { << 451 if (ival < 1 || ival > (MaxAbsor-1)) 422 G4cout << "\n ---> warning from SetfNbOfAb << 452 { G4cout << "\n ---> warning from SetNbOfAbsor: " 423 << kMaxAbsor - 1 << ". Command refu << 453 << ival << " must be at least 1 and and most " << MaxAbsor-1 424 return; << 454 << ". Command refused" << G4endl; 425 } << 455 return; 426 fNbOfAbsor = ival; << 456 } >> 457 NbOfAbsor = ival; 427 } 458 } 428 459 429 //....oooOO0OOooo........oooOO0OOooo........oo 460 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 430 461 431 void DetectorConstruction::SetAbsorMaterial(G4 462 void DetectorConstruction::SetAbsorMaterial(G4int ival, const G4String& material) 432 { 463 { 433 // search the material by its name 464 // search the material by its name 434 // 465 // 435 if (ival > fNbOfAbsor || ival <= 0) { << 466 if (ival > NbOfAbsor || ival <= 0) 436 G4cout << "\n --->warning from SetAbsorMat << 467 { G4cout << "\n --->warning from SetAbsorMaterial: absor number " 437 << " out of range. Command refused" << 468 << ival << " out of range. Command refused" << G4endl; 438 return; << 469 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 } 470 } 448 } << 471 >> 472 G4Material* pttoMaterial = >> 473 G4NistManager::Instance()->FindOrBuildMaterial(material); >> 474 if (pttoMaterial) AbsorMaterial[ival] = pttoMaterial; 449 } 475 } 450 476 451 //....oooOO0OOooo........oooOO0OOooo........oo 477 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 452 478 453 void DetectorConstruction::SetAbsorThickness(G << 479 void DetectorConstruction::SetAbsorThickness(G4int ival,G4double val) 454 { 480 { 455 // change Absorber thickness 481 // change Absorber thickness 456 // 482 // 457 if (ival > fNbOfAbsor || ival <= 0) { << 483 if (ival > NbOfAbsor || ival <= 0) 458 G4cout << "\n --->warning from SetAbsorThi << 484 { G4cout << "\n --->warning from SetAbsorThickness: absor number " 459 << " out of range. Command refused" << 485 << ival << " out of range. Command refused" << G4endl; 460 return; << 486 return; 461 } << 487 } 462 if (val <= DBL_MIN) { << 488 if (val <= DBL_MIN) 463 G4cout << "\n --->warning from SetAbsorThi << 489 { G4cout << "\n --->warning from SetAbsorThickness: thickness " 464 << " out of range. Command refused" << 490 << val << " out of range. Command refused" << G4endl; 465 return; << 491 return; 466 } << 492 } 467 fAbsorThickness[ival] = val; << 493 AbsorThickness[ival] = val; 468 } 494 } 469 495 470 //....oooOO0OOooo........oooOO0OOooo........oo 496 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 471 497 472 void DetectorConstruction::SetCalorSizeYZ(G4do 498 void DetectorConstruction::SetCalorSizeYZ(G4double val) 473 { 499 { 474 // change the transverse size 500 // change the transverse size 475 // 501 // 476 if (val <= DBL_MIN) { << 502 if (val <= DBL_MIN) 477 G4cout << "\n --->warning from SetfCalorSi << 503 { G4cout << "\n --->warning from SetCalorSizeYZ: thickness " 478 << " out of range. Command refused" << 504 << val << " out of range. Command refused" << G4endl; 479 return; << 505 return; 480 } << 506 } 481 fCalorSizeYZ = val; << 507 CalorSizeYZ = val; 482 } 508 } 483 509 484 //....oooOO0OOooo........oooOO0OOooo........oo 510 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 485 511 486 #include "G4AutoDelete.hh" << 512 #include "G4FieldManager.hh" 487 #include "G4GlobalMagFieldMessenger.hh" << 513 #include "G4TransportationManager.hh" 488 514 489 void DetectorConstruction::ConstructSDandField << 515 void DetectorConstruction::SetMagField(G4double fieldValue) 490 { 516 { 491 if (fFieldMessenger.Get() == nullptr) { << 517 //apply a global uniform magnetic field along Z axis 492 // Create global magnetic field messenger. << 518 // 493 // Uniform magnetic field is then created << 519 G4FieldManager* fieldMgr 494 // the field value is not zero. << 520 = G4TransportationManager::GetTransportationManager()->GetFieldManager(); 495 G4ThreeVector fieldValue = G4ThreeVector() << 521 496 G4GlobalMagFieldMessenger* msg = new G4Glo << 522 if(magField) delete magField; //delete the existing magn field 497 // msg->SetVerboseLevel(1); << 523 498 G4AutoDelete::Register(msg); << 524 if(fieldValue!=0.) // create a new one if non nul 499 fFieldMessenger.Put(msg); << 525 { magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue)); >> 526 fieldMgr->SetDetectorField(magField); >> 527 fieldMgr->CreateChordFinder(magField); >> 528 } else { >> 529 magField = 0; >> 530 fieldMgr->SetDetectorField(magField); 500 } 531 } >> 532 } >> 533 >> 534 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 535 >> 536 #include "G4RunManager.hh" >> 537 >> 538 void DetectorConstruction::UpdateGeometry() >> 539 { >> 540 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter()); 501 } 541 } 502 542 503 //....oooOO0OOooo........oooOO0OOooo........oo 543 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 504 544