云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Geant4 程序编写中的常用代码

Geant4 程序编写中的常用代码

  • 62 次阅读
  • 3 次下载
  • 2025/7/12 14:25:05

if (theTrack->GetParentID() == 1) //判断当前粒子是否由初级粒子产生 std::cout << \

G4VProcess* creatorProcess= track->GetCreatorProcess();

G4cout << creatorProcess->GetProcessName() << std::endl; //获取产生当前粒子的物理过程名称

G4TouchableHandle theTouchable = preStepPoint->GetTouchableHandle(); theTouchable->GetCopyNumber(); //当前几何体的Copy Number theTouchable->GetCopyNumber(1); //当前几何体母体的Copy Number theTouchable->GetCopyNumber(2); //当前几何体母体的母体的Copy Number,以此类推,前提是该母体是存在的,否则可能抛出异常 }

===========================================================================

PS:自己写的一个按照MCNP格式来存储数据的类: 使用方法:

//新建计数,能量上下限为Emin和Emax,中间插入n个能量值,总共的源粒子个数为numberofevent(G4Run的

GetNumberOfEventToBeProcessed 函数可以获得该值,亦可手动输入对应的常数值)。

MyDataRecorder *pMDRCurrent = new MyDataRecorder(Emin, Emax, n, numberofevent);

pMDRCurrent ->AddData(Energy,Weight); //多道计数

//每个源粒子事件之后,在EndOfEventAction函数中更新数据,用于方差计算。

pMDRCurrent->UpdateThisEvent();

//设置相关的参数并输出到文件

pMDRFluence->SetMessage(\//向文件中加入一个说明信息

pMDRFluence->SetFactor(fac); //将数据除以一个因子,比如面积、体积等等。

pMDRFluence->OutputFile(\//将数据保存到指定的文件中去。 cnscott的博客

============================头文件============================== //MCNP/X-like Data Recorder //Edited by Guoqing Zhang on May 20, 2010 #ifndef MyDataRecorder_hh #define MyDataRecorder_hh #include #include \#include \ //template class MyDataRecorder class MyDataRecorder { public: MyDataRecorder(G4double e1,G4double e2, G4int num,G4int numberofevent); MyDataRecorder(G4int numberofevent); ~MyDataRecorder(); void AddData(G4double Energy,G4double Data); void AddData(G4double Data); void OutputFile(G4String FileName=\ void SetMessage(G4String msg){message=msg;} void SetFactor(G4double f){factor=f;} void UpdateThisEvent(); private: void CalErr(); private: std::vector MyData; std::vector rerr; std::vector sumD2; std::vector TData; G4double E1; G4double E2; G4double dE; G4int NCHN; //Number of channels G4int NPS; //Number of source particles G4String message; //additional message G4double factor; //constant factor like area or volume }; #endif cnscott的博客 ===========================源文件=============================== //MCNP/X-like Data Recorder //Edited by Guoqing Zhang on May 20, 2010 #include \#include \#include #include using namespace std; //Single-channel constructor. MyDataRecorder::MyDataRecorder(G4int numberofevent) : E1(0),E2(0),dE(0),NCHN(1),NPS(numberofevent),message(\{ MyData.push_back(0); TData.push_back(0); rerr.push_back(0); sumD2.push_back(0); } //Multi-channel constructor. MyDataRecorder::MyDataRecorder(G4double e1,G4double e2, G4int numtoinsert, G4int numberofevent) : E1(e1),E2(e2),NCHN(numtoinsert+2),NPS(numberofevent),message(\or(1.) { if(E1>=E2) { G4Exception(\

搜索更多关于: Geant4 程序编写中的常用代码 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

if (theTrack->GetParentID() == 1) //判断当前粒子是否由初级粒子产生 std::cout << \ G4VProcess* creatorProcess= track->GetCreatorProcess(); G4cout GetTouchableHandle(); theTouchable->GetCopyNumber(); //当前几何体的Copy Number theTouchable->GetCopyNumber(1); //当前几何体母体的Copy N

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com