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