猪头Geant4讲座(4)

时间:2025-04-20

G4UImanager——UI(user interface)管理器

这个类的英文全名是user interface manager,顾名思义是用于人机交互的,用户可以通过这个类来向模拟过程发出“命令”,

这个类在一定程度上使用很简洁的命令语句代替了上述用户干涉类的功能。

需要说明的是,上面所说的几个类并没有包括所有可选类,根据每个用户的需求,用户可以有很多其他类。

下面以$G4INSTALL/example/novice/N01的例子为例看一下这些类,

因为这个粒子仅为了说明Geant4的基本运用,所以这个例子里面只定义了3个强制类,没有使用可选类来输出感兴趣的信息。

但是通过UI管理器查看了粒子输运过程中的一些信息。

// Construct the default run manager

//首先是要创建一个运行管理器的实例,根据C++的知识我们知道每个类都必须通过他的实例来进行操作

G4RunManager* runManager = new G4RunManager;

// set mandatory initialization classes

//通过Set函数设置几何结构和物理过程,这两个类属于强制类,也属于初始化类

G4VUserDetectorConstruction* detector = new ExN01DetectorConstruction;

runManager->SetUserInitialization(detector);

//

G4VUserPhysicsList* physics = new ExN01PhysicsList;

runManager->SetUserInitialization(physics);

// set mandatory user action class

//通过Set函数进行源描述,这个类属于强制类,也属于用户干涉类

G4VUserPrimaryGeneratorAction* gen_action = new ExN01PrimaryGeneratorAction;

runManager->SetUserAction(gen_action);

// Initialize G4 kernel

//Set完成后,通过Initialize()函数初始化G4内核

runManager->Initialize();

// Get the pointer to the UI manager and set verbosities

//创建UI管理器,通过UI管理器设置运行、事件、径迹的可视化精细程度。

G4UImanager* UI = G4UImanager::GetUIpointer();

UI->ApplyCommand("/run/verbose 1");

UI->ApplyCommand("/event/verbose 1");

UI->ApplyCommand("/tracking/verbose 1");

// Start a run

//通过BeamOn()函数开始模拟,这里macroFile和n_Select都是使用了默认值

G4int numberOfEvent = 3;

runManager->BeamOn(numberOfEvent);

猪头Geant4讲座(4).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219