Geant4  10.02
G4ParticleHPAngularP.hh
Go to the documentation of this file.
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 //
27 //
28 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
29 //
30 #ifndef G4ParticleHPAngularP_h
31 #define G4ParticleHPAngularP_h 1
32 
33 #include <CLHEP/Units/SystemOfUnits.h>
34 
35 #include "globals.hh"
37 
39 {
40  public:
41 
43  {
44  theCosTh = 0;
45  theProb = 0;
46  }
48  {
49  if(theCosTh!=0) delete [] theCosTh;
50  if(theProb!=0) delete [] theProb;
51  }
52 
53  inline void Init(std::istream & aDataFile)
54  {
55  G4double eNeu, cosTheta, probDist;
56  G4int nProb;
57  aDataFile >> eNeu >> nProb;
58  theManager.Init(aDataFile);
59  eNeu *= CLHEP::eV;
60  Init(eNeu, nProb);
61  for (G4int iii=0; iii<nProb; iii++)
62  {
63  aDataFile >> cosTheta >> probDist;
64  SetCosTh(iii, cosTheta);
65  SetProb(iii,probDist);
66  }
67  }
68 
69  inline void Init(G4double e, G4int n)
70  {
71  theCosTh = new G4double[n];
72  theProb = new G4double[n];
73  theEnergy = e;
74  nCoeff = n;
75  }
76 
78  inline void SetCosTh(G4int l, G4double coeff) {theCosTh[l]=coeff;}
79  inline void SetProb(G4int l, G4double coeff) {theProb[l]=coeff;}
80 
81  inline G4double GetCosTh(G4int l) {return theCosTh[l];}
82  inline G4double GetProb(G4int l) {return theProb[l];}
83  inline G4double GetEnergy(){return theEnergy;}
84  inline G4int GetNumberOfPoints(){ return nCoeff; }
85  inline G4double GetCosTh()
86  {
87  G4int i;
88  G4double rand = G4UniformRand();
89  G4double run=0, runo=0;
90  for (i=0; i<GetNumberOfPoints(); i++)
91  {
92  runo=run;
93  run += GetProb(i);
94  if(run>rand) break;
95  }
96  if(i == GetNumberOfPoints()) i--;
98  runo, run, GetCosTh(i-1), GetCosTh(i));
99  return costh;
100  }
101 
102  private:
103 
104  G4double theEnergy; // neutron energy
105  G4ParticleHPInterpolator theInt; // knows tointerpolate
107  G4InterpolationManager theManager; // knows the interpolation between stores
109  G4double * theProb; // probability distribution as fcn of theta
110  // integral normalised to 1.
111 };
112 #endif
void Init(std::istream &aDataFile)
void Init(G4int aScheme, G4int aRange)
void SetEnergy(G4double energy)
G4InterpolationManager theManager
G4ParticleHPInterpolator theInt
G4double GetCosTh(G4int l)
int G4int
Definition: G4Types.hh:78
void Init(G4double e, G4int n)
#define G4UniformRand()
Definition: Randomize.hh:97
G4InterpolationScheme GetScheme(G4int index) const
const G4int n
void SetCosTh(G4int l, G4double coeff)
G4double Interpolate(G4InterpolationScheme aScheme, G4double x, G4double x1, G4double x2, G4double y1, G4double y2) const
static const double eV
Definition: G4SIunits.hh:212
G4double energy(const ThreeVector &p, const G4double m)
double G4double
Definition: G4Types.hh:76
G4double GetProb(G4int l)
void SetProb(G4int l, G4double coeff)