Beispiel #1
0
def plot(data_path, pt_title, ecms, xmin, xmax, xbins, mode):
    try:
        f_data = TFile(data_path)
        t_data = f_data.Get('save')
        entries_data = t_data.GetEntries()
        logging.info('data entries :'+str(entries_data))
    except:
        logging.error('File paths are invalid!')
        sys.exit()

    set_pub_style()
    set_prelim_style()
    mbc = TCanvas('mbc', 'mbc', 800, 600)
    content = (xmax - xmin)/xbins * 1000
    ytitle = 'Events/%.1f MeV/c^{2}'%content
    xtitle = 'M(K^{-}#pi_{d}^{+}#pi_{d}^{-}#pi^{+}) (GeV/c^{2})'
    h_Kpipipi1 = TH1F('Kpipipi1', 'Kpipipi1', xbins, xmin, float(xmax))
    format_data_hist(h_Kpipipi1)
    name_axis(h_Kpipipi1, xtitle, ytitle)
    m_Kpipipi_fill(t_data, h_Kpipipi1, 'Kpipipi1')
    
    h_Kpipipi2 = TH1F('Kpipipi2', 'Kpipipi2', xbins, xmin, float(xmax))
    format_data_hist(h_Kpipipi2)
    name_axis(h_Kpipipi2, xtitle, ytitle)
    m_Kpipipi_fill(t_data, h_Kpipipi2, 'Kpipipi2')
   
    h_data = TH1F('data', 'data', xbins, xmin, float(xmax))
    format_data_hist(h_data)
    name_axis(h_data, xtitle, ytitle)
    h_data.Add(h_Kpipipi1)
    h_data.Add(h_Kpipipi2)
    if mode == 'raw':
        ymax = 100
        h_data.GetYaxis().SetRangeUser(20, ymax)
    if mode == 'side_low':
        ymax = 100
        h_data.GetYaxis().SetRangeUser(0, ymax)
    if mode == 'side_up':
        ymax = 60
        h_data.GetYaxis().SetRangeUser(0, ymax)

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')
    
    h_data.Draw('E1')

    leg = TLegend(0.65, 0.65, 0.8, 0.8)
    set_legend(leg, h_data, 'Data', pt_title)
    leg.Draw()

    mbc.SaveAs('./figs/m_Kpipipi_'+str(ecms)+'_'+mode+'.pdf')

    raw_input('Enter anything to end...')
def plot(path, pt_title, ecms, xmin, xmax, xbins, ymax, mode):
    try:
        f_data = TFile(path[0])
        t_data = f_data.Get('save')
        entries_data = t_data.GetEntries()
        logging.info('data entries :' + str(entries_data))
    except:
        logging.error(path[0] + ' is invalid!')
        sys.exit()
    try:
        f_DDPIPI = TFile(path[1])
        t_DDPIPI = f_DDPIPI.Get('save')
        entries_DDPIPI = t_DDPIPI.GetEntries()
        logging.info('DDPIPI entries :' + str(entries_DDPIPI))
    except:
        logging.error(path[1] + ' is invalid!')
        sys.exit()
    try:
        f_DDPI = TFile(path[2])
        t_DDPI = f_DDPI.Get('save')
        entries_DDPI = t_DDPI.GetEntries()
        logging.info('DDPI entries :' + str(entries_DDPI))
    except:
        logging.error(path[2] + ' is invalid!')
        sys.exit()

    set_pub_style()
    set_prelim_style()
    mbc = TCanvas('mbc', 'mbc', 800, 600)
    content = (xmax - xmin) / xbins * 1000
    ytitle = 'Events/%.1f MeV/c^{2}' % content
    xtitle = 'RM(D^{+}#pi_{d}^{+}#pi_{d}^{-}) (GeV/c^{2})'

    h_data = TH1F('data', 'data', xbins, xmin, float(xmax))
    format_data_hist(h_data)
    name_axis(h_data, xtitle, ytitle)
    rm_Dpipi_fill(t_data, h_data)

    h_DDPIPI = TH1F('DDPIPI', 'DDPIPI', xbins, xmin, float(xmax))
    format_mc_hist(h_DDPIPI, 2)
    rm_Dpipi_fill(t_DDPIPI, h_DDPIPI)

    h_DDPI = TH1F('DDPI', 'DDPI', xbins, xmin, float(xmax))
    format_mc_hist(h_DDPI, 3)
    rm_Dpipi_fill(t_DDPI, h_DDPI)

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')

    F_DDPIPI = scale(ecms, 'DDPIPI')
    F_DDPI = scale(ecms, 'DDPI')
    h_DDPIPI.Scale(F_DDPIPI)
    h_DDPI.Scale(F_DDPI)
    h_data.GetYaxis().SetRangeUser(0, ymax)
    h_data.Draw('E1')
    hs = THStack('hs', 'Stacked')
    hs.Add(h_DDPIPI)
    hs.Add(h_DDPI)
    hs.Draw('same')
    h_data.Draw('sameE1')

    if ecms > 4320 and mode == 'before': legend = TLegend(0.2, 0.25, 0.5, 0.55)
    elif ecms > 4320 and mode == 'after':
        legend = TLegend(0.2, 0.22, 0.5, 0.52)
    elif ecms > 4320:
        legend = TLegend(0.2, 0.25, 0.5, 0.55)
    elif ecms < 4320:
        legend = TLegend(0.2, 0.2, 0.55, 0.4)
    set_legend(legend, h_data, h_DDPIPI, h_DDPI, pt_title, ecms)
    legend.Draw()

    mbc.SaveAs('./figs/rm_Dpipi_' + str(ecms) + '_raw_sideband_' + mode +
               '.pdf')

    raw_input('Enter anything to end...')
Beispiel #3
0
def plot(path, leg_title, ecms, xmin, xmax, xbins):
    try:
        f_data = TFile(path[0])
        t_data = f_data.Get('save')
        entries_data = t_data.GetEntries()
        logging.info('data entries :' + str(entries_data))
    except:
        logging.error(path[0] + 'is invalid!')
        sys.exit()
    try:
        f_side1 = TFile(path[1])
        t_side1 = f_side1.Get('save')
        entries_side1 = t_side1.GetEntries()
        logging.info('data(side1) entries :' + str(entries_side1))
    except:
        logging.error(path[1] + ' is invalid!')
        sys.exit()
    try:
        f_side2 = TFile(path[2])
        t_side2 = f_side2.Get('save')
        entries_side2 = t_side2.GetEntries()
        logging.info('data(side2) entries :' + str(entries_side2))
    except:
        logging.error(path[2] + ' is invalid!')
        sys.exit()
    try:
        f_side3 = TFile(path[3])
        t_side3 = f_side3.Get('save')
        entries_side3 = t_side3.GetEntries()
        logging.info('data(side3) entries :' + str(entries_side3))
    except:
        logging.error(path[3] + ' is invalid!')
        sys.exit()
    try:
        f_side4 = TFile(path[4])
        t_side4 = f_side4.Get('save')
        entries_side4 = t_side4.GetEntries()
        logging.info('data(side4) entries :' + str(entries_side4))
    except:
        logging.error(path[4] + ' is invalid!')
        sys.exit()

    set_pub_style()
    set_prelim_style()
    mbc = TCanvas('mbc', 'mbc', 800, 600)
    content = (xmax - xmin) / xbins
    ytitle = 'Eentries/%.2f' % content
    xtitle = 'L_{#pi_{d}^{+}#pi_{d}^{-}}/#Delta_{L_{#pi_{d}^{+}#pi_{d}^{-}}}'

    h_data = TH1F('data', 'data', xbins, xmin, xmax)
    format_data_hist(h_data)
    h_data.GetXaxis().SetTitleOffset(0.94)
    name_axis(h_data, xtitle, ytitle)
    L_Lerr_fill(t_data, h_data)

    h_side1 = TH1F('side1', 'side1', xbins, xmin, xmax)
    format_mc_hist(h_side1, 3)
    L_Lerr_fill(t_side1, h_side1)

    h_side2 = TH1F('side2', 'side2', xbins, xmin, xmax)
    format_mc_hist(h_side2, 3)
    L_Lerr_fill(t_side2, h_side2)

    h_side3 = TH1F('side3', 'side3', xbins, xmin, xmax)
    format_mc_hist(h_side3, 3)
    L_Lerr_fill(t_side3, h_side3)

    h_side4 = TH1F('side4', 'side4', xbins, xmin, xmax)
    format_mc_hist(h_side4, 3)
    L_Lerr_fill(t_side4, h_side4)

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')

    h_side1.Add(h_side2)
    h_side1.Scale(0.5)
    h_side3.Add(h_side4)
    h_side3.Scale(0.25)
    h_side1.Add(h_side3, -1)
    h_data.Draw('E1')
    hs = THStack('hs', 'Stacked')
    hs.Add(h_side1)
    hs.Draw('same')
    h_data.Draw('sameE1')

    legend = TLegend(0.55, 0.65, 0.75, 0.85)
    set_legend(legend, h_data, h_side1, leg_title)
    legend.Draw()

    mbc.SaveAs('./figs/L_Lerr_' + str(ecms) + '.pdf')

    raw_input('Enter anything to end...')
