Belle II Software  release-08-01-10
SVDCoGTimeCalibrationCheck.py
1 # !/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
22 
23 
24 import basf2 as b2
25 import sys
26 from svd import add_svd_reconstruction
27 from svd.CoGCalibration_utils_checkCalibration import SVDCoGTimeCalibrationCheckModule
28 import rawdata as raw
29 
30 
31 localdb = sys.argv[1]
32 filename = sys.argv[2]
33 run = sys.argv[3]
34 exp = sys.argv[4]
35 branches = ['RawSVDs', 'SVDShaperDigitsFromTracks', 'EventT0']
36 
37 trk_outputFile = "TrackFilterControlNtuples_" + localdb + ".root"
38 nSVD = 6
39 nCDC = 1
40 pVal = 0.0 # 0001
41 
42 inputFileList = []
43 
44 if filename.rfind(".root") != -1:
45  inputFileList.append(filename)
46 else:
47  with open(filename, 'r') as f:
48  inputFileList = [line.strip() for line in f]
49 
50 b2.conditions.override_globaltags()
51 b2.conditions.globaltags = [
52  "svd_NOCoGCorrections",
53  "staging_data_reprocessing_proc11",
54  "data_reprocessing_proc11_baseline",
55  "online_proc11"]
56 
57 b2.conditions.testing_payloads = [
58  str(localdb) + "/database.txt",
59 ]
60 
61 main = b2.create_path()
62 
63 rootinput = b2.register_module('RootInput')
64 rootinput.param('inputFileNames', inputFileList)
65 rootinput.param('branchNames', branches)
66 main.add_module(rootinput)
67 
68 main.add_module("Gearbox")
69 main.add_module("Geometry", useDB=True)
70 
71 # unpack raw data to get SVDEventInfo
72 raw.add_unpackers(main, components=['SVD'])
73 
74 # re-reconstruct SVDShaperDigitsFromTracks using the localDB
75 add_svd_reconstruction(main)
76 
77 for moda in main.modules():
78  if moda.name() == 'SVDCoGTimeEstimator':
79  moda.param("ShaperDigits", 'SVDShaperDigitsFromTracks')
80  moda.param("RecoDigits", 'SVDRecoDigitsFromTracks')
81  if moda.name() == 'SVDSimpleClusterizer':
82  moda.param("Clusters", 'SVDClustersFromTracks')
83  moda.param("RecoDigits", 'SVDRecoDigitsFromTracks')
84  moda.param("timeAlgorithm", 0)
85  if moda.name() == 'SVDSpacePointCreator':
86  moda.param("SVDClusters", 'SVDClustersFromTracks')
87 
88 main = b2.remove_module(main, 'SVDMissingAPVsClusterCreator')
89 
90 check = SVDCoGTimeCalibrationCheckModule()
91 check.set_localdb(localdb)
92 check.set_run_number(run)
93 check.set_exp_number(exp)
94 main.add_module(check)
95 
96 # Show progress of processing
97 progress = b2.register_module('ProgressBar')
98 main.add_module(progress)
99 
100 b2.print_path(main)
101 
102 # Process events
103 b2.process(main)
104 
105 print(b2.statistics)