CMS 3D CMS Logo

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