Example #1
0
    def __init__(self, indir="./METSkim_v1", outdir='./output/stacker/',
                 channel='inclusive',  whichregion='SR', zpt_cut='100', met_cut= '100',  lumi = 2.318278305,  
                 sepSig=True, LogY=True, doRatio=True, addSig=True, addData=True, scaleDphi=False, onlyStats=False):
        self.outdir=outdir
        self.channel=channel
        self.whichregion=whichregion
        self.zpt_cut, self.met_cut = zpt_cut, met_cut
        self.lumi=lumi
        CheckDir(self.outdir) # if not, this will create it
        #channel='inclusive'#raw_input("Please choose a channel (el or mu): \n")
        self.tag0='ZJstudy'
                
        self.plotter_dd = InitializePlotter(indir=indir, addSig=addSig, addData=addData, doRatio=doRatio, scaleDphi=scaleDphi, onlyStats=onlyStats)

        self.plotter = InitializePlotter(indir=indir, addSig=addSig, addData=addData, doRatio=doRatio, onlyStats=onlyStats)
        self.plotter.Stack.rmPlotter(self.plotter.ZJets, "ZJets","Z+Jets", "background")
        
        setcuts = SetCuts()
        self.cuts_eld = setcuts.abcdCuts(channel=self.channel, whichRegion=whichregion, zpt_cut=zpt_cut, met_cut=met_cut)
        zjcuts = setcuts.GetZjetsCuts(whichRegion=whichregion, zpt_cut=zpt_cut, met_cut=met_cut)
        self.cuts = zjcuts[self.channel]
        
        # self.fabsDphi={'A': "fabs(llnunu_deltaPhi)",
        #                'B': "fabs(llnunu_deltaPhi)+TMath::Pi()/4",
        #                'C': "fabs(llnunu_deltaPhi)+TMath::Pi()/2",
        #                'D': "fabs(llnunu_deltaPhi)+TMath::Pi()*3/4"}
        self.fabsDphi="fabs(llnunu_deltaPhi)"
        
        # et1="TMath::Sqrt(llnunu_l1_pt*llnunu_l1_pt+llnunu_l1_mass*llnunu_l1_mass)"
        # et2="TMath::Sqrt(llnunu_l2_pt*llnunu_l2_pt+llnunu_l1_mass*llnunu_l1_mass)"
        # newMtB='TMath::Sqrt(2.0*(llnunu_l1_mass*llnunu_l1_mass+'+et1+'*'+et2+'-llnunu_l1_pt*llnunu_l2_pt*cos('+self.fabsDphi['B']+')))'
        # newMtC='TMath::Sqrt(2.0*(llnunu_l1_mass*llnunu_l1_mass+'+et1+'*'+et2+'-llnunu_l1_pt*llnunu_l2_pt*cos('+self.fabsDphi['C']+')))'
        # newMtD='TMath::Sqrt(2.0*(llnunu_l1_mass*llnunu_l1_mass+'+et1+'*'+et2+'-llnunu_l1_pt*llnunu_l2_pt*cos('+self.fabsDphi['D']+')))'
        # self.Mt={'A':'llnunu_mt',
        #          'B':newMtB,
        #          'C':newMtC,
        #          'D':newMtD}
        self.Mt='llnunu_mt'
        
        self.mtxbins=[150,200,250,300,350,400,450,550,850]
        self.mtnbins, self.mtxmin, self.mtxmax= len(self.mtxbins), min(self.mtxbins), max(self.mtxbins)#14, 150.0, 850.0
                        
        
        ROOT.gROOT.ProcessLine('.x ../src/tdrstyle.C')
        ROOT.gStyle.SetPadBottomMargin(0.2)
        ROOT.gStyle.SetPadLeftMargin(0.15)
