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