Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4InterpolationManager Class Reference

#include <G4InterpolationManager.hh>

Public Member Functions

 G4InterpolationManager ()
 
 ~G4InterpolationManager ()
 
G4InterpolationManageroperator= (const G4InterpolationManager &aManager)
 
void Init (G4int aScheme, G4int aRange)
 
void Init (G4InterpolationScheme aScheme, G4int aRange)
 
void Init (std::istream &aDataFile)
 
G4InterpolationScheme MakeScheme (G4int it)
 
G4InterpolationScheme GetScheme (G4int index) const
 
void CleanUp ()
 
G4InterpolationScheme GetInverseScheme (G4int index)
 
void AppendScheme (G4int aPoint, const G4InterpolationScheme &aScheme)
 

Friends

class G4InterpolationIterator
 

Detailed Description

Definition at line 38 of file G4InterpolationManager.hh.

Constructor & Destructor Documentation

◆ G4InterpolationManager()

G4InterpolationManager::G4InterpolationManager ( )
inline

Definition at line 43 of file G4InterpolationManager.hh.

44 {
45 nRanges = 1;
46 start = new G4int[1];
47 start[0] = 0;
48 range = new G4int[1];
49 range[0] = 100000;
50 scheme = new G4InterpolationScheme[1];
51 scheme[0] = LINLIN;
52 nEntries = 0;
53 }
G4InterpolationScheme
int G4int
Definition G4Types.hh:85

◆ ~G4InterpolationManager()

G4InterpolationManager::~G4InterpolationManager ( )
inline

Definition at line 55 of file G4InterpolationManager.hh.

56 {
57 delete[] start;
58 delete[] range;
59 delete[] scheme;
60 }

Member Function Documentation

◆ AppendScheme()

void G4InterpolationManager::AppendScheme ( G4int aPoint,
const G4InterpolationScheme & aScheme )

Definition at line 91 of file G4InterpolationManager.cc.

92{
93 if (aPoint != nEntries) {
94 G4cout << "G4InterpolationManager::AppendScheme - " << aPoint << " " << nEntries << G4endl;
95 throw G4HadronicException(__FILE__, __LINE__,
96 "Wrong usage of G4InterpolationManager::AppendScheme");
97 }
98 if (nEntries == 0) {
99 nEntries = 1;
100 nRanges = 1;
101 start[0] = 0;
102 range[0] = 1;
103 scheme[0] = aScheme;
104 }
105 else if (aScheme == scheme[nRanges - 1]) {
106 ++range[nRanges - 1];
107 nEntries++;
108 }
109 else {
110 nEntries++;
111 nRanges++;
112 G4int i;
113 auto buffer = new G4int[nRanges];
114 auto buffer1 = new G4int[nRanges];
115 auto buff2 = new G4InterpolationScheme[nRanges];
116 for (i = 0; i < nRanges - 1; i++) {
117 buffer[i] = start[i];
118 buffer1[i] = range[i];
119 buff2[i] = scheme[i];
120 }
121 delete[] start;
122 delete[] range;
123 delete[] scheme;
124 start = buffer;
125 range = buffer1;
126 scheme = buff2;
127 start[nRanges - 1] = start[nRanges - 2] + range[nRanges - 2];
128 range[nRanges - 1] = 1;
129 scheme[nRanges - 1] = aScheme;
130 }
131}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

Referenced by G4ParticleHPVector::Merge(), G4ParticleHPVector::Merge(), and G4ParticleHPVector::SetScheme().

◆ CleanUp()

void G4InterpolationManager::CleanUp ( )
inline

Definition at line 138 of file G4InterpolationManager.hh.

139 {
140 nRanges = 0;
141 nEntries = 0;
142 }

Referenced by G4ParticleHPVector::CleanUp().

◆ GetInverseScheme()

G4InterpolationScheme G4InterpolationManager::GetInverseScheme ( G4int index)
inline

Definition at line 144 of file G4InterpolationManager.hh.

