14 <output>timeDistributions.root</output>
15 <contact>marko.staric@ijs.si</contact>
16 <description>Runs BG mixer and makes validation histograms</description>
24 from ROOT
import Belle2
25 from ROOT
import TH1F, TFile, TNamed
27 b2.set_random_seed(123452)
33 Make validation histograms for BG mixer.
51 ''' Initialize the Module: set histogram axis titles, description and check'''
54 self.
histhist = [TH1F(
'h' + str(i), self.
simHitssimHits[i], 400, -20, 20)
for i
in range(self.
nn)]
56 for i
in range(self.
nn):
57 self.
histhist[i].GetXaxis().SetTitle(
'time [#mus]')
58 self.
histhist[i].GetYaxis().SetTitle(
'entries/bin')
59 descr = TNamed(
'Description',
'Time distribution of ' + self.
simHitssimHits[i] +
60 ' for mixed background')
61 self.
histhist[i].GetListOfFunctions().Add(descr)
62 check = TNamed(
'Check',
'Distribution must be flat in the time window. ' +
63 'Bin statistics is not Poissonian.')
64 self.
histhist[i].GetListOfFunctions().Add(check)
65 contact = TNamed(
'Contact',
'marko.staric@ijs.si')
66 self.
histhist[i].GetListOfFunctions().Add(contact)
67 options = TNamed(
'MetaOptions',
'shifter')
68 self.
histhist[i].GetListOfFunctions().Add(options)
71 ''' Event processor: fill histograms '''
73 for i
in range(self.
nn):
76 time = hit.getGlobalTime() / 1000
77 self.
histhist[i].Fill(time)
80 ''' Set bin errors - they are not Poissonian'''
81 hmax = hist.GetMaximum()
82 temp = TH1F(
'temp',
'temporary', 100, 0, hmax * 1.1)
83 for i
in range(hist.GetNbinsX()):
84 h = hist.GetBinContent(i + 1)
88 rms = temp.GetStdDev()
90 for i
in range(hist.GetNbinsX()):
91 h = hist.GetBinContent(i + 1)
94 e = rms * math.sqrt(h / mean)
95 hist.SetBinError(i + 1, e)
98 """ Write histograms to the file."""
100 tfile = TFile(
'timeDistributions.root',
'recreate')
101 for i
in range(self.
nn):
103 self.
histhist[i].Write()
108 main = b2.create_path()
111 eventinfosetter = b2.register_module(
'EventInfoSetter')
112 eventinfosetter.param({
'evtNumList': [100],
'runList': [1]})
113 main.add_module(eventinfosetter)
116 gearbox = b2.register_module(
'Gearbox')
117 main.add_module(gearbox)
120 geometry = b2.register_module(
'Geometry')
121 main.add_module(geometry)
125 if 'BELLE2_BACKGROUND_MIXING_DIR' in os.environ:
126 bg = glob.glob(os.environ[
'BELLE2_BACKGROUND_MIXING_DIR'] +
'/*.root')
128 b2.B2FATAL(
'No beam background samples found in folder ' +
129 os.environ[
'BELLE2_BACKGROUND_MIXING_DIR'])
130 b2.B2INFO(
'Using background samples from ' + os.environ[
'BELLE2_BACKGROUND_MIXING_DIR'])
131 bkgmixer = b2.register_module(
'BeamBkgMixer')
132 bkgmixer.param(
'backgroundFiles', bg)
133 main.add_module(bkgmixer)
135 b2.B2FATAL(
'variable BELLE2_BACKGROUND_MIXING_DIR is not set')
141 progress = b2.register_module(
'Progress')
142 main.add_module(progress)
a (simplified) python wrapper for StoreArray.
def setErrors(self, hist)
list simHits
list of SimHits to be histogramed