CMS 3D CMS Logo

Functions
MuonResiduals5DOFFitter.cc File Reference
#include "Alignment/MuonAlignmentAlgorithms/interface/MuonResiduals5DOFFitter.h"
#include "TH2F.h"
#include "TMath.h"
#include "TTree.h"
#include "TFile.h"

Go to the source code of this file.

Functions

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

Function Documentation

◆ MuonResiduals5DOFFitter_FCN()

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

Definition at line 76 of file MuonResiduals5DOFFitter.cc.

76  {
77  MuonResidualsFitterFitInfo *fitinfo = (MuonResidualsFitterFitInfo *)(minuit->GetObjectFit());
78  MuonResidualsFitter *fitter = fitinfo->fitter();
79 
80  fval = 0.;
81  for (std::vector<double *>::const_iterator resiter = fitter->residuals_begin(); resiter != fitter->residuals_end();
82  ++resiter) {
83  const double residual = (*resiter)[MuonResiduals5DOFFitter::kResid];
84  const double resslope = (*resiter)[MuonResiduals5DOFFitter::kResSlope];
85  const double positionX = (*resiter)[MuonResiduals5DOFFitter::kPositionX];
86  const double positionY = (*resiter)[MuonResiduals5DOFFitter::kPositionY];
87  const double angleX = (*resiter)[MuonResiduals5DOFFitter::kAngleX];
88  const double angleY = (*resiter)[MuonResiduals5DOFFitter::kAngleY];
89  const double redchi2 = (*resiter)[MuonResiduals5DOFFitter::kRedChi2];
90 
91  const double alignx = par[MuonResiduals5DOFFitter::kAlignX];
92  const double alignz = par[MuonResiduals5DOFFitter::kAlignZ];
93  const double alignphix = par[MuonResiduals5DOFFitter::kAlignPhiX];
94  const double alignphiy = par[MuonResiduals5DOFFitter::kAlignPhiY];
95  const double alignphiz = par[MuonResiduals5DOFFitter::kAlignPhiZ];
96  const double residsigma = par[MuonResiduals5DOFFitter::kResidSigma];
97  const double resslopesigma = par[MuonResiduals5DOFFitter::kResSlopeSigma];
98  const double alpha = par[MuonResiduals5DOFFitter::kAlpha];
99  const double residgamma = par[MuonResiduals5DOFFitter::kResidGamma];
100  const double resslopegamma = par[MuonResiduals5DOFFitter::kResSlopeGamma];
101 
102  double coeff = alpha;
105  coeff = 0.;
106  double residpeak = residual_x(
107  alignx, alignz, alignphix, alignphiy, alignphiz, positionX, positionY, angleX, angleY, coeff, resslope);
108  double resslopepeak =
109  residual_dxdz(alignx, alignz, alignphix, alignphiy, alignphiz, positionX, positionY, angleX, angleY);
110 
111  double weight = (1. / redchi2) * number_of_hits / sum_of_weights;
112  if (!weight_alignment)
113  weight = 1.;
114 
115  if (!weight_alignment || TMath::Prob(redchi2 * 8, 8) < 0.99) // no spikes allowed
116  {
118  if (fitter->useRes() == MuonResidualsFitter::k1111 || fitter->useRes() == MuonResidualsFitter::k1110 ||
119  fitter->useRes() == MuonResidualsFitter::k1010) {
120  fval += -weight * MuonResidualsFitter_logPureGaussian(residual, residpeak, residsigma);
121  fval += -weight * MuonResidualsFitter_logPureGaussian(resslope, resslopepeak, resslopesigma);
122  } else if (fitter->useRes() == MuonResidualsFitter::k1100) {
123  fval += -weight * MuonResidualsFitter_logPureGaussian(residual, residpeak, residsigma);
124  } else if (fitter->useRes() == MuonResidualsFitter::k0010) {
125  fval += -weight * MuonResidualsFitter_logPureGaussian(resslope, resslopepeak, resslopesigma);
126  }
127  } else if (fitter->residualsModel() == MuonResidualsFitter::kPureGaussian2D) {
128  if (fitter->useRes() == MuonResidualsFitter::k1111 || fitter->useRes() == MuonResidualsFitter::k1110 ||
129  fitter->useRes() == MuonResidualsFitter::k1010) {
131  residual, resslope, residpeak, resslopepeak, residsigma, resslopesigma, alpha);
132  } else if (fitter->useRes() == MuonResidualsFitter::k1100) {
133  fval += -weight * MuonResidualsFitter_logPureGaussian(residual, residpeak, residsigma);
134  } else if (fitter->useRes() == MuonResidualsFitter::k0010) {
135  fval += -weight * MuonResidualsFitter_logPureGaussian(resslope, resslopepeak, resslopesigma);
136  }
137  } else if (fitter->residualsModel() == MuonResidualsFitter::kPowerLawTails) {
138  fval += -weight * MuonResidualsFitter_logPowerLawTails(residual, residpeak, residsigma, residgamma);
139  fval += -weight * MuonResidualsFitter_logPowerLawTails(resslope, resslopepeak, resslopesigma, resslopegamma);
140  } else if (fitter->residualsModel() == MuonResidualsFitter::kROOTVoigt) {
141  fval += -weight * MuonResidualsFitter_logROOTVoigt(residual, residpeak, residsigma, residgamma);
142  fval += -weight * MuonResidualsFitter_logROOTVoigt(resslope, resslopepeak, resslopesigma, resslopegamma);
143  } else if (fitter->residualsModel() == MuonResidualsFitter::kGaussPowerTails) {
144  fval += -weight * MuonResidualsFitter_logGaussPowerTails(residual, residpeak, residsigma);
145  fval += -weight * MuonResidualsFitter_logGaussPowerTails(resslope, resslopepeak, resslopesigma);
146  } else {
147  assert(false);
148  }
149  }
150  }
151 }