Example #2
0
 def __init__(self, indir="./nonResSkim_v3.0", outdir='stack_test',
              lumi = 2.318278305,  sepSig=True,
              LogY=True,   doRatio=True,
              addSig=True, addData=True):
     if not os.path.exists(outdir): os.system('mkdir '+outdir)
     self.logy=LogY
     self.outdir = outdir
     self.lumi = lumi
     self.plotter_eu=InitializePlotter(indir, addSig=False, addData=True, doRatio=doRatio, doElMu=True, LogY=LogY)
     self.plotter_ll=InitializePlotter(indir, addSig=addSig, addData=True, doRatio=doRatio, LogY=LogY)
     self.plotter_ll.Stack.rmPlotter(self.plotter_ll.TT, "TT","TT", "background")
     self.plotter_ll.Stack.rmPlotter(self.plotter_ll.WW, "WW","WW, WZ non-reson.", "background")
     self.plotter_ll.Stack.rmPlotter(self.plotter_ll.WJets, "WJets","W+Jets", "background")
     
     self.setcuts=SetCuts()
     ROOT.gROOT.ProcessLine('.x ../src/tdrstyle.C')
     self.zpt_cut, self.met_cut= '100', '0'
     self.cuts=self.setcuts.GetAlphaCuts(zpt_cut=self.zpt_cut, met_cut=self.met_cut)
Example #3
0
var = "fabs(llnunu_deltaPhi)"

doSub = True
whichdt = 'dt_sub' if doSub else 'dt'
whichbcd = 'zjets' if doSub else 'allmc'

tag = tag0 + '_' + 'printer'
outTag = outdir + '/' + tag

CheckDir(outdir)
outtxt = open(outdir + '/num_out.txt', 'a')

### ----- Initialize (samples):
plotter = InitializePlotter(indir=indir)

setcuts = SetCuts()
#cuts=setcuts.abcdCuts(channel=channel, whichRegion=whichregion, zpt_cut=zpt_cut, met_cut=met_cut)
#preselect=setcuts.abcdCuts(channel=channel, whichRegion=whichregion, zpt_cut=zpt_cut, met_cut=met_cut,isPreSelect=True)
zjcuts = setcuts.GetZjetsCuts(whichRegion=whichregion,
                              zpt_cut=zpt_cut,
                              met_cut=met_cut)
cuts = zjcuts[channel]

outtxt.write('\n' + '*' * 20 + '\n')
outtxt.write('\n' + whichregion + '\n')
for reg in cuts:
    outtxt.write(reg + " " + channel + " : " + cuts[reg] + '\n' + '-' * 20 +
                 '\n')

histo = OrderedDict()  # will have histo[<reg>]=[h1, h2...]
yields = OrderedDict()  # will have yields[<reg>][<memeber>]=yield
Example #4
0
    2: {
        'var':
        '(llnunu_l2_pt*(abs(llnunu_deltaPhi)-TMath::Pi()/2)/abs(abs(llnunu_deltaPhi)-TMath::Pi()/2)/llnunu_l1_pt)',
        'nick': 'ptRatio_signed',
        'title': '(+/-)E_{T}^{miss}/p_{T}^{Z}',
        'par': (50, -5, 5)
    }
}

### ----- Initialize (cuts and samples):
Plotters = InitializePlotter(indir, addSig=True, addData=True)
plotters = [(Plotters.ZJets, tags[0]), (Plotters.sigPlotters[1], tags[1])]
#ZJets = plotter.ZJets
#ZJets=plotter.sigPlotters[1]

mycuts = SetCuts()
#tex_dic = mycuts.Tex_dic
cuts = mycuts.abcdCuts(Channel, Region)
preSelect = mycuts.abcdCuts(Channel,
                            Region,
                            isPreSelect=True,
                            zpt_cut=zpt_cut,
                            met_cut=met_cut)
