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/TestEm8/src/Detector 26 /// \file electromagnetic/TestEm8/src/DetectorConstruction.cc 27 /// \brief Implementation of the DetectorConst 27 /// \brief Implementation of the DetectorConstruction class 28 // 28 // 29 // 29 // 30 ////////////////////////////////////////////// 30 ///////////////////////////////////////////////////////////////////////// 31 // 31 // 32 // TestEm8: Gaseous detector 32 // TestEm8: Gaseous detector 33 // 33 // 34 // Created: 31.08.2010 V.Ivanchenko ob base of 34 // Created: 31.08.2010 V.Ivanchenko ob base of V.Grichine code 35 // 35 // 36 // Modified: 36 // Modified: 37 // 37 // 38 ////////////////////////////////////////////// 38 //////////////////////////////////////////////////////////////////////// 39 // 39 // 40 //....oooOO0OOooo........oooOO0OOooo........oo 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 41 41 42 #include "DetectorConstruction.hh" 42 #include "DetectorConstruction.hh" 43 << 44 #include "DetectorMessenger.hh" 43 #include "DetectorMessenger.hh" 45 #include "TargetSD.hh" 44 #include "TargetSD.hh" 46 #include "TestParameters.hh" << 47 45 48 #include "G4Colour.hh" << 49 #include "G4GeometryManager.hh" << 50 #include "G4LogicalVolume.hh" << 51 #include "G4LogicalVolumeStore.hh" << 52 #include "G4Material.hh" 46 #include "G4Material.hh" 53 #include "G4NistManager.hh" << 47 #include "G4Tubs.hh" >> 48 #include "G4LogicalVolume.hh" 54 #include "G4PVPlacement.hh" 49 #include "G4PVPlacement.hh" 55 #include "G4PhysicalConstants.hh" << 50 56 #include "G4PhysicalVolumeStore.hh" << 51 #include "G4SDManager.hh" 57 #include "G4PionPlus.hh" << 52 #include "G4GeometryManager.hh" 58 #include "G4ProductionCuts.hh" << 53 #include "G4RunManager.hh" >> 54 #include "G4NistManager.hh" >> 55 59 #include "G4Region.hh" 56 #include "G4Region.hh" 60 #include "G4RegionStore.hh" 57 #include "G4RegionStore.hh" 61 #include "G4RunManager.hh" << 58 #include "G4PhysicalVolumeStore.hh" 62 #include "G4SDManager.hh" << 59 #include "G4LogicalVolumeStore.hh" 63 #include "G4SolidStore.hh" 60 #include "G4SolidStore.hh" 64 #include "G4SystemOfUnits.hh" << 61 #include "G4ProductionCuts.hh" 65 #include "G4Tubs.hh" << 62 66 #include "G4UnitsTable.hh" << 67 #include "G4VisAttributes.hh" 63 #include "G4VisAttributes.hh" >> 64 #include "G4Colour.hh" >> 65 >> 66 #include "G4UnitsTable.hh" >> 67 #include "G4PhysicalConstants.hh" >> 68 #include "G4SystemOfUnits.hh" 68 #include "G4ios.hh" 69 #include "G4ios.hh" >> 70 #include "TestParameters.hh" >> 71 #include "G4PionPlus.hh" 69 72 70 #include <vector> 73 #include <vector> 71 74 72 //....oooOO0OOooo........oooOO0OOooo........oo 75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 73 76 74 DetectorConstruction::DetectorConstruction() << 77 DetectorConstruction::DetectorConstruction() { 75 { << 76 fGasThickness = 23.0 * mm; 78 fGasThickness = 23.0 * mm; 77 fGasRadius = 10. * cm; 79 fGasRadius = 10. * cm; 78 fMaxStep = DBL_MAX; 80 fMaxStep = DBL_MAX; 79 81 80 fWindowThick = 51.0 * micrometer; 82 fWindowThick = 51.0 * micrometer; 81 83 82 DefineMaterials(); 84 DefineMaterials(); 83 85 84 fDetectorMessenger = new DetectorMessenger(t 86 fDetectorMessenger = new DetectorMessenger(this); 85 87 86 G4double cut = 0.7 * mm; 88 G4double cut = 0.7 * mm; 87 fGasDetectorCuts = new G4ProductionCuts(); 89 fGasDetectorCuts = new G4ProductionCuts(); 88 fGasDetectorCuts->SetProductionCut(cut, "gam 90 fGasDetectorCuts->SetProductionCut(cut, "gamma"); 89 fGasDetectorCuts->SetProductionCut(cut, "e-" 91 fGasDetectorCuts->SetProductionCut(cut, "e-"); 90 fGasDetectorCuts->SetProductionCut(cut, "e+" 92 fGasDetectorCuts->SetProductionCut(cut, "e+"); 91 fGasDetectorCuts->SetProductionCut(cut, "pro 93 fGasDetectorCuts->SetProductionCut(cut, "proton"); 92 } 94 } 93 95 94 //....oooOO0OOooo........oooOO0OOooo........oo 96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 95 97 96 DetectorConstruction::~DetectorConstruction() << 98 DetectorConstruction::~DetectorConstruction() { delete fDetectorMessenger; } 97 { << 98 delete fDetectorMessenger; << 99 } << 100 99 101 //....oooOO0OOooo........oooOO0OOooo........oo 100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 102 101 103 void DetectorConstruction::DefineMaterials() << 102 void DetectorConstruction::DefineMaterials() { 104 { << 105 // This function illustrates the possible wa 103 // This function illustrates the possible ways to define materials 106 G4String name, symbol; 104 G4String name, symbol; 107 G4double density; 105 G4double density; 108 G4int nel; 106 G4int nel; 109 G4int ncomponents; 107 G4int ncomponents; 110 G4double fractionmass; 108 G4double fractionmass; 111 109 112 G4NistManager* manager = G4NistManager::Inst << 110 G4NistManager *manager = G4NistManager::Instance(); 113 // 111 // 114 // define Elements 112 // define Elements 115 // 113 // 116 G4Element* elH = manager->FindOrBuildElement << 114 G4Element *elH = manager->FindOrBuildElement(1); 117 G4Element* elC = manager->FindOrBuildElement << 115 G4Element *elC = manager->FindOrBuildElement(6); 118 G4Element* elO = manager->FindOrBuildElement << 116 G4Element *elO = manager->FindOrBuildElement(8); 119 G4Element* elF = manager->FindOrBuildElement << 117 G4Element *elF = manager->FindOrBuildElement(9); 120 G4Element* elNe = manager->FindOrBuildElemen << 118 G4Element *elNe = manager->FindOrBuildElement(10); 121 G4Element* elXe = manager->FindOrBuildElemen << 119 G4Element *elXe = manager->FindOrBuildElement(54); 122 // 120 // 123 // simple gases at STP conditions 121 // simple gases at STP conditions 124 // 122 // 125 G4Material* Argon = manager->FindOrBuildMate << 123 G4Material *Argon = manager->FindOrBuildMaterial("G4_Ar"); 126 G4Material* Kr = manager->FindOrBuildMateria << 124 G4Material *Kr = manager->FindOrBuildMaterial("G4_Kr"); 127 G4Material* Xe = manager->FindOrBuildMateria << 125 G4Material *Xe = manager->FindOrBuildMaterial("G4_Xe"); 128 // 126 // 129 // gases at STP conditions 127 // gases at STP conditions 130 // 128 // 131 G4Material* CarbonDioxide = manager->FindOrB << 129 G4Material *CarbonDioxide = manager->FindOrBuildMaterial("G4_CARBON_DIOXIDE"); 132 G4Material* Mylar = manager->FindOrBuildMate << 130 G4Material *Mylar = manager->FindOrBuildMaterial("G4_MYLAR"); 133 G4Material* Methane = manager->FindOrBuildMa << 131 G4Material *Methane = manager->FindOrBuildMaterial("G4_METHANE"); 134 G4Material* Propane = manager->FindOrBuildMa << 132 G4Material *Propane = manager->FindOrBuildMaterial("G4_PROPANE"); 135 133 136 // propane at 10 atmospheres 134 // propane at 10 atmospheres 137 manager->ConstructNewGasMaterial("Propane10" << 135 manager->ConstructNewGasMaterial("Propane10", "G4_PROPANE", NTP_Temperature, >> 136 10. * atmosphere); 138 137 139 G4Material* empty = manager->FindOrBuildMate << 138 G4Material *empty = manager->FindOrBuildMaterial("G4_Galactic"); 140 139 141 // 93% Kr + 7% CH4, STP 140 // 93% Kr + 7% CH4, STP 142 density = 3.491 * mg / cm3; 141 density = 3.491 * mg / cm3; 143 G4Material* Kr7CH4 = new G4Material(name = " << 142 G4Material *Kr7CH4 = >> 143 new G4Material(name = "Kr7CH4", density, ncomponents = 2); 144 Kr7CH4->AddMaterial(Kr, fractionmass = 0.986 144 Kr7CH4->AddMaterial(Kr, fractionmass = 0.986); 145 Kr7CH4->AddMaterial(Methane, fractionmass = 145 Kr7CH4->AddMaterial(Methane, fractionmass = 0.014); 146 146 147 G4double TRT_Xe_density = 5.485 * mg / cm3; 147 G4double TRT_Xe_density = 5.485 * mg / cm3; 148 G4Material* TRT_Xe = new G4Material(name = " << 148 G4Material *TRT_Xe = 149 293.15 * << 149 new G4Material(name = "TRT_Xe", TRT_Xe_density, nel = 1, kStateGas, >> 150 293.15 * kelvin, 1. * atmosphere); 150 TRT_Xe->AddElement(elXe, 1); 151 TRT_Xe->AddElement(elXe, 1); 151 152 152 G4double TRT_CO2_density = 1.842 * mg / cm3; 153 G4double TRT_CO2_density = 1.842 * mg / cm3; 153 G4Material* TRT_CO2 = new G4Material(name = << 154 G4Material *TRT_CO2 = 154 293.15 << 155 new G4Material(name = "TRT_CO2", TRT_CO2_density, nel = 2, kStateGas, >> 156 293.15 * kelvin, 1. * atmosphere); 155 TRT_CO2->AddElement(elC, 1); 157 TRT_CO2->AddElement(elC, 1); 156 TRT_CO2->AddElement(elO, 2); 158 TRT_CO2->AddElement(elO, 2); 157 159 158 // check alternative constructor 160 // check alternative constructor 159 std::vector<G4String> trtatom = {"C", "O"}; << 161 std::vector<G4String> trtatom = { "C", "O" }; 160 std::vector<G4int> trtnum = {1, 2}; << 162 std::vector<G4int> trtnum = { 1, 2 }; 161 manager->ConstructNewMaterial("TRT_CO2p", tr << 163 manager->ConstructNewMaterial("TRT_CO2p", trtatom, trtnum, TRT_CO2_density, 162 NTP_Temperatur << 164 true, kStateGas, NTP_Temperature, atmosphere); 163 165 164 G4double TRT_CF4_density = 3.9 * mg / cm3; 166 G4double TRT_CF4_density = 3.9 * mg / cm3; 165 G4Material* TRT_CF4 = new G4Material(name = << 167 G4Material *TRT_CF4 = 166 293.15 << 168 new G4Material(name = "TRT_CF4", TRT_CF4_density, nel = 2, kStateGas, >> 169 293.15 * kelvin, 1. * atmosphere); 167 TRT_CF4->AddElement(elC, 1); 170 TRT_CF4->AddElement(elC, 1); 168 TRT_CF4->AddElement(elF, 4); 171 TRT_CF4->AddElement(elF, 4); 169 172 170 // ATLAS TRT straw tube gas mixture (20 C, 1 173 // ATLAS TRT straw tube gas mixture (20 C, 1 atm) 171 G4double XeCO2CF4_density = 4.76 * mg / cm3; 174 G4double XeCO2CF4_density = 4.76 * mg / cm3; 172 G4Material* XeCO2CF4 = new G4Material(name = << 175 G4Material *XeCO2CF4 = 173 kState << 176 new G4Material(name = "XeCO2CF4", XeCO2CF4_density, ncomponents = 3, >> 177 kStateGas, 293.15 * kelvin, 1. * atmosphere); 174 XeCO2CF4->AddMaterial(TRT_Xe, 0.807); 178 XeCO2CF4->AddMaterial(TRT_Xe, 0.807); 175 XeCO2CF4->AddMaterial(TRT_CO2, 0.039); 179 XeCO2CF4->AddMaterial(TRT_CO2, 0.039); 176 XeCO2CF4->AddMaterial(TRT_CF4, 0.154); 180 XeCO2CF4->AddMaterial(TRT_CF4, 0.154); 177 181 178 // C3H8,20 C, 2 atm 182 // C3H8,20 C, 2 atm 179 density = 3.758 * mg / cm3; 183 density = 3.758 * mg / cm3; 180 G4Material* C3H8 = << 184 G4Material *C3H8 = new G4Material(name = "C3H8", density, nel = 2, kStateGas, 181 new G4Material(name = "C3H8", density, nel << 185 293.15 * kelvin, 2. * atmosphere); 182 C3H8->AddElement(elC, 3); 186 C3H8->AddElement(elC, 3); 183 C3H8->AddElement(elH, 8); 187 C3H8->AddElement(elH, 8); 184 188 185 // The same material via different construct 189 // The same material via different constructor 186 std::vector<G4String> elmname = {"C", "H"}; << 190 std::vector<G4String> elmname = { "C", "H" }; 187 std::vector<G4int> atomnum = {3, 8}; << 191 std::vector<G4int> atomnum = { 3, 8 }; 188 manager->ConstructNewIdealGasMaterial("C3H8p << 192 manager->ConstructNewIdealGasMaterial("C3H8p", elmname, atomnum, true, 189 2. * a << 193 293.15 * kelvin, 2. * atmosphere); 190 194 191 // 87.5% Xe + 7.5% CH4 + 5% C3H8, 20 C, 1. a 195 // 87.5% Xe + 7.5% CH4 + 5% C3H8, 20 C, 1. atm 192 density = 4.9196 * mg / cm3; 196 density = 4.9196 * mg / cm3; 193 G4Material* XeCH4C3H8 = new G4Material(name << 197 G4Material *XeCH4C3H8 = 194 NTP_T << 198 new G4Material(name = "XeCH4C3H8", density, ncomponents = 3, kStateGas, >> 199 NTP_Temperature, 1. * atmosphere); 195 XeCH4C3H8->AddMaterial(Xe, fractionmass = 0. 200 XeCH4C3H8->AddMaterial(Xe, fractionmass = 0.971); 196 XeCH4C3H8->AddMaterial(Methane, fractionmass 201 XeCH4C3H8->AddMaterial(Methane, fractionmass = 0.010); 197 XeCH4C3H8->AddMaterial(Propane, fractionmass 202 XeCH4C3H8->AddMaterial(Propane, fractionmass = 0.019); 198 203 199 // 93% Ar + 7% CH4, STP 204 // 93% Ar + 7% CH4, STP 200 density = 1.709 * mg / cm3; 205 density = 1.709 * mg / cm3; 201 G4Material* Ar7CH4 = new G4Material(name = " << 206 G4Material *Ar7CH4 = new G4Material(name = "Ar7CH4", density, ncomponents = 2, 202 STP_Temp << 207 kStateGas, STP_Temperature, STP_Pressure); 203 Ar7CH4->AddMaterial(Argon, fractionmass = 0. 208 Ar7CH4->AddMaterial(Argon, fractionmass = 0.971); 204 Ar7CH4->AddMaterial(Methane, fractionmass = 209 Ar7CH4->AddMaterial(Methane, fractionmass = 0.029); 205 210 206 // 80% Ar + 20% CO2, STP 211 // 80% Ar + 20% CO2, STP 207 density = 1.8223 * mg / cm3; 212 density = 1.8223 * mg / cm3; 208 G4Material* Ar_80CO2_20 = new G4Material(nam << 213 G4Material *Ar_80CO2_20 = 209 STP << 214 new G4Material(name = "ArCO2", density, ncomponents = 2, kStateGas, >> 215 STP_Temperature, STP_Pressure); 210 Ar_80CO2_20->AddMaterial(Argon, fractionmass 216 Ar_80CO2_20->AddMaterial(Argon, fractionmass = 0.783); 211 Ar_80CO2_20->AddMaterial(CarbonDioxide, frac 217 Ar_80CO2_20->AddMaterial(CarbonDioxide, fractionmass = 0.217); 212 218 213 // 80% Xe + 20% CO2, STP 219 // 80% Xe + 20% CO2, STP 214 density = 5.0818 * mg / cm3; 220 density = 5.0818 * mg / cm3; 215 G4Material* Xe20CO2 = new G4Material(name = << 221 G4Material *Xe20CO2 = 216 STP_Tem << 222 new G4Material(name = "Xe20CO2", density, ncomponents = 2, kStateGas, >> 223 STP_Temperature, STP_Pressure); 217 Xe20CO2->AddMaterial(Xe, fractionmass = 0.92 224 Xe20CO2->AddMaterial(Xe, fractionmass = 0.922); 218 Xe20CO2->AddMaterial(CarbonDioxide, fraction 225 Xe20CO2->AddMaterial(CarbonDioxide, fractionmass = 0.078); 219 226 220 // 80% Kr + 20% CO2, STP 227 // 80% Kr + 20% CO2, STP 221 density = 3.601 * mg / cm3; 228 density = 3.601 * mg / cm3; 222 G4Material* Kr20CO2 = new G4Material(name = << 229 G4Material *Kr20CO2 = 223 STP_Tem << 230 new G4Material(name = "Kr20CO2", density, ncomponents = 2, kStateGas, >> 231 STP_Temperature, STP_Pressure); 224 Kr20CO2->AddMaterial(Kr, fractionmass = 0.89 232 Kr20CO2->AddMaterial(Kr, fractionmass = 0.89); 225 Kr20CO2->AddMaterial(CarbonDioxide, fraction 233 Kr20CO2->AddMaterial(CarbonDioxide, fractionmass = 0.11); 226 234 227 // ALICE mixture TPC_Ne-CO2-2 235 // ALICE mixture TPC_Ne-CO2-2 228 density = 0.939 * mg / cm3; 236 density = 0.939 * mg / cm3; 229 G4Material* NeCO2 = new G4Material(name = "T << 237 G4Material *NeCO2 = 230 NTP_Tempe << 238 new G4Material(name = "TPC_Ne-CO2-2", density, ncomponents = 3, kStateGas, >> 239 NTP_Temperature, 1. * atmosphere); 231 NeCO2->AddElement(elNe, fractionmass = 0.803 240 NeCO2->AddElement(elNe, fractionmass = 0.8039); 232 NeCO2->AddElement(elO, fractionmass = 0.1426 241 NeCO2->AddElement(elO, fractionmass = 0.1426); 233 NeCO2->AddElement(elC, fractionmass = 0.0535 242 NeCO2->AddElement(elC, fractionmass = 0.0535); 234 243 235 // check alternative constructor 244 // check alternative constructor 236 std::vector<G4String> neatom = {"Ne", "O", " << 245 std::vector<G4String> neatom = { "Ne", "O", "C" }; 237 std::vector<G4double> nefr = {0.8039, 0.1426 << 246 std::vector<G4double> nefr = { 0.8039, 0.1426, 0.0536 }; 238 manager->ConstructNewMaterial("TPC_Ne-CO2-2p << 247 manager->ConstructNewMaterial("TPC_Ne-CO2-2p", neatom, nefr, density, true, 239 NTP_Temperatur << 248 kStateGas, NTP_Temperature, atmosphere); 240 249 241 // ALICE TRD mixure 85% Xe + 15% CO2 NTP 250 // ALICE TRD mixure 85% Xe + 15% CO2 NTP 242 density = 4.9389 * mg / cm3; 251 density = 4.9389 * mg / cm3; 243 G4Material* Xe15CO2 = new G4Material(name = << 252 G4Material *Xe15CO2 = 244 NTP_Tem << 253 new G4Material(name = "Xe15CO2", density, ncomponents = 2, kStateGas, >> 254 NTP_Temperature, atmosphere); 245 Xe15CO2->AddMaterial(Xe, fractionmass = 0.94 255 Xe15CO2->AddMaterial(Xe, fractionmass = 0.944); 246 Xe15CO2->AddMaterial(CarbonDioxide, fraction 256 Xe15CO2->AddMaterial(CarbonDioxide, fractionmass = 0.056); 247 257 248 fGasMat = XeCH4C3H8; 258 fGasMat = XeCH4C3H8; 249 fWindowMat = Mylar; 259 fWindowMat = Mylar; 250 fWorldMaterial = empty; 260 fWorldMaterial = empty; 251 261 252 G4cout << *(G4Material::GetMaterialTable()) 262 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 253 } 263 } 254 264 255 //....oooOO0OOooo........oooOO0OOooo........oo 265 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 256 266 257 G4VPhysicalVolume* DetectorConstruction::Const << 267 G4VPhysicalVolume *DetectorConstruction::Construct() { 258 { << 268 if(nullptr != fPhysWorld) { return fPhysWorld; } 259 if (nullptr != fPhysWorld) { << 260 return fPhysWorld; << 261 } << 262 269 263 G4double contThick = fWindowThick * 2 + fGas 270 G4double contThick = fWindowThick * 2 + fGasThickness; 264 G4double contR = fWindowThick * 2 + fGasRadi 271 G4double contR = fWindowThick * 2 + fGasRadius; 265 272 266 G4double worldSizeZ = contThick * 1.2; 273 G4double worldSizeZ = contThick * 1.2; 267 G4double worldSizeR = contR * 1.2; 274 G4double worldSizeR = contR * 1.2; 268 275 269 TestParameters::GetPointer()->SetPositionZ(- 276 TestParameters::GetPointer()->SetPositionZ(-0.55 * contThick); 270 277 271 // Printout parameters 278 // Printout parameters 272 G4cout << "\n The WORLD is made of " << w 279 G4cout << "\n The WORLD is made of " << worldSizeZ / mm << "mm of " 273 << fWorldMaterial->GetName(); 280 << fWorldMaterial->GetName(); 274 G4cout << ", the transverse size (R) of the << 281 G4cout << ", the transverse size (R) of the world is " << worldSizeR / mm 275 G4cout << " The CONTAINER is made of " << fW << 282 << " mm. " << G4endl; >> 283 G4cout << " The CONTAINER is made of " << fWindowThick / mm << "mm of " >> 284 << fWindowMat->GetName() << G4endl; >> 285 G4cout << " The TARGET is made of " << fGasThickness / mm << "mm of " >> 286 << fGasMat->GetName(); >> 287 G4cout << ", the transverse size (R) is " << fGasRadius / mm << " mm. " 276 << G4endl; 288 << G4endl; 277 G4cout << " The TARGET is made of " << fGasT << 278 G4cout << ", the transverse size (R) is " << << 279 G4cout << G4endl; 289 G4cout << G4endl; 280 290 281 // World 291 // World 282 fSolidWorld = new G4Tubs("World", 0., worldS << 292 fSolidWorld = >> 293 new G4Tubs("World", 0., worldSizeR, worldSizeZ / 2., 0., CLHEP::twopi); 283 294 284 fLogicWorld = new G4LogicalVolume(fSolidWorl 295 fLogicWorld = new G4LogicalVolume(fSolidWorld, fWorldMaterial, "World"); 285 296 286 fPhysWorld = new G4PVPlacement(0, G4ThreeVec << 297 fPhysWorld = new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), "World", >> 298 fLogicWorld, 0, false, 0); 287 299 288 // Window 300 // Window 289 fSolidContainer = new G4Tubs("Absorber", 0., << 301 fSolidContainer = >> 302 new G4Tubs("Absorber", 0., contR, contThick / 2., 0., CLHEP::twopi); 290 303 291 fLogicContainer = new G4LogicalVolume(fSolid 304 fLogicContainer = new G4LogicalVolume(fSolidContainer, fWindowMat, "Window"); 292 305 293 G4PVPlacement* PhysWind = new G4PVPlacement( << 306 G4PVPlacement *PhysWind = 294 << 307 new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), "Window", fLogicContainer, >> 308 fPhysWorld, false, 0); 295 309 296 // Detector volume 310 // Detector volume 297 fSolidDetector = new G4Tubs("Gas", 0., fGasR << 311 fSolidDetector = >> 312 new G4Tubs("Gas", 0., fGasRadius, fGasThickness / 2., 0., CLHEP::twopi); 298 313 299 fLogicDetector = new G4LogicalVolume(fSolidD 314 fLogicDetector = new G4LogicalVolume(fSolidDetector, fGasMat, "Gas"); 300 315 301 new G4PVPlacement(0, G4ThreeVector(0., 0., 0 << 316 new G4PVPlacement(0, G4ThreeVector(0., 0., 0.), "Gas", fLogicDetector, >> 317 PhysWind, false, 0); 302 318 303 // defined gas detector region 319 // defined gas detector region 304 fRegGasDet = new G4Region("GasDetector"); 320 fRegGasDet = new G4Region("GasDetector"); 305 fRegGasDet->SetProductionCuts(fGasDetectorCu 321 fRegGasDet->SetProductionCuts(fGasDetectorCuts); 306 fRegGasDet->AddRootLogicalVolume(fLogicDetec 322 fRegGasDet->AddRootLogicalVolume(fLogicDetector); 307 323 308 // visualisation 324 // visualisation 309 fLogicWorld->SetVisAttributes(G4VisAttribute 325 fLogicWorld->SetVisAttributes(G4VisAttributes::GetInvisible()); 310 G4VisAttributes* color1 = new G4VisAttribute << 326 G4VisAttributes *color1 = new G4VisAttributes(G4Colour(0.3, 0.3, 0.3)); 311 fLogicContainer->SetVisAttributes(color1); 327 fLogicContainer->SetVisAttributes(color1); 312 G4VisAttributes* color2 = new G4VisAttribute << 328 G4VisAttributes *color2 = new G4VisAttributes(G4Colour(0.0, 0.3, 0.7)); 313 fLogicDetector->SetVisAttributes(color2); 329 fLogicDetector->SetVisAttributes(color2); 314 330 315 if (0.0 == fGasMat->GetIonisation()->GetMean 331 if (0.0 == fGasMat->GetIonisation()->GetMeanEnergyPerIonPair()) { 316 SetPairEnergy(20 * eV); 332 SetPairEnergy(20 * eV); 317 } 333 } 318 return fPhysWorld; 334 return fPhysWorld; 319 } 335 } 320 336 321 //....oooOO0OOooo........oooOO0OOooo........oo 337 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 322 338 323 void DetectorConstruction::ConstructSDandField << 339 void DetectorConstruction::ConstructSDandField() { 324 { << 325 auto sd = new TargetSD("GasSD"); 340 auto sd = new TargetSD("GasSD"); 326 G4SDManager::GetSDMpointer()->AddNewDetector 341 G4SDManager::GetSDMpointer()->AddNewDetector(sd); 327 SetSensitiveDetector(fLogicDetector, sd); 342 SetSensitiveDetector(fLogicDetector, sd); 328 } 343 } 329 344 330 //....oooOO0OOooo........oooOO0OOooo........oo 345 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 331 346 332 void DetectorConstruction::SetGasMaterial(cons << 347 void DetectorConstruction::SetGasMaterial(const G4String &name) { 333 { << 334 // get the pointer to the existing material 348 // get the pointer to the existing material 335 G4Material* mat = G4Material::GetMaterial(na << 349 G4Material *mat = G4Material::GetMaterial(name, false); 336 350 337 // create the material by its name 351 // create the material by its name 338 if (!mat) { 352 if (!mat) { 339 mat = G4NistManager::Instance()->FindOrBui 353 mat = G4NistManager::Instance()->FindOrBuildMaterial(name); 340 } 354 } 341 355 342 if (mat && mat != fGasMat) { 356 if (mat && mat != fGasMat) { 343 G4cout << "### New target material: " << m 357 G4cout << "### New target material: " << mat->GetName() << G4endl; 344 fGasMat = mat; 358 fGasMat = mat; 345 if (fLogicDetector) { 359 if (fLogicDetector) { 346 fLogicDetector->SetMaterial(mat); 360 fLogicDetector->SetMaterial(mat); 347 G4RunManager::GetRunManager()->PhysicsHa 361 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 348 } 362 } 349 } 363 } 350 } 364 } 351 365 352 //....oooOO0OOooo........oooOO0OOooo........oo 366 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 353 367 354 void DetectorConstruction::SetContainerMateria << 368 void DetectorConstruction::SetContainerMaterial(const G4String &name) { 355 { << 356 // get the pointer to the existing material 369 // get the pointer to the existing material 357 G4Material* mat = G4Material::GetMaterial(na << 370 G4Material *mat = G4Material::GetMaterial(name, false); 358 371 359 // create the material by its name 372 // create the material by its name 360 if (!mat) { 373 if (!mat) { 361 mat = G4NistManager::Instance()->FindOrBui 374 mat = G4NistManager::Instance()->FindOrBuildMaterial(name); 362 } 375 } 363 376 364 if (mat && mat != fWindowMat) { 377 if (mat && mat != fWindowMat) { 365 G4cout << "### New material for container: 378 G4cout << "### New material for container: " << mat->GetName() << G4endl; 366 fWindowMat = mat; 379 fWindowMat = mat; 367 if (fLogicContainer) { 380 if (fLogicContainer) { 368 fLogicContainer->SetMaterial(mat); 381 fLogicContainer->SetMaterial(mat); 369 G4RunManager::GetRunManager()->PhysicsHa 382 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 370 } 383 } 371 } 384 } 372 } 385 } 373 386 374 //....oooOO0OOooo........oooOO0OOooo........oo 387 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 375 388 376 void DetectorConstruction::SetWorldMaterial(co << 389 void DetectorConstruction::SetWorldMaterial(const G4String &name) { 377 { << 378 // get the pointer to the existing material 390 // get the pointer to the existing material 379 G4Material* mat = G4Material::GetMaterial(na << 391 G4Material *mat = G4Material::GetMaterial(name, false); 380 392 381 // create the material by its name 393 // create the material by its name 382 if (!mat) { 394 if (!mat) { 383 mat = G4NistManager::Instance()->FindOrBui 395 mat = G4NistManager::Instance()->FindOrBuildMaterial(name); 384 } 396 } 385 397 386 if (mat && mat != fWorldMaterial) { 398 if (mat && mat != fWorldMaterial) { 387 G4cout << "### New World material: " << ma 399 G4cout << "### New World material: " << mat->GetName() << G4endl; 388 fWorldMaterial = mat; 400 fWorldMaterial = mat; 389 if (fLogicWorld) { 401 if (fLogicWorld) { 390 fLogicWorld->SetMaterial(mat); 402 fLogicWorld->SetMaterial(mat); 391 G4RunManager::GetRunManager()->PhysicsHa 403 G4RunManager::GetRunManager()->PhysicsHasBeenModified(); 392 } 404 } 393 } 405 } 394 } 406 } 395 407 396 //....oooOO0OOooo........oooOO0OOooo........oo 408 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 397 409 398 void DetectorConstruction::SetGasThickness(G4d << 410 void DetectorConstruction::SetGasThickness(G4double val) { 399 { << 411 if(val <= 0.0) { return; } 400 if (val <= 0.0) { << 401 return; << 402 } << 403 fGasThickness = val; 412 fGasThickness = val; 404 if (nullptr != fPhysWorld) { 413 if (nullptr != fPhysWorld) { 405 ChangeGeometry(); 414 ChangeGeometry(); 406 } 415 } 407 } 416 } 408 417 409 //....oooOO0OOooo........oooOO0OOooo........oo 418 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 410 419 411 void DetectorConstruction::SetGasRadius(G4doub << 420 void DetectorConstruction::SetGasRadius(G4double val) { 412 { << 421 if(val <= 0.0) { return; } 413 if (val <= 0.0) { << 414 return; << 415 } << 416 fGasRadius = val; 422 fGasRadius = val; 417 if (nullptr != fPhysWorld) { 423 if (nullptr != fPhysWorld) { 418 ChangeGeometry(); 424 ChangeGeometry(); 419 } 425 } 420 } 426 } 421 427 422 //....oooOO0OOooo........oooOO0OOooo........oo 428 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 423 429 424 void DetectorConstruction::SetContainerThickne << 430 void DetectorConstruction::SetContainerThickness(G4double val) { 425 { << 431 if(val <= 0.0) { return; } 426 if (val <= 0.0) { << 427 return; << 428 } << 429 fWindowThick = val; 432 fWindowThick = val; 430 if (nullptr != fPhysWorld) { 433 if (nullptr != fPhysWorld) { 431 ChangeGeometry(); 434 ChangeGeometry(); 432 } 435 } 433 } 436 } 434 437 435 //....oooOO0OOooo........oooOO0OOooo........oo 438 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 436 439 437 void DetectorConstruction::SetPairEnergy(G4dou << 440 void DetectorConstruction::SetPairEnergy(G4double val) { 438 { << 439 if (val > 0.0) { 441 if (val > 0.0) { 440 fGasMat->GetIonisation()->SetMeanEnergyPer 442 fGasMat->GetIonisation()->SetMeanEnergyPerIonPair(val); 441 } 443 } 442 } 444 } 443 445 444 //....oooOO0OOooo........oooOO0OOooo........oo 446 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 445 447 446 void DetectorConstruction::ChangeGeometry() << 448 void DetectorConstruction::ChangeGeometry() { 447 { << 448 G4double contThick = fWindowThick * 2 + fGas 449 G4double contThick = fWindowThick * 2 + fGasThickness; 449 G4double contR = fWindowThick * 2 + fGasRadi 450 G4double contR = fWindowThick * 2 + fGasRadius; 450 451 451 G4double worldSizeZ = contThick * 1.2; 452 G4double worldSizeZ = contThick * 1.2; 452 G4double worldSizeR = contR * 1.2; 453 G4double worldSizeR = contR * 1.2; 453 454 454 TestParameters::GetPointer()->SetPositionZ(- 455 TestParameters::GetPointer()->SetPositionZ(-0.55 * contThick); 455 456 456 fSolidWorld->SetOuterRadius(worldSizeR); 457 fSolidWorld->SetOuterRadius(worldSizeR); 457 fSolidWorld->SetZHalfLength(worldSizeZ * 0.5 458 fSolidWorld->SetZHalfLength(worldSizeZ * 0.5); 458 459 459 fSolidContainer->SetOuterRadius(contR); 460 fSolidContainer->SetOuterRadius(contR); 460 fSolidContainer->SetZHalfLength(contThick * 461 fSolidContainer->SetZHalfLength(contThick * 0.5); 461 462 462 fSolidDetector->SetOuterRadius(fGasRadius); 463 fSolidDetector->SetOuterRadius(fGasRadius); 463 fSolidDetector->SetZHalfLength(fGasThickness 464 fSolidDetector->SetZHalfLength(fGasThickness * 0.5); 464 } 465 } 465 466 466 //....oooOO0OOooo........oooOO0OOooo........oo 467 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 467 468