-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNormalize_Histo.py
More file actions
49 lines (30 loc) · 943 Bytes
/
Normalize_Histo.py
File metadata and controls
49 lines (30 loc) · 943 Bytes
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
import ROOT
input_root_file = ROOT.TFile.Open("WZ_2016.root","UPDATE")
output_root_file = ROOT.TFile.Open("Edited_output.root","RECREATE")
root_keys = input_root_file.GetListOfKeys()
for key in root_keys:
key_obj = key.ReadObj()
# histo_name = key_obj.GetName()
# print(histo_name)
# print(type(histo_name))
# ROOT.gStyle.SetLineStyleString(1,"400 200")
output_root_file.cd()
############################
# b+l+nu invariant mass
############################
NMuon1 = input_root_file.Get("NGenElectron/NMuon1")
NMuon1.SetLineColor(ROOT.kBlue)
c1 = ROOT.TCanvas("NMuon1", "NMuon1", 600, 400)
pad1 = ROOT.TPad("Pad1", "Pad1", 0.0, 0.0, 0.95, 0.95)
pad1.Draw()
pad1.cd()
NMuon1.Scale(1.0/NMuon1.Integral(0,10000))
th1 = ROOT.THStack()
th1.Add(NMuon1)
th1.Draw("Hist text")
th1.GetXaxis().SetTitle("NMuon1")
th1.GetYaxis().SetTitle("a.u.")
c1.Write()
input_root_file.Purge()
input_root_file.Close()
output_root_file.Close()