コード例 #1
0
def plot_root(sample, base_name):
    met_pred, met_truth, met_reco, mt_pred, mt_reco = [
        TH1F(n, '', 100, 0, 500)
        for n
        in ['pt_{}'.format(arguments.regressor), 'pt_truth', 'met_reco',
            'mt_{}'.format(arguments.regressor), 'mt_reco']]
    res_pred, res_reco = [
        TH1F(n, '', 100, -100, 100)
        for n
        in ['res_{}'.format(arguments.regressor), 'res_reco']]
    profile = TProfile('profile_pred_{}'.format(arguments.regressor),
                       '', 100, 0, 500)

    map(met_pred.Fill, sample[met_pred_parameter])
    map(met_truth.Fill, sample[met_truth_parameter])
    map(met_reco.Fill, sample[met_reco_parameter])
    map(mt_pred.Fill, sample[mt_pred_parameter])
    map(mt_reco.Fill, sample[mt_reco_parameter])
    map(res_pred.Fill, sample[met_pred_resolution])
    map(res_reco.Fill, sample[met_reco_resolution])
    map(profile.Fill, sample['pt(mc nuH)'], sample[met_pred_ratio])

    root_file = TFile.Open('{}.root'.format(base_name), 'RECREATE')
    root_file.cd()
    met_pred.Write()
    mt_pred.Write()
    res_pred.Write()
    profile.Write()
    root_file.ls()
    root_file.Close()

    init_atlas_style()

    met_pred.SetName('Pred')
    met_reco.SetName('Reco')
    met_truth.SetName('Target')
    o1 = show_hists((met_pred, met_truth, met_reco),
                    'Missing ET',
                    '{}_met.pdf'.format(base_name))

    res_pred.SetName('Pred')
    res_reco.SetName('Reco')
    o2 = show_hists((res_pred, res_reco),
                    'Missing ET resolution',
                    '{}_res.pdf'.format(base_name))

    mt_pred.SetName('Pred')
    mt_reco.SetName('Reco')
    o3 = show_hists((mt_pred, mt_reco),
                    'Transverse mass',
                    '{}_mt.pdf'.format(base_name))

    profile.SetName('Profile')
    o3 = show_hists((profile,),
                    'Profile',
                    '{}_profile.pdf'.format(base_name))
    raw_input('Press any key...')
コード例 #2
0
def pccPerLumiSection(options):
    """Extract PCC data from ROOT files and sort by lumisection"""
    c = chain(options['fileset'], options['scan'])
    rc = reducedChain(options['fileset'], options['scan'])
    name = options['name'] + '_perLS'
    f = openRootFileU(name)
    print '<<< Analyze', options['title']
    histname = plotName(options['title'] + '_perLS', timestamp=False)
    histtitl = plotTitle()
    print '<<< Get Minimum'
    mini = int(rc.GetMinimum('LS'))
    print '<<< Get Maximum'
    maxi = int(rc.GetMaximum('LS'))
    print '<<< Fill Profile Histogram', histname
    hist = TProfile(histname, histtitl, maxi - mini + 1, mini - 0.5,
                    maxi + 0.5)
    c.Draw(options['field'] + ':LS>>' + histname, '', 'goff')
    hist.Write('', TObject.kOverwrite)
    closeRootFile(f, name)
コード例 #3
0
def pccPerTimeStamp(options):
    """Extract PCC data from ROOT files and sort by timestamps"""
    c = chain(options['fileset'], options['scan'])
    rc = chain(options['fileset'], options['scan'])
    name = options['name'] + '_' + options['scan'] + '_perTime'
    f = openRootFileU(options['name'] + '_perTime')
    print '<<< Analyze', options['scan'], options['name']
    histname = plotName(name, timestamp=False)
    histtitl = plotTitle(options['scan'])
    print '<<< Get Minimum'
    mini = int(rc.GetMinimum(O['timename'][options['fileset']]))
    print '<<< Get Maximum'
    maxi = int(rc.GetMaximum(O['timename'][options['fileset']]))
    print '<<< Fill Profile Histogram', histname
    hist = TProfile(histname, histtitl, maxi - mini + 1, mini - 0.5,
                    maxi + 0.5)
    c.Draw(options['field']+':'+O['timename'][options['fileset']]+'>>'+ \
           histname, '', 'goff')
    hist.Write('', TObject.kOverwrite)
    closeRootFile(f, options['name'] + '_perTime')
