14 #ifndef SI_PIXEL_TEMPLATE_STANDALONE 24 #include<boost/bind.hpp> 28 void sincosint(
double x,
double & sint,
double & cint);
34 int dzero(
double a,
double b,
double& x0,
35 double& rv,
double eps,
int mxf,
F func);
50 const double xp[9] = { 9.29,2.47,.89,.36,.15,.07,.03,.02,0.0 };
51 const double xq[7] = { .012,.03,.08,.26,.87,3.83,11.0 };
53 double q, u,
x,
c1, c2, c3, c4, d1, h4, h5, h6,
q2, x1,
d, ll, ul, xf1, xf2, rv;
58 if(kappa < 0.01) kappa = 0.01;
59 if(kappa > 10.) kappa = 10.;
60 if(beta2 < 0.) beta2 = 0.;
61 if(beta2 > 1.) beta2 = 1.;
63 h_[4] = 1. - beta2*0.42278433999999998 + 7.6/
kappa;
66 h4 = -7.6/kappa - (beta2 * .57721566 + 1);
73 for (lp = 0; lp < 9; ++lp) {
74 if (kappa >= xp[lp])
break;
77 for (lq = 0; lq < 7; ++lq) {
78 if (kappa <= xq[lq])
break;
87 h_[0] = kappa * (beta2 * .57721566 + 2.) + 9.9166128600000008;
88 if (kappa >= .07) {h_[0] += 6.90775527;}
89 h_[1] = beta2 *
kappa;
91 h_[3] = omega_ * 1.5707963250000001;
92 auto f1 = [h_](
double x){
return h_[0]+h_[1]*
std::log(h_[2]*x)-h_[3]*
x;};
95 d =
exp(kappa * (beta2 * (.57721566 - h5) + 1.)) * .31830988654751274;
98 a_[n - 1] = omega_ * .31830988654751274;
102 for (k = 1; k <
n; ++
k) {
110 xf1 = kappa * (beta2 * c1 - c4) - x * c2;
111 xf2 = x * c1 + kappa * (c3 + beta2 * c2) + t0_ * x;
113 d1 = q * d * omega_ *
exp(xf1);
114 a_[l - 1] = d1 *
cos(xf2);
115 b_[l - 1] = -d1 *
sin(xf2);
117 d1 = q * d *
exp(xf1)/
k;
118 a_[l - 1] = d1 *
sin(xf2);
119 b_[l - 1] = d1 *
cos(xf2);
120 a_[n - 1] += q2 *
a_[l - 1];
139 double f, u,
y, a0, a1;
141 double b1, b0, b2, cof;
147 }
else if (x <=
t1_) {
149 u =
omega_ * y - 3.141592653589793;
154 for (k = 2; k <= n1; ++
k) {
157 a0 =
a_[k - 1] + cof * a1 - a2;
161 for (k = 2; k <=
n; ++
k) {
164 b0 =
b_[k - 1] + cof * b1 - b2;
166 f = (a0 - a2) * .5 + b0 *
sin(u);
170 if (
mode_ != 0) {f = 1.;}
196 const double zero = 0.;
197 const double one = 1.;
198 const double two = 2.;
199 const double eight = 8.;
200 const double ce = .57721566490153;
201 const double c__[14] = { 1.9405491464836,.9413409132865,
202 -.579845034293,.3091572011159,-.0916101792208,.0164437407515,
203 -.0019713091952,1.692538851e-4,-1.09393296e-5,5.522386e-7,
204 -2.23995e-8,7.465e-10,-2.08e-11,5
e-13 };
205 const double p[23] = { .96074783975204,-.0371138962124,
206 .00194143988899,-1.7165988425e-4,2.112637753e-5,-3.27163257e-6,
207 6.0069212e-7,-1.2586794e-7,2.932563e-8,-7.45696e-9,2.04105e-9,
208 -5.9502e-10,1.8323e-10,-5.921e-11,1.997e-11,-7
e-12,2.54e-12,
209 -9.5e-13,3.7e-13,-1.4e-13,6
e-14,-2
e-14,1e-14 };
210 const double q[20] = { .98604065696238,-.0134717382083,
211 4.5329284117e-4,-3.067288652e-5,3.13199198e-6,-4.2110196e-7,
212 6.907245e-8,-1.318321e-8,2.83697e-9,-6.7329e-10,1.734e-10,
213 -4.787e-11,1.403e-11,-4.33e-12,1.4e-12,-4.7e-13,1.7e-13,-6e-14,
222 double r__,
y, b0, b1, b2,
pp, qq, alfa;
229 if (fabs(x) <= eight) {
233 h__ = two * (d__1 * d__1) - one;
237 for (i__ = 13; i__ >= 0; --i__) {
238 b0 = c__[i__] - alfa * b1 - b2;
242 b1 = ce +
log((fabs(x))) - b0 + h__ * b2;
248 h__ = two * (d__1 * d__1) - one;
252 for (i__ = 22; i__ >= 0; --i__) {
253 b0 = p[i__] - alfa * b1 - b2;
260 for (i__ = 19; i__ >= 0; --i__) {
261 b0 = q[i__] - alfa * b1 - b2;
266 b1 = r__ * (qq *
sin(x) - r__ * pp *
cos(x));
274 const double zero = 0.;
275 const double one = 1.;
276 const double two = 2.;
277 const double eight = 8.;
278 const double pih = 1.5707963267949;
279 const double s[14] = { 1.9522209759531,-.6884042321257,
280 .4551855132256,-.1804571236838,.0410422133759,-.0059586169556,
281 6.001427414e-4,-4.44708329e-5,2.5300782e-6,-1.141308e-7,4.1858e-9,
282 -1.273e-10,3.3e-12,-1
e-13 };
283 const double p[23] = { .96074783975204,-.0371138962124,
284 .00194143988899,-1.7165988425e-4,2.112637753e-5,-3.27163257e-6,
285 6.0069212e-7,-1.2586794e-7,2.932563e-8,-7.45696e-9,2.04105e-9,
286 -5.9502e-10,1.8323e-10,-5.921e-11,1.997e-11,-7
e-12,2.54e-12,
287 -9.5e-13,3.7e-13,-1.4e-13,6
e-14,-2
e-14,1e-14 };
288 const double q[20] = { .98604065696238,-.0134717382083,
289 4.5329284117e-4,-3.067288652e-5,3.13199198e-6,-4.2110196e-7,
290 6.907245e-8,-1.318321e-8,2.83697e-9,-6.7329e-10,1.734e-10,
291 -4.787e-11,1.403e-11,-4.33e-12,1.4e-12,-4.7e-13,1.7e-13,-6e-14,
300 double r__,
y, b0, b1, b2,
pp, qq, alfa;
302 if (fabs(x) <= eight) {
305 h__ = two * (d__1 * d__1) - one;
309 for (i__ = 13; i__ >= 0; --i__) {
310 b0 = s[i__] - alfa * b1 - b2;
319 h__ = two * (d__1 * d__1) - one;
323 for (i__ = 22; i__ >= 0; --i__) {
324 b0 = p[i__] - alfa * b1 - b2;
331 for (i__ = 19; i__ >= 0; --i__) {
332 b0 = q[i__] - alfa * b1 - b2;
338 if(x < 0.) d__1 = -d__1;
339 b1 = d__1 - r__ * (r__ * pp *
sin(x) + qq *
cos(x));
348 const double zero = 0.;
349 const double one = 1.;
350 const double two = 2.;
351 const double eight = 8.;
352 const double ce = .57721566490153;
353 const double pih = 1.5707963267949;
354 const double s__[14] = { 1.9522209759531,-.6884042321257,
355 .4551855132256,-.1804571236838,.0410422133759,-.0059586169556,
356 6.001427414e-4,-4.44708329e-5,2.5300782e-6,-1.141308e-7,4.1858e-9,
357 -1.273e-10,3.3e-12,-1
e-13 };
359 const double c__[14] = { 1.9405491464836,.9413409132865,
360 -.579845034293,.3091572011159,-.0916101792208,.0164437407515,
361 -.0019713091952,1.692538851e-4,-1.09393296e-5,5.522386e-7,
362 -2.23995e-8,7.465e-10,-2.08e-11,5
e-13 };
364 const double p[23] = { .96074783975204,-.0371138962124,
365 .00194143988899,-1.7165988425e-4,2.112637753e-5,-3.27163257e-6,
366 6.0069212e-7,-1.2586794e-7,2.932563e-8,-7.45696e-9,2.04105e-9,
367 -5.9502e-10,1.8323e-10,-5.921e-11,1.997e-11,-7
e-12,2.54e-12,
368 -9.5e-13,3.7e-13,-1.4e-13,6
e-14,-2
e-14,1e-14 };
369 const double q[20] = { .98604065696238,-.0134717382083,
370 4.5329284117e-4,-3.067288652e-5,3.13199198e-6,-4.2110196e-7,
371 6.907245e-8,-1.318321e-8,2.83697e-9,-6.7329e-10,1.734e-10,
372 -4.787e-11,1.403e-11,-4.33e-12,1.4e-12,-4.7e-13,1.7e-13,-6e-14,
381 double r__,
y, b0, b1, b2,
pp, qq, alfa;
387 if (fabs(x) <= eight) {
391 h__ = two * (d__1 * d__1) - one;
398 for (i__ = 13; i__ >= 0; --i__) {
399 b0 = c__[i__] - alfa * b1 - b2;
403 cint = ce +
log((fabs(x))) - b0 + h__ * b2;
408 for (i__ = 13; i__ >= 0; --i__) {
409 b0 = s__[i__] - alfa * b1 - b2;
413 sint = y * (b0 - b2);
420 h__ = two * (d__1 * d__1) - one;
424 for (i__ = 22; i__ >= 0; --i__) {
425 b0 = p[i__] - alfa * b1 - b2;
432 for (i__ = 19; i__ >= 0; --i__) {
433 b0 = q[i__] - alfa * b1 - b2;
439 cint = r__ * (qq *
sin(x) - r__ * pp *
cos(x));
442 if(x < 0.) d__1 = -d__1;
443 sint = d__1 - r__ * (r__ * pp *
sin(x) + qq *
cos(x));
452 const double zero = 0.;
453 const double q2[7] = { .10340013040487,3.319092135933,
454 20.449478501379,41.280784189142,32.426421069514,10.041164382905,
456 const double p3[6] = { -2.3909964453136,-147.98219500504,
457 -254.3763397689,-119.55761038372,-19.630408535939,-.9999999999036
459 const double q3[6] = { 177.60070940351,530.68509610812,
460 462.23027156148,156.81843364539,21.630408494238,1. };
461 const double p4[8] = { -8.6693733995107,-549.14226552109,
462 -4210.0161535707,-249301.39345865,-119623.66934925,
463 -22174462.775885,3892804.213112,-391546073.8091 };
464 const double q4[8] = { 34.171875,-1607.0892658722,35730.029805851,
465 -483547.43616216,4285596.2461175,-24903337.574054,89192576.757561,
467 const double a1[8] = { -2.1808638152072,-21.901023385488,
468 9.3081638566217,25.076281129356,-33.184253199722,60.121799083008,
469 -43.253113287813,1.0044310922808 };
470 const double b1[8] = { 0.,3.9370770185272,300.89264837292,
471 -6.2504116167188,1003.6743951673,14.325673812194,2736.2411988933,
473 const double a2[8] = { -3.4833465360285,-18.65454548834,
474 -8.2856199414064,-32.34673303054,17.960168876925,1.7565631546961,
475 -1.9502232128966,.99999429607471 };
476 const double b2[8] = { 0.,69.500065588743,57.283719383732,
477 25.777638423844,760.76114800773,28.951672792514,-3.4394226689987,
479 const double a3[6] = { -27.780928934438,-10.10479081576,
480 -9.1483008216736,-5.0223317461851,-3.0000077799358,
482 const double one = 1.;
483 const double b3[6] = { 0.,122.39993926823,2.7276100778779,
484 -7.1897518395045,-2.9990118065262,1.999999942826 };
485 const double two = 2.;
486 const double three = 3.;
487 const double x0 = .37250741078137;
488 const double xl[6] = { -24.,-12.,-6.,0.,1.,4. };
489 const double p1[5] = { 4.293125234321,39.894153870321,
490 292.52518866921,425.69682638592,-434.98143832952 };
491 const double q1[5] = { 1.,18.899288395003,150.95038744251,
492 568.05252718987,753.58564359843 };
493 const double p2[7] = { .43096783946939,6.9052252278444,
494 23.019255939133,24.378408879132,9.0416155694633,.99997957705159,
498 double v,
y, ap, bp, aq,
dp, bq, dq;
502 for (
int i__ = 2; i__ <= 5; ++i__) {
504 ap = a3[i__ - 1] - x + b3[i__ - 1] / ap;
506 y =
exp(-x) / x * (one - (a3[5] + b3[5] / ap) / x);
507 }
else if (x <= xl[1]) {
509 for (
int i__ = 2; i__ <= 7; ++i__) {
510 ap = a2[i__ - 1] - x + b2[i__ - 1] / ap;
512 y =
exp(-x) / x * (a2[7] + b2[7] / ap);
513 }
else if (x <= xl[2]) {
515 for (
int i__ = 2; i__ <= 7; ++i__) {
516 ap = a1[i__ - 1] - x + b1[i__ - 1] / ap;
518 y =
exp(-x) / x * (a1[7] + b1[7] / ap);
519 }
else if (x < xl[3]) {
520 v = -two * (x / three + one);
523 for (
int i__ = 2; i__ <= 8; ++i__) {
526 dp = p4[i__ - 1] - ap + v * bp;
530 for (
int i__ = 2; i__ <= 8; ++i__) {
533 dq = q4[i__ - 1] - aq + v * bq;
535 y = -
log(-x / x0) + (x + x0) * (dp - ap) / (dq - aq);
536 }
else if (x == xl[3]) {
538 }
else if (x < xl[4]) {
541 for (
int i__ = 2; i__ <= 5; ++i__) {
542 ap = p1[i__ - 1] + x * ap;
543 aq = q1[i__ - 1] + x * aq;
545 y = -
log(x) + ap / aq;
546 }
else if (x <= xl[5]) {
550 for (
int i__ = 2; i__ <= 7; ++i__) {
551 ap = p2[i__ - 1] + y * ap;
552 aq = q2[i__ - 1] + y * aq;
554 y =
exp(-x) * ap / aq;
559 for (
int i__ = 2; i__ <= 6; ++i__) {
560 ap = p3[i__ - 1] + y * ap;
561 aq = q3[i__ - 1] + y * aq;
563 y =
exp(-x) * y * (one + y * ap / aq);
571 double& rv,
double eps,
int mxf,
F func) {
573 double d__1, d__2, d__3, d__4;
576 double f1,
f2,
f3,
u1,
u2, x1, x2, u3, u4, x3, ca, cb, cc,
fa,
fb, ee,
ff;
578 double xa, xb, fx,
xx, su4;
593 ee = eps * (fabs(x0) + 1);
607 rv = (d__1 = xb - xa, fabs(d__1)) * -.5;
623 if (u2 == 0. || u4 == 0.) {
goto L1;}
629 cb = (x1 + x2) * u2 - (x2 + x0) *
u1;
630 cc = (x1 - x0) * f1 - x1 * (ca * x1 + cb);
632 if (cb == 0.) {
goto L1;}
636 u4 = u3 * u3 - cc / ca;
637 if (u4 < 0.) {
goto L1;}
639 if (x0 + u3 < 0.
f) {su4 = -su4;}
642 if (x0 < xa || x0 > xb) {
goto L1;}
644 d__3 = (d__1 = x0 - x3, fabs(d__1)), d__4 = (d__2 = x0 - x2, fabs(d__2));
646 ee = eps * (fabs(x0) + 1);
684 rv = (d__1 = xb - xa, fabs(d__1)) * -.5;
void limits(double &xl, double &xu) const
density (mode=0) or distribution (mode=1) function
double expint(double x)
Private version of the sine integral.
double sinint(double x)
Private version of the cosine integral.
void sincosint(double x, double &sint, double &cint)
Sin< T >::type sin(const T &t)
int dzero(double a, double b, double &x0, double &rv, double eps, int mxf, F func)
double sinint(double x)
Private version of the cosine integral.
int dzero(double a, double b, double &x0, double &rv, double eps, int mxf, F func)
Private version of the exponential integral.
T x() const
Cartesian x coordinate.
double cosint(double x)
Private version of the cosine and sine integral.
double cosint(double x)
Private version of the cosine and sine integral.
Cos< T >::type cos(const T &t)
double f1(double x, double const *h_)
Private version of the exponential integral.
Abs< T >::type abs(const T &t)
VVIObj(double kappa=0.01, double beta2=1., int mode=0)
Constructor.
double fcn(double x) const
double f2(double x, double const *h_)
void sincosint(double x, double &sint, double &cint)
const int mode_
returns the limits on the non-zero (mode=0) or normalized region (mode=1)
static const G4double kappa
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
double expint(double x)
Private version of the sine integral.