Geant4学习之能谱输入
生活随笔
收集整理的這篇文章主要介紹了
Geant4学习之能谱输入
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Geant4學習
- Geant4學習——能譜輸入
- G4VPrimaryGenerator【G4主發生器】
- G4ParticleGun【G4粒子槍】
- GEANT4 General Particle Source【GEANT4通用粒子源】
- 代碼實現能譜輸入
- PrimaryGeneratorAction.hh
- PrimaryGeneratorAction.cc
- Macro Commands【run1.mac】
Geant4學習——能譜輸入
G4VPrimaryGenerator【G4主發生器】
GEANT4 提 供 了 三 個 G4VPrimaryGenerator 具 體 類。 G4ParticleGun 和G4GeneralParticleSource將在這里討論。第三個是G4HEPEvtInterface,本次尚不討論。
G4ParticleGun【G4粒子槍】
G4ParticleGun是由GEANT4提供的generator。這個類產生具有給定動量和位置的初級粒子。它不提供任何形式的隨機化。
G4ParticleGun的構造函數采用一個整數,該整數會導致生成一個或多個具有完全相同運動特性的原色。產生具有隨機能量,動量和/或位置是用戶的相當頻繁需求。這種隨機化可以通過調用 G4ParticleGun 提供的各種設置方法來實現。
可產生具有給定動量和位置的初級粒子,不提供任何形式的隨機化(可以通過對位置、動量、能量等抽取分布進行隨機化)
GEANT4 General Particle Source【GEANT4通用粒子源】
G4GeneralParticleSource(GPS)是用于Monte-Carlo高能粒子傳輸的GEANT4工具包的一部分。具體來說,它允許規定主源粒子的光譜,空間和角度分布。
GPS控制主要粒子的以下特征:空間采樣:在簡單的2D或3D的表面或3D的體內角度分布:單向、各向同性、余弦定律、波束或者用戶自定義能譜:線性、指數、冪律、高斯、黑體或者分段擬合數據多種源:可以在同一運行中使用多個獨立源代碼實現能譜輸入
PrimaryGeneratorAction.hh
#ifndef PrimaryGeneratorAction_h #define PrimaryGeneratorAction_h 1 #include "G4VUserPrimaryGeneratorAction.hh" #include "G4ParticleGun.hh" #include "globals.hh"class G4GeneralParticleSource; class G4Event;class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {public:PrimaryGeneratorAction();virtual ~PrimaryGeneratorAction();public:virtual void GeneratePrimaries(G4Event* anEvent);private:G4GeneralParticleSource* fParticleGun; };#endifPrimaryGeneratorAction.cc
#include "PrimaryGeneratorAction.hh" #include "G4IonTable.hh" #include "G4Event.hh" #include "G4RunManager.hh" /G4GeneralParticleSource/ #include "G4GeneralParticleSource.hh" #include "G4ParticleTable.hh" #include "G4ParticleDefinition.hh" #include "G4SystemOfUnits.hh" #include "globals.hh" #include "G4Geantino.hh" /Particlegun/ #include "G4ParticleGun.hh" #include "Randomize.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......PrimaryGeneratorAction::PrimaryGeneratorAction() {fParticleGun = new G4GeneralParticleSource(); }//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......PrimaryGeneratorAction::~PrimaryGeneratorAction() {delete fParticleGun; }//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......void PrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent) { //設置離子源為Fe離子/*if (fParticleGun->GetParticleDefinition() == G4Geantino::Geantino()){G4int Z = 26, A = 56;G4double ionCharge = 0. * eplus;G4double excitEnergy = 0. * keV;G4ParticleDefinition *ion = G4IonTable::GetIonTable()->GetIon(Z, A, excitEnergy);fParticleGun->SetParticleDefinition(ion);fParticleGun->SetParticleCharge(ionCharge);}*/fParticleGun->GeneratePrimaryVertex(anEvent); }Macro Commands【run1.mac】
以下宏命令實現粒子源為質子,粒子源的位置為(0,0,-200um),粒子入射方向為沿Z軸正方向,以能譜形式輸入。
/run/initialize /control/verbose 2 /run/verbose 2 /tracking/verbose 2 #點源輸入 /gps/particle proton #/gps/particle e- /gps/pos/type Point /gps/pos/centre 0 0 -200 um #/gps/pos/centre 50 0 -200 um #/gps/pos/centre -200 0 -240 um #粒子方向 /gps/ang/type iso /gps/direction 0 0 1 #/gps/direction 100 0 120 #能譜輸入 /gps/ene/type Arb /gps/hist/type arb #能量/數量輸入 # E(MeV) Rel.yield /gps/hist/point 0.09856 0.7167 /gps/hist/point 0.1985 0.16876 /gps/hist/point 0.29844 0.06781 /gps/hist/point 0.39858 0.02794 /gps/hist/point 0.49693 0.01123 /gps/hist/point 0.59707 0.00463 /gps/hist/point 0.69701 0.00182 /gps/hist/point 0.79695 7.14898E-4 /gps/hist/point 1 1.1292E-4 /gps/hist/inter Lin/run/beamOn 1000總結
以上是生活随笔為你收集整理的Geant4学习之能谱输入的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 随记:STM32L053LL库LPUAR
- 下一篇: HGOI 20190711 题解