References alpha, cms::cuda::assert(), MuonResidualsFitterFitInfo::fitter(), MuonResidualsFitter::k0010, MuonResidualsFitter::k1010, MuonResidualsFitter::k1100, MuonResidualsFitter::k1110, MuonResidualsFitter::k1111, MuonResiduals5DOFFitter::kAlignPhiX, MuonResiduals5DOFFitter::kAlignPhiY, MuonResiduals5DOFFitter::kAlignPhiZ, MuonResiduals5DOFFitter::kAlignX, MuonResiduals5DOFFitter::kAlignZ, MuonResiduals5DOFFitter::kAlpha, MuonResiduals5DOFFitter::kAngleX, MuonResiduals5DOFFitter::kAngleY, MuonResidualsFitter::kGaussPowerTails, MuonResiduals5DOFFitter::kPositionX, MuonResiduals5DOFFitter::kPositionY, MuonResidualsFitter::kPowerLawTails, MuonResidualsFitter::kPureGaussian, MuonResidualsFitter::kPureGaussian2D, MuonResiduals5DOFFitter::kRedChi2, MuonResiduals5DOFFitter::kResid, MuonResiduals5DOFFitter::kResidGamma, MuonResiduals5DOFFitter::kResidSigma, MuonResiduals5DOFFitter::kResSlope, MuonResiduals5DOFFitter::kResSlopeGamma, MuonResiduals5DOFFitter::kResSlopeSigma, MuonResidualsFitter::kROOTVoigt, MuonResidualsFitter_logGaussPowerTails(), MuonResidualsFitter_logPowerLawTails(), MuonResidualsFitter_logPureGaussian(), MuonResidualsFitter_logPureGaussian2D(), MuonResidualsFitter_logROOTVoigt(), MuonResidualsFitter::residuals_begin(), MuonResidualsFitter::residuals_end(), MuonResidualsFitter::residualsModel(), and MuonResidualsFitter::useRes().

Referenced by MuonResiduals5DOFFitter::fit().

