Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 /// \file OpNovice/src/OpNoviceRun.cc 27 /// \brief Implementation of the OpNoviceRun class 28 // 29 // 30 // 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 34 #include "OpNoviceRun.hh" 35 36 #include "G4ParticleDefinition.hh" 37 #include "G4Run.hh" 38 #include "G4UnitsTable.hh" 39 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 41 42 void OpNoviceRun::SetPrimary(G4ParticleDefinition* particle, G4double energy) 43 { 44 fParticle = particle; 45 fEnergy = energy; 46 } 47 48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 49 50 void OpNoviceRun::Merge(const G4Run* run) 51 { 52 const auto localRun = static_cast<const OpNoviceRun*>(run); 53 54 fParticle = localRun->fParticle; 55 fEnergy = localRun->fEnergy; 56 57 fCerenkovCounter += localRun->fCerenkovCounter; 58 fCerenkov2 += localRun->fCerenkov2; 59 fScintillationCounter += localRun->fScintillationCounter; 60 fScintillation2 += localRun->fScintillation2; 61 62 fRayleighCounter += localRun->fRayleighCounter; 63 fRayleigh2 += localRun->fRayleigh2; 64 fAbsorptionCounter += localRun->fAbsorptionCounter; 65 fAbsorption2 += localRun->fAbsorption2; 66 fMieCounter += localRun->fMieCounter; 67 fMie2 += localRun->fMie2; 68 fBoundaryCounter += localRun->fBoundaryCounter; 69 fBoundary2 += localRun->fBoundary2; 70 71 G4Run::Merge(run); 72 } 73 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 75 void OpNoviceRun::EndOfRun() 76 { 77 if (numberOfEvent == 0) return; 78 auto TotNbofEvents = G4double(numberOfEvent); 79 80 fCerenkovCounter /= TotNbofEvents; 81 fCerenkov2 /= TotNbofEvents; 82 G4double rmsCerenkov = fCerenkov2 - fCerenkovCounter * fCerenkovCounter; 83 if (rmsCerenkov > 0.) 84 rmsCerenkov = std::sqrt(rmsCerenkov); 85 else 86 rmsCerenkov = 0.; 87 88 fScintillationCounter /= TotNbofEvents; 89 fScintillation2 /= TotNbofEvents; 90 G4double rmsScint = fScintillation2 - fScintillationCounter * fScintillationCounter; 91 if (rmsScint > 0.) 92 rmsScint = std::sqrt(rmsScint); 93 else 94 rmsScint = 0.; 95 96 fRayleighCounter /= TotNbofEvents; 97 fRayleigh2 /= TotNbofEvents; 98 G4double rmsRayleigh = fRayleigh2 - fRayleighCounter * fRayleighCounter; 99 if (rmsRayleigh > 0.) 100 rmsRayleigh = std::sqrt(rmsRayleigh); 101 else 102 rmsRayleigh = 0.; 103 104 fAbsorptionCounter /= TotNbofEvents; 105 fAbsorption2 /= TotNbofEvents; 106 G4double rmsAbsorption = fAbsorption2 - fAbsorptionCounter * fAbsorptionCounter; 107 if (rmsAbsorption > 0.) 108 rmsAbsorption = std::sqrt(rmsAbsorption); 109 else 110 rmsAbsorption = 0.; 111 112 fMieCounter /= TotNbofEvents; 113 fMie2 /= TotNbofEvents; 114 G4double rmsMie = fMie2 - fMieCounter * fMieCounter; 115 if (rmsMie > 0.) 116 rmsMie = std::sqrt(rmsMie); 117 else 118 rmsMie = 0.; 119 120 fBoundaryCounter /= TotNbofEvents; 121 fBoundary2 /= TotNbofEvents; 122 G4double rmsBoundary = fBoundary2 - fBoundaryCounter * fBoundaryCounter; 123 if (rmsBoundary > 0.) 124 rmsBoundary = std::sqrt(rmsBoundary); 125 else 126 rmsBoundary = 0.; 127 128 G4int prec = G4cout.precision(3); 129 G4cout << "\n ======================== run summary ======================\n"; 130 131 G4cout << "Primary particle was: " << fParticle->GetParticleName() << " with energy " 132 << G4BestUnit(fEnergy, "Energy") << "." << G4endl; 133 G4cout << "Number of events: " << numberOfEvent << G4endl; 134 135 G4cout << "Average number of Cerenkov photons created per event: " << fCerenkovCounter << " +- " 136 << rmsCerenkov << G4endl; 137 G4cout << "Average number of scintillation photons created per event: " << fScintillationCounter 138 << " +- " << rmsScint << G4endl; 139 140 G4cout << "Average number of optical Rayleigh interactions per event: " << fRayleighCounter 141 << " +- " << rmsRayleigh << G4endl; 142 G4cout << "Average number of optical absorption interactions per event: " << fAbsorptionCounter 143 << " +- " << rmsAbsorption << G4endl; 144 G4cout << "Average number of optical Mie interactions per event: " << fMieCounter << " +- " 145 << rmsMie << G4endl; 146 G4cout << "Average number of optical boundary interactions per event: " << fBoundaryCounter 147 << " +- " << rmsBoundary << G4endl; 148 149 G4cout << G4endl; 150 G4cout.precision(prec); 151 } 152