Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:12

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