Belle II Software development
cdstAnalysis.py
1#!/usr/bin/env python3
2
3
10
11# -------------------------------------------------------------------------
12# Example of using top variables on real data (cdst files required)
13# See topVariables.py on how to use top variables on MC
14#
15# To print available top variables: basf2 top/examples/printTOPVariables.py
16# -------------------------------------------------------------------------
17
18from basf2 import conditions, create_path, process, statistics
19from reconstruction import prepare_user_cdst_analysis
20import modularAnalysis as ma
21from variables import variables
22
23# global tags
24# ******************************************************************************************************************
25# note: The patching global tags and their order are bucket number and basf2 version dependent.
26# Given below is what is needed for cdst files of bucket 16 calibration and January-2023 development version.
27# ******************************************************************************************************************
28conditions.override_globaltags()
29conditions.append_globaltag('patch_main_release-07_noTOP')
30conditions.append_globaltag('data_reprocessing_proc13') # experiments 7 - 18
31# conditions.append_globaltag('data_reprocessing_prompt') # experiments 20 - 26
32conditions.append_globaltag('online')
33
34# create path
35main = create_path()
36
37# read events from a cdst file: use -i option to pass the name of the file
38# files of bucket 16 can be found on KEKCC in /gpfs/group/belle2/dataprod/Data/PromptReco/bucket16_calib/
39main.add_module('RootInput')
40
41# run unpackers and post-tracking reconstruction
42prepare_user_cdst_analysis(main)
43
44# make a particle list of pions from all charged tracks
45ma.fillParticleList(decayString='pi+:all', cut='', path=main)
46
47# make aliases of some expert variables
48variables.addAlias('topTOF_kaon', 'topTOFExpert(321)')
49
50# define a list of variables to be written to ntuple
51var_list = ['p',
52 'theta',
53 'phi',
54 'charge',
55 'PDG',
56 'topSlotID',
57 'topLocalX',
58 'topLocalY',
59 'topLocalZ',
60 'topLocalPhi',
61 'topLocalTheta',
62 'topTOF',
63 'topTOF_kaon',
64 'extrapTrackToTOPimpactZ',
65 'extrapTrackToTOPimpactTheta',
66 'extrapTrackToTOPimpactPhi',
67 'topDigitCount',
68 'topDigitCountSignal',
69 'topDigitCountBkg',
70 'topDigitCountRaw',
71 'topLogLFlag',
72 'topLogLPhotonCount',
73 'topLogLExpectedPhotonCount',
74 'topLogLEstimatedBkgCount',
75 'topLogLElectron',
76 'topLogLMuon',
77 'topLogLPion',
78 'topLogLKaon',
79 'topLogLProton',
80 'topLogLDeuteron',
81 'topBunchIsReconstructed',
82 'topBunchNumber',
83 'topBunchOffset',
84 'topBunchTrackCount',
85 'topBunchUsedTrackCount',
86 'topTracksInSlot']
87
88# write variables to ntuple
89ma.variablesToNtuple(decayString='pi+:all', variables=var_list, treename='tree', filename='topVars_data.root', path=main)
90
91# print progress
92main.add_module('Progress')
93
94# process events
95process(main)
96
97# Print statistics
98print(statistics)