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 // P. Arce, June-2014 Conversion neutron_hp to 28 // 29 #ifndef G4ParticleHPSimpleEvapSpectrum_h 30 #define G4ParticleHPSimpleEvapSpectrum_h 1 31 32 #include "G4Exp.hh" 33 #include "G4Log.hh" 34 #include "G4ParticleHPVector.hh" 35 #include "G4VParticleHPEDis.hh" 36 #include "G4ios.hh" 37 #include "Randomize.hh" 38 #include "globals.hh" 39 40 #include <CLHEP/Units/SystemOfUnits.h> 41 42 #include <fstream> 43 44 // we will need a List of these .... one per t 45 46 class G4ParticleHPSimpleEvapSpectrum : public 47 { 48 public: 49 G4ParticleHPSimpleEvapSpectrum() { expm1 = 50 ~G4ParticleHPSimpleEvapSpectrum() override 51 52 inline void Init(std::istream& aDataFile) 53 { 54 theFractionalProb.Init(aDataFile, CLHEP: 55 theThetaDist.Init(aDataFile, CLHEP::eV); 56 } 57 58 inline G4double GetFractionalProbability(G 59 { 60 return theFractionalProb.GetY(anEnergy); 61 } 62 63 inline G4double Sample(G4double anEnergy) 64 { 65 G4double theta = theThetaDist.GetY(anEne 66 G4double random, cut, max, result = 0.; 67 max = 10. * theta; 68 G4int icounter = 0; 69 G4int icounter_max = 1024; 70 do { 71 icounter++; 72 if (icounter > icounter_max) { 73 G4cout << "Loop-counter exceeded the 74 << __FILE__ << "." << G4endl; 75 break; 76 } 77 random = G4UniformRand(); 78 result = -theta * G4Log(random); 79 cut = G4UniformRand(); 80 } while (cut > result / max); // Loop c 81 return result; 82 } 83 84 private: 85 inline G4double Evapo(G4double anEnergy, G 86 { 87 G4double result = (anEnergy * CLHEP::eV) 88 return result; 89 } 90 91 private: 92 G4double expm1; 93 94 G4ParticleHPVector theFractionalProb; 95 96 G4ParticleHPVector theThetaDist; 97 }; 98 99 #endif 100