Belle II Software  release-08-01-10
runClusterizer.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 alg = 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 = '3sampleClusterizer_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_timeCalibration_test', 'klm_alignment_testing', 'online']
56 else:
57  b2conditions.globaltags = ['svd_timeCalibration_test']
58 
59 # svd_timeCalibration_test CONTENT:
60 # exp 0, run 0: no calibration applied: returned time from the database = raw time
61 
62 eventinfosetter = b2.register_module('EventInfoSetter')
63 eventinfosetter.param('expList', [0])
64 eventinfosetter.param('runList', [0])
65 
66 evtgeninput = b2.register_module('EvtGenInput')
67 evtgeninput.logging.log_level = b2.LogLevel.INFO
68 
69 # main main
70 main = b2.create_path()
71 
72 # read input rootfile
73 # -> can be overwritten with the -i option
74 if data:
75  main.add_module("RootInput", inputFileNames=files)
76 else:
77  main.add_module(eventinfosetter)
78  main.add_module(evtgeninput)
79 
80 # nee to know SVD geometry to create histograms
81 main.add_module('Gearbox')
82 main.add_module('Geometry')
83 
84 # if using RAW data you need to unpack them
85 if data and unpack:
86  add_unpackers(main, components=['SVD'])
87 
88 if not data:
89  main.add_module('FullSim')
90  add_simulation(main, bkgfiles=None, usePXDDataReduction=False, forceSetPXDDataReduction=True)
91 # add_simulation(main, bkgfiles=bkg, usePXDDataReduction=False, forceSetPXDDataReduction=True)
92 
93 if not data:
94  fileout = 'SVD3SampleClusterizer_MCnoBKG_timeAlg'+str(alg)+'.root'
95 
96 add_svd_reconstruction(main)
97 
98 for m in main.modules():
99  if "SVDSimpleClusterizer" == m.name():
100  m.param("timeAlgorithm", alg)
101 
102 main.add_module('RootOutput', outputFileName=fileout, branchNames=['SVDClusters'])
103 # Show progress
104 main.add_module('Progress')
105 
106 b2.print_path(main)
107 
108 # Process events
109 b2.process(main)
110 
111 print(b2.statistics)