コード例 #4
0
pt_prof = TProfile("ptprof", "profile of deltapt versus pt", n_bins, x_low,
                   x_high, 0, 1)
tau32_prof = TProfile("tau32prof", "profile of tau32 vs. jet pt", n_bins,
                      x_low, x_high, 0, 1)
tau31_prof = TProfile("tau31prof", "profile of tau31 vs. jet pt", n_bins,
                      x_low, x_high, 0, 1)
tau21_prof = TProfile("tau21prof", "profile of tau21 vs. jet pt", n_bins,
                      x_low, x_high, 0, 1)

nevts = data_chain.GetEntries()
for i in range(nevts):
    data_chain.GetEntry(i)

    hlt_n_jets = data_chain.jet_num
    fj_n_jets = data_chain.fj_jet_num

    n_jets = min(hlt_n_jets, fj_n_jets)

    for j in range(n_jets):
        delta_pt = (data_chain.jet_pt[j] -
                    data_chain.fj_jet_pt[j]) / data_chain.jet_pt[j]
        pt_prof.Fill(data_chain.jet_pt[j], delta_pt)
        if data_chain.tau2[j] != 0:
            tau32_prof.Fill(data_chain.tau3[j] / data_chain.tau2[j], delta_pt)

# Write Histos
outfile.cd()
pt_prof.Write()
tau32_prof.Write()
outfile.Close()
コード例 #5
0
def generator(nuslice_tree, rootfile, pset):
    n_bins = pset.n_bins
    drift_distance = pset.DriftDistance
    bin_width = drift_distance/n_bins
    half_bin_width = bin_width/2.

    xvals = np.arange(half_bin_width, drift_distance, bin_width)
    xerrs = np.array([half_bin_width] * len(xvals))
    dist_to_anode_bins = n_bins
    dist_to_anode_low = 0.
    dist_to_anode_up = drift_distance
    profile_bins = n_bins
    profile_option = 's'  # errors are the standard deviation

    dy_spreads = [None] * n_bins
    dy_means = [None] * n_bins
    dy_hist = TH2D("dy_hist", "#Delta y",
                   dist_to_anode_bins, dist_to_anode_low, dist_to_anode_up,
                   pset.dy_bins, pset.dy_low, pset.dy_up)
    dy_hist.GetXaxis().SetTitle("distance from anode (cm)")
    dy_hist.GetYaxis().SetTitle("y_flash - y_TPC (cm)")
    dy_prof = TProfile("dy_prof", "Profile of dy_spreads in #Delta y",
                       profile_bins, dist_to_anode_low, dist_to_anode_up,
                       pset.dy_low*2, pset.dy_up*2, profile_option)
    dy_prof.GetXaxis().SetTitle("distance from anode (cm)")
    dy_prof.GetYaxis().SetTitle("y_flash - y_TPC (cm)")
    dy_h1 = TH1D("dy_h1", "",
                 profile_bins, dist_to_anode_low, dist_to_anode_up)
    dy_h1.GetXaxis().SetTitle("distance from anode (cm)")
    dy_h1.GetYaxis().SetTitle("y_flash - y_TPC (cm)")

    dz_spreads = [None] * n_bins
    dz_means = [None] * n_bins
    dz_hist = TH2D("dz_hist", "#Delta z",
                   dist_to_anode_bins, dist_to_anode_low, dist_to_anode_up,
                   pset.dz_bins, pset.dz_low, pset.dz_up)
    dz_hist.GetXaxis().SetTitle("distance from anode (cm)")
    dz_hist.GetYaxis().SetTitle("z_flash - z_TPC (cm)")
    dz_prof = TProfile("dz_prof", "Profile of dz_spreads in #Delta z",
                       profile_bins, dist_to_anode_low, dist_to_anode_up,
                       pset.dz_low*2.5, pset.dz_up*2.5, profile_option)
    dz_prof.GetXaxis().SetTitle("distance from anode (cm)")
    dz_prof.GetYaxis().SetTitle("z_flash - z_TPC (cm)")
    dz_h1 = TH1D("dz_h1", "",
                 profile_bins, dist_to_anode_low, dist_to_anode_up)
    dz_h1.GetXaxis().SetTitle("distance from anode (cm)")
    dz_h1.GetYaxis().SetTitle("z_flash - z_TPC (cm)")

    rr_spreads = [None] * n_bins
    rr_means = [None] * n_bins
    rr_hist = TH2D("rr_hist", "PE Spread",
                   dist_to_anode_bins, dist_to_anode_low, dist_to_anode_up,
                   pset.rr_bins, pset.rr_low, pset.rr_up)
    rr_hist.GetXaxis().SetTitle("distance from anode (cm)")
    rr_hist.GetYaxis().SetTitle("RMS flash (cm)")
    rr_prof = TProfile("rr_prof", "Profile of PE Spread",
                       profile_bins, dist_to_anode_low, dist_to_anode_up,
                       pset.rr_low, pset.rr_up, profile_option)
    rr_prof.GetXaxis().SetTitle("distance from anode (cm)")
    rr_prof.GetYaxis().SetTitle("RMS flash (cm)")
    rr_h1 = TH1D("rr_h1", "",
                 profile_bins, dist_to_anode_low, dist_to_anode_up)
    rr_h1.GetXaxis().SetTitle("distance from anode (cm)")
    rr_h1.GetYaxis().SetTitle("RMS flash (cm)")

    if detector == "sbnd":
        pe_spreads = [None] * n_bins
        pe_means = [None] * n_bins
        pe_hist = TH2D("pe_hist", "Uncoated/Coated Ratio",
                       dist_to_anode_bins, dist_to_anode_low, dist_to_anode_up,
                       pset.pe_bins, pset.pe_low, pset.pe_up)
        pe_hist.GetXaxis().SetTitle("distance from anode (cm)")
        pe_hist.GetYaxis().SetTitle("ratio_{uncoated/coated}")
        pe_prof = TProfile("pe_prof", "Profile of Uncoated/Coated Ratio",
                           profile_bins, dist_to_anode_low, dist_to_anode_up,
                           pset.pe_low, pset.pe_up, profile_option)
        pe_prof.GetXaxis().SetTitle("distance from anode (cm)")
        pe_prof.GetYaxis().SetTitle("ratio_{uncoated/coated}")
        pe_h1 = TH1D("pe_h1", "",
                     profile_bins, dist_to_anode_low, dist_to_anode_up)
        pe_h1.GetXaxis().SetTitle("distance from anode (cm)")
        pe_h1.GetYaxis().SetTitle("ratio_{uncoated/coated}")

    match_score_scatter = TH2D("match_score_scatter", "Scatter plot of match scores",
                               dist_to_anode_bins, dist_to_anode_low, dist_to_anode_up,
                               pset.score_hist_bins, pset.score_hist_low, pset.score_hist_up*(3./5.))
    match_score_scatter.GetXaxis().SetTitle("distance from anode (cm)")
    match_score_scatter.GetYaxis().SetTitle("match score (arbitrary)")
    match_score_hist = TH1D("match_score", "Match Score",
                            pset.score_hist_bins, pset.score_hist_low, pset.score_hist_up)
    match_score_hist.GetXaxis().SetTitle("match score (arbitrary)")

    for e in nuslice_tree:
        slice = e.charge_x

        dy_hist.Fill(slice, e.flash_y - e.charge_y)
        dy_prof.Fill(slice, e.flash_y - e.charge_y)
        dz_hist.Fill(slice, e.flash_z - e.charge_z)
        dz_prof.Fill(slice, e.flash_z - e.charge_z)
        rr_hist.Fill(slice, e.flash_r)
        rr_prof.Fill(slice, e.flash_r)
        if detector == "sbnd":
            pe_hist.Fill(slice, e.flash_ratio)
            pe_prof.Fill(slice, e.flash_ratio)

    # fill histograms for match score calculation from profile histograms
    for ib in list(range(0, profile_bins)):
        ibp = ib + 1
        dy_h1.SetBinContent(ibp, dy_prof.GetBinContent(ibp))
        dy_h1.SetBinError(ibp, dy_prof.GetBinError(ibp))
        dy_means[int(ib)] = dy_prof.GetBinContent(ibp)
        dy_spreads[int(ib)] = dy_prof.GetBinError(ibp)
        dz_h1.SetBinContent(ibp, dz_prof.GetBinContent(ibp))
        dz_h1.SetBinError(ibp, dz_prof.GetBinError(ibp))
        dz_means[int(ib)] = dz_prof.GetBinContent(ibp)
        dz_spreads[int(ib)] = dz_prof.GetBinError(ibp)
        rr_h1.SetBinContent(ibp, rr_prof.GetBinContent(ibp))
        rr_h1.SetBinError(ibp, rr_prof.GetBinError(ibp))
        rr_means[int(ib)] = rr_prof.GetBinContent(ibp)
        rr_spreads[int(ib)] = rr_prof.GetBinError(ibp)
        if detector == "sbnd":
            pe_h1.SetBinContent(ibp, pe_prof.GetBinContent(ibp))
            pe_h1.SetBinError(ibp, pe_prof.GetBinError(ibp))
            pe_means[int(ib)] = pe_prof.GetBinContent(ibp)
            pe_spreads[int(ib)] = pe_prof.GetBinError(ibp)

    for e in nuslice_tree:
        slice = e.charge_x
        # calculate match score
        isl = int(slice/bin_width)
        score = 0.
        if dy_spreads[isl] <= 1.e-8:
            print("Warning zero spread.\n",
                  f"slice: {slice}. isl: {isl}. dy_spreads[isl]: {dy_spreads[isl]} ")
            dy_spreads[isl] = dy_spreads[isl+1]
        if dz_spreads[isl] <= 1.e-8:
            print("Warning zero spread.\n",
                  f"slice: {slice}. isl: {isl}. dz_spreads[isl]: {dz_spreads[isl]} ")
            dz_spreads[isl] = dz_spreads[isl+1]
        if rr_spreads[isl] <= 1.e-8:
            print("Warning zero spread.\n",
                  f"slice: {slice}. isl: {isl}. rr_spreads[isl]: {rr_spreads[isl]} ")
            rr_spreads[isl] = rr_spreads[isl+1]
        if detector == "sbnd" and pe_spreads[isl] <= 1.e-8:
            print("Warning zero spread.\n",
                  f"slice: {slice}. isl: {isl}. pe_spreads[isl]: {pe_spreads[isl]} ")
            pe_spreads[isl] = pe_spreads[isl+1]
        score += abs(abs(e.flash_y-e.charge_y) - dy_means[isl])/dy_spreads[isl]
        score += abs(abs(e.flash_z-e.charge_z) - dz_means[isl])/dz_spreads[isl]
        score += abs(e.flash_r-rr_means[isl])/rr_spreads[isl]
        if detector == "sbnd" and pset.UseUncoatedPMT:
            score += abs(e.flash_ratio-pe_means[isl])/pe_spreads[isl]
        match_score_scatter.Fill(slice, score)
        match_score_hist.Fill(score)
    metrics_filename = 'fm_metrics_' + detector + '.root'
    hfile = gROOT.FindObject(metrics_filename)
    if hfile:
        hfile.Close()
    hfile = TFile(metrics_filename, 'RECREATE',
                  'Simple flash matching metrics for ' + detector.upper())
    dy_hist.Write()
    dy_prof.Write()
    dy_h1.Write()
    dz_hist.Write()
    dz_prof.Write()
    dz_h1.Write()
    rr_hist.Write()
    rr_prof.Write()
    rr_h1.Write()
    if detector == "sbnd":
        pe_hist.Write()
        pe_prof.Write()
        pe_h1.Write()
    match_score_scatter.Write()
    match_score_hist.Write()
    hfile.Close()

    canv = TCanvas("canv")

    dy_hist.Draw()
    crosses = TGraphErrors(n_bins,
                           array('f', xvals), array('f', dy_means),
                           array('f', xerrs), array('f', dy_spreads))
    crosses.SetLineColor(9)
    crosses.SetLineWidth(3)
    crosses.Draw("Psame")
    canv.Print("dy.pdf")
    canv.Update()

    dz_hist.Draw()
    crosses = TGraphErrors(n_bins,
                           array('f', xvals), array('f', dz_means),
                           array('f', xerrs), array('f', dz_spreads))
    crosses.SetLineColor(9)
    crosses.SetLineWidth(3)
    crosses.Draw("Psame")
    canv.Print("dz.pdf")
    canv.Update()

    rr_hist.Draw()
    crosses = TGraphErrors(n_bins,
                           array('f', xvals), array('f', rr_means),
                           array('f', xerrs), array('f', rr_spreads))
    crosses.SetLineColor(9)
    crosses.SetLineWidth(3)
    crosses.Draw("Psame")
    canv.Print("rr.pdf")
    canv.Update()

    if detector == "sbnd":
        pe_hist.Draw()
        crosses = TGraphErrors(n_bins,
                               array('f', xvals), array('f', pe_means),
                               array('f', xerrs), array('f', pe_spreads))
        crosses.SetLineColor(9)
        crosses.SetLineWidth(3)
        crosses.Draw("Psame")
        canv.Print("pe.pdf")
        canv.Update()

    match_score_scatter.Draw()
    canv.Print("match_score_scatter.pdf")
    canv.Update()

    match_score_hist.Draw()
    canv.Print("match_score.pdf")
    canv.Update()
    sleep(20)
