Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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::G4DNARevertProbability ( double  toleranceY)
inline

Definition at line 53 of file G4DNARevertProbability.hh.

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 
73  fXminDef = fXmin;
74  fXmaxDef = fXmax;
76  }

Member Function Documentation

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  }
134  else if(fIncreasingCumulativeFunction < 0)
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  }
153  else if(fIncreasingCumulativeFunction > 0)
154  {
155  fXmin = proposedXValue;
156  fXmax = fXmaxDef;
157  }
158  returnFlag = true;
159  }
160 
161  return returnFlag;
162  }

Here is the caller graph for this function:

void G4DNARevertProbability::Reset ( )
inline

Definition at line 78 of file G4DNARevertProbability.hh.

Here is the caller graph for this function:

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)
tuple x
Definition: test.py:50

Here is the call graph for this function:

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 
95  fXminDef = fXmin;
96  fXmaxDef = fXmax;
97  }
void G4DNARevertProbability::SetTolerance ( double  toleranceY)
inline

Definition at line 99 of file G4DNARevertProbability.hh.

100  {
101  fToleranceProba = toleranceY;
102  }

Member Data Documentation

double G4DNARevertProbability::fIncreasingCumulativeFunction

Definition at line 51 of file G4DNARevertProbability.hh.

double G4DNARevertProbability::fToleranceProba

Definition at line 50 of file G4DNARevertProbability.hh.

double G4DNARevertProbability::fXmax

Definition at line 46 of file G4DNARevertProbability.hh.

double G4DNARevertProbability::fXmaxDef

Definition at line 48 of file G4DNARevertProbability.hh.

double G4DNARevertProbability::fXmin

Definition at line 47 of file G4DNARevertProbability.hh.

double G4DNARevertProbability::fXminDef

Definition at line 49 of file G4DNARevertProbability.hh.


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