Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sigmaEff.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file sigmaEff.py
1 import numpy as np
2 import math
3 
4 def sigmaEff(v, threshold, xmin, xmax):
5  v = np.sort(v)
6 
7  total = np.size(v)
8  max = threshold * total
9 
10  start = []
11  stop = []
12  width = []
13 
14  i = 0
15  while i != np.size(v)-1:
16  count = 0
17  j = i
18  while j != np.size(v)-1 and count < max:
19  count +=1
20  j += 1
21 
22  if j != np.size(v)-1:
23  start.append(v[i])
24  stop.append(v[j])
25  width.append(v[j] - v[i])
26 
27  i += 1
28 
29  npminwidth = np.array(width)
30 
31  minwidth = np.amin(npminwidth)
32  pos = np.argmin(npminwidth)
33 
34  xmin += [start[pos]]
35  xmax += [stop[pos]]
36 
37  return minwidth
38 
39 
40 def minimum_size_range(file_sizes, percentage):
41  # calculate how many files need to be in the range
42  window_size = math.ceil(len(file_sizes) * percentage / 100)
43 
44  sorted_sizes = sorted(file_sizes)
45 
46  # initialize variables with worst-case values
47  min_size, max_size = sorted_sizes[0], sorted_sizes[-1]
48  min_interval = max_size - min_size
49 
50  # calculate interval for every window
51  for i in range(len(sorted_sizes) - (window_size - 1)):
52  lower, upper = sorted_sizes[i], sorted_sizes[i + (window_size - 1)]
53  interval = upper - lower
54 
55  # if we found a new minimum interval, replace values
56  if interval < min_interval:
57  min_interval = interval
58  min_size, max_size = lower, upper
59 
60  return min_size, max_size