CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
VVIObjF Class Reference

#include <VVIObjF.h>

Public Member Functions

float fcn (float x) const
 
void limits (float &xl, float &xu) const
 density (mode=0) or distribution (mode=1) function More...
 
 VVIObjF (float kappa, float beta2, int mode)
 Constructor. More...
 
 VVIObjF (float kappa)
 Constructor with kappa only. More...
 

Private Attributes

float a_ [155]
 
float b_ [155]
 
const int mode_
 returns the limits on the non-zero (mode=0) or normalized region (mode=1) More...
 
float omega_
 
float t0_
 
float t1_
 
float t_
 
float x0_
 

Detailed Description

Port of CERNLIB routines vvidis/vviden (G116) to calculate higher quality Vavilov density and distribution functions

Definition at line 25 of file VVIObjF.h.

Constructor & Destructor Documentation

◆ VVIObjF() [1/2]

VVIObjF::VVIObjF ( float  kappa,
float  beta2,
int  mode 
)

Constructor.

Constructor Set Vavilov parameters kappa and beta2 and define whether to calculate density fcn or distribution fcn

Parameters
kappa- (input) Vavilov kappa parameter [0.01 (Landau-like) < kappa < 10. (Gaussian-like)]
beta2- (input) Vavilov beta2 parameter (square of particle speed in v/c units)
mode- (input) set to 0 to calculate the density function and to 1 to calculate the distribution function

Definition at line 43 of file VVIObjF.cc.

References a_, funct::abs(), b_, HltBtagPostValidation_cff::c, alignmentValidation::c1, ztail::d, d1, VVIObjFDetails::dzero(), MillePedeFileConverter_cfg::e, VVIObjFDetails::expint(), f, DeadROC_duringRun::f1, DeadROC_duringRun::f2, myMath::fast_expf(), myMath::fast_logf(), nano_mu_digi_cff::float, dqmdumpme::k, hgcalLayerClustersEE_cfi::kappa, MainPageGenerator::l, mode_, dqmiodumpmetadata::n, omega_, submitPVResolutionJobs::q, alignCSCRings::s, VVIObjFDetails::sincosint(), t0_, t1_, t_, x, x0_, and testProducerWithPsetDescEmpty_cfi::x1.

43  : mode_(mode) {
44  const float xp[9] = {9.29, 2.47, .89, .36, .15, .07, .03, .02, 0.0};
45  const float xq[7] = {.012, .03, .08, .26, .87, 3.83, 11.0};
46  float h_[7];
47  float q, u, h4, h5, h6, q2, d, ll, ul, rv;
48  int lp, lq, k, l, n;
49 
50  // Make sure that the inputs are reasonable
51 
52  if (kappa < 0.01f)
53  kappa = 0.01f;
54  if (kappa > 10.f)
55  kappa = 10.f;
56  if (beta2 < 0.f)
57  beta2 = 0.f;
58  if (beta2 > 1.f)
59  beta2 = 1.f;
60 
61  float invKappa = 1.f / kappa;
62  h_[4] = 1.f - beta2 * 0.42278433999999998f + (7.6f * invKappa);
63  h_[5] = beta2;
64  h_[6] = 1.f - beta2;
65  h4 = -(7.6f * invKappa) - (beta2 * .57721566f + 1.f);
66  h5 = vdt::fast_logf(kappa);
67  h6 = invKappa;
68  t0_ = (h4 - h_[4] * h5 - (h_[4] + beta2) * (vdt::fast_logf(h_[4]) + VVIObjFDetails::expint(h_[4])) +
69  vdt::fast_expf(-h_[4])) /
70  h_[4];
71 
72  // Set up limits for the root search
73 
74  for (lp = 0; lp < 9; ++lp) {
75  if (kappa >= xp[lp])
76  break;
77  }
78  ll = -float(lp) - 1.5f;
79  for (lq = 0; lq < 7; ++lq) {
80  if (kappa <= xq[lq])
81  break;
82  }
83  ul = lq - 6.5f;
84  auto f2 = [h_](float x) {
85  return h_[4] - x + h_[5] * (vdt::fast_logf(std::abs(x)) + VVIObjFDetails::expint(x)) - h_[6] * vdt::fast_expf(-x);
86  };
87  VVIObjFDetails::dzero(ll, ul, u, rv, 1.e-3f, 100, f2);
88  q = 1. / u;
89  t1_ = h4 * q - h5 - (beta2 * q + 1.f) * (vdt::fast_logf((fabs(u))) + VVIObjFDetails::expint(u)) +
90  vdt::fast_expf(-u) * q;
91  t_ = t1_ - t0_;
92  omega_ = 6.2831853000000004f / t_;
93  h_[0] = kappa * (beta2 * .57721566f + 2.f) + 9.9166128600000008f;
94  if (kappa >= .07) {
95  h_[0] += 6.90775527f;
96  }
97  h_[1] = beta2 * kappa;
98  h_[2] = h6 * omega_;
99  h_[3] = omega_ * 1.5707963250000001f;
100  auto f1 = [h_](float x) { return h_[0] + h_[1] * vdt::fast_logf(h_[2] * x) - h_[3] * x; };
101  VVIObjFDetails::dzero(5.f, 155.f, x0_, rv, 1.e-3f, 100, f1);
102  n = x0_ + 1.;
103  d = vdt::fast_expf(kappa * (beta2 * (.57721566f - h5) + 1.f)) * .31830988654751274f;
104  a_[n - 1] = 0.f;
105  if (mode_ == 0) {
106  a_[n - 1] = omega_ * .31830988654751274f;
107  }
108  q = -1.;
109  q2 = 2.;
110 
111  float x[n];
112  x[0] = 0.f;
113  float x1[n];
114  x1[0] = 0.f;
115  float c1[n];
116  c1[0] = 0.f;
117  float c2[n];
118  c2[0] = 0.f;
119  float c3[n];
120  c3[0] = 0.f;
121  float c4[n];
122  c4[0] = 0.f;
123  float s[n];
124  s[0] = 0.f;
125  float c[n];
126  c[0] = 0.f;
127  float xf1[n];
128  xf1[0] = 0.f;
129  float xf2[n];
130  xf2[0] = 0.f;
131  for (k = 1; k < n; ++k) {
132  x[k] = omega_ * k;
133  x1[k] = h6 * x[k];
134  }
135  for (k = 1; k < n; ++k) {
136  VVIObjFDetails::sincosint(x1[k], c2[k], c1[k]);
137  }
138  for (k = 1; k < n; ++k) {
139  c1[k] = vdt::fast_logf(x[k]) - c1[k];
140  }
141  for (k = 1; k < n; ++k) {
142  vdt::fast_sincosf(x1[k], c3[k], c4[k]);
143  xf1[k] = kappa * (beta2 * c1[k] - c4[k]) - x[k] * c2[k];
144  xf2[k] = x[k] * c1[k] + kappa * (c3[k] + beta2 * c2[k]) + t0_ * x[k];
145  }
146  for (k = 1; k < n; ++k) {
147  vdt::fast_sincosf(xf2[k], s[k], c[k]);
148  }
149  float d1[n];
150  d1[0] = 0.f;
151  if (mode_ == 0) {
152  for (k = 1; k < n; ++k) {
153  d1[k] = q * d * omega_ * vdt::fast_expf(xf1[k]);
154  q = -q;
155  }
156  for (k = 1; k < n; ++k) {
157  l = n - k;
158  a_[l - 1] = d1[k] * c[k];
159  b_[l - 1] = -d1[k] * s[k];
160  }
161  } else {
162  for (k = 1; k < n; ++k) {
163  d1[k] = q * d * vdt::fast_expf(xf1[k]) / k;
164  q = -q;
165  }
166  for (k = 1; k < n; ++k) {
167  l = n - k;
168  a_[l - 1] = d1[k] * s[k];
169  }
170  for (k = 1; k < n; ++k) {
171  l = n - k;
172  b_[l - 1] = d1[k] * c[k];
173  }
174  for (k = 1; k < n; ++k) {
175  l = n - k;
176  a_[n - 1] += q2 * a_[l - 1];
177  q2 = -q2;
178  }
179  }
180 } // VVIObjF
float omega_
Definition: VVIObjF.h:40
float t1_
Definition: VVIObjF.h:38
const int mode_
returns the limits on the non-zero (mode=0) or normalized region (mode=1)
Definition: VVIObjF.h:36
void sincosint(float x, float &sint, float &cint)
Definition: VVIObjF.cc:370
float x0_
Definition: VVIObjF.h:41
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
int dzero(float a, float b, float &x0, float &rv, float eps, int mxf, F func)
Private version of the exponential integral.
Definition: VVIObjF.cc:518
float t0_
Definition: VVIObjF.h:37
d
Definition: ztail.py:151
float expint(float x)
Private version of the cosine and sine integral.
Definition: VVIObjF.cc:372
float b_[155]
Definition: VVIObjF.h:43
float fast_expf(float x)
static constexpr float d1
float fast_logf(float x)
float t_
Definition: VVIObjF.h:39
float a_[155]
Definition: VVIObjF.h:42

