forked from apaasch/UHH_EXP18_LHC-Analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHistograms.py
34 lines (28 loc) · 950 Bytes
/
Histograms.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
import ROOT
from collections import OrderedDict
class Histograms(object):
"""
A collection of histograms.
"""
def __init__(self, name):
self.name = name
if not self.hists:
self.hists = OrderedDict()
self.is_init = False
self.initialize_histograms()
def initialize_histograms(self):
"""
Add collection name to histograms to avoid root overwriting
histograms with same name.
"""
# prevent to initialize histograms multiple times
if self.is_init:
raise ValueError("Histograms(): called initialize_histograms() on initialized histograms")
for hist in self.hists.values():
hist.SetName(self.name+"_"+hist.GetName())
def fill(self, event):
"""
Fill histograms.
Has to be implemented by actual implemenation of Histograms.
"""
raise NotImplementedError()