Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/extended/medical/dna/neuron/src/RunAction.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 RunAction.cc
0027 /// \brief Implementation of the RunAction class
0028 
0029 // This example is provided by the Geant4-DNA collaboration
0030 // Any report or published results obtained using the Geant4-DNA software
0031 // shall cite the following Geant4-DNA collaboration publication:
0032 // Med. Phys. 37 (2010) 4692-4708
0033 // and papers
0034 // M. Batmunkh et al. J Radiat Res Appl Sci 8 (2015) 498-507
0035 // O. Belov et al. Physica Medica 32 (2016) 1510-1520
0036 // The Geant4-DNA web site is available at http://geant4-dna.org
0037 //
0038 // -------------------------------------------------------------------
0039 // November 2016
0040 // -------------------------------------------------------------------
0041 //
0042 
0043 #include "RunAction.hh"
0044 
0045 #include "CommandLineParser.hh"
0046 #include "DetectorConstruction.hh"
0047 #include "PrimaryGeneratorAction.hh"
0048 #include "Run.hh"
0049 #include "TrackingAction.hh"
0050 
0051 #include "G4AnalysisManager.hh"
0052 #include "G4ParticleDefinition.hh"
0053 #include "G4Run.hh"
0054 #include "G4RunManager.hh"
0055 #include "G4SystemOfUnits.hh"
0056 #include "G4Threading.hh"
0057 #include "G4UImanager.hh"
0058 #include "G4UnitsTable.hh"
0059 #include "Randomize.hh"
0060 
0061 #include <iomanip>
0062 
0063 using namespace G4DNAPARSER;
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 
0067 RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim)
0068   : G4UserRunAction(), fDetector(det), fPrimary(prim)
0069 {}
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 G4Run* RunAction::GenerateRun()
0074 {
0075   if (nullptr == fRun) {
0076     fRun = new Run(fDetector);
0077   }
0078   return fRun;
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 
0083 void RunAction::BeginOfRunAction(const G4Run* /*run*/)
0084 {
0085   RunInitManager::Instance()->Initialize();
0086 
0087   if (nullptr != fPrimary) {
0088     G4ParticleDefinition* particle = fPrimary->GetParticleGun()->GetParticleDefinition();
0089     G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
0090     fRun->SetPrimary(particle, energy);
0091   }
0092 }
0093 
0094 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0095 
0096 void RunAction::EndOfRunAction(const G4Run* /*run*/)
0097 {
0098   if (isMaster) fRun->EndOfRun();
0099 }
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102 
0103 void RunAction::CreateHistogram()
0104 {
0105   // Book histograms, ntuple
0106   // Create analysis manager
0107 
0108   CommandLineParser* parser = CommandLineParser::GetParser();
0109   Command* command(0);
0110   if ((command = parser->GetCommandIfActive("-out")) == 0) return;
0111 }
0112 
0113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0114 
0115 void RunAction::WriteHistogram()
0116 {
0117   CommandLineParser* parser = CommandLineParser::GetParser();
0118   Command* commandLine(0);
0119   if ((commandLine = parser->GetCommandIfActive("-out")) == 0) return;
0120 
0121   // print histogram statistics
0122   //
0123   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0124 
0125   // save histograms
0126   //
0127   analysisManager->Write();
0128   analysisManager->CloseFile();
0129 
0130   if (fDebug) {
0131     G4cout << "================ ROOT FILES HAVE BEEN WRITTEN" << G4endl;
0132   }
0133 }
0134 
0135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0136 
0137 void RunAction::PrintRunInfo(const G4Run* run)
0138 {
0139   G4cout << "================ Run is = " << run->GetRunID() << G4endl;
0140   G4cout << "================ Run type is = " << G4RunManager::GetRunManager()->GetRunManagerType()
0141          << G4endl;
0142   G4cout << "================ Event processed = " << run->GetNumberOfEventToBeProcessed() << G4endl;
0143   G4cout << "================ Nevent = " << run->GetNumberOfEvent() << G4endl;
0144 }
0145 
0146 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......