CMS 3D CMS Logo

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

Functions

def copy_next_lumi
 
def dat_sanity_check
 
def pb_sanity_check
 

Variables

int current_lumi = 1
 
string dat_source = '/fff/ramdisk/playback_files/run224380'
 
string destination = '/fff/ramdisk'
 
list files_copied = []
 
int files_copied_buffer_len = 20
 
int lumi_len = 23
 
int lumi_padding = 4
 
string output_dir = destination+'/'
 
string pb_source = '/fff/ramdisk/playback_files/run225044_pb'
 
tuple run_number = int(dat_run_number)
 
int run_padding = 6
 

Function Documentation

def roll_playback.copy_next_lumi (   jsn_files,
  files,
  run_number,
  current_lumi,
  source,
  destination 
)

Definition at line 101 of file roll_playback.py.

References dat_sanity_check(), pb_sanity_check(), and reco.print().

102 def copy_next_lumi(jsn_files, files, run_number, current_lumi, source, destination):
103  assert(len(jsn_files) == len(files))
104 
105  index = current_lumi % len(jsn_files)
106 
107  # copy the file
108  input_fn = source + '/' + files[index]
109  output_fn = files[index]
110  run_start = output_fn.find('run') + 3
111  output_fn = output_fn[:run_start] + str(run_number).zfill(run_padding) + output_fn[run_start + run_padding:]
112  lumi_start = output_fn.find('ls') + 2
113  output_fn = destination + '/' + output_fn[:lumi_start] + str(current_lumi).zfill(lumi_padding) + output_fn[lumi_start + lumi_padding:]
114  os.link(input_fn, output_fn) # instead of copying the file create a hard link
115  print(input_fn + ' -> ' + output_fn)
116 
117  # modyfy and copy the json file
118  input_jsn_fn = source + '/' + jsn_files[index]
119  input_jsn = open(input_jsn_fn, 'r')
120  jsn_data = json.load(input_jsn)
121  input_jsn.close()
122 
123  # generate the output jsn file name
124  output_jsn_fn = jsn_files[index]
125  run_start = output_jsn_fn.find('run') + 3
126  output_jsn_fn = output_jsn_fn[:run_start] + str(run_number).zfill(run_padding) + output_jsn_fn[run_start + run_padding:]
127  lumi_start = output_jsn_fn.find('ls') + 2
128  output_jsn_fn = destination + '/' + output_jsn_fn[:lumi_start] + str(current_lumi).zfill(lumi_padding) + output_jsn_fn[lumi_start + lumi_padding:]
129 
130  # modify the json file contents
131  jsn_data['data'][3] = output_fn[output_fn.rfind('/')+1:]
132 
133  # create the outpuf jsn file
134  output_jsn = open(output_jsn_fn, 'w')
135  output_jsn.write(json.dumps(jsn_data, indent=4))
136  output_jsn.close()
137 
138  print(input_jsn_fn + ' -> ' + output_jsn_fn)
139 
140  return output_jsn_fn, output_fn
141 
142 
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
def roll_playback.dat_sanity_check (   dat_source)

Definition at line 23 of file roll_playback.py.

References alcazmumu_cfi.filter, watchdog.group, python.multivaluedict.map(), and reco.print().

Referenced by copy_next_lumi().

23 
24 def dat_sanity_check(dat_source):
25  dat_jsn_files = []
26  dat_files = []
27  dat_run_number = None
28 
29  # find the dat json files
30  files = os.listdir(dat_source)
31  dat_jsn_pattern = re.compile(r'run([0-9]+)_ls([0-9]+)_streamDQM_StorageManager.jsn')
32  dat_jsn_files = sorted(filter(lambda x: dat_jsn_pattern.match(x), files))
33  if len(dat_jsn_files) < 1:
34  print('No dat json files are found in "{0}"'.format(dat_source))
35  return False, dat_jsn_files, dat_files, dat_run_number
36 
37  # check if the dat files exist
38  jsn_files_tobe_removed = []
39  for jsn_file in dat_jsn_files:
40  dat_file = jsn_file.replace('.jsn','.dat')
41  if not os.path.exists(dat_source + '/' + dat_file):
42  print('The dat file {0} does NOT exist! Removing the corresponding json file.'.format(dat_file))
43  jsn_files_tobe_removed.append(jsn_file)
44 
45  # remove the json files that don't have corresponding dat file
46  dat_jsn_files = [x for x in dat_jsn_files if x not in jsn_files_tobe_removed]
47 
48  # create a list of dat files
49  dat_files = map(lambda x: x.replace('.jsn','.dat'), dat_jsn_files)
50 
51 
52  dat_run_number = int(dat_jsn_pattern.match(dat_jsn_files[0]).group(1))
53  # check for run_number consistency
54  for i in range(1,len(dat_jsn_files)):
55  run_number_current = int(dat_jsn_pattern.match(dat_jsn_files[i]).group(1))
56  if run_number_current != dat_run_number:
57  print('Non consistent run numbers: "{0}" - expected, "{1}" - found'.format(run_nummber, run_nummber_current))
58  print('\t "{0}" - will be used as a run number'.format(run_nummber))
59 
60  return True, dat_jsn_files, dat_files, dat_run_number
61 
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
tuple group
Definition: watchdog.py:82
def roll_playback.pb_sanity_check (   pb_source)

