Ejemplo n.º 1
0
    fake1est = compute_errors(fr1)
    fake2est = compute_errors(fr2)
    double_est = 0
    if fr12en:
        double_est = fr12s*get_rel_counting_err(fr12en)

    total_yield = fake1est + fake2est - double_est
    return total_yield

# Make these importable

int_lumi = analysis_cfg.INT_LUMI
skips = ['DoubleEl', 'EM']
samples, plotter = data_tool.build_data(
    'VH', analysis_cfg.JOBID, 'scratch_results',
    int_lumi, skips, count='emt/skimCounter')

if __name__ == "__main__":
    # Load the MC-DATA correction functions
    log.info("Loading MC-DATA corrections")
    ROOT.gROOT.ProcessLine('.L corrections.C++')

    log.info("Loading fake rate functions")
    ROOT.gROOT.ProcessLine('.L fake_rates.C++')

    log.info("Beginning analysis at %s", _START)
    ############################################################################
    ### Load the data ##########################################################
    ############################################################################
            varname = match.group('var')
    assert(varname)
    barrel_info_clone['denom'].append('%sAbsEta <= 1.48' % varname)
    endcap_info_clone['denom'].append('%sAbsEta > 1.48' % varname)
    fakerates[fr + '_endcap'] = endcap_info_clone
    fakerates[fr + '_barrel'] = barrel_info_clone

output_file = ROOT.TFile("results_singleMuFakeRates.root", "RECREATE")
for data_set, skips, int_lumi, puTag in [
    ('2011A', ['2011B', 'EM',], 2170, 'pu2011A'),
    #('2011B', ['2011A', 'EM'], 2170),
    ('2011AB', ['EM',], 4684, 'pu2011AB') ]:
    log.info("Plotting dataset: %s", data_set)

    samples, plotter = data_tool.build_data(
        'Mu', '2012-04-14-v1-MuonTP', 'scratch_results', int_lumi, skips,
        count = '/mm/skimCounter', unweighted = False)

    legend = plotter.build_legend(
        '/em/skimCounter',
        include = ['*'],
        exclude = ['*data*','*VH*'],
        drawopt='lf')

    def saveplot(filename):
        # Save the current canvas
        filetype = '.pdf'
        canvas.SetLogy(False)
        canvas.Update()
        canvas.Print(os.path.join(
            "plots", 'singleMuFakeRates', data_set, filename + filetype))
Ejemplo n.º 3
0
#!/usr/bin/env python

import ROOT
from rootpy.utils import asrootpy
from rootpy.plotting import Canvas, Legend, HistStack
from FinalStateAnalysis.Utilities.AnalysisPlotter import styling,samplestyles
import rootpy.io as io
import FinalStateAnalysis.StatTools.poisson as poisson

# This stuff is just so we can get matching styles as analysis.py
import FinalStateAnalysis.PatTools.data as data_tool
int_lumi = 5000
skips = ['DoubleEl', 'EM']
samples, plotter = data_tool.build_data(
    'VH',  '2012-04-14-v1-WHAnalyze', 'scratch_results',
    int_lumi, skips, count='emt/skimCounter')

# Get stupid templates to build the styles automatically
signal = asrootpy(plotter.get_histogram(
    'VH120',
    'emt/skimCounter',
).th1)

wz = asrootpy(plotter.get_histogram(
    'WZ',
    'emt/skimCounter',
).th1)

