diff --git a/tools/plotting/fastnnlo_statunc.py b/tools/plotting/fastnnlo_statunc.py index f8bd699562d571dbe4dfb8f14b5264d954c54a2e..2b94f5dd8daa1979369f6e4fa7e88715a47de5a6 100755 --- a/tools/plotting/fastnnlo_statunc.py +++ b/tools/plotting/fastnnlo_statunc.py @@ -93,6 +93,7 @@ class SplitArgs(argparse.Action): # Some global definitions _channels = [ 'LO', 'R', 'V', 'RRa', 'RRb', 'RV', 'VV' ] _channel_lists = { 'LO': [ 'LO' ], 'NLO': [ 'LO', 'R', 'V' ], 'NNLO': [ 'LO', 'R', 'V', 'RRa', 'RRb', 'RV', 'VV' ] } +_channel_lists_sum = { 'LO': [ 'LO' ], 'NLO': [ 'LO', 'NLO_only' ], 'NNLO': [ 'LO', 'NLO_only', 'NNLO_only' ] } _orders = [ 'LO', 'NLO', 'NNLO', 'NLO_only', 'NNLO_only' ] _order_lists = { 'LO': [ 'LO' ], 'NLO': [ 'LO', 'NLO', 'NLO_only' ], 'NNLO': [ 'LO', 'NLO', 'NNLO', 'NLO_only', 'NNLO_only' ] } _fntrans = str.maketrans({'[': '', ']': '', '(': '', ')': '', ',': ''}) # Filename translation table @@ -101,8 +102,8 @@ _text_to_order = {'LO': 0, 'NLO': 1, 'NNLO': 2, 'NLO_only': 3, 'NNLO_only': 4} _order_to_text = {0: 'LO', 1: 'NLO', 2: 'NNLO', 3: 'NLO_only', 4: 'NNLO_only'} _order_color = {'LO': 'g', 'NLO': 'b', 'NNLO': 'r', 'NLO_only': 'tab:olive', 'NNLO_only': 'tab:brown'} _order_symbol = {'LO': '^', 'NLO': 's', 'NNLO': 'o', 'NLO_only': 'tri_up', 'NNLO_only': 'plus'} -_channel_color = {'LO': 'tab:green', 'R': 'tab:cyan', 'V': 'tab:blue', 'RRa': 'tab:red', 'RRb': 'tab:orange', 'RV': 'tab:pink', 'VV': 'tab:purple'} -_channel_symbol = {'LO': 'o', 'R': 's', 'V': 'D', 'RRa': 'v', 'RRb': '^', 'RV': '<', 'VV': '>'} +_channel_color = {'LO': 'tab:green', 'R': 'tab:cyan', 'V': 'tab:blue', 'RRa': 'tab:red', 'RRb': 'tab:orange', 'RV': 'tab:pink', 'VV': 'tab:purple', 'NLO_only': 'tab:blue', 'NNLO_only': 'tab:red'} +_channel_symbol = {'LO': 'o', 'R': 's', 'V': 'D', 'RRa': 'v', 'RRb': '^', 'RV': '<', 'VV': '>', 'NLO_only': 'h', 'NNLO_only': 'p'} _colors = ['tab:orange', 'tab:green', 'tab:purple', 'tab:blue', 'tab:brown'] _symbols = ['s', 'X', 'o', '^', 'v'] _hatches = ['', '//', '\\', '|', '-'] @@ -120,7 +121,7 @@ _debug = False # Function plotting statistical uncertainties and signed cross-section shares # for each channel with respect to the total at a chosen order # -def plotting(x_axis, xmin, xmax, dxsr_ch, dxsr_or, xlabel, ylabel, title, tablename, order, given_filename, nice_scale_name, formats, chnshare, xsr_ch, xsr_or, ylabel2): +def plotting(x_axis, xmin, xmax, dxsr_ch, dxsr_or, xlabel, ylabel, title, tablename, order, channel_lists, given_filename, nice_scale_name, formats, chnshare, xsr_ch, xsr_or, ylabel2): # For plotting shifted results, 'next to each other', handling via shift from bincenter # Always seven _channels @@ -143,7 +144,7 @@ def plotting(x_axis, xmin, xmax, dxsr_ch, dxsr_or, xlabel, ylabel, title, tablen # Plot all normalised statistical uncertainties in channel list xs_index = -1 - for channel_item, shift in zip(_channel_lists[order], shift_list): + for channel_item, shift in zip(channel_lists[order], shift_list): xs_index += 1 yerror = 0*dxsr_ch[xs_index, :] ax1.errorbar(x_axis*shift, dxsr_ch[xs_index], yerr=yerror, elinewidth=1, linewidth=0.0, @@ -186,13 +187,13 @@ def plotting(x_axis, xmin, xmax, dxsr_ch, dxsr_or, xlabel, ylabel, title, tablen # Plot signed cross-section shares per channel xs_index = -1 - for channel_item, shift in zip(_channel_lists[order], shift_list): + for channel_item, shift in zip(channel_lists[order], shift_list): xs_index += 1 yerror = 0*xsr_ch[xs_index, :] ax2.errorbar(x_axis*shift, xsr_ch[xs_index], yerr=yerror, elinewidth=1, linewidth=0.0, ms=6, marker=_channel_symbol[channel_item], color=_channel_color[channel_item], fmt='.', label=channel_item) - ax2.errorbar(x_axis*shift, xsr_or[_text_to_order['NLO']], yerr=yerror, elinewidth=1, linewidth=0.0, - ms=6, marker='X', color='k', fmt='.', label='NLO') + ax2.errorbar(x_axis*shift, xsr_or[_text_to_order[order]], yerr=yerror, elinewidth=1, linewidth=0.0, + ms=6, marker='P', color='k', fmt='.', label='total') plt.axhline(y=1.0, linestyle='--', linewidth=1.0, color='black') ax2.legend(fontsize=10, numpoints=1) @@ -227,6 +228,8 @@ def main(): parser.add_argument('table', type=str, nargs='+', help='Filename glob of fastNLO tables to be evaluated. This must be specified!') # Optional arguments + parser.add_argument('-c', '--channels', default='all', type=str, + help='Subchannels to show: "all" for selected order or "sum"med per suborder. If nothing is chosen, "all" is used.') parser.add_argument('-d', '--datfiles', required=False, nargs='?', type=str, action=SplitArgs, help='Comma-separated or empty list of NNLOJET dat files with statistical uncertainties for each channel. If empty, dat files matching to table name are used.') parser.add_argument('-f', '--filename', default=None, type=str, @@ -274,6 +277,16 @@ def main(): exit(1) print('[fastnnlo_statunc]: Normalising statistical uncertainties to', order) + # Channels to show per order + channel_lists = None + if args['channels'] == 'all': + channel_lists = _channel_lists + elif args['channels'] == 'sum': + channel_lists = _channel_lists_sum + else: + print('[fastnnlo_statunc]: Illegal channel lists chosen, aborted! channels =', args['channels']) + exit(1) + # Check existence of NNLOJET dat files for all channels and normalising order datfilenames = [] if args['datfiles'] is None or args['datfiles'][0] == '': @@ -472,14 +485,14 @@ def main(): dxs_ch = [] dxsr_ch = [] if args['datfiles'] is None or args['datfiles'][0] == '': - for channel in _channel_lists[order]: + for channel in channel_lists[order]: parts = tablename.split(sep) parts[1] = channel datfile = tablepath + '/' + sep.join(parts) + '.dat' datfilenames.append(datfile) lstat = (len(datfilenames) > 0) - if lstat and len(datfilenames) != len(_channel_lists[order]): + if lstat and len(datfilenames) != len(channel_lists[order]): print('[fastnnlo_statunc]: Mismatch between required channels and no. of filenames for statistical uncertainties, aborted!') exit(1) @@ -526,7 +539,7 @@ def main(): print('dxsr_ch', dxsr_ch) plotting(x_axis, xmin, xmax, dxsr_ch, dxsr_or, xlabel, ylabel, title, tablename, - order, given_filename, nice_scale_name, formats, chnshare, xsr_ch, xsr_or, ylabel2) + order, channel_lists, given_filename, nice_scale_name, formats, chnshare, xsr_ch, xsr_or, ylabel2) stop_time = timeit.default_timer() timediff = stop_time-start_time