Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
B4c::EventAction Class Reference
basic » B4 » B4c

Event action class. More...

#include <Doxymodules_basic.h>

Inheritance diagram for B4c::EventAction:
G4UserEventAction

Public Member Functions

 EventAction ()=default
 
 ~EventAction () override=default
 
void BeginOfEventAction (const G4Event *event) override
 
void EndOfEventAction (const G4Event *event) override
 

Private Member Functions

CalorHitsCollectionGetHitsCollection (G4int hcID, const G4Event *event) const
 
void PrintEventStatistics (G4double absoEdep, G4double absoTrackLength, G4double gapEdep, G4double gapTrackLength) const
 

Private Attributes

G4int fAbsHCID = -1
 
G4int fGapHCID = -1
 

Detailed Description

Event action class.

In EndOfEventAction(), it prints the accumulated quantities of the energy deposit and track lengths of charged particles in Absober and Gap layers stored in the hits collections.

Definition at line 160 of file Doxymodules_basic.h.

Constructor & Destructor Documentation

◆ EventAction()

B4c::EventAction::EventAction ( )
default

◆ ~EventAction()

B4c::EventAction::~EventAction ( )
overridedefault

Member Function Documentation

◆ BeginOfEventAction()

void B4c::EventAction::BeginOfEventAction ( const G4Event event)
override

Definition at line 89 of file EventAction.cc.

90{}

◆ EndOfEventAction()

void B4c::EventAction::EndOfEventAction ( const G4Event event)
override

Definition at line 94 of file EventAction.cc.

95{
96 // Get hits collections IDs (only once)
97 if ( fAbsHCID == -1 ) {
99 = G4SDManager::GetSDMpointer()->GetCollectionID("AbsorberHitsCollection");
101 = G4SDManager::GetSDMpointer()->GetCollectionID("GapHitsCollection");
102 }
103
104 // Get hits collections
105 auto absoHC = GetHitsCollection(fAbsHCID, event);
106 auto gapHC = GetHitsCollection(fGapHCID, event);
107
108 // Get hit with total values
109 auto absoHit = (*absoHC)[absoHC->entries()-1];
110 auto gapHit = (*gapHC)[gapHC->entries()-1];
111
112 // Print per event (modulo n)
113 //
114 auto eventID = event->GetEventID();
115 auto printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
116 if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) {
118 absoHit->GetEdep(), absoHit->GetTrackLength(),
119 gapHit->GetEdep(), gapHit->GetTrackLength());
120 G4cout << "--> End of event: " << eventID << "\n" << G4endl;
121 }
122
123 // Fill histograms, ntuple
124 //
125
126 // get analysis manager
127 auto analysisManager = G4AnalysisManager::Instance();
128
129 // fill histograms
130 analysisManager->FillH1(0, absoHit->GetEdep());
131 analysisManager->FillH1(1, gapHit->GetEdep());
132 analysisManager->FillH1(2, absoHit->GetTrackLength());
133 analysisManager->FillH1(3, gapHit->GetTrackLength());
134
135 // fill ntuple
136 analysisManager->FillNtupleDColumn(0, absoHit->GetEdep());
137 analysisManager->FillNtupleDColumn(1, gapHit->GetEdep());
138 analysisManager->FillNtupleDColumn(2, absoHit->GetTrackLength());
139 analysisManager->FillNtupleDColumn(3, gapHit->GetTrackLength());
140 analysisManager->AddNtupleRow();
141}
CalorHitsCollection * GetHitsCollection(G4int hcID, const G4Event *event) const
void PrintEventStatistics(G4double absoEdep, G4double absoTrackLength, G4double gapEdep, G4double gapTrackLength) const

◆ GetHitsCollection()

CalorHitsCollection * B4c::EventAction::GetHitsCollection ( G4int  hcID,
const G4Event event 
) const
private

Definition at line 50 of file EventAction.cc.

52{
53 auto hitsCollection
54 = static_cast<CalorHitsCollection*>(
55 event->GetHCofThisEvent()->GetHC(hcID));
56
57 if ( ! hitsCollection ) {
58 G4ExceptionDescription msg;
59 msg << "Cannot access hitsCollection ID " << hcID;
60 G4Exception("EventAction::GetHitsCollection()",
61 "MyCode0003", FatalException, msg);
62 }
63
64 return hitsCollection;
65}
G4THitsCollection< CalorHit > CalorHitsCollection
Definition CalorHit.hh:80

◆ PrintEventStatistics()

void B4c::EventAction::PrintEventStatistics ( G4double  absoEdep,
G4double  absoTrackLength,
G4double  gapEdep,
G4double  gapTrackLength 
) const
private

Definition at line 69 of file EventAction.cc.

72{
73 // print event statistics
74 G4cout
75 << " Absorber: total energy: "
76 << std::setw(7) << G4BestUnit(absoEdep, "Energy")
77 << " total track length: "
78 << std::setw(7) << G4BestUnit(absoTrackLength, "Length")
79 << G4endl
80 << " Gap: total energy: "
81 << std::setw(7) << G4BestUnit(gapEdep, "Energy")
82 << " total track length: "
83 << std::setw(7) << G4BestUnit(gapTrackLength, "Length")
84 << G4endl;
85}

Member Data Documentation

◆ fAbsHCID

G4int B4c::EventAction::fAbsHCID = -1
private

Definition at line 65 of file EventAction.hh.

◆ fGapHCID

G4int B4c::EventAction::fGapHCID = -1
private

Definition at line 66 of file EventAction.hh.


The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration