def main():
    args = getComLineArgs()
    ROOT.gROOT.SetBatch(True)
    ROOT.TProof.Open('workers=16')
    sameFile = False
    if not args.denominator == args.numerator:
        sameFile = True

    num_sel = WeightTools.getWeightsFromROOTFile(args.numerator, args.analysis, args.num_cut, sameFile)
    denom_sel = WeightTools.getWeightsFromROOTFile(args.denominator, args.analysis, args.denom_cut, sameFile)
    variations = num_sel
    central = num_sel["1000"]["1001"]/denom_sel["1000"]["1001"]
    for weight_set in num_sel.keys():
        for weight_id in num_sel[weight_set].keys():
            variations[weight_set][weight_id] /= denom_sel[weight_set][weight_id]
            if weight_id != "1001":
                variations[weight_set][weight_id] /= central

    print '-'*80
    print 'Script called at %s' % datetime.datetime.now()
    print 'The command was: %s' % ' '.join(sys.argv)
    print '-'*40
    print "Final Result in %:"
    if not args.no_uncertainty:
        unc = WeightTools.getScaleAndPDFUnc(variations)
        print "%0.4f^{+%0.2f%%}_{-%0.2f%%} \pm %0.2f%%" % tuple(round(x*100, 2)
                for x in [central, unc["scales"]["up"], unc["scales"]["down"], unc["pdf"]["up"]])
        print ''.join(["%0.4e" % (central*100), 
                "^{+%0.4e}_{-%0.4e} \pm %0.4e" % tuple(x*central*100
                for x in [unc["scales"]["up"], unc["scales"]["down"], unc["pdf"]["up"]])])
    else: 
        print "%0.4f%%" % round(central*100, 2) 
    print '-'*40
def main():
    current_path = os.getcwd()
    os.chdir(sys.path[0])
    args  = getComLineArgs()
    command = ["cmsRun", "External/genXsec_cfg.py", "inputFiles=%s" % ",".join([args.file_name])]
    proc = subprocess.Popen(command, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
    for line in proc.stderr:
        if "After filter: final cross section" in line:
            values = re.findall("[0-9]+\.?[0-9]*(?:[Ee]\ *[-+]?\ *[0-9]+)?", line) 
            units = line.split()[-1]
            break
    print "Cross section from file is %s \pm %s %s (stat)" % (values[0], values[1], units) 
    print "\nComputing scale and PDF uncertainties" 
    variations = weight_tools.getWeightsFromEDMFile(args.file_name)
    unc = weight_tools.getScaleAndPDFUnc(variations)
    print "\nFinal values:"
    print "%s" % values[0] + \
        "^{%0.1f%%}_{%0.1f%%} (scale) \pm %0.1f (pdf+alpha_s) " % tuple(round(x*100, 1) for x in 
                [unc["scales"]["up"], unc["scales"]["down"], unc["pdf"]["up"]]) + \
        "%s" % units
    print "%s" % values[0] + \
        "^{%0.2e}_{%0.2e} (scale) \pm %0.2e (pdf+alpha_s) " % tuple(x*float(values[0]) for x in 
                [unc["scales"]["up"], unc["scales"]["down"], unc["pdf"]["up"]]) + \
        "\pm %s (stat) %s" % (values[1], units)
    print "\nNote that PDF+alpha_s uncertainty is taken only from NNPDF"
    os.chdir(current_path)
Пример #3
0
def main():
    args = getComLineArgs()
    ROOT.gROOT.SetBatch(True)
    ROOT.TProof.Open('workers=16')
    sameFile = False
    if not args.denominator == args.numerator:
        sameFile = True

    num_sel = WeightTools.getWeightsFromROOTFile(args.numerator, args.analysis,
                                                 args.num_cut, sameFile)
    denom_sel = WeightTools.getWeightsFromROOTFile(args.denominator,
                                                   args.analysis,
                                                   args.denom_cut, sameFile)
    variations = num_sel
    central = num_sel["1000"]["1001"] / denom_sel["1000"]["1001"]
    for weight_set in num_sel.keys():
        for weight_id in num_sel[weight_set].keys():
            variations[weight_set][weight_id] /= denom_sel[weight_set][
                weight_id]
            if weight_id != "1001":
                variations[weight_set][weight_id] /= central

    print '-' * 80
    print 'Script called at %s' % datetime.datetime.now()
    print 'The command was: %s' % ' '.join(sys.argv)
    print '-' * 40
    print "Final Result in %:"
    if not args.no_uncertainty:
        unc = WeightTools.getScaleAndPDFUnc(variations)
        print "%0.4f^{+%0.2f%%}_{-%0.2f%%} \pm %0.2f%%" % tuple(
            round(x * 100, 2) for x in [
                central, unc["scales"]["up"], unc["scales"]["down"], unc["pdf"]
                ["up"]
            ])
        print ''.join([
            "%0.4e" % (central * 100),
            "^{+%0.4e}_{-%0.4e} \pm %0.4e" % tuple(
                x * central * 100 for x in
                [unc["scales"]["up"], unc["scales"]["down"], unc["pdf"]["up"]])
        ])
    else:
        print "%0.4f%%" % round(central * 100, 2)
    print '-' * 40