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 PrimaryGeneratorAction.cc 26 /// \file PrimaryGeneratorAction.cc 27 /// \brief Implementation of the PrimaryGenera 27 /// \brief Implementation of the PrimaryGeneratorAction class 28 // 28 // 29 // 29 // >> 30 // $Id: PrimaryGeneratorAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $ >> 31 // >> 32 // >> 33 30 //....oooOO0OOooo........oooOO0OOooo........oo 34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 36 33 #include "PrimaryGeneratorAction.hh" 37 #include "PrimaryGeneratorAction.hh" 34 << 35 #include "DetectorConstruction.hh" 38 #include "DetectorConstruction.hh" 36 39 37 #include "G4Event.hh" 40 #include "G4Event.hh" 38 #include "G4Geantino.hh" << 41 #include "G4ParticleTable.hh" 39 #include "G4IonTable.hh" 42 #include "G4IonTable.hh" 40 #include "G4ParticleDefinition.hh" 43 #include "G4ParticleDefinition.hh" 41 #include "G4ParticleTable.hh" << 44 #include "G4Geantino.hh" 42 #include "G4PhysicalConstants.hh" 45 #include "G4PhysicalConstants.hh" 43 #include "G4SystemOfUnits.hh" 46 #include "G4SystemOfUnits.hh" 44 #include "Randomize.hh" 47 #include "Randomize.hh" 45 48 46 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 50 48 PrimaryGeneratorAction::PrimaryGeneratorAction << 51 PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det) >> 52 : G4VUserPrimaryGeneratorAction(), fParticleGun(0), fDetector(det) 49 { 53 { 50 G4int n_particle = 1; 54 G4int n_particle = 1; 51 fParticleGun = new G4ParticleGun(n_particle) << 55 fParticleGun = new G4ParticleGun(n_particle); >> 56 >> 57 fParticleGun->SetParticleEnergy(0*eV); >> 58 fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,0.)); >> 59 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.)); 52 60 53 fParticleGun->SetParticleEnergy(0 * eV); << 54 fParticleGun->SetParticlePosition(G4ThreeVec << 55 fParticleGun->SetParticleMomentumDirection(G << 56 } 61 } 57 62 58 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 59 64 60 PrimaryGeneratorAction::~PrimaryGeneratorActio 65 PrimaryGeneratorAction::~PrimaryGeneratorAction() 61 { 66 { 62 delete fParticleGun; 67 delete fParticleGun; 63 } 68 } 64 69 65 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 66 71 67 void PrimaryGeneratorAction::GeneratePrimaries 72 void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) 68 { 73 { 69 // particle type << 74 //particle type 70 if (fParticleGun->GetParticleDefinition() == 75 if (fParticleGun->GetParticleDefinition() == G4Geantino::Geantino()) { 71 G4int Z = 95, A = 241; 76 G4int Z = 95, A = 241; 72 G4double ionCharge = 0. * eplus; << 77 G4double ionCharge = 0.*eplus; 73 G4double excitEnergy = 0. * keV; << 78 G4double excitEnergy = 0.*keV; 74 79 75 G4ParticleDefinition* ion = G4IonTable::Ge << 80 G4ParticleDefinition* ion >> 81 = G4IonTable::GetIonTable()->GetIon(Z,A,excitEnergy); 76 fParticleGun->SetParticleDefinition(ion); 82 fParticleGun->SetParticleDefinition(ion); 77 fParticleGun->SetParticleCharge(ionCharge) 83 fParticleGun->SetParticleCharge(ionCharge); 78 } 84 } 79 85 80 // vertex position uniform within the absorb << 86 //vertex position uniform within the absorber 81 // 87 // 82 G4double Rmax = fDetector->GetAbsorRadius(); 88 G4double Rmax = fDetector->GetAbsorRadius(); 83 G4double Rmax2 = Rmax * Rmax; << 89 G4double Rmax2 = Rmax*Rmax; 84 G4double R2 = G4UniformRand() * Rmax2; << 90 G4double R2 = G4UniformRand()*Rmax2; 85 G4double R = std::sqrt(R2); << 91 G4double R = std::sqrt(R2); 86 << 92 87 G4double phi = twopi * G4UniformRand(); << 93 G4double phi = twopi*G4UniformRand(); 88 G4double ux = R * std::cos(phi), uy = R * st << 94 G4double ux = R*std::cos(phi), 89 G4double uz = (fDetector->GetAbsorLength()) << 95 uy = R*std::sin(phi); 90 << 96 G4double uz = (fDetector->GetAbsorLength())*(G4UniformRand() - 0.5); 91 fParticleGun->SetParticlePosition(G4ThreeVec << 97 >> 98 fParticleGun->SetParticlePosition(G4ThreeVector(ux,uy,uz)); 92 99 93 // distribution uniform in solid angle << 100 //distribution uniform in solid angle 94 // 101 // 95 G4double cosTheta = 2 * G4UniformRand() - 1. << 102 G4double cosTheta = 2*G4UniformRand() - 1.; 96 G4double sinTheta = std::sqrt(1. - cosTheta << 103 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta); 97 phi = twopi * G4UniformRand(); << 104 phi = twopi*G4UniformRand(); 98 G4double vx = sinTheta * std::cos(phi), vy = << 105 G4double vx = sinTheta*std::cos(phi), 99 << 106 vy = sinTheta*std::sin(phi), 100 fParticleGun->SetParticleMomentumDirection(G << 107 vz = cosTheta; 101 108 >> 109 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(vx,vy,vz)); >> 110 102 fParticleGun->GeneratePrimaryVertex(anEvent) 111 fParticleGun->GeneratePrimaryVertex(anEvent); 103 } 112 } 104 113 105 //....oooOO0OOooo........oooOO0OOooo........oo 114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 115 106 116