示例#1
0
    def __init__(self,
                 cuts,
                 weight=lambda s: 1,
                 slices_raw=False,
                 slices_cor=False):

        h1 = None
        h2 = None
        h3 = None
        h4 = None

        if slices_raw:
            h1 = ROOT.TH1D(hID(), '', 10, 3.00, 3.20)
            h1.Sumw2()
            h2 = ROOT.TH1D(hID(), '',  9, 2.24, 2.33)
            h2.Sumw2()

        if slices_cor:
            h3 = ROOT.TH1D(hID(), '', 10, 3.00, 3.20)
            h3.Sumw2()
            h4 = ROOT.TH1D(hID(), '',  9, 2.24, 2.33)
            h4.Sumw2()

        SpsiD.__init__(self,
                       lambda s: 3.0 <= s.m_psi <= 3.2 and 2.24 <= s.m_Lc <= 2.33 and cuts(
                           s),
                       ('Lc', 2.24, 2.33),
                       weight,
                       'psi',
                       h1, h2, h3, h4)
示例#2
0
    def __init__(self,
                 cuts,
                 weight=lambda s: 1,
                 slices_raw=False,
                 slices_cor=False):

        h1 = None
        h2 = None
        h3 = None
        h4 = None

        if slices_raw:
            h1 = ROOT.TH1D(hID(), '', 20, 3.00, 3.20)
            h1.Sumw2()
            h2 = ROOT.TH1D(hID(), '', 20, 1.82, 1.92)
            h2.Sumw2()
        if slices_cor:
            h3 = ROOT.TH1D(hID(), '', 10, 3.00, 3.20)
            h3.Sumw2()
            h4 = ROOT.TH1D(hID(), '', 10, 1.82, 1.92)
            h4.Sumw2()

        SpsiD.__init__(self,
                       lambda s: 3.0 <= s.m_psi <= 3.2 and 1.82 <= s.m_D0 <= 1.92 and cuts(
                           s),
                       ('D0', 1.82, 1.92),
                       weight,
                       'psi',
                       h1, h2, h3, h4)
示例#3
0
    def __init__(self,
                 cuts,
                 weight=lambda s: 1,
                 slices_raw=False,
                 slices_cor=False):

        h1 = None
        h2 = None
        h3 = None
        h4 = None

        if slices_raw:
            h1 = ROOT.TH1D(hID(), '', 10, 3.00, 3.20)
            h1.Sumw2()
            h2 = ROOT.TH1D(hID(), '', 14, 1.90, 2.04)
            h2.Sumw2()

        if slices_cor:
            h3 = ROOT.TH1D(hID(), '', 10, 3.00, 3.20)
            h3.Sumw2()
            h4 = ROOT.TH1D(hID(), '',  7, 1.90, 2.04)
            h4.Sumw2()

        SpsiD.__init__(self,
                       lambda s: 3.0 <= s.m_psi <= 3.2 and 1.9 <= s.m_Ds <= 2.04 and cuts(
                           s),
                       ('Ds', 1.9, 2.04),
                       weight,
                       'psi',
                       h1, h2, h3, h4)
示例#4
0
    def __init__(self,
                 cuts,
                 weight=lambda s: 1,
                 slices_raw=False,
                 slices_cor=False):

        h1 = None
        h2 = None
        h3 = None
        h4 = None

        if slices_raw:
            h1 = ROOT.TH1D(hID(), '', 18, 1.82, 1.91)
            h1.Sumw2()
            h2 = ROOT.TH1D(hID(), '', 14, 1.90, 2.04)
            h2.Sumw2()

        if slices_cor:
            h3 = ROOT.TH1D(hID(), '',  6, 1.82, 1.91)
            h3.Sumw2()
            h4 = ROOT.TH1D(hID(), '',  7, 1.90, 2.04)
            h4.Sumw2()

        DD.__init__(
            self,
            lambda s: 1.82 <= s.m_Dp <= 1.91 and 1.9 <= s.m_Ds <= 2.04 and cuts(
                s),
            ('Dp', 1.82,  1.91),
            ('Ds', 1.9,  2.04),
            weight,
            h1, h2, h3, h4)
