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