CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/ElectroWeakAnalysis/Utilities/python/fitWZ.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 from __future__ import division
00004 from math import *
00005 from ROOT import *
00006 from array import array
00007 
00008 gROOT.SetBatch(True)
00009 
00010 # Wmunu inputs
00011 wxsection = 9.922
00012 ewxsection = 0.090
00013 zxsection = 0.924
00014 ezxsection = 0.031
00015 sysEff = 0.013
00016 corrZEff = -0.236
00017 
00018 # FCN definition
00019 def MyChi2 (npar, g, chi2, x, iflag):
00020       # Inverse of (Zyield,sysEff) covariance matrix
00021       s11 = 1./ezxsection**2/(1.-corrZEff**2)
00022       s22 = 1./sysEff**2/(1.-corrZEff**2)
00023       s12 = -corrZEff/(1.-corrZEff**2)/ezxsection/sysEff
00024 
00025       # Build chi2
00026       wxsFit = x[0]*x[1]
00027       zxsFit = x[1]
00028       effFit = x[2]
00029       chi2[0] = (wxsFit*(1.+effFit)-wxsection)*(wxsFit*(1.+effFit)-wxsection)/ewxsection/ewxsection
00030       chi2[0] += (zxsFit-zxsection)*(zxsFit-zxsection) *s11
00031       chi2[0] += effFit*effFit * s22
00032       chi2[0] += 2*(zxsFit-zxsection)*effFit * s12
00033 
00034 # Minimation, main program
00035 gMinuit = TMinuit()
00036 gMinuit.SetPrintLevel(-1)
00037 gMinuit.SetFCN(MyChi2)
00038 arglist = array('d', 10*[0.])
00039 ier = Long(0)
00040 
00041 gMinuit.mnparm(0, "W/Z ratio   Mu", 10.0, 1.e-3, 0, 0, ier)
00042 gMinuit.mnparm(1, "Zsigma [nb] Mu", 1.0, 1.e-3, 0, 0, ier)
00043 gMinuit.mnparm(2, "DeltaEffRel Mu", 0.0, 1.e-4, 0, 0, ier)
00044 
00045 arglist[0] = 1000.; arglist[1] = 0.1
00046 gMinuit.mnexcm("MINIMIZE", arglist, 2, ier)
00047 
00048 finalChi2 = 0.0
00049 gMinuit.mnprin(3,finalChi2)
00050 
00051 par0 = Double(0.0)
00052 errpar0 = Double(0.0)
00053 gMinuit.GetParameter(0,par0,errpar0)
00054 
00055 # Extract statistical uncertainty on W/Z including efficiency uncertainties
00056 print "\n*** Statistical uncertainty on W/Z (including eff. unc.): %.4f" % (errpar0)