CMS 3D CMS Logo

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

Go to the source code of this file.

Functions

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

Function Documentation

◆ MuonResiduals6DOFrphiFitter_FCN()

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

Definition at line 102 of file MuonResiduals6DOFrphiFitter.cc.

102  {
103  MuonResidualsFitterFitInfo *fitinfo = (MuonResidualsFitterFitInfo *)(minuit->GetObjectFit());
104  MuonResidualsFitter *fitter = fitinfo->fitter();
105 
106  fval = 0.;
107  for (std::vector<double *>::const_iterator resiter = fitter->residuals_begin(); resiter != fitter->residuals_end();
108  ++resiter) {
109  const double residual = (*resiter)[MuonResiduals6DOFrphiFitter::kResid];
110  const double resslope = (*resiter)[MuonResiduals6DOFrphiFitter::kResSlope];
111  const double positionX = (*resiter)[MuonResiduals6DOFrphiFitter::kPositionX];
112  const double positionY = (*resiter)[MuonResiduals6DOFrphiFitter::kPositionY];
113  const double angleX = (*resiter)[MuonResiduals6DOFrphiFitter::kAngleX];
114  const double angleY = (*resiter)[MuonResiduals6DOFrphiFitter::kAngleY];
115  const double redchi2 = (*resiter)[MuonResiduals6DOFrphiFitter::kRedChi2];
116 
117  const double alignx = par[MuonResiduals6DOFrphiFitter::kAlignX];
118  const double aligny = par[MuonResiduals6DOFrphiFitter::kAlignY];
119  const double alignz = par[MuonResiduals6DOFrphiFitter::kAlignZ];
120  const double alignphix = par[MuonResiduals6DOFrphiFitter::kAlignPhiX];
121  const double alignphiy = par[MuonResiduals6DOFrphiFitter::kAlignPhiY];
122  const double alignphiz = par[MuonResiduals6DOFrphiFitter::kAlignPhiZ];
123  const double residsigma = par[MuonResiduals6DOFrphiFitter::kResidSigma];
124  const double resslopesigma = par[MuonResiduals6DOFrphiFitter::kResSlopeSigma];
125  const double alpha = par[MuonResiduals6DOFrphiFitter::kAlpha];
126  const double residgamma = par[MuonResiduals6DOFrphiFitter::kResidGamma];
127  const double resslopegamma = par[MuonResiduals6DOFrphiFitter::kResSlopeGamma];
128 
129  double coeff = alpha;
132  coeff = 0.;
133  double effr = effectiveR(positionX, positionY);
134  double residpeak = getResidual(alignx,
135  aligny,
136  alignz,
137  alignphix,
138  alignphiy,
139  alignphiz,
140  positionX,
141  positionY,
142  angleX,
143  angleY,
144  effr,
145  coeff,
146  resslope);
147  double resslopepeak = getResSlope(
148  alignx, aligny, alignz, alignphix, alignphiy, alignphiz, positionX, positionY, angleX, angleY, effr);
149 
150  double weight = (1. / redchi2) * number_of_hits / sum_of_weights;
151  if (!weight_alignment)
152  weight = 1.;
153 
154  if (!weight_alignment || TMath::Prob(redchi2 * 6, 6) < 0.99) // no spikes allowed
155  {
157  if (fitter->useRes() == MuonResidualsFitter::k1111 || fitter->useRes() == MuonResidualsFitter::k1110 ||
158  fitter->useRes() == MuonResidualsFitter::k1010) {
159  fval += -weight * MuonResidualsFitter_logPureGaussian(residual, residpeak, residsigma);
160  fval += -weight * MuonResidualsFitter_logPureGaussian(resslope, resslopepeak, resslopesigma);
161  } else if (fitter->useRes() == MuonResidualsFitter::k1100) {
162  fval += -weight * MuonResidualsFitter_logPureGaussian(residual, residpeak, residsigma);
163  } else if (fitter->useRes() == MuonResidualsFitter::k0010) {
164  fval += -weight * MuonResidualsFitter_logPureGaussian(resslope, resslopepeak, resslopesigma);
165  }
166  } else if (fitter->residualsModel() == MuonResidualsFitter::kPureGaussian2D) {
167  if (fitter->useRes() == MuonResidualsFitter::k1111 || fitter->useRes() == MuonResidualsFitter::k1110 ||
168  fitter->useRes() == MuonResidualsFitter::k1010) {
170  residual, resslope, residpeak, resslopepeak, residsigma, resslopesigma, alpha);
171  } else if (fitter->useRes() == MuonResidualsFitter::k1100) {
172  fval += -weight * MuonResidualsFitter_logPureGaussian(residual, residpeak, residsigma);
173  } else if (fitter->useRes() == MuonResidualsFitter::k0010) {
174  fval += -weight * MuonResidualsFitter_logPureGaussian(resslope, resslopepeak, resslopesigma);
175  }
176  } else if (fitter->residualsModel() == MuonResidualsFitter::kPowerLawTails) {
177  fval += -weight * MuonResidualsFitter_logPowerLawTails(residual, residpeak, residsigma, residgamma);
178  fval += -weight * MuonResidualsFitter_logPowerLawTails(resslope, resslopepeak, resslopesigma, resslopegamma);
179  } else if (fitter->residualsModel() == MuonResidualsFitter::kROOTVoigt) {
180  fval += -weight * MuonResidualsFitter_logROOTVoigt(residual, residpeak, residsigma, residgamma);
181  fval += -weight * MuonResidualsFitter_logROOTVoigt(resslope, resslopepeak, resslopesigma, resslopegamma);
182  } else if (fitter->residualsModel() == MuonResidualsFitter::kGaussPowerTails) {
183  fval += -weight * MuonResidualsFitter_logGaussPowerTails(residual, residpeak, residsigma);
184  fval += -weight * MuonResidualsFitter_logGaussPowerTails(resslope, resslopepeak, resslopesigma);
185  } else {
186  assert(false);
187  }
188  }
189  }
190 }

