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