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