test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
fitWZ.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from __future__ import division
4 from math import *
5 from ROOT import *
6 from array import array
7 
8 gROOT.SetBatch(True)
9 
10 # Wmunu inputs
11 wxsection = 9.922
12 ewxsection = 0.090
13 zxsection = 0.924
14 ezxsection = 0.031
15 sysEff = 0.013
16 corrZEff = -0.236
17 
18 # FCN definition
19 def MyChi2 (npar, g, chi2, x, iflag):
20  # Inverse of (Zyield,sysEff) covariance matrix
21  s11 = 1./ezxsection**2/(1.-corrZEff**2)
22  s22 = 1./sysEff**2/(1.-corrZEff**2)
23  s12 = -corrZEff/(1.-corrZEff**2)/ezxsection/sysEff
24 
25  # Build chi2
26  wxsFit = x[0]*x[1]
27  zxsFit = x[1]
28  effFit = x[2]
29  chi2[0] = (wxsFit*(1.+effFit)-wxsection)*(wxsFit*(1.+effFit)-wxsection)/ewxsection/ewxsection
30  chi2[0] += (zxsFit-zxsection)*(zxsFit-zxsection) *s11
31  chi2[0] += effFit*effFit * s22
32  chi2[0] += 2*(zxsFit-zxsection)*effFit * s12
33 
34 # Minimation, main program
35 gMinuit = TMinuit()
36 gMinuit.SetPrintLevel(-1)
37 gMinuit.SetFCN(MyChi2)
38 arglist = array('d', 10*[0.])
39 ier = Long(0)
40 
41 gMinuit.mnparm(0, "W/Z ratio Mu", 10.0, 1.e-3, 0, 0, ier)
42 gMinuit.mnparm(1, "Zsigma [nb] Mu", 1.0, 1.e-3, 0, 0, ier)
43 gMinuit.mnparm(2, "DeltaEffRel Mu", 0.0, 1.e-4, 0, 0, ier)
44 
45 arglist[0] = 1000.; arglist[1] = 0.1
46 gMinuit.mnexcm("MINIMIZE", arglist, 2, ier)
47 
48 finalChi2 = 0.0
49 gMinuit.mnprin(3,finalChi2)
50 
51 par0 = Double(0.0)
52 errpar0 = Double(0.0)
53 gMinuit.GetParameter(0,par0,errpar0)
54 
55 # Extract statistical uncertainty on W/Z including efficiency uncertainties
56 print "\n*** Statistical uncertainty on W/Z (including eff. unc.): %.4f" % (errpar0)
def MyChi2
Definition: fitWZ.py:19