Warning, file /geant4/examples/basic/B4/B4b/src/RunAction.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
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 "RunData.hh"
0033
0034 #include "G4AnalysisManager.hh"
0035 #include "G4Run.hh"
0036 #include "G4RunManager.hh"
0037 #include "G4SystemOfUnits.hh"
0038 #include "G4UnitsTable.hh"
0039 #include "globals.hh"
0040
0041 namespace B4b
0042 {
0043
0044
0045
0046 RunAction::RunAction()
0047 {
0048
0049 G4RunManager::GetRunManager()->SetPrintProgress(1);
0050
0051
0052
0053
0054 auto analysisManager = G4AnalysisManager::Instance();
0055
0056
0057
0058
0059 analysisManager->SetVerboseLevel(1);
0060 analysisManager->SetNtupleMerging(true);
0061
0062
0063
0064
0065
0066
0067 analysisManager->CreateH1("Eabs", "Edep in absorber", 110, 0., 330 * MeV);
0068 analysisManager->CreateH1("Egap", "Edep in gap", 100, 0., 30 * MeV);
0069 analysisManager->CreateH1("Labs", "trackL in absorber", 100, 0., 50 * cm);
0070 analysisManager->CreateH1("Lgap", "trackL in gap", 100, 0., 50 * cm);
0071
0072
0073
0074 analysisManager->CreateNtuple("B4", "Edep and TrackL");
0075 analysisManager->CreateNtupleDColumn("Eabs");
0076 analysisManager->CreateNtupleDColumn("Egap");
0077 analysisManager->CreateNtupleDColumn("Labs");
0078 analysisManager->CreateNtupleDColumn("Lgap");
0079 analysisManager->FinishNtuple();
0080 }
0081
0082
0083
0084 G4Run* RunAction::GenerateRun()
0085 {
0086 return (new RunData);
0087 }
0088
0089
0090
0091 void RunAction::BeginOfRunAction(const G4Run* run)
0092 {
0093 G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
0094
0095
0096
0097
0098
0099 auto analysisManager = G4AnalysisManager::Instance();
0100
0101
0102
0103 G4String fileName = "B4.root";
0104
0105
0106
0107
0108 analysisManager->OpenFile(fileName);
0109 G4cout << "Using " << analysisManager->GetType() << G4endl;
0110 }
0111
0112
0113
0114 void RunAction::EndOfRunAction(const G4Run* )
0115 {
0116
0117
0118 auto analysisManager = G4AnalysisManager::Instance();
0119 if (analysisManager->GetH1(1)) {
0120 G4cout << G4endl << " ----> print histograms statistic ";
0121 if (isMaster) {
0122 G4cout << "for the entire run " << G4endl << G4endl;
0123 }
0124 else {
0125 G4cout << "for the local thread " << G4endl << G4endl;
0126 }
0127
0128 G4cout << " EAbs : mean = " << G4BestUnit(analysisManager->GetH1(0)->mean(), "Energy")
0129 << " rms = " << G4BestUnit(analysisManager->GetH1(0)->rms(), "Energy") << G4endl;
0130
0131 G4cout << " EGap : mean = " << G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
0132 << " rms = " << G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy") << G4endl;
0133
0134 G4cout << " LAbs : mean = " << G4BestUnit(analysisManager->GetH1(2)->mean(), "Length")
0135 << " rms = " << G4BestUnit(analysisManager->GetH1(2)->rms(), "Length") << G4endl;
0136
0137 G4cout << " LGap : mean = " << G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
0138 << " rms = " << G4BestUnit(analysisManager->GetH1(3)->rms(), "Length") << G4endl;
0139 }
0140
0141
0142
0143 analysisManager->Write();
0144 analysisManager->CloseFile();
0145 }
0146
0147
0148
0149 }