Belle II Software development
BGHistogrammer Class Reference
Inheritance diagram for BGHistogrammer:

Public Member Functions

def initialize (self)
 
def event (self)
 
def setErrors (self, hist)
 
def terminate (self)
 

Public Attributes

 hist
 list of histograms
 

Static Public Attributes

list simHits
 list of SimHits to be histogramed
 
len n = len(simHits)
 length of simHits list
 

Detailed Description

Make validation histograms for BG mixer.

Definition at line 29 of file validate.py.

Member Function Documentation

◆ event()

def event (   self)
 Event processor: fill histograms 

Definition at line 68 of file validate.py.

68 def event(self):
69 ''' Event processor: fill histograms '''
70
71 for i in range(self.n):
72 hits = Belle2.PyStoreArray(self.simHits[i])
73 for hit in hits:
74 time = hit.getGlobalTime() / 1000
75 self.hist[i].Fill(time)
76
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72

◆ initialize()

def initialize (   self)
 Initialize the Module: set histogram axis titles, description and check

Definition at line 48 of file validate.py.

48 def initialize(self):
49 ''' Initialize the Module: set histogram axis titles, description and check'''
50
51
52 self.hist = [TH1F('h' + str(i), self.simHits[i], 400, -20, 20) for i in range(self.n)]
53
54 for i in range(self.n):
55 self.hist[i].GetXaxis().SetTitle('time [#mus]')
56 self.hist[i].GetYaxis().SetTitle('entries/bin')
57 descr = TNamed('Description', 'Time distribution of ' + self.simHits[i] +
58 ' for mixed background')
59 self.hist[i].GetListOfFunctions().Add(descr)
60 check = TNamed('Check', 'Distribution must be flat in the time window. ' +
61 'Bin statistics is not Poissonian.')
62 self.hist[i].GetListOfFunctions().Add(check)
63 contact = TNamed('Contact', 'marko.staric@ijs.si')
64 self.hist[i].GetListOfFunctions().Add(contact)
65 options = TNamed('MetaOptions', 'shifter')
66 self.hist[i].GetListOfFunctions().Add(options)
67

◆ setErrors()

def setErrors (   self,
  hist 
)
 Set bin errors - they are not Poissonian

Definition at line 77 of file validate.py.

77 def setErrors(self, hist):
78 ''' Set bin errors - they are not Poissonian'''
79 hmax = hist.GetMaximum()
80 temp = TH1F('temp', 'temporary', 100, 0, hmax * 1.1)
81 for i in range(hist.GetNbinsX()):
82 h = hist.GetBinContent(i + 1)
83 if h > hmax * 0.2:
84 temp.Fill(h)
85 mean = temp.GetMean()
86 rms = temp.GetStdDev()
87 if mean > 0:
88 for i in range(hist.GetNbinsX()):
89 h = hist.GetBinContent(i + 1)
90 e = 0
91 if h > 0:
92 e = rms * math.sqrt(h / mean)
93 hist.SetBinError(i + 1, e)
94

◆ terminate()

def terminate (   self)
 Write histograms to the file.

Definition at line 95 of file validate.py.

95 def terminate(self):
96 """ Write histograms to the file."""
97
98 tfile = TFile('timeDistributions.root', 'recreate')
99 for i in range(self.n):
100 self.setErrors(self.hist[i])
101 self.hist[i].Write()
102 tfile.Close()
103
104
105# Create path

Member Data Documentation

◆ hist

hist

list of histograms

Definition at line 52 of file validate.py.

◆ n

len n = len(simHits)
static

length of simHits list

Definition at line 46 of file validate.py.

◆ simHits

list simHits
static
Initial value:
= [
'PXDSimHits',
'SVDSimHits',
'CDCSimHits',
'TOPSimHits',
'ARICHSimHits',
'ECLHits',
'KLMSimHits',
]

list of SimHits to be histogramed

Definition at line 36 of file validate.py.


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