File indexing completed on 2025-02-23 09:22:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include "OpNoviceRun.hh"
0035
0036 #include "G4ParticleDefinition.hh"
0037 #include "G4Run.hh"
0038 #include "G4UnitsTable.hh"
0039
0040
0041
0042 void OpNoviceRun::SetPrimary(G4ParticleDefinition* particle, G4double energy)
0043 {
0044 fParticle = particle;
0045 fEnergy = energy;
0046 }
0047
0048
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
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 }