File indexing completed on 2025-01-18 09:17:16
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
0030 #include "RunAction.hh"
0031
0032 #include "G4AnalysisManager.hh"
0033 #include "G4RunManager.hh"
0034 #include "G4SystemOfUnits.hh"
0035 #include "G4UnitsTable.hh"
0036 #include "globals.hh"
0037
0038 namespace B4
0039 {
0040
0041
0042
0043 RunAction::RunAction()
0044 {
0045
0046 G4RunManager::GetRunManager()->SetPrintProgress(1);
0047
0048
0049
0050
0051 auto analysisManager = G4AnalysisManager::Instance();
0052
0053
0054
0055
0056 analysisManager->SetVerboseLevel(1);
0057 analysisManager->SetNtupleMerging(true);
0058
0059
0060
0061
0062
0063
0064 analysisManager->CreateH1("Eabs", "Edep in absorber", 110, 0., 330 * MeV);
0065 analysisManager->CreateH1("Egap", "Edep in gap", 100, 0., 30 * MeV);
0066 analysisManager->CreateH1("Labs", "trackL in absorber", 100, 0., 50 * cm);
0067 analysisManager->CreateH1("Lgap", "trackL in gap", 100, 0., 50 * cm);
0068
0069
0070
0071 analysisManager->CreateNtuple("B4", "Edep and TrackL");
0072 analysisManager->CreateNtupleDColumn("Eabs");
0073 analysisManager->CreateNtupleDColumn("Egap");
0074 analysisManager->CreateNtupleDColumn("Labs");
0075 analysisManager->CreateNtupleDColumn("Lgap");
0076 analysisManager->FinishNtuple();
0077 }
0078
0079
0080
0081 void RunAction::BeginOfRunAction(const G4Run* )
0082 {
0083
0084
0085
0086
0087 auto analysisManager = G4AnalysisManager::Instance();
0088
0089
0090
0091 G4String fileName = "B4.root";
0092
0093
0094
0095
0096 analysisManager->OpenFile(fileName);
0097 G4cout << "Using " << analysisManager->GetType() << G4endl;
0098 }
0099
0100
0101
0102 void RunAction::EndOfRunAction(const G4Run* )
0103 {
0104
0105
0106 auto analysisManager = G4AnalysisManager::Instance();
0107 if (analysisManager->GetH1(1)) {
0108 G4cout << G4endl << " ----> print histograms statistic ";
0109 if (isMaster) {
0110 G4cout << "for the entire run " << G4endl << G4endl;
0111 }
0112 else {
0113 G4cout << "for the local thread " << G4endl << G4endl;
0114 }
0115
0116 G4cout << " EAbs : mean = " << G4BestUnit(analysisManager->GetH1(0)->mean(), "Energy")
0117 << " rms = " << G4BestUnit(analysisManager->GetH1(0)->rms(), "Energy") << G4endl;
0118
0119 G4cout << " EGap : mean = " << G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
0120 << " rms = " << G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy") << G4endl;
0121
0122 G4cout << " LAbs : mean = " << G4BestUnit(analysisManager->GetH1(2)->mean(), "Length")
0123 << " rms = " << G4BestUnit(analysisManager->GetH1(2)->rms(), "Length") << G4endl;
0124
0125 G4cout << " LGap : mean = " << G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
0126 << " rms = " << G4BestUnit(analysisManager->GetH1(3)->rms(), "Length") << G4endl;
0127 }
0128
0129
0130
0131 analysisManager->Write();
0132 analysisManager->CloseFile();
0133 }
0134
0135
0136
0137 }