CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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=0.01, float beta2=1., int mode=0)
 Constructor. 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 24 of file VVIObjF.h.

Constructor & Destructor Documentation

VVIObjF::VVIObjF ( float  kappa = 0.01,
float  beta2 = 1.,
int  mode = 0 
)

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 41 of file VVIObjF.cc.

References a_, funct::abs(), b_, c, alignmentValidation::c1, ztail::d, d1, VVIObjFDetails::dzero(), alignCSCRings::e, VVIObjFDetails::expint(), validate-o2o-wbm::f, validate-o2o-wbm::f1, validate-o2o-wbm::f2, myMath::fast_expf(), myMath::fast_logf(), isotrackApplyRegressor::k, cmsLHEtoEOSManager::l, mode_, dqmiodumpmetadata::n, omega_, submitPVResolutionJobs::q, alignCSCRings::s, VVIObjFDetails::sincosint(), t0_, t1_, t_, x, and x0_.

41  : mode_(mode) {
42  const float xp[9] = {9.29, 2.47, .89, .36, .15, .07, .03, .02, 0.0};
43  const float xq[7] = {.012, .03, .08, .26, .87, 3.83, 11.0};
44  float h_[7];
45  float q, u, x, c1, c2, c3, c4, d1, h4, h5, h6, q2, x1, d, ll, ul, xf1, xf2, rv;
46  int lp, lq, k, l, n;
47 
48  // Make sure that the inputs are reasonable
49 
50  if (kappa < 0.01f)
51  kappa = 0.01f;
52  if (kappa > 10.f)
53  kappa = 10.f;
54  if (beta2 < 0.f)
55  beta2 = 0.f;
56  if (beta2 > 1.f)
57  beta2 = 1.f;
58 
59  float invKappa = 1.f / kappa;
60  h_[4] = 1.f - beta2 * 0.42278433999999998f + (7.6f * invKappa);
61  h_[5] = beta2;
62  h_[6] = 1.f - beta2;
63  h4 = -(7.6f * invKappa) - (beta2 * .57721566f + 1.f);
64  h5 = vdt::fast_logf(kappa);
65  h6 = invKappa;
66  t0_ = (h4 - h_[4] * h5 - (h_[4] + beta2) * (vdt::fast_logf(h_[4]) + VVIObjFDetails::expint(h_[4])) +
67  vdt::fast_expf(-h_[4])) /
68  h_[4];
69 
70  // Set up limits for the root search
71 
72  for (lp = 0; lp < 9; ++lp) {
73  if (kappa >= xp[lp])
74  break;
75  }
76  ll = -float(lp) - 1.5f;
77  for (lq = 0; lq < 7; ++lq) {
78  if (kappa <= xq[lq])
79  break;
80  }
81  ul = lq - 6.5f;
82  auto f2 = [h_](float x) {
83  return h_[4] - x + h_[5] * (vdt::fast_logf(std::abs(x)) + VVIObjFDetails::expint(x)) - h_[6] * vdt::fast_expf(-x);
84  };
85  VVIObjFDetails::dzero(ll, ul, u, rv, 1.e-3f, 100, f2);
86  q = 1. / u;
87  t1_ = h4 * q - h5 - (beta2 * q + 1.f) * (vdt::fast_logf((fabs(u))) + VVIObjFDetails::expint(u)) +
88  vdt::fast_expf(-u) * q;
89  t_ = t1_ - t0_;
90  omega_ = 6.2831853000000004f / t_;
91  h_[0] = kappa * (beta2 * .57721566f + 2.f) + 9.9166128600000008f;
92  if (kappa >= .07) {
93  h_[0] += 6.90775527f;
94  }
95  h_[1] = beta2 * kappa;
96  h_[2] = h6 * omega_;
97  h_[3] = omega_ * 1.5707963250000001f;
98  auto f1 = [h_](float x) { return h_[0] + h_[1] * vdt::fast_logf(h_[2] * x) - h_[3] * x; };
99  VVIObjFDetails::dzero(5.f, 155.f, x0_, rv, 1.e-3f, 100, f1);
100  n = x0_ + 1.;
101  d = vdt::fast_expf(kappa * (beta2 * (.57721566f - h5) + 1.f)) * .31830988654751274f;
102  a_[n - 1] = 0.f;
103  if (mode_ == 0) {
104  a_[n - 1] = omega_ * .31830988654751274f;
105  }
106  q = -1.;
107  q2 = 2.;
108  for (k = 1; k < n; ++k) {
109  l = n - k;
110  x = omega_ * k;
111  x1 = h6 * x;
112  VVIObjFDetails::sincosint(x1, c2, c1);
113  c1 = vdt::fast_logf(x) - c1;
114  vdt::fast_sincosf(x1, c3, c4);
115  xf1 = kappa * (beta2 * c1 - c4) - x * c2;
116  xf2 = x * c1 + kappa * (c3 + beta2 * c2) + t0_ * x;
117  float s, c;
118  vdt::fast_sincosf(xf2, s, c);
119  if (mode_ == 0) {
120  d1 = q * d * omega_ * vdt::fast_expf(xf1);
121  a_[l - 1] = d1 * c;
122  b_[l - 1] = -d1 * s;
123  } else {
124  d1 = q * d * vdt::fast_expf(xf1) / k;
125  a_[l - 1] = d1 * s;
126  b_[l - 1] = d1 * c;
127  a_[n - 1] += q2 * a_[l - 1];
128  }
129  q = -q;
130  q2 = -q2;
131  }
132 
133 } // VVIObjF
float omega_
Definition: VVIObjF.h:39
const edm::EventSetup & c
float t1_
Definition: VVIObjF.h:37
tuple d
Definition: ztail.py:151
const int mode_
returns the limits on the non-zero (mode=0) or normalized region (mode=1)
Definition: VVIObjF.h:35
void sincosint(float x, float &sint, float &cint)
Definition: VVIObjF.cc:200
float x0_
Definition: VVIObjF.h:40
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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:348
float t0_
Definition: VVIObjF.h:36
float expint(float x)
Private version of the cosine and sine integral.
Definition: VVIObjF.cc:202
float b_[155]
Definition: VVIObjF.h:42
float fast_expf(float x)
static constexpr float d1
float fast_logf(float x)
float t_
Definition: VVIObjF.h:38
float a_[155]
Definition: VVIObjF.h:41

