ATLAS Offline Software
Loading...
Searching...
No Matches
plot_material.HistManager Class Reference
Collaboration diagram for plot_material.HistManager:

Public Member Functions

 __init__ (self)
 addHist2D (self, name, binx, xmin, xmax, biny, ymin, ymax, xlab="", ylab="", zlab="", average=False)
 hist2DExists (self, name)
 fillHist2D (self, name, x, y, *args)
 hist2D (self, name)
 hist2Diter (self)

Protected Member Functions

 _key (self, k)

Protected Attributes

dict _hist2D = {}
dict _hist2D_count = {}

Detailed Description

Definition at line 66 of file plot_material.py.

Constructor & Destructor Documentation

◆ __init__()

plot_material.HistManager.__init__ ( self)

Definition at line 67 of file plot_material.py.

67 def __init__(self):
68 self._hist2D = {}
69 self._hist2D_count = {}
70

Member Function Documentation

◆ _key()

plot_material.HistManager._key ( self,
k )
protected

Definition at line 71 of file plot_material.py.

71 def _key(self, k):
72 if type(k) == tuple:
73 return "_".join(str(v) for v in k)
74 else:
75 return k
76

◆ addHist2D()

plot_material.HistManager.addHist2D ( self,
name,
binx,
xmin,
xmax,
biny,
ymin,
ymax,
xlab = "",
ylab = "",
zlab = "",
average = False )

Definition at line 77 of file plot_material.py.

77 def addHist2D(self, name, binx, xmin, xmax, biny, ymin, ymax, xlab="", ylab="", zlab="", average=False):
78 key = self._key(name)
79 root_name = os.path.basename(name)
80
81 assert key not in self._hist2D, "hist2D with key {} exists".format(key)
82 self._hist2D[key] = ROOT.TH2D(root_name, root_name, binx, xmin, xmax, biny, ymin, ymax)
83 self._hist2D[key].GetXaxis().SetTitle(xlab)
84 self._hist2D[key].GetYaxis().SetTitle(ylab)
85 self._hist2D[key].GetZaxis().SetTitle(zlab)
86
87
88
89 if average:
90 self._hist2D_count[key] = ROOT.TH2D(root_name+"_count", root_name+"_count", binx, xmin, xmax, biny, ymin, ymax)
91

◆ fillHist2D()

plot_material.HistManager.fillHist2D ( self,
name,
x,
y,
* args )

Definition at line 96 of file plot_material.py.

96 def fillHist2D(self, name, x, y, *args):
97 key = self._key(name)
98 assert key in self._hist2D, "{} not in histograms".format(key)
99 self._hist2D[key].Fill(x, y, *args)
100 if key in self._hist2D_count:
101 self._hist2D_count[key].Fill(x, y)
102

◆ hist2D()

plot_material.HistManager.hist2D ( self,
name )

Definition at line 103 of file plot_material.py.

103 def hist2D(self, name):
104 key = self._key(name)
105 return self._hist2D[key]
106

◆ hist2DExists()

plot_material.HistManager.hist2DExists ( self,
name )

Definition at line 92 of file plot_material.py.

92 def hist2DExists(self, name):
93 key = self._key(name)
94 return key in self._hist2D
95

◆ hist2Diter()

plot_material.HistManager.hist2Diter ( self)

Definition at line 107 of file plot_material.py.

107 def hist2Diter(self):
108 for name, hist in self._hist2D.items():
109 if name not in self._hist2D_count:
110 yield name, hist
111 else:
112 hist_divided = hist.Clone()
113 hist_divided.Divide(self._hist2D_count[name])
114 yield name, hist_divided

Member Data Documentation

◆ _hist2D

plot_material.HistManager._hist2D = {}
protected

Definition at line 68 of file plot_material.py.

◆ _hist2D_count

dict plot_material.HistManager._hist2D_count = {}
protected

Definition at line 69 of file plot_material.py.


The documentation for this class was generated from the following file: