Пример #1
0
def gammaDistTF1(ptmax, ptmin=0, mass=None, name=''):
    """
    Create GammaDist function (as TF1) for fitting pt-spectra
    >>> histo =
    >>> fun   = gammaDistTF1 ( ptmax = 50 )
    >>> histo.Fit( fun , 'SI' )
    """
    if ptmax <= ptmin:
        raise ArrtibuteError("GammaDist/TF1: wrong ptmin/ptmax: %s/%s" %
                             (ptmin, ptmax))

    obj = GammaDistFun(ptmax, ptmin)
    if not name: name = funID()
    func = ROOT.TF1(name, obj, ptmin, ptmax, 3)
    func._obj = obj
    func.SetParNames(
        'norm',  ## 0
        'k',  ## 1 
        'theta')  ## 2
    ##
    func.SetParameter(0, 1)  ## norm
    func.SetParameter(1, 2)
    func.SetParameter(2, 2)
    ##
    return func
Пример #2
0
def qgsmTF1(ptmax, ptmin=0, mass=None, name=''):
    """
    Create QGSM functin (as TF1) for fitting pt-spectra
    
    >>> histo =
    >>> fun   = qgsmTF1 ( ptmax = 50 )
    >>> histo.Fit( fun , 'SI' )
    """
    if ptmax <= ptmin:
        raise ArrtibuteError("QGSM/TF1: wrong ptmin/ptmax: %s/%s" %
                             (ptmin, ptmax))

    obj = QGSMFun(ptmax, ptmin)
    if not name: name = funID()
    func = ROOT.TF1(name, obj, ptmin, ptmax, 3)
    func._obj = obj
    func.SetParNames(
        'norm',  ## 0
        'm',  ## 1 
        'b')  ## 2
    ##
    if isinstance(mass, float) and 0 <= mass: func.FixParameter(1, mass)
    else: func.SetParameter(1, 0)
    ##
    func.SetParameter(0, 1)  ## norm
    func.SetParameter(2, 1)
    ##
    return func
Пример #3
0
def tsallisTF1(ptmax, ptmin=0, mass=None, name=''):
    """
    create Tsallis function (as TF1) for fitting pt-spectra:
    
    >>> histo =
    >>> fun   = tsallisFun ( ptmax = 50 )
    >>> histo.Fit( fun , 'SI' )    
    """
    if ptmax <= ptmin:
        raise ArrtibuteError("Tsallis/TF1: wrong ptmin/ptmax: %s/%s" %
                             (ptmin, ptmax))

    obj = TsallisFun(ptmax, ptmin)
    if not name: name = funID()
    func = ROOT.TF1(name, obj, ptmin, ptmax, 4)
    func._obj = obj
    func.SetParNames(
        'norm',  ## 0
        'm',  ## 1 
        'n',  ## 2
        'T')  ## 3
    ##
    if isinstance(mass, float) and 0 <= mass: func.FixParameter(1, mass)
    else: func.SetParameter(1, 0)
    ##
    func.SetParameter(0, 1)  ## norm
    func.SetParameter(2, 10)
    func.SetParameter(3, 1.1)
    ##
    return func
Пример #4
0
def _as_TF1_ ( obj , xmin , xmax ) :

    import ROOT 
    from   Ostap.Core import funID
    
    fobj     = _WF1( obj ) 
    fun      = ROOT.TF1( funID() , fobj , xmin , xmax ) 
    fun._obj = fobj
    
    fun.SetNpx(500)
    
    return fun
Пример #5
0
def _as_TF2_ ( obj , xmin , xmax , ymin , ymax ) :

    import ROOT 
    from   Ostap.Core import funID

    fobj       = _WF2(obj) 
    fun        = ROOT.TF2( funID() , fobj , xmin , xmax , ymin , ymax ) 
    fun._obj   = fobj

    fun.SetNpx(250)
    fun.SetNpy(250)
    
    return fun
Пример #6
0
def _tf1_ ( self , *args ) :
    """Convert the function to TF1
    
    >>> obj = ...
    
    >>> fun = obj.tf1 ( 3.0 , 3.2 )
    
    >>> fun.Draw() 
    """
    #
    if not hasattr ( self , '_wo1' ) : self._wo1 = _WO1_ ( self )
    if not self._wo1                 : self._wo1 = _WO1_ ( self )
    ## 
    _wo = self._wo1 
    fun = ROOT.TF1 ( funID()  , _wo , *args )
    fun.SetNpx ( 500 ) 
    #
    return fun 
Пример #7
0
def _tf2_ ( self , *args ) :
    """Convert the function to TF2
    
    >>> obj = ...
    
    >>> fun = obj.tf2 ( 3.0 , 3.2 , 3.0 , 3.2 )
    
    >>> fun.Draw() 
    """
    ##
    if not hasattr ( self , '_wo2' ) : self._wo2 = _WO2_ ( self )
    if not self._wo2                 : self._wo2 = _WO2_ ( self )
    ## 
    _wo = self._wo2
    fun = ROOT.TF2 ( funID ()  , _wo , *args )
    fun.SetNpx ( 100 ) 
    fun.SetNpy ( 100 ) 
    #
    return fun