Belle II Software  release-06-02-00
svdPerformanceTree.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
18 
19 import basf2 as b2
20 from basf2 import conditions as b2conditions
21 import rawdata as raw
22 import tracking as trk
23 import simulation as sim
24 import glob
25 
26 useSimulation = True
27 
28 # set this string to identify the output rootfiles
29 tag = "_test"
30 
31 main = b2.create_path()
32 
33 b2.set_random_seed(1)
34 
35 if useSimulation:
36  # options for simulation:
37  expList = [1003]
38  numEvents = 2000
39  bkgFiles = glob.glob('/sw/belle2/bkg/*.root') # Phase3 background
40  bkgFiles = None # uncomment to remove background
41  simulateJitter = False
42  ROIfinding = False
43  MCTracking = False
44  eventinfosetter = b2.register_module('EventInfoSetter')
45  eventinfosetter.param('expList', expList)
46  eventinfosetter.param('runList', [0])
47  eventinfosetter.param('evtNumList', [numEvents])
48  main.add_module(eventinfosetter)
49  # main.add_module('EventInfoPrinter')
50  main.add_module('EvtGenInput')
51 
52  sim.add_simulation(
53  main,
54  bkgfiles=bkgFiles,
55  forceSetPXDDataReduction=True,
56  usePXDDataReduction=ROIfinding,
57  simulateT0jitter=simulateJitter)
58 else:
59  # setup database
60  b2conditions.reset()
61  b2conditions.override_globaltags()
62  b2conditions.globaltags = ["online"]
63 
64  # input root files
65  main.add_module('RootInput', branchNames=['RawPXDs', 'RawSVDs', 'RawCDCs'])
66  raw.add_unpackers(main, components=['PXD', 'SVD', 'CDC'])
67 
68  # change ZS to 5
69  # for moda in main.modules():
70  # if moda.name() == 'SVDUnpacker':
71  # moda.param("svdShaperDigitListName", "SVDShaperDigitsZS3")
72  # main.add_module("SVDZeroSuppressionEmulator",SNthreshold=5,ShaperDigits="SVDShaperDigitsZS3",ShaperDigitsIN="SVDShaperDigits")
73 
74 # now do reconstruction:
75 trk.add_tracking_reconstruction(
76  main,
77  mcTrackFinding=MCTracking,
78  trackFitHypotheses=[211]) # ,
79 # skipHitPreparerAdding=True)
80 
81 '''
82 # skim mu+mu- events:
83 ma.applyEventCuts("nTracks ==2", path=main)
84 
85 mySelection = 'pt>1.0 and abs(dz)<0.5 and dr<0.4'
86 ma.fillParticleList('mu+:DQM', mySelection, path=main)
87 ma.reconstructDecay('Upsilon(4S):IPDQM -> mu+:DQM mu-:DQM', '10<M<11', path=main)
88 
89 skimfilter = b2.register_module('SkimFilter')
90 skimfilter.set_name('SkimFilter_MUMU')
91 skimfilter.param('particleLists', ['Upsilon(4S):IPDQM'])
92 main.add_module(skimfilter)
93 filter_path = b2.create_path()
94 skimfilter.if_value('=1', filter_path, b2.AfterConditionPath.CONTINUE)
95 '''
96 
97 # fill TTrees
98 main.add_module('SVDPerformanceTTree', outputFileName="SVDPerformanceTree"+str(tag)+".root")
99 
100 # write everything
101 main.add_module('OverlapResiduals', ExpertLevel=True)
102 
103 # main.add_module('RootOutput')
104 main.add_module('Progress')
105 
106 b2.print_path(main)
107 
108 b2.process(main)
109 
110 print(b2.statistics)