Пример #1
0
def makeChain(samplesPath, singleFile=False):
    plotfactory.setpfstyle()
    chain = ROOT.TChain('tree')

    all_files = glob.glob(samplesPath + '*/HNLTreeProducer*/tree.root')
    nfiles = len(all_files)

    if singleFile == False:
        for file in all_files:
            chain.Add(file)

    elif singleFile == True:
        chain.Add(
            '/Users/dehuazhu/SynologyDrive/PhD/5_Projects/analysis/200114_AcceptancePlots/signals_2018/HN3L_M_2_V_0p0307896086367_mu_Dirac_cc_massiveAndCKM_LO/HNLTreeProducer_mmm/tree.root'
        )

    return chain, nfiles
Пример #2
0
#################
# Configuration #
#################
import ROOT
import numpy as np
import plotfactory as pf
from glob import glob

pf.setpfstyle()
bewl = input("Makechain: True or False\n")
tt = pf.makechain(bewl)

#file = ROOT.TFile('tree.root')
#tt = file.Get('tree')
ntries = tt.GetEntries()

print('Number of entries: ' + str(ntries))

#################
# Define x-axes #
#################
pTbins = np.arange(5., 73, 5)

###################
# Create canvases #
###################
print('Preparing canvas')
t = ROOT.TCanvas('t', 'bar_d2')

#####################
# Create histograms #
Пример #3
0
    plotfactory.showlumi('N#rightarrow%s;  59.7 fb^{-1}  (13 TeV)' % (ch))
    can.Update()

    if not os.path.isdir(output_dir + 'pdf'): os.mkdir(output_dir + 'pdf')
    if not os.path.isdir(output_dir + 'png'): os.mkdir(output_dir + 'png')
    if not os.path.isdir(output_dir + 'root'): os.mkdir(output_dir + 'root')

    can.SaveAs(output_dir + 'pdf/%s.pdf' % (ch))
    can.SaveAs(output_dir + 'png/%s.png' % (ch))
    can.SaveAs(output_dir + 'root/%s.root' % (ch))


if __name__ == '__main__':
    print('starting draw_limits.py...')

    plotfactory.setpfstyle()

    channel = 'mmm'
    # channel = 'mem_OS'
    # channel = 'mem_SS'
    # channel = 'eee'
    # channel = 'eem_OS'
    # channel = 'eem_SS'

    #2017
    # base_dir   = '/work/dezhu/3_figures/2_Limits/2017/mmm/20191119_limits'

    #2018
    # base_dir   = '/work/dezhu/3_figures/2_Limits/2018/%s/20191120_Aachen'%channel
    # base_dir   = '/work/dezhu/3_figures/2_Limits/2018/%s/20191121_RiccardoDatacards'%channel
    base_dir = '/work/dezhu/3_figures/2_Limits/2018/%s/20191125_SignalReweight' % channel
Пример #4
0
def makeFakeRatePlot(varName):
    tt = makechain()
    dataframe = ROOT.RDataFrame(tt)
    plotfactory.setpfstyle()
    can = ROOT.TCanvas('c1', 'c1')

    print('running variable %s' % varName)

    if varName == 'l1_pt':
        binsx = np.array([0., 5., 10., 15., 20., 30., 50., 70.])  # for pt
    if varName == 'abs_l1_eta': binsx = np.arange(0., 2.5, 0.4)
    if varName == 'abs_l1_dxy': binsx = np.logspace(-1.9, -1.4, 5)
    if varName == 'abs_l1_dz': binsx = np.logspace(-1.8, -0.5, 10)
    if varName == 'hnl_2d_disp': binsx = np.logspace(-0.7, 0.4, 5)
    if varName == 'hnl_dr_12': binsx = np.logspace(-1.3, -0.4, 9)
    if varName == 'hnl_m_12': binsx = np.arange(1., 4., 0.5)
    if varName == 'sv_prob': binsx = np.arange(0., 1.0, 0.1)
    if varName == 'hnl_w_vis_m': binsx = np.arange(0., 200.0, 30)
    # if varName == 'sv_prob':        binsx = np.logspace(-1.6,   0.,    5)
    # binsx = np.logspace(-7,2,40)
    # binsx = np.arange(0.,200.,10.)

    MeasurementRegion = Selections.Region('cr', 'mmm', 'CustomRegion')

    ht = dataframe\
        .Define('abs_l1_eta','abs(l1_eta)')\
        .Define('abs_l1_dxy','abs(l1_dxy)')\
        .Define('abs_l1_dz','abs(l1_dz)')\
        .Filter(MeasurementRegion.data)\
        .Histo1D(('','',len(binsx)-1,binsx),'%s'%varName)

    hl = dataframe\
        .Define('abs_l1_eta','abs(l1_eta)')\
        .Define('abs_l1_dxy','abs(l1_dxy)')\
        .Define('abs_l1_dz','abs(l1_dz)')\
        .Filter(MeasurementRegion.baseline)\
        .Histo1D(('','',len(binsx)-1,binsx),'%s'%varName)

    hist_tight = ht.Clone()
    hist_loose = hl.Clone()

    if varName == 'l1_pt': hist_tight.SetTitle(';lepton p_{T} (GeV); fakerate')
    if varName == 'abs_l1_eta': hist_tight.SetTitle(';lepton #eta; fakerate')
    if varName == 'abs_l1_dxy':
        hist_tight.SetTitle(';lepton impact parameter d_{xy} (cm); fakerate')
    if varName == 'abs_l1_dz':
        hist_tight.SetTitle(';lepton impact parameter d_{z} (cm); fakerate')
    if varName == 'hnl_2d_disp':
        hist_tight.SetTitle('; 2D displacement (cm); fakerate')
    if varName == 'hnl_dr_12': hist_tight.SetTitle('; #Delta R_{12}; fakerate')
    if varName == 'hnl_m_12':
        hist_tight.SetTitle('; dilepton invariant mass m_{12} (GeV); fakerate')
    if varName == 'sv_prob':
        hist_tight.SetTitle('; dilepton vertex quality; fakerate')
    if varName == 'hnl_w_vis_m':
        hist_tight.SetTitle('; Tri-Lepton Mass (GeV); fakerate')

    hist_tight.Divide(hist_loose)

    hist_tight.SetMarkerColor(ROOT.kBlue + 2)
    hist_tight.SetLineColor(ROOT.kBlue + 2)
    hist_tight.GetYaxis().SetRangeUser(0., 0.40)
    hist_tight.Draw()

    if varName == 'hnl_2d_disp': can.SetLogx()
    if varName == 'hnl_dr_12': can.SetLogx()
    if varName == 'abs_l1_dz': can.SetLogx()
    # if varName == 'sv_prob': can.SetLogx()
    # can.SetLogy()

    plotfactory.showlumi('59.7 fb^{-1} (13 TeV)')
    plotfactory.showlogopreliminary()

    can.Update()
    plotName = 'fr_%s' % varName
    for datatype in ['pdf', 'png', 'tex', 'root']:
        can.SaveAs('fakerateplots/%s/%s.%s' % (datatype, plotName, datatype))

    for histogram in [ht, hl, hist_tight, hist_loose]:
        histogram.Reset()