Пример #1
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))
Пример #2
0
    def import_xs_lumi(self, w):
        roo.factory(w, "d_lumi[0,-0.2,0.2]")
        roo.factory(w, 'lumi_factor[1.0]')
        w.arg('lumi_factor').setConstant()
        for L, channel in self.channels.items() + self.channels_qcd.items():
            roo.wimport_const(w, 'lumi_%s_hat' % L, channel.lumi)
            if 'qcd' in L:
                roo.factory(
                    w, "expr::lumi_%s('(1+@0)*@1', {d_lumi, lumi_%s_hat})" %
                    (L, L))
            else:
                roo.factory(
                    w,
                    "expr::lumi_%s('(1+@0)*@1*@2', {d_lumi, lumi_%s_hat, lumi_factor})"
                    % (L, L))

        xs_constraints = dict([
            (samp[:2], data.xs)
            for samp, data in self.channels['el'].samples.items()
            if data.xs > 0
        ])

        for sample, xs in xs_constraints.items():
            roo.wimport_const(w, 'xs_%s_hat' % sample, xs)
            roo.factory(w, "d_xs_%s[0,-0.5,1.5]" % sample)
            roo.factory(
                w, "expr::xs_%s('(1+@0)*@1',{d_xs_%s, xs_%s_hat})" %
                (3 * (sample, )))

        [
            roo.factory(w, "prod::xs_tt%s(f_%s,xs_tt)" % (c, c))
            for c in self.ttcomps
        ]
Пример #3
0
    def import_alt_model(self, channelDict):
        w = self.w

        sample = "ttalt"
        leptons = ['el', 'mu']
        channels = dict((L, channelDict[(L, 'top')]) for L in leptons)

        #xs
        xs = channels['el'].samples[sample].xs
        roo.wimport_const(w, 'xs_%s_hat' % sample, xs)
        roo.factory(w, "d_xs_%s[0,-0.5,1.5]" % sample)
        roo.factory(
            w,
            "expr::xs_%s('(1+@0)*@1',{d_xs_%s, xs_%s_hat})" % (3 * (sample, )))

        # eff
        [
            roo.wimport_const(w, 'eff_%s_%s' % (lepton, sample),
                              channel.samples[sample].eff)
            for lepton, channel in channels.items()
        ]

        [
            self.import_shape(w, lepton, sample, data)
            for lepton, channel in channels.items()
            for sample, data in channel.samples.items()
        ]

        self.import_model(w,
                          whichs={
                              '':
                              dict((i, '_both')
                                   for i in ['dy', 'wj', 'st', 'ttalt'])
                          },
                          name="alt")
Пример #4
0
 def import_asymmetry(self, w):
     alpha_max = 0.99 * lib.alphaMax(self.symm, self.anti)
     roo.factory(w, "alpha[0, -%f, %f]"%(alpha_max,alpha_max))
     roo.factory(w, 'SUM::model( alpha * pdf_template_both, pdf_template_symm)')
     ac, eac = lib.asymmetry(self.template)
     roo.wimport_const(w, "Ac_template", ac)
     roo.factory(w, "prod::Ac(Ac_template, alpha)")
Пример #5
0
    def import_asymmetry(self, w):
        if not self.asymmetry: return

        roo.factory(w, "falphaT[0.18, -0.8, 0.8]")
        roo.factory(w, "expr::alphaT('@0/@1',{falphaT,f_qg})")
        roo.factory(w, "expr::alphaL('@0/@1',{falphaL,f_qq})")

        [(roo.factory(w, "SUM::%(n)s( alphaT * %(n)s_both, %(n)s_symm )" % {'n': L + '_ttag'}),
          roo.factory(w, "SUM::%(n)s( alphaT * %(n)s_both, %(n)s_symm )" % {'n': L + '_ttqg'}),
          roo.factory(w, "SUM::%(n)s( alphaL * %(n)s_both, %(n)s_symm )" % {'n': L + '_ttqq'}))
         for L in self.channels.keys()]

        [(roo.factory(w, "SUM::%(n)s( 0 * %(n)s_both, %(n)s_symm )" % {'n': L + '_ttag'}),
          roo.factory(w, "SUM::%(n)s( 0 * %(n)s_both, %(n)s_symm )" % {'n': L + '_ttqg'}),
          roo.factory(w, "SUM::%(n)s( 0 * %(n)s_both, %(n)s_symm )" % {'n': L + '_ttqq'}))
         for L in self.channels_qcd.keys()]

        assert self.gen.samples['tt'].datas[0].GetXaxis().GetTitle() == genNameX
        assert self.gen.samples['tt'].datas[0].GetYaxis().GetTitle() == genNameY

        for n, d in self.gen.samples.items():
            y,ey = lib.asymmetry(d.datasX[0])
            p,ep = lib.asymmetry(d.datasY[0])
            roo.wimport_const(w, 'Ac_y_' + n, y)
            roo.wimport_const(w, 'Ac_phi_' + n, p)
            roo.wimport_const(w, 'err_Ac_y_' + n, ey)
            roo.wimport_const(w, 'err_Ac_phi_' + n, ep)
