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