Ejemplo n.º 1
0
    )
    groupJobs = 5  # used in make_helicity_cards.py

    (options, args) = parser.parse_args()
    if len(args) < 2:
        parser.print_usage()
        quit()
    channel = args[1]

    ybinfile = args[0] + '/binningYW.txt'
    ybinfile = open(ybinfile, 'r')
    ybins = eval(ybinfile.read())
    ybinfile.close()

    etaPtBinningVec = getDiffXsecBinning(
        args[0] + '/binningPtEta.txt',
        "reco")  # this get two vectors with eta and pt binning
    recoBins = templateBinning(
        etaPtBinningVec[0],
        etaPtBinningVec[1])  # this create a class to manage the binnings
    binning = [recoBins.Neta, recoBins.etaBins, recoBins.Npt, recoBins.ptBins]
    etabins = recoBins.etaBins
    ptbins = recoBins.ptBins

    if options.fitresult:
        print "Scaling the templates to the post-fit results in: ", options.fitresult
        valuesAndErrors = utilities.getFromHessian(options.fitresult)
        allNuisances = utilities.getFromHessian(options.fitresult,
                                                keepGen=True)

    outname = options.outdir
Ejemplo n.º 2
0
                lat.DrawLatex(0.78, 0.92, '35.9 fb^{-1} (13 TeV)')
                for i in ['pdf', 'png']:
                    suff = '' if not options.suffix else '_' + options.suffix
                    cs.SetLogy()
                    cs.SaveAs(options.outdir +
                              '/ywImpacts{rel}{suff}_{target}_{ch}{pol}.{i}'.
                              format(rel='Abs' if options.absolute else 'Rel',
                                     suff=suff,
                                     target=options.target,
                                     i=i,
                                     ch=charge,
                                     pol=pol))

    if options.etaptbinfile:

        etaPtBinningVec = getDiffXsecBinning(options.etaptbinfile, "gen")
        genBins = templateBinning(etaPtBinningVec[0], etaPtBinningVec[1])

        flavour = ""  # decided below

        summaries = {}
        groups = [
            th2_sub.GetYaxis().GetBinLabel(j + 1)
            for j in xrange(th2_sub.GetNbinsY())
        ]
        charges = ['allcharges'
                   ] if 'asym' in options.target else ['plus', 'minus']
        for charge in charges:
            for ing, nuisgroup in enumerate(groups):
                h = ROOT.TH1D(charge + '_' + nuisgroup, '', genBins.Neta,
                              array('d', genBins.etaBins))
Ejemplo n.º 3
0
        quit()

    analysis = options.analysis
    if analysis not in ["helicity", "diffXsec"]:
        print "Warning: analysis not recognized, must be either \"helicity\" or \"diffXsec\""
        quit()

    if options.analysis != "diffXsec" and options.draw_selected_etaPt != '':
        print "Warning: option --select-etaPt is only supported with --analysis diffXsec (but %s passed).\nIt will be ignored." % options.analysis

    outname = options.outdir
    addStringToEnd(outname, "/", notAddIfEndswithMatch=True)
    createPlotDirAndCopyPhp(outname)

    # get eta-pt binning for both reco and gen
    etaPtBinningVec = getDiffXsecBinning(options.etaPtbinning, "reco")
    recoBins = templateBinning(etaPtBinningVec[0], etaPtBinningVec[1])
    etaPtBinningVec = getDiffXsecBinning(options.etaPtbinning, "gen")
    genBins = templateBinning(etaPtBinningVec[0], etaPtBinningVec[1])

    #following array is used to call function dressed2D()
    binning = [recoBins.Neta, recoBins.etaBins, recoBins.Npt, recoBins.ptBins]

    if options.draw_selected_etaPt != '':
        eta = float(options.draw_selected_etaPt.split(',')[0])
        pt = float(options.draw_selected_etaPt.split(',')[1])
        ieta_sel = getArrayBinNumberFromValue(genBins.etaBins, eta)
        ipt_sel = getArrayBinNumberFromValue(genBins.ptBins, pt)
        if ieta_sel < 0 or ipt_sel < 0:
            print "Error: at least one of eta,pt values passed to --select-etaPt is outside the allowed binning. Please check. Exit"
            quit()
Ejemplo n.º 4
0
        if os.path.exists("/afs/cern.ch"): os.system("cp /afs/cern.ch/user/g/gpetrucc/php/index.php "+outnamesub)

    savErrorLevel = ROOT.gErrorIgnoreLevel; ROOT.gErrorIgnoreLevel = ROOT.kError;
    
    infile = ROOT.TFile(args[0], 'read')
    channel = 'el' if any(['el_Ybin' in k.GetName() for k in infile.GetListOfKeys()]) else 'mu'
    print "From the list of histograms it seems that you are plotting results for channel ",channel

    full_outfileName = '{odir}/plots_{sfx}.root'.format(odir=outname,sfx=options.suffix)
    outfile = ROOT.TFile(full_outfileName, 'recreate')
    print "Will save 2D templates in file --> " + full_outfileName

    ## get the pT and eta binning from the file in the directory
    etaPtBinningFile = args[1]+"/binningPtEta.txt"
    # get eta-pt binning for reco
    etaPtBinningVec = getDiffXsecBinning(etaPtBinningFile, "reco")
    recoBins = templateBinning(etaPtBinningVec[0],etaPtBinningVec[1])

    binning = [recoBins.Neta, recoBins.etaBins, recoBins.Npt, recoBins.ptBins]

    # to draw panels in the unrolled plots
    ptBinRanges = []
    for ipt in range(0,recoBins.Npt):
        ptBinRanges.append("p_{{T}} #in [{ptmin:3g}, {ptmax:.3g}]".format(ptmin=recoBins.ptBins[ipt], ptmax=recoBins.ptBins[ipt+1]))


    shifts = chargeUnrolledBinShifts(infile,channel,nCharges,nMaskedChanPerCharge)

    for charge in ['plus','minus']:
        binshift = shifts[charge]
        
Ejemplo n.º 5
0
        quit()

    ROOT.TH1.SetDefaultSumw2()
    ROOT.TH1.StatOverflows(True)

    channel = options.channel
    if channel not in ["el","mu"]:
        print "Error: unknown channel %s (select 'el' or 'mu')" % channel
        quit()
        
    if options.type not in ["toys", "hessian", "scans"]:
        print 'ERROR: none of your types is supported. specify either "toys", "scans", or "hessian"'
        sys.exit()

    # get gen binning from file or directly from option
    binning = getDiffXsecBinning(options.etaPtbinning, "gen")
    #print binning
    etabinning = binning[0]
    ptbinning  = binning[1]

    charges = options.charge.split(',')

    canvas = ROOT.TCanvas("canvas","",800,700)

    for charge in charges:

        outname = options.outdir
        addStringToEnd(outname,"/",notAddIfEndswithMatch=True)
        outname = outname + options.type + ("" if not options.suffix else ("_"+options.suffix)) + "/" + charge + "/"
        createPlotDirAndCopyPhp(outname)