Belle II Software  release-05-01-25
make_fine_bins.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import basf2
5 
6 import ROOT
7 from ROOT import Belle2 # make Belle2 namespace available
8 from ROOT import std
9 from ROOT.Belle2 import TrackFindingCDC as TFCDC
10 
11 import os
12 import sys
13 import math
14 import random
15 import numpy as np
16 
17 
18 def is_power_of_two(x):
19  while x % 2 == 0:
20  print(x)
21  x = x / 2
22  if x == 1:
23  return True
24  else:
25  return False
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 if __name__ == '__main__':
72  main()
main
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:77