def calculate_xsections(normalisation, category, channel):
    global variable, met_type, path_to_JSON
    # calculate the x-sections
    branching_ratio = 0.15
    if channel == 'combined':
        branching_ratio = branching_ratio * 2
    TTJet_xsection = calculate_xsection(normalisation['TTJet_measured'], luminosity, branching_ratio)  # L in pb1
    TTJet_xsection_unfolded = calculate_xsection(normalisation['TTJet_unfolded'], luminosity, branching_ratio)  # L in pb1
    MADGRAPH_xsection = calculate_xsection(normalisation['MADGRAPH'], luminosity, branching_ratio)  # L in pb1
    POWHEG_xsection = calculate_xsection(normalisation['POWHEG'], luminosity, branching_ratio)  # L in pb1
    MCATNLO_xsection = calculate_xsection(normalisation['MCATNLO'], luminosity, branching_ratio)  # L in pb1
    matchingdown_xsection = calculate_xsection(normalisation['matchingdown'], luminosity, branching_ratio)  # L in pb1
    matchingup_xsection = calculate_xsection(normalisation['matchingup'], luminosity, branching_ratio)  # L in pb1
    scaledown_xsection = calculate_xsection(normalisation['scaledown'], luminosity, branching_ratio)  # L in pb1
    scaleup_xsection = calculate_xsection(normalisation['scaleup'], luminosity, branching_ratio)  # L in pb1
    
    xsection_unfolded = {'TTJet_measured' : TTJet_xsection,
                         'TTJet_unfolded' : TTJet_xsection_unfolded,
                         'MADGRAPH': MADGRAPH_xsection,
                         'POWHEG': POWHEG_xsection,
                         'MCATNLO': MCATNLO_xsection,
                         # systematics
                         'matchingdown': matchingdown_xsection,
                         'matchingup': matchingup_xsection,
                         'scaledown': scaledown_xsection,
                         'scaleup': scaleup_xsection
                         }
    write_data_to_JSON(xsection_unfolded, path_to_JSON + '/xsection_measurement_results' + '/kv' + str(unfoldCfg.SVD_k_value) + '/' + category + '/xsection_' + channel + '_' + met_type + '.txt')
def calculate_xsections(normalisation, category, channel):
    global variable, met_type, path_to_JSON
    # calculate the x-sections
    TTJet_xsection = calculate_xsection(normalisation['TTJet_measured'],
                                        luminosity, 0.15)  # L in pb1
    TTJet_xsection_unfolded = calculate_xsection(
        normalisation['TTJet_unfolded'], luminosity, 0.15)  # L in pb1
    MADGRAPH_xsection = calculate_xsection(normalisation['MADGRAPH'],
                                           luminosity, 0.15)  # L in pb1
    POWHEG_xsection = calculate_xsection(normalisation['POWHEG'], luminosity,
                                         0.15)  # L in pb1
    MCATNLO_xsection = calculate_xsection(normalisation['MCATNLO'], luminosity,
                                          0.15)  # L in pb1
    matchingdown_xsection = calculate_xsection(normalisation['matchingdown'],
                                               luminosity, 0.15)  # L in pb1
    matchingup_xsection = calculate_xsection(normalisation['matchingup'],
                                             luminosity, 0.15)  # L in pb1
    scaledown_xsection = calculate_xsection(normalisation['scaledown'],
                                            luminosity, 0.15)  # L in pb1
    scaleup_xsection = calculate_xsection(normalisation['scaleup'], luminosity,
                                          0.15)  # L in pb1

    xsection_unfolded = {
        'TTJet_measured': TTJet_xsection,
        'TTJet_unfolded': TTJet_xsection_unfolded,
        'MADGRAPH': MADGRAPH_xsection,
        'POWHEG': POWHEG_xsection,
        'MCATNLO': MCATNLO_xsection,
        #systematics
        'matchingdown': matchingdown_xsection,
        'matchingup': matchingup_xsection,
        'scaledown': scaledown_xsection,
        'scaleup': scaleup_xsection
    }
    write_data_to_JSON(
        xsection_unfolded, path_to_JSON + '/' + variable +
        '/xsection_measurement_results' + '/kv' + str(unfoldCfg.SVD_k_value) +
        '/' + category + '/xsection_' + channel + '_' + met_type + '.txt')
def calculate_xsections( normalisation, category, channel ):
    global variable, met_type, path_to_JSON
    # calculate the x-sections
    branching_ratio = 0.15
    if channel == 'combined':
        branching_ratio = branching_ratio * 2
    TTJet_xsection = calculate_xsection( normalisation['TTJet_measured'], luminosity, branching_ratio )  # L in pb1
    TTJet_withoutFakes_xsection = calculate_xsection( normalisation['TTJet_measured_withoutFakes'], luminosity, branching_ratio )  # L in pb1
    TTJet_xsection_unfolded = calculate_xsection( normalisation['TTJet_unfolded'], luminosity, branching_ratio )  # L in pb1

    xsection_unfolded = {'TTJet_measured' : TTJet_xsection,
                         'TTJet_measured_withoutFakes' : TTJet_withoutFakes_xsection,
                         'TTJet_unfolded' : TTJet_xsection_unfolded,
                         }

    if category == 'central':
        powhegPythia8_xsection = calculate_xsection( normalisation['powhegPythia8'], luminosity, branching_ratio )  # L in pb1
        amcatnlo_xsection = calculate_xsection( normalisation['amcatnlo'], luminosity, branching_ratio )  # L in pb1
        amcatnlo_HERWIG_xsection = calculate_xsection( normalisation['amcatnlo_HERWIG'], luminosity, branching_ratio )  # L in pb1
        scaledown_xsection = calculate_xsection( normalisation['scaledown'], luminosity, branching_ratio )  # L in pb1
        scaleup_xsection = calculate_xsection( normalisation['scaleup'], luminosity, branching_ratio )  # L in pb1
        massdown_xsection = calculate_xsection( normalisation['massdown'], luminosity, branching_ratio )  # L in pb1
        massup_xsection = calculate_xsection( normalisation['massup'], luminosity, branching_ratio )  # L in pb1

        madgraphMLM_xsection = calculate_xsection( normalisation['madgraphMLM'], luminosity, branching_ratio )

        xsection_unfolded['powhegPythia8'] =  powhegPythia8_xsection
        xsection_unfolded['amcatnlo'] =  amcatnlo_xsection
        xsection_unfolded['madgraphMLM'] =  madgraphMLM_xsection
        xsection_unfolded['amcatnlo_HERWIG'] =  amcatnlo_HERWIG_xsection
        xsection_unfolded['scaledown'] =  scaledown_xsection
        xsection_unfolded['scaleup'] =  scaleup_xsection
        xsection_unfolded['massdown'] =  massdown_xsection
        xsection_unfolded['massup'] =  massup_xsection
    file_template = '{path_to_JSON}/{category}/xsection_{channel}_{method}.txt'
    filename = file_template.format(
                path_to_JSON = path_to_JSON,
                category = category,
                channel = channel,
                method = method,
                )

    write_data_to_JSON( xsection_unfolded, filename )
def calculate_xsections( normalisation, category, channel, k_value = None ):
    global variable, met_type, path_to_JSON
    # calculate the x-sections
    branching_ratio = 0.15
    if channel == 'combined':
        branching_ratio = branching_ratio * 2
    TTJet_xsection = calculate_xsection( normalisation['TTJet_measured'], luminosity, branching_ratio )  # L in pb1
    TTJet_xsection_unfolded = calculate_xsection( normalisation['TTJet_unfolded'], luminosity, branching_ratio )  # L in pb1
    MADGRAPH_xsection = calculate_xsection( normalisation['MADGRAPH'], luminosity, branching_ratio )  # L in pb1
    MADGRAPH_ptreweight_xsection = calculate_xsection( normalisation['MADGRAPH_ptreweight'], luminosity, branching_ratio )  # L in pb1
    POWHEG_PYTHIA_xsection = calculate_xsection( normalisation['POWHEG_PYTHIA'], luminosity, branching_ratio )  # L in pb1
    POWHEG_HERWIG_xsection = calculate_xsection( normalisation['POWHEG_HERWIG'], luminosity, branching_ratio )  # L in pb1
    MCATNLO_xsection = calculate_xsection( normalisation['MCATNLO'], luminosity, branching_ratio )  # L in pb1
    matchingdown_xsection = calculate_xsection( normalisation['matchingdown'], luminosity, branching_ratio )  # L in pb1
    matchingup_xsection = calculate_xsection( normalisation['matchingup'], luminosity, branching_ratio )  # L in pb1
    scaledown_xsection = calculate_xsection( normalisation['scaledown'], luminosity, branching_ratio )  # L in pb1
    scaleup_xsection = calculate_xsection( normalisation['scaleup'], luminosity, branching_ratio )  # L in pb1
    
    xsection_unfolded = {'TTJet_measured' : TTJet_xsection,
                         'TTJet_unfolded' : TTJet_xsection_unfolded,
                         'MADGRAPH': MADGRAPH_xsection,
                         'MADGRAPH_ptreweight': MADGRAPH_ptreweight_xsection,
                         'POWHEG_PYTHIA': POWHEG_PYTHIA_xsection,
                         'POWHEG_HERWIG': POWHEG_HERWIG_xsection,
                         'MCATNLO': MCATNLO_xsection,
                         # systematics
                         'matchingdown': matchingdown_xsection,
                         'matchingup': matchingup_xsection,
                         'scaledown': scaledown_xsection,
                         'scaleup': scaleup_xsection
                         }
    if k_value:
        filename = path_to_JSON + '/xsection_measurement_results/%s/kv%d/%s/xsection_%s.txt' % ( channel, k_value, category, met_type )
    elif not channel == 'combined':
        raise ValueError( 'Invalid k-value for variable %s, channel %s, category %s.' % ( variable, channel, category ) )
    else:
        filename = path_to_JSON + '/xsection_measurement_results/%s/%s/xsection_%s.txt' % ( channel, category, met_type )

    write_data_to_JSON( xsection_unfolded, filename )
                                    'MADGRAPH': MADGRAPH_results_electron,
                                    #other generators
                                    'POWHEG': POWHEG_results_electron,
                                    'PYTHIA': PYTHIA_results_electron,
                                    'MCATNLO': MCATNLO_results_electron,
                                    #systematics
                                    'matchingdown': matchingdown_results_electron,
                                    'matchingup': matchingup_results_electron,
                                    'scaledown': scaledown_results_electron,
                                    'scaleup': scaleup_results_electron
                                    }
 write_data_to_JSON(normalisation_electron_unfolded, 'data/normalisation_electron_unfolded.txt')
 
 # calculate the x-sections and
 bin_widths = [25, 20, 25, 30, 150]
 TTJet_xsection = calculate_xsection(TTJet_fit_results_electron, 5050, 0.15)  # L in pb1
 TTJet_xsection_unfolded = calculate_xsection(TTJet_fit_results_electron_unfolded, 5050, 0.15)  # L in pb1
 MADGRAPH_xsection = calculate_xsection(MADGRAPH_results_electron, 5050, 0.15)  # L in pb1
 
 xsection_electron_unfolded = {'TTJet' : TTJet_xsection_unfolded,
                                    'MADGRAPH': MADGRAPH_xsection
                                    }
 write_data_to_JSON(xsection_electron_unfolded, 'data/xsection_electron_unfolded.txt')
 
 TTJet_normalised_to_one_xsection = calculate_normalised_xsection(TTJet_fit_results_electron, bin_widths, normalise_to_one=True)
 TTJet_normalised_to_one_xsection_unfolded = calculate_normalised_xsection(TTJet_fit_results_electron_unfolded, bin_widths, normalise_to_one=True)
 MADGRAPH_normalised_to_one_xsection = calculate_normalised_xsection(MADGRAPH_results_electron, bin_widths, normalise_to_one=True)
 
 normalised_to_one_xsection_electron_unfolded = {'TTJet' : TTJet_normalised_to_one_xsection_unfolded,
                                    'MADGRAPH': MADGRAPH_normalised_to_one_xsection
                                    }
Example #6
0
def calculate_xsections(normalisation, category, channel):
    global variable, met_type, path_to_JSON
    # calculate the x-sections
    branching_ratio = 0.15
    if channel == 'combined':
        branching_ratio = branching_ratio * 2
    TTJet_xsection = calculate_xsection(normalisation['TTJet_measured'],
                                        luminosity,
                                        branching_ratio)  # L in pb1
    TTJet_withoutFakes_xsection = calculate_xsection(
        normalisation['TTJet_measured_withoutFakes'], luminosity,
        branching_ratio)  # L in pb1
    TTJet_xsection_unfolded = calculate_xsection(
        normalisation['TTJet_unfolded'], luminosity,
        branching_ratio)  # L in pb1

    xsection_unfolded = {
        'TTJet_measured': TTJet_xsection,
        'TTJet_measured_withoutFakes': TTJet_withoutFakes_xsection,
        'TTJet_unfolded': TTJet_xsection_unfolded,
    }

    if category == 'central':
        powhegPythia8_xsection = calculate_xsection(
            normalisation['powhegPythia8'], luminosity,
            branching_ratio)  # L in pb1
        amcatnlo_xsection = calculate_xsection(normalisation['amcatnlo'],
                                               luminosity,
                                               branching_ratio)  # L in pb1
        amcatnlo_HERWIG_xsection = calculate_xsection(
            normalisation['amcatnlo_HERWIG'], luminosity,
            branching_ratio)  # L in pb1
        scaledown_xsection = calculate_xsection(normalisation['scaledown'],
                                                luminosity,
                                                branching_ratio)  # L in pb1
        scaleup_xsection = calculate_xsection(normalisation['scaleup'],
                                              luminosity,
                                              branching_ratio)  # L in pb1
        massdown_xsection = calculate_xsection(normalisation['massdown'],
                                               luminosity,
                                               branching_ratio)  # L in pb1
        massup_xsection = calculate_xsection(normalisation['massup'],
                                             luminosity,
                                             branching_ratio)  # L in pb1

        madgraphMLM_xsection = calculate_xsection(normalisation['madgraphMLM'],
                                                  luminosity, branching_ratio)

        xsection_unfolded['powhegPythia8'] = powhegPythia8_xsection
        xsection_unfolded['amcatnlo'] = amcatnlo_xsection
        xsection_unfolded['madgraphMLM'] = madgraphMLM_xsection
        xsection_unfolded['amcatnlo_HERWIG'] = amcatnlo_HERWIG_xsection
        xsection_unfolded['scaledown'] = scaledown_xsection
        xsection_unfolded['scaleup'] = scaleup_xsection
        xsection_unfolded['massdown'] = massdown_xsection
        xsection_unfolded['massup'] = massup_xsection
    file_template = '{path_to_JSON}/{category}/xsection_{channel}_{method}.txt'
    filename = file_template.format(
        path_to_JSON=path_to_JSON,
        category=category,
        channel=channel,
        method=method,
    )

    write_data_to_JSON(xsection_unfolded, filename)
def get_cross_sections(normalisation_unfolded, luminosity, branching_ratio):
    result = {}
    for sample in normalisation_unfolded.keys():
        result[sample] = calculate_xsection(normalisation_unfolded[sample], luminosity, branching_ratio)
    return result