◆ VVIObjF() [2/2]

VVIObjF::VVIObjF ( float  kappa)

Constructor with kappa only.

Constructor Set Vavilov parameter kappa and calculate the distribution fcn

Parameters
kappa- (input) Vavilov kappa parameter [0.01 (Landau-like) < kappa < 10. (Gaussian-like)]

Definition at line 189 of file VVIObjF.cc.

References a_, funct::abs(), b_, HltBtagPostValidation_cff::c, alignmentValidation::c1, ztail::d, d1, VVIObjFDetails::dzero(), MillePedeFileConverter_cfg::e, VVIObjFDetails::expint(), f, DeadROC_duringRun::f1, DeadROC_duringRun::f2, myMath::fast_expf(), myMath::fast_logf(), nano_mu_digi_cff::float, dqmdumpme::k, hgcalLayerClustersEE_cfi::kappa, MainPageGenerator::l, dqmiodumpmetadata::n, omega_, submitPVResolutionJobs::q, alignCSCRings::s, VVIObjFDetails::sincosint(), t0_, t1_, t_, x, x0_, and testProducerWithPsetDescEmpty_cfi::x1.

189  : mode_(1) {
190  const float xp[9] = {9.29, 2.47, .89, .36, .15, .07, .03, .02, 0.0};
191  const float xq[7] = {.012, .03, .08, .26, .87, 3.83, 11.0};
192  float h_[5];
193  float q, u, h4, h5, h6, q2, d, ll, ul, rv;
194  int lp, lq, k, l, n;
195 
196  // Make sure that the inputs are reasonable
197 
198  if (kappa < 0.01f)
199  kappa = 0.01f;
200  if (kappa > 10.f)
201  kappa = 10.f;
202 
203  float invKappa = 1.f / kappa;
204  h_[4] = 0.57721566f + (7.6f * invKappa);
205  h4 = -(7.6f * invKappa) - 1.57721566f;
206  h5 = vdt::fast_logf(kappa);
207  h6 = invKappa;
208  t0_ = (h4 - h_[4] * h5 - (h_[4] + 1.f) * (vdt::fast_logf(h_[4]) + VVIObjFDetails::expint(h_[4])) +
209  vdt::fast_expf(-h_[4])) /
210  h_[4];
211 
212  // Set up limits for the root search
213 
214  for (lp = 0; lp < 9; ++lp) {
215  if (kappa >= xp[lp])
216  break;
217  }
218  ll = -float(lp) - 1.5f;
219  for (lq = 0; lq < 7; ++lq) {
220  if (kappa <= xq[lq])
221  break;
222  }
223  ul = lq - 6.5f;
224  auto f2 = [h_](float x) { return h_[4] - x + (vdt::fast_logf(std::abs(x)) + VVIObjFDetails::expint(x)); };
225  VVIObjFDetails::dzero(ll, ul, u, rv, 1.e-3f, 100, f2);
226  q = 1. / u;
227  t1_ = h4 * q - h5 - (q + 1.f) * (vdt::fast_logf((fabs(u))) + VVIObjFDetails::expint(u)) + vdt::fast_expf(-u) * q;
228  t_ = t1_ - t0_;
229  omega_ = 6.2831853000000004f / t_;
230  h_[0] = kappa * 2.57721566f + 9.9166128600000008f;
231  if (kappa >= .07) {
232  h_[0] += 6.90775527f;
233  }
234  h_[1] = kappa;
235  h_[2] = h6 * omega_;
236  h_[3] = omega_ * 1.5707963250000001f;
237  auto f1 = [h_](float x) { return h_[0] + h_[1] * vdt::fast_logf(h_[2] * x) - h_[3] * x; };
238  VVIObjFDetails::dzero(5.f, 155.f, x0_, rv, 1.e-3f, 100, f1);
239  n = x0_ + 1.;
240  d = vdt::fast_expf(kappa * ((0.57721566f - h5) + 1.f)) * .31830988654751274f;
241  a_[n - 1] = 0.f;
242  q = -1.;
243  q2 = 2.;
244 
245  float x[n];
246  x[0] = 0.f;
247  float x1[n];
248  x1[0] = 0.f;
249  float c1[n];
250  c1[0] = 0.f;
251  float c2[n];
252  c2[0] = 0.f;
253  float c3[n];
254  c3[0] = 0.f;
255  float c4[n];
256  c4[0] = 0.f;
257  float s[n];
258  s[0] = 0.f;
259  float c[n];
260  c[0] = 0.f;
261  float xf1[n];
262  xf1[0] = 0.f;
263  float xf2[n];
264  xf2[0] = 0.f;
265  for (k = 1; k < n; ++k) {
266  x[k] = omega_ * k;
267  x1[k] = h6 * x[k];
268  }
269  for (k = 1; k < n; ++k) {
270  VVIObjFDetails::sincosint(x1[k], c2[k], c1[k]);
271  }
272  for (k = 1; k < n; ++k) {
273  c1[k] = vdt::fast_logf(x[k]) - c1[k];
274  }
275  for (k = 1; k < n; ++k) {
276  vdt::fast_sincosf(x1[k], c3[k], c4[k]);
277  xf1[k] = kappa * (c1[k] - c4[k]) - x[k] * c2[k];
278  xf2[k] = x[k] * c1[k] + kappa * (c3[k] + c2[k]) + t0_ * x[k];
279  }
280  for (k = 1; k < n; ++k) {
281  vdt::fast_sincosf(xf2[k], s[k], c[k]);
282  }
283  float d1[n];
284  d1[0] = 0.f;
285  for (k = 1; k < n; ++k) {
286  d1[k] = q * d * vdt::fast_expf(xf1[k]) / k;
287  q = -q;
288  }
289  for (k = 1; k < n; ++k) {
290  l = n - k;
291  a_[l - 1] = d1[k] * s[k];
292  }
293  for (k = 1; k < n; ++k) {
294  l = n - k;
295  b_[l - 1] = d1[k] * c[k];
296  }
297  for (k = 1; k < n; ++k) {
298  l = n - k;
299  a_[n - 1] += q2 * a_[l - 1];
300  q2 = -q2;
301  }
302 
303 } // VVIObjF with kappa only
float omega_
Definition: VVIObjF.h:40
float t1_
Definition: VVIObjF.h:38
const int mode_
returns the limits on the non-zero (mode=0) or normalized region (mode=1)
Definition: VVIObjF.h:36
void sincosint(float x, float &sint, float &cint)
Definition: VVIObjF.cc:370
float x0_
Definition: VVIObjF.h:41
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
int dzero(float a, float b, float &x0, float &rv, float eps, int mxf, F func)
Private version of the exponential integral.
Definition: VVIObjF.cc:518
float t0_
Definition: VVIObjF.h:37
d
Definition: ztail.py:151
float expint(float x)
Private version of the cosine and sine integral.
Definition: VVIObjF.cc:372
float b_[155]
Definition: VVIObjF.h:43
float fast_expf(float x)
static constexpr float d1
float fast_logf(float x)
float t_
Definition: VVIObjF.h:39
float a_[155]
Definition: VVIObjF.h:42