Definition at line 62 of file roll_playback.py.

References alcazmumu_cfi.filter, watchdog.group, python.multivaluedict.map(), and reco.print().

Referenced by copy_next_lumi().

62 
63 def pb_sanity_check(pb_source):
64  pb_jsn_files = []
65  pb_files = []
66  pb_run_number = None
67 
68  # find the pb json files
69  files = os.listdir(pb_source)
70  pb_jsn_pattern = re.compile(r'run([0-9]+)_ls([0-9]+)_streamDQMHistograms_StorageManager.jsn')
71  pb_jsn_files = sorted(filter(lambda x: pb_jsn_pattern.match(x), files))
72 
73  # check if the pb files exist
74  jsn_files_tobe_removed = []
75  for jsn_file in pb_jsn_files:
76  pb_file = jsn_file.replace('.jsn','.pb')
77  if not os.path.exists(pb_source + '/' + pb_file):
78  print('The pb file {0} does NOT exist! Removing the corresponding json file.'.format(pb_file))
79  jsn_files_tobe_removed.append(jsn_file)
80 
81  # remove the json files that don't have corresponding pb file
82  pb_jsn_files = [x for x in pb_jsn_files if x not in jsn_files_tobe_removed]
83 
84  if len(pb_jsn_files) < 1:
85  print('No pb json files are found in "{0}"'.format(pb_source))
86  return False, pb_jsn_files, pb_files, pb_run_number
87 
88  # create a list of pb files
89  pb_files = map(lambda x: x.replace('.jsn','.pb'), pb_jsn_files)
90 
91  pb_run_number = int(pb_jsn_pattern.match(pb_jsn_files[0]).group(1))
92  # check for run_number consistency
93  for i in range(1,len(pb_jsn_files)):
94  run_number_current = int(pb_jsn_pattern.match(pb_jsn_files[i]).group(1))
95  if run_number_current != pb_run_number:
96  print('Non consistent run numbers: "{0}" - expected, "{1}" - found'.format(run_nummber, run_nummber_current))
97  print('\t "{0}" - will be used as a run number'.format(run_nummber))
98 
99  return True, pb_jsn_files, pb_files, pb_run_number
100 
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
tuple group
Definition: watchdog.py:82

Variable Documentation

int roll_playback.current_lumi = 1

Definition at line 159 of file roll_playback.py.

string roll_playback.dat_source = '/fff/ramdisk/playback_files/run224380'

Definition at line 14 of file roll_playback.py.

string roll_playback.destination = '/fff/ramdisk'

Definition at line 16 of file roll_playback.py.

Referenced by ora::DatabaseContainer.getNames(), ora::Database.getNamesForObject(), cond::persistency.import(), cond::CredentialStore.listConnections(), ora::OraPtrReadBuffer.read(), ora::DependentClassReader.read(), ora::ReadBuffer.read(), and FedRawDataInputSource.renameToNextFree().

list roll_playback.files_copied = []

Definition at line 160 of file roll_playback.py.

int roll_playback.files_copied_buffer_len = 20

Definition at line 20 of file roll_playback.py.

int roll_playback.lumi_len = 23

Definition at line 17 of file roll_playback.py.

int roll_playback.lumi_padding = 4

Definition at line 19 of file roll_playback.py.

string roll_playback.output_dir = destination+'/'

Definition at line 154 of file roll_playback.py.

string roll_playback.pb_source = '/fff/ramdisk/playback_files/run225044_pb'

Definition at line 15 of file roll_playback.py.

tuple roll_playback.run_number = int(dat_run_number)

Definition at line 148 of file roll_playback.py.

int roll_playback.run_padding = 6

Definition at line 18 of file roll_playback.py.