Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
7f2a47c
personalize submission scripts
jhoss Oct 30, 2015
16fd05a
solve merge conflict
jhoss Oct 30, 2015
3845f89
added 5 to 10 pt bin for efficiencies of ip and iso
jhoss Nov 3, 2015
71bddb9
ignore .sh scripts in git
jhoss Nov 3, 2015
6d45a70
typo correction and logX for activity plots
jhoss Nov 5, 2015
fae71ea
fix bug in calculating SF of last bin
jhoss Nov 5, 2015
45fba7f
improve drawing of ratio plots
jhoss Nov 5, 2015
19c1eb2
cleanup and axis range
jhoss Nov 5, 2015
38aa1d7
cleaned retrieve plots
Nov 5, 2015
35ff178
typo correction and logX for activity plots
jhoss Nov 5, 2015
fd1626b
fix bug in calculating SF of last bin
jhoss Nov 5, 2015
93395fb
improve drawing of ratio plots
jhoss Nov 5, 2015
4fd599f
cleanup and axis range
jhoss Nov 5, 2015
e132c87
Merge branch 'eff2015_v2' of https://github.com/GLP90/MuonAnalysis-Ta…
jhoss Nov 5, 2015
3a8a927
updated fitMuonID.py
Nov 5, 2015
92676db
Merge pull request #11 from jhoss/pick
gael-perrin Nov 6, 2015
70dcb63
Merge branch 'eff2015_v2' of ssh://github.com/GLP90/MuonAnalysis-TagA…
Nov 6, 2015
bd1b0f7
retrieve_plots.py: save as png
jhoss Nov 6, 2015
78b93a0
Merge branch 'eff2015_v2' of https://github.com/GLP90/MuonAnalysis-Ta…
jhoss Nov 6, 2015
e47ef3c
display xaxis of rel activity plot only up to certain cut value which…
jhoss Nov 6, 2015
b5245bc
Merge branch 'eff2015_v2' of github.com:GLP90/MuonAnalysis-TagAndProb…
Nov 6, 2015
d5fe57e
Merge pull request #12 from jhoss/pick
gael-perrin Nov 6, 2015
eb80382
Merge branch 'eff2015_v2' of github.com:GLP90/MuonAnalysis-TagAndProb…
Nov 6, 2015
a4c1da8
included new fits functions
Nov 6, 2015
50f5862
added NLO samples
Nov 6, 2015
1520dae
added modifications to handle negative weights properly
Nov 6, 2015
1b1514e
Merge branch 'eff2015_v2' of https://github.com/GLP90/MuonAnalysis-Ta…
jhoss Nov 7, 2015
f61090e
updated fit function
Nov 9, 2015
ba51072
corrected the Cheb fit such that it starts at pt > 60
Nov 9, 2015
1faf350
Merge branch 'eff2015_v2' of https://github.com/GLP90/MuonAnalysis-Ta…
jhoss Nov 9, 2015
76c1f3c
remove git conflict lines from retrieve_plots.py
jhoss Nov 9, 2015
f8c72d3
submit.sh
jhoss Nov 9, 2015
397a65d
use Chebyshev also in 50-60 pt bin when Loose ID
Nov 9, 2015
63a4ca4
fixed indent error
Nov 9, 2015
6c52d37
Merge branch 'eff2015_v2' of https://github.com/GLP90/MuonAnalysis-Ta…
jhoss Nov 9, 2015
37f7f19
added 6th argument to run.sh
jhoss Nov 10, 2015
6faec6b
dropping pt bin 5-10
jhoss Nov 10, 2015
d20ee71
dropping pt bin 5-10 (now really)
jhoss Nov 10, 2015
b684dec
git: ignore root files
jhoss Nov 10, 2015
97a9e3c
display min and max in ratio plot, save root file of ratio plot
jhoss Nov 10, 2015
da70c76
added stacked working points, restructured and renamed output root files
jhoss Nov 11, 2015
82de75e
fix typos
jhoss Nov 11, 2015
6f07846
remove useless parts from output file name
jhoss Nov 11, 2015
15cc050
avoid ambiguity in file naming
jhoss Nov 11, 2015
8e0eda9
add source for small Ntuples for testing
jhoss Nov 11, 2015
24a7d62
script to merge efficiencies to 2D eta pt maps
jhoss Nov 11, 2015
8d76a6c
2D eta pt maps working
jhoss Nov 12, 2015
73be681
new binning for pt-eta maps
jhoss Nov 12, 2015
f972bac
adapted legend header text for new samples, prepared for 3 eta bins
jhoss Nov 12, 2015
da74b20
minor addition
jhoss Nov 12, 2015
29e8641
adapt ratio plots for new plots and new names
jhoss Nov 13, 2015
3f000c8
smaller updates, 4 eta bins
jhoss Nov 15, 2015
1e0618b
take input samples from afs, fix selection of fitting functions
jhoss Nov 16, 2015
a6b70ab
pt bin 25, fit range 77 or 70 depending on bin
jhoss Nov 16, 2015
4278de8
adjustments for 4th eta bin
jhoss Nov 16, 2015
b63302b
fix error in pt binning
jhoss Nov 16, 2015
91c6022
use chebychev fit also for stacked bins
jhoss Nov 17, 2015
066e159
y range adjustments for ratio plots
jhoss Nov 18, 2015
5b68e36
corrected eta labling
jhoss Nov 18, 2015
692f6e7
new input tree location
jhoss Nov 19, 2015
62e00d1
script for making 2D pt activity maps
jhoss Nov 20, 2015
b6d4eb1
labling of stacked histograms improved
jhoss Nov 20, 2015
1544aed
only run pt-eta maps
jhoss Dec 1, 2015
147c2f6
Merge pull request #13 from jhoss/eff2015_v2_jan
gael-perrin Dec 1, 2015
f530bf2
path to files for top-up
jhoss Dec 2, 2015
8594adc
Merge pull request #14 from jhoss/eff2015_v2_jan
gael-perrin Dec 2, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ __init__.py
.#*
#*#
*~
*.sh
*.root
submit.sh
452 changes: 283 additions & 169 deletions test/zmumu/SUSY/SF2015/fitMuonID.py

