Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:49:53

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 GB03RunAction.cc
0027 /// \brief Implementation of the GB03RunAction class
0028 
0029 #include "GB03RunAction.hh"
0030 
0031 #include "GB03DetectorConstruction.hh"
0032 #include "GB03Run.hh"
0033 
0034 #include "G4AnalysisManager.hh"
0035 #include "G4Box.hh"
0036 #include "G4RunManager.hh"
0037 #include "G4SolidStore.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4UnitsTable.hh"
0040 #include "globals.hh"
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 G4Run* GB03RunAction::GenerateRun()
0045 {
0046   // Generate new RUN object
0047   return new GB03Run();
0048 }
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 GB03RunAction::GB03RunAction()
0052 {
0053   // Create analysis manager
0054   auto analysisManager = G4AnalysisManager::Instance();
0055   analysisManager->SetDefaultFileType("root");
0056   analysisManager->SetFileName("GB03");
0057 
0058   //
0059   // Book histograms
0060   //
0061 
0062   analysisManager->CreateH1("En", "E kin neutron", 100, 0., 100.0 * MeV);
0063   analysisManager->CreateH1("Eg", "E kin gamma", 100, 0., 15.0 * MeV);
0064   analysisManager->CreateH1("Nnhit", "The number of neutrons along x", 100, -1.5 * m, 150 * m / cm);
0065   analysisManager->CreateH1("Nghit", "The number of gammas along x", 100, -1.5 * m / cm,
0066                             1.5 * m / cm);
0067 }
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0070 
0071 void GB03RunAction::BeginOfRunAction(const G4Run* /*run*/)
0072 {
0073   auto rm = G4RunManager::GetRunManager();
0074   auto det = static_cast<const GB03DetectorConstruction*>(rm->GetUserDetectorConstruction());
0075   fVerbose = det->GetVerboseLevel();
0076 
0077   auto* smeas = static_cast<G4Box*>(G4SolidStore::GetInstance()->GetSolid("Hodo"));
0078 
0079   auto halfX = smeas->GetXHalfLength() / cm;
0080 
0081   // Get analysis manager
0082   auto analysisManager = G4AnalysisManager::Instance();
0083 
0084   // set histo binning
0085   analysisManager->SetH1(2, 100, -halfX, halfX);
0086   analysisManager->SetH1(3, 100, -halfX, halfX);
0087 
0088   // Open an output file
0089 
0090   analysisManager->OpenFile();
0091 }
0092 
0093 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0094 
0095 void GB03RunAction::EndOfRunAction(const G4Run* brun)
0096 {
0097   auto run = static_cast<const GB03Run*>(brun);
0098   if (isMaster) {
0099     if (fVerbose > 0) {
0100       G4cout << "for the entire run " << run->GetNumberOfEvent() << G4endl << G4endl;
0101       run->GetPartCounter()->Print();
0102     }
0103   }
0104   else {
0105     if (fVerbose > 2) {
0106       G4cout << "for the local thread " << G4endl << G4endl;
0107       run->GetPartCounter()->Print();
0108     }
0109   }
0110 
0111   // Save Histograms
0112   auto analysisManager = G4AnalysisManager::Instance();
0113   analysisManager->Write();
0114   analysisManager->CloseFile();
0115 }
0116 
0117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......