34 #include "B4Analysis.hh"
39 #include "G4HCofThisEvent.hh"
61 B4cEventAction::GetHitsCollection(
G4int hcID,
66 event->GetHCofThisEvent()->GetHC(hcID));
68 if ( ! hitsCollection ) {
70 msg <<
"Cannot access hitsCollection ID " << hcID;
75 return hitsCollection;
80 void B4cEventAction::PrintEventStatistics(
86 <<
" Absorber: total energy: "
87 << std::setw(7) <<
G4BestUnit(absoEdep,
"Energy")
88 <<
" total track length: "
89 << std::setw(7) <<
G4BestUnit(absoTrackLength,
"Length")
91 <<
" Gap: total energy: "
92 << std::setw(7) <<
G4BestUnit(gapEdep,
"Energy")
93 <<
" total track length: "
94 << std::setw(7) <<
G4BestUnit(gapTrackLength,
"Length")
108 if ( fAbsHCID == -1 ) {
116 auto absoHC = GetHitsCollection(fAbsHCID, event);
117 auto gapHC = GetHitsCollection(fGapHCID, event);
120 auto absoHit = (*absoHC)[absoHC->entries()-1];
121 auto gapHit = (*gapHC)[gapHC->entries()-1];
125 auto eventID =
event->GetEventID();
127 if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) {
130 PrintEventStatistics(
131 absoHit->GetEdep(), absoHit->GetTrackLength(),
132 gapHit->GetEdep(), gapHit->GetTrackLength());
139 auto analysisManager = G4AnalysisManager::Instance();
142 analysisManager->FillH1(0, absoHit->GetEdep());
143 analysisManager->FillH1(1, gapHit->GetEdep());
144 analysisManager->FillH1(2, absoHit->GetTrackLength());
145 analysisManager->FillH1(3, gapHit->GetTrackLength());
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();
G4int GetCollectionID(G4String colName)
std::ostringstream G4ExceptionDescription
virtual void BeginOfEventAction(const G4Event *event)
virtual void EndOfEventAction(const G4Event *event)
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
Definition of the B4cCalorimeterSD class.
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4RunManager * GetRunManager()
static G4SDManager * GetSDMpointer()
Definition of the B4cEventAction class.
virtual ~B4cEventAction()
Definition of the B4cCalorHit class.