Exemplo n.º 1
0
        fakerates.fillFakeRates(chain, weight, passed, index=fake_index)

    print fakerates.getFakeRate('total').getNumerator().GetSumOfWeights(
    ), fakerates.getFakeRate('total').getDenominator().GetSumOfWeights()
    print fakerates.getFakeRate('total').getNumerator().GetEntries(
    ), fakerates.getFakeRate('total').getDenominator().GetEntries()
    print fakerates.getFakeRate('0jets').getNumerator().GetSumOfWeights(
    ), fakerates.getFakeRate('0jets').getDenominator().GetSumOfWeights()
    print fakerates.getFakeRate('0jets').getNumerator().GetEntries(
    ), fakerates.getFakeRate('0jets').getDenominator().GetEntries()
    print fakerates.getFakeRate('njets').getNumerator().GetSumOfWeights(
    ), fakerates.getFakeRate('njets').getDenominator().GetSumOfWeights()
    print fakerates.getFakeRate('njets').getNumerator().GetEntries(
    ), fakerates.getFakeRate('njets').getDenominator().GetEntries()
    fakerates.writeFakeRates(is_test=arg_string)
    cutter.saveCutFlow(getOutputName(region_to_select))
    closeLogger(log)

#
# Plotting time
#
else:
    from HNL.Tools.mergeFiles import merge
    import glob
    from HNL.Tools.helpers import makePathTimeStamped
    from HNL.Plotting.plot import Plot

    base_path_in = getOutputBase(region_to_select)
    if args.isTest:
        base_path_out = os.path.join(
            os.path.expandvars('$CMSSW_BASE'), 'src', 'HNL',
Exemplo n.º 2
0
            ) if not chain.is_signal else 1.
            new_vars[prompt_str][sc].eventNb = chain._eventNb
            new_vars[prompt_str][sc].entry = entry

            output_tree[prompt_str][sc].Fill()

    for prompt_str in ['prompt', 'nonprompt']:
        for c in SUPER_CATEGORIES.keys():
            output_file.cd(prompt_str + '/' + c)
            output_tree[prompt_str][c].Write()

    output_file.Close()

    closeLogger(log)

    cutter.saveCutFlow(output_name)

else:
    #
    # Check subjobs
    #
    from HNL.Tools.jobSubmitter import checkCompletedJobs

    from HNL.Tools.mergeFiles import merge
    from HNL.Tools.makeBranches import makeBranches

    import uproot

    def mergeSignal(out_name, in_names):
        num_of_entries = {'tot': {}}
        for in_name in in_names:
Exemplo n.º 3
0
        output_name += '/tmp_' + sample.output + '/' + sample.name + '_'

        for iv, v in enumerate(var.keys()):
            if iv == 0:
                list_of_hist[sample.name][v].write(output_name + 'variables' +
                                                   subjobAppendix + '.root',
                                                   subdirs=[v],
                                                   is_test=args.isTest)
            else:
                list_of_hist[sample.name][v].write(output_name + 'variables' +
                                                   subjobAppendix + '.root',
                                                   subdirs=[v],
                                                   append=True,
                                                   is_test=args.isTest)

        cutter.saveCutFlow(output_name + 'variables' + subjobAppendix +
                           '.root')

#If the option to not run over the events again is made, load in the already created histograms here
else:
    import glob

    hist_list = glob.glob(os.getcwd() + '/data/' + __file__.split('.')[0] +
                          '/' + args.year + '/*')

    # Merge files if necessary
    merge(hist_list, __file__, jobs, ('sample', 'subJob'), argParser)

    list_of_hist = {}
    legend_names = {}
    # Load in the histograms from the files
    for v in var.keys():
Exemplo n.º 4
0
        chain.search_region = srm[args.region].getSearchRegion(chain)
        list_of_numbers[ec.returnCategory()][prompt_str].fill(
            chain, lw.getLumiWeight())
        list_of_numbers[ec.returnCategory()]['total'].fill(
            chain, lw.getLumiWeight())

    for prompt_str in ['prompt', 'nonprompt', 'total']:
        for i, c_h in enumerate(list_of_numbers.keys()):
            output_name = getOutputName(prompt_str)
            if i == 0:
                list_of_numbers[c_h][prompt_str].write(output_name)
            else:
                list_of_numbers[c_h][prompt_str].write(output_name,
                                                       append=True)

        cutter.saveCutFlow(getOutputName('total'))

#
# Merge if needed
#
else:
    from HNL.Tools.mergeFiles import merge
    import glob
    import os
    from HNL.Tools.helpers import getObjFromFile
    from HNL.Plotting.plot import Plot
    from HNL.EventSelection.eventCategorization import CATEGORY_NAMES, ANALYSIS_CATEGORIES

    # args.selection, args.region, sample.output, prompt_str

    if not args.isTest:
Exemplo n.º 5
0
                co[c][v].write(is_test=arg_string)
            else:
                co[c][v].write(append=True, is_test=arg_string)

    print "Observed:", co['total']['m3l'].getObserved().GetSumOfWeights()
    print "Predicted:", co['total']['m3l'].getSideband().GetSumOfWeights()

    for b in xrange(1, co['total']['etaFakes'].getObserved().GetNbinsX() + 1):
        print "bin", b, "at eta =", co['total']['etaFakes'].getObserved(
        ).GetBinCenter(b), ":"
        print "OBSERVED:", co['total']['etaFakes'].getObserved().GetBinContent(
            b)
        print "PREDICTED:", co['total']['etaFakes'].getSideband(
        ).GetBinContent(b)

    cutter.saveCutFlow(getOutputName())

    closeLogger(log)

else:
    from HNL.Tools.mergeFiles import merge
    import glob
    from HNL.Tools.helpers import mergeHistograms
    from HNL.Plotting.plot import Plot

    base_path = getOutputBase()

    in_files = glob.glob(os.path.join(base_path, '*'))
    merge(in_files,
          __file__,
          jobs, ('sample', 'subJob'),
Exemplo n.º 6
0
            if args.skimSelection != 'LukaFR':
                if len(chain.leptons) < 3:       continue
            else:
                if len(chain.leptons) < 1:       continue


            new_vars.lumiweight = lw.getLumiWeight()
        else:
            event.initEvent()
            if not event.passedFilter(cutter, sample.output): continue

        output_tree.Fill()

    # print output_name.split('.')[-1]+'_cutflow.root'
    cutter.saveCutFlow(output_name.split('.')[-1]+'_cutflow.root')

    output_tree.AutoSave()

    if not sample.is_data:
        if args.region is None:
            hcounter = sample.getSubHist(args.subJob, 'hCounter')
        else:
            hcounter = sample.getHist('hCounter')
        output_file.cd('blackJackAndHookers')
        hcounter.Write()
        
    output_file.Close()

    closeLogger(log)