八千里路云和月

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  62 随笔 :: 0 文章 :: 0 评论 :: 37899 阅读

geant4 trackingAction


在 tractAction 类中实现的 PreUserTrackingAction(const G4Track* theTrack) 和 PostUserTrackingAction(const G4Track* theTrack) 的区别 ?

通过输出,判断两者的区别

复制代码
PreUserTrackingAction track ID = 1
PreUserTrackingAction parent ID = 0
PreUserTrackingAction Current Step ID = 0
PreUserTrackingAction Particle = Am241
PreUserTrackingAction Position = (0,0,0)
PreUserTrackingAction KineticEnergy = 0
PreUserTrackingAction Momentum = (0,0,-0)
PreUserTrackingAction GlobalTime = 0
PreUserTrackingAction LocalTime = 0
PreUserTrackingAction ProperTime = 0

PostUserTrackingAction track ID = 1
PostUserTrackingAction parent ID = 0
PostUserTrackingAction Current Step ID = 1
PostUserTrackingAction Particle = Am241
PostUserTrackingAction Position = (0,0,0)
PostUserTrackingAction KineticEnergy = 0
PostUserTrackingAction Momentum = (0,0,-0)
PostUserTrackingAction GlobalTime = 4.03267e+18
PostUserTrackingAction LocalTime = 4.03267e+18
PostUserTrackingAction ProperTime = 4.03267e+18


PreUserTrackingAction track ID = 3
PreUserTrackingAction parent ID = 1
PreUserTrackingAction Current Step ID = 0
PreUserTrackingAction Particle = alpha
PreUserTrackingAction Position = (0,0,0)
PreUserTrackingAction KineticEnergy = 5.4429
PreUserTrackingAction Momentum = (16.6282,-161.089,-119.912)
PreUserTrackingAction GlobalTime = 4.03267e+18
PreUserTrackingAction LocalTime = 0
PreUserTrackingAction ProperTime = 0

PostUserTrackingAction track ID = 3
PostUserTrackingAction parent ID = 1
PostUserTrackingAction Current Step ID = 154
PostUserTrackingAction Particle = alpha
PostUserTrackingAction Position = (1.48547,-13.0785,-9.85898)
PostUserTrackingAction KineticEnergy = 0
PostUserTrackingAction Momentum = (0,-0,-0)
PostUserTrackingAction GlobalTime = 4.03267e+18
PostUserTrackingAction LocalTime = 1.10012
PostUserTrackingAction ProperTime = 1.09875
复制代码
  • PreUserTrackingAction() 和 PostUserTrackingAction() 指的是同一个 track.
  • PreUserTrackingAction() 返回的是该 track 第一个 step 提取出的信息。
  • PostUserTrackingAction() 返回的是该 track 最后一个step 提取出的信息。

从 trackAction 中可以提取哪些信息?

  • trackID
  • parent ID
  • current step ID
  • particle name
  • current step position
  • current step kinetic energy
  • current step momentum
  • golbal time: 从 event 起点到当前 step 的时间,单位是 ns
  • local time: 从 tarck 起点到当前 step 的时间
  • proper time: time in its rest frame since the track was created

解释 GlobalTime

使用 241Am 放射源,其半衰期为 432.6 y,模拟 10w 次事件,提取 trackID = 1 时,postuserTrackingAction 中的 GlobalTime. 理论上,将提取得到的 GlobalTime 做直方图,是指数衰减的曲线。实际的模拟结果如下,这里横坐标是 GlobalTime/432.6y 的结果,理论上该曲线为 y=100000e0.693t,实际的拟合结果很接近。

代码如下:Am241Life.cc

复制代码
 1 const double half_life = 432.6*365*24*3600*1000000000;
 2 
 3 void Am241Life()
 4 {
 5   ifstream file;
 6   file.open("hanX3Copy", ifstream::in);
 7   if (!file) {
 8     cout << "cannot open the file." << endl;
 9     return ;
10   }
11 
12   cout << "half time = " << half_life << endl;
13   vector<double> life_unit;
14   double life_ns;
15   
16   while (1) {
17     file >> life_ns;
18     if (!file.good()) break;
19     life_unit.push_back((double)life_ns/half_life);
20   }
21 
22   file.close();
23 
24   cout << life_unit.size() << endl;
25   for (int i=0; i<10; i++) {
26     cout << life_unit[i] << endl;
27   }
28 
29   TH1D* h1 = new TH1D("h1","h1",10,0.,10.);
30   vector<double>::iterator it;
31   for (it = life_unit.begin() ; it != life_unit.end(); ++it) {
32     h1->Fill(*it);
33   }
34 
35   h1->Draw();
36 }
复制代码

这说明,在使用时间作为 kill track 的限制时,要排除掉第一个 trackID 的 GlobalTime.

 

posted on   hanX3  阅读(710)  评论(0编辑  收藏  举报
编辑推荐:
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示