示例#5
0
    def __init__(self,
                 cuts,
                 weight=lambda s: 1,
                 slices_raw=False,
                 slices_cor=False):

        h1 = None
        h2 = None
        h3 = None
        h4 = None

        if slices_raw:
            h1 = ROOT.TH1D(hID(), '',  9, 2.24, 2.33)
            h1.Sumw2()
            h2 = ROOT.TH1D(hID(), '',  9, 2.24, 2.33)
            h2.Sumw2()

        if slices_cor:
            h3 = ROOT.TH1D(hID(), '',  9, 2.24, 2.33)
            h3.Sumw2()
            h4 = ROOT.TH1D(hID(), '',  9, 2.24, 2.33)
            h4.Sumw2()

        DD.__init__(
            self,
            lambda s: 2.24 <= s.m_Lc1 <= 2.33 and 2.24 <= s.m_Lc2 <= 2.33 and cuts(
                s),
            ('Lc1', 2.24,  2.33),
            ('Lc2', 2.24,  2.33),
            weight,
            h1, h2, h3, h4)
示例#6
0
    def __init__(self,
                 histo,
                 pt_axis=ROOT.TAxis(20, 2.0, 12.0),
                 y_axis=ROOT.TAxis(10, 2.0,  4.5),
                 cuts=lambda s: True):

        Selector.__init__(self, None, self)  # initialize the base

        self._cuts = cuts
        self._pt_axis = pt_axis
        self. _y_axis = y_axis

        self._histos = {}
        self._events = 0L
        #
        for iPt in pt_axis:

            for iY in y_axis:

                hTotal = histo.Clone(hID())
                hAccept = histo.Clone(hID())
                hReject = histo.Clone(hID())

                hTotal  . SetTitle('Total')
                hAccept . SetTitle('Accept')
                hReject . SetTitle('Reject')

                self._histos[(iPt, iY)] = [
                    hTotal,
                    hAccept,
                    hReject,
                ]
示例#7
0
    def __init__(self, h1, h2):

        h = h1.Clone(hID())
        h.Reset()
        if not h.GetSumw2():
            h.Sumw2()
        self.h1_ = h

        h = h2.Clone(hID())
        h.Reset()
        if not h.GetSumw2():
            h.Sumw2()
        self.h2_ = h

        self.axis_1 = self.h1_.GetXaxis()
        self.axis_2 = self.h2_.GetXaxis()

        self.histos_1 = {}
        self.histos_2 = {}

        for ibin in self.axis_2:
            h = self.h1_.Clone(hID())
            self.histos_1[ibin] = h

        for ibin in self.axis_1:
            h = self.h2_.Clone(hID())
            self.histos_2[ibin] = h
示例#8
0
    def __init__(self,
                 cuts,
                 weight=lambda s: 1,
                 slices_raw=False,
                 slices_cor=False):

        h1 = None
        h2 = None
        h3 = None
        h4 = None

        if slices_raw:
            h1 = ROOT.TH1D(hID(), '',  7, 1.90, 2.04)
            h1.Sumw2()
            h2 = ROOT.TH1D(hID(), '',  6, 2.24, 2.33)
            h2.Sumw2()

        if slices_cor:
            h3 = ROOT.TH1D(hID(), '',  7, 1.90, 2.04)
            h3.Sumw2()
            h4 = ROOT.TH1D(hID(), '',  6, 2.24, 2.33)
            h4.Sumw2()

        DD.__init__(
            self,
            lambda s: 1.9 <= s.m_Ds <= 2.04 and 2.24 <= s.m_Lc <= 2.33 and cuts(
                s),
            ('Ds', 1.9,  2.04),
            ('Lc', 2.24,  2.33),
            weight,
            h1, h2, h3, h4)
