Loading...
Searching...
No Matches
Public Member Functions | List of all members
B4b::RunAction Class Reference
basic » B4 » B4b

Run action class. More...

#include <Doxymodules_basic.h>

Inheritance diagram for B4b::RunAction:
G4UserRunAction

Public Member Functions

 RunAction ()
 
 ~RunAction () override=default
 
G4RunGenerateRun () override
 
void BeginOfRunAction (const G4Run *) override
 
void EndOfRunAction (const G4Run *) override
 

Detailed Description

Run action class.

It accumulates statistic and computes dispersion of the energy deposit and track lengths of charged particles with use of analysis tools: H1D histograms are created in BeginOfRunAction() for the following physics quantities:

In EndOfRunAction(), the accumulated statistic and computed dispersion is printed.

Definition at line 142 of file Doxymodules_basic.h.

Constructor & Destructor Documentation

◆ RunAction()

B4b::RunAction::RunAction ( )

Definition at line 44 of file RunAction.cc.

45{
46 // set printing event number per each event
47 G4RunManager::GetRunManager()->SetPrintProgress(1);
48
49 // Create analysis manager
50 // The choice of analysis technology is done via selectin of a namespace
51 // in Analysis.hh
52 auto analysisManager = G4AnalysisManager::Instance();
53
54 // Create directories
55 //analysisManager->SetHistoDirectoryName("histograms");
56 //analysisManager->SetNtupleDirectoryName("ntuple");
57 analysisManager->SetVerboseLevel(1);
58 analysisManager->SetNtupleMerging(true);
59 // Note: merging ntuples is available only with Root output
60
61 // Book histograms, ntuple
62 //
63
64 // Creating histograms
65 analysisManager->CreateH1("Eabs" ,"Edep in absorber", 110, 0., 330*MeV);
66 analysisManager->CreateH1("Egap" ,"Edep in gap", 100, 0., 30*MeV);
67 analysisManager->CreateH1("Labs" ,"trackL in absorber", 100, 0., 50*cm);
68 analysisManager->CreateH1("Lgap" ,"trackL in gap", 100, 0., 50*cm);
69
70 // Creating ntuple
71 //
72 analysisManager->CreateNtuple("B4", "Edep and TrackL");
73 analysisManager->CreateNtupleDColumn("Eabs");
74 analysisManager->CreateNtupleDColumn("Egap");
75 analysisManager->CreateNtupleDColumn("Labs");
76 analysisManager->CreateNtupleDColumn("Lgap");
77 analysisManager->FinishNtuple();
78}

◆ ~RunAction()

B4b::RunAction::~RunAction ( )
overridedefault

Member Function Documentation

◆ GenerateRun()

G4Run * B4b::RunAction::GenerateRun ( )
override

Definition at line 82 of file RunAction.cc.

83{
84 return (new RunData);
85}

◆ BeginOfRunAction()

void B4b::RunAction::BeginOfRunAction ( const G4Run run)
override

Definition at line 89 of file RunAction.cc.

90{
91 G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
92
93 //inform the runManager to save random number seed
94 //G4RunManager::GetRunManager()->SetRandomNumberStore(true);
95
96 // Get analysis manager
97 auto analysisManager = G4AnalysisManager::Instance();
98
99 // Open an output file
100 //
101 G4String fileName = "B4.root";
102 // Other supported output types:
103 // G4String fileName = "B4.csv";
104 // G4String fileName = "B4.hdf5";
105 // G4String fileName = "B4.xml";
106 analysisManager->OpenFile(fileName);
107 G4cout << "Using " << analysisManager->GetType() << G4endl;
108}

◆ EndOfRunAction()

void B4b::RunAction::EndOfRunAction ( const G4Run )
override

Definition at line 112 of file RunAction.cc.

113{
114 // print histogram statistics
115 //
116 auto analysisManager = G4AnalysisManager::Instance();
117 if ( analysisManager->GetH1(1) ) {
118 G4cout << G4endl << " ----> print histograms statistic ";
119 if(isMaster) {
120 G4cout << "for the entire run " << G4endl << G4endl;
121 }
122 else {
123 G4cout << "for the local thread " << G4endl << G4endl;
124 }
125
126 G4cout << " EAbs : mean = "
127 << G4BestUnit(analysisManager->GetH1(0)->mean(), "Energy")
128 << " rms = "
129 << G4BestUnit(analysisManager->GetH1(0)->rms(), "Energy") << G4endl;
130
131 G4cout << " EGap : mean = "
132 << G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
133 << " rms = "
134 << G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy") << G4endl;
135
136 G4cout << " LAbs : mean = "
137 << G4BestUnit(analysisManager->GetH1(2)->mean(), "Length")
138 << " rms = "
139 << G4BestUnit(analysisManager->GetH1(2)->rms(), "Length") << G4endl;
140
141 G4cout << " LGap : mean = "
142 << G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
143 << " rms = "
144 << G4BestUnit(analysisManager->GetH1(3)->rms(), "Length") << G4endl;
145 }
146
147 // save histograms & ntuple
148 //
149 analysisManager->Write();
150 analysisManager->CloseFile();
151
152}

The documentation for this class was generated from the following files:

Applications | User Support | Publications | Collaboration