diff --git a/raremodel.py b/raremodel.py index e895d14..bcd1842 100644 --- a/raremodel.py +++ b/raremodel.py @@ -273,40 +273,24 @@ verbose_calls.append(int(set_size*j/100)) start = time.time() - end = 0 counter = 0 counter_x = 0 - while int(counter_x) < set_size: - Hit = False + while len(x_part) < set_size: counter += 1 x = ROOT.TRandom1().Uniform(x_min, x_max) - - if xx2: - Hit = True - y = ROOT.TRandom1().Uniform(0, y2) - else: - Hit = True - y = ROOT.TRandom1().Uniform(0, _max) + y = ROOT.TRandom1().Uniform(0, _max) if y < self.total_pdf(x**2): x_part.append(x) y_part.append(y) - if xx2: - counter_x += A23_x2/(_max*x2) - else: counter_x += 1 #progress calls if verbose != 0: end = time.time() - if o*verbose+verbose < 100 and counter%200 == 0: + if o*verbose+verbose < 100 and counter%300 == 0: print(" {0}{1} completed".format(o*verbose+verbose, "%")) - print(" Projected time left: {0}".format(display_time(int((end-start)*set_size/(counter_x+1)-(end-start))))) + print(" Projected time left: {0}".format(display_time(int((end-start)*set_size/(len(x_part)+1)-(end-start))))) sys.stdout.write("\033[F") sys.stdout.write("\x1b[2K") sys.stdout.write("\033[F") @@ -316,11 +300,17 @@ sys.stdout.write("\x1b[2K") print(" Time to generate set: {0}".format(display_time(int(end-start)))) - if counter_x >= verbose_calls[o]: + if len(x_part) == verbose_calls[o]: o += 1 + print(" {0} out of {1} particles chosen!".format(len(x_part), counter)) + + print(" Set generated!") + + + print(" {0} out of {1} particles chosen!".format(int(counter_x), counter)) print(" Set generated!") @@ -380,13 +370,13 @@ #progress calls if verbose != 0: end = time.time() - if o*verbose+verbose < 100 and counter%30000 == 0: + if o*verbose+verbose < 100 and counter%300 == 0: print(" {0}{1} completed".format(o*verbose+verbose, "%")) print(" Projected time left: {0}".format(display_time(int((end-start)*set_size/(len(x_part)+1)-(end-start))))) - #sys.stdout.write("\033[F") - #sys.stdout.write("\x1b[2K") - #sys.stdout.write("\033[F") - #sys.stdout.write("\x1b[2K") + sys.stdout.write("\033[F") + sys.stdout.write("\x1b[2K") + sys.stdout.write("\033[F") + sys.stdout.write("\x1b[2K") if o*verbose + verbose >=100: sys.stdout.write("\033[F") sys.stdout.write("\x1b[2K") diff --git a/test.py b/test.py index e91eb09..a3204ae 100644 --- a/test.py +++ b/test.py @@ -23,7 +23,7 @@ min_bin_scaling = 100 -set_size = 4e5 +set_size = 1e3 jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale = pdg["jpsi"] modl.add_resonance(jpsi_mass, jpsi_width, jpsi_phase, jpsi_scale) @@ -34,14 +34,14 @@ if load_set: - with open(r"set.pkl", "rb") as input_file: + with open(r"set_400000.pkl", "rb") as input_file: set_dic = pkl.load(input_file) part_set = (set_dic["x_part"], set_dic["y_part"]) counter = set_dic["counter"] else: - x_part, y_part, counter = modl.generate_points(set_size, mode = mode, min_bin_scaling = min_bin_scaling) + x_part, y_part, counter = modl.generate_points(set_size, x_min = 3100, x_max = 3600, mode = mode, min_bin_scaling = min_bin_scaling) part_set = (x_part, y_part) if draw: