首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Geant4的几何边界判断代码解析

Geant4的几何边界判断代码解析

作者头像
梁佐佐
发布2020-09-04 17:29:56
1.7K6
发布2020-09-04 17:29:56
举报
文章被收录于专栏:人芳觅人芳觅

来不及解释了,“几何边界的信息抽取”加班加点写给大家。

目 录

1.事件示范step信息

2.几何边界的判断

a) 抽取track的nextvolume

b) 抽取PostStepPoint的所属volume

c) 抽取Pre/PostStepPoint的status

1. 事件示范step信息

图1. 1MeV gamma入射到1cm3 BGO闪烁体的step信息

图2. 1 MeV gamma入射事件的几何记录信息

2. 几何边界的判断

以伽玛在Boundary2处做讲解分析。首先判断PreStepPoint所在的physicalvolume是否为”phybgo”,然后通过以下三种方式给出Boundary2的定义:

a) 抽取当前step所属track的nextvolume

void B1SteppingAction::UserSteppingAction(const G4Step* step)
{ /* const*/ G4StepPoint* prePoint = step->GetPreStepPoint();
/* const*/ G4StepPoint* endPoint = step->GetPostStepPoint();
G4String nowvolumename= prePoint->GetTouchableHandle()->GetVolume()->GetName();
G4Track *aTrack = step->GetTrack();
G4VPhysicalVolume* nextpv=aTrack->GetNextVolume();
if (nextpv!=NULL)
  {
  G4String nextvolumename = nextpv->GetName();
  if(nowvolumename=="phybgo"&&nextvolumename=="World")
    {G4double E=aTrack->GetKineticEnergy();
    G4cout<<"boundaryenergy is "<< E<<G4endl;
    }
  }
}

b) 抽取当前step的PostStepPoint的所属volume

void B1SteppingAction::UserSteppingAction(const G4Step* step)
{ /* const*/ G4StepPoint* prePoint = step->GetPreStepPoint();
/* const*/ G4StepPoint* endPoint = step->GetPostStepPoint();
G4Track *aTrack = step->GetTrack();
G4String nowvolumename= prePoint->GetTouchableHandle()->GetVolume()->GetName();
G4VPhysicalVolume* nextpv= endPoint ->GetTouchableHandle()->GetVolume();
if (nextpv!=NULL)
  {
  G4String nextvolumename = nextpv->GetName();
  if(nowvolumename=="phybgo"&&nextvolumename=="World")
    {G4double E=aTrack->GetKineticEnergy();
    G4cout<<"boundaryenergy is "<< E<<G4endl;
    }
  }
}

c) 抽取当前step的PreStepPoint或PostStepPoint的status

void B1SteppingAction::UserSteppingAction(const G4Step* step)
{ /* const*/ G4StepPoint* prePoint = step->GetPreStepPoint();
/* const*/ G4StepPoint* endPoint = step->GetPostStepPoint();
G4Track *aTrack = step->GetTrack();
G4String nowvolumename= prePoint->GetTouchableHandle()->GetVolume()->GetName();
if ( nowvolumename=="phybgo"&&endPoint->GetStepStatus() == fGeomBoundary)
  {G4double E=aTrack->GetKineticEnergy();
  G4cout<<"boundary energy is "<<E<<G4endl;
  }
}

图3. 三种方法均能给出gamma逃出BGO时的判断

下一篇将给出step的信息抽取代码示范,特别给出Segmentationfault (core dumped)段错误的常见情况分析。

本公众号的教程本着给代码、给特例的初衷,助力大家的科研,严谨、用心,力争做到最实用、无BUG,成为值得备份的学习资料。

进入公众号点击“看看圈子”,Geant4问题可以留言交流~

喜欢的话,分享一下吧~^o^~

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-06-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 人芳觅 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档