File indexing completed on 2026-03-28 07:49:53
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #include "GB03RunAction.hh"
0030
0031 #include "GB03DetectorConstruction.hh"
0032 #include "GB03Run.hh"
0033
0034 #include "G4AnalysisManager.hh"
0035 #include "G4Box.hh"
0036 #include "G4RunManager.hh"
0037 #include "G4SolidStore.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4UnitsTable.hh"
0040 #include "globals.hh"
0041
0042
0043
0044 G4Run* GB03RunAction::GenerateRun()
0045 {
0046
0047 return new GB03Run();
0048 }
0049
0050
0051 GB03RunAction::GB03RunAction()
0052 {
0053
0054 auto analysisManager = G4AnalysisManager::Instance();
0055 analysisManager->SetDefaultFileType("root");
0056 analysisManager->SetFileName("GB03");
0057
0058
0059
0060
0061
0062 analysisManager->CreateH1("En", "E kin neutron", 100, 0., 100.0 * MeV);
0063 analysisManager->CreateH1("Eg", "E kin gamma", 100, 0., 15.0 * MeV);
0064 analysisManager->CreateH1("Nnhit", "The number of neutrons along x", 100, -1.5 * m, 150 * m / cm);
0065 analysisManager->CreateH1("Nghit", "The number of gammas along x", 100, -1.5 * m / cm,
0066 1.5 * m / cm);
0067 }
0068
0069
0070
0071 void GB03RunAction::BeginOfRunAction(const G4Run* )
0072 {
0073 auto rm = G4RunManager::GetRunManager();
0074 auto det = static_cast<const GB03DetectorConstruction*>(rm->GetUserDetectorConstruction());
0075 fVerbose = det->GetVerboseLevel();
0076
0077 auto* smeas = static_cast<G4Box*>(G4SolidStore::GetInstance()->GetSolid("Hodo"));
0078
0079 auto halfX = smeas->GetXHalfLength() / cm;
0080
0081
0082 auto analysisManager = G4AnalysisManager::Instance();
0083
0084
0085 analysisManager->SetH1(2, 100, -halfX, halfX);
0086 analysisManager->SetH1(3, 100, -halfX, halfX);
0087
0088
0089
0090 analysisManager->OpenFile();
0091 }
0092
0093
0094
0095 void GB03RunAction::EndOfRunAction(const G4Run* brun)
0096 {
0097 auto run = static_cast<const GB03Run*>(brun);
0098 if (isMaster) {
0099 if (fVerbose > 0) {
0100 G4cout << "for the entire run " << run->GetNumberOfEvent() << G4endl << G4endl;
0101 run->GetPartCounter()->Print();
0102 }
0103 }
0104 else {
0105 if (fVerbose > 2) {
0106 G4cout << "for the local thread " << G4endl << G4endl;
0107 run->GetPartCounter()->Print();
0108 }
0109 }
0110
0111
0112 auto analysisManager = G4AnalysisManager::Instance();
0113 analysisManager->Write();
0114 analysisManager->CloseFile();
0115 }
0116
0117