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