- 78
- 0
- 约1.81万字
- 约 26页
- 2019-04-25 发布于江苏
- 举报
Geant4 基础知识
G4模拟粒子过程 :
建立一次模拟,在 G4 中称为一次 Run;Run 建立后,需要对几何结构、物理过程进行初始化; 初始化完成后就开始模拟过程了, 首先发射一个粒子。 在 G4 中,发射一个(或一系列) 粒子到所有次级粒子死亡的过程成为一次 Event 。而每次发射的初始粒子则有粒子发射器进行控制。 而在每一个 event 过程中,粒子与材料反应后会可能生成多个次级粒子, 每个粒子都会有一条径 迹,称之为 track ;
而每一个粒子(初始的或次级的)的径迹又是由很多步组成的,称之为 step 。
G4模拟的基本算法:
A Run Start - 初始化物理模型 / 几何模型 - An Event Start - 调用粒子发
射器发射粒子
- A Track Start
- A Step Start
- A Step End
- Next Step Start
,,
- All Step End
- A Track End
- Next Track Start
- ,,
- All Track End
- An Event End - Next Event Start
- ,,
- All Event End(All Primaries Shot) - A Run End - Next Run Start
,,
main() 中应该包括的内容
Geant4 是一个探测器模拟工具 , 但它对于某个特定的模拟程序没有固定的
main() 函数 , 用户在建立模拟程序的过程中需要提供自己的 main() 函数 . 一个
最基本的 main() 函数需要包括以下几个方面 :
G4RunManager( 模拟整个过程 )
G4VUserDetectorConstruction( 定义探测器材料 , 几何形状 , 灵敏区和读
出方案 )
G4VUserPhysicsList( 定义粒子种类和物理过程 , 还有截断参数 )
G4VUserPrimaryGeneratorAction( 定义了源粒子的种类 , 能量 , 出射方向
)
一个最简单的 main() 函数如下 :
#include G4RunManager.hh
#include G4UImanager.hh
#include ExN01DetectorConstruction.hh
#include ExN01PhysicsList.hh
#include ExN01PrimaryGeneratorAction.hh
int main()
{
Construct the default run manager G4RunManager* runManager = new G4RunManager;
// set mandatory initialization classes
runManager-SetUserInitialization(new ExN01DetectorConstruction);
runManager-SetUserInitialization(new ExN01PhysicsList);
// set mandatory user action class
runManager-SetUserAction(new ExN01PrimaryGeneratorAction);
Initialize G4 kernel runManager-Initialize();
get the pointer to the UI manager and set verbosities
G4UImanager* UI = G4UImanager::GetUIpointer();
UI-ApplyCommand(/run/verbose 1);
UI-ApplyCommand(/event/verbose 1);
UI-ApplyCommand(/tracking/verbose 1);
// start a run
int numberOfEvent = 3;
runManager-BeamOn(numberOfEvent);
job termination delete runManager; return 0;
}
main() 首先生成一个 G4RunManager类,这个类是在主程序中用以初始化模拟信息,用来连接子程序,连接方式是通过 Set 函数来完成。 例如:
BDetectorConstruction* detector = new BDetectorConstruction;
runManager-SetUserInitialization(detector);
先构造一个探测器几何,再用
SET
函数
原创力文档

文档评论(0)