Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:04

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