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

def merged_datasets = merge_datasets(num_evts_per_dataset)
 
def mille_lines = get_mille_lines()
 
string mps_db = "mps.db"
 
def num_evts_per_dataset = get_num_evts_per_dataset(mille_lines)
 
def 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

◆ get_mille_lines()

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

Definition at line 25 of file mps_list_evts.py.

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 
41 
def get_mille_lines()

◆ get_num_evts_per_dataset()

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 42 of file mps_list_evts.py.

References createfilelist.int.

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 
60 
def get_num_evts_per_dataset(mille_lines)

◆ get_num_evts_per_merged_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 61 of file mps_list_evts.py.

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.items():
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 
77 
def get_num_evts_per_merged_dataset(merged_datasets, num_evts_per_dataset)

◆ merge_datasets()

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 78 of file mps_list_evts.py.

References mps_setup.append.

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 
100 
def merge_datasets(num_evts_per_dataset)

◆ print_merging_scheme()

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 101 of file mps_list_evts.py.

References print().

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.items():
109  print("\n `"+merged_dataset+"' from:")
110  for dataset in datasets:
111  print(" `"+dataset+"'")
112 
113 
114 
def print_merging_scheme(merged_datasets)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ print_num_evts_per_dataset()

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 115 of file mps_list_evts.py.

References print(), and str.

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 
135 
def print_num_evts_per_dataset(num_evts_per_dataset)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)

Variable Documentation

◆ merged_datasets

def mps_list_evts.merged_datasets = merge_datasets(num_evts_per_dataset)

Definition at line 151 of file mps_list_evts.py.

◆ mille_lines

def mps_list_evts.mille_lines = get_mille_lines()

Definition at line 149 of file mps_list_evts.py.

◆ mps_db

mps_list_evts.mps_db = "mps.db"

Definition at line 22 of file mps_list_evts.py.

◆ num_evts_per_dataset

def mps_list_evts.num_evts_per_dataset = get_num_evts_per_dataset(mille_lines)

Definition at line 150 of file mps_list_evts.py.

◆ num_evts_per_merged_dataset

def mps_list_evts.num_evts_per_merged_dataset = get_num_evts_per_merged_dataset(merged_datasets,num_evts_per_dataset)

Definition at line 152 of file mps_list_evts.py.