Back to home page

EIC code displayed by LXR

 
 

    


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

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 OpNovice/src/OpNoviceRun.cc
0027 /// \brief Implementation of the OpNoviceRun class
0028 //
0029 //
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #include "OpNoviceRun.hh"
0035 
0036 #include "G4ParticleDefinition.hh"
0037 #include "G4Run.hh"
0038 #include "G4UnitsTable.hh"
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 void OpNoviceRun::SetPrimary(G4ParticleDefinition* particle, G4double energy)
0043 {
0044   fParticle = particle;
0045   fEnergy = energy;
0046 }
0047 
0048 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0049 
0050 void OpNoviceRun::Merge(const G4Run* run)
0051 {
0052   const auto localRun = static_cast<const OpNoviceRun*>(run);
0053 
0054   fParticle = localRun->fParticle;
0055   fEnergy = localRun->fEnergy;
0056 
0057   fCerenkovCounter += localRun->fCerenkovCounter;
0058   fCerenkov2 += localRun->fCerenkov2;
0059   fScintillationCounter += localRun->fScintillationCounter;
0060   fScintillation2 += localRun->fScintillation2;
0061 
0062   fRayleighCounter += localRun->fRayleighCounter;
0063   fRayleigh2 += localRun->fRayleigh2;
0064   fAbsorptionCounter += localRun->fAbsorptionCounter;
0065   fAbsorption2 += localRun->fAbsorption2;
0066   fMieCounter += localRun->fMieCounter;
0067   fMie2 += localRun->fMie2;
0068   fBoundaryCounter += localRun->fBoundaryCounter;
0069   fBoundary2 += localRun->fBoundary2;
0070 
0071   G4Run::Merge(run);
0072 }
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0075 void OpNoviceRun::EndOfRun()
0076 {
0077   if (numberOfEvent == 0) return;
0078   auto TotNbofEvents = G4double(numberOfEvent);
0079 
0080   fCerenkovCounter /= TotNbofEvents;
0081   fCerenkov2 /= TotNbofEvents;
0082   G4double rmsCerenkov = fCerenkov2 - fCerenkovCounter * fCerenkovCounter;
0083   if (rmsCerenkov > 0.)
0084     rmsCerenkov = std::sqrt(rmsCerenkov);
0085   else
0086     rmsCerenkov = 0.;
0087 
0088   fScintillationCounter /= TotNbofEvents;
0089   fScintillation2 /= TotNbofEvents;
0090   G4double rmsScint = fScintillation2 - fScintillationCounter * fScintillationCounter;
0091   if (rmsScint > 0.)
0092     rmsScint = std::sqrt(rmsScint);
0093   else
0094     rmsScint = 0.;
0095 
0096   fRayleighCounter /= TotNbofEvents;
0097   fRayleigh2 /= TotNbofEvents;
0098   G4double rmsRayleigh = fRayleigh2 - fRayleighCounter * fRayleighCounter;
0099   if (rmsRayleigh > 0.)
0100     rmsRayleigh = std::sqrt(rmsRayleigh);
0101   else
0102     rmsRayleigh = 0.;
0103 
0104   fAbsorptionCounter /= TotNbofEvents;
0105   fAbsorption2 /= TotNbofEvents;
0106   G4double rmsAbsorption = fAbsorption2 - fAbsorptionCounter * fAbsorptionCounter;
0107   if (rmsAbsorption > 0.)
0108     rmsAbsorption = std::sqrt(rmsAbsorption);
0109   else
0110     rmsAbsorption = 0.;
0111 
0112   fMieCounter /= TotNbofEvents;
0113   fMie2 /= TotNbofEvents;
0114   G4double rmsMie = fMie2 - fMieCounter * fMieCounter;
0115   if (rmsMie > 0.)
0116     rmsMie = std::sqrt(rmsMie);
0117   else
0118     rmsMie = 0.;
0119 
0120   fBoundaryCounter /= TotNbofEvents;
0121   fBoundary2 /= TotNbofEvents;
0122   G4double rmsBoundary = fBoundary2 - fBoundaryCounter * fBoundaryCounter;
0123   if (rmsBoundary > 0.)
0124     rmsBoundary = std::sqrt(rmsBoundary);
0125   else
0126     rmsBoundary = 0.;
0127 
0128   G4int prec = G4cout.precision(3);
0129   G4cout << "\n ======================== run summary ======================\n";
0130 
0131   G4cout << "Primary particle was: " << fParticle->GetParticleName() << " with energy "
0132          << G4BestUnit(fEnergy, "Energy") << "." << G4endl;
0133   G4cout << "Number of events: " << numberOfEvent << G4endl;
0134 
0135   G4cout << "Average number of Cerenkov photons created per event: " << fCerenkovCounter << " +- "
0136          << rmsCerenkov << G4endl;
0137   G4cout << "Average number of scintillation photons created per event: " << fScintillationCounter
0138          << " +- " << rmsScint << G4endl;
0139 
0140   G4cout << "Average number of optical Rayleigh interactions per event: " << fRayleighCounter
0141          << " +- " << rmsRayleigh << G4endl;
0142   G4cout << "Average number of optical absorption interactions per event: " << fAbsorptionCounter
0143          << " +- " << rmsAbsorption << G4endl;
0144   G4cout << "Average number of optical Mie interactions per event: " << fMieCounter << " +- "
0145          << rmsMie << G4endl;
0146   G4cout << "Average number of optical boundary interactions per event: " << fBoundaryCounter
0147          << " +- " << rmsBoundary << G4endl;
0148 
0149   G4cout << G4endl;
0150   G4cout.precision(prec);
0151 }