Member Function Documentation

◆ fcn()

float VVIObjF::fcn ( float  x) const

Vavilov function method Returns density fcn (mode=0) or distribution fcn (mode=1)

Parameters
x- (input) Argument of function [typically defined as (Q-mpv)/sigma]

Definition at line 311 of file VVIObjF.cc.

References a0, testProducerWithPsetDescEmpty_cfi::a2, a_, b0, b1, b2, b_, f, dqmdumpme::k, mode_, dqmiodumpmetadata::n, omega_, t0_, t1_, t_, x, x0_, and y.

Referenced by SiPixelTemplateReco::PixelTempReco1D(), and SiPixelTemplateReco2D::PixelTempReco2D().

311  {
312  // Local variables
313 
314  float f, u, y, a0, a1;
315  float a2 = 0.;
316  float b1, b0, b2, cof;
317  int k, n, n1;
318 
319  n = x0_;
320  if (x < t0_) {
321  f = 0.f;
322  } else if (x <= t1_) {
323  y = x - t0_;
324  u = omega_ * y - 3.141592653589793f;
325  float su, cu;
326  vdt::fast_sincosf(u, su, cu);
327  cof = cu * 2.f;
328  a1 = 0.;
329  a0 = a_[0];
330  n1 = n + 1;
331  for (k = 2; k <= n1; ++k) {
332  a2 = a1;
333  a1 = a0;
334  a0 = a_[k - 1] + cof * a1 - a2;
335  }
336  b1 = 0.;
337  b0 = b_[0];
338  for (k = 2; k <= n; ++k) {
339  b2 = b1;
340  b1 = b0;
341  b0 = b_[k - 1] + cof * b1 - b2;
342  }
343  f = (a0 - a2) * .5f + b0 * su;
344  if (mode_ != 0) {
345  f += y / t_;
346  }
347  } else {
348  f = 0.f;
349  if (mode_ != 0) {
350  f = 1.f;
351  }
352  }
353  return f;
354 } // fcn
weight_default_t b1[25]
Definition: b1.h:9
float omega_
Definition: VVIObjF.h:40
float t1_
Definition: VVIObjF.h:38
const int mode_
returns the limits on the non-zero (mode=0) or normalized region (mode=1)
Definition: VVIObjF.h:36
float x0_
Definition: VVIObjF.h:41
double f[11][100]
weight_default_t b2[10]
Definition: b2.h:9
float t0_
Definition: VVIObjF.h:37
float b_[155]
Definition: VVIObjF.h:43
static constexpr float a0
static constexpr float b0
float t_
Definition: VVIObjF.h:39
float a_[155]
Definition: VVIObjF.h:42