Large diffs are not rendered by default.

285 changes: 285 additions & 0 deletions test/zmumu/SUSY/SF2015/make_PtActivityMaps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
import ROOT as r
import os
import glob
import sys
from array import *
import numpy as np
import string

debug = True
nActBins = 5

r.gROOT.SetBatch()
r.gStyle.SetOptStat(0)
args = sys.argv[1:]
iteration = '1'
if len(args) > 0: iteration = args[0]
print "The iteration is ", iteration
if len(args) > 0: order = args[1]
_sample1 = '/DATA25ns2015D/'
_sample2 = '/MC25ns2015D' + order + '/'
_folder1 = os.getcwd() + '/Efficiency' + iteration + '/' + _sample1 + '/'
_folder2 = os.getcwd() + '/Efficiency' + iteration + '/' + _sample2 + '/'
_folder_out = os.getcwd() + '/RatioMap' + iteration + '/' + 'DATA_vs_MC' + order + '/'
if not os.path.exists(_folder_out):
os.makedirs(_folder_out)

_tptree = 'tpTree'

dir = os.listdir(_folder1)
os.chdir(_folder1)
for file in glob.glob("*map_activity_pt*.root"):
if debug: print 'the file is ', file
if file.find('TnP_MuonID') != -1:
if not os.path.isfile(_folder1 + '/' + file):
if debug: print 'The file ', file, 'doesn\'t exist in ', _folder1
continue
else:
if debug: print 'The file', file, 'exists !'
f = r.TFile.Open(_folder1+file)
r.gDirectory.cd(_tptree)
for key in r.gDirectory.GetListOfKeys():
print "The name of the key is", key.GetName()
r.gDirectory.cd(key.GetName())
r.gDirectory.cd('fit_eff_plots')
PLOTS = r.gDirectory.GetListOfKeys()
PLOTS.ls()
for plot in PLOTS:
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin0_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin0"
actbin0_mc = hist
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin1_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin1"
actbin1_mc = hist
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin2_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin2"
actbin2_mc = hist
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin3_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin3"
actbin3_mc = hist
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin4_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin4"
actbin4_mc = hist


if debug: print 'the file is ', file
if file.find('TnP_MuonID') != -1:
if not os.path.isfile(_folder2 + '/' + file):
if debug: print 'The file ', file, 'doesn\'t exist in ', _folder2
continue
else:
if debug: print 'The file', file, 'exists !'
f = r.TFile.Open(_folder2+file)
r.gDirectory.cd(_tptree)
for key in r.gDirectory.GetListOfKeys():
print "The name of the key is", key.GetName()
r.gDirectory.cd(key.GetName())
r.gDirectory.cd('fit_eff_plots')
PLOTS = r.gDirectory.GetListOfKeys()
PLOTS.ls()
for plot in PLOTS:
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin0_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin0"
actbin0_data = hist
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin1_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin1"
actbin1_data = hist
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin2_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin2"
actbin2_data = hist
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin3_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin3"
actbin3_data = hist
if plot.GetName().startswith("pt_PLOT_pfCombRelActivitydBCorr_bin4_"):
canvas = plot.ReadObj()
HISTS = canvas.GetListOfPrimitives()
for hist in HISTS:
print hist
if hist.GetName().startswith("hxy_fit_eff"):
print "found actbin4"
actbin4_data = hist

c1=r.TCanvas("c1","c1",1200,800)
p1 = r.TPad("p1","p1",0.01,0.01,0.99,0.99);
p1.Draw();
p1.cd();
p1.SetLogy()

Map = r.TH2F()
Map = p1.DrawFrame(10,0.001,200,10)
xbins = np.array([10.,40.,80.,200.])
ybins = np.array([0.001, 0.02, 0.05, 0.15, 1., 10.])
p1.Update()


SFmap = r.TH2F("SFmap", file, 3, xbins, 5, ybins)

pt_data = 0
eff_data = 0
pt_data = r.Double(pt_data)
eff_data = r.Double(eff_data)

pt_mc = 0
eff_mc = 0
pt_mc = r.Double(pt_mc)
eff_mc = r.Double(eff_mc)

for act in range(nActBins):
for i in range(actbin0_data.GetN()):
if act==0:
actbin0_data.GetPoint(i, pt_data, eff_data)
errh_data = actbin0_data.GetErrorYhigh(i)
errl_data = actbin0_data.GetErrorYlow(i)
actbin0_mc.GetPoint(i, pt_mc, eff_mc)
errh_mc = actbin0_mc.GetErrorYhigh(i)
errl_mc = actbin0_mc.GetErrorYlow(i)
a = eff_data/eff_mc * ((errh_data/eff_data)**2 + (errh_mc/eff_mc)**2)**.5
b = eff_data/eff_mc * ((errl_data/eff_data)**2 + (errl_mc/eff_mc)**2)**.5
err = max(a,b)
SFmap.SetBinContent(i+1, act+1, eff_data/eff_mc)
SFmap.SetBinError(i+1, act+1, err)
if act==1:
actbin1_data.GetPoint(i, pt_data, eff_data)
errh_data = actbin1_data.GetErrorYhigh(i)
errl_data = actbin1_data.GetErrorYlow(i)
actbin1_mc.GetPoint(i, pt_mc, eff_mc)
errh_mc = actbin1_mc.GetErrorYhigh(i)
errl_mc = actbin1_mc.GetErrorYlow(i)
a = eff_data/eff_mc * ((errh_data/eff_data)**2 + (errh_mc/eff_mc)**2)**.5
b = eff_data/eff_mc * ((errl_data/eff_data)**2 + (errl_mc/eff_mc)**2)**.5
err = max(a,b)
SFmap.SetBinContent(i+1, act+1, eff_data/eff_mc)
SFmap.SetBinError(i+1, act+1, err)
if act==2:
actbin1_data.GetPoint(i, pt_data, eff_data)
errh_data = actbin2_data.GetErrorYhigh(i)
errl_data = actbin2_data.GetErrorYlow(i)
actbin2_mc.GetPoint(i, pt_mc, eff_mc)
errh_mc = actbin2_mc.GetErrorYhigh(i)
errl_mc = actbin2_mc.GetErrorYlow(i)
a = eff_data/eff_mc * ((errh_data/eff_data)**2 + (errh_mc/eff_mc)**2)**.5
b = eff_data/eff_mc * ((errl_data/eff_data)**2 + (errl_mc/eff_mc)**2)**.5
err = max(a,b)
SFmap.SetBinContent(i+1, act+1, eff_data/eff_mc)
SFmap.SetBinError(i+1, act+1, err)
if act==3:
actbin3_data.GetPoint(i, pt_data, eff_data)
errh_data = actbin3_data.GetErrorYhigh(i)
errl_data = actbin3_data.GetErrorYlow(i)
actbin3_mc.GetPoint(i, pt_mc, eff_mc)
errh_mc = actbin3_mc.GetErrorYhigh(i)
errl_mc = actbin3_mc.GetErrorYlow(i)
a = eff_data/eff_mc * ((errh_data/eff_data)**2 + (errh_mc/eff_mc)**2)**.5
b = eff_data/eff_mc * ((errl_data/eff_data)**2 + (errl_mc/eff_mc)**2)**.5
err = max(a,b)
SFmap.SetBinContent(i+1, act+1, eff_data/eff_mc)
SFmap.SetBinError(i+1, act+1, err)
if act==4:
actbin4_data.GetPoint(i, pt_data, eff_data)
errh_data = actbin4_data.GetErrorYhigh(i)
errl_data = actbin4_data.GetErrorYlow(i)
actbin4_mc.GetPoint(i, pt_mc, eff_mc)
errh_mc = actbin4_mc.GetErrorYhigh(i)
errl_mc = actbin4_mc.GetErrorYlow(i)
a = eff_data/eff_mc * ((errh_data/eff_data)**2 + (errh_mc/eff_mc)**2)**.5
b = eff_data/eff_mc * ((errl_data/eff_data)**2 + (errl_mc/eff_mc)**2)**.5
err = max(a,b)
SFmap.SetBinContent(i+1, act+1, eff_data/eff_mc)
SFmap.SetBinError(i+1, act+1, err)



ncontours = 999
MyPalette = []
stops = [0.00, 0.50, 1.00]
red = [0.00, 1.00, 1.00]
green = [0.00, 1.00, 0.00]
blue = [1.00, 1.00, 0.00]

st = array('d', stops)
re = array('d', red)
gr = array('d', green)
bl = array('d', blue)

npoints = len(st)
FI = r.TColor.CreateGradientColorTable(npoints, st, re, gr, bl, ncontours)

nLevels = 999;
levels = []
zmin = 0.9
zmax = 1.1

for i in range(nLevels):
levels.append(zmin + (zmax - zmin) / (nLevels - 1) * (i))
levels = array('d', levels)

SFmap.SetContour(nLevels)

filename = string.replace(file, '.root', '')
SFmap.SetTitle(file)
SFmap.SetMarkerSize(1.0)
SFmap.Draw("COLZ")
SFmap.GetXaxis().SetTitle("muon p_{T} (GeV/c)")
SFmap.GetXaxis().SetTitleOffset(1.2)
SFmap.GetYaxis().SetTitle("Rel. Activity")
c1.Update()
r.gStyle.SetPaintTextFormat("4.3f")
SFmap.GetZaxis().SetRangeUser(zmin,zmax)

SFmap.Draw("TEXT E same")
c1.Update()

fout = r.TFile(_folder_out + file, "RECREATE");
SFmap.Write();
c1.SaveAs(_folder_out + filename + '.png')
c1.SaveAs(_folder_out + filename + '.pdf')

fout.Close();



Loading