コード例 #6
0
        inProf.append(hist)
   
    # Filling the old fashioned way...
    for irow in range(diff.shape[0]):
        for ivar in range(diff.shape[1]):
            diffHists[ivar].Fill(diff[irow][ivar])
            vsHists[ivar].Fill(target[irow][ivar],output[irow][ivar])
            diffProf[ivar].Fill(target[irow][ivar],diff[irow][ivar])
            inHists[ivar].Fill(inputs[irow][ivar],output[irow][ivar])
            inProf[ivar].Fill(inputs[irow][ivar],diff[irow][ivar])
            
    # Finally, write out these diffHists to a file
    histFile = args.model.replace('.tgz','.root')
    
    rootFile = TFile.Open(histFile,'RECREATE')
    rootFile.cd()
    for hist in diffHists:
        hist.Write()
    for hist in vsHists:
        hist.Write()
    for hist in diffProf:
        hist.Write()
    for hist in inHists:
        hist.Write()
    for hist in inProf:
        hist.Write()

    rootFile.Close()

    
コード例 #7
0
def main():
    parser = ArgumentParser(description='Scan over ROOT files to find the '+ \
                            'lumisections belonging to a specific run.')
    parser.add_argument('-b', action='store_true', help='enable batch mode')
    parser.add_argument('--dataset', required=True, choices=['PromptReco2015', \
                        'ReRecoOct2015', 'ReRecoDec2015', 'PromptReco2016', \
                        '2015ReRecoJan2017', '2016ReRecoJan2017'], \
                        help='specify data-taking period and reconstruction')
    parser.add_argument('-n', nargs=1, default=1, type=int, help='Specify '+ \
                        'the number of ZeroBias datasets to be included')
    parser.add_argument('-run', nargs=1, required=True, type=int, \
                        help='Specify the run number for the selection of '+ \
                        'the lumisections')
    parser.add_argument('-range', nargs=2, type=int, help='Specify a range '+ \
                        'in lumisections for the histogram')
    parser.add_argument('-X', dest='coords', action='append_const', \
                        const='vtx_x', help='look for vtx_x')
    parser.add_argument('-Y', dest='coords', action='append_const', \
                        const='vtx_y', help='look for vtx_y')
    parser.add_argument('-noscan', action='store_const', const=True, \
                        default=False, help='don\'t repeat the scan of the '+ \
                        'ROOT files, just do the plotting')
    parser.add_argument('-title', nargs=1, help='Specify a title for the '+ \
                        'histogram')
    args = parser.parse_args()

    from importlib import import_module
    from lsctools import config
    from lsctools.config import options as O, EOSPATH as eos
    from lsctools.tools import openRootFileU, closeRootFile, writeFiles, \
                               plotName, plotTitle, loadFiles, plotPath, \
                               drawSignature
    from lsctools.prepare import loopOverRootFiles
    from ROOT import TChain, TObject, TProfile, TCanvas, gStyle, gPad
    getattr(config, 'PCC' + args.dataset)()
    O['fulltrees'] = O['fulltrees'][:args.n]
    run = args.run[0]
    files = []
    if args.noscan:
        files = loadFiles('fulltrees_' + str(run))
    else:

        def action(tree, filename):
            condition = 'run == ' + str(run)
            if tree.GetEntries(condition) > 0:
                files.append(filename)
                print '<<< Found file:', filename

        loopOverRootFiles(action, 'fulltrees')
        writeFiles(files, 'fulltrees_' + str(run))
    chain = TChain(O['treename']['fulltrees'])
    for filename in files:
        chain.Add(eos + filename)
    name = 'vtxPos_perLS'
    title1 = 'run' + str(run) + '_perLS'
    title2 = 'Run ' + str(run)
    if (args.title):
        title2 = args.title[0] + ' (' + title2 + ')'
    f = openRootFileU(name)
    if args.range:
        mini = args.range[0]
        maxi = args.range[1]
        title1 += '_from' + str(mini) + 'to' + str(maxi)
    else:
        print '<<< Get minimum lumisection'
        mini = int(chain.GetMinimum('LS'))
        print '<<< Get maximum lumisection'
        maxi = int(chain.GetMaximum('LS'))
    for coord in args.coords:
        print '<<< Analyze coordinate', coord
        histname = plotName(coord + '_' + title1, timestamp=False)
        histtitl = plotTitle('- ' + title2)
        histfile = plotName(coord + '_' + title1)
        histpath = plotPath(coord + '_' + title1)
        hist = TProfile(histname, histtitl, maxi - mini + 1, mini - 0.5,
                        maxi + 0.5)
        chain.Draw(coord + '*1e4:LS>>' + histname, 'run == ' + str(run),
                   'goff')
        hist.Write('', TObject.kOverwrite)
        print '<<< Save plot:', histpath
        canvas = TCanvas()
        gStyle.SetOptStat(0)
        hist.Draw()
        hist.GetXaxis().SetTitle('LS')
        hist.GetYaxis().SetTitle(coord + ' [#mum]')
        hist.GetYaxis().SetTitleOffset(1.2)
        for axis in [hist.GetXaxis(), hist.GetYaxis()]:
            axis.SetTitleFont(133)
            axis.SetTitleSize(16)
            axis.SetLabelFont(133)
            axis.SetLabelSize(12)
            axis.CenterTitle()
        drawSignature(histfile)
        gPad.Modified()
        gPad.Update()
        canvas.Print(histpath)
        canvas.Close()
    closeRootFile(f, name)
