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