References zMuMuMuonUserData::alpha, cms::cuda::assert(), MuonResidualsFitterFitInfo::fitter(), MuonResidualsFitter::k0010, MuonResidualsFitter::k1010, MuonResidualsFitter::k1100, MuonResidualsFitter::k1110, MuonResidualsFitter::k1111, MuonResiduals6DOFrphiFitter::kAlignPhiX, MuonResiduals6DOFrphiFitter::kAlignPhiY, MuonResiduals6DOFrphiFitter::kAlignPhiZ, MuonResiduals6DOFrphiFitter::kAlignX, MuonResiduals6DOFrphiFitter::kAlignY, MuonResiduals6DOFrphiFitter::kAlignZ, MuonResiduals6DOFrphiFitter::kAlpha, MuonResiduals6DOFrphiFitter::kAngleX, MuonResiduals6DOFrphiFitter::kAngleY, MuonResidualsFitter::kGaussPowerTails, MuonResiduals6DOFrphiFitter::kPositionX, MuonResiduals6DOFrphiFitter::kPositionY, MuonResidualsFitter::kPowerLawTails, MuonResidualsFitter::kPureGaussian, MuonResidualsFitter::kPureGaussian2D, MuonResiduals6DOFrphiFitter::kRedChi2, MuonResiduals6DOFrphiFitter::kResid, MuonResiduals6DOFrphiFitter::kResidGamma, MuonResiduals6DOFrphiFitter::kResidSigma, MuonResiduals6DOFrphiFitter::kResSlope, MuonResiduals6DOFrphiFitter::kResSlopeGamma, MuonResiduals6DOFrphiFitter::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 MuonResiduals6DOFrphiFitter::fit().

