Geant4  10.02.p03
B4cEventAction Class Reference

#include <B4cEventAction.hh>

Inheritance diagram for B4cEventAction:
Collaboration diagram for B4cEventAction:

Public Member Functions

 B4cEventAction ()
 
virtual ~B4cEventAction ()
 
virtual void BeginOfEventAction (const G4Event *event)
 
virtual void EndOfEventAction (const G4Event *event)
 
- Public Member Functions inherited from G4UserEventAction
 G4UserEventAction ()
 
virtual ~G4UserEventAction ()
 
virtual void SetEventManager (G4EventManager *value)
 

Private Member Functions

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

Private Attributes

G4int fAbsHCID
 
G4int fGapHCID
 

Additional Inherited Members

- Protected Attributes inherited from G4UserEventAction
G4EventManagerfpEventManager
 

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 46 of file B4cEventAction.hh.

Constructor & Destructor Documentation

◆ B4cEventAction()

B4cEventAction::B4cEventAction ( )

Definition at line 47 of file B4cEventAction.cc.

49  fAbsHCID(-1),
50  fGapHCID(-1)
51 {}

◆ ~B4cEventAction()

B4cEventAction::~B4cEventAction ( )
virtual

Definition at line 55 of file B4cEventAction.cc.

56 {}

Member Function Documentation

◆ BeginOfEventAction()

void B4cEventAction::BeginOfEventAction ( const G4Event event)
virtual

Reimplemented from G4UserEventAction.

Definition at line 100 of file B4cEventAction.cc.

101 {}

◆ EndOfEventAction()

void B4cEventAction::EndOfEventAction ( const G4Event event)
virtual

Reimplemented from G4UserEventAction.

Definition at line 105 of file B4cEventAction.cc.

106 {
107  // Get hits collections IDs (only once)
108  if ( fAbsHCID == -1 ) {
109  fAbsHCID
110  = G4SDManager::GetSDMpointer()->GetCollectionID("AbsorberHitsCollection");
111  fGapHCID
112  = G4SDManager::GetSDMpointer()->GetCollectionID("GapHitsCollection");
113  }
114 
115  // Get hits collections
118 
119  // Get hit with total values
120  B4cCalorHit* absoHit = (*absoHC)[absoHC->entries()-1];
121  B4cCalorHit* gapHit = (*gapHC)[gapHC->entries()-1];
122 
123  // Print per event (modulo n)
124  //
125  G4int eventID = event->GetEventID();
127  if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) {
128  G4cout << "---> End of event: " << eventID << G4endl;
129 
131  absoHit->GetEdep(), absoHit->GetTrackLength(),
132  gapHit->GetEdep(), gapHit->GetTrackLength());
133  }
134 
135  // Fill histograms, ntuple
136  //
137 
138  // get analysis manager
139  G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
140 
141  // fill histograms
142  analysisManager->FillH1(1, absoHit->GetEdep());
143  analysisManager->FillH1(2, gapHit->GetEdep());
144  analysisManager->FillH1(3, absoHit->GetTrackLength());
145  analysisManager->FillH1(4, gapHit->GetTrackLength());
146 
147  // fill ntuple
148  analysisManager->FillNtupleDColumn(0, absoHit->GetEdep());
149  analysisManager->FillNtupleDColumn(1, gapHit->GetEdep());
150  analysisManager->FillNtupleDColumn(2, absoHit->GetTrackLength());
151  analysisManager->FillNtupleDColumn(3, gapHit->GetTrackLength());
152  analysisManager->AddNtupleRow();
153 }
G4int GetPrintProgress()
G4double GetEdep() const
Definition: B4cCalorHit.hh:105
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4double GetTrackLength() const
Definition: B4cCalorHit.hh:109
ExG4HbookAnalysisManager G4AnalysisManager
Definition: g4hbook_defs.hh:66
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
B4cCalorHitsCollection * GetHitsCollection(G4int hcID, const G4Event *event) const
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61
void PrintEventStatistics(G4double absoEdep, G4double absoTrackLength, G4double gapEdep, G4double gapTrackLength) const
Here is the call graph for this function:

◆ GetHitsCollection()

B4cCalorHitsCollection * B4cEventAction::GetHitsCollection ( G4int  hcID,
const G4Event event 
) const
private

Definition at line 61 of file B4cEventAction.cc.

63 {
64  B4cCalorHitsCollection* hitsCollection
65  = static_cast<B4cCalorHitsCollection*>(
66  event->GetHCofThisEvent()->GetHC(hcID));
67 
68  if ( ! hitsCollection ) {
70  msg << "Cannot access hitsCollection ID " << hcID;
71  G4Exception("B4cEventAction::GetHitsCollection()",
72  "MyCode0003", FatalException, msg);
73  }
74 
75  return hitsCollection;
76 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrintEventStatistics()

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

Definition at line 80 of file B4cEventAction.cc.

83 {
84  // print event statistics
85  G4cout
86  << " Absorber: total energy: "
87  << std::setw(7) << G4BestUnit(absoEdep, "Energy")
88  << " total track length: "
89  << std::setw(7) << G4BestUnit(absoTrackLength, "Length")
90  << G4endl
91  << " Gap: total energy: "
92  << std::setw(7) << G4BestUnit(gapEdep, "Energy")
93  << " total track length: "
94  << std::setw(7) << G4BestUnit(gapTrackLength, "Length")
95  << G4endl;
96 }
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
Here is the caller graph for this function:

Member Data Documentation

◆ fAbsHCID

G4int B4cEventAction::fAbsHCID
private

Definition at line 63 of file B4cEventAction.hh.

◆ fGapHCID

G4int B4cEventAction::fGapHCID
private

Definition at line 64 of file B4cEventAction.hh.


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