#include "run.hh" #include "G4Timer.hh" #include "G4Run.hh" #include "G4AnalysisManager.hh" MyRunAction::MyRunAction() : G4UserRunAction() , fTimer(0) { fTimer = new G4Timer; G4AnalysisManager* mgr = G4AnalysisManager::Instance(); mgr->SetVerboseLevel(0); //mgr->SetNtupleMerging(true); mgr->CreateNtuple("Ntuple1", "B"); mgr->CreateNtupleDColumn("EdepCryst1"); mgr->FinishNtuple(); } MyRunAction::~MyRunAction() { delete fTimer; } void MyRunAction::BeginOfRunAction(const G4Run*) { // Get analysis manager G4AnalysisManager* mgr = G4AnalysisManager::Instance(); // Open an output file G4String fileName = "result.root"; mgr->OpenFile(fileName); fTimer->Start(); } void MyRunAction::EndOfRunAction(const G4Run*) { fTimer->Stop(); G4cout << "Simulation time: " << *fTimer << G4endl; G4AnalysisManager* mgr = G4AnalysisManager::Instance(); mgr->Write(); mgr->CloseFile(); } /*#include "run.hh" #include "G4Timer.hh" #include "G4Run.hh" #include "G4AnalysisManager.hh" MyRunAction::MyRunAction() : G4UserRunAction() , fTimer(0) { fTimer = new G4Timer; G4AnalysisManager* mgr = G4AnalysisManager::Instance(); mgr->SetVerboseLevel(0); // Create a histogram instead of an NTuple mgr->CreateH1("EdepCryst1", "Energy deposition in Cryst1", 100, 0., 100.); // Example parameters, adjust as needed } MyRunAction::~MyRunAction() { delete fTimer; } void MyRunAction::BeginOfRunAction(const G4Run*) { // Get analysis manager G4AnalysisManager* mgr = G4AnalysisManager::Instance(); // Open an output file G4String fileName = "result.root"; mgr->OpenFile(fileName); fTimer->Start(); } void MyRunAction::EndOfRunAction(const G4Run*) { fTimer->Stop(); G4cout << "Simulation time: " << *fTimer << G4endl; G4AnalysisManager* mgr = G4AnalysisManager::Instance(); mgr->Write(); mgr->CloseFile(); }*/ /*#include "run.hh" #include "G4Timer.hh" #include "G4Run.hh" #include "G4AnalysisManager.hh" MyRunAction::MyRunAction() : G4UserRunAction() { } MyRunAction::~MyRunAction() { } void MyRunAction::BeginOfRunAction(const G4Run*) { // Get analysis manager G4AnalysisManager* mgr = G4AnalysisManager::Instance(); // Open an output file G4String fileName = "result.root"; mgr->OpenFile(fileName); } void MyRunAction::EndOfRunAction(const G4Run*) { G4AnalysisManager* mgr = G4AnalysisManager::Instance(); mgr->Write(); mgr->CloseFile(); }*/