145 {
146 G4InterpolationScheme result = GetScheme(index);
147 if (result == HISTO) {
148 result = RANDOM;
149 }
150 else if (result == LINLOG) {
151 result = LOGLIN;
152 }
153 else if (result == LOGLIN) {
154 result = LINLOG;
155 }
156 else if (result == CHISTO) {
157 result = CRANDOM;
158 }
159 else if (result == CLINLOG) {
160 result = CLOGLIN;
161 }
162 else if (result == CLOGLIN) {
163 result = CLINLOG;
164 }
165 else if (result == UHISTO) {
166 result = URANDOM;
167 }
168 else if (result == ULINLOG) {
169 result = ULOGLIN;
170 }
171 else if (result == ULOGLIN) {
172 result = ULINLOG;
173 }
174 return result;
175 }
G4InterpolationScheme GetScheme(G4int index) const

Referenced by G4ParticleHPContAngularPar::Sample().

◆ GetScheme()

◆ Init() [1/3]

◆ Init() [2/3]

void G4InterpolationManager::Init ( G4InterpolationScheme aScheme,
G4int aRange )
inline

Definition at line 90 of file G4InterpolationManager.hh.

91 {
92 nRanges = 1;
93 start[0] = 0;
94 range[0] = aRange;
95 scheme[0] = aScheme;
96 nEntries = aRange;
97 }

◆ Init() [3/3]

void G4InterpolationManager::Init ( std::istream & aDataFile)
inline

Definition at line 99 of file G4InterpolationManager.hh.

100 {
101 delete[] start;
102 delete[] range;
103 delete[] scheme;
104 aDataFile >> nRanges;
105 start = new G4int[nRanges];
106 range = new G4int[nRanges];
107 scheme = new G4InterpolationScheme[nRanges];
108 start[0] = 0;
109 G4int it;
110 for (G4int i = 0; i < nRanges; i++) {
111 aDataFile >> range[i];
112 //***************************************************************
113 // EMendoza -> there is a bug here.
114 /*
115 if(i!=0) start[i] = start[i-1]+range[i-1];
116 */
117 //***************************************************************
118 if (i != 0) start[i] = range[i - 1];
119 //***************************************************************
120 aDataFile >> it;
121 scheme[i] = MakeScheme(it);
122 }
123 nEntries = start[nRanges - 1] + range[nRanges - 1];
124 }

◆ MakeScheme()

G4InterpolationScheme G4InterpolationManager::MakeScheme ( G4int it)

Definition at line 34 of file G4InterpolationManager.cc.

35{
37 switch (it) {
38 case 1:
39 result = HISTO;
40 break;
41 case 2:
42 result = LINLIN;
43 break;
44 case 3:
45 result = LINLOG;
46 break;
47 case 4:
48 result = LOGLIN;
49 break;
50 case 5:
51 result = LOGLOG;
52 break;
53 case 11:
54 result = CHISTO;
55 break;
56 case 12:
57 result = CLINLIN;
58 break;
59 case 13:
60 result = CLINLOG;
61 break;
62 case 14:
63 result = CLOGLIN;
64 break;
65 case 15:
66 result = CLOGLOG;
67 break;
68 case 21:
69 result = UHISTO;
70 break;
71 case 22:
72 result = ULINLIN;
73 break;
74 case 23:
75 result = ULINLOG;
76 break;
77 case 24:
78 result = ULOGLIN;
79 break;
80 case 25:
81 result = ULOGLOG;
82 break;
83 default:
84 throw G4HadronicException(__FILE__, __LINE__,
85 "G4InterpolationManager: unknown interpolation scheme");
86 break;
87 }
88 return result;
89}

Referenced by Init(), and Init().

◆ operator=()

G4InterpolationManager & G4InterpolationManager::operator= ( const G4InterpolationManager & aManager)
inline

Definition at line 62 of file G4InterpolationManager.hh.

63 {
64 if (this != &aManager) {
65 nRanges = aManager.nRanges;
66 nEntries = aManager.nEntries;
67 delete[] scheme;
68 delete[] start;
69 delete[] range;
70 scheme = new G4InterpolationScheme[nRanges];
71 start = new G4int[nRanges];
72 range = new G4int[nRanges];
73 for (G4int i = 0; i < nRanges; i++) {
74 scheme[i] = aManager.scheme[i];
75 start[i] = aManager.start[i];
76 range[i] = aManager.range[i];
77 }
78 }
79 return *this;
80 }

Friends And Related Symbol Documentation

◆ G4InterpolationIterator

friend class G4InterpolationIterator
friend

Definition at line 41 of file G4InterpolationManager.hh.


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