ATLAS Offline Software
Loading...
Searching...
No Matches
PlotUtils.DiagnosticHisto Class Reference
Inheritance diagram for PlotUtils.DiagnosticHisto:
Collaboration diagram for PlotUtils.DiagnosticHisto:

Public Types

typedef HLT::TypeInformation::for_each_type_c< typenameEDMLIST::map, my_functor, my_result<>, my_arg< HLT::TypeInformation::get_cont, CONTAINER > >::type result

Public Member Functions

 __init__ (self, name="", axis_title="", bins=-1, bmin=0., bmax=-1.e9, bin_width=-1, bdir=None, log_binning=False)
 has_log_binnnig (self)
 name (self)
 TH1 (self)
 fill (self, value, weight=1.)
 write (self)
 max (self)
 min (self)
 setMinimum (self, minimum)
 setMaximum (self, maximum)
 fixHisto (self)

Private Member Functions

 __getInterval (self, value)

Private Attributes

 __name = name
 __xTitle = axis_title
 __min = bmin
tuple __width = bin_width
int __entries = 0
 Pull back the overflow.
dict __content = {}
dict __error = {}
self.__TH1.Fill(value, weight) __TH1 = None
 __TDir = bdir
 __log_binning = log_binning
 __max = maximum

Detailed Description

Definition at line 18 of file PlotUtils.py.

Member Typedef Documentation

◆ result

Definition at line 90 of file EDM_MasterSearch.h.

Constructor & Destructor Documentation

◆ __init__()

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.

26 log_binning = False):
27 self.__name = name
28 self.__xTitle = axis_title
29 self.__min = bmin
30 self.__width = bin_width
31 self.__entries = 0
32 self.__content = {}
33 self.__error = {}
34 self.__TH1 = None
35 self.__TDir = bdir
36
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)
41 self.__TH1.SetDirectory(bdir)
42 elif bins > 0:
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)
48 self.__TH1.SetDirectory(bdir)
49
STL class.

Member Function Documentation

◆ __getInterval()

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()

PlotUtils.DiagnosticHisto.fill ( self,
value,
weight = 1. )

Definition at line 53 of file PlotUtils.py.

53 def fill(self, value, weight=1.):
54 self.__entries +=1
55 if self.__TH1: self.__TH1.Fill(value, weight)
56 else:
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
void fill(H5::Group &out_file, size_t iterations)

◆ fixHisto()

PlotUtils.DiagnosticHisto.fixHisto ( self)

Definition at line 86 of file PlotUtils.py.

86 def fixHisto(self):
87 if self.__TH1: return
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)
90 self.__TH1.SetDirectory(self.__TDir)
91
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]))
96

◆ has_log_binnnig()

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()

PlotUtils.DiagnosticHisto.max ( self)

Definition at line 78 of file PlotUtils.py.

78 def max(self):
79 try: return sorted(self.__content.iterkeys(), key=lambda Rng: Rng[1])[-1][1]
80 except: return float('nan')
#define max(a, b)
Definition cfImp.cxx:41

◆ min()

PlotUtils.DiagnosticHisto.min ( self)

Definition at line 81 of file PlotUtils.py.

81 def min(self):
82 try: return sorted(self.__content.iterkeys(), key=lambda Rng: Rng[0])[0][1]
83 except: return float('nan')
#define min(a, b)
Definition cfImp.cxx:40

◆ name()

PlotUtils.DiagnosticHisto.name ( self)

Definition at line 51 of file PlotUtils.py.

51 def name(self): return self.__name

◆ setMaximum()

PlotUtils.DiagnosticHisto.setMaximum ( self,
maximum )

Definition at line 85 of file PlotUtils.py.

85 def setMaximum(self, maximum): self.__max = maximum

◆ setMinimum()

PlotUtils.DiagnosticHisto.setMinimum ( self,
minimum )

Definition at line 84 of file PlotUtils.py.

84 def setMinimum(self, minimum): self.__min = minimum

◆ TH1()

PlotUtils.DiagnosticHisto.TH1 ( self)

Definition at line 52 of file PlotUtils.py.

52 def TH1(self): return self.__TH1

◆ write()

PlotUtils.DiagnosticHisto.write ( self)

Definition at line 65 of file PlotUtils.py.

65 def write(self):
66 self.fixHisto()
67 if not self.__TH1: return
68 self.__TH1.GetXaxis().SetTitle(self.__xTitle)
69
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))
72
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))
75
76 self.__TH1.SetEntries(self.__entries)
77 if self.__TDir: self.__TDir.WriteObject(self.__TH1, self.__name)

Member Data Documentation

◆ __content

dict PlotUtils.DiagnosticHisto.__content = {}
private

Definition at line 32 of file PlotUtils.py.

◆ __entries

PlotUtils.DiagnosticHisto.__entries = 0
private

Pull back the overflow.

Pull back the underflow

Definition at line 31 of file PlotUtils.py.

◆ __error

dict PlotUtils.DiagnosticHisto.__error = {}
private

Definition at line 33 of file PlotUtils.py.

◆ __log_binning

PlotUtils.DiagnosticHisto.__log_binning = log_binning
private

Definition at line 37 of file PlotUtils.py.

◆ __max

PlotUtils.DiagnosticHisto.__max = maximum
private

Definition at line 85 of file PlotUtils.py.

◆ __min

PlotUtils.DiagnosticHisto.__min = bmin
private

Definition at line 29 of file PlotUtils.py.

◆ __name

PlotUtils.DiagnosticHisto.__name = name
private

Definition at line 27 of file PlotUtils.py.

◆ __TDir

PlotUtils.DiagnosticHisto.__TDir = bdir
private

Definition at line 35 of file PlotUtils.py.

◆ __TH1

self.__TH1.Fill(value, weight) PlotUtils.DiagnosticHisto.__TH1 = None
private

Definition at line 34 of file PlotUtils.py.

◆ __width

tuple PlotUtils.DiagnosticHisto.__width = bin_width
private

Definition at line 30 of file PlotUtils.py.

◆ __xTitle

PlotUtils.DiagnosticHisto.__xTitle = axis_title
private

Definition at line 28 of file PlotUtils.py.


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