13 <input>EvtGenSimRec.root, EvtGenSimRec_B2Kpi.root</input>
14 <output>bunchFinder.root</output>
15 <contact>marko.staric@ijs.si</contact>
16 <description>makes validation plots
for TOPBunchFinder</description>
20from basf2 import create_path, process, statistics, Module
21from ROOT import Belle2
22from ROOT import TH1F, TFile, TNamed
26class MakePlots(Module):
28 Makes validation histograms for bunch finder
33 Sets description, check and contact to validation histogram.
34 :param h validation histogram
35 :param D description text
37 descr = TNamed('Description', D)
38 h.GetListOfFunctions().Add(descr)
39 check = TNamed(
'Check',
'Must agree with reference')
40 h.GetListOfFunctions().Add(check)
41 contact = TNamed(
'Contact',
'marko.staric@ijs.si')
42 h.GetListOfFunctions().Add(contact)
45 ''' Initializes the Module: book histograms and set descriptions and checks'''
48 self.
tfile = TFile.Open(
"bunchFinder.root",
"recreate")
52 "Reconstructed relative bunch number; relative bunch number; events per bunch",
53 100, -50.0 - 0.5, 50.0 - 0.5)
58 "Offset to reconstructed bunch; offset [ns]; events per bin",
64 "Number of tracks in TOP acceptance; number of tracks; entries per bin",
70 "Number of tracks used for bunch finding; number of used track; entries per bins",
72 self.
set_descr(self.
usedTracks,
'Number of tracks in the event actually used for finding the bunch crossing.')
76 "Efficiency vs. number of tracks; number of tracks; efficiency",
79 'the number of tracks per event in the acceptance of TOP.')
83 "Efficiency vs. number of used tracks; number of used tracks; efficiency",
86 'the number of tracks per event actually used.')
89 self.
effi = TH1F(
"effi",
"Acceptance and efficiency", 2, 0.5, 2.5)
90 self.
effi.GetXaxis().SetBinLabel(1,
"acceptance")
91 self.
effi.GetXaxis().SetBinLabel(2,
"efficiency")
92 self.
effi.GetXaxis().SetLabelSize(0.08)
93 self.
effi.GetXaxis().SetAlphanumeric()
94 self.
set_descr(self.
effi,
'Acceptance is defined as fraction of events with at least one track crossing TOP. '
95 'Efficiency is defined as fraction of correctly reconstructed bunch crossings in accepted events.')
102 ''' Event processor: fill histograms '''
105 if not recBunch.isValid():
108 if recBunch.isReconstructed():
110 self.
offset.Fill(recBunch.getCurrentOffset())
111 self.
numTracks.Fill(recBunch.getNumTracks())
112 self.
usedTracks.Fill(recBunch.getUsedTracks())
113 if recBunch.getBunchNo() == recBunch.getMCBunchNo():
118 ''' Processes and writes histograms to file'''
121 err = math.sqrt(eff * (1 - eff) / self.
nev)
122 self.
effi.SetBinContent(1, eff)
123 self.
effi.SetBinError(1, err)
126 err = math.sqrt(eff * (1 - eff) / self.
numTracks.GetEntries())
127 self.
effi.SetBinContent(2, eff)
128 self.
effi.SetBinError(2, err)
146main.add_module(
'RootInput', inputFileNames=[
'../EvtGenSimRec_B2Kpi.root',
'../EvtGenSimRec.root'])
151main.add_module(
'Progress')
effi_usedTracks
validation histogram
offset
validation histogram
recBunchNo
validation histogram
numTracks
validation histogram
usedTracks
validation histogram
def set_descr(self, h, D)
nev
number of events with valid TOPRecBunch object pointer
effi_numTracks
validation histogram
a (simplified) python wrapper for StoreObjPtr.