Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 08:31:44

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 //---------------------------------------------------------------------------
0030 //
0031 // ClassName:   RunAction
0032 //
0033 // Author:      V.Ivanchenko 01.09.2010
0034 //
0035 //----------------------------------------------------------------------------
0036 //
0037 
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 
0041 #include "RunAction.hh"
0042 
0043 #include "Run.hh"
0044 #include "TestParameters.hh"
0045 
0046 #include "G4Run.hh"
0047 #include "G4RunManager.hh"
0048 #include "G4SystemOfUnits.hh"
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 RunAction::RunAction() : G4UserRunAction(), fAnalysisManager(nullptr), fRun(nullptr)
0053 {
0054   TestParameters::GetPointer();
0055   fAnalysisManager = G4AnalysisManager::Instance();
0056   fAnalysisManager->SetFileName("dmp.root");
0057   fAnalysisManager->SetVerboseLevel(1);
0058   fAnalysisManager->SetActivation(true);
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 RunAction::~RunAction() {}
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 
0067 void RunAction::Book()
0068 {
0069   // Always creating analysis manager
0070   TestParameters* param = TestParameters::GetPointer();
0071   G4int nBinsE = param->GetNumberBins();
0072   G4double maxEnergy = param->GetMaxEnergy();
0073 
0074   // Creating an 1-dimensional histograms in the root directory of the tree
0075   fAnalysisManager->SetFirstHistoId(1);
0076   fAnalysisManager->CreateH1("h1", "Energy deposition in detector (GeV)", nBinsE, 0.0,
0077                              maxEnergy / GeV);
0078   fAnalysisManager->OpenFile();
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 
0083 G4Run* RunAction::GenerateRun()
0084 {
0085   fRun = new Run();
0086   return fRun;
0087 }
0088 
0089 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0090 
0091 void RunAction::BeginOfRunAction(const G4Run* aRun)
0092 {
0093   G4int id = aRun->GetRunID();
0094   G4cout << "### Run " << id << " start analysis activation: " << G4endl;
0095 
0096   fRun->BeginOfRun();
0097 
0098   // histograms
0099   Book();
0100 }
0101 
0102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0103 
0104 void RunAction::EndOfRunAction(const G4Run*)
0105 {
0106   // print Run summary
0107   G4cout << "RunAction: End of run actions are started " << isMaster
0108          << "  Nevt=  " << fRun->GetNumberOfEvent() << "  Edep= " << fRun->GetStat()->mean()
0109          << G4endl;
0110   if (isMaster) {
0111     fRun->EndOfRun();
0112   }
0113   // save histos and close analysis
0114   if (fAnalysisManager->IsActive()) {
0115     fAnalysisManager->Write();
0116     fAnalysisManager->CloseFile();
0117     fAnalysisManager->Clear();
0118   }
0119 }
0120 
0121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......