Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /// \file field/field03/src/F03DetectorConstru 27 /// \brief Implementation of the F03DetectorCo 28 // 29 // 30 // 31 // 32 //....oooOO0OOooo........oooOO0OOooo........oo 33 //....oooOO0OOooo........oooOO0OOooo........oo 34 35 #include "F03DetectorConstruction.hh" 36 37 #include "F03CalorimeterSD.hh" 38 #include "F03DetectorMessenger.hh" 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" 46 #include "G4PVPlacement.hh" 47 #include "G4PhysicalConstants.hh" 48 #include "G4PhysicalVolumeStore.hh" 49 #include "G4RunManager.hh" 50 #include "G4SDManager.hh" 51 #include "G4SolidStore.hh" 52 #include "G4SystemOfUnits.hh" 53 #include "G4Tubs.hh" 54 #include "G4UniformMagField.hh" 55 56 //....oooOO0OOooo........oooOO0OOooo........oo 57 58 F03DetectorConstruction::F03DetectorConstructi 59 { 60 fDetectorMessenger = new F03DetectorMessenge 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 74 // create materials 75 DefineMaterials(); 76 } 77 78 //....oooOO0OOooo........oooOO0OOooo........oo 79 80 F03DetectorConstruction::~F03DetectorConstruct 81 { 82 delete fDetectorMessenger; 83 } 84 85 //....oooOO0OOooo........oooOO0OOooo........oo 86 87 G4VPhysicalVolume* F03DetectorConstruction::Co 88 { 89 return ConstructCalorimeter(); 90 } 91 92 //....oooOO0OOooo........oooOO0OOooo........oo 93 94 void F03DetectorConstruction::DefineMaterials( 95 { 96 // This function illustrates the possible wa 97 98 G4String name, symbol; // a=mass of a mole; 99 G4double a, z, density; // z=mean number of 100 G4int nel; 101 G4int ncomponents; 102 G4double fractionmass, pressure, temperature 103 104 // 105 // define Elements 106 // 107 108 a = 1.01 * g / mole; 109 auto elH = new G4Element(name = "Hydrogen", 110 111 a = 12.01 * g / mole; 112 auto elC = new G4Element(name = "Carbon", sy 113 114 a = 14.01 * g / mole; 115 auto elN = new G4Element(name = "Nitrogen", 116 117 a = 16.00 * g / mole; 118 auto elO = new G4Element(name = "Oxygen", sy 119 120 a = 39.948 * g / mole; 121 auto elAr = new G4Element(name = "Argon", sy 122 123 // 124 // define simple materials 125 // 126 127 // Mylar 128 129 density = 1.39 * g / cm3; 130 auto mylar = new G4Material(name = "Mylar", 131 mylar->AddElement(elO, 2); 132 mylar->AddElement(elC, 5); 133 mylar->AddElement(elH, 4); 134 135 // Polypropelene 136 137 auto CH2 = new G4Material("Polypropelene", 0 138 CH2->AddElement(elH, 2); 139 CH2->AddElement(elC, 1); 140 141 // Krypton as detector gas, STP 142 143 density = 3.700 * mg / cm3; 144 a = 83.80 * g / mole; 145 auto Kr = new G4Material(name = "Kr", z = 36 146 147 // Dry air (average composition) 148 149 density = 1.7836 * mg / cm3; // STP 150 auto argon = new G4Material(name = "Argon", 151 argon->AddElement(elAr, 1); 152 153 density = 1.25053 * mg / cm3; // STP 154 auto nitrogen = new G4Material(name = "N2", 155 nitrogen->AddElement(elN, 2); 156 157 density = 1.4289 * mg / cm3; // STP 158 auto oxygen = new G4Material(name = "O2", de 159 oxygen->AddElement(elO, 2); 160 161 density = 1.2928 * mg / cm3; // STP 162 density *= 1.0e-8; // pumped vacuum 163 temperature = STP_Temperature; 164 pressure = 1.0e-8 * STP_Pressure; 165 166 auto air = 167 new G4Material(name = "Air", density, ncom 168 air->AddMaterial(nitrogen, fractionmass = 0. 169 air->AddMaterial(oxygen, fractionmass = 0.23 170 air->AddMaterial(argon, fractionmass = 0.012 171 172 // Xenon as detector gas, STP 173 174 density = 5.858 * mg / cm3; 175 a = 131.29 * g / mole; 176 auto Xe = new G4Material(name = "Xenon", z = 177 178 // Carbon dioxide, STP 179 180 density = 1.842 * mg / cm3; 181 auto CarbonDioxide = new G4Material(name = " 182 CarbonDioxide->AddElement(elC, 1); 183 CarbonDioxide->AddElement(elO, 2); 184 185 // 80% Xe + 20% CO2, STP 186 187 density = 5.0818 * mg / cm3; 188 auto Xe20CO2 = new G4Material(name = "Xe20CO 189 Xe20CO2->AddMaterial(Xe, fractionmass = 0.92 190 Xe20CO2->AddMaterial(CarbonDioxide, fraction 191 192 // 80% Kr + 20% CO2, STP 193 194 density = 3.601 * mg / cm3; 195 auto Kr20CO2 = new G4Material(name = "Kr20CO 196 Kr20CO2->AddMaterial(Kr, fractionmass = 0.89 197 Kr20CO2->AddMaterial(CarbonDioxide, fraction 198 199 G4cout << *(G4Material::GetMaterialTable()) 200 201 // default materials of the calorimeter and 202 203 fRadiatorMat = air; // CH2 ; // mylar; 204 205 fAbsorberMaterial = air; // Kr20CO2; // 206 207 fWorldMaterial = air; 208 } 209 210 //....oooOO0OOooo........oooOO0OOooo........oo 211 212 G4VPhysicalVolume* F03DetectorConstruction::Co 213 { 214 // Cleanup old geometry 215 216 if (fPhysiWorld) { 217 G4GeometryManager::GetInstance()->OpenGeom 218 G4PhysicalVolumeStore::GetInstance()->Clea 219 G4LogicalVolumeStore::GetInstance()->Clean 220 G4SolidStore::GetInstance()->Clean(); 221 } 222 223 // complete the Calor parameters definition 224 225 ComputeCalorParameters(); 226 PrintCalorParameters(); 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 235 "World"); 236 237 fPhysiWorld = new G4PVPlacement(nullptr, // 238 G4ThreeVecto 239 "World", // 240 fLogicWorld, 241 nullptr, // 242 false, // n 243 0, // copy 244 checkOverlap 245 246 // 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 263 fSolidRadSlice = new G4Tubs("RadSlice", 0.0, 264 265 fLogicRadSlice = new G4LogicalVolume(fSolidR 266 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 282 // Absorber 283 284 fSolidAbsorber = 285 new G4Tubs("Absorber", 1.0 * mm, fAbsorber 286 287 fLogicAbsorber = new G4LogicalVolume(fSolidA 288 289 fPhysiAbsorber = new G4PVPlacement(nullptr, 290 fLogicAbs 291 292 return fPhysiWorld; 293 } 294 295 //....oooOO0OOooo........oooOO0OOooo........oo 296 297 void F03DetectorConstruction::PrintCalorParame 298 { 299 G4cout << "\n The WORLD is made of " << f 300 << fWorldMaterial->GetName(); 301 G4cout << ", the transverse size (R) of the 302 G4cout << " The ABSORBER is made of " << fAb 303 << fAbsorberMaterial->GetName(); 304 G4cout << ", the transverse size (R) is " << 305 G4cout << " Z position of the (middle of the 306 G4cout << G4endl; 307 } 308 309 //....oooOO0OOooo........oooOO0OOooo........oo 310 311 void F03DetectorConstruction::SetAbsorberMater 312 { 313 // get the pointer to the material table 314 const G4MaterialTable* theMaterialTable = G4 315 316 // search the material by its name 317 G4Material* material; 318 for (size_t j = 0; j < theMaterialTable->siz 319 material = (*theMaterialTable)[j]; 320 if (material->GetName() == materialChoice) 321 fAbsorberMaterial = material; 322 fLogicAbsorber->SetMaterial(material); 323 G4RunManager::GetRunManager()->PhysicsHa 324 } 325 } 326 } 327 328 //....oooOO0OOooo........oooOO0OOooo........oo 329 330 void F03DetectorConstruction::SetWorldMaterial 331 { 332 // get the pointer to the material table 333 const G4MaterialTable* theMaterialTable = G4 334 335 // search the material by its name 336 G4Material* material; 337 for (size_t j = 0; j < theMaterialTable->siz 338 material = (*theMaterialTable)[j]; 339 if (material->GetName() == materialChoice) 340 fWorldMaterial = material; 341 fLogicWorld->SetMaterial(material); 342 G4RunManager::GetRunManager()->PhysicsHa 343 } 344 } 345 } 346 347 //....oooOO0OOooo........oooOO0OOooo........oo 348 349 void F03DetectorConstruction::SetAbsorberThick 350 { 351 // change Absorber thickness and recompute t 352 fAbsorberThickness = val; 353 ComputeCalorParameters(); 354 G4RunManager::GetRunManager()->GeometryHasBe 355 } 356 357 //....oooOO0OOooo........oooOO0OOooo........oo 358 359 void F03DetectorConstruction::SetAbsorberRadiu 360 { 361 // change the transverse size and recompute 362 fAbsorberRadius = val; 363 ComputeCalorParameters(); 364 G4RunManager::GetRunManager()->GeometryHasBe 365 } 366 367 //....oooOO0OOooo........oooOO0OOooo........oo 368 369 void F03DetectorConstruction::SetWorldSizeZ(G4 370 { 371 fWorldSizeZ = val; 372 ComputeCalorParameters(); 373 G4RunManager::GetRunManager()->GeometryHasBe 374 } 375 376 //....oooOO0OOooo........oooOO0OOooo........oo 377 378 void F03DetectorConstruction::SetWorldSizeR(G4 379 { 380 fWorldSizeR = val; 381 ComputeCalorParameters(); 382 G4RunManager::GetRunManager()->GeometryHasBe 383 } 384 385 //....oooOO0OOooo........oooOO0OOooo........oo 386 387 void F03DetectorConstruction::SetAbsorberZpos( 388 { 389 fZAbsorber = val; 390 ComputeCalorParameters(); 391 G4RunManager::GetRunManager()->GeometryHasBe 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 413 void F03DetectorConstruction::SetLocalFieldVal 414 { 415 fLocalFieldVector = value; 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 } 448 449 //....oooOO0OOooo........oooOO0OOooo........oo 450