14 <input>EvtGenSimRec.root, EvtGenSimRec_B2Kpi.root</input>
15 <output>bunchFinder.root</output>
16 <contact>marko.staric@ijs.si</contact>
17 <description>makes validation plots for TOPBunchFinder</description>
21 from basf2
import create_path, process, statistics, Module
22 from ROOT
import Belle2
23 from ROOT
import TH1F, TFile, TNamed
29 Makes validation histograms for bunch finder
34 Sets description, check and contact to validation histogram.
35 :param h validation histogram
36 :param D description text
38 descr = TNamed(
'Description', D)
39 h.GetListOfFunctions().Add(descr)
40 check = TNamed(
'Check',
'Must agree with reference')
41 h.GetListOfFunctions().Add(check)
42 contact = TNamed(
'Contact',
'marko.staric@ijs.si')
43 h.GetListOfFunctions().Add(contact)
46 ''' Initializes the Module: book histograms and set descriptions and checks'''
49 self.
tfiletfile = TFile.Open(
"bunchFinder.root",
"recreate")
53 "Reconstructed relative bunch number; relative bunch number; events per bunch",
54 100, -50.0 - 0.5, 50.0 - 0.5)
55 self.
set_descrset_descr(self.
recBunchNorecBunchNo,
'Reconstructed bunch number relative to L1 trigger.')
59 "Offset to reconstructed bunch; offset [ns]; events per bin",
61 self.
set_descrset_descr(self.
offsetoffset,
'Offset to reconstructed bunch.')
65 "Number of tracks in TOP acceptance; number of tracks; entries per bin",
67 self.
set_descrset_descr(self.
numTracksnumTracks,
'Number of tracks per event in the acceptance of TOP.')
71 "Number of tracks used for bunch finding; number of used track; entries per bins",
73 self.
set_descrset_descr(self.
usedTracksusedTracks,
'Number of tracks in the event actually used for finding the bunch crossing.')
77 "Efficiency vs. number of tracks; number of tracks; efficiency",
79 self.
set_descrset_descr(self.
effi_numTrackseffi_numTracks,
'Efficieny of finding the correct bunch crossing versus '
80 'the number of tracks per event in the acceptance of TOP.')
84 "Efficiency vs. number of used tracks; number of used tracks; efficiency",
86 self.
set_descrset_descr(self.
effi_usedTrackseffi_usedTracks,
'Efficieny of finding the correct bunch crossing versus '
87 'the number of tracks per event actually used.')
90 self.
effieffi = TH1F(
"effi",
"Acceptance and efficiency", 2, 0.5, 2.5)
91 self.
effieffi.GetXaxis().SetBinLabel(1,
"acceptance")
92 self.
effieffi.GetXaxis().SetBinLabel(2,
"efficiency")
93 self.
effieffi.GetXaxis().SetLabelSize(0.08)
94 self.
effieffi.GetXaxis().SetAlphanumeric()
95 self.
set_descrset_descr(self.
effieffi,
'Acceptance is defined as fraction of events with at least one track crossing TOP. '
96 'Efficiency is defined as fraction of correctly reconstructed bunch crossings in accepted events.')
103 ''' Event processor: fill histograms '''
106 if not recBunch.isValid():
109 if recBunch.isReconstructed():
110 self.
recBunchNorecBunchNo.Fill(recBunch.getBunchNo())
111 self.
offsetoffset.Fill(recBunch.getCurrentOffset())
112 self.
numTracksnumTracks.Fill(recBunch.getNumTracks())
113 self.
usedTracksusedTracks.Fill(recBunch.getUsedTracks())
114 if recBunch.getBunchNo() == recBunch.getMCBunchNo():
119 ''' Processes and writes histograms to file'''
121 eff = self.
numTracksnumTracks.GetEntries() / self.
nevnev
122 err = math.sqrt(eff * (1 - eff) / self.
nevnev)
123 self.
effieffi.SetBinContent(1, eff)
124 self.
effieffi.SetBinError(1, err)
127 err = math.sqrt(eff * (1 - eff) / self.
numTracksnumTracks.GetEntries())
128 self.
effieffi.SetBinContent(2, eff)
129 self.
effieffi.SetBinError(2, err)
139 self.
tfiletfile.Write()
140 self.
tfiletfile.Close()
147 main.add_module(
'RootInput', inputFileNames=[
'../EvtGenSimRec_B2Kpi.root',
'../EvtGenSimRec.root'])
152 main.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.