Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 /// \file Par02Smearer.cc 28 /// \brief Implementation of the Par02Smearer 29 30 #include "Par02Smearer.hh" 31 32 #include "Par02PrimaryParticleInformation.hh" 33 34 #include "G4FieldManager.hh" 35 #include "G4PrimaryParticle.hh" 36 #include "G4SystemOfUnits.hh" 37 #include "G4TransportationManager.hh" 38 #include "G4UniformMagField.hh" 39 #include "G4UnitsTable.hh" 40 41 #include <ctime> 42 43 //....oooOO0OOooo........oooOO0OOooo........oo 44 45 Par02Smearer* Par02Smearer::fPar02Smearer = nu 46 47 //....oooOO0OOooo........oooOO0OOooo........oo 48 49 Par02Smearer::Par02Smearer() 50 { 51 time_t seed = time(NULL); 52 fRandomEngine = new CLHEP::HepJamesRandom(st 53 fRandomGauss = new CLHEP::RandGauss(fRandomE 54 } 55 56 //....oooOO0OOooo........oooOO0OOooo........oo 57 58 Par02Smearer::~Par02Smearer() = default; 59 60 //....oooOO0OOooo........oooOO0OOooo........oo 61 62 Par02Smearer* Par02Smearer::Instance() 63 { 64 if (!fPar02Smearer) { 65 fPar02Smearer = new Par02Smearer(); 66 } 67 return fPar02Smearer; 68 } 69 70 //....oooOO0OOooo........oooOO0OOooo........oo 71 72 G4ThreeVector Par02Smearer::SmearMomentum(cons 73 { 74 return SmearGaussian(aTrackOriginal, aResolu 75 } 76 77 //....oooOO0OOooo........oooOO0OOooo........oo 78 79 G4double Par02Smearer::SmearEnergy(const G4Tra 80 { 81 G4double newE = -1.0; 82 while (newE < 0.0) { // To ensure that the 83 // (vital for energy s 84 // for momentum smeari 85 if (aResolution != -1.0) { 86 newE = aTrackOriginal->GetKineticEnergy( 87 } 88 else { 89 newE = aTrackOriginal->GetKineticEnergy( 90 } 91 } 92 return newE; 93 } 94 95 //....oooOO0OOooo........oooOO0OOooo........oo 96 97 G4ThreeVector Par02Smearer::SmearGaussian(cons 98 { 99 G4ThreeVector originP = aTrackOriginal->GetM 100 G4ThreeVector originPos = aTrackOriginal->Ge 101 G4double rdm = Gauss(1.0, aResolution); 102 G4ThreeVector smearedMom(originP.x() * rdm, 103 return smearedMom; 104 } 105 106 //....oooOO0OOooo........oooOO0OOooo........oo 107 108 G4double Par02Smearer::Gauss(G4double aMean, G 109 { 110 return fRandomGauss->fire(aMean, aStandardDe 111 } 112 113 //....oooOO0OOooo........oooOO0OOooo........oo 114