示例#9
0
    def __init__(self,
                 cuts,
                 weight=lambda s: 1,
                 slices_raw=False,
                 slices_cor=False):

        h1 = None
        h2 = None
        h3 = None
        h4 = None

        if slices_raw:
            h1 = ROOT.TH1D(hID(), '', 20, 1.82, 1.92)
            h1.Sumw2()
            h2 = ROOT.TH1D(hID(), '', 18, 1.82, 1.91)
            h2.Sumw2()
        if slices_cor:
            h3 = ROOT.TH1D(hID(), '', 10, 1.82, 1.92)
            h3.Sumw2()
            h4 = ROOT.TH1D(hID(), '',  9, 1.82, 1.91)
            h4.Sumw2()

        DD.__init__(
            self,
            lambda s: 1.8 <= s.m_D0 <= 1.92 and 1.82 <= s.m_Dp <= 1.91 and cuts(
                s),
            ('D0', 1.8,  1.92),
            ('Dp', 1.82,  1.91),
            weight,
            h1, h2, h3, h4)
示例#10
0
    def __init__(self,
                 cuts,
                 weight=lambda s: 1,
                 slices_raw=False,
                 slices_cor=False):

        h1 = None
        h2 = None
        h3 = None
        h4 = None

        if slices_raw:
            h1 = ROOT.TH1D(hID(), '', 10, 1.82, 1.92)
            h1.Sumw2()
            h2 = ROOT.TH1D(hID(), '',  9, 2.24, 2.33)
            h2.Sumw2()

        if slices_cor:
            h3 = ROOT.TH1D(hID(), '',  8, 1.82, 1.92)
            h3.Sumw2()
            h4 = ROOT.TH1D(hID(), '',  9, 2.24, 2.33)
            h4.Sumw2()

        DD.__init__(
            self,
            lambda s: 1.8 <= s.m_D0 <= 1.92 and 2.24 <= s.m_Lc <= 2.33 and cuts(
                s),
            ('D0', 1.8,  1.92),
            ('Lc', 2.24,  2.33),
            weight,
            h1, h2, h3, h4)
示例#11
0
    def __init__(self,
                 histo,
                 pv_axis=ROOT.TAxis(10, 0,    10),
                 spd_axis=ROOT.TAxis(100, 0,  1000),
                 ot_axis=ROOT.TAxis(150, 0, 15000),
                 tlong_axis=ROOT.TAxis(100, 0,   500),
                 tbest_axis=ROOT.TAxis(100, 0,  1000)):

        Selector.__init__(self, None, self)  # initialize the base

        #
        # PV
        self.pv_axis = pv_axis
        self.pv = {}
        for i in pv_axis:
            h = histo.Clone(hID())
            h.Sumw2()
            self.pv[i] = h
        #
        # SPD
        self.spd_axis = spd_axis
        self.spd = {}
        for i in spd_axis:
            h = histo.Clone(hID())
            h.Sumw2()
            self.spd[i] = h

        # OT
        self.ot_axis = ot_axis
        self.ot = {}
        for i in ot_axis:
            h = histo.Clone(hID())
            h.Sumw2()
            self.ot[i] = h

        # Long
        self.tlong_axis = tlong_axis
        self.tlong = {}
        for i in tlong_axis:
            h = histo.Clone(hID())
            h.Sumw2()
            self.tlong[i] = h

        # Best
        self.tbest_axis = tbest_axis
        self.tbest = {}
        for i in tbest_axis:
            h = histo.Clone(hID())
            h.Sumw2()
            self.tbest[i] = h

        self._events = 0
示例#12
0
文件: Models.py 项目: mazurov/cross
    def fitHisto ( self , histo , draw = False , *args ) :
        """
        Fit the histogram
        """
        self.lst  = ROOT.RooArgList    ( self.mass )
        self.imp  = ROOT.RooFit.Import ( histo     ) 
        self.hset = ROOT.RooDataHist (
            hID()     ,
            "Data set for histogram '%s'" % histo.GetTitle() ,
            self.lst  ,
            self.imp  
            )
        
        result = self.pdf.fitTo ( self.hset           ,
                                  ROOT.RooFit.Save () ,
                                  *args               )

        if not draw : return result
        
        frame = self.mass.frame()
        self.hset.plotOn ( frame )
        self.pdf .plotOn ( frame ,
                           ROOT.RooFit.Components ( self.background.pdf.GetName() ) ,
                           ROOT.RooFit.LineStyle  ( ROOT.kDashed ) ,
                           ROOT.RooFit.LineColor  ( ROOT.kBlue   ) )
        self.pdf .plotOn ( frame ,
                           ROOT.RooFit.LineColor  ( ROOT.kRed    ) )                
        frame.Draw() 
        
        return result, frame 
示例#13
0
    def __init__(self,
                 pt_axis=pt_axis_psi,
                 y_axis=y_axis_psi,
                 cuts=lambda s: 3.0 <= s.mass <= 3.2):

        MuPidSelector.__init__(self,
                               ROOT.TH1F(
                                   hID(), 'Psi+-template', 200, 3.0, 3.2),
                               pt_axis,
                               y_axis,
                               cuts)
示例#14
0
    def __init__(self,
                 scale=VE(1, 0)):

        Selector.__init__(self, None, self)  # initialize the base

        self.scale = scale
        self.dz_0 = ROOT.TH1F(hID(), '', 500, -250, 250)
        self.dz_1 = ROOT.TH1F(hID(), '', 100,  -10,  10)
        self.pid_0 = ROOT.TH1F(hID(), '', 204,  -51,  51)  # true pileup
        ## pileup with |dz|
        self.pid_1 = ROOT.TH1F(hID(), '', 204,  -51,  51)
        self.pid_2 = ROOT.TH1F(hID(), '', 204,  -51,  51)  # B-feeddown
        self.pid_3 = ROOT.TH1F(hID(), '', 204,  -51,  51)  # signal

        self.dz_0  . Sumw2()
        self.dz_1  . Sumw2()
        self.pid_0 . Sumw2()
        self.pid_1 . Sumw2()
        self.pid_2 . Sumw2()
        self.pid_3 . Sumw2()

        self.se_0 = SE()
        self.se_1 = SE()
        self.se_2 = SE()
        self.se_3 = SE()

        self._events = 0
示例#15
0
文件: Models.py 项目: mazurov/cross
 def sPlot ( self     ,
             dataset  ,
             *args    ) : 
     
     splot = ROOT.RooStats.SPlot ( "sPlot_" + hID() ,
                                   "sPlot"          ,
                                   dataset          ,
                                   self.pdf         ,
                                   self.alist2      )
     
     self._splots += [ splot ]
     
     return splot
示例#16
0
    def __init__(self,
                 mass,  # mass-variable
                 selection,  # Tree-selection
                 cuts=lambda s: True,
                 weight=lambda s: 1,
                 name='',
                 tmva_weights='',
                 short=False):

        if not name:
            name = hID()

        SelectorWithCuts.__init__(self, selection)  # initialize the base

        self.num_re = re.compile(r"[(\d)]")

        self._cuts = cuts
        self._weight = weight
        self._short = short

        self.variables = {}

        # meta info about vector-variables
        # contain pairs (name without `[N]`, N as int)
        self.meta = {} 

        self.mass = mass
        self.varset = ROOT.RooArgSet(self.mass)

        for v in varlist:
            self.add_variable(v[0], v[4], v[2] - 0.1, v[3] + 0.1,)

        self.data = ROOT.RooDataSet(
            #
            name,
            "Bu -> J/psi KK pi: " + self.mass.GetName(),
            #
            self.varset
        )

        ROOT.SetOwnership(self.data, False)

        self.mmin = self.mass.getMin()
        self.mmax = self.mass.getMax()

        self._events = 0
        self._counter = SE()
        self._progress = None
        self._total = 1

        self._tmva_weights = tmva_weights
