// // /// \file B4aEventAction.cc /// \brief Implementation of the B4aEventAction class #include "B4aEventAction.hh" #include "B4RunAction.hh" #include "B4Analysis.hh" #include "G4RunManager.hh" #include "G4Event.hh" #include "G4UnitsTable.hh" #include "Randomize.hh" #include //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... B4aEventAction::B4aEventAction() : G4UserEventAction(), fEnergySilicon(0.), fEnergyScintillator(0.), fTrackLSilicon(0.), fTrackLScintillator(0.) {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... B4aEventAction::~B4aEventAction() {} //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void B4aEventAction::BeginOfEventAction(const G4Event* /*event*/) { // initialisation per event fEnergySilicon = 0.; fEnergyScintillator = 0.; fTrackLSilicon = 0.; fTrackLScintillator = 0.; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... void B4aEventAction::EndOfEventAction(const G4Event* event) { // Accumulate statistics // // get analysis manager auto analysisManager = G4AnalysisManager::Instance(); // fill histograms analysisManager->FillH1(0, fEnergySilicon); analysisManager->FillH1(1, fEnergyScintillator); analysisManager->FillH1(2, fTrackLSilicon); analysisManager->FillH1(3, fTrackLScintillator); analysisManager->FillH2(0, fEnergyScintillator, fEnergySilicon); // fill ntuple analysisManager->FillNtupleDColumn(0, fEnergySilicon); analysisManager->FillNtupleDColumn(1, fEnergyScintillator); analysisManager->FillNtupleDColumn(2, fTrackLSilicon); analysisManager->FillNtupleDColumn(3, fTrackLScintillator); analysisManager->AddNtupleRow(); // Print per event (modulo n) // auto eventID = event->GetEventID(); auto printModulo = G4RunManager::GetRunManager()->GetPrintProgress(); if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) { G4cout << "---> End of event: " << eventID << G4endl; G4cout << " Silicon: total energy: " << std::setw(7) << G4BestUnit(fEnergySilicon,"Energy") << " total track length: " << std::setw(7) << G4BestUnit(fTrackLSilicon,"Length") << G4endl << " Scintillator: total energy: " << std::setw(7) << G4BestUnit(fEnergyScintillator,"Energy") << " total track length: " << std::setw(7) << G4BestUnit(fTrackLScintillator,"Length") << G4endl; } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......