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