Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:25

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