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 /// \file medical/dna/range/src/RunAction.cc 26 /// \file medical/dna/range/src/RunAction.cc 27 /// \brief Implementation of the RunAction cla 27 /// \brief Implementation of the RunAction class 28 // 28 // 29 // $Id: RunAction.cc 78723 2014-01-20 10:32:17 29 // $Id: RunAction.cc 78723 2014-01-20 10:32:17Z gcosmo $ 30 // << 30 // 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 33 34 #include "RunAction.hh" 34 #include "RunAction.hh" 35 << 36 #include "DetectorConstruction.hh" 35 #include "DetectorConstruction.hh" 37 #include "HistoManager.hh" << 38 #include "PhysicsList.hh" 36 #include "PhysicsList.hh" 39 #include "PrimaryGeneratorAction.hh" 37 #include "PrimaryGeneratorAction.hh" 40 #include "Run.hh" 38 #include "Run.hh" >> 39 #include "HistoManager.hh" 41 40 42 #include "G4EmCalculator.hh" << 43 #include "G4RunManager.hh" 41 #include "G4RunManager.hh" >> 42 #include "G4EmCalculator.hh" >> 43 44 #include "Randomize.hh" 44 #include "Randomize.hh" 45 45 46 //....oooOO0OOooo........oooOO0OOooo........oo 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 47 48 RunAction::RunAction() : G4UserRunAction(), fp << 48 RunAction::RunAction() >> 49 :G4UserRunAction(), >> 50 fpDetector(0), fpRun(0),fpHistoManager(0) 49 { 51 { 50 fpDetector = dynamic_cast<const DetectorCons << 52 51 G4RunManager::GetRunManager()->GetUserDete << 53 fpDetector = >> 54 dynamic_cast<const DetectorConstruction*>(G4RunManager::GetRunManager() >> 55 ->GetUserDetectorConstruction()); 52 56 53 fpHistoManager = new HistoManager(); 57 fpHistoManager = new HistoManager(); 54 } << 58 } 55 59 56 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 61 58 RunAction::~RunAction() 62 RunAction::~RunAction() 59 { 63 { 60 delete fpHistoManager; 64 delete fpHistoManager; 61 } 65 } 62 66 63 //....oooOO0OOooo........oooOO0OOooo........oo 67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 68 65 G4Run* RunAction::GenerateRun() 69 G4Run* RunAction::GenerateRun() 66 { << 70 { 67 fpRun = new Run(fpDetector); 71 fpRun = new Run(fpDetector); 68 return fpRun; 72 return fpRun; 69 } 73 } 70 74 71 //....oooOO0OOooo........oooOO0OOooo........oo 75 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 72 76 73 void RunAction::BeginOfRunAction(const G4Run*) 77 void RunAction::BeginOfRunAction(const G4Run*) 74 { << 78 { 75 G4AnalysisManager* analysisManager = G4Analy 79 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 76 if (analysisManager->IsActive()) { << 80 if ( analysisManager->IsActive() ) { 77 analysisManager->OpenFile(); 81 analysisManager->OpenFile(); 78 } 82 } 79 << 83 80 const PrimaryGeneratorAction* primary = dyna << 84 const PrimaryGeneratorAction* primary = 81 G4RunManager::GetRunManager()->GetUserPrim << 85 dynamic_cast<const PrimaryGeneratorAction*>(G4RunManager::GetRunManager() >> 86 ->GetUserPrimaryGeneratorAction()); 82 87 83 if (!primary) return; 88 if (!primary) return; 84 << 89 85 G4ParticleDefinition* particle = primary->Ge << 90 G4ParticleDefinition* particle >> 91 = primary->GetParticleGun()->GetParticleDefinition(); 86 G4double energy = primary->GetParticleGun()- 92 G4double energy = primary->GetParticleGun()->GetParticleEnergy(); 87 fpRun->SetPrimary(particle, energy); 93 fpRun->SetPrimary(particle, energy); >> 94 88 } 95 } 89 96 90 //....oooOO0OOooo........oooOO0OOooo........oo 97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 91 98 92 void RunAction::EndOfRunAction(const G4Run*) 99 void RunAction::EndOfRunAction(const G4Run*) 93 { 100 { 94 G4AnalysisManager* analysisManager = G4Analy << 101 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 95 if (analysisManager->IsActive()) { << 102 if ( analysisManager->IsActive() ) { 96 analysisManager->Write(); 103 analysisManager->Write(); 97 analysisManager->CloseFile(); 104 analysisManager->CloseFile(); 98 } << 105 } 99 } 106 } 100 107 101 //....oooOO0OOooo........oooOO0OOooo........oo 108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 102 109