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 field/field03/src/F03DetectorConstru 26 /// \file field/field03/src/F03DetectorConstruction.cc 27 /// \brief Implementation of the F03DetectorCo 27 /// \brief Implementation of the F03DetectorConstruction class 28 // 28 // 29 // << 29 // $Id$ 30 // << 30 // 31 // << 32 //....oooOO0OOooo........oooOO0OOooo........oo << 33 //....oooOO0OOooo........oooOO0OOooo........oo << 34 31 35 #include "F03DetectorConstruction.hh" << 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 36 34 37 #include "F03CalorimeterSD.hh" << 35 #include "F03DetectorConstruction.hh" 38 #include "F03DetectorMessenger.hh" 36 #include "F03DetectorMessenger.hh" >> 37 #include "F03CalorimeterSD.hh" >> 38 #include "F03FieldSetup.hh" 39 39 40 #include "G4AutoDelete.hh" << 41 #include "G4GeometryManager.hh" << 42 #include "G4FieldBuilder.hh" << 43 #include "G4LogicalVolume.hh" << 44 #include "G4LogicalVolumeStore.hh" << 45 #include "G4Material.hh" 40 #include "G4Material.hh" >> 41 #include "G4Tubs.hh" >> 42 #include "G4LogicalVolume.hh" 46 #include "G4PVPlacement.hh" 43 #include "G4PVPlacement.hh" 47 #include "G4PhysicalConstants.hh" << 44 #include "G4UniformMagField.hh" 48 #include "G4PhysicalVolumeStore.hh" << 45 #include "G4FieldManager.hh" 49 #include "G4RunManager.hh" << 46 #include "G4TransportationManager.hh" 50 #include "G4SDManager.hh" 47 #include "G4SDManager.hh" >> 48 #include "G4RunManager.hh" >> 49 >> 50 #include "G4GeometryManager.hh" >> 51 #include "G4PhysicalVolumeStore.hh" >> 52 #include "G4LogicalVolumeStore.hh" 51 #include "G4SolidStore.hh" 53 #include "G4SolidStore.hh" >> 54 >> 55 #include "G4PhysicalConstants.hh" 52 #include "G4SystemOfUnits.hh" 56 #include "G4SystemOfUnits.hh" 53 #include "G4Tubs.hh" << 57 #include "G4ios.hh" 54 #include "G4UniformMagField.hh" << 55 58 56 //....oooOO0OOooo........oooOO0OOooo........oo << 59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 57 60 58 F03DetectorConstruction::F03DetectorConstructi 61 F03DetectorConstruction::F03DetectorConstruction() >> 62 : fMagField(0), fEmFieldSetup(0), fDetectorMessenger(0), fCalorimeterSD(0), >> 63 fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0), >> 64 fSolidAbsorber(0), fLogicAbsorber(0), fPhysiAbsorber(0), >> 65 fSolidRadSlice(0), fLogicRadSlice(0), fPhysiRadSlice(0), >> 66 fSolidRadiator(0), fLogicRadiator(0), fPhysiRadiator(0), >> 67 fWorldMaterial(0), fAbsorberMaterial(0), fRadiatorMat(0), >> 68 // default parameter values of the calorimeter >> 69 fWorldSizeR( 22000.*mm), >> 70 fWorldSizeZ( 44000.*mm), >> 71 fAbsorberThickness( 1.*mm), >> 72 fAbsorberRadius( 20000.*mm), >> 73 fZAbsorber( 21990.*mm), >> 74 fZStartAbs( 0.), >> 75 fZEndAbs( 0.), >> 76 fRadThickness( 100.*mm), >> 77 fGasGap( 100.*mm), >> 78 fDetGap( 1.*mm), >> 79 fFoilNumber(1), >> 80 fWorldChanged(false) 59 { 81 { 60 fDetectorMessenger = new F03DetectorMessenge << 82 // create commands for interactive definition of the calorimeter 61 << 62 // create field builder << 63 // this will create commands for field param << 64 G4FieldBuilder* fieldBuilder = G4FieldBuilde << 65 // fieldBuilder->SetVerboseLevel(2); << 66 << 67 auto globalFieldParameters = fieldBuilder->G << 68 auto localFieldParameters = fieldBuilder->Cr << 69 << 70 // set default min step 0.25 mm << 71 globalFieldParameters->SetMinimumStep(0.25 * << 72 localFieldParameters->SetMinimumStep(0.25 * << 73 83 74 // create materials << 75 DefineMaterials(); 84 DefineMaterials(); >> 85 >> 86 fEmFieldSetup = new F03FieldSetup() ; >> 87 >> 88 fDetectorMessenger = new F03DetectorMessenger(this); 76 } 89 } 77 90 78 //....oooOO0OOooo........oooOO0OOooo........oo << 91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 79 92 80 F03DetectorConstruction::~F03DetectorConstruct 93 F03DetectorConstruction::~F03DetectorConstruction() 81 { << 94 { 82 delete fDetectorMessenger; 95 delete fDetectorMessenger; >> 96 if (fEmFieldSetup) delete fEmFieldSetup ; 83 } 97 } 84 98 85 //....oooOO0OOooo........oooOO0OOooo........oo << 99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 86 100 87 G4VPhysicalVolume* F03DetectorConstruction::Co 101 G4VPhysicalVolume* F03DetectorConstruction::Construct() 88 { 102 { 89 return ConstructCalorimeter(); 103 return ConstructCalorimeter(); 90 } 104 } 91 105 92 //....oooOO0OOooo........oooOO0OOooo........oo << 106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 93 107 94 void F03DetectorConstruction::DefineMaterials( 108 void F03DetectorConstruction::DefineMaterials() 95 { << 109 { 96 // This function illustrates the possible wa 110 // This function illustrates the possible ways to define materials 97 << 111 98 G4String name, symbol; // a=mass of a mole; << 112 G4String name, symbol ; // a=mass of a mole; 99 G4double a, z, density; // z=mean number of << 113 G4double a, z, density ; // z=mean number of protons; 100 G4int nel; << 114 G4int nel ; 101 G4int ncomponents; 115 G4int ncomponents; 102 G4double fractionmass, pressure, temperature 116 G4double fractionmass, pressure, temperature; 103 117 104 // 118 // 105 // define Elements 119 // define Elements 106 // 120 // 107 121 108 a = 1.01 * g / mole; << 122 a = 1.01*g/mole; 109 auto elH = new G4Element(name = "Hydrogen", << 123 G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , z= 1., a); 110 124 111 a = 12.01 * g / mole; << 125 a = 12.01*g/mole; 112 auto elC = new G4Element(name = "Carbon", sy << 126 G4Element* elC = new G4Element(name="Carbon", symbol="C", z=6., a); 113 127 114 a = 14.01 * g / mole; << 128 a = 14.01*g/mole; 115 auto elN = new G4Element(name = "Nitrogen", << 129 G4Element* elN = new G4Element(name="Nitrogen",symbol="N" , z= 7., a); 116 130 117 a = 16.00 * g / mole; << 131 a = 16.00*g/mole; 118 auto elO = new G4Element(name = "Oxygen", sy << 132 G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , z= 8., a); 119 133 120 a = 39.948 * g / mole; << 134 a = 39.948*g/mole; 121 auto elAr = new G4Element(name = "Argon", sy << 135 G4Element* elAr = new G4Element(name="Argon", symbol="Ar", z=18., a); 122 136 123 // 137 // 124 // define simple materials 138 // define simple materials 125 // 139 // 126 140 127 // Mylar 141 // Mylar 128 142 129 density = 1.39 * g / cm3; << 143 density = 1.39*g/cm3; 130 auto mylar = new G4Material(name = "Mylar", << 144 G4Material* Mylar = new G4Material(name="Mylar", density, nel=3); 131 mylar->AddElement(elO, 2); << 145 Mylar->AddElement(elO,2); 132 mylar->AddElement(elC, 5); << 146 Mylar->AddElement(elC,5); 133 mylar->AddElement(elH, 4); << 147 Mylar->AddElement(elH,4); 134 148 135 // Polypropelene 149 // Polypropelene 136 150 137 auto CH2 = new G4Material("Polypropelene", 0 << 151 G4Material* CH2 = new G4Material ("Polypropelene" , 0.91*g/cm3, 2); 138 CH2->AddElement(elH, 2); << 152 CH2->AddElement(elH,2); 139 CH2->AddElement(elC, 1); << 153 CH2->AddElement(elC,1); 140 154 141 // Krypton as detector gas, STP 155 // Krypton as detector gas, STP 142 156 143 density = 3.700 * mg / cm3; << 157 density = 3.700*mg/cm3 ; 144 a = 83.80 * g / mole; << 158 a = 83.80*g/mole ; 145 auto Kr = new G4Material(name = "Kr", z = 36 << 159 G4Material* Kr = new G4Material(name="Kr",z=36., a, density ); 146 160 147 // Dry air (average composition) 161 // Dry air (average composition) 148 162 149 density = 1.7836 * mg / cm3; // STP << 163 density = 1.7836*mg/cm3 ; // STP 150 auto argon = new G4Material(name = "Argon", << 164 G4Material* Argon = new G4Material(name="Argon" , density, ncomponents=1); 151 argon->AddElement(elAr, 1); << 165 Argon->AddElement(elAr, 1); 152 << 166 153 density = 1.25053 * mg / cm3; // STP << 167 density = 1.25053*mg/cm3 ; // STP 154 auto nitrogen = new G4Material(name = "N2", << 168 G4Material* Nitrogen = new G4Material(name="N2" , density, ncomponents=1); 155 nitrogen->AddElement(elN, 2); << 169 Nitrogen->AddElement(elN, 2); 156 << 170 157 density = 1.4289 * mg / cm3; // STP << 171 density = 1.4289*mg/cm3 ; // STP 158 auto oxygen = new G4Material(name = "O2", de << 172 G4Material* Oxygen = new G4Material(name="O2" , density, ncomponents=1); 159 oxygen->AddElement(elO, 2); << 173 Oxygen->AddElement(elO, 2); 160 174 161 density = 1.2928 * mg / cm3; // STP << 175 density = 1.2928*mg/cm3 ; // STP 162 density *= 1.0e-8; // pumped vacuum << 176 density *= 1.0e-8 ; // pumped vacuum 163 temperature = STP_Temperature; 177 temperature = STP_Temperature; 164 pressure = 1.0e-8 * STP_Pressure; << 178 pressure = 1.0e-8*STP_Pressure; 165 179 166 auto air = << 180 G4Material* Air = new G4Material(name="Air" , density, ncomponents=3, 167 new G4Material(name = "Air", density, ncom << 181 kStateGas,temperature,pressure); 168 air->AddMaterial(nitrogen, fractionmass = 0. << 182 Air->AddMaterial( Nitrogen, fractionmass = 0.7557 ) ; 169 air->AddMaterial(oxygen, fractionmass = 0.23 << 183 Air->AddMaterial( Oxygen, fractionmass = 0.2315 ) ; 170 air->AddMaterial(argon, fractionmass = 0.012 << 184 Air->AddMaterial( Argon, fractionmass = 0.0128 ) ; 171 185 172 // Xenon as detector gas, STP 186 // Xenon as detector gas, STP 173 187 174 density = 5.858 * mg / cm3; << 188 density = 5.858*mg/cm3 ; 175 a = 131.29 * g / mole; << 189 a = 131.29*g/mole ; 176 auto Xe = new G4Material(name = "Xenon", z = << 190 G4Material* Xe = new G4Material(name="Xenon",z=54., a, density ); 177 191 178 // Carbon dioxide, STP 192 // Carbon dioxide, STP 179 193 180 density = 1.842 * mg / cm3; << 194 density = 1.842*mg/cm3; 181 auto CarbonDioxide = new G4Material(name = " << 195 G4Material* CarbonDioxide = new G4Material(name="CO2", density, nel=2); 182 CarbonDioxide->AddElement(elC, 1); << 196 CarbonDioxide->AddElement(elC,1); 183 CarbonDioxide->AddElement(elO, 2); << 197 CarbonDioxide->AddElement(elO,2); 184 198 185 // 80% Xe + 20% CO2, STP 199 // 80% Xe + 20% CO2, STP 186 200 187 density = 5.0818 * mg / cm3; << 201 density = 5.0818*mg/cm3 ; 188 auto Xe20CO2 = new G4Material(name = "Xe20CO << 202 G4Material* Xe20CO2 = new G4Material(name="Xe20CO2" , density, ncomponents=2); 189 Xe20CO2->AddMaterial(Xe, fractionmass = 0.92 << 203 Xe20CO2->AddMaterial( Xe, fractionmass = 0.922 ) ; 190 Xe20CO2->AddMaterial(CarbonDioxide, fraction << 204 Xe20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.078 ) ; 191 205 192 // 80% Kr + 20% CO2, STP 206 // 80% Kr + 20% CO2, STP 193 207 194 density = 3.601 * mg / cm3; << 208 density = 3.601*mg/cm3 ; 195 auto Kr20CO2 = new G4Material(name = "Kr20CO << 209 G4Material* Kr20CO2 = new G4Material(name="Kr20CO2" , density, 196 Kr20CO2->AddMaterial(Kr, fractionmass = 0.89 << 210 ncomponents=2); 197 Kr20CO2->AddMaterial(CarbonDioxide, fraction << 211 Kr20CO2->AddMaterial( Kr, fractionmass = 0.89 ) ; >> 212 Kr20CO2->AddMaterial( CarbonDioxide, fractionmass = 0.11 ) ; 198 213 199 G4cout << *(G4Material::GetMaterialTable()) << 200 214 201 // default materials of the calorimeter and << 215 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 202 216 203 fRadiatorMat = air; // CH2 ; // mylar; << 217 //default materials of the calorimeter and TR radiator 204 218 205 fAbsorberMaterial = air; // Kr20CO2; // << 219 fRadiatorMat = Air ; // CH2 ; // Mylar ; >> 220 >> 221 fAbsorberMaterial = Air ; // Kr20CO2 ; // XeCO2CF4 ; 206 222 207 fWorldMaterial = air; << 223 fWorldMaterial = Air ; 208 } 224 } 209 225 210 //....oooOO0OOooo........oooOO0OOooo........oo << 226 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 211 << 227 212 G4VPhysicalVolume* F03DetectorConstruction::Co 228 G4VPhysicalVolume* F03DetectorConstruction::ConstructCalorimeter() 213 { 229 { >> 230 G4int j ; >> 231 G4double zModule, zRadiator; >> 232 >> 233 // complete the Calor parameters definition and Print >> 234 >> 235 ComputeCalorParameters(); >> 236 PrintCalorParameters(); >> 237 214 // Cleanup old geometry 238 // Cleanup old geometry 215 239 216 if (fPhysiWorld) { << 240 if (fPhysiWorld) >> 241 { 217 G4GeometryManager::GetInstance()->OpenGeom 242 G4GeometryManager::GetInstance()->OpenGeometry(); 218 G4PhysicalVolumeStore::GetInstance()->Clea 243 G4PhysicalVolumeStore::GetInstance()->Clean(); 219 G4LogicalVolumeStore::GetInstance()->Clean 244 G4LogicalVolumeStore::GetInstance()->Clean(); 220 G4SolidStore::GetInstance()->Clean(); 245 G4SolidStore::GetInstance()->Clean(); 221 } 246 } 222 247 223 // complete the Calor parameters definition << 248 fSolidWorld = new G4Tubs("World", // its name 224 << 249 0.,fWorldSizeR,fWorldSizeZ/2.,0.,twopi);// its size 225 ComputeCalorParameters(); << 250 226 PrintCalorParameters(); << 251 fLogicWorld = new G4LogicalVolume(fSolidWorld, // its solid 227 << 228 G4bool checkOverlaps = true; << 229 << 230 fSolidWorld = new G4Tubs("World", // its na << 231 0., fWorldSizeR, fW << 232 << 233 fLogicWorld = new G4LogicalVolume(fSolidWorl << 234 fWorldMate 252 fWorldMaterial, // its material 235 "World"); << 253 "World"); // its name 236 << 254 237 fPhysiWorld = new G4PVPlacement(nullptr, // << 255 fPhysiWorld = new G4PVPlacement(0, // no rotation 238 G4ThreeVecto << 256 G4ThreeVector(), // at (0,0,0) 239 "World", // << 257 "World", // its name 240 fLogicWorld, << 258 fLogicWorld, // its logical volume 241 nullptr, // << 259 0, // its mother volume 242 false, // n << 260 false, // no boolean operation 243 0, // copy << 261 0); // copy number 244 checkOverlap << 245 262 246 // TR radiator envelope 263 // TR radiator envelope 247 G4double radThick = fFoilNumber * (fRadThick << 248 G4double zRad = fZAbsorber - 0.5 * (radThick << 249 << 250 G4cout << "zRad = " << zRad / mm << " mm" << << 251 G4cout << "radThick = " << radThick / mm << << 252 G4cout << "fFoilNumber = " << fFoilNumber << << 253 G4cout << "fRadiatorMat = " << fRadiatorMat- << 254 G4cout << "WorldMaterial = " << fWorldMateri << 255 << 256 fSolidRadiator = new G4Tubs("Radiator", 0.0, << 257 << 258 fLogicRadiator = new G4LogicalVolume(fSolidR << 259 << 260 fPhysiRadiator = new G4PVPlacement(nullptr, << 261 fPhysiWor << 262 264 263 fSolidRadSlice = new G4Tubs("RadSlice", 0.0, << 265 G4double radThick = fFoilNumber*(fRadThickness + fGasGap) + fDetGap ; 264 266 265 fLogicRadSlice = new G4LogicalVolume(fSolidR << 267 G4double zRad = fZAbsorber - 20*cm - 0.5*radThick ; 266 << 268 G4cout << "zRad = " << zRad/mm << " mm" << G4endl ; 267 // Radiator slice << 268 G4double radSliceThick = fRadThickness + fGa << 269 G4double zStart = 0.5 * (-radThick + radSlic << 270 // start on the board of radiator enevelope << 271 << 272 for (G4int j = 0; j < fFoilNumber; j++) { << 273 G4double zSlice = zStart + j * radSliceThi << 274 G4cout << zSlice / mm << " mm" << 275 << "\t"; << 276 << 277 fPhysiRadSlice = new G4PVPlacement(nullptr << 278 fLogicR << 279 } << 280 G4cout << G4endl; << 281 269 >> 270 radThick *= 1.02 ; >> 271 G4cout << "radThick = " << radThick/mm << " mm" << G4endl ; >> 272 G4cout << "fFoilNumber = " << fFoilNumber << G4endl ; >> 273 G4cout << "fRadiatorMat = " << fRadiatorMat->GetName() << G4endl ; >> 274 G4cout << "WorldMaterial = " << fWorldMaterial->GetName() << G4endl ; >> 275 >> 276 fSolidRadiator = new G4Tubs("Radiator",0.0, >> 277 1.01*fAbsorberRadius, >> 278 0.5*radThick,0.0, twopi) ; >> 279 >> 280 fLogicRadiator = new G4LogicalVolume(fSolidRadiator, >> 281 fWorldMaterial, >> 282 "Radiator"); >> 283 >> 284 // Set local field manager and local field in radiator and its daughters: >> 285 >> 286 G4bool allLocal = true ; >> 287 >> 288 fLogicRadiator->SetFieldManager( fEmFieldSetup->GetLocalFieldManager(), >> 289 allLocal ) ; >> 290 >> 291 >> 292 fPhysiRadiator = new G4PVPlacement(0, >> 293 G4ThreeVector(0,0,zRad), >> 294 "Radiator", fLogicRadiator, >> 295 fPhysiWorld, false, 0); >> 296 >> 297 fSolidRadSlice = new G4Tubs("RadSlice",0.0, >> 298 fAbsorberRadius,0.5*fRadThickness,0.0,twopi ) ; >> 299 >> 300 fLogicRadSlice = new G4LogicalVolume(fSolidRadSlice,fRadiatorMat, >> 301 "RadSlice",0,0,0); >> 302 >> 303 zModule = zRad + 0.5*radThick/1.02 ; >> 304 G4cout << "zModule = " << zModule/mm << " mm" << G4endl ; >> 305 >> 306 for (j=0;j<fFoilNumber;j++) >> 307 { >> 308 >> 309 zRadiator = zModule - j*(fRadThickness + fGasGap) ; >> 310 G4cout << zRadiator/mm << " mm" << "\t" ; >> 311 // G4cout << "j = " << j << "\t" ; >> 312 >> 313 fPhysiRadSlice = new G4PVPlacement(0,G4ThreeVector(0.,0.,zRadiator-zRad), >> 314 "RadSlice",fLogicRadSlice, >> 315 fPhysiRadiator,false,j); >> 316 } >> 317 G4cout << G4endl ; >> 318 282 // Absorber 319 // Absorber 283 320 284 fSolidAbsorber = << 321 if (fAbsorberThickness > 0.) 285 new G4Tubs("Absorber", 1.0 * mm, fAbsorber << 322 { 286 << 323 fSolidAbsorber = new G4Tubs("Absorber", 1.0*mm, 287 fLogicAbsorber = new G4LogicalVolume(fSolidA << 324 fAbsorberRadius, 288 << 325 fAbsorberThickness/2., 289 fPhysiAbsorber = new G4PVPlacement(nullptr, << 326 0.0,twopi); 290 fLogicAbs << 327 >> 328 fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber, >> 329 fAbsorberMaterial, >> 330 "Absorber"); >> 331 >> 332 fPhysiAbsorber = new G4PVPlacement(0, >> 333 G4ThreeVector(0.,0.,fZAbsorber), >> 334 "Absorber", >> 335 fLogicAbsorber, >> 336 fPhysiWorld, >> 337 false, >> 338 0); >> 339 } >> 340 >> 341 // Sensitive Detectors: Absorber >> 342 >> 343 G4SDManager* sdManager = G4SDManager::GetSDMpointer(); >> 344 >> 345 if (!fCalorimeterSD) >> 346 { >> 347 fCalorimeterSD = new F03CalorimeterSD("CalorSD",this); >> 348 sdManager->AddNewDetector( fCalorimeterSD ); >> 349 } >> 350 if (fLogicAbsorber) fLogicAbsorber->SetSensitiveDetector(fCalorimeterSD); 291 351 292 return fPhysiWorld; 352 return fPhysiWorld; 293 } 353 } 294 354 295 //....oooOO0OOooo........oooOO0OOooo........oo << 355 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 296 356 297 void F03DetectorConstruction::PrintCalorParame 357 void F03DetectorConstruction::PrintCalorParameters() 298 { 358 { 299 G4cout << "\n The WORLD is made of " << f << 359 G4cout << "\n The WORLD is made of " 300 << fWorldMaterial->GetName(); << 360 << fWorldSizeZ/mm << "mm of " << fWorldMaterial->GetName() ; 301 G4cout << ", the transverse size (R) of the << 361 G4cout << ", the transverse size (R) of the world is " << fWorldSizeR/mm << " mm. " << G4endl; 302 G4cout << " The ABSORBER is made of " << fAb << 362 G4cout << " The ABSORBER is made of " 303 << fAbsorberMaterial->GetName(); << 363 << fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName() ; 304 G4cout << ", the transverse size (R) is " << << 364 G4cout << ", the transverse size (R) is " << fAbsorberRadius/mm << " mm. " << G4endl; 305 G4cout << " Z position of the (middle of the << 365 G4cout << " Z position of the (middle of the) absorber " << fZAbsorber/mm << " mm." << G4endl; 306 G4cout << G4endl; 366 G4cout << G4endl; 307 } 367 } 308 368 309 //....oooOO0OOooo........oooOO0OOooo........oo << 369 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 310 370 311 void F03DetectorConstruction::SetAbsorberMater 371 void F03DetectorConstruction::SetAbsorberMaterial(G4String materialChoice) 312 { 372 { 313 // get the pointer to the material table 373 // get the pointer to the material table 314 const G4MaterialTable* theMaterialTable = G4 374 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); 315 375 316 // search the material by its name << 376 // search the material by its name 317 G4Material* material; 377 G4Material* material; 318 for (size_t j = 0; j < theMaterialTable->siz << 378 for (size_t j=0 ; j<theMaterialTable->size() ; j++) 319 material = (*theMaterialTable)[j]; << 379 { 320 if (material->GetName() == materialChoice) << 380 material = (*theMaterialTable)[j]; 321 fAbsorberMaterial = material; << 381 if (material->GetName() == materialChoice) 322 fLogicAbsorber->SetMaterial(material); << 382 { 323 G4RunManager::GetRunManager()->PhysicsHa << 383 fAbsorberMaterial = material; 324 } << 384 fLogicAbsorber->SetMaterial(material); 325 } << 385 } >> 386 } 326 } 387 } 327 388 328 //....oooOO0OOooo........oooOO0OOooo........oo << 389 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 329 390 330 void F03DetectorConstruction::SetWorldMaterial 391 void F03DetectorConstruction::SetWorldMaterial(G4String materialChoice) 331 { 392 { 332 // get the pointer to the material table 393 // get the pointer to the material table 333 const G4MaterialTable* theMaterialTable = G4 394 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); 334 395 335 // search the material by its name << 396 // search the material by its name 336 G4Material* material; 397 G4Material* material; 337 for (size_t j = 0; j < theMaterialTable->siz << 398 for (size_t j=0 ; j<theMaterialTable->size() ; j++) 338 material = (*theMaterialTable)[j]; << 399 { 339 if (material->GetName() == materialChoice) << 400 material = (*theMaterialTable)[j]; 340 fWorldMaterial = material; << 401 if (material->GetName() == materialChoice) 341 fLogicWorld->SetMaterial(material); << 402 { 342 G4RunManager::GetRunManager()->PhysicsHa << 403 fWorldMaterial = material; 343 } << 404 fLogicWorld->SetMaterial(material); 344 } << 405 } >> 406 } 345 } 407 } 346 408 347 //....oooOO0OOooo........oooOO0OOooo........oo << 409 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 348 410 349 void F03DetectorConstruction::SetAbsorberThick 411 void F03DetectorConstruction::SetAbsorberThickness(G4double val) 350 { 412 { 351 // change Absorber thickness and recompute t 413 // change Absorber thickness and recompute the calorimeter parameters 352 fAbsorberThickness = val; 414 fAbsorberThickness = val; 353 ComputeCalorParameters(); 415 ComputeCalorParameters(); 354 G4RunManager::GetRunManager()->GeometryHasBe << 416 } 355 } << 356 417 357 //....oooOO0OOooo........oooOO0OOooo........oo << 418 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 358 419 359 void F03DetectorConstruction::SetAbsorberRadiu 420 void F03DetectorConstruction::SetAbsorberRadius(G4double val) 360 { 421 { 361 // change the transverse size and recompute 422 // change the transverse size and recompute the calorimeter parameters 362 fAbsorberRadius = val; 423 fAbsorberRadius = val; 363 ComputeCalorParameters(); 424 ComputeCalorParameters(); 364 G4RunManager::GetRunManager()->GeometryHasBe << 425 } 365 } << 366 426 367 //....oooOO0OOooo........oooOO0OOooo........oo << 427 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 368 428 369 void F03DetectorConstruction::SetWorldSizeZ(G4 429 void F03DetectorConstruction::SetWorldSizeZ(G4double val) 370 { 430 { >> 431 fWorldChanged=true; 371 fWorldSizeZ = val; 432 fWorldSizeZ = val; 372 ComputeCalorParameters(); 433 ComputeCalorParameters(); 373 G4RunManager::GetRunManager()->GeometryHasBe << 434 } 374 } << 375 435 376 //....oooOO0OOooo........oooOO0OOooo........oo << 436 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 377 437 378 void F03DetectorConstruction::SetWorldSizeR(G4 438 void F03DetectorConstruction::SetWorldSizeR(G4double val) 379 { 439 { >> 440 fWorldChanged=true; 380 fWorldSizeR = val; 441 fWorldSizeR = val; 381 ComputeCalorParameters(); 442 ComputeCalorParameters(); 382 G4RunManager::GetRunManager()->GeometryHasBe << 443 } 383 } << 384 444 385 //....oooOO0OOooo........oooOO0OOooo........oo << 445 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 386 446 387 void F03DetectorConstruction::SetAbsorberZpos( 447 void F03DetectorConstruction::SetAbsorberZpos(G4double val) 388 { 448 { 389 fZAbsorber = val; << 449 fZAbsorber = val; 390 ComputeCalorParameters(); 450 ComputeCalorParameters(); 391 G4RunManager::GetRunManager()->GeometryHasBe << 451 } 392 } << 393 << 394 //....oooOO0OOooo........oooOO0OOooo........oo << 395 << 396 void F03DetectorConstruction::SetFieldValue(G4 << 397 { << 398 fFieldVector = value; << 399 << 400 G4UniformMagField* magField = nullptr; << 401 if (fFieldVector != G4ThreeVector(0.,0.,0.)) << 402 magField = new G4UniformMagField(fFieldVec << 403 } << 404 << 405 // Set field to the field builder << 406 auto fieldBuilder = G4FieldBuilder::Instance << 407 fieldBuilder->SetGlobalField(magField); << 408 } << 409 << 410 //....oooOO0OOooo........oooOO0OOooo........oo << 411 << 412 452 413 void F03DetectorConstruction::SetLocalFieldVal << 453 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 454 >> 455 void F03DetectorConstruction::UpdateGeometry() 414 { 456 { 415 fLocalFieldVector = value; << 457 G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter()); 416 << 417 G4UniformMagField* magField = nullptr; << 418 if (fLocalFieldVector != G4ThreeVector(0.,0. << 419 magField = new G4UniformMagField(fLocalFie << 420 } << 421 << 422 // Set field to the field builder << 423 auto fieldBuilder = G4FieldBuilder::Instance << 424 fieldBuilder->SetLocalField(magField, fLogic << 425 } << 426 << 427 //....oooOO0OOooo........oooOO0OOooo........oo << 428 << 429 void F03DetectorConstruction::ConstructSDandFi << 430 { << 431 // Sensitive Detectors: Absorber << 432 << 433 if (!fCalorimeterSD.Get()) { << 434 auto calorimeterSD = new F03CalorimeterSD( << 435 fCalorimeterSD.Put(calorimeterSD); << 436 } << 437 G4SDManager::GetSDMpointer()->AddNewDetector << 438 SetSensitiveDetector(fLogicAbsorber, fCalori << 439 << 440 // Create detector fields << 441 SetFieldValue(fFieldVector); << 442 SetLocalFieldValue(fLocalFieldVector); << 443 << 444 // Construct all Geant4 field objects << 445 auto fieldBuilder = G4FieldBuilder::Instance << 446 fieldBuilder->ConstructFieldSetup(); << 447 } 458 } 448 459 449 //....oooOO0OOooo........oooOO0OOooo........oo << 460 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 450 461