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 sanity_check
 

Variables

string calib_source = '/fff/ramdisk/playback_files/run233238/'
 
 copy_file = True
 
int current_lumi = 1
 
string dat_source = '/fff/ramdisk/playback_files/run233238/'
 
string destination = '/fff/ramdisk'
 
string EoRfile = output_dir+'/'
 
dictionary file_types
 
list files_copied = []
 
int files_copied_buffer_len = 60
 
tuple gf = open(global_runfile, 'w')
 
string global_runfile = destination+'/'
 
tuple j = i%len(pb_jsn_files)
 
tuple k = i%len(calib_jsn_files)
 
int lumi_len = 23
 
int lumi_padding = 4
 
 lumi_skip_at = None
 
int lumi_skip_length = 10
 
string output_dir = destination+'/'
 
string pb_source = '/fff/ramdisk/playback_files/run233238/'
 
tuple run_length = len(dat_jsn_files)
 
int run_padding = 6
 
int run_switch_interval = 90
 

Function Documentation

def roll_playback.copy_next_lumi (   jsn_file,
  file,
  run_number,
  current_lumi,
  source,
  destination,
  copy_file = True 
)

Definition at line 67 of file roll_playback.py.

References reco.print(), and sanity_check().

67 
68 def copy_next_lumi(jsn_file, file, run_number, current_lumi, source, destination, copy_file=True):
69  index = current_lumi % len(jsn_file)
70 
71  # copy the file
72  input_fn = source + '/' + file
73  output_fn = file
74  run_start = output_fn.find('run') + 3
75  output_fn = output_fn[:run_start] + str(run_number).zfill(run_padding) + output_fn[run_start + run_padding:]
76  lumi_start = output_fn.find('ls') + 2
77  output_fn = destination + '/' + output_fn[:lumi_start] + str(current_lumi).zfill(lumi_padding) + output_fn[lumi_start + lumi_padding:]
78  if copy_file:
79  os.link(input_fn, output_fn) # instead of copying the file create a hard link
80  print(input_fn + ' -> ' + output_fn)
81 
82  # load the original json contents
83  input_jsn_fn = source + '/' + jsn_file
84  input_jsn = open(input_jsn_fn, 'r')
85  jsn_data = json.load(input_jsn)
86  input_jsn.close()
87 
88  # generate the output jsn file name
89  output_jsn_fn = jsn_file
90  run_start = output_jsn_fn.find('run') + 3
91  output_jsn_fn = output_jsn_fn[:run_start] + str(run_number).zfill(run_padding) + output_jsn_fn[run_start + run_padding:]
92  lumi_start = output_jsn_fn.find('ls') + 2
93  output_jsn_fn = destination + '/' + output_jsn_fn[:lumi_start] + str(current_lumi).zfill(lumi_padding) + output_jsn_fn[lumi_start + lumi_padding:]
94 
95  # modify the json file contents
96  jsn_data['data'][3] = output_fn[output_fn.rfind('/')+1:]
97 
98  # create the outpuf jsn file
99  output_jsn = open(output_jsn_fn, 'w')
100  output_jsn.write(json.dumps(jsn_data, indent=4))
101  output_jsn.close()
102 
103  print(input_jsn_fn + ' -> ' + output_jsn_fn)
104 
105  return (output_jsn_fn, output_fn) if copy_file else (output_jsn_fn, )
106 
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
def roll_playback.sanity_check (   source,
  file_info 
)

Definition at line 33 of file roll_playback.py.

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

Referenced by copy_next_lumi().

