Belle II Software development
SVDOccupancyCalibrationCAF.py
1
8
9
13
14import basf2 as b2
15
16import os
17import sys
18import multiprocessing
19
20from caf.framework import CAF, Calibration, CentralDatabase
21from caf import backends
22from caf import strategies
23
24import rawdata as raw
25# import vertex as vx
26
27b2.set_log_level(b2.LogLevel.INFO)
28
29input_branches = [
30 'RawSVDs'
31]
32
33b2.set_log_level(b2.LogLevel.INFO)
34
35
36def SVDOccupancyCalibrations(files, tags):
37 # avoid top level ROOT imports
38 from ROOT import Belle2 # noqa: make Belle2 namespace available
39 from ROOT.Belle2 import SVDOccupancyCalibrationsAlgorithm
40
41 # Set-up re-processing path
42 path = b2.create_path()
43
44 # logging.log_level = LogLevel.WARNING
45
46 path.add_module('Progress')
47 # Remove all non-raw data to run the full reco again
48 path.add_module('RootInput', branchNames=input_branches)
49
50 path.add_module("Gearbox")
51 path.add_module("Geometry", useDB=True)
52
53 # fil = register_module('SVDShaperDigitsFromTracks')
54 # fil.param('outputINArrayName', 'SVDShaperDigitsFromTracks')
55 # main.add_module(fil)
56
57 # Not needed for di-muon skim cdst or mdst, but needed to re-run reconstruction
58 # with possibly changed global tags
59 raw.add_unpackers(path, components=['SVD'])
60 path.add_module(
61 'SVDZeroSuppressionEmulator',
62 SNthreshold=5,
63 ShaperDigits='SVDShaperDigits',
64 ShaperDigitsIN='SVDShaperDigitsZS5',
65 FADCmode=True)
66
67 collector = b2.register_module('SVDOccupancyCalibrationsCollector')
68# collector.param("SVDShaperDigitsName", "SVDShaperDigits")
69 collector.param("SVDShaperDigitsName", "SVDShaperDigitsZS5")
70 algorithm = SVDOccupancyCalibrationsAlgorithm("SVDOccupancyCAF")
71
72 calibration = Calibration('SVDOccupancy',
73 collector=collector,
74 algorithms=algorithm,
75 input_files=files,
76 pre_collector_path=path,
77 database_chain=[CentralDatabase(tag) for tag in tags],
78 output_patterns=None,
79 max_files_per_collector_job=1,
80 backend_args=None
81 )
82
83 calibration.strategies = strategies.SequentialRunByRun
84
85 return calibration
86
87
88if __name__ == "__main__":
89 # use by default raw data from cdst of exp8, run1309 (shaperDigits need to be unpacked, not available in cdst format)
90 input_files = [os.path.abspath(file) for file in [
91 "/group/belle2/dataprod/Data/Raw/e0008/r01309/sub00/physics.0008.01309.HLT5.f00098.root"]]
92 # "/group/belle2/dataprod/Data/Raw/e0008/r01309/sub00/physics.0008.01309.HLT5*"]]
93 # "/group/belle2/dataprod/Data/release-03-02-02/DB00000635/proc00000009/\
94 # e0008/4S/r01309/skim/hlt_bhabha/cdst/sub00/cdst.physics.0008.01309.HLT*"]]
95
96 if not len(input_files):
97 print("You have to specify some input file(s)\n"
98 "using the standard basf2 command line option - i")
99 print("See: basf2 -h")
100 sys.exit(1)
101
102 svdOccupCAF = SVDOccupancyCalibrations(input_files,
103 ['giulia_CDCEDepToADCConversions_rel4_patch',
104 'data_reprocessing_prompt_rel4_patch'])
105# beamspot.max_iterations = 0
106
107 cal_fw = CAF()
108 cal_fw.add_calibration(svdOccupCAF)
109
110 cal_fw.backend = backends.LSF()
111
112# Try to guess if we are at KEKCC and change the backend to Local if not
113 if multiprocessing.cpu_count() < 10:
114 cal_fw.backend = backends.Local(8)
115
116 cal_fw.run()