Belle II Software development
SVDHotStripsCalibrationsCAF.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
33# set_log_level(LogLevel.WARNING)
34
35
36def SVDHotStripsCalibrations(files, tags):
37 # avoid top level ROOT imports
38 from ROOT import Belle2 # noqa: make Belle2 namespace available
39 from ROOT.Belle2 import SVDHotStripsCalibrationsAlgorithm
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
61 collector = b2.register_module('SVDOccupancyCalibrationsCollector')
62 collector.param("SVDShaperDigitsName", "SVDShaperDigits")
63 algorithm = SVDHotStripsCalibrationsAlgorithm("SVDHotStripsCAF")
64
65 calibration = Calibration('SVDHotStrips',
66 collector=collector,
67 algorithms=algorithm,
68 input_files=files,
69 pre_collector_path=path,
70 database_chain=[CentralDatabase(tag) for tag in tags],
71 output_patterns=None,
72 max_files_per_collector_job=1,
73 backend_args=None
74 )
75
76 calibration.strategies = strategies.SequentialRunByRun
77
78 return calibration
79
80
81if __name__ == "__main__":
82 # use by default raw data from cdst of exp8, run1309 (shaperDigits need to be unpacked, not available in cdst format)
83 input_files = [os.path.abspath(file) for file in [
84 "/group/belle2/dataprod/Data/Raw/e0008/r01309/sub00/physics.0008.01309.HLT5.f00098.root"]]
85 # "/group/belle2/dataprod/Data/Raw/e0008/r01309/sub00/physics.0008.01309.HLT5*"]]
86# "/group/belle2/dataprod/Data/release-03-02-02/DB00000635/proc00000009/\
87# e0008/4S/r01309/skim/hlt_bhabha/cdst/sub00/cdst.physics.0008.01309.HLT*"]]
88
89 if not len(input_files):
90 print("You have to specify some input file(s)\n"
91 "using the standard basf2 command line option - i")
92 print("See: basf2 -h")
93 sys.exit(1)
94
95 svdOccupCAF = SVDHotStripsCalibrations(input_files,
96 ['giulia_CDCEDepToADCConversions_rel4_patch',
97 'data_reprocessing_prompt_rel4_patch'])
98 # beamspot.max_iterations = 0
99
100 cal_fw = CAF()
101 cal_fw.add_calibration(svdOccupCAF)
102 cal_fw.backend = backends.LSF()
103
104 # Try to guess if we are at KEKCC and change the backend to Local if not
105 if multiprocessing.cpu_count() < 10:
106 cal_fw.backend = backends.Local(8)
107
108 cal_fw.run()