MuonResidualsFitter
Definition: MuonResidualsFitter.h:84
MuonResiduals6DOFrphiFitter::kAlpha
Definition: MuonResiduals6DOFrphiFitter.h:30
MuonResiduals6DOFrphiFitter::kResid
Definition: MuonResiduals6DOFrphiFitter.h:36
MuonResiduals6DOFrphiFitter::kRedChi2
Definition: MuonResiduals6DOFrphiFitter.h:36
MuonResidualsFitter_logROOTVoigt
double MuonResidualsFitter_logROOTVoigt(double residual, double center, double sigma, double gamma)
Definition: MuonResidualsFitter.cc:120
zMuMuMuonUserData.alpha
alpha
zGenParticlesMatch = cms.InputTag(""),
Definition: zMuMuMuonUserData.py:9
MuonResidualsFitter::k1100
Definition: MuonResidualsFitter.h:90
cms::cuda::assert
assert(be >=bs)
MuonResidualsFitter::kGaussPowerTails
Definition: MuonResidualsFitter.h:86
MuonResidualsFitter::k1111
Definition: MuonResidualsFitter.h:90
MuonResiduals6DOFrphiFitter::kAlignPhiZ
Definition: MuonResiduals6DOFrphiFitter.h:27
MuonResiduals6DOFrphiFitter::kAngleY
Definition: MuonResiduals6DOFrphiFitter.h:36
MuonResidualsFitterFitInfo
Definition: MuonResidualsFitter.h:250
MuonResiduals6DOFrphiFitter::kResidGamma
Definition: MuonResiduals6DOFrphiFitter.h:31
MuonResidualsFitter::kPowerLawTails
Definition: MuonResidualsFitter.h:86
MuonResiduals6DOFrphiFitter::kPositionX
Definition: MuonResiduals6DOFrphiFitter.h:36
MuonResidualsFitter::useRes
int useRes(int pattern=-1)
Definition: MuonResidualsFitter.h:119
MuonResiduals6DOFrphiFitter::kResSlope
Definition: MuonResiduals6DOFrphiFitter.h:36
MuonResidualsFitter::k1010
Definition: MuonResidualsFitter.h:90
MuonResidualsFitter::kPureGaussian
Definition: MuonResidualsFitter.h:86
MuonResidualsFitter::k1110
Definition: MuonResidualsFitter.h:90
MuonResidualsFitter::residuals_end
std::vector< double * >::const_iterator residuals_end() const
Definition: MuonResidualsFitter.h:191
MuonResiduals6DOFrphiFitter::kResSlopeSigma
Definition: MuonResiduals6DOFrphiFitter.h:29
MuonResiduals6DOFrphiFitter::kAlignPhiX
Definition: MuonResiduals6DOFrphiFitter.h:25
MuonResiduals6DOFrphiFitter::kAlignY
Definition: MuonResiduals6DOFrphiFitter.h:23
MuonResidualsFitter_logPowerLawTails
double MuonResidualsFitter_logPowerLawTails(double residual, double center, double sigma, double gamma)
Definition: MuonResidualsFitter.cc:85
MuonResiduals6DOFrphiFitter::kPositionY
Definition: MuonResiduals6DOFrphiFitter.h:36
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
MuonResiduals6DOFrphiFitter::kResidSigma
Definition: MuonResiduals6DOFrphiFitter.h:28
MuonResiduals6DOFrphiFitter::kAlignX
Definition: MuonResiduals6DOFrphiFitter.h:22
MuonResidualsFitterFitInfo::fitter
MuonResidualsFitter * fitter()
Definition: MuonResidualsFitter.h:253
MuonResiduals6DOFrphiFitter::kAlignPhiY
Definition: MuonResiduals6DOFrphiFitter.h:26
MuonResidualsFitter::k0010
Definition: MuonResidualsFitter.h:90
MuonResidualsFitter_logGaussPowerTails
double MuonResidualsFitter_logGaussPowerTails(double residual, double center, double sigma)
Definition: MuonResidualsFitter.cc:128
MuonResiduals6DOFrphiFitter::kAlignZ
Definition: MuonResiduals6DOFrphiFitter.h:24
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
MuonResiduals6DOFrphiFitter::kAngleX
Definition: MuonResiduals6DOFrphiFitter.h:36
weight
Definition: weight.py:1
MuonResidualsFitter_logPureGaussian
double MuonResidualsFitter_logPureGaussian(double residual, double center, double sigma)
Definition: MuonResidualsFitter.cc:31
MuonResiduals6DOFrphiFitter::kResSlopeGamma
Definition: MuonResiduals6DOFrphiFitter.h:32