Belle II Software development
SVDCoGTimeCalibrationImporter.py
1# !/usr/bin/env python
2
3
10
11
25
26
27import basf2 as b2
28import svd
29import os
30import sys
31from svd.CoGCalibration_utils import SVDCoGTimeCalibrationImporterModule
32from basf2 import conditions as b2conditions
33
34localdb = sys.argv[1]
35filename = sys.argv[2]
36branches = ['SVDShaperDigits', 'SVDRecoDigits', 'SVDClusters', 'EventT0', 'Tracks', 'RecoTracks']
37
38trk_outputFile = "TrackFilterControlNtuples_" + localdb + ".root"
39nSVD = 6
40nCDC = 1
41pVal = 0.0 # 0001
42
43inputFileList = []
44if filename.rfind(".root") != -1:
45 inputFileList.append(filename)
46else:
47 with open(filename) as f:
48 inputFileList = [line.strip() for line in f]
49
50b2conditions.prepend_globaltag("online")
51b2conditions.prepend_globaltag("data_reprocessing_prompt")
52if '_CHECK' not in localdb:
53 b2conditions.prepend_globaltag('svd_NOCoGCorrections')
54 if os.path.isdir(localdb):
55 print('WARNING, you are using CoG corrections in ' + localdb + ' exiting')
56 sys.exit(1)
57 else:
58 b2conditions.testing_payloads = [str(localdb)]
59else:
60 localdb = localdb.split('_')
61 if not os.path.isdir(localdb[0]):
62 print('WARNING, the localDB ' + localdb[0] + ' containing the corrections is missing, exiting.')
63 sys.exit(1)
64 else:
65 b2conditions.testing_payloads = [str(localdb)]
66 localdb = sys.argv[1]
67 if os.path.isdir(localdb):
68 print('WARNING, you are using CoG corrections in ' + localdb + ' exiting')
69 sys.exit(1)
70 else:
71 b2conditions.testing_payloads = [str(localdb)]
72
73main = b2.create_path()
74
75rootinput = b2.register_module('RootInput')
76rootinput.param('inputFileNames', inputFileList)
77rootinput.param('branchNames', branches)
78main.add_module(rootinput)
79
80main.add_module("Gearbox")
81main.add_module("Geometry", useDB=True)
82
83# Track selection - NOT YET
84trkFlt = b2.register_module('TrackFilter')
85trkFlt.param('outputFileName', trk_outputFile)
86trkFlt.param('outputINArrayName', 'SelectedTracks')
87trkFlt.param('outputOUTArrayName', 'ExcludedTracks')
88trkFlt.param('min_NumHitSVD', nSVD)
89trkFlt.param('min_NumHitCDC', nCDC)
90trkFlt.param('min_Pvalue', pVal)
91# trkFlt.logging.log_level = LogLevel.DEBUG
92# main.add_module(trkFlt)
93
94fil = b2.register_module('SVDShaperDigitsFromTracks')
95fil.param('outputINArrayName', 'SVDShaperDigitsFromTracks')
96main.add_module(fil)
97
99
100for moda in main.modules():
101 if moda.name() == 'SVDCoGTimeEstimator':
102 moda.param("ShaperDigits", 'SVDShaperDigitsFromTracks')
103 moda.param("RecoDigits", 'SVDRecoDigitsFromTracks')
104 if moda.name() == 'SVDSimpleClusterizer':
105 moda.param("Clusters", 'SVDClustersFromTracks')
106 moda.param("RecoDigits", 'SVDRecoDigitsFromTracks')
107 if moda.name() == 'SVDSpacePointCreator':
108 moda.param("SVDClusters", 'SVDClustersFromTracks')
109
110calib = SVDCoGTimeCalibrationImporterModule()
111calib.set_localdb(localdb)
112calib.notApplyCorrectForCDCLatency(False) # False = apply correction, True = not apply correction
113main.add_module(calib)
114
115# Show progress of processing
116progress = b2.register_module('ProgressBar')
117main.add_module(progress)
118
119b2.print_path(main)
120
121# Process events
122b2.process(main)
123
124print(b2.statistics)
def add_svd_reconstruction(path, isROIsimulation=False, createRecoDigits=False, applyMasking=False)
Definition: __init__.py:14