イベントアクションしたい(G4UserEventAction

イベントごとのデータを収集したい場合は、 G4UserEventActionクラスを継承したクラスを作成します。

 1#include "G4UserEventAction.hh"
 2
 3#include "RunAction.hh"
 4
 5class EventAction: public G4UserEventAction
 6{
 7    public:
 8        EventAction(RunAction *aAction);
 9        ~EventAction() override = default;
10
11        void BeginOfEventAction(const G4Event *aEvent) override;
12        void EndOfEventAction(const G4Event *aEvent) override;
13    private:
14        fEnergyDeposit = -1;
15}

イベント開始したい(BeginOfEventAction

1void EventAction::BeginOfEventAction(const G4Event *aEvent)
2{
3    // 内部変数(プライベート変数など)の初期化など
4    fEnergyDeposit = 0;
5}

BeginOfEventActionはイベント開始に実行されるメソッドです。 イベントごとのデータを代入するために用意した変数は、ここで初期化できます。

注釈

ヒット情報(G4THitMapG4THitsCollection)はここで初期化します。

::

イベント終了したい(EndOfEventAction

1void EventAction::EndOfEventAction(const G4Event *aEvent)
2{
3
4
5}

EndOfEventActionはイベントの終わりに実行されるメソッドです。 イベントごとデータを集計して、イベントサマリーを表示できます。

注釈

アナリシスマネージャー(G4AnalysisManager)に向けた出力は、ここで設定できます。