【G4基础01】2.1 How to Define the main() Program

本文档介绍了Geant4模拟中的核心组件G4RunManager,包括其在单线程和多线程环境中的应用,以及强制初始类ExG4DetectorConstruction01、ExG4PhysicsList00和ExG4ActionInitialization01的作用。此外,还讲解了用户初始化和动作类的使用,以及G4UImanager和UI命令的管理。最后,讨论了G4out和G4cerr在输出控制中的角色。
摘要由CSDN通过智能技术生成


一、main( )方法sample

Listing 2.1: main函数最简单的例子

#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "ExG4DetectorConstruction01.hh"
#include "ExG4PhysicsList00.hh"
#include "ExG4ActionInitialization01.hh"
int main()
{
   
// construct the default run manager
    auto runManager = G4RunManagerFactory::CreateRunManager();
// set mandatory initialization classes
    runManager->SetUserInitialization(new ExG4DetectorConstruction01);
    runManager->SetUserInitialization(new ExG4PhysicsList00);
    runManager->SetUserInitialization(new ExG4ActionInitialization01);
// 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->
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值