1 |
#!/bin/env python
|
2 |
|
3 |
import sys,math
|
4 |
from ROOT import *
|
5 |
|
6 |
gROOT.Macro("rootlogon.C")
|
7 |
c1 = TCanvas("c1","c1",800,600)
|
8 |
|
9 |
err1 = Double(0.0)
|
10 |
err2 = Double(0.0)
|
11 |
#schemes = ["loose","medium","tight"]
|
12 |
sele = "bdt"
|
13 |
scheme = "medium"
|
14 |
chans = ["0","2"]
|
15 |
components = ["","-zjets","-ZZ-powheg","-wzmg","-zllg"]
|
16 |
loops = ["singleEle","doubleEle"]
|
17 |
|
18 |
wz_ch0,wz_ch2,wz_ch0_err,wz_ch2_err = 0,0,0,0
|
19 |
|
20 |
|
21 |
print " 4e 2e2mu"
|
22 |
for comp in components:
|
23 |
for loop in loops:
|
24 |
name = "root/ntuples/"+loop+"-"+sele+"-"+scheme+comp+"-test.root"
|
25 |
tf = TFile(name)
|
26 |
|
27 |
hist = TH1F("hist","hist",10,0,1000)
|
28 |
hist.Sumw2()
|
29 |
|
30 |
# cut = "(!isConv1 && !isConv2 && !isConvtight && channel=="+chan+")"
|
31 |
# cut = "((gMatch1 && gMatch2) && channel=="+chan+")"
|
32 |
cut = "(1)"
|
33 |
if name.find("zllg") != -1 or name.find("zjets") != -1 or name.find("wz") != -1 or name.find("ZZ") != -1:
|
34 |
cut = "(4700*xswgt*woff*won*npuw)*" + cut
|
35 |
|
36 |
tree = tf.Get("passtuple")
|
37 |
# tree.Scan("run:evt:w:channel:pt1:pt2:eta1:eta2:mZ1:mZ2:met",cut)
|
38 |
tree.Draw("mZ1>>hist","w*(channel==0)*"+cut)
|
39 |
integral1 = hist.IntegralAndError(0,hist.GetNbinsX()+1,err1)
|
40 |
|
41 |
# tree.Scan("run:evt:w:channel:pt1:pt2:eta1:eta2:mZ1:mZ2:met",cut)
|
42 |
tree.Draw("mZ1>>hist","w*(channel==2)*"+cut)
|
43 |
integral2 = hist.IntegralAndError(0,hist.GetNbinsX()+1,err2)
|
44 |
print "{4:10s} {0:5.3f} +/- {1:5.3f} {2:5.3f} +/- {3:5.3f}".format(integral1,err1,integral2,err2,comp[1:])
|
45 |
|
46 |
if comp=="":
|
47 |
if loop=="singleEle":
|
48 |
wz_ch0 += integral1
|
49 |
wz_ch0_err += err1*err1
|
50 |
wz_ch2 += integral2
|
51 |
wz_ch2_err += err2*err2
|
52 |
elif loop=="doubleEle":
|
53 |
wz_ch0 -= 2*integral1
|
54 |
wz_ch0_err += 2*err1*err1
|
55 |
wz_ch2 -= 2*integral2
|
56 |
wz_ch2_err += 2*err2*err2
|
57 |
if comp.find("ZZ") != -1 or comp.find("zllg") != -1:
|
58 |
if loop=="singleEle":
|
59 |
wz_ch0 -= integral1
|
60 |
wz_ch0_err += err1*err1
|
61 |
wz_ch2 -= integral2
|
62 |
wz_ch2_err += err2*err2
|
63 |
|
64 |
print "\nwz est. {0:.3f} +/- {1:.3f} {2:.3f} +/- {3:.3f}".format(wz_ch0,math.sqrt(wz_ch0_err),wz_ch2,math.sqrt(wz_ch2_err))
|