Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-13 08:26:58

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 //
0027 /// \file RunAction.cc
0028 /// \brief Implementation of the RunAction class
0029 
0030 #include "RunAction.hh"
0031 #include "G4AnalysisManager.hh"
0032 
0033 #include "G4RunManager.hh"
0034 #include "G4Run.hh"
0035 #include <CLHEP/Units/SystemOfUnits.h>
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 RunAction::RunAction()
0040     : G4UserRunAction()
0041 {
0042     //using analysis manager for output
0043     auto analysisManager = G4AnalysisManager::Instance();
0044 
0045     //setting our histogram
0046     //a true range and bin number is set up in BeginOfRunAction
0047     analysisManager->CreateH1("Spectrum_electrons","Spectrum_e-",20,0,100);
0048     analysisManager->CreateH1("Spectrum_positrons","Spectrum_e+",20,0,100);
0049     analysisManager->CreateH1("Spectrum_gamma","Spectrum_gamma",25,0,125);
0050 }
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 RunAction::~RunAction()
0055 {}
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 void RunAction::BeginOfRunAction(const G4Run*)
0060 {
0061     //opening output file
0062     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0063     G4String fileName = "results.root";
0064     analysisManager->OpenFile(fileName);
0065 
0066     //setting histograms
0067     analysisManager->SetH1(0,20,0,100);
0068     analysisManager->SetH1XAxisTitle(0,"E_e- [GeV]");
0069     analysisManager->SetH1YAxisTitle(0,"Count");
0070 
0071     analysisManager->SetH1(1,20,0,100);
0072     analysisManager->SetH1XAxisTitle(1,"E_e+ [GeV]");
0073     analysisManager->SetH1YAxisTitle(1,"Count");
0074 
0075     analysisManager->SetH1(2,25,0,125);
0076     analysisManager->SetH1XAxisTitle(2,"E_gamma [GeV]");
0077     analysisManager->SetH1YAxisTitle(2,"Count");
0078 }
0079 
0080 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0081 
0082 void RunAction::EndOfRunAction(const G4Run*)
0083 {
0084     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0085     analysisManager->Write();
0086     analysisManager->CloseFile();
0087 }
0088 
0089 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......