preCuts = OrderedDict({
    'preSelect':
    preSelect,
    'preSelect_dphiJMet2':
    preSelect + '&&(dPhi_jetMet_min>0.2)',
    'preSelect_dphiJMet2a':
    preSelect + '&&(dPhi_jetMet_min_a>0.2)',
    'preSelect_dphiJMet2b':
Example #5
0
    def __init__(self,
                 indir="../AnalysisRegion",
                 outdir='plots',
                 lumi=2.169126704526,
                 sepSig=True,
                 LogY=True,
                 doRatio=True):
        if not os.path.exists(outdir): os.system('mkdir ' + outdir)

        self.mycuts = SetCuts()
        self.Channel = raw_input("Please choose a channel (el or mu): \n")
        self.outdir = outdir
        self.lumi = lumi
        self.sepSig = sepSig
        self.tex_dic = self.mycuts.Tex_dic
        self.whichregion = raw_input(
            "Please choose a benchmarck Region (SR or VR): \n")

        self.cuts = self.mycuts.abcdCuts(self.Channel, self.whichregion)
        self.preCuts = self.mycuts.abcdCuts(self.Channel, self.whichregion,
                                            True)

        if self.whichregion == "VR":
            self.nbins, self.xMin, self.xMax = 10, 0, float(self.mycuts.met_pt)
        else:
            self.nbins, self.xMin, self.xMax = 10, 0, 500

        #######----------- Prepare samples to plot:
        zjetsPlotters = []
        #zjetsSamples = ['DYJetsToLL_M50_HT100to200','DYJetsToLL_M50_HT200to400','DYJetsToLL_M50_HT400to600','DYJetsToLL_M50_HT600toInf']
        #zjetsSamples = ['DYJetsToLL_M50','DYJetsToLL_M50_Ext']
        zjetsSamples = ['DYJetsToLL_M50_BIG']  # M50_BIG = M50 + M50_Ext

        for sample in zjetsSamples:
            zjetsPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))
            zjetsPlotters[-1].addCorrectionFactor('1./SumWeights', 'tree')
            zjetsPlotters[-1].addCorrectionFactor('xsec', 'tree')
            zjetsPlotters[-1].addCorrectionFactor('genWeight', 'tree')
            zjetsPlotters[-1].addCorrectionFactor('puWeight', 'tree')
            zjetsPlotters[-1].addCorrectionFactor('triggersf', 'tree')
            zjetsPlotters[-1].addCorrectionFactor(
                'llnunu_l1_l1_lepsf*llnunu_l1_l2_lepsf', 'tree')

        self.ZJets = MergedPlotter(zjetsPlotters)
        self.ZJets.setFillProperties(1001, ROOT.kGreen + 2)

        wwPlotters = []
        wwSamples = ['WWTo2L2Nu', 'WWToLNuQQ', 'WZTo1L1Nu2Q']

        for sample in wwSamples:
            wwPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))
            wwPlotters[-1].addCorrectionFactor('1./SumWeights', 'tree')
            wwPlotters[-1].addCorrectionFactor('xsec', 'tree')
            wwPlotters[-1].addCorrectionFactor('genWeight', 'tree')
            wwPlotters[-1].addCorrectionFactor('puWeight', 'tree')
            wwPlotters[-1].addCorrectionFactor('triggersf', 'tree')
            wwPlotters[-1].addCorrectionFactor(
                'llnunu_l1_l1_lepsf*llnunu_l1_l2_lepsf', 'tree')

        self.WW = MergedPlotter(wwPlotters)
        self.WW.setFillProperties(1001, ROOT.kOrange)

        vvPlotters = []
        vvSamples = ['WZTo2L2Q', 'WZTo3LNu', 'ZZTo2L2Nu', 'ZZTo2L2Q', 'ZZTo4L']

        for sample in vvSamples:
            vvPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))
            vvPlotters[-1].addCorrectionFactor('1./SumWeights', 'tree')
            vvPlotters[-1].addCorrectionFactor('xsec', 'tree')
            vvPlotters[-1].addCorrectionFactor('genWeight', 'tree')
            vvPlotters[-1].addCorrectionFactor('puWeight', 'tree')
            vvPlotters[-1].addCorrectionFactor('triggersf', 'tree')
            vvPlotters[-1].addCorrectionFactor(
                'llnunu_l1_l1_lepsf*llnunu_l1_l2_lepsf', 'tree')

        self.VV = MergedPlotter(vvPlotters)
        self.VV.setFillProperties(1001, ROOT.kMagenta)

        wjetsPlotters = []
        wjetsSamples = ['WJetsToLNu']

        for sample in wjetsSamples:
            wjetsPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))
            wjetsPlotters[-1].addCorrectionFactor('1./SumWeights', 'tree')
            wjetsPlotters[-1].addCorrectionFactor('xsec', 'tree')
            wjetsPlotters[-1].addCorrectionFactor('genWeight', 'tree')
            wjetsPlotters[-1].addCorrectionFactor('puWeight', 'tree')
            wjetsPlotters[-1].addCorrectionFactor('triggersf', 'tree')
            wjetsPlotters[-1].addCorrectionFactor(
                'llnunu_l1_l1_lepsf*llnunu_l1_l2_lepsf', 'tree')

        self.WJets = MergedPlotter(wjetsPlotters)
        self.WJets.setFillProperties(1001, ROOT.kBlue - 6)

        ttPlotters = []
        ttSamples = ['TTTo2L2Nu']  #,'TTZToLLNuNu','TTWJetsToLNu']

        for sample in ttSamples:
            ttPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))
            ttPlotters[-1].addCorrectionFactor('1./SumWeights', 'tree')
            ttPlotters[-1].addCorrectionFactor('xsec', 'tree')
            ttPlotters[-1].addCorrectionFactor('genWeight', 'tree')
            ttPlotters[-1].addCorrectionFactor('puWeight', 'tree')
            ttPlotters[-1].addCorrectionFactor('triggersf', 'tree')
            ttPlotters[-1].addCorrectionFactor(
                'llnunu_l1_l1_lepsf*llnunu_l1_l2_lepsf', 'tree')

        self.TT = MergedPlotter(ttPlotters)
        self.TT.setFillProperties(1001, ROOT.kAzure - 9)

        # --> define different background sets:
        nonZBGPlotters = []
        nonZBGSamples = wwSamples + vvSamples + wjetsSamples + ttSamples

        for sample in nonZBGSamples:
            nonZBGPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))
            nonZBGPlotters[-1].addCorrectionFactor('1./SumWeights', 'tree')
            nonZBGPlotters[-1].addCorrectionFactor('xsec', 'tree')
            nonZBGPlotters[-1].addCorrectionFactor('genWeight', 'tree')
            nonZBGPlotters[-1].addCorrectionFactor('puWeight', 'tree')
            nonZBGPlotters[-1].addCorrectionFactor('triggersf', 'tree')
            nonZBGPlotters[-1].addCorrectionFactor(
                'llnunu_l1_l1_lepsf*llnunu_l1_l2_lepsf', 'tree')

        self.NonZBG = MergedPlotter(nonZBGPlotters)
        self.NonZBG.setFillProperties(1001, ROOT.kPink + 6)

        nonResBGPlotters = []
        nonResBGSamples = wwSamples + wjetsSamples + ttSamples

        for sample in nonResBGSamples:
            nonResBGPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))
            nonResBGPlotters[-1].addCorrectionFactor('1./SumWeights', 'tree')
            nonResBGPlotters[-1].addCorrectionFactor('xsec', 'tree')
            nonResBGPlotters[-1].addCorrectionFactor('genWeight', 'tree')
            nonResBGPlotters[-1].addCorrectionFactor('puWeight', 'tree')
            nonResBGPlotters[-1].addCorrectionFactor('triggersf', 'tree')
            nonResBGPlotters[-1].addCorrectionFactor(
                'llnunu_l1_l1_lepsf*llnunu_l1_l2_lepsf', 'tree')

        self.NonResBG = MergedPlotter(nonResBGPlotters)
        self.NonResBG.setFillProperties(1001, ROOT.kYellow)

        resBGPlotters = []
        resBGSamples = zjetsSamples + vvSamples

        for sample in resBGSamples:
            resBGPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))
            resBGPlotters[-1].addCorrectionFactor('1./SumWeights', 'tree')
            resBGPlotters[-1].addCorrectionFactor('xsec', 'tree')
            resBGPlotters[-1].addCorrectionFactor('genWeight', 'tree')
            resBGPlotters[-1].addCorrectionFactor('puWeight', 'tree')
            resBGPlotters[-1].addCorrectionFactor('triggersf', 'tree')
            resBGPlotters[-1].addCorrectionFactor(
                'llnunu_l1_l1_lepsf*llnunu_l1_l2_lepsf', 'tree')

        self.ResBG = MergedPlotter(resBGPlotters)
        self.ResBG.setFillProperties(1001, ROOT.kRed)

        # --> Prepare the signal plotters:
        sigPlotters = []
        sigSamples = [
            'BulkGravToZZToZlepZinv_narrow_800',
            'BulkGravToZZToZlepZinv_narrow_1000',
            'BulkGravToZZToZlepZinv_narrow_1200',
        ]
        k = 1000
        sigSampleNames = [
            str(k) + ' x BulkG-800',
            str(k) + ' x BulkG-1000',
            str(k) + ' x BulkG-1200',
        ]
        sigXsec = {
            'BulkGravToZZToZlepZinv_narrow_800': 4.42472e-04 * k,
            'BulkGravToZZToZlepZinv_narrow_1000': 1.33926e-04 * k,
            'BulkGravToZZToZlepZinv_narrow_1200': 4.76544e-05 * k,
        }

        for sample in sigSamples:
            sigPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))
            sigPlotters[-1].addCorrectionFactor('1./SumWeights', 'tree')
            sigPlotters[-1].addCorrectionFactor(str(sigXsec[sample]), 'tree')
            sigPlotters[-1].addCorrectionFactor('genWeight', 'tree')
            sigPlotters[-1].addCorrectionFactor('puWeight', 'tree')
            sigPlotters[-1].addCorrectionFactor('triggersf', 'tree')
            sigPlotters[-1].addCorrectionFactor(
                'llnunu_l1_l1_lepsf*llnunu_l1_l2_lepsf', 'tree')
            sigPlotters[-1].setFillProperties(0, ROOT.kWhite)

        # --> Prepare data plotters:
        dataPlotters = []
        dataSamples = [
            'SingleElectron_Run2015C_25ns_16Dec',
            'SingleElectron_Run2015D_16Dec', 'SingleMuon_Run2015C_25ns_16Dec',
            'SingleMuon_Run2015D_16Dec'
        ]
        for sample in dataSamples:
            dataPlotters.append(
                TreePlotter(indir + '/' + sample + '.root', 'tree'))

        self.Data = MergedPlotter(dataPlotters)
        self.Data.setFillProperties(1001, ROOT.kGreen + 2)

        self.Stack = StackPlotter()
        self.Stack.addPlotter(self.Data, "data_obs", "Data", "data")
        self.Stack.addPlotter(self.WJets, "WJets", "W+Jets", "background")
        self.Stack.addPlotter(self.WW, "WW", "WW, WZ non-reson.", "background")
        self.Stack.addPlotter(self.TT, "TT", "TT", "background")
        self.Stack.addPlotter(self.VV, "ZZ", "ZZ, WZ reson.", "background")
        self.Stack.addPlotter(self.ZJets, "ZJets", "Z+Jets", "background")

        for i in range(len(sigSamples)):
            sigPlotters[i].setLineProperties(2, ROOT.kRed + i, 2)
            self.Stack.addPlotter(sigPlotters[i], sigSamples[i],
                                  sigSampleNames[i], 'signal')

        self.Stack.setLog(LogY)
        self.Stack.doRatio(doRatio)
        ROOT.gROOT.ProcessLine('.x tdrstyle.C')