◆ limits()

void VVIObjF::limits ( float &  xl,
float &  xu 
) const

density (mode=0) or distribution (mode=1) function

Vavilov limits method

Parameters
xl- (output) Smallest value of the argument for the density and the beginning of the normalized region for the distribution
xu- (output) Largest value of the argument for the density and the end of the normalized region for the distribution

Definition at line 362 of file VVIObjF.cc.

References t0_, and t1_.

362  {
363  xl = t0_;
364  xu = t1_;
365  return;
366 } // limits
float t1_
Definition: VVIObjF.h:38
float t0_
Definition: VVIObjF.h:37

Member Data Documentation

◆ a_

float VVIObjF::a_[155]
private

Definition at line 42 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

◆ b_

float VVIObjF::b_[155]
private

Definition at line 43 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

◆ mode_

const int VVIObjF::mode_
private

returns the limits on the non-zero (mode=0) or normalized region (mode=1)

set to 0 to calculate the density function and to 1 to calculate the distribution function

Definition at line 36 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

◆ omega_

float VVIObjF::omega_
private

Definition at line 40 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

◆ t0_

float VVIObjF::t0_
private

Definition at line 37 of file VVIObjF.h.

Referenced by fcn(), limits(), and VVIObjF().

◆ t1_

float VVIObjF::t1_
private

Definition at line 38 of file VVIObjF.h.

Referenced by fcn(), limits(), and VVIObjF().

◆ t_

float VVIObjF::t_
private

Definition at line 39 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

◆ x0_

float VVIObjF::x0_
private

Definition at line 41 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().