|
def | __init__ (self, name="", axis_title="", bins=-1, bmin=0., bmax=-1.e9, bin_width=-1, bdir=None, log_binning=False) |
|
def | has_log_binnnig (self) |
|
def | name (self) |
|
def | TH1 (self) |
|
def | fill (self, value, weight=1.) |
|
def | write (self) |
|
def | max (self) |
|
def | min (self) |
|
def | setMinimum (self, minimum) |
|
def | setMaximum (self, maximum) |
|
def | fixHisto (self) |
|
Definition at line 18 of file PlotUtils.py.
◆ __init__()
def PlotUtils.DiagnosticHisto.__init__ |
( |
|
self, |
|
|
|
name = "" , |
|
|
|
axis_title = "" , |
|
|
|
bins = -1 , |
|
|
|
bmin = 0. , |
|
|
|
bmax = -1.e9 , |
|
|
|
bin_width = -1 , |
|
|
|
bdir = None , |
|
|
|
log_binning = False |
|
) |
| |
Definition at line 19 of file PlotUtils.py.
28 self.__xTitle = axis_title
30 self.__width = bin_width
37 self.__log_binning = log_binning
38 if bins > 0
and not log_binning:
39 self.__width = (bmax-bmin)/ bins
40 self.__TH1 = ROOT.TH1D(name,
"Diagnostic histogram", bins, bmin, bmax)
43 log_start = math.log(bmin)
44 log_end = math.log(bmax)
45 log_step = (log_end -log_start) / bins
46 binning =
array(
"f", [math.exp(log_start +n*log_step)
for n
in range(bins+1)])
47 self.__TH1 = ROOT.TH1D(name,
"Diagnostic histogram", bins, binning)
◆ __getInterval()
def PlotUtils.DiagnosticHisto.__getInterval |
( |
|
self, |
|
|
|
value |
|
) |
| |
|
private |
Definition at line 62 of file PlotUtils.py.
62 def __getInterval(self,value):
63 i = math.ceil( (value - self.__min) / self.__width)
64 return (self.__min +self.__width*(i-1), self.__min+ self.__width*i)
◆ fill()
def PlotUtils.DiagnosticHisto.fill |
( |
|
self, |
|
|
|
value, |
|
|
|
weight = 1. |
|
) |
| |
Definition at line 53 of file PlotUtils.py.
53 def fill(self, value, weight=1.):
55 if self.__TH1: self.__TH1.Fill(value, weight)
57 rng = self.__getInterval(value)
58 try: self.__content[rng] += weight
59 except: self.__content[rng] = weight
60 try: self.__error[rng] += weight**2
61 except: self.__error[rng] = weight**2
◆ fixHisto()
def PlotUtils.DiagnosticHisto.fixHisto |
( |
|
self | ) |
|
Definition at line 86 of file PlotUtils.py.
88 bins = min (
int((self.__max - self.__min) / self.__width), 10000)
89 self.__TH1 = ROOT.TH1D(self.name(),
"Diagnostic histogram", bins, self.__min, self.__max)
92 for rng
in self.__content.
iterkeys():
93 bin = self.__TH1.
FindBin((rng[1] + rng[0])/2.)
94 self.__TH1.SetBinContent(bin, self.__content[rng])
95 self.__TH1.SetBinError(bin, math.sqrt(self.__error[rng]))
◆ has_log_binnnig()
def PlotUtils.DiagnosticHisto.has_log_binnnig |
( |
|
self | ) |
|
Definition at line 50 of file PlotUtils.py.
50 def has_log_binnnig(self):
return self.__log_binning
◆ max()
def PlotUtils.DiagnosticHisto.max |
( |
|
self | ) |
|
◆ min()
def PlotUtils.DiagnosticHisto.min |
( |
|
self | ) |
|
◆ name()
def PlotUtils.DiagnosticHisto.name |
( |
|
self | ) |
|
◆ setMaximum()
def PlotUtils.DiagnosticHisto.setMaximum |
( |
|
self, |
|
|
|
maximum |
|
) |
| |
Definition at line 85 of file PlotUtils.py.
85 def setMaximum(self, maximum): self.__max = maximum
◆ setMinimum()
def PlotUtils.DiagnosticHisto.setMinimum |
( |
|
self, |
|
|
|
minimum |
|
) |
| |
Definition at line 84 of file PlotUtils.py.
84 def setMinimum(self, minimum): self.__min = minimum
◆ TH1()
def PlotUtils.DiagnosticHisto.TH1 |
( |
|
self | ) |
|
Definition at line 52 of file PlotUtils.py.
52 def TH1(self):
return self.__TH1
◆ write()
def PlotUtils.DiagnosticHisto.write |
( |
|
self | ) |
|
Definition at line 65 of file PlotUtils.py.
67 if not self.__TH1:
return
68 self.__TH1.GetXaxis().SetTitle(self.__xTitle)
70 self.TH1().SetBinContent(self.TH1().GetNbinsX(),self.TH1().GetBinContent(self.TH1().GetNbinsX()+1) + self.TH1().GetBinContent(self.TH1().GetNbinsX()))
71 self.TH1().SetBinError(self.TH1().GetNbinsX(), math.sqrt( (self.TH1().GetBinError(self.TH1().GetNbinsX()+1) + self.TH1().GetBinError(self.TH1().GetNbinsX()))**2))
73 self.TH1().SetBinContent(1,self.TH1().GetBinContent(0) + self.TH1().GetBinContent(1))
74 self.TH1().SetBinError(1, math.sqrt( (self.TH1().GetBinError(0) + self.TH1().GetBinError(1))**2))
76 self.__TH1.SetEntries(self.__entries)
77 if self.__TDir: self.__TDir.WriteObject(self.__TH1, self.__name)
◆ __content
PlotUtils.DiagnosticHisto.__content |
|
private |
◆ __entries
PlotUtils.DiagnosticHisto.__entries |
|
private |
◆ __error
PlotUtils.DiagnosticHisto.__error |
|
private |
◆ __log_binning
PlotUtils.DiagnosticHisto.__log_binning |
|
private |
◆ __max
PlotUtils.DiagnosticHisto.__max |
|
private |
◆ __min
PlotUtils.DiagnosticHisto.__min |
|
private |
◆ __name
PlotUtils.DiagnosticHisto.__name |
|
private |
◆ __TDir
PlotUtils.DiagnosticHisto.__TDir |
|
private |
◆ __TH1
PlotUtils.DiagnosticHisto.__TH1 |
|
private |
◆ __width
PlotUtils.DiagnosticHisto.__width |
|
private |
◆ __xTitle
PlotUtils.DiagnosticHisto.__xTitle |
|
private |
The documentation for this class was generated from the following file: