Back to home page

EIC code displayed by LXR

 
 

    


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

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 optical/OpNovice2/src/RunAction.cc
0027 /// \brief Implementation of the RunAction class
0028 //
0029 //
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 
0033 #include "RunAction.hh"
0034 
0035 #include "HistoManager.hh"
0036 #include "PrimaryGeneratorAction.hh"
0037 #include "Run.hh"
0038 
0039 #include "G4Run.hh"
0040 #include "G4UnitsTable.hh"
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 
0044 RunAction::RunAction(PrimaryGeneratorAction* prim)
0045   : G4UserRunAction(), fRun(nullptr), fHistoManager(nullptr), fPrimary(prim)
0046 {
0047   fHistoManager = new HistoManager();
0048 }
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 RunAction::~RunAction()
0053 {
0054   delete fHistoManager;
0055 }
0056 
0057 G4Run* RunAction::GenerateRun()
0058 {
0059   fRun = new Run();
0060   return fRun;
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 
0065 void RunAction::BeginOfRunAction(const G4Run*)
0066 {
0067   if (fPrimary) {
0068     G4ParticleDefinition* particle = fPrimary->GetParticleGun()->GetParticleDefinition();
0069     G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
0070     G4bool polarized = fPrimary->GetPolarized();
0071     G4double polarization = fPrimary->GetPolarization();
0072     fRun->SetPrimary(particle, energy, polarized, polarization);
0073   }
0074 
0075   // histograms
0076   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0077   if (analysisManager->IsActive()) {
0078     analysisManager->OpenFile();
0079   }
0080 }
0081 
0082 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0083 
0084 void RunAction::EndOfRunAction(const G4Run*)
0085 {
0086   if (isMaster) fRun->EndOfRun();
0087 
0088   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0089 
0090   G4cout << G4endl << " Histogram statistics for the ";
0091   if (isMaster) {
0092     G4cout << "entire run:" << G4endl << G4endl;
0093   }
0094   else {
0095     G4cout << "local thread:" << G4endl << G4endl;
0096   }
0097 
0098   G4int id = analysisManager->GetH1Id("Cerenkov spectrum");
0099   if (analysisManager->GetH1Activation(id)) {
0100     G4cout << " Cerenkov spectrum: mean = " << analysisManager->GetH1(id)->mean()
0101            << " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV." << G4endl;
0102   }
0103   id = analysisManager->GetH1Id("Scintillation spectrum");
0104   if (analysisManager->GetH1Activation(id)) {
0105     G4cout << " Scintillation spectrum: mean = " << analysisManager->GetH1(id)->mean()
0106            << " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV." << G4endl;
0107   }
0108   id = analysisManager->GetH1Id("Scintillation time");
0109   if (analysisManager->GetH1Activation(id)) {
0110     G4cout << " Scintillation time: mean = " << analysisManager->GetH1(id)->mean()
0111            << " ns; rms = " << analysisManager->GetH1(id)->rms() << " ns." << G4endl;
0112   }
0113   id = analysisManager->GetH1Id("WLS abs");
0114   if (analysisManager->GetH1Activation(id)) {
0115     G4cout << " WLS absorption spectrum: mean = " << analysisManager->GetH1(id)->mean()
0116            << " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV." << G4endl;
0117   }
0118   id = analysisManager->GetH1Id("WLS em");
0119   if (analysisManager->GetH1Activation(id)) {
0120     G4cout << " WLS emission spectrum: mean = " << analysisManager->GetH1(id)->mean()
0121            << " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV." << G4endl;
0122   }
0123   id = analysisManager->GetH1Id("WLS time");
0124   if (analysisManager->GetH1Activation(id)) {
0125     G4cout << " WLS emission time: mean = " << analysisManager->GetH1(id)->mean()
0126            << " ns; rms = " << analysisManager->GetH1(id)->rms() << " ns." << G4endl;
0127   }
0128   id = analysisManager->GetH1Id("WLS2 abs");
0129   if (analysisManager->GetH1Activation(id)) {
0130     G4cout << " WLS emission time: mean = " << analysisManager->GetH1(id)->mean()
0131            << " ns; rms = " << analysisManager->GetH1(id)->rms() << " ns." << G4endl;
0132   }
0133   id = analysisManager->GetH1Id("WLS2 em");
0134   if (analysisManager->GetH1Activation(id)) {
0135     G4cout << " WLS2 emission spectrum: mean = " << analysisManager->GetH1(id)->mean()
0136            << " eV; rms = " << analysisManager->GetH1(id)->rms() << " eV." << G4endl;
0137   }
0138   id = analysisManager->GetH1Id("WLS2 time");
0139   if (analysisManager->GetH1Activation(id)) {
0140     G4cout << " WLS2 emission time: mean = " << analysisManager->GetH1(id)->mean()
0141            << " ns; rms = " << analysisManager->GetH1(id)->rms() << " ns." << G4endl;
0142   }
0143   id = analysisManager->GetH1Id("x_backward");
0144   if (analysisManager->GetH1Activation(id)) {
0145     G4cout << " X momentum dir of backward-going photons: mean = "
0146            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0147            << G4endl;
0148   }
0149   id = analysisManager->GetH1Id("y_backward");
0150   if (analysisManager->GetH1Activation(id)) {
0151     G4cout << " Y momentum dir of backward-going photons: mean = "
0152            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0153            << G4endl;
0154   }
0155   id = analysisManager->GetH1Id("z_backward");
0156   if (analysisManager->GetH1Activation(id)) {
0157     G4cout << " Z momentum dir of backward-going photons: mean = "
0158            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0159            << G4endl;
0160   }
0161   id = analysisManager->GetH1Id("x_forward");
0162   if (analysisManager->GetH1Activation(id)) {
0163     G4cout << " X momentum dir of forward-going photons: mean = "
0164            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0165            << G4endl;
0166   }
0167   id = analysisManager->GetH1Id("y_forward");
0168   if (analysisManager->GetH1Activation(id)) {
0169     G4cout << " Y momentum dir of forward-going photons: mean = "
0170            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0171            << G4endl;
0172   }
0173   id = analysisManager->GetH1Id("z_forward");
0174   if (analysisManager->GetH1Activation(id)) {
0175     G4cout << " Z momentum dir of forward-going photons: mean = "
0176            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0177            << G4endl;
0178   }
0179   id = analysisManager->GetH1Id("x_fresnel");
0180   if (analysisManager->GetH1Activation(id)) {
0181     G4cout << " X momentum dir of Fresnel-refracted photons: mean = "
0182            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0183            << G4endl;
0184   }
0185   id = analysisManager->GetH1Id("y_fresnel");
0186   if (analysisManager->GetH1Activation(id)) {
0187     G4cout << " Y momentum dir of Fresnel-refracted photons: mean = "
0188            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0189            << G4endl;
0190   }
0191   id = analysisManager->GetH1Id("z_fresnel");
0192   if (analysisManager->GetH1Activation(id)) {
0193     G4cout << " Z momentum dir of Fresnel-refracted photons: mean = "
0194            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0195            << G4endl;
0196   }
0197   id = analysisManager->GetH1Id("Transmitted");
0198   if (analysisManager->GetH1Activation(id)) {
0199     G4cout << " Angle of transmitted photons: mean = " << analysisManager->GetH1(id)->mean()
0200            << "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
0201   }
0202   id = analysisManager->GetH1Id("Fresnel reflection");
0203   if (analysisManager->GetH1Activation(id)) {
0204     G4cout << " Angle of Fresnel-reflected photons: mean = " << analysisManager->GetH1(id)->mean()
0205            << "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
0206   }
0207   id = analysisManager->GetH1Id("Total internal reflection");
0208   if (analysisManager->GetH1Activation(id)) {
0209     G4cout << " Angle of total internal reflected photons: mean = "
0210            << analysisManager->GetH1(id)->mean() << "; rms = " << analysisManager->GetH1(id)->rms()
0211            << G4endl;
0212   }
0213 
0214   id = analysisManager->GetH1Id("Fresnel refraction");
0215   if (analysisManager->GetH1Activation(id)) {
0216     G4cout << " Angle of Fresnel-refracted photons: mean = " << analysisManager->GetH1(id)->mean()
0217            << "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
0218   }
0219 
0220   id = analysisManager->GetH1Id("Absorption");
0221   if (analysisManager->GetH1Activation(id)) {
0222     G4cout << " Angle of absorbed photons: mean = " << analysisManager->GetH1(id)->mean()
0223            << "; rms = " << analysisManager->GetH1(id)->rms() << G4endl;
0224   }
0225 
0226   G4cout << G4endl;
0227 
0228   if (analysisManager->IsActive()) {
0229     analysisManager->Write();
0230     analysisManager->CloseFile();
0231   }
0232 }
0233 
0234 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......