CMS 3D CMS Logo

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 159 of file HDQMfitUtilities.cc.

Referenced by HDQMfitUtilities::doGaussFit().

159  {
160  // The noise function: a gaussian
161 
162  double arg = 0;
163  if (par[2])
164  arg = (x[0] - par[1]) / par[2];
165 
166  double noise = par[0] * TMath::Exp(-0.5 * arg * arg);
167  return noise;
168  }
A arg
Definition: Factorize.h:38
double HDQMUtil::langaufun ( double *  x,
double *  par 
)

Definition at line 5 of file HDQMfitUtilities.cc.

References mps_fire::i, np, SimDataFormats::CaloAnalysis::sc, and geometryCSVtoXML::xx.

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  // MP shift correction
35  mpc = par[1] - mpshift * par[0];
36 
37  // Range of convolution integral
38  xlow = x[0] - sc * par[3];
39  xupp = x[0] + sc * par[3];
40 
41  step = (xupp - xlow) / np;
42 
43  // Landau Distribution Production
44  for (i = 1.0; i <= np / 2; i++) {
45  xx = xlow + (i - .5) * step;
46  fland = TMath::Landau(xx, mpc, par[0]) / par[0];
47  sum += fland * TMath::Gaus(x[0], xx, par[3]);
48 
49  xx = xupp - (i - .5) * step;
50  fland = TMath::Landau(xx, mpc, par[0]) / par[0];
51  sum += fland * TMath::Gaus(x[0], xx, par[3]);
52  }
53 
54  return (par[2] * step * sum * invsq2pi / par[3]);
55  }
int np
Definition: AMPTWrapper.h:33
step
Definition: StallMonitor.cc:94
int32_t HDQMUtil::langaupro ( double *  params,
double &  maxx,
double &  FWHM 
)

Definition at line 58 of file HDQMfitUtilities.cc.

References Abs(), MillePedeFileConverter_cfg::e, mps_fire::i, checklumidiff::l, langaufun(), and AlCaHLTBitMon_ParallelJobs::p.

Referenced by MuonTestSummary::doEnergyTests(), and HDQMfitUtilities::doLanGaussFit().

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