-
Notifications
You must be signed in to change notification settings - Fork 3
/
plotHistos_auto.py
168 lines (151 loc) · 4.88 KB
/
plotHistos_auto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import copy
import ROOT
from tools.drawCanvas import drawCanvas
# "Aliases"
lineStyle = 1
lineWidth = 2
grid = "xy"
xSize = 800
ySize = 600
flavours = [
{
"key": "Bjets",
"filename": "Bjets",
"title": "(b-jets)",
},
{
"key": "Lightjets",
"filename": "Lightjets",
"title": "(light jets)",
},
{
"key": "Cjets",
"filename": "Cjets",
"title": "(c-jets)",
},
{
"key": "PUjets",
"filename": "PUjets",
"title": "(PU jets)",
},
]
cuts = [
{
"name": "bTag cuts", # for legend
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/btagCutsOnly/jetHistos_TC_btagCutsOnly.root",
"color": ROOT.kBlue,
},
{
"name": "Cuts + MVA>0.65",
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/MLP_N_Nmin1_bTag_zIPSel_ptChi2BothHits/jetHistos_TC_btagCuts_MLP_N_Nmin1_bTag_zIPSel_ptChi2BothHits_CUT065.root",
"color": ROOT.kMagenta+1,
},
{
"name": "Cuts + MVA>0.7",
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/MLP_N_Nmin1_bTag_zIPSel_ptChi2BothHits/jetHistos_TC_btagCuts_MLP_N_Nmin1_bTag_zIPSel_ptChi2BothHits_CUT07.root",
"color": ROOT.kGreen+1,
},
{
"name": "Cuts + MVA>0.75",
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/MLP_N_Nmin1_bTag_zIPSel_ptChi2BothHits/jetHistos_TC_btagCuts_MLP_N_Nmin1_bTag_zIPSel_ptChi2BothHits_CUT075.root",
"color": ROOT.kOrange,
},
{
"name": "Cuts + MVA>0.8",
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/MLP_N_Nmin1_bTag_zIPSel_ptChi2BothHits/jetHistos_TC_btagCuts_MLP_N_Nmin1_bTag_zIPSel_ptChi2BothHits_CUT08.root",
"color": ROOT.kRed,
},
]
histos = [
{
"key": "Jet_pt",
"filename": "Jet_pt",
"title": "Jet Pt",
"xTitle": "Jet Pt (GeV)",
"log": "",
"rebin": 4,
},
{
"key": "Jet_ntracks",
"filename": "Jet_ntracks",
"title": "Jet total number of tracks",
"xTitle": "Jet_ntracks",
"log": "",
"rebin": 2,
},
{
"key": "Jet_nseltracks",
"filename": "Jet_nseltracks",
"title": "Jet number of selected tracks",
"xTitle": "Jet_nseltracks",
"log": "",
},
{
"key": "Jet_Ip_DiscrEff",
"filename": "Jet_IPsig",
"title": "Jet_IPsig",
"xTitle": "Jet_IPsig",
"log": "",
"rebin": 2,
},
{
"key": "TCHE_DiscrEff",
"filename": "TCHE",
"title": "TCHE discriminant",
"xTitle": "TCHE",
"log": "",
"rebin": 2,
},
{
"key": "TCHP_DiscrEff",
"filename": "TCHP",
"title": "TCHP discriminant",
"xTitle": "TCHP",
"log": "",
"rebin": 2,
},
]
# General configuration
runCfg = {
"outFile": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/bTag-trackSel-optimisation/jetPlots.root",
"printDir": "./jetPlots", # optional
"formats": ["png"], # optional
"batch": True, # optional
}
# Will hold the canvases
canvasCfg = []
for histo in histos:
for flav in flavours:
myHists = []
for cut in cuts:
histCfg = {
"file": cut["file"],
"key": flav["key"] + "/" + histo["key"],
"name": cut["name"],
"color": cut["color"],
"lineStyle": lineStyle, # Only used if "L" in "style" (default 1)
"lineWidth": lineWidth, # (default 1)
}
try:
histCfg["rebin"] = histo["rebin"] # optional
histCfg["xRange"] = histo["xRange"] # optional
except KeyError:
pass
myHists.append(histCfg)
myCanvas = {
"name": histo["filename"] + "_" + flav["filename"], # Name of the canvas for the output ROOT/png/... files
"xSize": xSize,
"ySize": ySize,
"title": histo["title"] + " " + flav["title"],
"legPos": "tr", # t/b, l/r
"grid": grid, # optional
"log": histo["log"], # optional
"xTitle": histo["xTitle"],
"yTitle": "Arbitrary scale", # optional
"norm": True,
"hists": myHists,
}
canvasCfg.append(myCanvas)
# We're all set!
if __name__ == "__main__":
drawCanvas(runCfg, canvasCfg, mode = "TH1")