Functions | Variables
overlay_prestage_def Namespace Reference

Functions

def Subdivide (input)
 
def RecurseOverDefinitions (input, tier_num, n_tiers, overlay_def, output_def_name_base, overwrite_defns=False)
 

Variables

 GROUP_SIZE
 
 FILE_PATTERN
 
 SAM
 
 experiment
 
 parser
 
 description
 
 metavar
 
 help
 
 nargs
 
 action
 
 default
 
 args
 
 output_def_name
 
 fhicl_runs
 
 fhicl_files
 
 file_list
 
 dimensions
 
 defname
 
 n_files
 
 n_files_div10
 
 end
 
 curr_perc
 
 matches
 
 md
 
 num_tiers
 
 check_output
 
 files
 
 snapid
 
 n_runs
 
 files_unmatched
 
 overlay_runs
 

Detailed Description

  overlay_prestage_def.py:
  
  Create (and snapshot) a SAM definition that contains only those files
  from an overlay definition corresponding to the files actually used
  by the overlay FCLs in the FCL definition. 

Function Documentation

def overlay_prestage_def.RecurseOverDefinitions (   input,
  tier_num,
  n_tiers,
  overlay_def,
  output_def_name_base,
  overwrite_defns = False 
)

Definition at line 28 of file overlay_prestage_def.py.

References ana.assert(), print, and Subdivide().

28 def RecurseOverDefinitions(input, tier_num, n_tiers, overlay_def, output_def_name_base, overwrite_defns=False):
29  if len(input) == 0:
30  return None
31 
32  group_defns = []
33  for group_idx, grouping in enumerate(input):
34 
35  # fhicl_runs (they're tuples of two values)
36  if all(len(g) == 2 and all(isinstance(i, int) for i in g) for g in grouping):
37  subset_defn_dims = "defname: %s and (%s)" % (overlay_def, " or ".join(("run_number %d.%d" % (run,sub) for run,sub in grouping)))
38  else:
39  subset_defn_dims = " or ".join("dataset_def_name_newest_snapshot %s" % g for g in grouping)
40 
41  print(subset_defn_dims)
42 
43  if tier_num < n_tiers:
44  suffix = "_" + ("Sub" * (n_tiers - tier_num)) + ("set%d" % group_idx)
45  else:
46  suffix = ""
47 
48  output_def_name = output_def_name_base + suffix
49 
50  if overwrite_defns:
51  try:
52  SAM.deleteDefinition(defname=output_def_name)
54  pass
55 
56  SAM.createDefinition(defname=output_def_name, dims=subset_defn_dims)
57 
58 # print " " * (n_tiers - tier_num), "new defn:", output_def_name
59 # with open(output_def_name, "w") as outf:
60 # outf.write(subset_defn_dims)
61 
62  # MUST snapshot if we're recursing further
63  if tier_num < n_tiers:
64  SAM.takeSnapshot(defname=output_def_name)
65 # print " " * (n_tiers - tier_num), "snapshot:", output_def_name
66 
67  group_defns.append(output_def_name)
68 
69  # if it's still too big, go around again...
70  if len(group_defns) > 1:
71  recurse_defns = Subdivide(group_defns)
72  return RecurseOverDefinitions(recurse_defns, tier_num+1, n_tiers, overlay_def, output_def_name_base)
73  else:
74  assert(tier_num == n_tiers), "Down to 1 group before all tiers completed?!"
75  return group_defns[0]
76 
77 
def RecurseOverDefinitions(input, tier_num, n_tiers, overlay_def, output_def_name_base, overwrite_defns=False)
bool print
assert(nhit_max >=nhit_nbins)
def overlay_prestage_def.Subdivide (   input)

Definition at line 25 of file overlay_prestage_def.py.

References PandAna.Demos.demo1.range.

Referenced by RecurseOverDefinitions().

25 def Subdivide(input):
26  return [ input[n*GROUP_SIZE:(n+1)*GROUP_SIZE] for n in range(old_div(len(input), GROUP_SIZE) + 1) ]
27 

Variable Documentation

overlay_prestage_def.action

Definition at line 96 of file overlay_prestage_def.py.

overlay_prestage_def.args

Definition at line 116 of file overlay_prestage_def.py.

overlay_prestage_def.check_output

Definition at line 165 of file overlay_prestage_def.py.

overlay_prestage_def.curr_perc

Definition at line 134 of file overlay_prestage_def.py.

overlay_prestage_def.default

Definition at line 97 of file overlay_prestage_def.py.

overlay_prestage_def.defname

Definition at line 127 of file overlay_prestage_def.py.

overlay_prestage_def.description

Definition at line 81 of file overlay_prestage_def.py.

overlay_prestage_def.dimensions

Definition at line 125 of file overlay_prestage_def.py.

overlay_prestage_def.end

Definition at line 131 of file overlay_prestage_def.py.

overlay_prestage_def.experiment

Definition at line 78 of file overlay_prestage_def.py.

overlay_prestage_def.fhicl_files

Definition at line 121 of file overlay_prestage_def.py.

overlay_prestage_def.fhicl_runs

Definition at line 120 of file overlay_prestage_def.py.

overlay_prestage_def.file_list

Definition at line 125 of file overlay_prestage_def.py.

overlay_prestage_def.FILE_PATTERN

Definition at line 23 of file overlay_prestage_def.py.

overlay_prestage_def.files

Definition at line 167 of file overlay_prestage_def.py.

overlay_prestage_def.files_unmatched

Definition at line 177 of file overlay_prestage_def.py.

overlay_prestage_def.GROUP_SIZE

Definition at line 21 of file overlay_prestage_def.py.

overlay_prestage_def.help

Definition at line 84 of file overlay_prestage_def.py.

overlay_prestage_def.matches
overlay_prestage_def.md

Definition at line 145 of file overlay_prestage_def.py.

overlay_prestage_def.metavar

Definition at line 83 of file overlay_prestage_def.py.

overlay_prestage_def.n_files

Definition at line 129 of file overlay_prestage_def.py.

overlay_prestage_def.n_files_div10

Definition at line 130 of file overlay_prestage_def.py.

overlay_prestage_def.n_runs

Definition at line 175 of file overlay_prestage_def.py.

overlay_prestage_def.nargs

Definition at line 88 of file overlay_prestage_def.py.

overlay_prestage_def.num_tiers

Definition at line 155 of file overlay_prestage_def.py.

overlay_prestage_def.output_def_name

Definition at line 118 of file overlay_prestage_def.py.

overlay_prestage_def.overlay_runs

Definition at line 178 of file overlay_prestage_def.py.

overlay_prestage_def.parser

Definition at line 81 of file overlay_prestage_def.py.

overlay_prestage_def.SAM

Definition at line 78 of file overlay_prestage_def.py.

overlay_prestage_def.snapid

Definition at line 169 of file overlay_prestage_def.py.