Beispiel #4
0
def plot(path, ecms, xmin, xmax):
    try:
        f_data = TFile(path[0])
        t_data = f_data.Get('save')
        entries_data = t_data.GetEntries()
        logging.info('data entries :'+str(entries_data))
    except:
        logging.error(path[0] + ' path is invalid!')
        sys.exit()
    try:
        f_side1 = TFile(path[1])
        t_side1 = f_side1.Get('save')
        entries_side1 = t_side1.GetEntries()
        logging.info('data(side1) entries :'+str(entries_side1))
    except:
        logging.error(path[1] + ' is invalid!')
        sys.exit()
    try:
        f_side2 = TFile(path[2])
        t_side2 = f_side2.Get('save')
        entries_side2 = t_side2.GetEntries()
        logging.info('data(side2) entries :'+str(entries_side2))
    except:
        logging.error(path[2] + ' is invalid!')
        sys.exit()
    try:
        f_side3 = TFile(path[3])
        t_side3 = f_side3.Get('save')
        entries_side3 = t_side3.GetEntries()
        logging.info('data(side3) entries :'+str(entries_side3))
    except:
        logging.error(path[3] + ' is invalid!')
        sys.exit()
    try:
        f_side4 = TFile(path[4])
        t_side4 = f_side4.Get('save')
        entries_side4 = t_side4.GetEntries()
        logging.info('data(side4) entries :'+str(entries_side4))
    except:
        logging.error(path[4] + ' is invalid!')
        sys.exit()

    set_pub_style()
    set_prelim_style()

    mbc = TCanvas('mbc', 'mbc', 800, 600)
    mbc.SetLogy()
    xbins = 140
    content = (xmax - xmin)/xbins
    ytitle = 'Eentries/%.2f (cm)'%content
    xtitle = '|V_{xy}| (cm)'

    h_data = TH1F('data', 'data', xbins, xmin, xmax)
    format_data_hist(h_data)
    name_axis(h_data, xtitle, ytitle)
    Vr_trks_fill(t_data, h_data)
    
    h_side1 = TH1F('side1', 'side1', xbins, xmin, xmax)
    format_mc_hist(h_side1, 3)
    Vr_trks_fill(t_side1, h_side1)
    
    h_side2 = TH1F('side2', 'side2', xbins, xmin, xmax)
    format_mc_hist(h_side2, 3)
    Vr_trks_fill(t_side2, h_side2)
    
    h_side3 = TH1F('side3', 'side3', xbins, xmin, xmax)
    format_mc_hist(h_side3, 3)
    Vr_trks_fill(t_side3, h_side3)
    
    h_side4 = TH1F('side4', 'side4', xbins, xmin, xmax)
    format_mc_hist(h_side4, 3)
    Vr_trks_fill(t_side4, h_side4)
    
    h_side1.Add(h_side2)
    h_side1.Scale(0.5)
    h_side3.Add(h_side4)
    h_side3.Scale(0.25)
    h_side1.Add(h_side3, -1)
    h_data.Draw('E1')
    hs = THStack('hs', 'Stacked')
    hs.Add(h_side1)
    hs.Draw('same')
    h_data.Draw('sameE1')

    legend = TLegend(0.55, 0.6, 0.8, 0.85)
    if ecms == 4230: leg_title = '(a)'
    if ecms == 4420: leg_title = '(c)'
    if ecms == 4680: leg_title = '(e)'
    set_legend(legend, h_data, h_side1, leg_title)
    legend.Draw()

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')
    
    mbc.SaveAs('./figs/Vxy_trks_'+str(ecms)+'.pdf')

    raw_input('Enter anything to end...')
