def plotMassSpectrum(mJJ_pass,
                     mJJ_rej,
                     binning,
                     SM_eff,
                     title='',
                     fig_dir=None):

    h_a = create_TH1D(mJJ_pass,
                      name='h_acc',
                      title='Accepted',
                      binning=binning,
                      opt='overflow')
    bin_edges = [
        h_a.GetXaxis().GetBinLowEdge(i) for i in range(1,
                                                       h_a.GetNbinsX() + 2)
    ]
    h_a.SetLineColor(2)
    h_a.SetStats(0)
    h_a.Sumw2()

    h_r = create_TH1D(mJJ_rej,
                      name='h_rej',
                      title='Rejected',
                      axis_title=['M_{jj} [GeV]', 'Events'],
                      binning=binning,
                      opt='overflow')
    bin_edges = [
        h_a.GetXaxis().GetBinLowEdge(i) for i in range(1,
                                                       h_a.GetNbinsX() + 2)
    ]

    h_r.GetYaxis().SetRangeUser(0.5, 1.2 * h_r.GetMaximum())
    h_r.SetStats(0)
    h_r.Sumw2()

    c = make_effiency_plot([h_r, h_a],
                           ratio_bounds=[1e-4, 0.2],
                           draw_opt='E',
                           title=title)

    c.pad1.SetLogy()
    c.pad2.SetLogy()

    c.pad2.cd()
    c.ln = rt.TLine(h_r.GetXaxis().GetXmin(), SM_eff,
                    h_r.GetXaxis().GetXmax(), SM_eff)
    c.ln.SetLineWidth(2)
    c.ln.SetLineStyle(7)
    c.ln.SetLineColor(8)
    c.ln.DrawLine(h_r.GetXaxis().GetXmin(), SM_eff,
                  h_r.GetXaxis().GetXmax(), SM_eff)

    c.Draw()

    return c
Example #2
0
    h_pt[label] = create_TH2D(
        arr_pt_vtxpt,
        'h_pt_' + name,
        'SM particle generated tracks, HardQCD #hat{p}_{T} ' + label + ' GeV',
        binning=binning_pt,
        axis_title=['reco vtx sum p_{T} [GeV]', 'reco p_{T} [GeV]'])

    sel = np.logical_and(tree[label]['vtx_SumPT'] > min_vtx_pt,
                         tree[label]['pt'] > min_trk_pt)
    sel = np.logical_and(sel, tree[label]['M_reco'] > mass_lower_bound)
    arr_mass = tree[label]['M_reco'][sel]
    h_mass[label] = create_TH1D(
        arr_mass,
        'h_mass_' + name,
        'Mass spectrum of HardQCD #hat{p}_{T} ' + label + ' GeV',
        binning=binning_mass,
        axis_title=[
            'Mass reco [GeV]',
            'Events / {} GeV'.format(binning_mass[2] / binning_mass[0])
        ])

    c_pt.cd(2 * i + 1)
    h_pt[label].Draw('colz')
    sel_line.DrawLine(min_vtx_pt, min_trk_pt, min_vtx_pt, binning_pt[5])
    sel_line.DrawLine(min_vtx_pt, min_trk_pt, binning_pt[2], min_trk_pt)

    c_pt.cd(2 * i + 2)
    h_mass[label].Draw('E1')

    if h_mass[label].GetEntries() > 10:
        r = h_mass[label].Fit('expo', 'ILQRS', '', mass_lower_bound,
Example #3
0
                       axis_title=['p_{T}^{H} [GeV]', 'm_{H}/m_{L} - 1'])

    kin_sel = np.logical_and(
        np.abs(t['pth']) >= min_trk_pt,
        np.abs(t['vtx_SumPT']) >= min_vtx_pt)
    kin_sel = np.logical_and(kin_sel, t['ml'] > 0)
    kin_sel = np.logical_and(kin_sel, dm < max_dm)
    kin_sel = np.logical_and(kin_sel,
                             (t['mh'] + t['ml']) / 2. > mass_lower_bound)

    arr_mh = (t['mh'][kin_sel] + t['ml'][kin_sel]) / 2.
    h_mass[label] = create_TH1D(
        arr_mh,
        'h_mass_' + name,
        name,
        binning=binning_mass,
        axis_title=[
            '(m_{{H}} + m_{{L}})/2 [GeV]', 'Events / {:.1} GeV'.format(
                float(binning_mass[2] - binning_mass[1]) / binning_mass[0])
        ])
    '''  ------------------ Drawing --------------- '''
    line = rt.TLine()
    line.SetLineColor(2)
    line.SetLineWidth(2)
    line.SetLineStyle(7)

    c_summary.cd(3 * i + 1)
    h_vtx.DrawCopy('colz')
    # rt.gPad.SetLogy()
    line.DrawLine(min_vtx_pt, binning_vtx[4], min_vtx_pt, max_dm)
    line.DrawLine(min_vtx_pt, max_dm, binning_vtx[2], max_dm)
