Projections.py
Go to the documentation of this file.
1 ###########################
2 # Build a projection of the time it will take to build a dataset
3 def projectionTimes(chain, per_input_event=False, verbose=False):
4  if verbose: print "proj : --- Projection times"
5  tiers = chain.tiers
6  times = []
7  for tier in tiers:
8  if not tier.metric.run or (tier.metric.return_code != 0) or (tier.metric.input_events == 0):
9  times.append(0)
10  continue
11  m = tier.metric
12  time = m.user_cpu + m.system_cpu
13  if per_input_event:
14  n = 0
15  if (m.used_events == None) and (m.input_events == None):
16  if m.output_events != None:
17  n = m.output_events
18  else:
19  assert False, "Per event time requested but number of input events isn't know in tier: %s"%tier.short_name
20  elif m.used_events and m.input_events:
21  n = min(m.used_events,m.input_events)
22  elif m.used_events:
23  n = m.used_events
24  elif m.input_events:
25  n = m.input_events
26  assert n, "No input events for tier %s"%tier.short_name
27  time = float(time) / float(n)
28  times.append(time)
29  return times
30 ###########################
31 # Build a projection of the size of each tier
32 def projectionSizes(chain, per_output_event=False, verbose=False):
33  if verbose: print "proj : --- Projection sizes"
34  tiers = chain.tiers
35  sizes = []
36  for tier in tiers:
37  if (not tier.metric.run) or (tier.metric.return_code != 0) or (tier.metric.input_events == 0):
38  sizes.append(0)
39  continue
40  m = tier.metric
41  size = 0.
42  for o in m.output_size: size +=o
43  if per_output_event:
44  n = 0.
45  for o in m.output_events:
46  if o > n: n =o
47  if tier.short_name == "caf":
48  n = m.input_events
49  if n != 0:
50  size = float(size) / float(n)
51  sizes.append(size)
52  return sizes
53 ###########################
54 # Map out the dependency path of this chain
55 def buildPaths(chain, final_tier):
56  tier = chain.GetTier(final_tier)
57 
58  paths = [final_tier]
59  while(True):
60  no_dependencies = True
61  for path in paths:
62  if chain.GetTier(path).dependencies:
63  for d in chain.GetTier(path).dependencies:
64  paths.append(d)
65  no_depenencies = False
66  if no_dependencies: break
67  return paths
68 ###########################
69 # The overall efficiency of this chain
70 def overallEfficiency(chain,verbose=False):
71  efficiency = 1.
72  for tier in chain.tiers:
73  if tier.short_name in overlay_tiers.keys():
74  if verbose: print "proj : tier %s is an overlay tier"%tier.short_name
75  continue
76  efficiency = efficiency*tierEfficiency(tier)
77  return efficiency
78 ###########################
79 # The efficiency of this tier
80 def tierEfficiency(tier):
81 
82  if (tier.metric.used_events == None) and (tier.metric.input_events == None):
83  print "proj : Tier %s has no measure of the number of input events"%tier.short_name
84  exit(1)
85  elif tier.metric.used_events and tier.metric.input_events:
86  in_events = min(tier.metric.used_events,tier.metric.input_events)
87  elif tier.metric.used_events:
88  in_events = tier.metric.used_events
89  else:
90  in_events = tier.metric.input_events
91 
92  assert(in_events>0)
93 
94  if len(tier.metric.output_events) > 1:
95  print "proj : Tier %s has multiple output streams, we must pick one: %s, using the max for now"%\
96  (tier.short_name, repr(tier.output_name))
97  out_events = max(tier.metric.output_events)
98 
99  if out_events == 0: return 0.
100  else: return float(out_events) / float(in_events)
def buildPaths(chain, final_tier)
Map out the dependency path of this chain.
Definition: Projections.py:55
def tierEfficiency(tier)
The efficiency of this tier.
Definition: Projections.py:80
def overallEfficiency(chain, verbose=False)
The overall efficiency of this chain.
Definition: Projections.py:70
def projectionTimes(chain, per_input_event=False, verbose=False)
Build a projection of the time it will take to build a dataset.
Definition: Projections.py:3
def projectionSizes(chain, per_output_event=False, verbose=False)
Build a projection of the size of each tier.
Definition: Projections.py:32
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
exit(0)
while(!feof(fp))
assert(nhit_max >=nhit_nbins)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68