refruns utils

Tools for retrieving a reference run for a given run

Preliminary implementation, based on a json file generated by the Tracker DQM group. Retrieved from here .
Perhaps modify code later to fetch the up-to-date version at runtime instead of having to download a new version. Maybe also using an API to retrieve only the requested run instead of loading the entire file into memory.


get_reference_run

full signature:

def get_reference_run( runnb, jsonlist=None, jsonfile='json_allRunsRefRuns.json' )  

comments:

get the reference run for a given run number  
input arguments:  
- runnb: integer representing a run number.  
- jsonlist: list matching run numbers to reference run numbers.  
  note: the list is supposed to contain dicts with keys 'run_number' and 'reference_run_number',  
        this convention is based on the json file provided by the tracker group.  
  note: if jsonlist is None, jsonfile (see below) will be opened and a jsonlist read from it.  
- jsonfile: path to json file matching run numbers to reference run numbers.  
  note: the json file must contain a list of dicts with keys 'run_number' and 'reference_run_number', as explained above.  
  note: ignored if jsonlist is not None.  
output:  
integer representing the reference run number for the given run.  
if the given run is not in the json, -1 is returned.