Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 08:30:10

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 WLSRunAction.cc
0027 /// \brief Implementation of the WLSRunAction class
0028 
0029 #include "WLSRunAction.hh"
0030 
0031 #include "WLSDetectorConstruction.hh"
0032 #include "WLSRun.hh"
0033 #include "WLSSteppingAction.hh"
0034 
0035 #include "G4AnalysisManager.hh"
0036 #include "G4Run.hh"
0037 #include "G4RunManager.hh"
0038 #include "Randomize.hh"
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 WLSRunAction::WLSRunAction()
0043 {
0044   auto analysisManager = G4AnalysisManager::Instance();
0045 
0046   analysisManager->SetDefaultFileType("root");
0047   analysisManager->SetVerboseLevel(1);
0048   G4cout << "Using " << analysisManager->GetType() << G4endl;
0049 
0050   analysisManager->CreateH1("Energy", "Energy of optical photon", 100, 2. * CLHEP::eV,
0051                             3.2 * CLHEP::eV);
0052   analysisManager->CreateH1("Time", "Arrival time", 100, 0., 100. * CLHEP::ns);
0053   analysisManager->CreateH1("Number of photons", "Number of photons", 100, 0., 100.);
0054 }
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 G4Run* WLSRunAction::GenerateRun()
0059 {
0060   fRun = new WLSRun();
0061   return fRun;
0062 }
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0065 
0066 void WLSRunAction::BeginOfRunAction(const G4Run*)
0067 {
0068   G4AnalysisManager::Instance()->OpenFile("wls");
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 void WLSRunAction::EndOfRunAction(const G4Run*)
0074 {
0075   auto analysisManager = G4AnalysisManager::Instance();
0076   if (analysisManager->GetH1(0)) {
0077     G4cout << G4endl << " ----> print histograms statistics ";
0078     if (isMaster) {
0079       G4cout << "for the entire run " << G4endl << G4endl;
0080     }
0081     else {
0082       G4cout << "for the local thread " << G4endl << G4endl;
0083     }
0084 
0085     G4cout << " Mean number of photons detected/event: " << analysisManager->GetH1(2)->mean()
0086            << " rms = " << analysisManager->GetH1(2)->rms() << G4endl;
0087   }
0088 
0089   analysisManager->Write();
0090   analysisManager->CloseFile();
0091 
0092   if (isMaster) fRun->EndOfRun();
0093 }