コード例 #8
0
                    pr13.Fill(bcid, bcidTrigTAV1[bcid])
                    pr14.Fill(bcid, bcidTrigTAV2[bcid])
                    pr15.Fill(bcid, bcidTrigTAV3[bcid])
                    pr16.Fill(bcid, bcidTrigTAV4[bcid])
                    pr17.Fill(bcid, bcidTrigTAV5[bcid])

    itr.close()
except Exception, e:
    print "Reading data from", foldername, "failed:", e
db.closeDatabase()

fileName = "PerBcidMon_Run"
fileName += str(run)
fileName += ".root"
tfile = TFile(fileName, "recreate")
pr0.Write()
pr1.Write()
pr2.Write()
pr3.Write()
pr4.Write()
pr5.Write()
if doTrig:
    pr6.Write()
    pr7.Write()
    pr8.Write()
    pr9.Write()
    pr10.Write()
    pr11.Write()
    pr12.Write()
    pr13.Write()
    pr14.Write()
コード例 #9
0
ファイル: compare.py プロジェクト: whhopkins/FastSimNN
ax.SetTitle(nameX)
ay = h.GetYaxis()
ay.SetTitleOffset(0.8)
ay.SetTitle(nameY)
ax.SetTitleOffset(1.1)
ay.SetTitleOffset(1.4)
ax.Draw("same")
ay.Draw("same")

