Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: RunAction.cc 107824 2017-12-05 15:47:44Z gunter $ 26 // 27 // 27 /// \file medical/GammaTherapy/src/RunAction.c 28 /// \file medical/GammaTherapy/src/RunAction.cc 28 /// \brief Implementation of the RunAction cla 29 /// \brief Implementation of the RunAction class 29 // 30 // 30 // ------------------------------------------- 31 // ------------------------------------------------------------- 31 // 32 // 32 // GEANT4 << 33 // GEANT4 33 // 34 // 34 // ------------------------------------------- 35 // ------------------------------------------------------------- 35 36 36 //....oooOO0OOooo........oooOO0OOooo........oo 37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 37 //....oooOO0OOooo........oooOO0OOooo........oo 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 38 39 39 #include "RunAction.hh" 40 #include "RunAction.hh" 40 << 41 #include "DetectorConstruction.hh" 41 #include "DetectorConstruction.hh" 42 #include "HistoManager.hh" << 43 #include "PrimaryGeneratorAction.hh" 42 #include "PrimaryGeneratorAction.hh" >> 43 #include "HistoManager.hh" 44 #include "Run.hh" 44 #include "Run.hh" 45 45 46 #include "Randomize.hh" 46 #include "Randomize.hh" 47 #include "globals.hh" 47 #include "globals.hh" 48 48 49 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 50 50 51 RunAction::RunAction(DetectorConstruction* det << 51 RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin) 52 : G4UserRunAction(), fDetector(det), fRun(0) << 52 :G4UserRunAction(),fDetector(det), fPrimary(kin), fRun(0), fHistoManager(0) 53 { 53 { 54 // Book predefined histograms 54 // Book predefined histograms 55 fHistoManager = new HistoManager(); 55 fHistoManager = new HistoManager(); 56 fHistoManager->Update(det); 56 fHistoManager->Update(det); 57 } 57 } 58 58 59 //....oooOO0OOooo........oooOO0OOooo........oo 59 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 60 60 61 RunAction::~RunAction() 61 RunAction::~RunAction() 62 { 62 { >> 63 #ifdef G4MULTITHREADED >> 64 if (isMaster) delete fPrimary; >> 65 #endif 63 delete fHistoManager; 66 delete fHistoManager; 64 } 67 } 65 68 66 //....oooOO0OOooo........oooOO0OOooo........oo 69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 67 70 68 G4Run* RunAction::GenerateRun() 71 G4Run* RunAction::GenerateRun() 69 { << 72 { 70 fRun = new Run(fDetector, fHistoManager); << 73 fRun = new Run(fDetector,fPrimary,fHistoManager); 71 return fRun; 74 return fRun; 72 } 75 } 73 76 >> 77 74 void RunAction::BeginOfRunAction(const G4Run*) 78 void RunAction::BeginOfRunAction(const G4Run*) 75 { 79 { 76 // save Rndm status 80 // save Rndm status 77 //// G4RunManager::GetRunManager()->SetRand 81 //// G4RunManager::GetRunManager()->SetRandomNumberStore(true); 78 // if (isMaster) G4Random::showEngineStatus 82 // if (isMaster) G4Random::showEngineStatus(); 79 83 80 CLHEP::HepRandom::showEngineStatus(); 84 CLHEP::HepRandom::showEngineStatus(); 81 << 85 82 // histograms << 86 //histograms 83 // << 87 // 84 G4AnalysisManager* analysisManager = G4Analy 88 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 85 if (analysisManager->IsActive()) { << 89 if ( analysisManager->IsActive() ) { 86 analysisManager->OpenFile(); 90 analysisManager->OpenFile(); 87 } << 91 } 88 } 92 } 89 93 90 //....oooOO0OOooo........oooOO0OOooo........oo 94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 91 95 92 void RunAction::EndOfRunAction(const G4Run*) 96 void RunAction::EndOfRunAction(const G4Run*) 93 { << 97 { 94 // print Run summary 98 // print Run summary 95 // 99 // 96 if (isMaster) fRun->EndOfRun(); << 100 if (isMaster) fRun->EndOfRun(); 97 << 101 98 // save histograms 102 // save histograms 99 G4AnalysisManager* analysisManager = G4Analy << 103 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 100 if (analysisManager->IsActive()) { << 104 if ( analysisManager->IsActive() ) { 101 analysisManager->Write(); 105 analysisManager->Write(); 102 analysisManager->CloseFile(); 106 analysisManager->CloseFile(); 103 } << 107 } 104 108 105 // show Rndm status 109 // show Rndm status 106 if (isMaster) G4Random::showEngineStatus(); 110 if (isMaster) G4Random::showEngineStatus(); 107 } 111 } 108 112 109 //....oooOO0OOooo........oooOO0OOooo........oo 113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 114 110 115