Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 /// \file medical/dna/range/src/RunAction.cc 27 /// \brief Implementation of the RunAction class 28 // 29 // $Id: RunAction.cc 78723 2014-01-20 10:32:17Z gcosmo $ 30 // 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 34 #include "RunAction.hh" 35 36 #include "DetectorConstruction.hh" 37 #include "HistoManager.hh" 38 #include "PhysicsList.hh" 39 #include "PrimaryGeneratorAction.hh" 40 #include "Run.hh" 41 42 #include "G4EmCalculator.hh" 43 #include "G4RunManager.hh" 44 #include "Randomize.hh" 45 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 48 RunAction::RunAction() : G4UserRunAction(), fpDetector(0), fpRun(0), fpHistoManager(0) 49 { 50 fpDetector = dynamic_cast<const DetectorConstruction*>( 51 G4RunManager::GetRunManager()->GetUserDetectorConstruction()); 52 53 fpHistoManager = new HistoManager(); 54 } 55 56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 58 RunAction::~RunAction() 59 { 60 delete fpHistoManager; 61 } 62 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 64 65 G4Run* RunAction::GenerateRun() 66 { 67 fpRun = new Run(fpDetector); 68 return fpRun; 69 } 70 71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 72 73 void RunAction::BeginOfRunAction(const G4Run*) 74 { 75 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 76 if (analysisManager->IsActive()) { 77 analysisManager->OpenFile(); 78 } 79 80 const PrimaryGeneratorAction* primary = dynamic_cast<const PrimaryGeneratorAction*>( 81 G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction()); 82 83 if (!primary) return; 84 85 G4ParticleDefinition* particle = primary->GetParticleGun()->GetParticleDefinition(); 86 G4double energy = primary->GetParticleGun()->GetParticleEnergy(); 87 fpRun->SetPrimary(particle, energy); 88 } 89 90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 91 92 void RunAction::EndOfRunAction(const G4Run*) 93 { 94 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 95 if (analysisManager->IsActive()) { 96 analysisManager->Write(); 97 analysisManager->CloseFile(); 98 } 99 } 100 101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 102