1 |
#!/usr/bin/env python
|
2 |
import pickle
|
3 |
import ROOT
|
4 |
from array import array
|
5 |
import sys, os
|
6 |
from optparse import OptionParser
|
7 |
from copy import copy,deepcopy
|
8 |
from math import sqrt
|
9 |
ROOT.gROOT.SetBatch(True)
|
10 |
|
11 |
#CONFIGURE
|
12 |
argv = sys.argv
|
13 |
parser = OptionParser()
|
14 |
parser.add_option("-R", "--region", dest="region", default="",
|
15 |
help="region to plot")
|
16 |
parser.add_option("-M", "--figure_of_merit", dest="fom", default="",
|
17 |
help="figure of merit to be used to weight the plots. Possibilities: s/b, s/sqrt(b)")
|
18 |
parser.add_option("-C", "--config", dest="config", default=[], action="append",
|
19 |
help="configuration file")
|
20 |
(opts, args) = parser.parse_args(argv)
|
21 |
if opts.config =="":
|
22 |
opts.config = "config"
|
23 |
|
24 |
from myutils import BetterConfigParser, printc, ParseInfo, mvainfo, StackMaker, HistoMaker
|
25 |
|
26 |
print opts.config
|
27 |
opts.config.append('8TeVconfig/vhbbPlotDef.ini')
|
28 |
config = BetterConfigParser()
|
29 |
config.read(opts.config)
|
30 |
|
31 |
def get_s_over_b(fName):
|
32 |
#using bin 9, 10, 11
|
33 |
s=0
|
34 |
b=0
|
35 |
histos = get_th1(fName)
|
36 |
for histo in histos:
|
37 |
if 'data' in histo.GetName(): continue
|
38 |
for i in range(9,11):
|
39 |
if 'VH' in histo.GetName():
|
40 |
s+=histo.GetBinContent(i)
|
41 |
else:
|
42 |
b+=histo.GetBinContent(i)
|
43 |
return s/b
|
44 |
|
45 |
def get_th1(fName):
|
46 |
infile = ROOT.TFile.Open(fName,'read')
|
47 |
th1 = []
|
48 |
for key in ROOT.gDirectory.GetListOfKeys():
|
49 |
infile.cd()
|
50 |
th1.append(key.ReadObj())
|
51 |
return th1
|
52 |
|
53 |
def plot():
|
54 |
signalRegion = True
|
55 |
region = 'plot'
|
56 |
var = 'Hmass'
|
57 |
|
58 |
stack = StackMaker(config,var,region,signalRegion)
|
59 |
|
60 |
# fileList = [
|
61 |
# '/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch1_Wenu3_PreFit.root',
|
62 |
# '/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZeeHighPt_PreFit.root',
|
63 |
# '/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Znn_HighPt_ZnunuHighPt_8TeV_PreFit.root',
|
64 |
# '/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch2_Wmunu3_PreFit.root',
|
65 |
# '/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZmmHighPt_PreFit.root']
|
66 |
|
67 |
|
68 |
fileList = [
|
69 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZmmMedPt_PostFit_s.root',
|
70 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZeeMedPt_PostFit_s.root',
|
71 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Znn_MedPt_ZnunuMedPt_8TeV_PostFit_s.root',
|
72 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch2_Wmunu2_PostFit_s.root',
|
73 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Znn_LowPt_ZnunuLowPt_8TeV_PostFit_s.root',
|
74 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZmmLowPt_PostFit_s.root',
|
75 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZeeLowPt_PostFit_s.root',
|
76 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch1_Wenu_PostFit_s.root',
|
77 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch2_Wmunu_PostFit_s.root',
|
78 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch1_WenuHighPt_PostFit_s.root',
|
79 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZeeHighPt_PostFit_s.root',
|
80 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Znn_HighPt_ZnunuHighPt_8TeV_PostFit_s.root',
|
81 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch2_WmunuHighPt_PostFit_s.root',
|
82 |
'/shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZmmHighPt_PostFit_s.root']
|
83 |
|
84 |
|
85 |
# #tau
|
86 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wtn_Wtn_PostFit_s.root
|
87 |
|
88 |
|
89 |
# #Med
|
90 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZmmMedPt_PostFit_s.root
|
91 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZeeMedPt_PostFit_s.root
|
92 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Znn_MedPt_ZnunuMedPt_8TeV_PostFit_s.root
|
93 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch2_Wmunu2_PostFit_s.root
|
94 |
|
95 |
# #Low
|
96 |
|
97 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Znn_LowPt_ZnunuLowPt_8TeV_PostFit_s.root
|
98 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZmmLowPt_PostFit_s.root
|
99 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Zll_ZeeLowPt_PostFit_s.root
|
100 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch1_Wenu_PostFit_s.root
|
101 |
# /shome/bortigno/VHbbAnalysis/postPreApp//LHCP_PostFit/MJJ_Wln_ch2_Wmunu_PostFit_s.root
|
102 |
|
103 |
fileList += ['ZeeLowPt_7TeV.root','ZmmLowPt_7TeV.root','WmnLowPt_7TeV.root','ZnnLowPt_7TeV.root']
|
104 |
fileList += ['ZeeHighPt_7TeV.root','ZmmHighPt_7TeV.root','WmnHighPt_7TeV.root','ZnnHighPt_7TeV.root']
|
105 |
|
106 |
histosL = []
|
107 |
for file in fileList:
|
108 |
print file
|
109 |
print get_s_over_b(file)
|
110 |
for th1 in get_th1(file):
|
111 |
if opts.fom == 's/b':
|
112 |
th1.Scale(10*get_s_over_b(file))
|
113 |
histosL.append(th1)
|
114 |
|
115 |
print 'histoL'
|
116 |
print histosL
|
117 |
typs = []
|
118 |
typsL = []
|
119 |
datas = []
|
120 |
datasL = []
|
121 |
|
122 |
#append the name just once
|
123 |
for histo in histosL:
|
124 |
typsL.append(histo.GetName())
|
125 |
if 'data' in histo.GetName():
|
126 |
datasL.append(histo)
|
127 |
|
128 |
#datasL.append(datas)
|
129 |
#typsL.append(typs)
|
130 |
print typsL
|
131 |
|
132 |
stack.histos = histosL
|
133 |
stack.typs = typsL
|
134 |
stack.datas = datasL
|
135 |
# stack.datatyps = Ldatatyps[v]
|
136 |
stack.datanames='data_obs'
|
137 |
#if signalRegion:
|
138 |
# stack.overlay = ['VH','VVHF','VVLF']
|
139 |
# stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_preFit.pdf')
|
140 |
stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_combined78tev_postFit_s_over_b.C')
|
141 |
# stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_highPt_7tev.pdf')
|
142 |
# stack.options['pdfName'] = stack.options['pdfName'].replace('.pdf','_combined_postFit_s_over_b_Hpt_weight_1.pdf')
|
143 |
stack.lumi = 19040
|
144 |
stack.doPlot()
|
145 |
|
146 |
print 'i am done!\n'
|
147 |
|
148 |
|
149 |
plot()
|
150 |
sys.exit(0)
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|