示例#1
0
def createResponsePlots(ptbins, etabins):
    response_plots = []
    #we always use a range [ibin, ibin+1)
    for ietabin in range(len(etabins)-1):
        for iptbin in range(len(ptbins)-1):

            response_plots += [make_response_plot_pset(
                response_distribution_name(iptbin, ietabin),
                "Jet response (pT/pTgen) in {0} <= pt < {1}, {2} <= |eta| < {3}".format(ptbins[iptbin], ptbins[iptbin+1], etabins[ietabin], etabins[ietabin+1]),
                100, 0.0, 3.0, ptbins[iptbin], ptbins[iptbin+1], etabins[ietabin], etabins[ietabin+1]
            )]
    return response_plots
示例#2
0
文件: compare.py 项目: zflowers/cmssw
def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "-s",
        "--sample",
        type=str,
        action='append',
        required=True,
        help=
        "DQM files to compare for a single sample, in the format 'name:file1.root:file2.root:...:fileN.root'",
        #default=[
        #    "QCD:DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root:DQM_V0001_R000000001__Global__CMSSW_X_Y_Z__RECO.root"
        #]
    )
    parser.add_argument(
        "-p",
        "--plots",
        type=str,
        action='append',
        required=False,
        help=
        "Plots to put on a single canvas, in the format 'folder:name:plot1:plot2:...:plotN'",
        default=[],
        #default=[
        #    "JetResponse:reso_dist_10_24:reso_dist_10_24_eta05:reso_dist_10_24_eta13"
        #]
    )
    parser.add_argument("--doResponsePlots",
                        action='store_true',
                        required=False,
                        help="If enabled, do all jet response plots")
    parser.add_argument("--doOffsetPlots",
                        action='store_true',
                        required=False,
                        help="If enabled, do all offset plots")
    parser.add_argument("--offsetVar",
                        type=str,
                        action='store',
                        default="npv",
                        help="variable to bin offset eT")
    parser.add_argument("--offsetDR",
                        type=float,
                        action='store',
                        default=0.4,
                        help="offset deltaR value")
    args = parser.parse_args()

    #collect all the SimpleSample objects
    samples = []
    plots = []

    sample_strings = args.sample
    for ss in sample_strings:
        name, files = parse_sample_string(ss)
        samp = SimpleSample(name, name,
                            [(fn, fn.split('/')[-2]) for fn in files])
        samples += [samp]

    for ss in args.plots:
        folder, name, histograms = parse_plot_string(ss)
        plots += [(folder, name, histograms)]

    # This needs to be also changed whenever changing binning
    if args.doResponsePlots:
        plots += [("JetResponse", "reso_pt", [
            "preso_eta05", "preso_eta13", "preso_eta21", "preso_eta25",
            "preso_eta30", "preso_eta50"
        ])]
        plots += [("JetResponse", "reso_pt_rms", [
            "preso_eta05_rms", "preso_eta13_rms", "preso_eta21_rms",
            "preso_eta25_rms", "preso_eta30_rms", "preso_eta50_rms"
        ])]
        plots += [("JetResponse", "response_pt", [
            "presponse_eta05", "presponse_eta13", "presponse_eta21",
            "presponse_eta25", "presponse_eta30", "presponse_eta50"
        ])]
        for iptbin in range(len(ptbins) - 1):
            pthistograms = []
            for ietabin in range(len(etabins) - 1):
                pthistograms += [response_distribution_name(iptbin, ietabin)]
            plots += [("JetResponse", "response_{0:.0f}_{1:.0f}".format(
                ptbins[iptbin], ptbins[iptbin + 1]), pthistograms)]

    if args.doOffsetPlots:
        if args.offsetVar == "npv":
            varHigh, varLow = npvHighOffset, npvLowOffset
        else:
            varHigh, varLow = muHighOffset, muLowOffset
        for ivar in range(varLow, varHigh):
            offsetHists = []
            for itype in candidateType:
                offsetHists += [offset_name(args.offsetVar, ivar, itype)]
            plots += [("Offset/{0}Plots/{0}{1}".format(args.offsetVar, ivar),
                       "{0}{1}".format(args.offsetVar, ivar), offsetHists)]
    return samples, plots, args.doOffsetPlots, args.offsetVar, args.offsetDR