|
Geant4 examples
|
Run action class. More...
#include <Doxymodules_basic.h>
Public Member Functions | |
| B4RunAction () | |
| virtual | ~B4RunAction () |
| virtual void | BeginOfRunAction (const G4Run *) |
| virtual void | EndOfRunAction (const G4Run *) |
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 105 of file Doxymodules_basic.h.
| B4RunAction::B4RunAction | ( | ) |
Definition at line 40 of file B4RunAction.cc.
: G4UserRunAction() { }
| B4RunAction::~B4RunAction | ( | ) | [virtual] |
Definition at line 47 of file B4RunAction.cc.
{
}
Reimplemented from G4UserRunAction.
Definition at line 53 of file B4RunAction.cc.
{
G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
//inform the runManager to save random number seed
//G4RunManager::GetRunManager()->SetRandomNumberStore(true);
// Book histograms, ntuple
//
// Create analysis manager
// The choice of analysis technology is done via selectin of a namespace
// in B4Analysis.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
// Open an output file
//
G4String fileName = "B4";
analysisManager->OpenFile(fileName);
analysisManager->SetFirstHistoId(1);
// Creating histograms
//
analysisManager->CreateH1("1","Edep in absorber", 100, 0., 800*MeV);
analysisManager->CreateH1("2","Edep in gap", 100, 0., 100*MeV);
analysisManager->CreateH1("3","trackL in absorber", 100, 0., 1*m);
analysisManager->CreateH1("4","trackL in gap", 100, 0., 50*cm);
// Creating ntuple
//
analysisManager->CreateNtuple("B4", "Edep and TrackL");
analysisManager->CreateNtupleDColumn("Eabs");
analysisManager->CreateNtupleDColumn("Egap");
analysisManager->CreateNtupleDColumn("Labs");
analysisManager->CreateNtupleDColumn("Lgap");
analysisManager->FinishNtuple();
}
Reimplemented from G4UserRunAction.
Definition at line 93 of file B4RunAction.cc.
{
G4int nofEvents = aRun->GetNumberOfEvent();
if ( nofEvents == 0 ) return;
// print histogram statistics
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->GetH1(1) ) {
G4cout << "\n ----> print histograms statistic \n" << G4endl;
G4cout
<< " EAbs : mean = " << G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
<< " rms = " << G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy")
<< G4endl;
G4cout
<< " EGap : mean = " << G4BestUnit(analysisManager->GetH1(2)->mean(), "Energy")
<< " rms = " << G4BestUnit(analysisManager->GetH1(2)->rms(), "Energy")
<< G4endl;
G4cout
<< " LAbs : mean = " << G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
<< " rms = " << G4BestUnit(analysisManager->GetH1(3)->rms(), "Length")
<< G4endl;
G4cout
<< " LGap : mean = " << G4BestUnit(analysisManager->GetH1(4)->mean(), "Length")
<< " rms = " << G4BestUnit(analysisManager->GetH1(4)->rms(), "Length")
<< G4endl;
}
// save histograms
//
analysisManager->Write();
analysisManager->CloseFile();
// complete cleanup
//
delete G4AnalysisManager::Instance();
}
1.7.4