#
#
binning = [40, 0, 400]
axis_title = [
    'M_{reco} [GeV]', '# Events / {:.0f} GeV [a.u.]'.format(
        (binning[2] - binning[1]) / binning[0])
]
h_mass = {}
for i, k in enumerate(h_pt.keys()):
    kin_sel = np.logical_and(
        np.abs(tree[k]['pt']) >= min_trk_pt,
        np.abs(tree[k]['vtx_SumPT']) >= min_vtx_pt)
    aux = tree[k]['M_reco'][kin_sel]
    h_mass[k] = create_TH1D(aux,
                            'h_mass_' + k,
                            k,
                            binning=binning,
                            axis_title=axis_title)
    h_mass[k].SetLineColor(2 + 2 * i)
    h_mass[k].SetLineWidth(2)
#
#     aux = t['M_reco'][np.logical_and(np.logical_not(bsm_sel), kin_sel)]
#     h_mass_sm = create_TH1D(aux, 'h_m_sm_'+name, 'SM',binning=binning, axis_title=axis_title)
#     h_mass_sm.SetLineColor(4)
#     h_mass_sm.SetLineWidth(2)
#
# h_m_stack = rt.THStack('h_stack_m_'+name, 'Stack distribution of reco Mass')
#     if h_mass_sm.GetEntries()>h_mass_bsm.GetEntries():
#         h_m_stack.Add(h_mass_bsm)
#         h_m_stack.Add(h_mass_sm)
#     else:
Example #5
0
    if data_train.shape[0] > maxEvts:
        break

N_evts = i_file + 1 * 10000
QCD_xsec = 8.73e-6  #mb
QCD_xsec *= 1e9  #fb
print('\nLuminosity used for training')
print('{:.2} fb^-1'.format(N_evts / QCD_xsec))

# In[4]:

c = create_Canvas(size=(int(800 / 1.5), int(600 / 1.5)))
h_Mjj_side = create_TH1D(
    data_train[:, 0],
    title='',
    axis_title=['M_{jj} [GeV]', 'Events'],
    binning=[100, Mjj_selection, 0.8 * np.max(data_train[:, 0])])

h_Mjj_side.Draw()
c.SetLogy()
c.Draw()

# ### Quantile regression

# In[5]:


def quantile_loss(target, pred):
    alpha = 1 - SM_eff
    err = target - pred
Example #6
0
                       binning=binning_pt,
                       axis_title=['p_{T}^{H} [GeV]', 'm_{H}/m_{L} - 1'])

    kin_sel = np.logical_and(
        np.abs(t['pth']) >= min_trk_pt,
        np.abs(t['vtx_SumPT']) >= min_vtx_pt)
    kin_sel = np.logical_and(kin_sel, t['ml'] > 0)
    kin_sel = np.logical_and(kin_sel, dm < max_dm)

    binning_mass = [50, stopmass / 2., stopmass * 2.]
    arr_mh = (t['mh'][kin_sel] + t['ml'][kin_sel]) / 2.
    h_mass = create_TH1D(
        arr_mh,
        'h_mass_' + name,
        name,
        binning=binning_mass,
        axis_title=[
            '(m_{{H}} + m_{{L}})/2 [GeV]', 'Events / {:.1} GeV'.format(
                float(binning_mass[2] - binning_mass[1]) / binning_mass[0])
        ])
    # ---- Fit the mass distribution -----------
    '''
    [0] = Norm
    [1] = aL
    [2] = aR
    [3] = mu
    [4] = sigma
    '''
    t_str = '((x-[3])/[4])'
    left_fun = '(TMath::Sign(0.5,-{}-[1])+0.5)*exp(0.5*[1]*[1])*exp([1]*{})'.format(
        t_str, t_str)
