Geant4-11
Public Member Functions | Private Attributes
G4LEPTSElossDistr Class Reference

#include <G4LEPTSElossDistr.hh>

Public Member Functions

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

Private Attributes

G4bool bFileFound
 
std::string fileName
 
int NoBins
 
mdmddist theDistributions
 
G4int theNDistributions
 

Detailed Description

Definition at line 42 of file G4LEPTSElossDistr.hh.

Constructor & Destructor Documentation

◆ G4LEPTSElossDistr()

G4LEPTSElossDistr::G4LEPTSElossDistr ( std::string  file)

Member Function Documentation

◆ IsFileFound()

G4bool G4LEPTSElossDistr::IsFileFound ( ) const
inline

Definition at line 50 of file G4LEPTSElossDistr.hh.

50 {
51 return bFileFound;
52 }

References bFileFound.

◆ ReadFile()

void G4LEPTSElossDistr::ReadFile ( )

Definition at line 37 of file G4LEPTSElossDistr.cc.

38{
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 (void) fscanf(fp,"%i \n",&nEnergies);
56 for( G4int ie = 0; ie < nEnergies; ie++ ){
57 float energySep;
58 (void) fscanf(fp,"%f \n",&energySep);
59 (void) fscanf(fp,"%i \n",&nAngles);
60 for( G4int ia = 0; ia < nAngles; ia++ ){
61 float angleSep;
62 (void) fscanf(fp,"%f \n",&angleSep);
65 mddist angleDist;
66 angleDist[angleSep] = dist;
67 theDistributions[energySep] = angleDist;
68
69 (void) 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}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::map< G4double, G4LEPTSDistribution * > mddist
int G4int
Definition: G4Types.hh:85
void ReadFile(G4String fileName)

References bFileFound, FatalException, fileName, G4Exception(), NoBins, G4LEPTSDistribution::ReadFile(), theDistributions, and theNDistributions.

Referenced by G4LEPTSElossDistr().

◆ Sample()

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}
static constexpr double second
Definition: G4SIunits.hh:137
double G4double
Definition: G4Types.hh:83
G4double Sample(G4double, G4double)

References G4LEPTSDistribution::Sample(), second, theDistributions, and theNDistributions.

Field Documentation

◆ bFileFound

G4bool G4LEPTSElossDistr::bFileFound
private

Definition at line 60 of file G4LEPTSElossDistr.hh.

Referenced by IsFileFound(), and ReadFile().

◆ fileName

std::string G4LEPTSElossDistr::fileName
private

Definition at line 57 of file G4LEPTSElossDistr.hh.

Referenced by G4LEPTSElossDistr(), and ReadFile().

◆ NoBins

int G4LEPTSElossDistr::NoBins
private

Definition at line 58 of file G4LEPTSElossDistr.hh.

Referenced by ReadFile().

◆ theDistributions

mdmddist G4LEPTSElossDistr::theDistributions
private

Definition at line 55 of file G4LEPTSElossDistr.hh.

Referenced by ReadFile(), and Sample().

◆ theNDistributions

G4int G4LEPTSElossDistr::theNDistributions
private

Definition at line 56 of file G4LEPTSElossDistr.hh.

Referenced by ReadFile(), and Sample().


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