![]() |
|
|||
File indexing completed on 2025-02-23 09:20:59
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 /// \file electromagnetic/TestEm3/src/RunAction.cc 0027 /// \brief Implementation of the RunAction class 0028 // 0029 // 0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0032 0033 #include "RunAction.hh" 0034 0035 #include "DetectorConstruction.hh" 0036 #include "HistoManager.hh" 0037 #include "PrimaryGeneratorAction.hh" 0038 #include "Run.hh" 0039 #include "RunActionMessenger.hh" 0040 0041 #include "G4RunManager.hh" 0042 #include "G4Timer.hh" 0043 #include "Randomize.hh" 0044 0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0046 0047 RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim) 0048 : fDetector(det), fPrimary(prim) 0049 { 0050 fRunMessenger = new RunActionMessenger(this); 0051 fHistoManager = new HistoManager(); 0052 } 0053 0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0055 0056 RunAction::~RunAction() 0057 { 0058 delete fRunMessenger; 0059 } 0060 0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0062 0063 G4Run* RunAction::GenerateRun() 0064 { 0065 fRun = new Run(fDetector); 0066 return fRun; 0067 } 0068 0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0070 0071 void RunAction::BeginOfRunAction(const G4Run*) 0072 { 0073 // keep run condition 0074 if (fPrimary) { 0075 G4ParticleDefinition* particle = fPrimary->GetParticleGun()->GetParticleDefinition(); 0076 G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy(); 0077 fRun->SetPrimary(particle, energy); 0078 } 0079 0080 // histograms 0081 // 0082 G4AnalysisManager* analysis = G4AnalysisManager::Instance(); 0083 if (analysis->IsActive()) analysis->OpenFile(); 0084 0085 // save Rndm status and open the timer 0086 0087 if (isMaster) { 0088 // G4Random::showEngineStatus(); 0089 fTimer = new G4Timer(); 0090 fTimer->Start(); 0091 } 0092 } 0093 0094 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0095 0096 void RunAction::EndOfRunAction(const G4Run*) 0097 { 0098 // compute and print statistic 0099 if (isMaster) { 0100 fTimer->Stop(); 0101 if (!((G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM))) { 0102 G4cout << "\n" 0103 << "Total number of events: " << fRun->GetNumberOfEvent() << G4endl; 0104 G4cout << "Master thread time: " << *fTimer << G4endl; 0105 } 0106 delete fTimer; 0107 fRun->EndOfRun(); 0108 } 0109 // save histograms 0110 G4AnalysisManager* analysis = G4AnalysisManager::Instance(); 0111 if (analysis->IsActive()) { 0112 analysis->Write(); 0113 analysis->CloseFile(); 0114 } 0115 0116 // show Rndm status 0117 // if (isMaster) G4Random::showEngineStatus(); 0118 } 0119 0120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0121 0122 void RunAction::SetEdepAndRMS(G4int i, G4double edep, G4double rms, G4double lim) 0123 { 0124 if (fRun) fRun->SetEdepAndRMS(i, edep, rms, lim); 0125 } 0126 0127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0128 0129 void RunAction::SetApplyLimit(G4bool val) 0130 { 0131 if (fRun) fRun->SetApplyLimit(val); 0132 } 0133 0134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |