// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // /// \file fpPrimaryGeneratorAction.cc /// \brief Implementation of the fpPrimaryGeneratorAction class #include "fpPrimaryGeneratorAction.hh" #include "G4LogicalVolumeStore.hh" #include "G4LogicalVolume.hh" #include "G4Box.hh" #include "G4RunManager.hh" #include "G4ParticleGun.hh" #include "G4ParticleTable.hh" #include "G4ParticleDefinition.hh" #include "G4SystemOfUnits.hh" #include "Randomize.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... fpPrimaryGeneratorAction::fpPrimaryGeneratorAction() : G4VUserPrimaryGeneratorAction(), fgun(0) { fgun = new G4ParticleGun(); G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable(); G4String particleName; G4ParticleDefinition* particle = particleTable->FindParticle(particleName = "neutron"); fgun->SetParticleDefinition(particle); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... fpPrimaryGeneratorAction::~fpPrimaryGeneratorAction() { delete fgun; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void fpPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) { fgun->SetParticleEnergy(0.144*MeV); // // Neutron Surface Source Uniform Emitting by Area // /* rand1 = FLRNDM(XDUMMY) rand2 = FLRNDM(XDUMMY) IF(rand1.ge.rand2)then radius = 3.5 * rand1 else radius = 3.5 * rand2 endif thi = 360 * FLRNDM(XDUMMY) * 3.1415926535 * 2 / 360. XBEAM = radius * cos(thi) YBEAM = radius * sin(thi) ZBEAM = -3.5 XFLK(NPFLKA) = XBEAM YFLK(NPFLKA) = YBEAM ZFLK(NPFLKA) = ZBEAM */ double rand1 = G4UniformRand(); double rand2 = G4UniformRand(); double xx, yy, zz; double radius; if (rand1 >= rand2) radius = 5 * rand1*cm; else radius = 5 * rand2*cm; double thi = 360 * G4UniformRand() * 3.1415926535 * 2 / 360.; xx = radius * cos(thi); yy = radius * sin(thi); zz = -2.6 * cm; fgun->SetParticlePosition(G4ThreeVector(xx,yy,zz)); fgun->SetParticleMomentumDirection(G4ThreeVector(0, 0, 1)); fgun->GeneratePrimaryVertex(anEvent); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......