10 #if defined __cplusplus
65 double xSampled = sampled->
x, frac = 1.;
71 frac = ( dists->
Ws[iW+1] - sampled->
w ) / ( dists->
Ws[iW+1] - dists->
Ws[iW] );
72 sampled->
x = frac * xSampled + ( 1 - frac ) * sampled->
x; }
74 frac =
G4Log( dists->
Ws[iW+1] / sampled->
w ) /
G4Log( dists->
Ws[iW+1] / dists->
Ws[iW] );
75 sampled->
x = frac * xSampled + ( 1 - frac ) * sampled->
x; }
77 frac = ( dists->
Ws[iW+1] - sampled->
w ) / ( dists->
Ws[iW+1] - dists->
Ws[iW] );
80 frac =
G4Log( dists->
Ws[iW+1] / sampled->
w ) /
G4Log( dists->
Ws[iW+1] / dists->
Ws[iW] );
87 sampled->
iX2 = sampled->
iX1;
107 sampled->
x = dist->
Xs[0];
111 frac = ( dist->
cdf[iX+1] - rngValue ) / ( dist->
cdf[iX+1] - dist->
cdf[iX] );
112 sampled->
x = frac * dist->
Xs[iX] + ( 1 - frac ) * dist->
Xs[iX+1]; }
114 double s1 = dist->
pdf[iX+1] - dist->
pdf[iX];
117 if( dist->
pdf[iX] == 0 ) {
118 sampled->
x = dist->
Xs[iX];
119 if( iX == 0 ) sampled->
x = dist->
Xs[1]; }
121 frac = ( dist->
cdf[iX+1] - rngValue ) / ( dist->
cdf[iX+1] - dist->
cdf[iX] );
122 sampled->
x = frac * dist->
Xs[iX] + ( 1 - frac ) * dist->
Xs[iX+1];
125 s1 = s1 / ( dist->
Xs[iX+1] - dist->
Xs[iX] );
126 d1 = rngValue - dist->
cdf[iX];
127 d2 = dist->
cdf[iX+1] - rngValue;
129 sampled->
x = dist->
Xs[iX] + ( std::sqrt( dist->
pdf[iX] * dist->
pdf[iX] + 2. * s1 * d1 ) - dist->
pdf[iX] ) / s1; }
131 sampled->
x = dist->
Xs[iX+1] - ( dist->
pdf[iX+1] - std::sqrt( dist->
pdf[iX+1] * dist->
pdf[iX+1] - 2. * s1 * d2 ) ) / s1;
146 double randomW = decaySamplingInfo->
rng( decaySamplingInfo->
rngState ), randomX = decaySamplingInfo->
rng( decaySamplingInfo->
rngState );
161 e_in = pdfOfWGivenV->
Ws[iV];
165 sampledX.
w = sampledW.
x;
169 double x = sampledX.
x, w = sampledW.
x, Vs[3] = { e_in, pdfOfWGivenV->
Ws[iV], pdfOfWGivenV->
Ws[iV+1] };
172 sampledX.
w = sampledW.
x;
179 decaySamplingInfo->
mu = sampledW.
x;
180 decaySamplingInfo->
Ep = sampledX.
x;
192 frac = ( ws[2] - ws[0] ) / ( ws[2] - ws[1] );
193 *y = frac * y1 + ( 1 - frac ) * y2; }
195 frac =
G4Log( ws[2] / ws[0] ) /
G4Log( ws[2] / ws[1] );
196 *y = frac * y1 + ( 1 - frac ) * y2; }
198 frac = ( ws[2] - ws[0] ) / ( ws[2] - ws[1] );
201 frac =
G4Log( ws[2] / ws[0] ) /
G4Log( ws[2] / ws[1] );
226 #if defined __cplusplus
static G4Pow * GetInstance()
G4double powA(G4double A, G4double y) const
ptwXY_interpolation interpolationXY
nfu_status ptwXY_getValueAtX(ptwXYPoints *ptwXY, double x, double *y)
int MCGIDI_sampling_doubleDistribution(statusMessageReporting *smr, MCGIDI_pdfsOfXGivenW *pdfOfWGivenV, MCGIDI_pdfsOfXGivenW *pdfOfXGivenVAndW, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo)
ptwXY_interpolation interpolationWY
int MCGIDI_sampling_sampleX_from_pdfOfX(MCGIDI_pdfOfX *dist, MCGIDI_pdfsOfXGivenW_sampled *sampled, double r)
int MCGIDI_sampling_pdfsOfXGivenW_initialize(statusMessageReporting *smr, MCGIDI_pdfsOfXGivenW *dists)
statusMessageReporting * smr
#define smr_setReportError2(smr, libraryID, code, fmt,...)
double MCGIDI_sampling_ptwXY_getValueAtX(ptwXYPoints *ptwXY, double x1)
int MCGIDI_sampling_pdfsOfXGivenW_release(statusMessageReporting *smr, MCGIDI_pdfsOfXGivenW *dists)
int MCGIDI_sampling_interpolationValues(statusMessageReporting *smr, ptwXY_interpolation interpolation, double *ws, double y1, double y2, double *y)
ptwXY_interpolation interpolationWY
double ptwXY_getXMin(ptwXYPoints *ptwXY)
xDataTOM_Int MCGIDI_misc_binarySearch(xDataTOM_Int n, double *ds, double d)
enum ptwXY_interpolation_e ptwXY_interpolation
G4double G4Log(G4double x)
int MCGIDI_sampling_sampleX_from_pdfsOfXGivenW(MCGIDI_pdfsOfXGivenW *dists, MCGIDI_pdfsOfXGivenW_sampled *sampled, double r)
void * smr_freeMemory(void **p)
int MCGIDI_sampling_pdfsOfX_release(statusMessageReporting *smr, MCGIDI_pdfOfX *dist)
ptwXY_interpolation interpolationXY
double getProjectileEnergy(void) const
double ptwXY_getXMax(ptwXYPoints *ptwXY)