Member Function Documentation

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 141 of file VVIObjF.cc.

References a0, isotrackTrainRegressor::a1, isotrackTrainRegressor::a2, a_, b0, b1, b2, b_, validate-o2o-wbm::f, isotrackApplyRegressor::k, mode_, dqmiodumpmetadata::n, omega_, t0_, t1_, t_, x0_, and y.

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

141  {
142  // Local variables
143 
144  float f, u, y, a0, a1;
145  float a2 = 0.;
146  float b1, b0, b2, cof;
147  int k, n, n1;
148 
149  n = x0_;
150  if (x < t0_) {
151  f = 0.f;
152  } else if (x <= t1_) {
153  y = x - t0_;
154  u = omega_ * y - 3.141592653589793f;
155  float su, cu;
156  vdt::fast_sincosf(u, su, cu);
157  cof = cu * 2.f;
158  a1 = 0.;
159  a0 = a_[0];
160  n1 = n + 1;
161  for (k = 2; k <= n1; ++k) {
162  a2 = a1;
163  a1 = a0;
164  a0 = a_[k - 1] + cof * a1 - a2;
165  }
166  b1 = 0.;
167  b0 = b_[0];
168  for (k = 2; k <= n; ++k) {
169  b2 = b1;
170  b1 = b0;
171  b0 = b_[k - 1] + cof * b1 - b2;
172  }
173  f = (a0 - a2) * .5f + b0 * su;
174  if (mode_ != 0) {
175  f += y / t_;
176  }
177  } else {
178  f = 0.f;
179  if (mode_ != 0) {
180  f = 1.f;
181  }
182  }
183  return f;
184 } // fcn
float omega_
Definition: VVIObjF.h:39
float t1_
Definition: VVIObjF.h:37
const int mode_
returns the limits on the non-zero (mode=0) or normalized region (mode=1)
Definition: VVIObjF.h:35
float x0_
Definition: VVIObjF.h:40
float t0_
Definition: VVIObjF.h:36
float b_[155]
Definition: VVIObjF.h:42
static constexpr float a0
static constexpr float b2
static constexpr float b0
float t_
Definition: VVIObjF.h:38
static constexpr float b1
float a_[155]
Definition: VVIObjF.h:41
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 192 of file VVIObjF.cc.

References t0_, and t1_.

192  {
193  xl = t0_;
194  xu = t1_;
195  return;
196 } // limits
float t1_
Definition: VVIObjF.h:37
float t0_
Definition: VVIObjF.h:36

Member Data Documentation

float VVIObjF::a_[155]
private

Definition at line 41 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

float VVIObjF::b_[155]
private

Definition at line 42 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

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 35 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

float VVIObjF::omega_
private

Definition at line 39 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

float VVIObjF::t0_
private

Definition at line 36 of file VVIObjF.h.

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

float VVIObjF::t1_
private

Definition at line 37 of file VVIObjF.h.

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

float VVIObjF::t_
private

Definition at line 38 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().

float VVIObjF::x0_
private

Definition at line 40 of file VVIObjF.h.

Referenced by fcn(), and VVIObjF().