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

#include <G4DNARevertProbability.hh>

Public Member Functions

 G4DNARevertProbability (double toleranceY)
 
 G4DNARevertProbability (double xmin, double xmax, double toleranceY)
 
void Reset ()
 
void SetBoundaries (double xmin, double xmax)
 
void SetTolerance (double toleranceY)
 
bool Propose (double proposedXValue, double proposedProba, double nextProba, double &returnedValue)
 
double Revert (double probaForSearchedTime, std::function< double(double)> &funct)
 

Public Attributes

double fXmax
 
double fXmin
 
double fXmaxDef
 
double fXminDef
 
double fToleranceProba
 
double fIncreasingCumulativeFunction
 

Detailed Description

Definition at line 43 of file G4DNARevertProbability.hh.

Constructor & Destructor Documentation

◆ G4DNARevertProbability() [1/2]

G4DNARevertProbability::G4DNARevertProbability ( double toleranceY)
inline

◆ G4DNARevertProbability() [2/2]

G4DNARevertProbability::G4DNARevertProbability ( double xmin,
double xmax,
double toleranceY )
inline

Definition at line 63 of file G4DNARevertProbability.hh.

63 :
64 fXmax(xmax), fXmin(xmin), fToleranceProba(toleranceY)
65 {
66 if(fXmax < fXmin)
67 {
68 double tmp = fXmin;
69 fXmin = fXmax;
70 fXmax = tmp;
71 }
72
76 }

Member Function Documentation

◆ Propose()

bool G4DNARevertProbability::Propose ( double proposedXValue,
double proposedProba,
double nextProba,
double & returnedValue )
inline

Definition at line 104 of file G4DNARevertProbability.hh.

108 {
109 bool returnFlag = false;
110
111 if(proposedProba < nextProba - fToleranceProba) // proba trop petite ==> augmente
112 {
113 if(fIncreasingCumulativeFunction > 0) // croissant
114 {
115 if(proposedXValue > fXmin) fXmin = proposedXValue;
116 }
117 else if(fIncreasingCumulativeFunction < 0) // decroissant
118 {
119 if(proposedXValue < fXmax) fXmax = proposedXValue;
120 }
121
122 returnedValue = (fXmax + fXmin) / 2.;
123 returnFlag = false;
124 }
125 else if(proposedProba > nextProba + fToleranceProba) // proba trop grande
126 {
128 {
129 if(proposedXValue < fXmax)
130 {
131 fXmax = proposedXValue;
132 }
133 }
135 {
136 if(proposedXValue > fXmin)
137 {
138 fXmin = proposedXValue;
139 }
140 }
141
142 returnedValue = (fXmax + fXmin) / 2.;
143 returnFlag = false;
144 }
145 else
146 {
147 // Assuming search for next proba is increasing
149 {
150 fXmin = fXminDef;
151 fXmax = proposedXValue;
152 }
154 {
155 fXmin = proposedXValue;
156 fXmax = fXmaxDef;
157 }
158 returnFlag = true;
159 }
160
161 return returnFlag;
162 }

Referenced by Revert().

◆ Reset()

void G4DNARevertProbability::Reset ( )
inline

Definition at line 78 of file G4DNARevertProbability.hh.

79 {
82 }

Referenced by Revert().

◆ Revert()

double G4DNARevertProbability::Revert ( double probaForSearchedTime,
std::function< double(double)> & funct )
inline

Definition at line 168 of file G4DNARevertProbability.hh.

170 {
171 Reset();
172 bool notFound = true;
173 double proposedX;
174 double x = fXmax;
175
176 fIncreasingCumulativeFunction = (funct(fXmax) - funct(fXmin))
177 / (fXmax - fXmin);
178
179 while(notFound)
180 {
181 double newProba = funct(x);
182
183 if(Propose(x, newProba, probaForSearchedTime, proposedX))
184 {
185 notFound = false;
186 }
187 else
188 {
189 if(x == proposedX)
190 {
191 return x;
192// G4cout << "BREAK : x= " << x << G4endl;
193// G4cout << "nextProba= " << probaForSearchedTime << G4endl;
194// G4cout << "newProba= " << newProba << G4endl;
195// abort();
196 }
197 x = proposedX;
198 }
199 }
200 return x;
201 }
bool Propose(double proposedXValue, double proposedProba, double nextProba, double &returnedValue)

◆ SetBoundaries()

void G4DNARevertProbability::SetBoundaries ( double xmin,
double xmax )
inline

Definition at line 84 of file G4DNARevertProbability.hh.

85 {
86 fXmax = xmax;
87 fXmin = xmin;
88 if(fXmax < fXmin)
89 {
90 double tmp = fXmin;
91 fXmin = fXmax;
92 fXmax = tmp;
93 }
94
97 }

◆ SetTolerance()

void G4DNARevertProbability::SetTolerance ( double toleranceY)
inline

Definition at line 99 of file G4DNARevertProbability.hh.

100 {
101 fToleranceProba = toleranceY;
102 }

Member Data Documentation

◆ fIncreasingCumulativeFunction

double G4DNARevertProbability::fIncreasingCumulativeFunction

◆ fToleranceProba

double G4DNARevertProbability::fToleranceProba

Definition at line 50 of file G4DNARevertProbability.hh.

Referenced by Propose(), and SetTolerance().

◆ fXmax

double G4DNARevertProbability::fXmax

◆ fXmaxDef

double G4DNARevertProbability::fXmaxDef

◆ fXmin

double G4DNARevertProbability::fXmin

◆ fXminDef

double G4DNARevertProbability::fXminDef

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