Beispiel #5
0
def plot(data_path, pt_title, ecms, xmin, xmax, xbins, mode):
    try:
        f_data = TFile(data_path)
        t_data = f_data.Get('save')
        entries_data = t_data.GetEntries()
        logging.info('data entries :' + str(entries_data))
    except:
        logging.error('File paths are invalid!')
        sys.exit()

    set_pub_style()
    set_prelim_style()

    window_low = 1.86965 - window(ecms) / 2.
    window_up = 1.86965 + window(ecms) / 2.
    window_side_low_up = window_low - (window_up - window_low)
    window_side_low_low = window_side_low_up - (window_up - window_low)
    window_side_up_low = window_up + (window_up - window_low)
    window_side_up_up = window_side_up_low + (window_up - window_low)

    mbc = TCanvas('mbc', 'mbc', 800, 600)
    content = (xmax - xmin) / xbins * 1000
    ytitle = 'Events/%.1f MeV/c^{2}' % content
    xtitle = 'RM(D^{+}#pi_{d}^{+}#pi_{d}^{-}) (GeV/c^{2})'
    h_data = TH1F('data', 'data', xbins, xmin, float(xmax))

    format_data_hist(h_data)
    if ecms == 4420 or ecms == 4680:
        h_data.GetYaxis().SetTitleOffset(1.15)
    h_data.GetXaxis().SetTitleOffset(0.99)
    name_axis(h_data, xtitle, ytitle)
    rm_Dpipi_fill(t_data, h_data, window_low, window_up)

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')

    if mode == 'after' and ecms == 4230:
        h_data.GetYaxis().SetRangeUser(0, 1.2 * h_data.GetMaximum())
    h_data.Draw('E1')

    if ecms == 4420 and mode == 'before': low = 380
    elif ecms == 4420 and mode == 'after': low = 240
    elif ecms == 4230 and mode == 'before': low = 14
    elif ecms == 4230 and mode == 'after': low = 0
    elif ecms == 4680 and mode == 'before': low = 950
    elif ecms == 4680 and mode == 'after': low = 620
    else: low = 0
    top = h_data.GetMaximum()
    if ecms == 4680: top = top / 0.88

    arrow1 = TArrow(window_low, low, window_low, 0.8 * top, 0.02, '<-')
    set_arrow(arrow1, ROOT.kRed)
    arrow1.SetLineStyle(2)
    arrow1.Draw()

    arrow2 = TArrow(window_up, low, window_up, 0.8 * top, 0.02, '<-')
    set_arrow(arrow2, ROOT.kRed)
    arrow2.SetLineStyle(2)
    arrow2.Draw()

    arrow3 = TArrow(window_side_low_low, low, window_side_low_low, 0.8 * top,
                    0.02, '<-')
    set_arrow(arrow3, ROOT.kBlue)
    arrow3.Draw()

    arrow4 = TArrow(window_side_low_up, low, window_side_low_up, 0.8 * top,
                    0.02, '<-')
    set_arrow(arrow4, ROOT.kBlue)
    arrow4.Draw()

    arrow5 = TArrow(window_side_up_low, low, window_side_up_low, 0.8 * top,
                    0.02, '<-')
    set_arrow(arrow5, ROOT.kBlue)
    arrow5.Draw()

    arrow6 = TArrow(window_side_up_up, low, window_side_up_up, 0.8 * top, 0.02,
                    '<-')
    set_arrow(arrow6, ROOT.kBlue)
    arrow6.Draw()

    leg = TLegend(position_convert(0.8 * (xmax - xmin) + xmin, xmin, xmax),
                  position_convert(0.8 * (top - low) + low, low, top),
                  position_convert(0.95 * (xmax - xmin) + xmin, xmin, xmax),
                  position_convert((top - low) + low, low, top), 'BRNDC')
    set_legend(leg, h_data, 'Data', pt_title)
    leg.Draw()

    h_data.Draw('sameE1')
    mbc.SaveAs('./figs/rm_Dpipi_' + str(ecms) + '_' + mode + '.pdf')

    raw_input('Enter anything to end...')
