CMS 3D CMS Logo

Functions | Variables
mps_list_evts Namespace Reference

Functions

def get_mille_lines ()
 
def get_num_evts_per_dataset (mille_lines)
 
def get_num_evts_per_merged_dataset (merged_datasets, num_evts_per_dataset)
 
def merge_datasets (num_evts_per_dataset)
 
def print_merging_scheme (merged_datasets)
 
def print_num_evts_per_dataset (num_evts_per_dataset)
 

Variables

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

Detailed Description

Print the total number of events processed by the mille jobs per dataset

The information is taken from the `mps.db' file. Will group entries of the
same dataset and also datasets the script *thinks* belong to the same
data type, e.g. 0T cosmics. This is implemented very simple and should 
always be checked by the user.

Usage:

 `python mps_list_evts.py <mps.db file name>' or, after `scram b'
 `mps_list_evts.py <mps.db file name>'

M. Schroeder, DESY Hamburg      26-May-2014

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.

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

References createfilelist.int.

41 def get_num_evts_per_dataset(mille_lines):
42  """ Return number of events per dataset
43 
44  Returns a dict `<dataset>:<num_evts>', where <dataset> is the label
45  in the last field of the mille line.
46  """
47  num_evts_per_dataset = {}
48  for line in mille_lines:
49  dataset = line[12]
50  num_evts = int(line[6])
51  if dataset in num_evts_per_dataset:
52  num_evts_per_dataset[dataset] = num_evts_per_dataset[dataset] + num_evts
53  else:
54  num_evts_per_dataset[dataset] = num_evts
55 
56  return num_evts_per_dataset
57 
58 
59 
def get_num_evts_per_dataset(mille_lines)
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 def get_num_evts_per_merged_dataset(merged_datasets,num_evts_per_dataset):
61  """ Return number of events per merged dataset
62 
63  Returns a dict `<merged_dataset>:<num_evts>'; see comments to function
64  `merge_datasets' for an explanation of <merged_dataset>.
65  """
66  num_evts_per_merged_dataset = {}
67  for merged_dataset,datasets in merged_datasets.iteritems():
68  num_evts = 0
69  for dataset in datasets:
70  num_evts = num_evts + num_evts_per_dataset[dataset]
71  num_evts_per_merged_dataset[merged_dataset] = num_evts
72 
73  return num_evts_per_merged_dataset
74 
75 
76 
def get_num_evts_per_merged_dataset(merged_datasets, num_evts_per_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 mps_alisetup.append.

77 def merge_datasets(num_evts_per_dataset):
78  """ Return dict `<merged_dataset> : list of <dataset>'
79 
80  Associates all datasets in `num_evts_per_dataset' that belong by their
81  name to the same PD but to a different run era. For example:
82 
83  isolated_mu_runa_v1, isolated_mu_runb_v1, isolated_mu_runc_v2 --> isolated_mu
84 
85  The returned dict has as value a list of the merged datasets.
86  """
87  datasets = num_evts_per_dataset.keys()
88  merged_datasets = {}
89  for dataset in datasets:
90  bare_name = dataset[0:dataset.find("run")].rstrip("_")
91  if bare_name in merged_datasets:
92  merged_datasets[bare_name].append(dataset)
93  else:
94  merged_datasets[bare_name] = [dataset]
95 
96  return merged_datasets
97 
98 
99 
def merge_datasets(num_evts_per_dataset)
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.

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

References harvestTrackValidationPlots.str.

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

Variable Documentation

mps_list_evts.merged_datasets = merge_datasets(num_evts_per_dataset)

Definition at line 150 of file mps_list_evts.py.

mps_list_evts.mille_lines = get_mille_lines()

Definition at line 148 of file mps_list_evts.py.

mps_list_evts.mps_db = "mps.db"

Definition at line 21 of file mps_list_evts.py.

mps_list_evts.num_evts_per_dataset = get_num_evts_per_dataset(mille_lines)

Definition at line 149 of file mps_list_evts.py.

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.