Belle II Software development
make_fine_bins.py
1#!/usr/bin/env python3
2
3
10
11
12from ROOT import Belle2 # make Belle2 namespace available # noqa
13from ROOT.Belle2 import TrackFindingCDC as TFCDC
14
15
16def is_power_of_two(x):
17 while x % 2 == 0:
18 print(x)
19 x = x / 2
20 if x == 1:
21 return True
22 else:
23 return False
24
25
26assert(is_power_of_two(2048))
27
28
29def main():
30 new_bin_bounds = []
31
32 lowest_curv_bound = -0.02
33 uppest_curv_bound = 0.14
34 width = 0.00007
35
36 lower_bound = -width / 2
37 upper_bound = width / 2
38
39 new_bin_bounds = [(lower_bound, upper_bound)]
40
41 while upper_bound < uppest_curv_bound or not is_power_of_two(len(new_bin_bounds)):
42 if width == 0.00007:
43 overlap = 0
44 else:
45 # IMPR Adjustment to the actually density in the curvature would be great
46 overlap = 3. / 5.
47
48 lower_bound = lower_bound + (1.0 - overlap) * width
49
50 lower_width = TFCDC.PrecisionUtil.getOriginCurvPrecision(lower_bound)
51 upper_width = TFCDC.PrecisionUtil.getOriginCurvPrecision(lower_bound + lower_width)
52 width = (lower_width + upper_width) / 2
53 width = width if width > 0.00007 else 0.00007
54 upper_bound = lower_bound + width
55 new_bin_bounds.append((lower_bound, upper_bound))
56
57 # Symmetric up to the curling curvature
58 if not -lower_bound < lowest_curv_bound:
59 new_bin_bounds.append((-upper_bound, -lower_bound))
60
61 new_bin_bounds = sorted(new_bin_bounds)
62
63 with open('new_fine_curv_bounds.txt', 'w') as curv_bounds_file:
64 for bin_bound in new_bin_bounds:
65 curv_bounds_file.write(str(bin_bound[0]))
66 curv_bounds_file.write('\n')
67 curv_bounds_file.write(str(bin_bound[1]))
68 curv_bounds_file.write('\n')
69
70
71if __name__ == '__main__':
72 main()
Definition: main.py:1