示例#17
0
    def fit(self,
            fun1,
            fun2):

        h1 = self.h1_.Clone(hID())
        h2 = self.h2_.Clone(hID())

        mnerr = 1.e+9

        n1, r1 = fun1(self.h1_)
        for k in self.histos_1:
            h = self.histos_1[k]
            n, r = fun1(h)
            if r and 0 == r.Status() and 0 != n.value() and 0 < n.error():
                mnerr = min(mnerr, n.error())
            h2[k] = abs(n)

        n2, r2 = fun2(self.h2_)
        for k in self.histos_2:
            h = self.histos_2[k]
            n, r = fun2(h)
            if r and 0 == r.Status() and 0 != n.value() and 0 < n.error():
                mnerr = min(mnerr, n.error())
            h1[k] = abs(n)

        # adjust null entries (== empty histograms)
        for h in (h1, h2):
            for i in h:
                n = h[i]
                if n.error() < mnerr:
                    n.setError(mnerr)
                    h[i] = n

        n1, r1 = fun1(h1)
        n2, r2 = fun2(h2)

        return (n1, r1, h1), (n2, r2, h2)
示例#18
0
    def __init__(self,
                 pt_axis=pt_axis_psip,
                 y_axis=y_axis_psip,
                 l0=True,
                 l1=True,
                 l2=True,
                 cuts=lambda s: 3.61 <= s.m_psip <= 3.77):

        TrgSelector.__init__(
            self,
            'psip',  # see TrgEff
            ROOT.TH1F(hID(), "Psi'-template", 160, 3.61, 3.77),
            pt_axis,
            y_axis,
            l0,
            l1,
            l2,
            cuts)
示例#19
0
    def __init__(self,
                 pt_axis=pt_axis_ups,
                 y_axis=y_axis_ups,
                 l0=True,
                 l1=True,
                 l2=True,
                 cuts=lambda s: 8.5 <= s.m_ups <= 11):

        TrgSelector.__init__(
            self,
            'ups',  # see TrgEff
            ROOT.TH1F(hID(), "Y-template", 250, 8.5, 11),
            pt_axis,
            y_axis,
            l0,
            l1,
            l2,
            cuts)
示例#20
0
    def __init__(self,
                 pt_axis=pt_axis_psi,
                 y_axis=y_axis_all,
                 l0=True,
                 l1=True,
                 l2=True,
                 cuts=lambda s: 3.0 <= s.m_psi <= 3.2):

        TrgSelector.__init__(
            self,
            'psi',  # see TrgEff
            ROOT.TH1F(hID(), 'Psi+-template', 200, 3.0, 3.2),
            pt_axis,
            y_axis,
            l0,
            l1,
            l2,
            cuts)
示例#21
0
    def __init__(self,
                 pt_axis=pt_axis_ds,
                 y_axis=y_axis_all,
                 l0=True,
                 l1=True,
                 l2=True,
                 cuts=lambda s: 1.9 <= s.m_Ds <= 2.04):

        TrgSelector.__init__(
            self,
            'Ds',  # see TrgEff
            ROOT.TH1F(hID(), 'Ds+-template', 140, 1.9, 2.04),
            pt_axis,
            y_axis,
            l0,
            l1,
            l2,
            cuts)
示例#22
0
    def __init__(self,
                 pt_axis=pt_axis_lc,
                 y_axis=y_axis_all,
                 l0=True,
                 l1=True,
                 l2=True,
                 cuts=lambda s: 2.24 <= s.m_Lc <= 2.33):

        TrgSelector.__init__(
            self,
            'Lc',  # see TrgEff
            ROOT.TH1F(hID(), 'c+-template', 90, 2.24, 2.33),
            pt_axis,
            y_axis,
            l0,
            l1,
            l2,
            cuts)
示例#23
0
    def __init__(self,
                 pt_axis=pt_axis_had,
                 y_axis=y_axis_all,
                 l0=True,
                 l1=True,
                 l2=True,
                 cuts=lambda s: 1.82 <= s.m_Dp <= 1.91):

        TrgSelector.__init__(
            self,
            'Dp',  # see TrgEff
            ROOT.TH1F(hID(), 'D+-template', 90, 1.82, 1.91),
            pt_axis,
            y_axis,
            l0,
            l1,
            l2,
            cuts)