Пример #6
0
    def import_fractions(self, w):
        [
            roo.wimport_const(w, "f_%s_hat" % comp,
                              self.gen.samples['tt' + comp].frac)
            for comp in self.ttcomps
        ]

        if self.asymmetry:
            f_qq_max = 0.3
            alphaL_max = 0.99 * min(chan.samples['ttqq'].alphaMax
                                    for chan in self.channels.values() +
                                    self.channels_qcd.values())
            falphaL_max = f_qq_max * alphaL_max
            roo.factory(w,
                        "falphaL[0.13, -%f, %f]" % (falphaL_max, falphaL_max))
            roo.factory(w, "slosh[0.44, 0, 1]")
            e_dqq = '( @0*%f + (1-@0)*abs(@1)/%f) / @2 -1' % (f_qq_max,
                                                              alphaL_max)
            roo.factory(w, "expr::d_qq('%s',{slosh,falphaL,f_qq_hat})" % e_dqq)
        else:
            roo.factory(w, "d_qq[-0.999999,1]")

        roo.factory(
            w, "R_ag[%f,0.07,1]" %
            (self.gen.samples['ttag'].frac / self.gen.samples['ttqq'].frac))
        roo.factory(w, "expr::f_qq('(1+@0)*@1',{d_qq,f_qq_hat})")
        roo.factory(w, "prod::f_ag(R_ag,f_qq)")
        roo.factory(w, "expr::f_qg('(1-@0-@1)/(1+@2*@3*@4/(@5*@6))'," +\
                        "{f_qq,f_ag,R_ag,f_gg_hat,f_qq_hat,f_ag_hat,f_qg_hat})")
        roo.factory(w, "expr::f_gg('1-@0-@1-@2',{f_qq,f_ag,f_qg})")

        if self.fixFractions:
            w.arg('slosh').setConstant(True)
            w.arg('R_ag').setConstant(True)
Пример #7
0
 def import_efficiencies(self, w, channels=None):
     if not channels: channels = self.channels
     [
         roo.wimport_const(w, 'eff_%s_%s' % (lepton, sample), data.eff)
         for lepton, channel in channels.items()
         for sample, data in channel.samples.items() if sample != 'data'
     ]
Пример #8
0
    def import_fractions(self, w):
        [roo.wimport_const(w, "f_%s_hat" % comp, self.gen.samples['tt' + comp].frac)
         for comp in self.ttcomps]

        if self.asymmetry:
            f_qq_max = 0.3
            alphaL_max = 0.99 * min(chan.samples['ttqq'].alphaMax for chan in
                                    self.channels.values() +
                                    self.channels_qcd.values())
            falphaL_max = f_qq_max * alphaL_max
            roo.factory(w, "falphaL[0.13, -%f, %f]"%(falphaL_max,falphaL_max))
            roo.factory(w, "slosh[0.44, 0, 1]")
            e_dqq = '( @0*%f + (1-@0)*abs(@1)/%f) / @2 -1'%(f_qq_max, alphaL_max)
            roo.factory(w, "expr::d_qq('%s',{slosh,falphaL,f_qq_hat})"%e_dqq)
        else:
            roo.factory(w, "d_qq[-0.999999,1]")

        roo.factory(w, "R_ag[%f,0.07,1]" % (self.gen.samples['ttag'].frac /
                                            self.gen.samples['ttqq'].frac))
        roo.factory(w, "expr::f_qq('(1+@0)*@1',{d_qq,f_qq_hat})")
        roo.factory(w, "prod::f_ag(R_ag,f_qq)")
        roo.factory(w, "expr::f_qg('(1-@0-@1)/(1+@2*@3*@4/(@5*@6))'," +\
                        "{f_qq,f_ag,R_ag,f_gg_hat,f_qq_hat,f_ag_hat,f_qg_hat})")
        roo.factory(w, "expr::f_gg('1-@0-@1-@2',{f_qq,f_ag,f_qg})")

        if self.fixFractions:
            w.arg('slosh').setConstant(True)
            w.arg('R_ag').setConstant(True)
Пример #9
0
    def import_xs_lumi(self, w):
        roo.factory(w, "d_lumi[0,-0.2,0.2]")
        roo.factory(w, 'lumi_factor[1.0]')
        w.arg('lumi_factor').setConstant()
        for L, channel in self.channels.items() + self.channels_qcd.items():
            roo.wimport_const(w, 'lumi_%s_hat' % L, channel.lumi)
            if 'qcd' in L: roo.factory(w, "expr::lumi_%s('(1+@0)*@1', {d_lumi, lumi_%s_hat})" % (L, L))
            else:          roo.factory(w, "expr::lumi_%s('(1+@0)*@1*@2', {d_lumi, lumi_%s_hat, lumi_factor})" % (L, L))

        xs_constraints = dict([(samp[:2], data.xs)
                               for samp, data in self.channels['el'].samples.items()
                               if data.xs > 0])

        for sample, xs in xs_constraints.items():
            roo.wimport_const(w, 'xs_%s_hat' % sample, xs)
            roo.factory(w, "d_xs_%s[0,-0.5,1.5]" % sample)
            roo.factory(w, "expr::xs_%s('(1+@0)*@1',{d_xs_%s, xs_%s_hat})" % (3 * (sample,)))
