41 lines
1.2 KiB
C++
41 lines
1.2 KiB
C++
#include "GeneRunAction.hh"
|
|
|
|
#include "GeneAnalysisManager.hh"
|
|
#include "GeneRunActionMessenger.hh"
|
|
#include <G4Run.hh>
|
|
#include <G4SystemOfUnits.hh>
|
|
#include <G4UImanager.hh>
|
|
#include <G4VVisManager.hh>
|
|
#include <G4ios.hh>
|
|
|
|
GeneRunAction::GeneRunAction() : G4UserRunAction() {
|
|
RunNo = "00";
|
|
pMessenger = new GeneRunActionMessenger(this);
|
|
}
|
|
|
|
GeneRunAction::~GeneRunAction() { delete pMessenger; }
|
|
|
|
void GeneRunAction::BeginOfRunAction(const G4Run*) {
|
|
// Prepare the visualization
|
|
if (G4VVisManager::GetConcreteInstance()) {
|
|
G4UImanager* UI = G4UImanager::GetUIpointer();
|
|
UI->ApplyCommand("/vis/scene/notifyHandlers");
|
|
}
|
|
|
|
GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance();
|
|
G4String sFileName = "Simulation_RunNo" + RunNo + ".root";
|
|
analysisManager->SetAnalysisFileName(sFileName);
|
|
// Open an output file
|
|
analysisManager->book();
|
|
}
|
|
|
|
void GeneRunAction::EndOfRunAction(const G4Run*) {
|
|
// Run ended, update the visualization
|
|
if (G4VVisManager::GetConcreteInstance()) {
|
|
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
|
|
}
|
|
|
|
GeneAnalysisManager* analysisManager = GeneAnalysisManager::GetInstance();
|
|
analysisManager->save();
|
|
}
|