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