test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
mps_list_evts Namespace Reference

Functions

def get_mille_lines
 
def get_num_evts_per_dataset
 
def get_num_evts_per_merged_dataset
 
def merge_datasets
 
def print_merging_scheme
 
def print_num_evts_per_dataset
 

Variables

tuple merged_datasets = merge_datasets(num_evts_per_dataset)
 
tuple mille_lines = get_mille_lines()
 
string mps_db = "mps.db"
 
tuple num_evts_per_dataset = get_num_evts_per_dataset(mille_lines)
 
tuple num_evts_per_merged_dataset = get_num_evts_per_merged_dataset(merged_datasets,num_evts_per_dataset)
 

Function Documentation

def mps_list_evts.get_mille_lines ( )
Return list of mps.db lines that correspond to a mille job 

Definition at line 24 of file mps_list_evts.py.

24 
25 def get_mille_lines():
26  """ Return list of mps.db lines that correspond to a mille job """
27  mille_lines = []
28  with open(mps_db,"r") as db:
29  for line in db:
30  line = line.rstrip('\n')
31  # mille and pede job lines have 13 `:' separated fields
32  parts = line.split(":")
33  if len(parts) == 13:
34  # mille lines start with `<123>:job<123>'
35  if parts[1] == "job"+parts[0]:
36  mille_lines.append(parts)
37 
38  return mille_lines
39 
40 
def mps_list_evts.get_num_evts_per_dataset (   mille_lines)
Return number of events per dataset

Returns a dict `<dataset>:<num_evts>', where <dataset> is the label
in the last field of the mille line.

Definition at line 41 of file mps_list_evts.py.

41 
42 def get_num_evts_per_dataset(mille_lines):
43  """ Return number of events per dataset
44 
45  Returns a dict `<dataset>:<num_evts>', where <dataset> is the label
46  in the last field of the mille line.
47  """
48  num_evts_per_dataset = {}
49  for line in mille_lines:
50  dataset = line[12]
51  num_evts = int(line[6])
52  if dataset in num_evts_per_dataset:
53  num_evts_per_dataset[dataset] = num_evts_per_dataset[dataset] + num_evts
54  else:
55  num_evts_per_dataset[dataset] = num_evts
56 
57  return num_evts_per_dataset
58 
59 
def get_num_evts_per_dataset
def mps_list_evts.get_num_evts_per_merged_dataset (   merged_datasets,
  num_evts_per_dataset 
)
Return number of events per merged dataset

Returns a dict `<merged_dataset>:<num_evts>'; see comments to function
`merge_datasets' for an explanation of <merged_dataset>.

Definition at line 60 of file mps_list_evts.py.

60 
61 def get_num_evts_per_merged_dataset(merged_datasets,num_evts_per_dataset):
62  """ Return number of events per merged dataset
63 
64  Returns a dict `<merged_dataset>:<num_evts>'; see comments to function
65  `merge_datasets' for an explanation of <merged_dataset>.
66  """
67  num_evts_per_merged_dataset = {}
68  for merged_dataset,datasets in merged_datasets.iteritems():
69  num_evts = 0
70  for dataset in datasets:
71  num_evts = num_evts + num_evts_per_dataset[dataset]
72  num_evts_per_merged_dataset[merged_dataset] = num_evts
73 
74  return num_evts_per_merged_dataset
75 
76 
def get_num_evts_per_merged_dataset
def mps_list_evts.merge_datasets (   num_evts_per_dataset)
Return dict `<merged_dataset> : list of <dataset>'

Associates all datasets in `num_evts_per_dataset' that belong by their
name to the same PD but to a different run era. For example:

isolated_mu_runa_v1, isolated_mu_runb_v1, isolated_mu_runc_v2 --> isolated_mu

The returned dict has as value a list of the merged datasets.

Definition at line 77 of file mps_list_evts.py.

References bitset_utilities.append().

77 
78 def merge_datasets(num_evts_per_dataset):
79  """ Return dict `<merged_dataset> : list of <dataset>'
80 
81  Associates all datasets in `num_evts_per_dataset' that belong by their
82  name to the same PD but to a different run era. For example:
83 
84  isolated_mu_runa_v1, isolated_mu_runb_v1, isolated_mu_runc_v2 --> isolated_mu
85 
86  The returned dict has as value a list of the merged datasets.
87  """
88  datasets = num_evts_per_dataset.keys()
89  merged_datasets = {}
90  for dataset in datasets:
91  bare_name = dataset[0:dataset.find("run")].rstrip("_")
92  if bare_name in merged_datasets:
93  merged_datasets[bare_name].append(dataset)
94  else:
95  merged_datasets[bare_name] = [dataset]
96 
97  return merged_datasets
98 
99 
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
def mps_list_evts.print_merging_scheme (   merged_datasets)
Print number of events per merged dataset

See comments to function `merge_datasets' for an explanation
of what is meant by merged dataset.

Definition at line 100 of file mps_list_evts.py.

101 def print_merging_scheme(merged_datasets):
102  """ Print number of events per merged dataset
103 
104  See comments to function `merge_datasets' for an explanation
105  of what is meant by merged dataset.
106  """
107  print "Defining the following merged datasets:"
108  for merged_dataset,datasets in merged_datasets.iteritems():
109  print "\n `"+merged_dataset+"' from:"
110  for dataset in datasets:
111  print " `"+dataset+"'"
112 
113 
def print_merging_scheme
def mps_list_evts.print_num_evts_per_dataset (   num_evts_per_dataset)
Print number of events per dataset

See comments to function `get_num_evts_per_dataset' for an
explanation of what is meant by dataset.

Definition at line 114 of file mps_list_evts.py.

115 def print_num_evts_per_dataset(num_evts_per_dataset):
116  """ Print number of events per dataset
117 
118  See comments to function `get_num_evts_per_dataset' for an
119  explanation of what is meant by dataset.
120  """
121  print "The following number of events per dataset have been processed:"
122  datasets = sorted(num_evts_per_dataset.keys())
123  max_name = 0
124  max_num = 0
125  for dataset in datasets:
126  if len(dataset) > max_name:
127  max_name = len(dataset)
128  if len(str(num_evts_per_dataset[dataset])) > max_num:
129  max_num = len(str(num_evts_per_dataset[dataset]))
130  expr_name = " {0: <"+str(max_name)+"}"
131  expr_num = " {0: >"+str(max_num)+"}"
132  for dataset in datasets:
133  print expr_name.format(dataset)+" : "+expr_num.format(str(num_evts_per_dataset[dataset]))
134 
def print_num_evts_per_dataset

Variable Documentation

tuple mps_list_evts.merged_datasets = merge_datasets(num_evts_per_dataset)

Definition at line 150 of file mps_list_evts.py.

tuple mps_list_evts.mille_lines = get_mille_lines()

Definition at line 148 of file mps_list_evts.py.

list mps_list_evts.mps_db = "mps.db"

Definition at line 21 of file mps_list_evts.py.

tuple mps_list_evts.num_evts_per_dataset = get_num_evts_per_dataset(mille_lines)

Definition at line 149 of file mps_list_evts.py.

tuple mps_list_evts.num_evts_per_merged_dataset = get_num_evts_per_merged_dataset(merged_datasets,num_evts_per_dataset)

Definition at line 151 of file mps_list_evts.py.