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