Belle II Software  release-06-02-00
cdstAnalysis.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # Example of writing TOP cdst variable information using analysis package tools
13 
14 from basf2 import create_path, use_central_database, process, statistics
15 from modularAnalysis import variablesToNtuple
16 from ROOT import gSystem
17 
18 # you need to choose a consistent global tag that corresponds to the data
19 # you are analysing this will change from production to production
20 inputdata = "/hsm/belle2/bdata/Data/release-02-00-01/DB00000425/prod00000005/e0003/4S/r00784/all/cdst/sub00/*.root"
21 datadbtag = "data_reprocessing_prod5"
22 
23 # Load the top libraries -- needed until the "top/variables" directory
24 # gets upgraded and variables linked automatically
25 gSystem.Load('libtop.so')
26 
27 # setup and input
28 path = create_path()
29 use_central_database(datadbtag)
30 path.add_module('RootInput', inputFileName=inputdata)
31 goodtracks = 'abs(dz) < 2.0 and abs(dr) < 0.5 and pt > 0.15 and nCDCHits > 0'
32 # units: cm cm GeV/c
33 # note that this selection is more-or-less sensible on phase2 data
34 path.add_module('ParticleLoader',
35  decayStringsWithCuts=[('K+:goodtracks', goodtracks)])
36 
37 # variables one might care about
38 variables_of_interest = [
39  "topModuleDigitCount",
40  "topModuleReflectedDigitCount",
41  "topModuleDigitGapSize",
42  "px", "py", "pz", "E", "pt", "p", "theta", "phi"
43 ]
44 variablesToNtuple("K+:goodtracks", variables=variables_of_interest, path=path)
45 
46 # process path
47 process(path, 10) # process 10 events, override with basf2 -n option
48 print(statistics)