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