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/TestEm5/src/Detector 26 /// \file electromagnetic/TestEm5/src/DetectorConstruction.cc 27 /// \brief Implementation of the DetectorConst 27 /// \brief Implementation of the DetectorConstruction class 28 // 28 // >> 29 // $Id$ 29 // 30 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 33 33 #include "DetectorConstruction.hh" 34 #include "DetectorConstruction.hh" 34 << 35 #include "DetectorMessenger.hh" 35 #include "DetectorMessenger.hh" 36 36 37 #include "G4AutoDelete.hh" << 37 #include "G4Material.hh" 38 #include "G4Box.hh" 38 #include "G4Box.hh" 39 #include "G4GeometryManager.hh" << 40 #include "G4GlobalMagFieldMessenger.hh" << 41 #include "G4LogicalVolume.hh" 39 #include "G4LogicalVolume.hh" 42 #include "G4LogicalVolumeStore.hh" << 43 #include "G4Material.hh" << 44 #include "G4NistManager.hh" << 45 #include "G4PVPlacement.hh" 40 #include "G4PVPlacement.hh" 46 #include "G4PhysicalConstants.hh" << 41 #include "G4UniformMagField.hh" >> 42 >> 43 #include "G4GeometryManager.hh" 47 #include "G4PhysicalVolumeStore.hh" 44 #include "G4PhysicalVolumeStore.hh" 48 #include "G4RunManager.hh" << 45 #include "G4LogicalVolumeStore.hh" 49 #include "G4SolidStore.hh" 46 #include "G4SolidStore.hh" 50 #include "G4SystemOfUnits.hh" << 47 51 #include "G4UniformMagField.hh" << 52 #include "G4UnitsTable.hh" 48 #include "G4UnitsTable.hh" >> 49 #include "G4NistManager.hh" >> 50 #include "G4RunManager.hh" >> 51 >> 52 #include "G4PhysicalConstants.hh" >> 53 #include "G4SystemOfUnits.hh" 53 54 54 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 55 56 56 DetectorConstruction::DetectorConstruction() 57 DetectorConstruction::DetectorConstruction() >> 58 :fAbsorberMaterial(0),fWorldMaterial(0),fDefaultWorld(true), >> 59 fSolidWorld(0),fLogicWorld(0),fPhysiWorld(0), >> 60 fSolidAbsorber(0),fLogicAbsorber(0),fPhysiAbsorber(0), >> 61 fMagField(0) 57 { 62 { 58 // default parameter values of the calorimet 63 // default parameter values of the calorimeter 59 fAbsorberThickness = 1. * cm; << 64 fAbsorberThickness = 1.*cm; 60 fAbsorberSizeYZ = 2. * cm; << 65 fAbsorberSizeYZ = 2.*cm; 61 fXposAbs = 0. * cm; << 66 fXposAbs = 0.*cm; 62 ComputeGeomParameters(); << 67 ComputeCalorParameters(); 63 << 68 64 // materials << 69 // materials 65 DefineMaterials(); 70 DefineMaterials(); 66 SetWorldMaterial("G4_Galactic"); << 71 SetWorldMaterial ("Galactic"); 67 SetAbsorberMaterial("G4_Si"); << 72 SetAbsorberMaterial("Silicon"); 68 << 73 69 // create commands for interactive definitio << 74 // create commands for interactive definition of the calorimeter 70 fDetectorMessenger = new DetectorMessenger(t 75 fDetectorMessenger = new DetectorMessenger(this); 71 } 76 } 72 77 73 //....oooOO0OOooo........oooOO0OOooo........oo 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 74 79 75 DetectorConstruction::~DetectorConstruction() 80 DetectorConstruction::~DetectorConstruction() 76 { << 81 { 77 delete fDetectorMessenger; 82 delete fDetectorMessenger; 78 } 83 } 79 84 80 //....oooOO0OOooo........oooOO0OOooo........oo 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 81 86 82 void DetectorConstruction::DefineMaterials() << 87 G4VPhysicalVolume* DetectorConstruction::Construct() 83 { 88 { 84 // This function illustrates the possible wa << 89 return ConstructCalorimeter(); >> 90 } 85 91 86 G4String symbol; // a=mass of a mole; << 92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 87 G4double a, z, density; // z=mean number of << 93 >> 94 void DetectorConstruction::DefineMaterials() >> 95 { >> 96 //This function illustrates the possible ways to define materials >> 97 >> 98 G4String symbol; //a=mass of a mole; >> 99 G4double a, z, density; //z=mean number of protons; 88 100 89 G4int ncomponents, natoms; 101 G4int ncomponents, natoms; 90 G4double fractionmass; 102 G4double fractionmass; 91 G4double temperature, pressure; 103 G4double temperature, pressure; 92 << 104 93 // 105 // 94 // define Elements 106 // define Elements 95 // 107 // 96 108 97 G4Element* H = new G4Element("Hydrogen", sym << 109 G4Element* H = new G4Element("Hydrogen",symbol="H", z= 1, a= 1.01*g/mole); 98 G4Element* C = new G4Element("Carbon", symbo << 110 G4Element* C = new G4Element("Carbon", symbol="C", z= 6, a= 12.01*g/mole); 99 G4Element* N = new G4Element("Nitrogen", sym << 111 G4Element* N = new G4Element("Nitrogen",symbol="N", z= 7, a= 14.01*g/mole); 100 G4Element* O = new G4Element("Oxygen", symbo << 112 G4Element* O = new G4Element("Oxygen", symbol="O", z= 8, a= 16.00*g/mole); 101 G4Element* Na = new G4Element("Sodium", symb << 113 G4Element* Na = new G4Element("Sodium", symbol="Na", z=11, a= 22.99*g/mole); 102 G4Element* Ar = new G4Element("Argon", symbo << 114 G4Element* Ar = new G4Element("Argon", symbol="Ar", z=18, a= 39.95*g/mole); 103 G4Element* I = new G4Element("Iodine", symbo << 115 G4Element* I = new G4Element("Iodine", symbol="I" , z=53, a= 126.90*g/mole); 104 G4Element* Xe = new G4Element("Xenon", symbo << 116 G4Element* Xe = new G4Element("Xenon", symbol="Xe", z=54, a= 131.29*g/mole); 105 117 106 // 118 // 107 // define simple materials 119 // define simple materials 108 // 120 // 109 121 110 new G4Material("H2Liq", z = 1, a = 1.01 * g << 122 new G4Material("H2Liq" , z= 1, a= 1.01*g/mole, density= 70.8*mg/cm3); 111 new G4Material("Beryllium", z = 4, a = 9.01 << 123 new G4Material("Beryllium", z= 4, a= 9.01*g/mole, density= 1.848*g/cm3); 112 new G4Material("Aluminium", z = 13, a = 26.9 << 124 new G4Material("Aluminium", z=13, a=26.98*g/mole, density= 2.700*g/cm3); 113 new G4Material("Silicon", z = 14, a = 28.09 << 125 new G4Material("Silicon" , z=14, a=28.09*g/mole, density= 2.330*g/cm3); 114 << 126 115 G4Material* lAr = new G4Material("liquidArgo << 127 G4Material* lAr = 116 lAr->AddElement(Ar, natoms = 1); << 128 new G4Material("liquidArgon", density= 1.390*g/cm3, ncomponents=1); 117 << 129 lAr->AddElement(Ar, natoms=1); 118 new G4Material("Iron", z = 26, a = 55.85 * g << 130 119 new G4Material("Copper", z = 29, a = 63.55 * << 131 new G4Material("Iron", z=26, a= 55.85*g/mole, density= 7.870*g/cm3); 120 new G4Material("Germanium", z = 32, a = 72.6 << 132 new G4Material("Copper", z=29, a= 63.55*g/mole, density= 8.960*g/cm3); 121 new G4Material("Silver", z = 47, a = 107.87 << 133 new G4Material("Germanium",z=32, a= 72.61*g/mole, density= 5.323*g/cm3); 122 new G4Material("Tungsten", z = 74, a = 183.8 << 134 new G4Material("Silver", z=47, a=107.87*g/mole, density= 10.50*g/cm3); 123 new G4Material("Gold", z = 79, a = 196.97 * << 135 new G4Material("Tungsten", z=74, a=183.85*g/mole, density= 19.30*g/cm3); 124 new G4Material("Lead", z = 82, a = 207.19 * << 136 new G4Material("Gold", z=79, a=196.97*g/mole, density= 19.32*g/cm3); >> 137 new G4Material("Lead", z=82, a=207.19*g/mole, density= 11.35*g/cm3); 125 138 126 // 139 // 127 // define a material from elements. case 1 140 // define a material from elements. case 1: chemical molecule 128 // 141 // 129 142 130 G4Material* H2O = new G4Material("Water", de << 143 G4Material* H2O = new G4Material("Water", density= 1.000*g/cm3, ncomponents=2); 131 H2O->AddElement(H, natoms = 2); << 144 H2O->AddElement(H, natoms=2); 132 H2O->AddElement(O, natoms = 1); << 145 H2O->AddElement(O, natoms=1); 133 H2O->GetIonisation()->SetMeanExcitationEnerg << 146 H2O->GetIonisation()->SetMeanExcitationEnergy(78*eV); 134 << 147 135 G4Material* CH = new G4Material("Plastic", d << 148 G4Material* CH = new G4Material("Plastic", density= 1.04*g/cm3, ncomponents=2); 136 CH->AddElement(C, natoms = 1); << 149 CH->AddElement(C, natoms=1); 137 CH->AddElement(H, natoms = 1); << 150 CH->AddElement(H, natoms=1); 138 << 151 139 G4Material* NaI = new G4Material("NaI", dens << 152 G4Material* NaI = new G4Material("NaI", density= 3.67*g/cm3, ncomponents=2); 140 NaI->AddElement(Na, natoms = 1); << 153 NaI->AddElement(Na, natoms=1); 141 NaI->AddElement(I, natoms = 1); << 154 NaI->AddElement(I , natoms=1); 142 NaI->GetIonisation()->SetMeanExcitationEnerg << 155 NaI->GetIonisation()->SetMeanExcitationEnergy(452*eV); 143 156 144 // 157 // 145 // define a material from elements. case 2 158 // define a material from elements. case 2: mixture by fractional mass 146 // 159 // 147 160 148 G4Material* Air = new G4Material("Air", dens << 161 G4Material* Air = new G4Material("Air", density= 1.290*mg/cm3, ncomponents=2); 149 Air->AddElement(N, fractionmass = 0.7); << 162 Air->AddElement(N, fractionmass=0.7); 150 Air->AddElement(O, fractionmass = 0.3); << 163 Air->AddElement(O, fractionmass=0.3); 151 << 164 152 G4Material* Air20 = new G4Material("Air20", << 165 G4Material* Air20 = 153 kStateGas << 166 new G4Material("Air20", density= 1.205*mg/cm3, ncomponents=2, 154 Air20->AddElement(N, fractionmass = 0.7); << 167 kStateGas, 293.*kelvin, 1.*atmosphere); 155 Air20->AddElement(O, fractionmass = 0.3); << 168 Air20->AddElement(N, fractionmass=0.7); 156 << 169 Air20->AddElement(O, fractionmass=0.3); 157 // Graphite << 170 158 // << 171 //Graphite 159 G4Material* Graphite = new G4Material("Graph << 172 // 160 Graphite->AddElement(C, fractionmass = 1.); << 173 G4Material* Graphite = 161 << 174 new G4Material("Graphite", density= 1.7*g/cm3, ncomponents=1); 162 // Havar << 175 Graphite->AddElement(C, fractionmass=1.); 163 // << 176 164 G4Element* Cr = new G4Element("Chrome", "Cr" << 177 //Havar 165 G4Element* Fe = new G4Element("Iron", "Fe", << 178 // 166 G4Element* Co = new G4Element("Cobalt", "Co" << 179 G4Element* Cr = new G4Element("Chrome", "Cr", z=25, a= 51.996*g/mole); 167 G4Element* Ni = new G4Element("Nickel", "Ni" << 180 G4Element* Fe = new G4Element("Iron" , "Fe", z=26, a= 55.845*g/mole); 168 G4Element* W = new G4Element("Tungsten", "W" << 181 G4Element* Co = new G4Element("Cobalt", "Co", z=27, a= 58.933*g/mole); 169 << 182 G4Element* Ni = new G4Element("Nickel", "Ni", z=28, a= 58.693*g/mole); 170 G4Material* Havar = new G4Material("Havar", << 183 G4Element* W = new G4Element("Tungsten","W", z=74, a= 183.850*g/mole); 171 Havar->AddElement(Cr, fractionmass = 0.1785) << 184 172 Havar->AddElement(Fe, fractionmass = 0.1822) << 185 G4Material* Havar = 173 Havar->AddElement(Co, fractionmass = 0.4452) << 186 new G4Material("Havar", density= 8.3*g/cm3, ncomponents=5); 174 Havar->AddElement(Ni, fractionmass = 0.1310) << 187 Havar->AddElement(Cr, fractionmass=0.1785); 175 Havar->AddElement(W, fractionmass = 0.0631); << 188 Havar->AddElement(Fe, fractionmass=0.1822); >> 189 Havar->AddElement(Co, fractionmass=0.4452); >> 190 Havar->AddElement(Ni, fractionmass=0.1310); >> 191 Havar->AddElement(W , fractionmass=0.0631); 176 192 177 // 193 // 178 // examples of gas 194 // examples of gas 179 // << 195 // 180 new G4Material("ArgonGas", z = 18, a = 39.94 << 196 new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3, 181 273.15 * kelvin, 1 * atmosphe << 197 kStateGas, 273.15*kelvin, 1*atmosphere); 182 << 198 183 new G4Material("XenonGas", z = 54, a = 131.2 << 199 new G4Material("XenonGas", z=54, a=131.29*g/mole, density= 5.458*mg/cm3, 184 293.15 * kelvin, 1 * atmosphe << 200 kStateGas, 293.15*kelvin, 1*atmosphere); 185 << 201 186 G4Material* CO2 = new G4Material("CarbonicGa << 202 G4Material* CO2 = 187 CO2->AddElement(C, natoms = 1); << 203 new G4Material("CarbonicGas", density= 1.977*mg/cm3, ncomponents=2); 188 CO2->AddElement(O, natoms = 2); << 204 CO2->AddElement(C, natoms=1); 189 << 205 CO2->AddElement(O, natoms=2); 190 G4Material* ArCO2 = new G4Material("ArgonCO2 << 206 191 ArCO2->AddElement(Ar, fractionmass = 0.7844) << 207 G4Material* ArCO2 = 192 ArCO2->AddMaterial(CO2, fractionmass = 0.215 << 208 new G4Material("ArgonCO2", density= 1.8223*mg/cm3, ncomponents=2); >> 209 ArCO2->AddElement (Ar, fractionmass=0.7844); >> 210 ArCO2->AddMaterial(CO2, fractionmass=0.2156); 193 211 194 // another way to define mixture of gas per << 212 //another way to define mixture of gas per volume 195 G4Material* NewArCO2 = 213 G4Material* NewArCO2 = 196 new G4Material("NewArgonCO2", density = 1. << 214 new G4Material("NewArgonCO2", density= 1.8223*mg/cm3, ncomponents=3); 197 NewArCO2->AddElement(Ar, natoms = 8); << 215 NewArCO2->AddElement (Ar, natoms=8); 198 NewArCO2->AddElement(C, natoms = 2); << 216 NewArCO2->AddElement (C, natoms=2); 199 NewArCO2->AddElement(O, natoms = 4); << 217 NewArCO2->AddElement (O, natoms=4); 200 << 218 201 G4Material* ArCH4 = new G4Material("ArgonCH4 << 219 G4Material* ArCH4 = 202 ArCH4->AddElement(Ar, natoms = 93); << 220 new G4Material("ArgonCH4", density= 1.709*mg/cm3, ncomponents=3); 203 ArCH4->AddElement(C, natoms = 7); << 221 ArCH4->AddElement (Ar, natoms=93); 204 ArCH4->AddElement(H, natoms = 28); << 222 ArCH4->AddElement (C, natoms=7); 205 << 223 ArCH4->AddElement (H, natoms=28); 206 G4Material* XeCH = new G4Material("XenonMeth << 224 207 ncomponent << 225 G4Material* XeCH = 208 XeCH->AddElement(Xe, natoms = 875); << 226 new G4Material("XenonMethanePropane", density= 4.9196*mg/cm3, ncomponents=3, 209 XeCH->AddElement(C, natoms = 225); << 227 kStateGas, 293.15*kelvin, 1*atmosphere); 210 XeCH->AddElement(H, natoms = 700); << 228 XeCH->AddElement (Xe, natoms=875); 211 << 229 XeCH->AddElement (C, natoms=225); 212 G4Material* steam = new G4Material("WaterSte << 230 XeCH->AddElement (H, natoms=700); 213 steam->AddMaterial(H2O, fractionmass = 1.); << 231 214 steam->GetIonisation()->SetMeanExcitationEne << 232 G4Material* steam = 215 << 233 new G4Material("WaterSteam", density= 1.0*mg/cm3, ncomponents=1); 216 G4Material* rock1 = new G4Material("Standard << 234 steam->AddMaterial(H2O, fractionmass=1.); 217 rock1->AddElement(Na, 1); << 235 steam->GetIonisation()->SetMeanExcitationEnergy(71.6*eV); 218 236 219 // 237 // 220 // example of vacuum 238 // example of vacuum 221 // 239 // 222 density = universe_mean_density; // from Ph << 240 223 pressure = 3.e-18 * pascal; << 241 density = universe_mean_density; //from PhysicalConstants.h 224 temperature = 2.73 * kelvin; << 242 pressure = 3.e-18*pascal; 225 new G4Material("Galactic", z = 1, a = 1.01 * << 243 temperature = 2.73*kelvin; >> 244 new G4Material("Galactic", z=1, a=1.01*g/mole,density, >> 245 kStateGas,temperature,pressure); 226 } 246 } 227 247 228 //....oooOO0OOooo........oooOO0OOooo........oo 248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 229 249 230 void DetectorConstruction::ComputeGeomParamete << 250 void DetectorConstruction::ComputeCalorParameters() 231 { 251 { 232 // Compute derived parameters of the calorim 252 // Compute derived parameters of the calorimeter 233 fXstartAbs = fXposAbs - 0.5 * fAbsorberThick << 253 fXstartAbs = fXposAbs-0.5*fAbsorberThickness; 234 fXendAbs = fXposAbs + 0.5 * fAbsorberThickne << 254 fXendAbs = fXposAbs+0.5*fAbsorberThickness; 235 << 255 236 G4double xmax = std::max(std::abs(fXstartAbs << 256 if (fDefaultWorld) { 237 fWorldSizeX = 2.4 * xmax; << 257 fWorldSizeX = 1.5*fAbsorberThickness; fWorldSizeYZ= 1.2*fAbsorberSizeYZ; 238 fWorldSizeYZ = 1.2 * fAbsorberSizeYZ; << 258 } 239 if (nullptr != fPhysiWorld) { << 240 ChangeGeometry(); << 241 } << 242 } 259 } 243 260 244 //....oooOO0OOooo........oooOO0OOooo........oo 261 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 245 << 262 246 G4VPhysicalVolume* DetectorConstruction::Const << 263 G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter() 247 { << 264 { 248 if (nullptr != fPhysiWorld) { << 265 // Cleanup old geometry 249 return fPhysiWorld; << 266 // 250 } << 267 G4GeometryManager::GetInstance()->OpenGeometry(); >> 268 G4PhysicalVolumeStore::GetInstance()->Clean(); >> 269 G4LogicalVolumeStore::GetInstance()->Clean(); >> 270 G4SolidStore::GetInstance()->Clean(); >> 271 >> 272 // complete the Calor parameters definition >> 273 ComputeCalorParameters(); >> 274 251 // World 275 // World 252 // 276 // 253 fSolidWorld = new G4Box("World", // its nam << 277 fSolidWorld = new G4Box("World", //its name 254 fWorldSizeX / 2, fWo << 278 fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size 255 << 279 256 fLogicWorld = new G4LogicalVolume(fSolidWorl << 280 fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid 257 fWorldMate << 281 fWorldMaterial, //its material 258 "World"); << 282 "World"); //its name 259 << 283 260 fPhysiWorld = new G4PVPlacement(0, // no ro << 284 fPhysiWorld = new G4PVPlacement(0, //no rotation 261 G4ThreeVecto << 285 G4ThreeVector(), //at (0,0,0) 262 fLogicWorld, << 286 fLogicWorld, //its logical volume 263 "World", // << 287 "World", //its name 264 0, // its m << 288 0, //its mother volume 265 false, // n << 289 false, //no boolean operation 266 0); // copy << 290 0); //copy number 267 << 291 268 // Absorber 292 // Absorber 269 // << 293 // 270 fSolidAbsorber = << 294 fSolidAbsorber = new G4Box("Absorber", 271 new G4Box("Absorber", fAbsorberThickness / << 295 fAbsorberThickness/2,fAbsorberSizeYZ/2,fAbsorberSizeYZ/2); 272 << 296 273 fLogicAbsorber = new G4LogicalVolume(fSolidA << 297 fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber, //its solid 274 fAbsorb << 298 fAbsorberMaterial, //its material 275 "Absorb << 299 "Absorber"); //its name 276 << 300 277 fPhysiAbsorber = new G4PVPlacement(0, // no << 301 fPhysiAbsorber = new G4PVPlacement(0, //no rotation 278 G4ThreeVe << 302 G4ThreeVector(fXposAbs,0.,0.), //its position 279 fLogicAbs << 303 fLogicAbsorber, //its logical volume 280 "Absorber << 304 "Absorber", //its name 281 fLogicWor << 305 fLogicWorld, //its mother 282 false, / << 306 false, //no boulean operat 283 0); // c << 307 0); //copy number 284 << 308 285 PrintGeomParameters(); << 309 PrintCalorParameters(); 286 << 310 287 // always return the physical World << 311 //always return the physical World 288 // 312 // 289 return fPhysiWorld; 313 return fPhysiWorld; 290 } 314 } 291 315 292 //....oooOO0OOooo........oooOO0OOooo........oo 316 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 293 317 294 void DetectorConstruction::PrintGeomParameters << 318 void DetectorConstruction::PrintCalorParameters() 295 { 319 { 296 G4cout << "\n" << fWorldMaterial << G4endl; << 320 G4cout << "\n" << fWorldMaterial << G4endl; 297 G4cout << "\n" << fAbsorberMaterial << G4end 321 G4cout << "\n" << fAbsorberMaterial << G4endl; 298 << 322 299 G4cout << "\n The WORLD is made of " << G << 323 G4cout << "\n The WORLD is made of " << G4BestUnit(fWorldSizeX,"Length") 300 << fWorldMaterial->GetName(); << 324 << " of " << fWorldMaterial->GetName(); 301 G4cout << ". The transverse size (YZ) of the << 325 G4cout << ". The transverse size (YZ) of the world is " 302 << G4endl; << 326 << G4BestUnit(fWorldSizeYZ,"Length") << G4endl; 303 G4cout << " The ABSORBER is made of " << G4B << 327 G4cout << " The ABSORBER is made of " 304 << fAbsorberMaterial->GetName(); << 328 <<G4BestUnit(fAbsorberThickness,"Length") 305 G4cout << ". The transverse size (YZ) is " < << 329 << " of " << fAbsorberMaterial->GetName(); 306 G4cout << " X position of the middle of the << 330 G4cout << ". The transverse size (YZ) is " >> 331 << G4BestUnit(fAbsorberSizeYZ,"Length") << G4endl; >> 332 G4cout << " X position of the middle of the absorber " >> 333 << G4BestUnit(fXposAbs,"Length"); 307 G4cout << G4endl; 334 G4cout << G4endl; 308 } 335 } 309 336 310 //....oooOO0OOooo........oooOO0OOooo........oo 337 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 311 338 312 void DetectorConstruction::SetAbsorberMaterial << 339 void DetectorConstruction::SetAbsorberMaterial(G4String materialChoice) 313 { 340 { 314 // search the material by its name 341 // search the material by its name 315 G4Material* pttoMaterial = G4NistManager::In << 342 G4Material* pttoMaterial = >> 343 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 316 344 317 if (pttoMaterial && fAbsorberMaterial != ptt 345 if (pttoMaterial && fAbsorberMaterial != pttoMaterial) { 318 fAbsorberMaterial = pttoMaterial; << 346 fAbsorberMaterial = pttoMaterial; 319 if (fLogicAbsorber) { << 347 if(fLogicAbsorber) fLogicAbsorber->SetMaterial(fAbsorberMaterial); 320 fLogicAbsorber->SetMaterial(fAbsorberMat << 321 } << 322 G4RunManager::GetRunManager()->PhysicsHasB 348 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 323 } 349 } 324 } 350 } 325 351 326 //....oooOO0OOooo........oooOO0OOooo........oo 352 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 327 353 328 void DetectorConstruction::SetWorldMaterial(co << 354 void DetectorConstruction::SetWorldMaterial(G4String materialChoice) 329 { 355 { 330 // search the material by its name 356 // search the material by its name 331 G4Material* pttoMaterial = G4NistManager::In << 357 G4Material* pttoMaterial = >> 358 G4NistManager::Instance()->FindOrBuildMaterial(materialChoice); 332 359 333 if (pttoMaterial && fWorldMaterial != pttoMa 360 if (pttoMaterial && fWorldMaterial != pttoMaterial) { 334 fWorldMaterial = pttoMaterial; << 361 fWorldMaterial = pttoMaterial; 335 if (fLogicWorld) { << 362 if(fLogicWorld) fLogicWorld->SetMaterial(fWorldMaterial); 336 fLogicWorld->SetMaterial(fWorldMaterial) << 337 } << 338 G4RunManager::GetRunManager()->PhysicsHasB 363 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 339 } 364 } 340 } 365 } 341 << 366 342 //....oooOO0OOooo........oooOO0OOooo........oo 367 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 343 368 344 void DetectorConstruction::SetAbsorberThicknes 369 void DetectorConstruction::SetAbsorberThickness(G4double val) 345 { 370 { 346 fAbsorberThickness = val; 371 fAbsorberThickness = val; 347 ComputeGeomParameters(); << 372 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 348 } << 373 } 349 374 350 //....oooOO0OOooo........oooOO0OOooo........oo 375 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 351 376 352 void DetectorConstruction::SetAbsorberSizeYZ(G 377 void DetectorConstruction::SetAbsorberSizeYZ(G4double val) 353 { 378 { 354 fAbsorberSizeYZ = val; 379 fAbsorberSizeYZ = val; 355 ComputeGeomParameters(); << 380 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 356 } << 381 } 357 382 358 //....oooOO0OOooo........oooOO0OOooo........oo 383 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 359 384 360 void DetectorConstruction::SetWorldSizeX(G4dou 385 void DetectorConstruction::SetWorldSizeX(G4double val) 361 { 386 { 362 fWorldSizeX = val; 387 fWorldSizeX = val; 363 ComputeGeomParameters(); << 388 fDefaultWorld = false; 364 } << 389 G4RunManager::GetRunManager()->GeometryHasBeenModified(); >> 390 } 365 391 366 //....oooOO0OOooo........oooOO0OOooo........oo 392 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 367 393 368 void DetectorConstruction::SetWorldSizeYZ(G4do 394 void DetectorConstruction::SetWorldSizeYZ(G4double val) 369 { 395 { 370 fWorldSizeYZ = val; 396 fWorldSizeYZ = val; 371 ComputeGeomParameters(); << 397 fDefaultWorld = false; 372 } << 398 G4RunManager::GetRunManager()->GeometryHasBeenModified(); >> 399 } 373 400 374 //....oooOO0OOooo........oooOO0OOooo........oo 401 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 375 402 376 void DetectorConstruction::SetAbsorberXpos(G4d 403 void DetectorConstruction::SetAbsorberXpos(G4double val) 377 { 404 { 378 fXposAbs = val; << 405 fXposAbs = val; 379 ComputeGeomParameters(); << 406 G4RunManager::GetRunManager()->GeometryHasBeenModified(); 380 } << 407 } 381 408 382 //....oooOO0OOooo........oooOO0OOooo........oo 409 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 383 410 384 void DetectorConstruction::ConstructSDandField << 411 #include "G4FieldManager.hh" >> 412 #include "G4TransportationManager.hh" >> 413 >> 414 void DetectorConstruction::SetMagField(G4double fieldValue) 385 { 415 { 386 if (fFieldMessenger.Get() == 0) { << 416 //apply a global uniform magnetic field along Z axis 387 // Create global magnetic field messenger. << 417 G4FieldManager* fieldMgr 388 // Uniform magnetic field is then created << 418 = G4TransportationManager::GetTransportationManager()->GetFieldManager(); 389 // the field value is not zero. << 419 390 G4ThreeVector fieldValue = G4ThreeVector() << 420 if(fMagField) delete fMagField; //delete the existing magn field 391 G4GlobalMagFieldMessenger* msg = new G4Glo << 421 392 // msg->SetVerboseLevel(1); << 422 if(fieldValue!=0.) // create a new one if non nul 393 G4AutoDelete::Register(msg); << 423 { fMagField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue)); 394 fFieldMessenger.Put(msg); << 424 fieldMgr->SetDetectorField(fMagField); >> 425 fieldMgr->CreateChordFinder(fMagField); >> 426 } else { >> 427 fMagField = NULL; >> 428 fieldMgr->SetDetectorField(fMagField); 395 } 429 } 396 } 430 } 397 431 398 //....oooOO0OOooo........oooOO0OOooo........oo << 432 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 399 433 400 void DetectorConstruction::ChangeGeometry() << 434 void DetectorConstruction::UpdateGeometry() 401 { 435 { 402 fSolidWorld->SetXHalfLength(fWorldSizeX * 0. << 436 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 403 fSolidWorld->SetYHalfLength(fWorldSizeYZ * 0 << 437 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter()); 404 fSolidWorld->SetZHalfLength(fWorldSizeYZ * 0 << 405 << 406 fSolidAbsorber->SetXHalfLength(fAbsorberThic << 407 fSolidAbsorber->SetYHalfLength(fAbsorberSize << 408 fSolidAbsorber->SetZHalfLength(fAbsorberSize << 409 } 438 } 410 439 411 //....oooOO0OOooo........oooOO0OOooo........oo 440 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 441 412 442