MuonResidualsFitter
Definition: MuonResidualsFitter.h:84
MuonResiduals5DOFFitter::kRedChi2
Definition: MuonResiduals5DOFFitter.h:41
MuonResiduals5DOFFitter::kPositionY
Definition: MuonResiduals5DOFFitter.h:38
MuonResidualsFitter_logROOTVoigt
double MuonResidualsFitter_logROOTVoigt(double residual, double center, double sigma, double gamma)
Definition: MuonResidualsFitter.cc:120
MuonResiduals5DOFFitter::kAlignZ
Definition: MuonResiduals5DOFFitter.h:22
MuonResidualsFitter::k1100
Definition: MuonResidualsFitter.h:90
cms::cuda::assert
assert(be >=bs)
alpha
float alpha
Definition: AMPTWrapper.h:105
MuonResidualsFitter::kGaussPowerTails
Definition: MuonResidualsFitter.h:86
MuonResiduals5DOFFitter::kResidSigma
Definition: MuonResiduals5DOFFitter.h:26
MuonResiduals5DOFFitter::kAngleX
Definition: MuonResiduals5DOFFitter.h:39
MuonResiduals5DOFFitter::kResSlope
Definition: MuonResiduals5DOFFitter.h:36
MuonResidualsFitter::k1111
Definition: MuonResidualsFitter.h:90
MuonResiduals5DOFFitter::kResSlopeGamma
Definition: MuonResiduals5DOFFitter.h:30
MuonResidualsFitterFitInfo
Definition: MuonResidualsFitter.h:250
MuonResidualsFitter::kPowerLawTails
Definition: MuonResidualsFitter.h:86
MuonResiduals5DOFFitter::kResidGamma
Definition: MuonResiduals5DOFFitter.h:29
MuonResidualsFitter::useRes
int useRes(int pattern=-1)
Definition: MuonResidualsFitter.h:119
MuonResidualsFitter::k1010
Definition: MuonResidualsFitter.h:90
MuonResiduals5DOFFitter::kAlignPhiY
Definition: MuonResiduals5DOFFitter.h:24
MuonResiduals5DOFFitter::kAlignX
Definition: MuonResiduals5DOFFitter.h:21
MuonResiduals5DOFFitter::kAlpha
Definition: MuonResiduals5DOFFitter.h:28
MuonResiduals5DOFFitter::kResid
Definition: MuonResiduals5DOFFitter.h:35
MuonResidualsFitter::kPureGaussian
Definition: MuonResidualsFitter.h:86
MuonResidualsFitter::k1110
Definition: MuonResidualsFitter.h:90
MuonResiduals5DOFFitter::kAlignPhiZ
Definition: MuonResiduals5DOFFitter.h:25
MuonResidualsFitter::residuals_end
std::vector< double * >::const_iterator residuals_end() const
Definition: MuonResidualsFitter.h:191
MuonResidualsFitter_logPowerLawTails
double MuonResidualsFitter_logPowerLawTails(double residual, double center, double sigma, double gamma)
Definition: MuonResidualsFitter.cc:85
MuonResidualsFitter_logPureGaussian2D
double MuonResidualsFitter_logPureGaussian2D(double x, double y, double x0, double y0, double sx, double sy, double r)
Definition: MuonResidualsFitter.cc:43
MuonResidualsFitter::kROOTVoigt
Definition: MuonResidualsFitter.h:86
MuonResiduals5DOFFitter::kAlignPhiX
Definition: MuonResiduals5DOFFitter.h:23
MuonResiduals5DOFFitter::kResSlopeSigma
Definition: MuonResiduals5DOFFitter.h:27
MuonResidualsFitterFitInfo::fitter
MuonResidualsFitter * fitter()
Definition: MuonResidualsFitter.h:253
MuonResidualsFitter::k0010
Definition: MuonResidualsFitter.h:90
MuonResiduals5DOFFitter::kAngleY
Definition: MuonResiduals5DOFFitter.h:40
MuonResidualsFitter_logGaussPowerTails
double MuonResidualsFitter_logGaussPowerTails(double residual, double center, double sigma)
Definition: MuonResidualsFitter.cc:128
MuonResiduals5DOFFitter::kPositionX
Definition: MuonResiduals5DOFFitter.h:37
MuonResidualsFitter::kPureGaussian2D
Definition: MuonResidualsFitter.h:86
MuonResidualsFitter::residualsModel
int residualsModel() const
Definition: MuonResidualsFitter.h:124
MuonResidualsFitter::residuals_begin
std::vector< double * >::const_iterator residuals_begin() const
Definition: MuonResidualsFitter.h:190
weight
Definition: weight.py:1
MuonResidualsFitter_logPureGaussian
double MuonResidualsFitter_logPureGaussian(double residual, double center, double sigma)
Definition: MuonResidualsFitter.cc:31