cebefo_style()

file_list = glob('_root/gg2Rhad_PU*_tks_flat.root')
color = [1, 2, 4, 8]
c_out = rt.TCanvas('c_Tin', 'c_Tin', 800, 600)
histo_list = []
leg = rt.TLegend(0.2, 0.3)
for i, fname in enumerate(file_list):
    print fname
    res = re.search('PU[0-9]+', fname)
    PU = int(res.group(0)[2:])
    particles = rtnp.root2array(fname)

    h = create_TH1D(particles['error_Tin'],
                    name='ht{}'.format(i),
                    title='Inner time resolution for different PU',
                    binning=[151, -100, 100])
    h.SetMarkerColor(color[i])
    h.SetMarkerStyle(24)
    h.SetMarkerSize(0.5)
    h.SetLineColor(color[i])
    h.Scale(1. / h.Integral())
    h.SetStats(0)
    h.SetXTitle('T_{in}^{MC}-T_{in}^{reco} [ps]')
    h.Draw('sames')
    leg.AddEntry(h.GetName(), 'PU {}, std = {:.1f}'.format(PU, h.GetRMS()),
                 'lep')

    histo_list.append(h)

c_out.SetLogy()
h = {}
leg = rt.TLegend(0.8, .82, 0.5, 0.92)
leg.SetTextSize(0.022)
leg.SetBorderSize(0)
leg.SetTextFont(42)

for i, k in enumerate(tree.keys()):
    #     print(sel_rechitcluster2[k], 'sel', len(sel_rechitcluster2[k]), 'len')
    #     print(gLLP_eta[k], 'eta', len(gLLP_eta[k]), 'eln')
    #     print(len(cscRechitClusterEta[k]), 'eta')
    #     print(len(cscRechitClusterPhi[k]), 'phi')
    #print(Bigger(sel_rechitcluster2[k].flatten(), gLLP_eta[k]))
    #     print(len(sel_rechitcluster2[k]))
    #     print(len(gLLP_eta[k]))
    hm = create_TH1D(sel_rechitcluster2[k].flatten(),
                     axis_title=['Number of Rechits', 'Signal Efficiency'],
                     name='hey',
                     binning=[30, 0, 2.5])
    hb = create_TH1D((gLLP_eta[k]).flatten(),
                     axis_title=['Number of Rechits', 'Signal Efficiency'],
                     name='hey',
                     binning=[30, 0, 2.5])
    pEff1 = rt.TEfficiency(hm, hb)
    pEff1.Draw()

leg.Draw()
#c.SetLogx()
c.Draw()
c.SaveAs()

# In[ ]:
    c_pt.cd(2)
    h_SM.Draw('colz')
    line.DrawLine(min_vtx_pt, min_trk_pt, min_vtx_pt, binning[5])
    line.DrawLine(min_vtx_pt, min_trk_pt, binning[2], min_trk_pt)

    binning = [130, 0, stopmass * 2.2]
    axis_title = [
        'M_{reco} [GeV]', '# Events / {:.0f} GeV [a.u.]'.format(
            (binning[2] - binning[1]) / binning[0])
    ]

    aux = t['M_reco'][np.logical_and(bsm_sel, kin_sel)]
    h_mass_bsm = create_TH1D(aux,
                             'h_m_bsm_' + name,
                             'BSM',
                             binning=binning,
                             axis_title=axis_title)
    h_mass_bsm.SetLineColor(2)
    h_mass_bsm.SetLineWidth(2)

    aux = t['M_reco'][np.logical_and(np.logical_not(bsm_sel), kin_sel)]
    h_mass_sm = create_TH1D(aux,
                            'h_m_sm_' + name,
                            'SM',
                            binning=binning,
                            axis_title=axis_title)
    h_mass_sm.SetLineColor(4)
    h_mass_sm.SetLineWidth(2)

    h_m_stack = rt.THStack('h_stack_m_' + name,