示例#24
0
def getLumi(tree):
    """
    Get Lumi 
    """

    import ROOT
    from AnalysisPython.PyRoUts import hID, VE
    #
    hL = ROOT.TH1F(hID(), '', 10, -1, 4)
    hL.Sumw2()
    tree.Project(hL.GetName(), '1', 'IntegratedLuminosity')
    l0 = hL.accumulate()
    #
    tree.Project(hL.GetName(), '1',
                 'IntegratedLuminosity+IntegratedLuminosityErr')
    l1 = hL.accumulate()
    #
    # tree.Project ( hL.GetName() , 'IntegratedLuminosity+IntegratedLuminosityErr')
    # l2 = hL.accumulate()
    #
    return VE(l0.value(), (l1.value() - l0.value()) ** 2)
示例#25
0
def cross_T(tree,
            first,
            second,
            gec):
    """
    calculate the cross-section in nanobarns
    
    >>> tree = ...
    >>> cross_section, syst = cross_T ( tree , 'D0' , 'D0' )
    
    """
    if issubclass(tree .__class__,  (ROOT.RooAbsData, ROOT.RooDataSet)):
        tree = tree.store().tree()

    h0 = ROOT.TH1F(hID(), '', 10, -1, 4)
    h0.Sumw2()
    tree.Project(h0.GetName(), '1', 'S1S2_sw')
    n_raw = h0.accumulate()
    tree.Project(h0.GetName(), '1', 'S1S2_sw*weight')
    n_corr = h0.accumulate()

    return n_raw, n_corr, cross_N(n_corr, first, second, gec)
示例#26
0
    def __init__(self,
                 var_,
                 histo,
                 pt_axis,
                 y_axis,
                 l0=True,
                 l1=True,
                 l2=True,
                 cuts=lambda s: True):

        Selector.__init__(self, None, self)  # initialize the base

        self._l0 = l0
        self._l1 = l1
        self._l2 = l2

        trg = self._l0 or self._l1 or self._l2
        if not trg:
            raise TypeError, 'Trigger is not specified '

        self._cuts = cuts
        self._pt_axis = pt_axis
        self. _y_axis = y_axis

        self._histos = {}
        self._events = 0L
        #
        self.pt_ = 'pt_' + var_
        self.y_ = 'y_' + var_
        self.m_ = 'm_' + var_
        #
        self.l0_tos = var_ + '_l0tos_1'
        self.l0_tis = var_ + '_l0tis_2'
        #
        self.l1_tos = var_ + '_l1tos_1'
        self.l1_tis = var_ + '_l1tis_2'
        #
        self.l2_tos = var_ + '_l2tos_1'
        self.l2_tis = var_ + '_l2tis_2'

        self._var = var_

        for iPt in pt_axis:

            for iY in y_axis:

                hTotal = histo.Clone(hID())
                hExTos = histo.Clone(hID())
                hTisTos = histo.Clone(hID())
                hExTis = histo.Clone(hID())
                hTob = histo.Clone(hID())

                hTotal  . SetTitle('Total')
                hExTis  . SetTitle('ExTis')
                hExTos  . SetTitle('ExTos')
                hTisTos . SetTitle('Tis&Tos')
                hTob    . SetTitle('Tob')

                self._histos[(iPt, iY)] = [
                    hTotal,
                    hExTos,
                    hTisTos,
                    hExTis,
                    hTob
                ]

        #
        ## global bin
        #
        hTotal = histo.Clone(hID())
        hExTos = histo.Clone(hID())
        hTisTos = histo.Clone(hID())
        hExTis = histo.Clone(hID())
        hTob = histo.Clone(hID())

        hTotal  . SetTitle('Total')
        hExTis  . SetTitle('ExTis')
        hExTos  . SetTitle('ExTos')
        hTisTos . SetTitle('Tis&Tos')
        hTob    . SetTitle('Tob')

        self._histos0 = [
            hTotal,
            hExTos,
            hTisTos,
            hExTis,
            hTob
        ]

        #
        # progress bar
        #
        self._progress = None
        self._events = 0