prof_eta.SetMarkerSize(1.1)
prof_eta.SetMarkerColor(1)
prof_eta.Draw("pe same")
prof_eta_nn.SetMarkerSize(1)
prof_eta_nn.SetMarkerColor(2)
prof_eta_nn.Draw("pe same")

out = "histo_" + outfile
hfile = TFile(out, "RECREATE", "DijetsMC")
c1.Write()
prof_eta.Write()
prof_pt.Write()

prof_eta_nn.Write()
prof_pt_nn.Write()
hfile.ls()
hfile.Close()
print "Write with cross sections written=", out

c1.Close()
rfile.Close()
コード例 #10
0
# Book histos
# we want to make 15 pt bins covering the range 20 - 500 (spacing of 480/15 = 32 GeV)
n_bins = 40
x_low = 0
x_high = 200

pt_prof = TProfile("ptprof", "profile of deltapt versus pt", n_bins, x_low,
                   x_high, 0, 1)

nevts = data_chain.GetEntries()
for i in range(nevts):
    data_chain.GetEntry(i)

    hlt_n_jets = data_chain.jet_num
    fj_n_jets = data_chain.fj_jet_num

    n_jets = min(hlt_n_jets, fj_n_jets)

    for j in range(n_jets):
        if data_chain.jet_pt[j] > 200:
            continue
        delta_pt = (data_chain.jet_pt[j] -
                    data_chain.fj_jet_pt[j]) / data_chain.jet_pt[j]
        pt_prof.Fill(data_chain.jet_pt[j], delta_pt)

# Write Histos
outfile.cd()
pt_prof.Write()
outfile.Close()