33 
34 def sanity_check(source, file_info):
35  jsn_files = []
36  data_files = []
37  run_number = None
38 
39  # find the json files that match the given pattern
40  files = os.listdir(source)
41  jsn_pattern = re.compile(file_info['re_pattern'])
42  jsn_files = sorted(filter(lambda x: jsn_pattern.match(x), files))
43 
44  # check if the data files exist
45  jsn_files_tobe_removed = []
46  for jsn_file in jsn_files:
47  data_file = jsn_file.replace('.jsn', file_info['extension'])
48  if os.path.exists(source + '/' + data_file):
49  data_files.append(data_file)
50  else:
51  print('The data file {0} does NOT exist! Removing the corresponding json file.'.format(data_file))
52  jsn_files_tobe_removed.append(jsn_file)
53 
54  # remove the json files that don't have corresponding data file
55  jsn_files = [x for x in jsn_files if x not in jsn_files_tobe_removed]
56 
57  run_number = int(jsn_pattern.match(jsn_files[0]).group(1))
58  # check for run_number consistency
59  for i in range(1,len(jsn_files)):
60  run_number_current = int(jsn_pattern.match(jsn_files[i]).group(1))
61  if run_number_current != run_number:
62  print('Non consistent run numbers: "{0}" - expected, "{1}" - found'.format(run_nummber, run_nummber_current))
63  print('\t "{0}" - will be used as a run number'.format(run_nummber))
64 
65  return True, jsn_files, data_files, run_number
66 
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
tuple group
Definition: watchdog.py:82

Variable Documentation

string roll_playback.calib_source = '/fff/ramdisk/playback_files/run233238/'

Definition at line 17 of file roll_playback.py.

roll_playback.copy_file = True

Definition at line 119 of file roll_playback.py.

Referenced by evf::EvFDaqDirector.EvFDaqDirector().

int roll_playback.current_lumi = 1

Definition at line 136 of file roll_playback.py.

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

Definition at line 15 of file roll_playback.py.

string roll_playback.destination = '/fff/ramdisk'

Definition at line 19 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 FWPartialConfigSaveGUI.Write().

string roll_playback.EoRfile = output_dir+'/'

Definition at line 160 of file roll_playback.py.

dictionary roll_playback.file_types
Initial value:
1 = { 'general_files': {'extension':'.dat', 're_pattern':r'run([0-9]+)_ls([0-9]+)_streamDQM_mrg-[A-Za-z0-9-]+\.jsn'},
2  'hlt_pb_files': {'extension':'.pb', 're_pattern':r'run([0-9]+)_ls([0-9]+)_streamDQMHistograms_mrg-[A-Za-z0-9-]+\.jsn'},
3  'calib_files': {'extension':'.dat', 're_pattern':r'run([0-9]+)_ls([0-9]+)_streamDQMCalibration_mrg-[A-Za-z0-9-]+\.jsn'}, }

Definition at line 28 of file roll_playback.py.

list roll_playback.files_copied = []

Definition at line 123 of file roll_playback.py.

int roll_playback.files_copied_buffer_len = 60

Definition at line 23 of file roll_playback.py.

tuple roll_playback.gf = open(global_runfile, 'w')

Definition at line 127 of file roll_playback.py.

string roll_playback.global_runfile = destination+'/'

Definition at line 126 of file roll_playback.py.

tuple roll_playback.j = i%len(pb_jsn_files)

Definition at line 140 of file roll_playback.py.

tuple roll_playback.k = i%len(calib_jsn_files)

Definition at line 143 of file roll_playback.py.

int roll_playback.lumi_len = 23

Definition at line 20 of file roll_playback.py.

int roll_playback.lumi_padding = 4

Definition at line 22 of file roll_playback.py.

int roll_playback.lumi_skip_at = None

Definition at line 118 of file roll_playback.py.

int roll_playback.lumi_skip_length = 10

Definition at line 26 of file roll_playback.py.

string roll_playback.output_dir = destination+'/'

Definition at line 131 of file roll_playback.py.

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

Definition at line 16 of file roll_playback.py.

tuple roll_playback.run_length = len(dat_jsn_files)

Definition at line 117 of file roll_playback.py.

int roll_playback.run_padding = 6

Definition at line 21 of file roll_playback.py.

int roll_playback.run_switch_interval = 90

Definition at line 24 of file roll_playback.py.