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