1 |
< |
#!/afs/cern.ch/cms/slc5_amd64_gcc434/cms/cmssw/CMSSW_4_2_8/external/slc5_amd64_gcc434/bin/python2.6 |
1 |
> |
#!/usr/bin/env python |
2 |
|
|
3 |
< |
import sys,ROOT |
3 |
> |
import sys,hashlib,ROOT |
4 |
|
ROOT.gROOT.SetBatch(True) |
5 |
|
from array import array |
6 |
|
from optparse import OptionParser |
141 |
|
def do_validation(fileList,inclusive,newpostfix): |
142 |
|
histo = ROOT.TH1F("lheV_pt","lheV_pt",300,0,300) |
143 |
|
histo1 = ROOT.TH1F("lheV_ptInc","lheV_ptInc",300,0,300) |
144 |
+ |
histo.SetDirectory(0) |
145 |
+ |
histo1.SetDirectory(0) |
146 |
|
|
147 |
|
for file in fileList: |
148 |
< |
h_name=file[0] |
148 |
> |
h_name=str(hashlib.sha224(file[0]).hexdigest()) |
149 |
> |
print file[0] |
150 |
|
print h_name |
151 |
|
tfile = ROOT.TFile.Open(file[0].replace('.root',newpostfix),"read") |
152 |
|
tree = tfile.Get("tree") |
153 |
|
h_tmp = ROOT.TH1F(h_name,h_name,300,0,300) |
154 |
< |
ROOT.gDirectory.ls() |
154 |
> |
#ROOT.gDirectory.ls() |
155 |
|
tree.Draw("lheV_pt>>"+str(h_name),"(lheWeight)*(lheV_pt < 300.)","goff") |
156 |
|
if inclusive in file[0]: |
157 |
|
h_tmp1 = ROOT.TH1F(h_name+'Inc',h_name+'Inc',300,0,300) |
166 |
|
ROOT.gPad.SetLogy() |
167 |
|
histo.Draw() |
168 |
|
histo1.Draw('SAME') |
169 |
< |
print histo.Integral(180,300) |
170 |
< |
print histo1.Integral(180,300) |
169 |
> |
print histo.Integral(100,300) |
170 |
> |
print histo1.Integral(100,300) |
171 |
|
histo1.SetLineColor(ROOT.kRed) |
172 |
|
canvas.Print("validation_lheV_pt.pdf","pdf") |
173 |
|
|
177 |
|
f = open('8TeVconfig/lhe_weights', 'w') |
178 |
|
config.write(f) |
179 |
|
f.close() |
180 |
< |
else: |
180 |
> |
elif opts.apply: |
181 |
|
weight_map = config.get('LHEWeights', 'weights_per_bin') |
182 |
|
if opts.apply: |
183 |
|
apply_weights(fileList,weight_map,prefix+inclusive,newpostfix) |