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