CMS 3D CMS Logo

Functions | Variables
MuonResidualsFitter.cc File Reference
#include "Alignment/MuonAlignmentAlgorithms/interface/MuonResidualsFitter.h"
#include <fstream>
#include <set>
#include "TMath.h"
#include "TH1.h"
#include "TF1.h"
#include "TRobustEstimator.h"

Go to the source code of this file.

Functions

double MuonResidualsFitter_compute_log_convolution (double toversigma, double gammaoversigma, double max, double step, double power)
 
Double_t MuonResidualsFitter_GaussPowerTails_TF1 (Double_t *xvec, Double_t *par)
 
double MuonResidualsFitter_integrate_pureGaussian (double low, double high, double center, double sigma)
 
double MuonResidualsFitter_logGaussPowerTails (double residual, double center, double sigma)
 
double MuonResidualsFitter_logPowerLawTails (double residual, double center, double sigma, double gamma)
 
double MuonResidualsFitter_logPureGaussian (double residual, double center, double sigma)
 
double MuonResidualsFitter_logPureGaussian2D (double x, double y, double x0, double y0, double sx, double sy, double r)
 
double MuonResidualsFitter_logROOTVoigt (double residual, double center, double sigma, double gamma)
 
Double_t MuonResidualsFitter_powerLawTails_TF1 (Double_t *xvec, Double_t *par)
 
Double_t MuonResidualsFitter_pureGaussian_TF1 (Double_t *xvec, Double_t *par)
 
Double_t MuonResidualsFitter_ROOTVoigt_TF1 (Double_t *xvec, Double_t *par)
 

Variables

const double MuonResidualsFitter_gsbinsize = 0.01
 
double MuonResidualsFitter_lookup_table [MuonResidualsFitter_numgsbins][MuonResidualsFitter_numtsbins]
 
const int MuonResidualsFitter_numgsbins = 500
 
const int MuonResidualsFitter_numtsbins = 500
 
bool MuonResidualsFitter_table_initialized = false
 
static TMinuit * MuonResidualsFitter_TMinuit
 
const double MuonResidualsFitter_tsbinsize = 0.1
 

Function Documentation

◆ MuonResidualsFitter_compute_log_convolution()

double MuonResidualsFitter_compute_log_convolution ( double  toversigma,
double  gammaoversigma,
double  max,
double  step,
double  power 
)

Definition at line 54 of file MuonResidualsFitter.cc.

References JetChargeProducer_cfi::exp, dqm-mbProfile::log, M_PI, SiStripPI::max, conifer::pow(), cms::alpakatools::detail::power(), and mathSSE::sqrt().

Referenced by MuonResidualsFitter::initialize_table().

55  {
56  if (gammaoversigma == 0.)
57  return (-toversigma * toversigma / 2.) - log(sqrt(2 * M_PI));
58 
59  double sum = 0.;
60  double uplus = 0.;
61  double integrandplus_last = 0.;
62  double integrandminus_last = 0.;
63  for (double inc = 0.; uplus < max; inc += step) {
64  double uplus_last = uplus;
65  uplus = pow(inc, power);
66 
67  double integrandplus = exp(-pow(uplus - toversigma, 2) / 2.) / (uplus * uplus / gammaoversigma + gammaoversigma) /
68  M_PI / sqrt(2. * M_PI);
69  double integrandminus = exp(-pow(-uplus - toversigma, 2) / 2.) / (uplus * uplus / gammaoversigma + gammaoversigma) /
70  M_PI / sqrt(2. * M_PI);
71 
72  sum += integrandplus * (uplus - uplus_last);
73  sum += 0.5 * fabs(integrandplus_last - integrandplus) * (uplus - uplus_last);
74 
75  sum += integrandminus * (uplus - uplus_last);
76  sum += 0.5 * fabs(integrandminus_last - integrandminus) * (uplus - uplus_last);
77 
78  integrandplus_last = integrandplus;
79  integrandminus_last = integrandminus;
80  }
81  return log(sum);
82 }
constexpr int pow(int x)
Definition: conifer.h:24
T sqrt(T t)
Definition: SSEVec.h:19
#define M_PI
constexpr unsigned int power(unsigned int base, unsigned int exponent)
step
Definition: StallMonitor.cc:83

◆ MuonResidualsFitter_GaussPowerTails_TF1()

Double_t MuonResidualsFitter_GaussPowerTails_TF1 ( Double_t *  xvec,
Double_t *  par 
)

◆ MuonResidualsFitter_integrate_pureGaussian()

double MuonResidualsFitter_integrate_pureGaussian ( double  low,
double  high,
double  center,
double  sigma 
)

Definition at line 146 of file MuonResidualsFitter.cc.

References JetChargeProducer_cfi::exp, LaserClient_cfi::high, LaserClient_cfi::low, and mathSSE::sqrt().

146  {
147  static const double isqr2 = 1. / sqrt(2.);
148  return (erf((high + center) * isqr2 / sigma) - erf((low + center) * isqr2 / sigma)) * exp(0.5 / sigma / sigma) * 0.5;
149 }
T sqrt(T t)
Definition: SSEVec.h:19

◆ MuonResidualsFitter_logGaussPowerTails()

double MuonResidualsFitter_logGaussPowerTails ( double  residual,
double  center,
double  sigma 
)

Definition at line 128 of file MuonResidualsFitter.cc.

References a, JetChargeProducer_cfi::exp, dqm-mbProfile::log, visualization-live-secondInstance_cfg::m, M_PI, dqmiodumpmetadata::n, conifer::pow(), alignCSCRings::s, mathSSE::sqrt(), and x.

Referenced by MuonResiduals1DOFFitter_FCN(), MuonResiduals5DOFFitter_FCN(), MuonResiduals6DOFFitter_FCN(), MuonResiduals6DOFrphiFitter_FCN(), MuonResidualsAngleFitter_FCN(), MuonResidualsBfieldAngleFitter_FCN(), MuonResidualsFitter_GaussPowerTails_TF1(), and MuonResidualsPositionFitter_FCN().

128  {
129  double x = residual - center;
130  double s = fabs(sigma);
131  double m = 2. * s;
132  static const double e2 = exp(-2.), sqerf = sqrt(2. * M_PI) * erf(sqrt(2.));
133  double a = pow(m, 4) * e2;
134  double n = sqerf * s + 2. * a * pow(m, -3) / 3.;
135 
136  if (fabs(x) < m)
137  return -x * x / (2. * s * s) - log(n);
138  else
139  return log(a) - 4. * log(fabs(x)) - log(n);
140 }
constexpr int pow(int x)
Definition: conifer.h:24
T sqrt(T t)
Definition: SSEVec.h:19
#define M_PI
double a
Definition: hdecay.h:121
float x

◆ MuonResidualsFitter_logPowerLawTails()

double MuonResidualsFitter_logPowerLawTails ( double  residual,
double  center,
double  sigma,
double  gamma 
)

Definition at line 85 of file MuonResidualsFitter.cc.

References reco::ceil(), CustomPhysics_cfi::gamma, createfilelist::int, dqm-mbProfile::log, M_PI, MuonResidualsFitter_gsbinsize, MuonResidualsFitter_lookup_table, MuonResidualsFitter_numgsbins, MuonResidualsFitter_numtsbins, MuonResidualsFitter_tsbinsize, and heppy_batch::val.

Referenced by MuonResiduals1DOFFitter_FCN(), MuonResiduals5DOFFitter_FCN(), MuonResiduals6DOFFitter_FCN(), MuonResiduals6DOFrphiFitter_FCN(), MuonResidualsAngleFitter_FCN(), MuonResidualsBfieldAngleFitter_FCN(), MuonResidualsFitter_powerLawTails_TF1(), and MuonResidualsPositionFitter_FCN().

85  {
86  sigma = fabs(sigma);
87  double gammaoversigma = fabs(gamma / sigma);
88  double toversigma = fabs((residual - center) / sigma);
89 
90  int gsbin0 = int(floor(gammaoversigma / MuonResidualsFitter_gsbinsize));
91  int gsbin1 = int(ceil(gammaoversigma / MuonResidualsFitter_gsbinsize));
92  int tsbin0 = int(floor(toversigma / MuonResidualsFitter_tsbinsize));
93  int tsbin1 = int(ceil(toversigma / MuonResidualsFitter_tsbinsize));
94 
95  bool gsisbad = (gsbin0 >= MuonResidualsFitter_numgsbins || gsbin1 >= MuonResidualsFitter_numgsbins);
96  bool tsisbad = (tsbin0 >= MuonResidualsFitter_numtsbins || tsbin1 >= MuonResidualsFitter_numtsbins);
97 
98  if (gsisbad || tsisbad) {
99  return log(gammaoversigma / M_PI) - log(toversigma * toversigma + gammaoversigma * gammaoversigma) - log(sigma);
100  } else {
101  double val00 = MuonResidualsFitter_lookup_table[gsbin0][tsbin0];
102  double val01 = MuonResidualsFitter_lookup_table[gsbin0][tsbin1];
103  double val10 = MuonResidualsFitter_lookup_table[gsbin1][tsbin0];
104  double val11 = MuonResidualsFitter_lookup_table[gsbin1][tsbin1];
105 
106  double val0 = val00 + ((toversigma / MuonResidualsFitter_tsbinsize) - tsbin0) * (val01 - val00);
107  double val1 = val10 + ((toversigma / MuonResidualsFitter_tsbinsize) - tsbin0) * (val11 - val10);
108 
109  double val = val0 + ((gammaoversigma / MuonResidualsFitter_gsbinsize) - gsbin0) * (val1 - val0);
110 
111  return val - log(sigma);
112  }
113 }
constexpr int32_t ceil(float num)
const int MuonResidualsFitter_numgsbins
const int MuonResidualsFitter_numtsbins
const double MuonResidualsFitter_gsbinsize
const double MuonResidualsFitter_tsbinsize
#define M_PI
double MuonResidualsFitter_lookup_table[MuonResidualsFitter_numgsbins][MuonResidualsFitter_numtsbins]

◆ MuonResidualsFitter_logPureGaussian()

double MuonResidualsFitter_logPureGaussian ( double  residual,
double  center,
double  sigma 
)

Definition at line 31 of file MuonResidualsFitter.cc.

References dqm-mbProfile::log, M_PI, and conifer::pow().

Referenced by MuonResiduals1DOFFitter_FCN(), MuonResiduals5DOFFitter_FCN(), MuonResiduals6DOFFitter_FCN(), MuonResiduals6DOFrphiFitter_FCN(), MuonResidualsAngleFitter_FCN(), MuonResidualsBfieldAngleFitter_FCN(), MuonResidualsFitter_pureGaussian_TF1(), and MuonResidualsPositionFitter_FCN().

31  {
32  sigma = fabs(sigma);
33  static const double cgaus = 0.5 * log(2. * M_PI);
34  return (-pow(residual - center, 2) * 0.5 / sigma / sigma) - cgaus - log(sigma);
35 }
constexpr int pow(int x)
Definition: conifer.h:24
#define M_PI

◆ MuonResidualsFitter_logPureGaussian2D()

double MuonResidualsFitter_logPureGaussian2D ( double  x,
double  y,
double  x0,
double  y0,
double  sx,
double  sy,
double  r 
)

Definition at line 43 of file MuonResidualsFitter.cc.

References PVValHelper::dx, PVValHelper::dy, dqm-mbProfile::log, M_PI, conifer::pow(), alignCSCRings::r, mathSSE::sqrt(), fftjetcommon_cfi::sx, fftjetcommon_cfi::sy, x, and detailsBasic3DVector::y.

Referenced by MuonResiduals5DOFFitter_FCN(), MuonResiduals6DOFFitter_FCN(), and MuonResiduals6DOFrphiFitter_FCN().

43  {
44  sx = fabs(sx);
45  sy = fabs(sy);
46  static const double c2gaus = log(2. * M_PI);
47  double one_r2 = 1. - r * r;
48  double dx = x - x0;
49  double dy = y - y0;
50  return -0.5 / one_r2 * (pow(dx / sx, 2) + pow(dy / sy, 2) - 2. * r * dx / sx * dy / sy) - c2gaus -
51  log(sx * sy * sqrt(one_r2));
52 }
constexpr int pow(int x)
Definition: conifer.h:24
T sqrt(T t)
Definition: SSEVec.h:19
#define M_PI
float x

◆ MuonResidualsFitter_logROOTVoigt()

double MuonResidualsFitter_logROOTVoigt ( double  residual,
double  center,
double  sigma,
double  gamma 
)

◆ MuonResidualsFitter_powerLawTails_TF1()

Double_t MuonResidualsFitter_powerLawTails_TF1 ( Double_t *  xvec,
Double_t *  par 
)

◆ MuonResidualsFitter_pureGaussian_TF1()

Double_t MuonResidualsFitter_pureGaussian_TF1 ( Double_t *  xvec,
Double_t *  par 
)

◆ MuonResidualsFitter_ROOTVoigt_TF1()

Double_t MuonResidualsFitter_ROOTVoigt_TF1 ( Double_t *  xvec,
Double_t *  par 
)

Variable Documentation

◆ MuonResidualsFitter_gsbinsize

const double MuonResidualsFitter_gsbinsize = 0.01

◆ MuonResidualsFitter_lookup_table

double MuonResidualsFitter_lookup_table[MuonResidualsFitter_numgsbins][MuonResidualsFitter_numtsbins]

◆ MuonResidualsFitter_numgsbins

const int MuonResidualsFitter_numgsbins = 500

◆ MuonResidualsFitter_numtsbins

const int MuonResidualsFitter_numtsbins = 500

◆ MuonResidualsFitter_table_initialized

bool MuonResidualsFitter_table_initialized = false

Definition at line 25 of file MuonResidualsFitter.cc.

Referenced by MuonResidualsFitter::initialize_table().

◆ MuonResidualsFitter_TMinuit

TMinuit* MuonResidualsFitter_TMinuit
static

Definition at line 28 of file MuonResidualsFitter.cc.

Referenced by MuonResidualsFitter::dofit().

◆ MuonResidualsFitter_tsbinsize

const double MuonResidualsFitter_tsbinsize = 0.1