File indexing completed on 2026-09-23 08:30:10
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 "WLSRunAction.hh"
0030
0031 #include "WLSDetectorConstruction.hh"
0032 #include "WLSRun.hh"
0033 #include "WLSSteppingAction.hh"
0034
0035 #include "G4AnalysisManager.hh"
0036 #include "G4Run.hh"
0037 #include "G4RunManager.hh"
0038 #include "Randomize.hh"
0039
0040
0041
0042 WLSRunAction::WLSRunAction()
0043 {
0044 auto analysisManager = G4AnalysisManager::Instance();
0045
0046 analysisManager->SetDefaultFileType("root");
0047 analysisManager->SetVerboseLevel(1);
0048 G4cout << "Using " << analysisManager->GetType() << G4endl;
0049
0050 analysisManager->CreateH1("Energy", "Energy of optical photon", 100, 2. * CLHEP::eV,
0051 3.2 * CLHEP::eV);
0052 analysisManager->CreateH1("Time", "Arrival time", 100, 0., 100. * CLHEP::ns);
0053 analysisManager->CreateH1("Number of photons", "Number of photons", 100, 0., 100.);
0054 }
0055
0056
0057
0058 G4Run* WLSRunAction::GenerateRun()
0059 {
0060 fRun = new WLSRun();
0061 return fRun;
0062 }
0063
0064
0065
0066 void WLSRunAction::BeginOfRunAction(const G4Run*)
0067 {
0068 G4AnalysisManager::Instance()->OpenFile("wls");
0069 }
0070
0071
0072
0073 void WLSRunAction::EndOfRunAction(const G4Run*)
0074 {
0075 auto analysisManager = G4AnalysisManager::Instance();
0076 if (analysisManager->GetH1(0)) {
0077 G4cout << G4endl << " ----> print histograms statistics ";
0078 if (isMaster) {
0079 G4cout << "for the entire run " << G4endl << G4endl;
0080 }
0081 else {
0082 G4cout << "for the local thread " << G4endl << G4endl;
0083 }
0084
0085 G4cout << " Mean number of photons detected/event: " << analysisManager->GetH1(2)->mean()
0086 << " rms = " << analysisManager->GetH1(2)->rms() << G4endl;
0087 }
0088
0089 analysisManager->Write();
0090 analysisManager->CloseFile();
0091
0092 if (isMaster) fRun->EndOfRun();
0093 }