Beispiel #6
0
def plot(path, ecms, xmin, xmax, mode):
    try:
        f_data = TFile(path[0])
        t_data = f_data.Get('save')
        entries_data = t_data.GetEntries()
        logging.info('data entries :' + str(entries_data))
    except:
        logging.error(path[0] + ' path is invalid!')
        sys.exit()
    try:
        f_side1 = TFile(path[1])
        t_side1 = f_side1.Get('save')
        entries_side1 = t_side1.GetEntries()
        logging.info('data(side1) entries :' + str(entries_side1))
    except:
        logging.error(path[1] + ' is invalid!')
        sys.exit()
    try:
        f_side2 = TFile(path[2])
        t_side2 = f_side2.Get('save')
        entries_side2 = t_side2.GetEntries()
        logging.info('data(side2) entries :' + str(entries_side2))
    except:
        logging.error(path[2] + ' is invalid!')
        sys.exit()
    try:
        f_side3 = TFile(path[3])
        t_side3 = f_side3.Get('save')
        entries_side3 = t_side3.GetEntries()
        logging.info('data(side3) entries :' + str(entries_side3))
    except:
        logging.error(path[3] + ' is invalid!')
        sys.exit()
    try:
        f_side4 = TFile(path[4])
        t_side4 = f_side4.Get('save')
        entries_side4 = t_side4.GetEntries()
        logging.info('data(side4) entries :' + str(entries_side4))
    except:
        logging.error(path[4] + ' is invalid!')
        sys.exit()

    set_pub_style()
    set_prelim_style()

    mbc = TCanvas('mbc', 'mbc', 800, 600)
    xbins = 100
    content = int((xmax - xmin) / xbins * 1000)
    ytitle = 'Eentries/%.1f MeV/c^{2}' % content
    xtitle = 'M(#pi_{d}^{+}#pi_{d}^{-}) (GeV/c^{2})'
    h_data = TH1F('data', 'data', xbins, xmin, xmax)
    format_data_hist(h_data)
    name_axis(h_data, xtitle, ytitle)
    m_pipi_fill(t_data, h_data, mode)

    h_side1 = TH1F('side1', 'side1', xbins, xmin, xmax)
    format_mc_hist(h_side1, 3)
    m_pipi_fill(t_side1, h_side1, mode)

    h_side2 = TH1F('side2', 'side2', xbins, xmin, xmax)
    format_mc_hist(h_side2, 3)
    m_pipi_fill(t_side2, h_side2, mode)

    h_side3 = TH1F('side3', 'side3', xbins, xmin, xmax)
    format_mc_hist(h_side3, 3)
    m_pipi_fill(t_side3, h_side3, mode)

    h_side4 = TH1F('side4', 'side4', xbins, xmin, xmax)
    format_mc_hist(h_side4, 3)
    m_pipi_fill(t_side4, h_side4, mode)

    h_side1.Add(h_side2)
    h_side1.Scale(0.5)
    h_side3.Add(h_side4)
    h_side3.Scale(0.25)
    h_side1.Add(h_side3, -1)
    h_data.Draw('E1')
    hs = THStack('hs', 'Stacked')
    hs.Add(h_side1)
    hs.Draw('same')
    h_data.Draw('sameE1')

    legend = TLegend(0.55, 0.65, 0.75, 0.85)
    if mode == 'before': leg_title = '(a)'
    if mode == 'after': leg_title = '(c)'
    set_legend(legend, h_data, h_side1, leg_title)
    legend.Draw()

    if not os.path.exists('./figs/'):
        os.makedirs('./figs/')

    mbc.SaveAs('./figs/m_pipi_' + str(ecms) + '_' + mode + '.pdf')

    raw_input('Enter anything to end...')