CMS 3D CMS Logo

Functions | Variables

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/Alignment/MuonAlignmentAlgorithms/src/MuonResiduals1DOFFitter.cc File Reference

#include "Alignment/MuonAlignmentAlgorithms/interface/MuonResiduals1DOFFitter.h"
#include "TMath.h"

Go to the source code of this file.

Functions

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

Variables

static double MuonResiduals1DOFFitter_number_of_hits
static double MuonResiduals1DOFFitter_sum_of_weights
static TMinuit * MuonResiduals1DOFFitter_TMinuit
static bool MuonResiduals1DOFFitter_weightAlignment

Function Documentation

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

Definition at line 13 of file MuonResiduals1DOFFitter.cc.

References MuonResidualsFitterFitInfo::fitter(), MuonResiduals1DOFFitter::kAlign, MuonResiduals1DOFFitter::kGamma, MuonResidualsFitter::kGaussPowerTails, MuonResidualsFitter::kPowerLawTails, MuonResidualsFitter::kPureGaussian, MuonResiduals1DOFFitter::kRedChi2, MuonResiduals1DOFFitter::kResid, MuonResidualsFitter::kROOTVoigt, MuonResiduals1DOFFitter::kSigma, MuonResiduals1DOFFitter_number_of_hits, MuonResiduals1DOFFitter_sum_of_weights, MuonResiduals1DOFFitter_TMinuit, MuonResiduals1DOFFitter_weightAlignment, MuonResidualsFitter_logGaussPowerTails(), MuonResidualsFitter_logPowerLawTails(), MuonResidualsFitter_logPureGaussian(), MuonResidualsFitter_logROOTVoigt(), MuonResidualsFitter::residuals_begin(), MuonResidualsFitter::residuals_end(), MuonResidualsFitter::residualsModel(), and CommonMethods::weight().

Referenced by MuonResiduals1DOFFitter::fit().

                                                                                               {
  MuonResidualsFitterFitInfo *fitinfo = (MuonResidualsFitterFitInfo*)(MuonResiduals1DOFFitter_TMinuit->GetObjectFit());
  MuonResidualsFitter *fitter = fitinfo->fitter();

  fval = 0.;
  for (std::vector<double*>::const_iterator resiter = fitter->residuals_begin();  resiter != fitter->residuals_end();  ++resiter) {
    const double residual = (*resiter)[MuonResiduals1DOFFitter::kResid];
    const double redchi2 = (*resiter)[MuonResiduals1DOFFitter::kRedChi2];

    const double residpeak = par[MuonResiduals1DOFFitter::kAlign];
    const double residsigma = par[MuonResiduals1DOFFitter::kSigma];
    const double residgamma = par[MuonResiduals1DOFFitter::kGamma];

    double weight = (1./redchi2) * MuonResiduals1DOFFitter_number_of_hits / MuonResiduals1DOFFitter_sum_of_weights;
    if (!MuonResiduals1DOFFitter_weightAlignment) weight = 1.;

    if (!MuonResiduals1DOFFitter_weightAlignment  ||  TMath::Prob(redchi2*8, 8) < 0.99) {  // no spikes allowed
      if (fitter->residualsModel() == MuonResidualsFitter::kPureGaussian) {
        fval += -weight * MuonResidualsFitter_logPureGaussian(residual, residpeak, residsigma);
      }
      else if (fitter->residualsModel() == MuonResidualsFitter::kPowerLawTails) {
        fval += -weight * MuonResidualsFitter_logPowerLawTails(residual, residpeak, residsigma, residgamma);
      }
      else if (fitter->residualsModel() == MuonResidualsFitter::kROOTVoigt) {
        fval += -weight * MuonResidualsFitter_logROOTVoigt(residual, residpeak, residsigma, residgamma);
      }
      else if (fitter->residualsModel() == MuonResidualsFitter::kGaussPowerTails) {
        fval += -weight * MuonResidualsFitter_logGaussPowerTails(residual, residpeak, residsigma);
      }
      else { assert(false); }

    }
  }
}

Variable Documentation