Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ParticleHPArbitaryTab.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 G4ParticleHPArbitaryTab_h
31 #define G4ParticleHPArbitaryTab_h 1
32 
33 #include <fstream>
35 
36 #include "globals.hh"
37 #include "G4ios.hh"
38 #include "Randomize.hh"
39 #include "G4ParticleHPVector.hh"
40 #include "G4VParticleHPEDis.hh"
42 
43 // we will need a List of these .... one per term.
44 
46 {
47  public:
49  {
50  theDistFunc = 0;
51  nDistFunc = 0;
52  }
54  {
55  if(theDistFunc!=0) delete [] theDistFunc;
56  }
57 
58  inline void Init(std::istream & theData)
59  {
60  G4int i;
61  theFractionalProb.Init(theData, CLHEP::eV);
62  theData >> nDistFunc; // = number of incoming n energy points
63  theDistFunc = new G4ParticleHPVector [nDistFunc];
64  theManager.Init(theData);
65  G4double currentEnergy;
66  for(i=0; i<nDistFunc; i++)
67  {
68  theData >> currentEnergy;
69  theDistFunc[i].SetLabel(currentEnergy*CLHEP::eV);
70  theDistFunc[i].Init(theData, CLHEP::eV);
71  theDistFunc[i].IntegrateAndNormalise();
72  //************************************************************************
73  //EMendoza:
74  //ThinOut() assumes that the data is linear-linear, what is false:
75  //theDistFunc[i].ThinOut(0.02); // @@@ optimization to be finished.
76  //************************************************************************
77  }
78 
79  //************************************************************************
80  //EMendoza:
81  //Here we calculate the thresholds for the 2D sampling:
82  for(i=0; i<nDistFunc; i++){
83  G4int np=theDistFunc[i].GetVectorLength();
84  theLowThreshold[i]=theDistFunc[i].GetEnergy(0);
85  theHighThreshold[i]=theDistFunc[i].GetEnergy(np-1);
86  for(G4int j=0;j<np-1;j++){
87  if(theDistFunc[i].GetXsec(j+1)>1.e-20){
88  theLowThreshold[i]=theDistFunc[i].GetEnergy(j);
89  break;
90  }
91  }
92  for(G4int j=1;j<np;j++){
93  if(theDistFunc[i].GetXsec(j-1)>1.e-20){
94  theHighThreshold[i]=theDistFunc[i].GetEnergy(j);
95  }
96  }
97  }
98  //************************************************************************
99  }
100 
102  {
103  return theFractionalProb.GetY(anEnergy);
104  }
105 
106  G4double Sample(G4double anEnergy) ;
107 
108  private:
109 
110  G4ParticleHPVector theFractionalProb;
111  G4int nDistFunc;
112  G4InterpolationManager theManager; // knows the interpolation between stores
113  G4ParticleHPVector * theDistFunc; // one per incoming energy
114  G4ParticleHPVector theBuffer;
115  //************************************************************************
116  //EMendoza:
117  G4double theLowThreshold[1000];
118  G4double theHighThreshold[1000];
119  //************************************************************************
120 
121 };
122 
123 #endif
G4double GetEnergy(G4int i) const
void Init(std::istream &theData)
G4double GetFractionalProbability(G4double anEnergy)
G4int GetVectorLength() const
void Init(G4int aScheme, G4int aRange)
int G4int
Definition: G4Types.hh:78
G4double Sample(G4double anEnergy)
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
G4double GetY(G4double x)
static constexpr double eV
double G4double
Definition: G4Types.hh:76
void SetLabel(G4double aLabel)