CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
HDQMUtil Namespace Reference

Functions

double Gauss (double *x, double *par)
 
double langaufun (double *x, double *par)
 
int32_t langaupro (double *params, double &maxx, double &FWHM)
 

Detailed Description

@ class HDQMfitUtilities @ fit Landau distributions to historic monitoring elements @ fits from Susy's analysis (DQM/SiStripHistoricInfoClient/test/TrendsWithFits)

Function Documentation

double HDQMUtil::Gauss ( double *  x,
double *  par 
)

Definition at line 164 of file HDQMfitUtilities.cc.

Referenced by HDQMfitUtilities::doGaussFit().

165  {
166  // The noise function: a gaussian
167 
168  double arg = 0;
169  if (par[2]) arg = (x[0] - par[1])/par[2];
170 
171  double noise = par[0]*TMath::Exp(-0.5*arg*arg);
172  return noise;
173  }
A arg
Definition: Factorize.h:36
Definition: DDAxes.h:10
double HDQMUtil::langaufun ( double *  x,
double *  par 
)

Definition at line 5 of file HDQMfitUtilities.cc.

References i, np, and relval_parameters_module::step.

Referenced by HDQMfitUtilities::doLanGaussFit(), and langaupro().

5  {
6  //Fit parameters:
7  //par[0]=Width (scale) parameter of Landau density
8  //par[1]=Most Probable (MP, location) parameter of Landau density
9  //par[2]=Total area (integral -inf to inf, normalization constant)
10  //par[3]=Width (sigma) of convoluted Gaussian function
11  //
12  //In the Landau distribution (represented by the CERNLIB approximation),
13  //the maximum is located at x=-0.22278298 with the location parameter=0.
14  //This shift is corrected within this function, so that the actual
15  //maximum is identical to the MP parameter.
16 
17  // Numeric constants
18  double invsq2pi = 0.3989422804014; // (2 pi)^(-1/2)
19  double mpshift = -0.22278298; // Landau maximum location
20 
21  // Control constants
22  double np = 100.0; // number of convolution steps
23  double sc = 5.0; // convolution extends to +-sc Gaussian sigmas
24 
25  // Variables
26  double xx;
27  double mpc;
28  double fland;
29  double sum = 0.0;
30  double xlow,xupp;
31  double step;
32  double i;
33 
34 
35  // MP shift correction
36  mpc = par[1] - mpshift * par[0];
37 
38  // Range of convolution integral
39  xlow = x[0] - sc * par[3];
40  xupp = x[0] + sc * par[3];
41 
42  step = (xupp-xlow) / np;
43 
44  // Landau Distribution Production
45  for(i=1.0; i<=np/2; i++) {
46  xx = xlow + (i-.5) * step;
47  fland = TMath::Landau(xx,mpc,par[0]) / par[0];
48  sum += fland * TMath::Gaus(x[0],xx,par[3]);
49 
50  xx = xupp - (i-.5) * step;
51  fland = TMath::Landau(xx,mpc,par[0]) / par[0];
52  sum += fland * TMath::Gaus(x[0],xx,par[3]);
53  }
54 
55  return (par[2] * step * sum * invsq2pi / par[3]);
56  }
int i
Definition: DBlmapReader.cc:9
int np
Definition: AMPTWrapper.h:33
Definition: DDAxes.h:10
int32_t HDQMUtil::langaupro ( double *  params,
double &  maxx,
double &  FWHM 
)

Definition at line 59 of file HDQMfitUtilities.cc.

References Abs(), alignCSCRings::e, i, prof2calltree::l, langaufun(), AlCaHLTBitMon_ParallelJobs::p, relval_parameters_module::step, and x.

Referenced by HDQMfitUtilities::doLanGaussFit().

59  {
60  edm::LogInfo("fitUtility") << "inside langaupro " << std::endl;
61  // Seaches for the location (x value) at the maximum of the
62  // Landau and its full width at half-maximum.
63  //
64  // The search is probably not very efficient, but it's a first try.
65 
66  double p,x,fy,fxr,fxl;
67  double step;
68  double l,lold,dl;
69  int32_t i = 0;
70  const int32_t MAXCALLS = 10000;
71  const double dlStop = 1e-3; // relative change < .001
72 
73  // Search for maximum
74  p = params[1] - 0.1 * params[0];
75  step = 0.05 * params[0];
76  lold = -2.0;
77  l = -1.0;
78 
79  dl = (l-lold)/lold; // FIXME catch divide by zero
80  while ( (TMath::Abs(dl)>dlStop ) && (i < MAXCALLS) ) {
81  i++;
82 
83  lold = l;
84  x = p + step;
85  l = langaufun(&x,params);
86  dl = (l-lold)/lold; // FIXME catch divide by zero
87 
88  if (l < lold)
89  step = -step/10;
90 
91  p += step;
92  }
93 
94  if (i == MAXCALLS)
95  return (-1);
96 
97  maxx = x;
98 
99  fy = l/2;
100 
101 
102  // Search for right x location of fy
103  p = maxx + params[0];
104  step = params[0];
105  lold = -2.0;
106  l = -1e300;
107  i = 0;
108 
109  dl = (l-lold)/lold; // FIXME catch divide by zero
110  while ( ( TMath::Abs(dl)>dlStop ) && (i < MAXCALLS) ) {
111  i++;
112 
113  lold = l;
114  x = p + step;
115  l = TMath::Abs(langaufun(&x,params) - fy);
116  dl = (l-lold)/lold; // FIXME catch divide by zero
117 
118  if (l > lold)
119  step = -step/10;
120 
121  p += step;
122  }
123 
124  if (i == MAXCALLS)
125  return (-2);
126 
127  fxr = x;
128 
129 
130  // Search for left x location of fy
131  p = maxx - 0.5 * params[0];
132  step = -params[0];
133  lold = -2.0;
134  l = -1e300;
135  i = 0;
136 
137  dl = (l-lold)/lold; // FIXME catch divide by zero
138  while ( ( TMath::Abs(dl)>dlStop ) && (i < MAXCALLS) ) {
139  i++;
140 
141  lold = l;
142  x = p + step;
143  l = TMath::Abs(langaufun(&x,params) - fy);
144  dl = (l-lold)/lold; // FIXME catch divide by zero
145 
146  if (l > lold)
147  step = -step/10;
148 
149  p += step;
150  }
151 
152  if (i == MAXCALLS)
153  return (-3);
154 
155 
156  fxl = x;
157 
158  FWHM = fxr - fxl;
159  return (0);
160  }
int i
Definition: DBlmapReader.cc:9
T Abs(T a)
Definition: MathUtil.h:49
Definition: DDAxes.h:10
Double_t langaufun(Double_t *x, Double_t *par)