Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4LEPTSElossDistr Class Reference

#include <G4LEPTSElossDistr.hh>

Public Member Functions

 G4LEPTSElossDistr (std::string)
 
void ReadFile ()
 
G4double Sample (G4double, G4double)
 
G4bool IsFileFound () const
 

Detailed Description

Definition at line 42 of file G4LEPTSElossDistr.hh.

Constructor & Destructor Documentation

G4LEPTSElossDistr::G4LEPTSElossDistr ( std::string  file)

Definition at line 30 of file G4LEPTSElossDistr.cc.

30  {
31  fileName = file;
32 
33  ReadFile();
34 }

Here is the call graph for this function:

Member Function Documentation

G4bool G4LEPTSElossDistr::IsFileFound ( ) const
inline

Definition at line 50 of file G4LEPTSElossDistr.hh.

50  {
51  return bFileFound;
52  }
void G4LEPTSElossDistr::ReadFile ( )

Definition at line 37 of file G4LEPTSElossDistr.cc.

38 {
39  theNDistributions = 0;
40 
41  FILE * fp;
42 
43  if ((fp=fopen(fileName.c_str(), "r"))==NULL){
44  //G4cout << "Error reading " << fileName << G4endl;
45  NoBins = 0;
46  bFileFound = false;
47  return;
48  }
49 
50  bFileFound = true;
51  // G4cout << "Read Eloss Distro (" << fileName << ") " << G4endl;
52  G4int nEnergies;
53  G4int nAngles;
54  G4int nData;
55  fscanf(fp,"%i \n",&nEnergies);
56  for( G4int ie = 0; ie < nEnergies; ie++ ){
57  float energySep;
58  fscanf(fp,"%f \n",&energySep);
59  fscanf(fp,"%i \n",&nAngles);
60  for( G4int ia = 0; ia < nAngles; ia++ ){
61  float angleSep;
62  fscanf(fp,"%f \n",&angleSep);
64  theNDistributions ++;
65  mddist angleDist;
66  angleDist[angleSep] = dist;
67  theDistributions[energySep] = angleDist;
68 
69  fscanf(fp,"%i \n",&nData);
70  if( dist->ReadFile( fp, nData ) ) {
71  G4Exception("G4LEPTSElossDistr",
72  "",
74  ("End of file found while reading file"+ fileName).c_str());
75  }
76  }
77  }
78 
79  fclose(fp);
80 
81 }
std::map< G4double, G4LEPTSDistribution * > mddist
int G4int
Definition: G4Types.hh:78
void ReadFile(G4String fileName)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4LEPTSElossDistr::Sample ( G4double  eMin,
G4double  eMax 
)

Definition at line 85 of file G4LEPTSElossDistr.cc.

86 {
87 // Sample Energy from Cumulative distr. G4interval [eMin, eMax]
88 
89  if( eMin > eMax) return 0.0;
90 
91  //Get the distribution to do the sampling
92  G4LEPTSDistribution* distr = 0;
93  if( theNDistributions == 1 ){
94  distr = (*( (*(theDistributions.begin())).second ).begin()).second;
95  } else{
96  mdmddist::const_iterator itedd;
97  for( itedd = theDistributions.begin(); itedd != theDistributions.end(); itedd++ ){
98  G4double energySep = (*itedd).first;
99  if( eMax < energySep ) {
100  //tt if( eMax <= energySep ) {
101  mddist dist1 = (*itedd).second;
102  mddist::const_iterator ited;
103  for( ited = dist1.begin(); ited != dist1.end(); ited++ ){
104  G4double angleSep = (*ited).first;
105  if( 1 < angleSep ) {
106  distr = (*ited).second;
107  break;
108  }
109  }
110  break;
111  }
112  }
113  }
114 
115  // G4cout << " LEPTSElossDistr::Sample( " << distr << " NDIST " << theNDistributions << G4endl; //GDEB
116  return distr->Sample(eMin, eMax);
117 }
std::map< G4double, G4LEPTSDistribution * > mddist
static constexpr double second
Definition: G4SIunits.hh:157
G4double Sample(G4double, G4double)
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:


The documentation for this class was generated from the following files: