CMS 3D CMS Logo

Classes | Functions
MuonResidualsFitter.h File Reference
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "Alignment/CommonAlignment/interface/Alignable.h"
#include "TMinuit.h"
#include "TH1F.h"
#include "TProfile.h"
#include "TF1.h"
#include "TMath.h"
#include "TRandom3.h"
#include "TMatrixDSym.h"
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <map>

Go to the source code of this file.

Classes

struct  MuonResidualsFitter::MuonAlignmentTreeRow
 
class  MuonResidualsFitter
 
class  MuonResidualsFitterFitInfo
 

Functions

void MuonResidualsAngleFitter_FCN (int &npar, double *gin, double &fval, double *par, int iflag)
 
double MuonResidualsFitter_compute_log_convolution (double toversigma, double gammaoversigma, double max=1000., double step=0.001, double power=4.)
 
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)
 
void MuonResidualsPositionFitter_FCN (int &npar, double *gin, double &fval, double *par, int iflag)
 

Function Documentation

◆ MuonResidualsAngleFitter_FCN()

void MuonResidualsAngleFitter_FCN ( int &  npar,
double *  gin,
double &  fval,
double *  par,
int  iflag 
)

Definition at line 7 of file MuonResidualsAngleFitter.cc.

7  {
10  MuonResidualsFitter *fitter = fitinfo->fitter();
11 
12  fval = 0.;
13  for (std::vector<double *>::const_iterator resiter = fitter->residuals_begin(); resiter != fitter->residuals_end();
14  ++resiter) {
15  const double residual = (*resiter)[MuonResidualsAngleFitter::kResidual];
16  const double xangle = (*resiter)[MuonResidualsAngleFitter::kXAngle];
17  const double yangle = (*resiter)[MuonResidualsAngleFitter::kYAngle];
18 
19  double center = 0.;
20  center += par[MuonResidualsAngleFitter::kAngle];
22  center += par[MuonResidualsAngleFitter::kYControl] * yangle;
23 
26  } else if (fitter->residualsModel() == MuonResidualsFitter::kPowerLawTails) {
29  } else if (fitter->residualsModel() == MuonResidualsFitter::kROOTVoigt) {
32  } else if (fitter->residualsModel() == MuonResidualsFitter::kGaussPowerTails) {
34  } else {
35  assert(false);
36  }
37  }
38 }

References cms::cuda::assert(), MuonResidualsFitterFitInfo::fitter(), MuonResidualsAngleFitter::kAngle, MuonResidualsAngleFitter::kGamma, MuonResidualsFitter::kGaussPowerTails, MuonResidualsFitter::kPowerLawTails, MuonResidualsFitter::kPureGaussian, MuonResidualsAngleFitter::kResidual, MuonResidualsFitter::kROOTVoigt, MuonResidualsAngleFitter::kSigma, MuonResidualsAngleFitter::kXAngle, MuonResidualsAngleFitter::kXControl, MuonResidualsAngleFitter::kYAngle, MuonResidualsAngleFitter::kYControl, MuonResidualsAngleFitter_TMinuit, MuonResidualsFitter_logGaussPowerTails(), MuonResidualsFitter_logPowerLawTails(), MuonResidualsFitter_logPureGaussian(), MuonResidualsFitter_logROOTVoigt(), MuonResidualsFitter::residuals_begin(), MuonResidualsFitter::residuals_end(), MuonResidualsFitter::residualsModel(), and OpticalFunctionsConfig_cfi::xangle.

Referenced by MuonResidualsAngleFitter::fit().

◆ MuonResidualsFitter_compute_log_convolution()

double MuonResidualsFitter_compute_log_convolution ( double  toversigma,
double  gammaoversigma,
double  max = 1000.,
double  step = 0.001,
double  power = 4. 
)

Definition at line 54 of file MuonResidualsFitter.cc.

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 }

References JetChargeProducer_cfi::exp, dqm-mbProfile::log, M_PI, SiStripPI::max, funct::pow(), and mathSSE::sqrt().

Referenced by MuonResidualsFitter::initialize_table().

◆ 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.

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 }

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

◆ MuonResidualsFitter_logGaussPowerTails()

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

Definition at line 128 of file MuonResidualsFitter.cc.

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 }

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

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

◆ MuonResidualsFitter_logPowerLawTails()

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

Definition at line 85 of file MuonResidualsFitter.cc.

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 }

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().

◆ MuonResidualsFitter_logPureGaussian()

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

Definition at line 31 of file MuonResidualsFitter.cc.

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 }

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

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

◆ 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.

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 }

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

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

◆ 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 
)

◆ MuonResidualsPositionFitter_FCN()

void MuonResidualsPositionFitter_FCN ( int &  npar,
double *  gin,
double &  fval,
double *  par,
int  iflag 
)

Definition at line 7 of file MuonResidualsPositionFitter.cc.

7  {
10  MuonResidualsFitter *fitter = fitinfo->fitter();
11 
12  fval = 0.;
13  for (std::vector<double *>::const_iterator resiter = fitter->residuals_begin(); resiter != fitter->residuals_end();
14  ++resiter) {
15  const double residual = (*resiter)[MuonResidualsPositionFitter::kResidual];
16  const double angleerror = (*resiter)[MuonResidualsPositionFitter::kAngleError];
17  const double trackangle = (*resiter)[MuonResidualsPositionFitter::kTrackAngle];
18  const double trackposition = (*resiter)[MuonResidualsPositionFitter::kTrackPosition];
19 
20  double center = 0.;
22  center += par[MuonResidualsPositionFitter::kZpos] * trackangle;
23  center += par[MuonResidualsPositionFitter::kPhiz] * trackposition;
24  center += par[MuonResidualsPositionFitter::kScattering] * angleerror;
25 
28  } else if (fitter->residualsModel() == MuonResidualsFitter::kPowerLawTails) {
31  } else if (fitter->residualsModel() == MuonResidualsFitter::kROOTVoigt) {
34  } else if (fitter->residualsModel() == MuonResidualsFitter::kGaussPowerTails) {
36  } else {
37  assert(false);
38  }
39  }
40 }

References cms::cuda::assert(), MuonResidualsFitterFitInfo::fitter(), MuonResidualsPositionFitter::kAngleError, MuonResidualsPositionFitter::kGamma, MuonResidualsFitter::kGaussPowerTails, MuonResidualsPositionFitter::kPhiz, MuonResidualsPositionFitter::kPosition, MuonResidualsFitter::kPowerLawTails, MuonResidualsFitter::kPureGaussian, MuonResidualsPositionFitter::kResidual, MuonResidualsFitter::kROOTVoigt, MuonResidualsPositionFitter::kScattering, MuonResidualsPositionFitter::kSigma, MuonResidualsPositionFitter::kTrackAngle, MuonResidualsPositionFitter::kTrackPosition, MuonResidualsPositionFitter::kZpos, MuonResidualsFitter_logGaussPowerTails(), MuonResidualsFitter_logPowerLawTails(), MuonResidualsFitter_logPureGaussian(), MuonResidualsFitter_logROOTVoigt(), MuonResidualsPositionFitter_TMinuit, MuonResidualsFitter::residuals_begin(), MuonResidualsFitter::residuals_end(), and MuonResidualsFitter::residualsModel().

Referenced by MuonResidualsPositionFitter::fit().

MuonResidualsFitter
Definition: MuonResidualsFitter.h:84
MuonResidualsPositionFitter::kGamma
Definition: MuonResidualsPositionFitter.h:14
MuonResidualsPositionFitter::kScattering
Definition: MuonResidualsPositionFitter.h:14
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
MuonResidualsPositionFitter::kAngleError
Definition: MuonResidualsPositionFitter.h:16
step
step
Definition: StallMonitor.cc:94
MuonResidualsPositionFitter::kTrackPosition
Definition: MuonResidualsPositionFitter.h:16
MuonResidualsAngleFitter::kGamma
Definition: MuonResidualsAngleFitter.h:14
MuonResidualsFitter_logROOTVoigt
double MuonResidualsFitter_logROOTVoigt(double residual, double center, double sigma, double gamma)
Definition: MuonResidualsFitter.cc:120
MuonResidualsPositionFitter::kPhiz
Definition: MuonResidualsPositionFitter.h:14
cms::cuda::assert
assert(be >=bs)
CustomPhysics_cfi.gamma
gamma
Definition: CustomPhysics_cfi.py:17
MuonResidualsPositionFitter::kResidual
Definition: MuonResidualsPositionFitter.h:16
MuonResidualsFitter::kGaussPowerTails
Definition: MuonResidualsFitter.h:86
MuonResidualsFitter_logGaussPowerTails
double MuonResidualsFitter_logGaussPowerTails(double residual, double center, double sigma)
Definition: MuonResidualsFitter.cc:128
MuonResidualsAngleFitter_TMinuit
static TMinuit * MuonResidualsAngleFitter_TMinuit
Definition: MuonResidualsAngleFitter.cc:3
MuonResidualsAngleFitter::kResidual
Definition: MuonResidualsAngleFitter.h:16
MuonResidualsFitter_lookup_table
double MuonResidualsFitter_lookup_table[MuonResidualsFitter_numgsbins][MuonResidualsFitter_numtsbins]
Definition: MuonResidualsFitter.cc:26
alignCSCRings.s
s
Definition: alignCSCRings.py:92
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
MuonResidualsPositionFitter_TMinuit
static TMinuit * MuonResidualsPositionFitter_TMinuit
Definition: MuonResidualsPositionFitter.cc:3
MuonResidualsFitterFitInfo
Definition: MuonResidualsFitter.h:250
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
vertices_cff.x
x
Definition: vertices_cff.py:29
MuonResidualsFitter::kPowerLawTails
Definition: MuonResidualsFitter.h:86
MuonResidualsPositionFitter::kZpos
Definition: MuonResidualsPositionFitter.h:14
MuonResidualsFitter_numgsbins
const int MuonResidualsFitter_numgsbins
Definition: MuonResidualsFitter.cc:22
OpticalFunctionsConfig_cfi.xangle
xangle
Definition: OpticalFunctionsConfig_cfi.py:17
MuonResidualsPositionFitter::kPosition
Definition: MuonResidualsPositionFitter.h:14
MuonResidualsAngleFitter::kXAngle
Definition: MuonResidualsAngleFitter.h:16
MuonResidualsFitter::kPureGaussian
Definition: MuonResidualsFitter.h:86
a
double a
Definition: hdecay.h:119
MuonResidualsFitter_gsbinsize
const double MuonResidualsFitter_gsbinsize
Definition: MuonResidualsFitter.cc:20
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
MuonResidualsFitter::residuals_end
std::vector< double * >::const_iterator residuals_end() const
Definition: MuonResidualsFitter.h:191
MuonResidualsAngleFitter::kSigma
Definition: MuonResidualsAngleFitter.h:14
createfilelist.int
int
Definition: createfilelist.py:10
fftjetcommon_cfi.sy
sy
Definition: fftjetcommon_cfi.py:203
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
MuonResidualsFitter_logPureGaussian
double MuonResidualsFitter_logPureGaussian(double residual, double center, double sigma)
Definition: MuonResidualsFitter.cc:31
PVValHelper::dy
Definition: PVValidationHelpers.h:49
MuonResidualsFitter_logPowerLawTails
double MuonResidualsFitter_logPowerLawTails(double residual, double center, double sigma, double gamma)
Definition: MuonResidualsFitter.cc:85
MuonResidualsPositionFitter::kSigma
Definition: MuonResidualsPositionFitter.h:14
MuonResidualsFitter::kROOTVoigt
Definition: MuonResidualsFitter.h:86
MuonResidualsFitter_numtsbins
const int MuonResidualsFitter_numtsbins
Definition: MuonResidualsFitter.cc:23
alignCSCRings.r
r
Definition: alignCSCRings.py:93
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
heppy_batch.val
val
Definition: heppy_batch.py:351
MuonResidualsFitterFitInfo::fitter
MuonResidualsFitter * fitter()
Definition: MuonResidualsFitter.h:253
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
MuonResidualsFitter_logGaussPowerTails
double MuonResidualsFitter_logGaussPowerTails(double residual, double center, double sigma)
Definition: MuonResidualsFitter.cc:128
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
MuonResidualsFitter_tsbinsize
const double MuonResidualsFitter_tsbinsize
Definition: MuonResidualsFitter.cc:21
MuonResidualsFitter_logPowerLawTails
double MuonResidualsFitter_logPowerLawTails(double residual, double center, double sigma, double gamma)
Definition: MuonResidualsFitter.cc:85
MuonResidualsAngleFitter::kAngle
Definition: MuonResidualsAngleFitter.h:14
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
MuonResidualsPositionFitter::kTrackAngle
Definition: MuonResidualsPositionFitter.h:16
MuonResidualsAngleFitter::kXControl
Definition: MuonResidualsAngleFitter.h:14
MuonResidualsAngleFitter::kYControl
Definition: MuonResidualsAngleFitter.h:14
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
MuonResidualsFitter::residualsModel
int residualsModel() const
Definition: MuonResidualsFitter.h:124
MuonResidualsFitter::residuals_begin
std::vector< double * >::const_iterator residuals_begin() const
Definition: MuonResidualsFitter.h:190
MuonResidualsAngleFitter::kYAngle
Definition: MuonResidualsAngleFitter.h:16
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
PVValHelper::dx
Definition: PVValidationHelpers.h:48
MuonResidualsFitter_logPureGaussian
double MuonResidualsFitter_logPureGaussian(double residual, double center, double sigma)
Definition: MuonResidualsFitter.cc:31
fftjetcommon_cfi.sx
sx
Definition: fftjetcommon_cfi.py:202