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