Example #1
0
    def import_data(self, altData=None):
        w = self.w
        if altData:
            altData.SetName('data')
            roo.wimport(w, altData)
            return
        obs_ = w.argSet(','.join(self.observables))
        obs = r.RooArgList(obs_)

        dataHists = dict([(L,
                           unqueue(chan.samples['data'].datas[0],
                                   self.asymmetry))
                          for L, chan in self.channels.items()])
        datas = [(L, r.RooDataHist('data_' + L, 'N_{obs}^{%s}' % L, obs, data))
                 for L, data in dataHists.items()]
        if not self.quiet:
            print self.observables[0]
            print '\n'.join('%s: %.6f (%.6f)' %
                            ((L, ) + lib.asymmetry(hist.ProjectionX()))
                            for L, hist in dataHists.items())
            print self.observables[1]
            print '\n'.join('%s: %.6f (%.6f)' %
                            ((L, ) + lib.asymmetry(hist.ProjectionY()))
                            for L, hist in dataHists.items())
            print

        [roo.wimport(w, dat) for _, dat in datas]
        args = [r.RooFit.Import(*dat) for dat in datas]
        roo.wimport(
            w,
            r.RooDataHist('data', 'N_{obs}', obs,
                          r.RooFit.Index(w.arg('channel')), *args))
Example #2
0
 def import_data(self, data, name=""):
     roo.wimport_const(self.w,"Ac_data"+name, lib.asymmetry(data)[0])
     roo.wimport(self.w,
                 r.RooDataHist('data'+name,
                               'N_{obs}',
                               r.RooArgList(self.w.argSet('x')),
                               data))
Example #3
0
    def import_qcd(self, w):
        [roo.factory(w, "factor_%s[1,0,5]" % lepton) for lepton in self.channels_qcd]

        self.import_efficiencies(w, self.channels_qcd)
        self.import_shapes(w, self.channels_qcd)
        arglist = r.RooArgList(*[w.var(o) for o in self.observables])
        argset = r.RooArgSet(arglist)
        for L, channel in self.channels_qcd.items():
            hist = channel.samples['data'].datas[0]
            dhist = '%s_data_sim_both' % L
            roo.wimport(w, r.RooDataHist(dhist, '', arglist, hist))
            roo.wimport(w, r.RooHistPdf('%s_data_both' % L, '', argset, w.data(dhist)))
            roo.factory(w, "expr::expect_%s_data('@0*%f',{factor_%s})" %
                        (L, hist.Integral(), L))
Example #4
0
    def import_shape(self, w, lepton, sample, data):
        name = '_'.join([lepton, sample])
        arglist = r.RooArgList(*[w.var(o) for o in self.observables])
        argset = r.RooArgSet(arglist)

        for i, label in enumerate(['both', 'symm'][:None if sample in ['tt', 'dy'] else -1]):
            nL = (name, label)
            roo.wimport(w, r.RooDataHist('_sim_'.join(nL), '', arglist, data.datas[i]))
            roo.wimport(w, r.RooHistPdf('_'.join(nL), '', argset, w.data('_sim_'.join(nL))))

        roo.factory(w, "prod::expect_%s(%s)" %
                    (name, ','.join(['lumi_' + lepton,
                                     'xs_' + sample,
                                     'eff_' + name,
                                     '-1',
                                     'factor_%s' % lepton][:None if 'qcd' in lepton else -2])))
Example #5
0
    def import_qcd(self, w):
        [
            roo.factory(w, "factor_%s[1,0,5]" % lepton)
            for lepton in self.channels_qcd
        ]

        self.import_efficiencies(w, self.channels_qcd)
        self.import_shapes(w, self.channels_qcd)
        arglist = r.RooArgList(*[w.var(o) for o in self.observables])
        argset = r.RooArgSet(arglist)
        for L, channel in self.channels_qcd.items():
            hist = unqueue(channel.samples['data'].datas[0], self.asymmetry)
            dhist = '%s_data_sim_both' % L
            roo.wimport(w, r.RooDataHist(dhist, '', arglist, hist))
            roo.wimport(
                w, r.RooHistPdf('%s_data_both' % L, '', argset, w.data(dhist)))
            roo.factory(
                w, "expr::expect_%s_data('@0*%f',{factor_%s})" %
                (L, hist.Integral(), L))
Example #6
0
    def import_data(self, altData=None):
        w = self.w
        if altData:
            altData.SetName('data')
            roo.wimport(w, altData)
            return
        obs_ = w.argSet(','.join(self.observables))
        obs = r.RooArgList(obs_)

        dataHists = dict([(L,unqueue(chan.samples['data'].datas[0], self.asymmetry)) for L,chan in self.channels.items()])
        datas = [(L, r.RooDataHist('data_' + L, 'N_{obs}^{%s}' % L, obs, data))  for L, data in dataHists.items()]
        if not self.quiet:
            print self.observables[0]
            print '\n'.join('%s: %.6f (%.6f)'%((L,)+lib.asymmetry(hist.ProjectionX())) for L,hist in dataHists.items())
            print self.observables[1]
            print '\n'.join('%s: %.6f (%.6f)'%((L,)+lib.asymmetry(hist.ProjectionY())) for L,hist in dataHists.items())
            print

        [roo.wimport(w, dat) for _, dat in datas]
        args = [r.RooFit.Import(*dat) for dat in datas]
        roo.wimport(w, r.RooDataHist('data', 'N_{obs}', obs,
                                     r.RooFit.Index(w.arg('channel')), *args))
Example #7
0
    def import_shape(self, w, lepton, sample, data):
        name = '_'.join([lepton, sample])
        arglist = r.RooArgList(*[w.var(o) for o in self.observables])
        argset = r.RooArgSet(arglist)

        for i, label in enumerate([
                'both', 'symm'
        ][:None if sample in ['ttag', 'ttqg', 'ttqq', 'dy'] else -1]):
            nL = (name, label)
            roo.wimport(
                w,
                r.RooDataHist('_sim_'.join(nL), '', arglist,
                              unqueue(data.datas[i], self.asymmetry)))
            roo.wimport(
                w,
                r.RooHistPdf('_'.join(nL), '', argset,
                             w.data('_sim_'.join(nL))))

        roo.factory(
            w, "prod::expect_%s(%s)" % (name, ','.join([
                'lumi_' + lepton, 'xs_' + sample, 'eff_' + name, '-1',
                'factor_%s' % lepton
            ][:None if 'qcd' in lepton else -2])))
Example #8
0
    def __init__(self, template):

        symm,anti = lib.symmAnti(template)
        for item in ['template','symm','anti']:
            setattr(self, item, eval(item))
        
        self.nBinsX = symm.GetNbinsX()

        w = r.RooWorkspace('Workspace')
        roo.factory(w, "x[-1,1]")
        argset = w.argSet("x")
        arglist = r.RooArgList(argset)
        roo.wimport(w, r.RooDataHist('dh_template_both','', arglist, template))
        roo.wimport(w, r.RooDataHist('dh_template_symm','', arglist, symm))
        roo.wimport(w, r.RooHistPdf('pdf_template_both','',argset, w.data('dh_template_both')))
        roo.wimport(w, r.RooHistPdf('pdf_template_symm','',argset, w.data('dh_template_symm')))
        self.import_asymmetry(w)
        self.w = w