CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

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

Definition at line 102 of file MuonResiduals6DOFrphiFitter.cc.

References 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(), MuonResidualsFitter::useRes(), and histoStyle::weight.

Referenced by MuonResiduals6DOFrphiFitter::fit().

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) {
169  fval += -weight * MuonResidualsFitter_logPureGaussian2D(
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 }
double MuonResidualsFitter_logGaussPowerTails(double residual, double center, double sigma)
float alpha
Definition: AMPTWrapper.h:105
std::vector< double * >::const_iterator residuals_begin() const
double MuonResidualsFitter_logPureGaussian2D(double x, double y, double x0, double y0, double sx, double sy, double r)
MuonResidualsFitter * fitter()
assert(be >=bs)
double MuonResidualsFitter_logROOTVoigt(double residual, double center, double sigma, double gamma)
double MuonResidualsFitter_logPowerLawTails(double residual, double center, double sigma, double gamma)
int useRes(int pattern=-1)
std::vector< double * >::const_iterator residuals_end() const
int weight
Definition: histoStyle.py:51
double MuonResidualsFitter_logPureGaussian(double residual, double center, double sigma)