Belle II Software  release-08-01-10
runUVTimeDifference.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
19 
20 import glob
21 import sys
22 
23 import basf2 as b2
24 from basf2 import conditions as b2conditions
25 from rawdata import add_unpackers
26 from simulation import add_simulation
27 from svd import add_svd_reconstruction
28 
29 MCrun = int(sys.argv[1])
30 data = False # True
31 unpack = True
32 if not data:
33  unpack = False
34 
35 # only relevant for data:
36 run = 5900 # 3239 #5751
37 fileout = 'hitTimeSelection_exp10run'+str(run)+'.root'
38 
39 # RAW
40 files = ['/group/belle2/dataprod/Data/Raw/e0010/r0'+str(run)+'/sub00/physics.0010.0'+str(run)+'.HLT*.root']
41 # 5751
42 # 5900
43 # RAW CT skims
44 # files = ['/gpfs/fs02/belle2/group/detector/SVD/']
45 # run = 3239
46 
47 # old-format cDST
48 # 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"]
49 
50 bkg = glob.glob('/group/belle2/BGFile/OfficialBKG/early_phase3/prerelease-04-00-00a/overlay/phase31/BGx1/set0/*.root')
51 
52 # needed for some temporary issues with BKLMDisplacement payload
53 if data:
54  b2conditions.override_globaltags()
55  b2conditions.globaltags = ['svd_svdHitTimeSelection_test', 'klm_alignment_testing', 'online']
56 else:
57  b2conditions.globaltags = ['svd_svdHitTimeSelection_test']
58 
59 # svd_svd_svdHitTimeSelection_test CONTENT:
60 # exp 0, run 0 maxTimeDiff = 100
61 # exp 0, run 1 maxTimeDiff = 10
62 # exp 0, run 2 maxTimeDiff = 15
63 # exp 0, run 3 maxTimeDiff = 20
64 # exp 0, run 4 maxTimeDiff = 25
65 # exp 0, run 5 maxTimeDiff = 30
66 # exp 0, run 6 maxTimeDiff = 35
67 # exp 0, run 7 maxTimeDiff = 40
68 # exp 0, run 8 maxTimeDiff = 45
69 # exp 0, run 9 maxTimeDiff = 50
70 
71 eventinfosetter = b2.register_module('EventInfoSetter')
72 eventinfosetter.param('expList', [0])
73 eventinfosetter.param('runList', [MCrun])
74 
75 evtgeninput = b2.register_module('EvtGenInput')
76 evtgeninput.logging.log_level = b2.LogLevel.INFO
77 
78 # main main
79 main = b2.create_path()
80 
81 # read input rootfile
82 # -> can be overwritten with the -i option
83 if data:
84  main.add_module("RootInput", inputFileNames=files)
85 else:
86  main.add_module(eventinfosetter)
87  main.add_module(evtgeninput)
88 
89 # nee to know SVD geometry to create histograms
90 main.add_module('Gearbox')
91 main.add_module('Geometry')
92 
93 # if using RAW data you need to unpack them
94 if data and unpack:
95  add_unpackers(main, components=['SVD'])
96 
97 if not data:
98  main.add_module('FullSim')
99  add_simulation(main, bkgfiles=None, usePXDDataReduction=False, forceSetPXDDataReduction=True)
100 # add_simulation(main, bkgfiles=bkg, usePXDDataReduction=False, forceSetPXDDataReduction=True)
101 
102 if not data:
103  fileout = 'SVDHitTimeSelection_MCnoBKG_run'+str(MCrun)+'.root'
104 
105 add_svd_reconstruction(main)
106 
107 main.add_module('RootOutput', outputFileName=fileout, branchNames=['SVDSpacePoints'])
108 # Show progress
109 main.add_module('Progress')
110 
111 b2.print_path(main)
112 
113 # Process events
114 b2.process(main)
115 
116 print(b2.statistics)