GEANT4学习 第三节 B2中的SD 敏感探测器 2 hit信息输出

GEANT4学习 第三节 B2中的SD 敏感探测器 2 Hit信息输出

之前的博文看了B2a这个例子的设置的类,接下来看输出信息的类。

B2a的输出信息类只有两个:

B2RunAction
B2EventAction

B2RunAction里面没什么可看的,主要还是看一下B2EventAction

1.B2EventAction

在B2EventAction的EndOfEventAction里面,例子实质上已经写了一个输出hit总数的例子,如下:

G4VHitsCollection* hc = event->GetHCofThisEvent()->GetHC(0);
G4cout << "    "  
       << hc->GetSize() << " hits stored in this event" << G4endl;

这里的

hc

就是我们之前写的hitCollection.

2.输出每个事件的沉积能量

单个事件沉积能量的输出,我们需要返回B2TrackerSD::EndOfEvent函数中去进行。

我们将这个函数改成如下:

void B2TrackerSD::EndOfEvent(G4HCofThisEvent*)
{
  //if ( verboseLevel>1 ) { 
     G4int nofHits = fHitsCollection->entries();

     G4cout << G4endl
            << "-------->Hits Collection: in this event they are " << nofHits 
            << " hits in the tracker chambers: " << G4endl;
     //for ( G4int i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print();
     G4double edepofThisEvent=0.;

     for ( G4int i=0; i<nofHits; i++ ) {
     edepofThisEvent+=(*fHitsCollection)[i]->GetEdep();
     //G4cout <<"SAY: "<<(*fHitsCollection)[i]->GetTrackID()<< G4endl;  
     };
     G4cout <<edepofThisEvent<<" Mev energy deposit in this event"<< G4endl ;
  //}
}

这样就可以输出了。

### Run 0 starts.
--> Event 0 starts.

-------->Hits Collection: in this event they are 124 hits in the tracker chambers: 
0.751416 Mev energy deposit in this event
>>> Event: 0
    125 trajectories stored in this event.
    124 hits stored in this event

-------->Hits Collection: in this event they are 100 hits in the tracker chambers: 
0.640863 Mev energy deposit in this event
>>> Event: 1
    102 trajectories stored in this event.
    100 hits stored in this event

-------->Hits Collection: in this event they are 67 hits in the tracker chambers: 
0.444898 Mev energy deposit in this event
>>> Event: 2
    88 trajectories stored in this event.
    67 hits stored in this event

-------->Hits Collection: in this event they are 101 hits in the tracker chambers: 
0.629 Mev energy deposit in this event
>>> Event: 3
    104 trajectories stored in this event.
    101 hits stored in this event

-------->Hits Collection: in this event they are 0 hits in the tracker chambers: 
0 Mev energy deposit in this event
>>> Event: 4
    1066 trajectories stored in this event.
    0 hits stored in this event

-------->Hits Collection: in this event they are 0 hits in the tracker chambers: 
0 Mev energy deposit in this event
>>> Event: 5
    637 trajectories stored in this event.
    0 hits stored in this event

-------->Hits Collection: in this event they are 158 hits in the tracker chambers: 
0.967425 Mev energy deposit in this event
>>> Event: 6
    143 trajectories stored in this event.
    158 hits stored in this event

-------->Hits Collection: in this event they are 104 hits in the tracker chambers: 
0.699531 Mev energy deposit in this event
>>> Event: 7
    107 trajectories stored in this event.
    104 hits stored in this event

-------->Hits Collection: in this event they are 104 hits in the tracker chambers: 
0.595938 Mev energy deposit in this event
>>> Event: 8
    128 trajectories stored in this event.
    104 hits stored in this event

-------->Hits Collection: in this event they are 128 hits in the tracker chambers: 
0.868534 Mev energy deposit in this event
>>> Event: 9
    109 trajectories stored in this event.
    128 hits stored in this event
  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

于谦烫头

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值