forked from kdlong/WZConfigPlotting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeCutFlow.py
executable file
·42 lines (40 loc) · 1.58 KB
/
makeCutFlow.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
#!/usr/bin/env python
import ROOT
from Utilities import CutFlowTools
import Utilities.UserInput as UserInput
import Utilities.helper_functions as helper
from Utilities import CutFlowDefinitions
from Utilities.scripts import makeSimpleHtml
import os
def getMonteCarloStack(cutflow_maker, filelist, unc, scale_facs):
hist_stack = ROOT.THStack("stack", "")
for plot_set in filelist:
hist = cutflow_maker.getHist(plot_set, unc, "", scale_facs)
hist_stack.Add(hist)
return hist_stack
ROOT.gROOT.SetBatch(True)
ROOT.TProof.Open('workers=12')
path = "/cms/kdlong" if "hep.wisc.edu" in os.environ['HOSTNAME'] else \
"/afs/cern.ch/work/m/mumuhamm/WBoson/CMSSW_11_0_0/src/Data_Manager"
parser = UserInput.getDefaultParser()
args = parser.parse_args()
cutflow_maker = CutFlowDefinitions.getWZCutFlow(
"%s/AnalysisDatasetManager" % path,
"full"
)
cutflow_maker.setLuminosity(args.luminosity)
cutflow_maker.setStates(args.channels)
filelist = UserInput.getListOfFiles(args.files_to_plot, "Wselection")
if not args.no_data:
data_hist = cutflow_maker.getHist("data_2016", "stat", "")
else:
data_hist = 0
hist_stack = getMonteCarloStack(cutflow_maker, filelist,
args.uncertainties, not args.no_scalefactors)
hist_stack.Draw()
hist_stack.GetXaxis().SetLabelSize(0.4*8/9)
canvas = helper.makePlot(hist_stack, data_hist, "CutFlow", args)
canvas.SetRightMargin(0.3)
(plot_path, html_path) = helper.getPlotPaths("WZxsec2016/Wselection", args.folder_name)
helper.savePlot(canvas, plot_path, html_path, "CutFlow", False, args)
makeSimpleHtml.writeHTML(html_path, "Wselection")