-
Notifications
You must be signed in to change notification settings - Fork 3
/
createROCCanvases.py
169 lines (151 loc) · 5.61 KB
/
createROCCanvases.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
168
import copy
import ROOT
from tools.drawCanvas import drawCanvas
# "Aliases"
drawStyle = "LX"
markerStyle = 24
markerSize = 1.35
lineStyle = 1
lineWidth = 2
grid = "xy"
log = "y"
xRange = [0,0.85]
yRange = [10**-3, 1]
xSize = 800
ySize = 600
flavours = [
{
"key": "Bjets_vs_Lightjets",
"filename": "Lightjets",
"title": "(light jets)",
},
{
"key": "Bjets_vs_Cjets",
"filename": "Cjets",
"title": "(c-jets)",
},
{
"key": "Bjets_vs_PUjets",
"filename": "PUjets",
"title": "(PU jets)",
},
]
#cuts = [
# {
# "name": "MVA>#cutvalue",
# "wps": [
# { "idx": 8, "val": -0.08, "col": ROOT.kMagenta+1 },
# { "idx": 12, "val": -0.07, "col": ROOT.kGreen+1 },
# { "idx": 20, "val": -0.05, "col": ROOT.kOrange },
# { "idx": 28, "val": -0.03, "col": ROOT.kRed },
# ],
# "file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/BDT_LogdZ_length_dist_IP2D_pt_chi2_nHitPix_nHitAll/jetROC_TC.root",
# },
# {
# "name": "Default cuts",
# "wps": [
# { "idx": 0, "col": ROOT.kBlue }
# ],
# "file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/btagCutsOnly/jetROC_TC.root",
# }
# ]
cuts = [
{
"name": "Loosened cuts + MVA>#cutvalue",
"wps": [
{ "idx": 14, "val": -0.2, "col": ROOT.kMagenta+1 },
{ "idx": 18, "val": -0.11, "col": ROOT.kGreen+1 },
{ "idx": 30, "val": -0.05, "col": ROOT.kOrange },
{ "idx": 40, "val": 0.0, "col": ROOT.kRed },
],
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/BDT_loosenedbTagCuts_dZ_length_dist_IP2D_pt_chi2_nHitPix_nHitAll/jetROC_TC.root",
},
{
"name": "Default cuts",
"wps": [
{ "idx": 0, "col": ROOT.kBlue }
],
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/btagCutsOnly/jetROC_TC.root",
}
]
#cuts = [
# {
# "name": "Default cuts + MVA>#cutvalue",
# "wps": [
# { "idx": 0, "val": -0.3, "col": ROOT.kMagenta+1 },
# { "idx": 20, "val": -0.2, "col": ROOT.kGreen+1 },
# { "idx": 40, "val": -0.1, "col": ROOT.kOrange },
# { "idx": 70, "val": 0.05, "col": ROOT.kRed },
# ],
# "file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/BDT_bTagCuts_LogdZ_length_dist_IP2D_pt_chi2_nHitPix_nHitAll/jetROC_TC.root",
# },
# {
# "name": "Default cuts",
# "wps": [
# { "idx": 0, "col": ROOT.kBlue }
# ],
# "file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/btagCutsOnly/jetROC_TC.root",
# }
# ]
discriminants = [
{
"key": "TCHE_DiscrEff",
"filename": "TCHE",
"title": "TCHE performances",
},
{
"key": "TCHP_DiscrEff",
"filename": "TCHP",
"title": "TCHP performances",
},
]
# General configuration
runCfg = {
"outFile": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/comp_default_vs_BDTloosenedCuts.root",
#"printDir": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/plots", # optional
"formats": ["png"], # optional
"batch": True, # optional
}
# Will hold the canvases
canvasCfg = []
for discr in discriminants:
for flav in flavours:
myGraphs = []
for cut in cuts:
for wp in cut["wps"]:
graphCfg = {
"file": cut["file"],
"key": flav["key"] + "/" + discr["key"],
# Following two options only when the Graph is retrieved from a list of graphs in the file
"isFromTList": True,
"idx": wp["idx"],
"color": wp["col"],
"style": drawStyle,
"markerStyle": markerStyle, # Only used if "P" in "style" (default 20)
"markerSize": markerSize, # (default 1)
"lineStyle": lineStyle, # Only used if "L" in "style" (default 1)
"lineWidth": lineWidth, # (default 1)
}
try:
graphCfg["name"] = cut["name"].replace("#cutvalue", str(wp["val"]))
except KeyError:
graphCfg["name"] = cut["name"]
myGraphs.append(graphCfg)
myCanvas = {
"name": discr["filename"] + "_" + flav["filename"], # Name of the canvas for the output ROOT/png/... files
"xSize": xSize,
"ySize": ySize,
"title": discr["title"] + " " + flav["title"],
"legPos": "br", # t/b, l/r
"xRange": xRange, # optional
"yRange": yRange, # optional
"grid": grid, # optional
"log": log, # optional
"xTitle": "B-jet efficiency", # optional
"yTitle": "Background efficiency", # optional
"graphs": myGraphs,
}
canvasCfg.append(myCanvas)
# We're all set!
if __name__ == "__main__":
drawCanvas(runCfg, canvasCfg, mode = "TGraph")