Пример #10
0
    def import_asymmetry(self, w):
        alpha_max = 0.99 * min(chan.samples['tt'].alphaMax for chan in
                                self.channels.values() +
                                self.channels_qcd.values())
        roo.factory(w, "alpha[1, -%f, %f]"%(alpha_max,alpha_max))

        [roo.factory(w, "SUM::%(n)s( alpha * %(n)s_both, %(n)s_symm )" % {'n': L+'_tt'})
         for L in (self.channels.keys() + self.channels_qcd.keys())]

        assert self.gen.samples['tt'].datas[0].GetXaxis().GetTitle() == genNameX
        assert self.gen.samples['tt'].datas[0].GetYaxis().GetTitle() == genNameY

        for n, d in self.gen.samples.items():
            hists = {'XL':d.datasX[0], 'XT':d.datasY[0]}
            ac, eac = lib.asymmetry(hists[self.observables[0]])
            roo.wimport_const(w, 'Ac_'+n, ac)
            roo.wimport_const(w, 'err_Ac_'+n, eac)
Пример #11
0
    def import_alt_model(self, channelDict):
        w = self.w

        sample = "ttalt"
        leptons = ['el', 'mu']
        channels = dict((L, channelDict[(L,'top')]) for L in leptons)

        #xs
        xs = channels['el'].samples[sample].xs
        roo.wimport_const(w, 'xs_%s_hat' % sample, xs)
        roo.factory(w, "d_xs_%s[0,-0.5,1.5]" % sample)
        roo.factory(w, "expr::xs_%s('(1+@0)*@1',{d_xs_%s, xs_%s_hat})" % (3 * (sample,)))

        # eff
        [roo.wimport_const(w, 'eff_%s_%s' % (lepton, sample), channel.samples[sample].eff)
         for lepton, channel in channels.items() ]

        [self.import_shape(w, lepton, sample, data)
         for lepton, channel in channels.items()
         for sample, data in channel.samples.items()]

        self.import_model(w, whichs={'':dict((i, '_both') for i in ['dy', 'wj', 'st', 'ttalt'])},
                          name="alt")
Пример #12
0
    def import_asymmetry(self, w):
        if not self.asymmetry: return

        roo.factory(w, "falphaT[0.18, -0.8, 0.8]")
        roo.factory(w, "expr::alphaT('@0/@1',{falphaT,f_qg})")
        roo.factory(w, "expr::alphaL('@0/@1',{falphaL,f_qq})")

        [(roo.factory(
            w, "SUM::%(n)s( alphaT * %(n)s_both, %(n)s_symm )" %
            {'n': L + '_ttag'}),
          roo.factory(
              w, "SUM::%(n)s( alphaT * %(n)s_both, %(n)s_symm )" %
              {'n': L + '_ttqg'}),
          roo.factory(
              w, "SUM::%(n)s( alphaL * %(n)s_both, %(n)s_symm )" %
              {'n': L + '_ttqq'})) for L in self.channels.keys()]

        [(roo.factory(
            w,
            "SUM::%(n)s( 0 * %(n)s_both, %(n)s_symm )" % {'n': L + '_ttag'}),
          roo.factory(
              w,
              "SUM::%(n)s( 0 * %(n)s_both, %(n)s_symm )" % {'n': L + '_ttqg'}),
          roo.factory(
              w,
              "SUM::%(n)s( 0 * %(n)s_both, %(n)s_symm )" % {'n': L + '_ttqq'}))
         for L in self.channels_qcd.keys()]

        assert self.gen.samples['tt'].datas[0].GetXaxis().GetTitle(
        ) == genNameX
        assert self.gen.samples['tt'].datas[0].GetYaxis().GetTitle(
        ) == genNameY

        for n, d in self.gen.samples.items():
            y, ey = lib.asymmetry(d.datasX[0])
            p, ep = lib.asymmetry(d.datasY[0])
            roo.wimport_const(w, 'Ac_y_' + n, y)
            roo.wimport_const(w, 'Ac_phi_' + n, p)
            roo.wimport_const(w, 'err_Ac_y_' + n, ey)
            roo.wimport_const(w, 'err_Ac_phi_' + n, ep)
Пример #13
0
 def import_efficiencies(self, w, channels=None):
     if not channels: channels = self.channels
     [roo.wimport_const(w, 'eff_%s_%s' % (lepton, sample), data.eff)
      for lepton, channel in channels.items()
      for sample, data in channel.samples.items()
      if sample != 'data']