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 runAndEvent/RE02/src/RE02DetectorCon 27 /// \brief Implementation of the RE02DetectorC 28 // 29 // 30 // 31 32 #include "RE02DetectorConstruction.hh" 33 34 #include "RE02NestedPhantomParameterisation.hh 35 36 #include "G4Box.hh" 37 #include "G4Colour.hh" 38 #include "G4LogicalVolume.hh" 39 #include "G4Material.hh" 40 #include "G4NistManager.hh" 41 #include "G4PSCellFlux3D.hh" 42 #include "G4PSEnergyDeposit3D.hh" 43 #include "G4PSFlatSurfaceCurrent3D.hh" 44 #include "G4PSFlatSurfaceFlux3D.hh" 45 #include "G4PSNofStep3D.hh" 46 #include "G4PSPassageCellFlux3D.hh" 47 #include "G4PVParameterised.hh" 48 #include "G4PVPlacement.hh" 49 #include "G4SDChargedFilter.hh" 50 #include "G4SDManager.hh" 51 #include "G4SDParticleFilter.hh" 52 #include "G4SDParticleWithEnergyFilter.hh" 53 #include "G4SystemOfUnits.hh" 54 #include "G4VisAttributes.hh" 55 #include "G4ios.hh" 56 57 //============================================ 58 // RE02DetectorConstruction 59 // 60 // (Description) 61 // 62 // Detector construction for example RE02. 63 // 64 // [Geometry] 65 // The world volume is defined as 200 cm x 66 // Water phantom is defined as 200 mm x 200 67 // The water phantom is divided into 100 seg 68 // replication, 69 // and then divided into 200 segments perpen 70 // parameterised volume. 71 // These values are defined at constructor, 72 // e.g. the size of water phantom (fPhantom 73 // of water phantom (fNx, fNy, fNz). 74 // 75 // By default, lead plates are inserted into 76 // segments. 77 // NIST database is used for materials. 78 // 79 // 80 // [Scorer] 81 // Assignment of G4MultiFunctionalDetector 82 // is demonstrated in this example. 83 // ------------------------------------- 84 // The collection names of defined Primi 85 // 0 PhantomSD/totalEDep 86 // 1 PhantomSD/protonEDep 87 // 2 PhantomSD/protonNStep 88 // 3 PhantomSD/chargedPassCellFlu 89 // 4 PhantomSD/chargedCellFlux 90 // 5 PhantomSD/chargedSurfFlux 91 // 6 PhantomSD/gammaSurfCurr000 92 // 7 PhantomSD/gammaSurfCurr001 93 // 9 PhantomSD/gammaSurdCurr002 94 // 10 PhantomSD/gammaSurdCurr003 95 // -------------------------------------- 96 // Please see README for detail descripti 97 // 98 //============================================ 99 100 //....oooOO0OOooo........oooOO0OOooo........oo 101 RE02DetectorConstruction::RE02DetectorConstruc 102 { 103 // Default size of water phantom,and segment 104 fPhantomSize.setX(200. * mm); 105 fPhantomSize.setY(200. * mm); 106 fPhantomSize.setZ(400. * mm); 107 fNx = fNy = fNz = 100; 108 fInsertLead = TRUE; 109 } 110 111 //....oooOO0OOooo........oooOO0OOooo........oo 112 RE02DetectorConstruction::~RE02DetectorConstru 113 { 114 ; 115 } 116 117 //....oooOO0OOooo........oooOO0OOooo........oo 118 G4VPhysicalVolume* RE02DetectorConstruction::C 119 { 120 //===================== 121 // Material Definitions 122 //===================== 123 // 124 //-------- NIST Materials ------------------ 125 // Material Information imported from NIST 126 // 127 G4NistManager* NISTman = G4NistManager::Inst 128 G4Material* air = NISTman->FindOrBuildMateri 129 G4Material* water = NISTman->FindOrBuildMate 130 G4Material* lead = NISTman->FindOrBuildMater 131 132 // 133 // Print all the materials defined. 134 G4cout << G4endl << "The materials defined a 135 G4cout << *(G4Material::GetMaterialTable()) 136 137 //========================================== 138 // Definitions of Solids, Logical Volum 139 //========================================== 140 141 //------------- 142 // World Volume 143 //------------- 144 145 G4ThreeVector worldSize = G4ThreeVector(200 146 147 G4Box* solidWorld = 148 new G4Box("world", worldSize.x() / 2., wor 149 G4LogicalVolume* logicWorld = new G4LogicalV 150 151 // 152 // Must place the World Physical volume unr 153 G4VPhysicalVolume* physiWorld = new G4PVPlac 154 155 156 157 158 159 160 161 //--------------- 162 // Water Phantom 163 //--------------- 164 165 //................................ 166 // Mother Volume of Water Phantom 167 //................................ 168 169 //-- Default size of water phantom is defin 170 G4ThreeVector phantomSize = fPhantomSize; 171 172 G4Box* solidPhantom = 173 new G4Box("phantom", phantomSize.x() / 2., 174 G4LogicalVolume* logicPhantom = new G4Logica 175 176 G4RotationMatrix* rot = new G4RotationMatrix 177 // rot->rotateY(30.*deg); 178 G4ThreeVector positionPhantom; 179 // G4VPhysicalVolume * physiPhantom = 180 new G4PVPlacement(rot, // no rotation 181 positionPhantom, // at (x 182 logicPhantom, // its logi 183 "Phantom", // its name 184 logicWorld, // its mother 185 false, // no boolean oper 186 0); // copy number 187 188 //.......................................... 189 // Phantom segmentation using Parameterisati 190 //.......................................... 191 // 192 G4cout << "<-- RE02DetectorConstruction::Con 193 G4cout << " Water Phantom Size " << fPhanto 194 G4cout << " Segmentation (" << fNx << "," 195 G4cout << " Lead plate at even copy # (0-Fa 196 G4cout << "<-------------------------------- 197 // Number of segmentation. 198 // - Default number of segmentation is defin 199 G4int nxCells = fNx; 200 G4int nyCells = fNy; 201 G4int nzCells = fNz; 202 203 G4ThreeVector sensSize; 204 sensSize.setX(phantomSize.x() / (G4double)nx 205 sensSize.setY(phantomSize.y() / (G4double)ny 206 sensSize.setZ(phantomSize.z() / (G4double)nz 207 // i.e Voxel size will be 2.0 x 2.0 x 2.0 mm 208 // 209 210 // Replication of Water Phantom Volume. 211 // Y Slice 212 G4String yRepName("RepY"); 213 G4VSolid* solYRep = 214 new G4Box(yRepName, phantomSize.x() / 2., 215 G4LogicalVolume* logYRep = new G4LogicalVolu 216 // G4PVReplica* yReplica = 217 new G4PVReplica(yRepName, logYRep, logicPhan 218 // X Slice 219 G4String xRepName("RepX"); 220 G4VSolid* solXRep = 221 new G4Box(xRepName, sensSize.x() / 2., sen 222 G4LogicalVolume* logXRep = new G4LogicalVolu 223 // G4PVReplica* xReplica = 224 new G4PVReplica(xRepName, logXRep, logYRep, 225 226 // 227 //.................................. 228 // Voxel solid and logical volumes 229 //.................................. 230 // Z Slice 231 G4String zVoxName("phantomSens"); 232 G4VSolid* solVoxel = new G4Box(zVoxName, sen 233 fLVPhantomSens = new G4LogicalVolume(solVoxe 234 // 235 // 236 std::vector<G4Material*> phantomMat(2, water 237 if (IsLeadSegment()) phantomMat[1] = lead; 238 // 239 // Parameterisation for transformation of vo 240 // (voxel size is fixed in this example. 241 // e.g. nested parameterisation handles mat 242 RE02NestedPhantomParameterisation* paramPhan 243 new RE02NestedPhantomParameterisation(sens 244 // G4VPhysicalVolume * physiPhantomSens = 245 new G4PVParameterised("PhantomSens", // the 246 fLVPhantomSens, // th 247 logXRep, // Mother lo 248 kUndefined, // Are pl 249 nzCells, // Number of 250 paramPhantom); // Par 251 // Optimization flag is avaiable for, 252 // kUndefined, kXAxis, kYAxis, kZAxis. 253 // 254 255 //=============================== 256 // Visualization attributes 257 //=============================== 258 259 G4VisAttributes* boxVisAtt = new G4VisAttrib 260 logicWorld->SetVisAttributes(boxVisAtt); 261 // logicWorld->SetVisAttributes(G4VisAttribu 262 263 // Mother volume of WaterPhantom 264 G4VisAttributes* phantomVisAtt = new G4VisAt 265 logicPhantom->SetVisAttributes(phantomVisAtt 266 267 // Replica 268 G4VisAttributes* yRepVisAtt = new G4VisAttri 269 logYRep->SetVisAttributes(yRepVisAtt); 270 G4VisAttributes* xRepVisAtt = new G4VisAttri 271 logXRep->SetVisAttributes(xRepVisAtt); 272 273 // Skip the visualization for those voxels. 274 fLVPhantomSens->SetVisAttributes(G4VisAttrib 275 276 return physiWorld; 277 } 278 279 void RE02DetectorConstruction::ConstructSDandF 280 { 281 //========================================== 282 // Sensitive detectors : MultiFunctionalDete 283 //========================================== 284 // 285 // Sensitive Detector Manager. 286 G4SDManager* pSDman = G4SDManager::GetSDMpoi 287 // 288 // Sensitive Detector Name 289 G4String phantomSDname = "PhantomSD"; 290 291 //------------------------ 292 // MultiFunctionalDetector 293 //------------------------ 294 // 295 // Define MultiFunctionalDetector with name. 296 G4MultiFunctionalDetector* mFDet = new G4Mul 297 pSDman->AddNewDetector(mFDet); // Register 298 fLVPhantomSens->SetSensitiveDetector(mFDet); 299 300 //--------------------------------------- 301 // SDFilter : Sensitive Detector Filters 302 //--------------------------------------- 303 // 304 // Particle Filter for Primitive Scorer with 305 // and particle name(particleName), 306 // or particle names are given by add("parti 307 // 308 G4String fltName, particleName; 309 // 310 //-- proton filter 311 G4SDParticleFilter* protonFilter = 312 new G4SDParticleFilter(fltName = "protonFi 313 // 314 //-- electron filter 315 G4SDParticleFilter* electronFilter = new G4S 316 electronFilter->add(particleName = "e+"); / 317 electronFilter->add(particleName = "e-"); / 318 // 319 //-- charged particle filter 320 G4SDChargedFilter* chargedFilter = new G4SDC 321 322 //------------------------ 323 // PS : Primitive Scorers 324 //------------------------ 325 // Primitive Scorers are used with SDFilters 326 // 327 // 328 //-- Primitive Scorer for Energy Deposit. 329 // Total, by protons, by electrons. 330 G4String psName; 331 G4PSEnergyDeposit3D* scorer0 = new G4PSEnerg 332 G4PSEnergyDeposit3D* scorer1 = new G4PSEnerg 333 scorer1->SetFilter(protonFilter); 334 335 // 336 //-- Number of Steps for protons 337 G4PSNofStep3D* scorer2 = new G4PSNofStep3D(p 338 scorer2->SetFilter(protonFilter); 339 340 // 341 //-- CellFlux for charged particles 342 G4PSPassageCellFlux3D* scorer3 = 343 new G4PSPassageCellFlux3D(psName = "charge 344 G4PSCellFlux3D* scorer4 = new G4PSCellFlux3D 345 G4PSFlatSurfaceFlux3D* scorer5 = 346 new G4PSFlatSurfaceFlux3D(psName = "charge 347 scorer3->SetFilter(chargedFilter); 348 scorer4->SetFilter(chargedFilter); 349 scorer5->SetFilter(chargedFilter); 350 351 // 352 //------------------------------------------ 353 // Register primitive scorers to MultiFunct 354 //------------------------------------------ 355 mFDet->RegisterPrimitive(scorer0); 356 mFDet->RegisterPrimitive(scorer1); 357 mFDet->RegisterPrimitive(scorer2); 358 mFDet->RegisterPrimitive(scorer3); 359 mFDet->RegisterPrimitive(scorer4); 360 mFDet->RegisterPrimitive(scorer5); 361 362 //======================== 363 // More additional Primitive Scoreres 364 //======================== 365 // 366 //--- Surface Current for gamma with energy 367 // This example creates four primitive score 368 // 4 bins with energy --- Primitive Sco 369 // 1. to 10 KeV, gammaSurfCur 370 // 10 keV to 100 KeV, gammaSurfCur 371 // 100 keV to 1 MeV, gammaSurfCur 372 // 1 MeV to 10 MeV. gammaSurfCur 373 // 374 for (G4int i = 0; i < 4; i++) { 375 std::ostringstream name; 376 name << "gammaSurfCurr" << std::setfill('0 377 G4String psgName = name.str(); 378 G4double kmin = std::pow(10., (G4double)i) 379 G4double kmax = std::pow(10., (G4double)(i 380 //-- Particle with kinetic energy filter. 381 G4SDParticleWithEnergyFilter* pkinEFilter 382 new G4SDParticleWithEnergyFilter(fltName 383 pkinEFilter->add("gamma"); // Accept only 384 pkinEFilter->show(); // Show accepting co 385 //-- Surface Current Scorer which scores 386 G4PSFlatSurfaceCurrent3D* scorer = 387 new G4PSFlatSurfaceCurrent3D(psgName, fC 388 scorer->SetFilter(pkinEFilter); // Assign 389 mFDet->RegisterPrimitive(scorer); // Regi 390 } 391 } 392