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