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 // This example is provided by the Geant4-DNA 26 // This example is provided by the Geant4-DNA collaboration 27 // Any report or published results obtained us << 27 // Any report or published results obtained using the Geant4-DNA software 28 // shall cite the following Geant4-DNA collabo 28 // shall cite the following Geant4-DNA collaboration publications: 29 // Med. Phys. 45 (2018) e722-e739 << 30 // Phys. Med. 31 (2015) 861-874 << 31 // Med. Phys. 37 (2010) 4692-4708 29 // Med. Phys. 37 (2010) 4692-4708 32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) << 30 // Phys. Med. 31 (2015) 861-874 33 // << 34 // The Geant4-DNA web site is available at htt 31 // The Geant4-DNA web site is available at http://geant4-dna.org 35 // 32 // 36 /// \file medical/dna/svalue/src/RunAction.cc 33 /// \file medical/dna/svalue/src/RunAction.cc 37 /// \brief Implementation of the RunAction cla 34 /// \brief Implementation of the RunAction class 38 35 39 #include "RunAction.hh" 36 #include "RunAction.hh" 40 << 37 #include "DetectorConstruction.hh" >> 38 #include "PhysicsList.hh" >> 39 #include "Run.hh" 41 #include "HistoManager.hh" 40 #include "HistoManager.hh" 42 #include "MyFile.hh" 41 #include "MyFile.hh" 43 #include "Run.hh" << 44 42 45 #ifdef MYFILE 43 #ifdef MYFILE 46 # include "MyPrimaryGeneratorActionFromFile.h << 44 #include "MyPrimaryGeneratorActionFromFile.hh" 47 #else 45 #else 48 # include "PrimaryGeneratorAction.hh" << 46 #include "PrimaryGeneratorAction.hh" 49 #endif 47 #endif 50 48 51 #include "G4RunManager.hh" 49 #include "G4RunManager.hh" >> 50 #include "G4EmCalculator.hh" >> 51 >> 52 #include "Randomize.hh" 52 53 53 //....oooOO0OOooo........oooOO0OOooo........oo 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 54 55 55 RunAction::RunAction() : G4UserRunAction(), fp << 56 RunAction::RunAction() >> 57 :G4UserRunAction(), >> 58 fpDetector(0), fpRun(0),fpHistoManager(0) 56 { 59 { 57 fpDetector = dynamic_cast<const DetectorCons << 60 fpDetector = 58 G4RunManager::GetRunManager()->GetUserDete << 61 dynamic_cast<const DetectorConstruction*>(G4RunManager::GetRunManager() >> 62 ->GetUserDetectorConstruction()); 59 63 60 // Book predefined histograms 64 // Book predefined histograms 61 fpHistoManager = new HistoManager(); 65 fpHistoManager = new HistoManager(); 62 } << 66 } 63 67 64 //....oooOO0OOooo........oooOO0OOooo........oo 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 69 66 RunAction::~RunAction() 70 RunAction::~RunAction() 67 { 71 { 68 delete fpHistoManager; 72 delete fpHistoManager; 69 } 73 } 70 74 71 //....oooOO0OOooo........oooOO0OOooo........oo 75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 72 76 73 G4Run* RunAction::GenerateRun() 77 G4Run* RunAction::GenerateRun() 74 { << 78 { 75 fpRun = new Run(fpDetector); 79 fpRun = new Run(fpDetector); 76 return fpRun; 80 return fpRun; 77 } 81 } 78 82 79 //....oooOO0OOooo........oooOO0OOooo........oo 83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 80 84 81 void RunAction::BeginOfRunAction(const G4Run*) 85 void RunAction::BeginOfRunAction(const G4Run*) 82 { << 86 { 83 // If needed, save Rndm status << 87 // save Rndm status 84 // G4RunManager::GetRunManager()->SetRandomN 88 // G4RunManager::GetRunManager()->SetRandomNumberStore(true); 85 // if (isMaster) G4Random::showEngineStatus( 89 // if (isMaster) G4Random::showEngineStatus(); 86 << 90 87 // Histograms << 91 //histograms 88 << 92 // 89 G4AnalysisManager* analysisManager = G4Analy 93 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 90 if (analysisManager->IsActive()) { << 94 if ( analysisManager->IsActive() ) { 91 analysisManager->OpenFile(); 95 analysisManager->OpenFile(); 92 } 96 } 93 << 97 94 // Selection of primary generator << 98 //============================================================================ 95 99 96 #ifdef MYFILE 100 #ifdef MYFILE 97 << 101 98 const MyPrimaryGeneratorActionFromFile* prim << 102 const MyPrimaryGeneratorActionFromFile* primary = 99 dynamic_cast<const MyPrimaryGeneratorActio << 103 dynamic_cast<const MyPrimaryGeneratorActionFromFile*>(G4RunManager::GetRunManager() 100 G4RunManager::GetRunManager()->GetUserPr << 104 ->GetUserPrimaryGeneratorAction()); 101 << 105 102 #else 106 #else 103 const PrimaryGeneratorAction* primary = dyna << 107 const PrimaryGeneratorAction* primary = 104 G4RunManager::GetRunManager()->GetUserPrim << 108 dynamic_cast<const PrimaryGeneratorAction*>(G4RunManager::GetRunManager() >> 109 ->GetUserPrimaryGeneratorAction()); 105 110 106 #endif 111 #endif 107 112 108 if (!primary) return; // << 113 if (!primary) return; // 109 << 114 110 // Keep run condition << 115 // keep run condition 111 << 116 G4ParticleDefinition* particle 112 G4ParticleDefinition* particle = primary->Ge << 117 = primary->GetParticleGun()->GetParticleDefinition(); 113 << 114 G4double energy = primary->GetParticleGun()- 118 G4double energy = primary->GetParticleGun()->GetParticleEnergy(); 115 << 116 fpRun->SetPrimary(particle, energy); 119 fpRun->SetPrimary(particle, energy); >> 120 117 } 121 } 118 122 119 //....oooOO0OOooo........oooOO0OOooo........oo 123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 120 124 121 void RunAction::EndOfRunAction(const G4Run*) 125 void RunAction::EndOfRunAction(const G4Run*) 122 { 126 { 123 if (isMaster) fpRun->EndOfRun(); 127 if (isMaster) fpRun->EndOfRun(); 124 << 128 125 // Save histograms << 129 // save histograms 126 << 130 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 127 G4AnalysisManager* analysisManager = G4Analy << 131 if ( analysisManager->IsActive() ) { 128 if (analysisManager->IsActive()) { << 129 analysisManager->Write(); 132 analysisManager->Write(); 130 analysisManager->CloseFile(); 133 analysisManager->CloseFile(); 131 } << 134 } 132 << 135 133 // If needed, show Rndm status << 136 // show Rndm status 134 // if (isMaster) G4Random::showEngineStatus( << 137 // if (isMaster) G4Random::showEngineStatus(); 135 } 138 } 136 139