Belle II Software  release-08-01-10
topVariables.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # -------------------------------------------------------------------------
13 # Example of using top variables on MC
14 # See cdstAnalysis.py on how to use top variables on real data
15 #
16 # To print available top variables: basf2 top/examples/printTOPVariables.py
17 # -------------------------------------------------------------------------
18 
19 from basf2 import create_path, process
20 from simulation import add_simulation
21 from reconstruction import add_reconstruction
22 from background import get_background_files
23 import modularAnalysis as ma
24 from variables import variables
25 
26 # create path
27 main = create_path()
28 
29 # generate and reconstruct 100 generic BBbar events w/ the beam background overlayed
30 main.add_module('EventInfoSetter', evtNumList=[100])
31 main.add_module('EvtGenInput')
32 add_simulation(main, bkgfiles=get_background_files())
33 add_reconstruction(main)
34 
35 # make a particle list of MC true pions
36 ma.fillParticleList(decayString='pi+', cut='', path=main)
37 ma.matchMCTruth(list_name='pi+', path=main)
38 ma.applyCuts(list_name='pi+', cut='isSignal==1', path=main)
39 
40 # make aliases of some expert variables
41 variables.addAlias('topTOF_kaon', 'topTOFExpert(321)')
42 variables.addAlias('topLogLPhotonCountMCMatch', 'topDigitCountIntervalMCMatch(-20, 74.327756)')
43 
44 # define a list of variables to be written to ntuple
45 var_list = ['p',
46  'theta',
47  'phi',
48  'charge',
49  'PDG',
50  'isSignal',
51  'topSlotID',
52  'topSlotIDMCMatch',
53  'topLocalX',
54  'topLocalY',
55  'topLocalZ',
56  'topLocalXMCMatch',
57  'topLocalYMCMatch',
58  'topLocalZMCMatch',
59  'topLocalPhi',
60  'topLocalTheta',
61  'topLocalPhiMCMatch',
62  'topLocalThetaMCMatch',
63  'topTOF',
64  'topTOFMCMatch',
65  'topTOF_kaon',
66  'extrapTrackToTOPimpactZ',
67  'extrapTrackToTOPimpactTheta',
68  'extrapTrackToTOPimpactPhi',
69  'topDigitCount',
70  'topDigitCountMCMatch',
71  'topDigitCountSignal',
72  'topDigitCountBkg',
73  'topDigitCountRaw',
74  'topLogLFlag',
75  'topLogLPhotonCount',
76  'topLogLPhotonCountMCMatch',
77  'topLogLExpectedPhotonCount',
78  'topLogLEstimatedBkgCount',
79  'topLogLElectron',
80  'topLogLMuon',
81  'topLogLPion',
82  'topLogLKaon',
83  'topLogLProton',
84  'topLogLDeuteron',
85  'topBunchIsReconstructed',
86  'topBunchNumber',
87  'topBunchMCMatch',
88  'topBunchOffset',
89  'topBunchTrackCount',
90  'topBunchUsedTrackCount',
91  'topTracksInSlot']
92 
93 # write variables to ntuple
94 ma.variablesToNtuple(decayString='pi+', variables=var_list, treename='tree', filename='topVars_mc.root', path=main)
95 
96 # print progress
97 main.add_module('Progress')
98 
99 # process events
100 process(main)