2 set_log_level(LogLevel.INFO)
8 from ROOT
import Belle2
9 from ROOT.Belle2
import MillepedeAlgorithm
11 from caf.framework
import CAF, Calibration, CentralDatabase
12 from caf
import backends
13 from caf
import strategies
15 import reconstruction
as reco
17 from generators
import add_kkmc_generator
18 from simulation
import add_simulation
19 from L1trigger
import add_tsim
22 runList = [4, 5, 6, 7]
24 expList = [0, 0, 0, 0]
26 evtNumList = [20, 60, 20, 40]
34 params = [1, 2, 3, 4, 5, 6]
39 for shell
in [ying, yang]:
42 pxd_labels.append(label.label())
45 timedep = [(pxd_labels, [(0, run, 0)
for run
in runList] + [(20, 5, 0), (40, 5, 0)] + [(20, 7, 0)])]
47 db_components = [
'VXDAlignment']
48 components = [
'PXD',
'SVD',
'CDC']
51 def PXDHalfShellsAlignment(files, tags):
56 path.add_module(
'Progress')
59 path.add_module(
'Gearbox')
60 path.add_module(
'Geometry')
64 reco.add_mc_reconstruction(path, pruneTracks=
False, components=components)
65 path.add_module(
'DAFRecoFitter')
67 collector = register_module(
'MillepedeCollector',
68 tracks=[
'RecoTracks'],
70 calibrateVertex=
True, components=db_components,
77 algorithm = MillepedeAlgorithm()
78 algorithm.invertSign(
True)
79 algorithm.ignoreUndeterminedParams(
False)
81 std_components = ROOT.vector(
'string')()
82 for component
in db_components:
83 std_components.push_back(component)
84 algorithm.setComponents(std_components)
86 algorithm.steering().command(
'method diagonalization 3 0.1')
87 algorithm.steering().command(
'skipemptycons')
88 algorithm.steering().command(
'threads 4 4')
89 algorithm.steering().command(
'matiter 1')
90 algorithm.steering().command(
'scaleerrors 1. 1.')
92 algorithm.steering().command(
'printcounts 1')
94 algorithm.steering().command(
'monitorresiduals')
95 algorithm.steering().command(
'closeandreopen')
96 algorithm.steering().command(
'hugecut 50.')
102 algorithm.steering().command(
'Parameters')
104 def fix_vxd_id(vxd_id, params=None):
106 params = [1, 2, 3, 4, 5, 6]
110 algorithm.steering().command(
'{} 0.0 -1. ! {}'.format(str(label.label()), str(vxd_id)))
118 ladders = [8, 12, 7, 10, 12, 16]
119 sensors = [2, 2, 2, 3, 4, 5]
121 for layer
in range(1, 7):
122 for ladder
in range(1, ladders[layer - 1] + 1):
123 fix_vxd_id(
Belle2.VxdID(layer, ladder, 0), params=[1, 2, 3, 4, 5, 6])
124 for sensor
in range(1, sensors[layer - 1] + 1):
152 algorithm.setTimedepConfig(timedep)
154 calibration =
Calibration(
'PXDHalfShellsAlignment',
156 algorithms=algorithm,
158 pre_collector_path=path,
159 database_chain=[CentralDatabase(tag)
for tag
in tags],
160 output_patterns=
None,
161 max_files_per_collector_job=1,
173 main.add_module(
"EventInfoSetter", evtNumList=evtNumList, runList=runList, expList=expList)
175 main.add_module(
'Gearbox')
176 main.add_module(
'Geometry')
178 add_kkmc_generator(main,
'mu-mu+')
183 main.add_module(
"RootOutput", outputFileName=filename)
184 main.add_module(
"Progress")
188 return os.path.abspath(filename)
190 if __name__ ==
"__main__":
193 if not len(input_files):
196 outfile =
'TimeDepCalibration_TestData.root'
197 print(
"No input file provided. This will now generate test data into {} and run over it.".format(outfile))
198 print(
"It will take couple of minutes.")
199 print(
"You can set this file as input next time using -i option of basf2")
203 tags = conditions.default_globaltags
204 mp2_beamspot = PXDHalfShellsAlignment(input_files, tags)
205 mp2_beamspot.max_iterations = 1
208 cal_fw.add_calibration(mp2_beamspot)
212 if multiprocessing.cpu_count() < 10: