Belle II Software  release-08-01-10
runOccupancy.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
19 
20 import glob
21 
22 import basf2 as b2
23 from basf2 import conditions as b2conditions
24 from rawdata import add_unpackers
25 from simulation import add_simulation
26 
27 data = True
28 run = 5751
29 
30 # RAW
31 files = ['/group/belle2/dataprod/Data/Raw/e0010/r0'+str(run)+'/sub00/physics.0010.0'+str(run)+'.HLT*.root']
32 # 5751 (1% media)
33 # 5900
34 
35 # old-format cDST
36 # files=["/group/belle2/dataprod/Data/release-04-00-02/DB00000523/Unofficial/e0010/4S/r04295/skim/hlt_hadron/cdst/sub00/cdst.physics.0010.04295.HLT1*.root","/group/belle2/dataprod/Data/release-04-00-02/DB00000523/Unofficial/e0010/4S/r04295/skim/hlt_bhabha/cdst/sub00/cdst.physics.0010.04295.HLT1.*.root","/group/belle2/dataprod/Data/release-04-00-02/DB00000523/Unofficial/e0010/4S/r04295/skim/hlt_mumu_2trk/cdst/sub00/cdst.physics.0010.04295.HLT1.*.root"]
37 
38 bkg = glob.glob('/group/belle2/BGFile/OfficialBKG/early_phase3/prerelease-04-00-00a/overlay/phase31/BGx1/set0/*.root')
39 # needed for some temporary issues with BKLMDisplacement payload
40 if data:
41  b2conditions.override_globaltags()
42  b2conditions.globaltags = ['klm_alignment_testing', 'online']
43 
44 eventinfosetter = b2.register_module('EventInfoSetter')
45 eventinfosetter.param('expList', [1003])
46 eventinfosetter.param('runList', [1])
47 
48 evtgeninput = b2.register_module('EvtGenInput')
49 evtgeninput.logging.log_level = b2.LogLevel.INFO
50 
51 
52 # main main
53 main = b2.create_path()
54 
55 
56 # read input rootfile
57 # -> can be overwritten with the -i option
58 if data:
59  main.add_module("RootInput", inputFileNames=files)
60 else:
61  main.add_module(eventinfosetter)
62  main.add_module(evtgeninput)
63 
64 # nee to know SVD geometry to create histograms
65 main.add_module('Gearbox')
66 main.add_module('Geometry')
67 
68 # if using RAW data you need to unpack them
69 if data:
70  add_unpackers(main, components=['SVD'])
71 
72 if not data:
73  main.add_module('FullSim')
74  add_simulation(main, bkgfiles=bkg)
75 
76 # add offline ZS
77 main.add_module(
78  'SVDZeroSuppressionEmulator',
79  SNthreshold=5,
80  ShaperDigits='SVDShaperDigits',
81  ShaperDigitsIN='SVDShaperDigitsZS5',
82  FADCmode=True)
83 
84 main.add_module(
85  'SVDOccupancyAnalysis',
86  outputFileName='SVDOccupancyAnalysis_exp10run'+str(run)+'.root',
87  ShaperDigitsName='SVDShaperDigitsZS5',
88  skipHLTRejectedEvents=True)
89 
90 # == Show progress
91 main.add_module('Progress')
92 
93 b2.print_path(main)
94 
95 # Process events
96 b2.process(main)
97 
98 print(b2.statistics)