zz = asrootpy(plotter.get_histogram(
    'ZZ',
    'emt/skimCounter',
    'Electron_EBtag < 3.3',
    'abs(Muon2DZ) < 0.2',
    'abs(ElectronDZ) < 0.2',

    'Electron_MissingHits < 0.5',
    'Electron_hasConversion < 0.5',

    'Muon2AbsEta < 2.1',
    'Muon2_MtToMET < 40',
    'NIsoMuonsPt5_Nmuons < 0.5',
    'vtxNDOF > 0',
    'vtxChi2/vtxNDOF < 10',
]

samples, plotter = data_tool.build_data(
    'Mu', '2012-04-14-v1-MuonTP', 'scratch_results',
    4684, ['MuEG', 'DoubleMu', 'EM'], count='em/skimCounter')

canvas = ROOT.TCanvas("basdf", "aasdf", 1200, 600)
canvas.Divide(2)

def saveplot(filename):
    # Save the current canvas
    filetype = '.pdf'
    canvas.SetLogy(False)
    canvas.Update()
    canvas.Print(os.path.join(
        "plots", 'muEGTrigger', filename + filetype))
    canvas.SetLogy(True)
    canvas.Update()
    canvas.Print(os.path.join(
from json import encoder
encoder.FLOAT_REPR = lambda o: format(o, '.4f')

# Setup logging
logging.basicConfig(
    filename='estimateScaleSystematics.log',level=logging.DEBUG, filemode='w')
log = logging.getLogger("analysis")
stderr_log = logging.StreamHandler()
log.addHandler(stderr_log)

int_lumi = analysis_cfg.INT_LUMI
jobid = '2012-02-01-v1-WHAnalyze'

skips = ['DoubleEl', 'EM']
samples, plotter = data_tool.build_data(
    'VH', jobid, 'scratch_results',
    int_lumi, skips, count='emt/skimCounter')

results = {}
for channel, channel_cfg in analysis_cfg.cfg.iteritems():
    log.info("Analyzing channel: %s", channel)
    if channel in analysis_cfg.skip:
        log.warning("Skipping channel %s!!", channel)
        continue
    channel_results = {}
    results[channel] = channel_results
    # The baseline selection
    baseline = channel_cfg['baseline']
    # Get samples to exclude
    exclude = channel_cfg['exclude'] + ['data*']
    ntuple = channel_cfg['ntuple']
Ejemplo n.º 6
0
    filetype = '.pdf'
    #legend.Draw()
    canvas.SetLogy(False)
    canvas.Update()
    canvas.Print(os.path.join(
        "plots", 'controlPlots', filename + filetype))
    canvas.SetLogy(True)
    canvas.Update()
    canvas.Print(os.path.join(
        "plots", 'controlPlots', filename + '_log' + filetype))

skips = ['EM', 'DoubleEl']
int_lumi = 4700

samples, plotter = data_tool.build_data(
    'VH', '2012-02-19-v1-WHAnalyze', 'scratch_results', int_lumi, skips,
    count = '/mmt/skimCounter', unweighted = False)


base_dimuon_selection = [
    #'(run < 5 && Muon1Pt > 13.5 || Muon1Pt > 13.365)',
    #'(run < 5 && Muon2Pt > 9 || Muon2Pt > 8.91)',
    'Muon1Pt > 20',
    'Muon2Pt > 10',
    'Muon1AbsEta < 1.44',
    'Muon2AbsEta < 1.44',
    'Muon1_MuRelIso < 0.1',
    'Muon2_MuRelIso < 0.1',
    'Muon1_MuID_WWID > 0.5',
    'Muon2_MuID_WWID > 0.5',
    'NIsoMuonsPt5_Nmuons < 0.5',
import analysis_cfg
import ROOT
import os
import math
import uncertainties
import FinalStateAnalysis.PatTools.data as data_tool

if __name__ == "__main__":
    log.info("Beginning analysis")
    ############################################################################
    ### Load the data ##########################################################
    ############################################################################
    int_lumi = analysis_cfg.INT_LUMI
    skips = ['DoubleEl', 'EM', 'MuEG']
    samples, plotter = data_tool.build_data(
        'VH', analysis_cfg.JOBID, 'scratch_results',
        int_lumi, skips, count='emt/skimCounter', unweighted=True)

    mumusamples, mumuplotter = data_tool.build_data(
        'VH', '2012-01-28-v1-MuonTP', 'scratch_results',
        int_lumi, skips + ['WW', 'VH', 'TTW', 'TTZ', 'WWW', 'WZ', 'ZZ'],
        count='emt/skimCounter', unweighted=True)

    canvas = ROOT.TCanvas("basdf", "aasdf", 800, 600)

    channel = analysis_cfg.cfg['mmt']
    charge_cat_cfg = channel['charge_categories']['mumu']

    object1_cfg = charge_cat_cfg['object1']
    object2_cfg = charge_cat_cfg['object2']
    object3_cfg = charge_cat_cfg['object3']
    assert varname
    barrel_info_clone["denom"].append("%sAbsEta <= 1.48" % varname)
    endcap_info_clone["denom"].append("%sAbsEta > 1.48" % varname)
    fakerates[fr + "_endcap"] = endcap_info_clone
    fakerates[fr + "_barrel"] = barrel_info_clone

output_file = ROOT.TFile("results_singleMuFakeRates.root", "RECREATE")
for data_set, skips, int_lumi, puTag in [
    ("2011A", ["2011B", "EM"], 2170, "pu2011A"),
    # ('2011B', ['2011A', 'EM'], 2170),
    ("2011AB", ["EM"], 4684, "pu2011AB"),
]:
    log.info("Plotting dataset: %s", data_set)

    samples, plotter = data_tool.build_data(
        "Mu", "2012-04-14-v1-MuonTP", "scratch_results", int_lumi, skips, count="/mm/skimCounter", unweighted=False
    )

    legend = plotter.build_legend("/em/skimCounter", include=["*"], exclude=["*data*", "*VH*"], drawopt="lf")

    def saveplot(filename):
        # Save the current canvas
        filetype = ".pdf"
        canvas.SetLogy(False)
        canvas.Update()
        canvas.Print(os.path.join("plots", "singleMuFakeRates", data_set, filename + filetype))
        canvas.SetLogy(True)
        canvas.Update()
        canvas.Print(os.path.join("plots", "singleMuFakeRates", data_set, filename + "_log" + filetype))

    for fr_type, fr_info in fakerates.iteritems():