6 <output>timeDistributions.root</output>
7 <contact>marko.staric@ijs.si</contact>
8 <description>Runs BG mixer and makes validation histograms</description>
16 from ROOT
import Belle2
17 from ROOT
import TH1F, TFile, TNamed
19 set_random_seed(123452)
25 Make validation histograms for BG mixer.
43 ''' Initialize the Module: set histogram axis titles, description and check'''
46 self.
hist = [TH1F(
'h' + str(i), self.
simHits[i], 400, -20, 20)
for i
in range(self.
n)]
48 for i
in range(self.
n):
49 self.
hist[i].GetXaxis().SetTitle(
'time [#mus]')
50 self.
hist[i].GetYaxis().SetTitle(
'entries/bin')
51 descr = TNamed(
'Description',
'Time distribution of ' + self.
simHits[i] +
52 ' for mixed background')
53 self.
hist[i].GetListOfFunctions().Add(descr)
54 check = TNamed(
'Check',
'Distribution must be flat in the time window. ' +
55 'Bin statistics is not Poissonian.')
56 self.
hist[i].GetListOfFunctions().Add(check)
57 contact = TNamed(
'Contact',
'marko.staric@ijs.si')
58 self.
hist[i].GetListOfFunctions().Add(contact)
59 options = TNamed(
'MetaOptions',
'shifter')
60 self.
hist[i].GetListOfFunctions().Add(options)
63 ''' Event processor: fill histograms '''
65 for i
in range(self.
n):
68 time = hit.getGlobalTime() / 1000
69 self.
hist[i].Fill(time)
72 ''' Set bin errors - they are not Poissonian'''
73 hmax = hist.GetMaximum()
74 temp = TH1F(
'temp',
'temporary', 100, 0, hmax * 1.1)
75 for i
in range(hist.GetNbinsX()):
76 h = hist.GetBinContent(i + 1)
80 rms = temp.GetStdDev()
82 for i
in range(hist.GetNbinsX()):
83 h = hist.GetBinContent(i + 1)
86 e = rms * math.sqrt(h / mean)
87 hist.SetBinError(i + 1, e)
90 """ Write histograms to the file."""
92 tfile = TFile(
'timeDistributions.root',
'recreate')
93 for i
in range(self.
n):
103 eventinfosetter = register_module(
'EventInfoSetter')
104 eventinfosetter.param({
'evtNumList': [100],
'runList': [1]})
105 main.add_module(eventinfosetter)
108 gearbox = register_module(
'Gearbox')
109 main.add_module(gearbox)
112 geometry = register_module(
'Geometry')
113 main.add_module(geometry)
117 if 'BELLE2_BACKGROUND_MIXING_DIR' in os.environ:
118 bg = glob.glob(os.environ[
'BELLE2_BACKGROUND_MIXING_DIR'] +
'/*.root')
120 B2FATAL(
'No beam background samples found in folder ' +
121 os.environ[
'BELLE2_BACKGROUND_MIXING_DIR'])
122 B2INFO(
'Using background samples from ' + os.environ[
'BELLE2_BACKGROUND_MIXING_DIR'])
123 bkgmixer = register_module(
'BeamBkgMixer')
124 bkgmixer.param(
'backgroundFiles', bg)
125 main.add_module(bkgmixer)
127 B2FATAL(
'variable BELLE2_BACKGROUND_MIXING_DIR is not set')
133 progress = register_module(
'Progress')
134 main.add_module(progress)