-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcreateMVAPerfsCanvases.py
123 lines (107 loc) · 3.78 KB
/
createMVAPerfsCanvases.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
import copy
import ROOT
from tools.drawCanvas import drawCanvas
# "Aliases"
drawStyle = "LX"
markerStyle = 24
markerSize = 1.35
lineStyle = 1
lineWidth = 2
grid = "xy"
log = ""
xRange = [-0.3,0.1]
yRange = [0, 0.7]
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)",
},
]
MVAs = [
{
"name": "No preselection",
"color": ROOT.kOrange,
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/BDT_LogdZ_length_dist_IP2D_pt_chi2_nHitPix_nHitAll/jetMVAperf_TC.root"
},
{
"name": "Loose preselection",
"color": ROOT.kRed,
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/BDT_loosenedbTagCuts_dZ_length_dist_IP2D_pt_chi2_nHitPix_nHitAll/jetMVAperf_TC.root"
},
{
"name": "Default preselection",
"color": ROOT.kMagenta+1,
"file": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/BDT_bTagCuts_LogdZ_length_dist_IP2D_pt_chi2_nHitPix_nHitAll/jetMVAperf_TC.root"
}
]
discriminants = [
{
"key": "TCHE_DiscrEff",
"filename": "TCHE",
"title": "TCHE",
"wps": ["loose", "medium"]
},
{
"key": "TCHP_DiscrEff",
"filename": "TCHP",
"title": "TCHP",
"wps": ["loose", "medium"]
},
]
# General configuration
runCfg = {
"outFile": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/rejFakeTracks_manyMVA/jetMVAperfCanvases_TC.root",
#"printDir": "/home/fynu/swertz/CMS_tasks/BTagTrackSel/myTrees/testFormulaMVA/MVAplots", # optional
"formats": ["png"], # optional
"batch": True, # optional
}
# Will hold the canvases
canvasCfg = []
for discr in discriminants:
for wp in discr["wps"]:
for flav in flavours:
myGraphs = []
for mva in MVAs:
graphCfg = {
"file": mva["file"],
"key": flav["key"] + "/" + discr["key"] + "_" + wp,
"name": mva["name"],
"color": mva["color"],
"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)
}
myGraphs.append(graphCfg)
myCanvas = {
"name": discr["filename"] + "_" + flav["filename"] + "_" + wp, # Name of the canvas for the output ROOT/png/... files
"xSize": xSize,
"ySize": ySize,
"title": discr["title"] + " " + wp + " " + flav["title"],
"legPos": "tl", # t/b, l/r
"xRange": xRange, # optional
"yRange": yRange, # optional
"grid": grid, # optional
"log": log, # optional
"xTitle": "MVA cut", # optional
"yTitle": "B-jet efficiency", # optional
"graphs": myGraphs,
}
canvasCfg.append(myCanvas)
# We're all set!
if __name__ == "__main__":
drawCanvas(runCfg, canvasCfg, mode = "TGraph")