Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:08:33

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 #include "Randomize.hh"
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 RunAction::RunAction()
0054 {
0055   TestParameters::GetPointer();
0056   fAnalysisManager = G4AnalysisManager::Instance();
0057   fAnalysisManager->SetDefaultFileType("root");
0058   fAnalysisManager->SetFileName("testem8");
0059   fAnalysisManager->SetVerboseLevel(1);
0060   fAnalysisManager->SetActivation(true);
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 void RunAction::Book()
0066 {
0067   // Always creating analysis manager
0068   TestParameters* param = TestParameters::GetPointer();
0069   G4int nBinsE = param->GetNumberBins();
0070   G4int nBinsCluster = param->GetNumberBinsCluster();
0071   G4int nMaxCluster = param->GetMaxCluster();
0072   G4double maxEnergy = param->GetMaxEnergy();
0073   G4double factorALICE = param->GetFactorALICE();
0074 
0075   // G4cout << "### maxenergy(keV)= " << maxEnergy/keV
0076   //         << "  factorALICE= " <<  factorALICE << G4endl;
0077 
0078   // Creating an 1-dimensional histograms in the root directory of the tree
0079   fAnalysisManager->SetFirstHistoId(1);
0080   fAnalysisManager->CreateH1("h1", "Energy deposition in detector (keV)", nBinsE, 0.0,
0081                              maxEnergy / keV);
0082   fAnalysisManager->CreateH1("h2", "Number of primary clusters", nBinsCluster, 0.0,
0083                              G4double(nMaxCluster));
0084   fAnalysisManager->CreateH1("h3", "Energy deposition in detector (ADC)", nBinsE, 0.0,
0085                              maxEnergy * factorALICE);
0086   fAnalysisManager->OpenFile();
0087 }
0088 
0089 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0090 
0091 G4Run* RunAction::GenerateRun()
0092 {
0093   fRun = new Run();
0094   return fRun;
0095 }
0096 
0097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0098 
0099 void RunAction::BeginOfRunAction(const G4Run* aRun)
0100 {
0101   G4int id = aRun->GetRunID();
0102   G4cout << "### Run " << id << " start analysis activation; rand= " << G4UniformRand() << G4endl;
0103 
0104   fRun->BeginOfRun();
0105 
0106   // histograms
0107   Book();
0108 }
0109 
0110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0111 
0112 void RunAction::EndOfRunAction(const G4Run*)
0113 {
0114   // print Run summary
0115   G4cout << "RunAction: End of run actions are started " << isMaster
0116          << "  Nevt=  " << fRun->GetNumberOfEvent() << "  Edep= " << fRun->GetStat()->mean()
0117          << G4endl;
0118   if (isMaster) {
0119     fRun->EndOfRun();
0120   }
0121   // save histos and close analysis
0122   if (fAnalysisManager->IsActive()) {
0123     fAnalysisManager->Write();
0124     fAnalysisManager->CloseFile();
0125     fAnalysisManager->Clear();
0126   }
0127 }
0128 
0129 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......