def __init__( self, name, ## the name x, ## the variable k=None, ## k-parameter theta=None): ## theta-parameter # PDF.__init__(self, name) # self.x = x self.mass = x ## ditto # self.k = makeVar(k, 'k_%s' % name, 'k_{#Gamma}(%s)' % name, k, 1, 1.e-3, 100) self.theta = makeVar(theta, 'theta_%s' % name, '#theta_{#Gamma}(%s)' % name, theta, 1, 1.e-3, 100) if self.k.getMin() <= 0: self.k.setMin(1.e-3) logger.warning('GammaDist(%s): min(k) is set %s ' % (name, self.k.getMin())) if self.theta.getMin() <= 0: theta.setMin(1.e-3) logger.warning('GammaDist(%s): min(theta) is set %s ' % (name, self.theta.getMin())) self.pdf = Ostap.Models.GammaDist('gd_%s' % name, 'GammaDist(%s)' % name, self.x, self.k, self.theta)
def __init__(self, name, xvar, right, x0, nu, sigma): PDF.__init__(self, name, xvar=xvar) self.__x0 = self.make_var(x0, 'x0_%s' % name, '#x_{0}(%s)' % name, x0, x0) self.__nu = self.make_var(nu, 'nu_%s' % name, '#nu_{CB}(%s)' % name, nu, nu, 0, 1000) self.__sigma = self.make_var(sigma, 'sigma_%s' % name, '#sigma_{CB}(%s)' % name, sigma, sigma, 0, 1.e+6) self.__right = True if right else False self.pdf = Ostap.Models.CutOffStudent( self.roo_name('cofs_'), "Student's t-like cut-off %s" % self.name, self.xvar, self.right, self.x0, self.nu, self.sigma) ## save the configuration self.config = { 'name': self.name, 'xvar': self.xvar, 'right': self.right, 'x0': self.x0, 'nu': self.nu, 'sigma': self.sigma, }
def __init__( self, name, ## the name mass, ## the variable L, ## L N, ## N left=None, right=None): ## # ## initialize the base PDF.__init__(self, name) # self.mass = mass # mmin = mass.getMin() mmax = mass.getMax() # self.left = makeVar(left, 'left_%s' % name, 'm_{left}(%s)' % name, left, 0.9 * mmin + 0.1 * mmax, mmin, mmax) self.right = makeVar(right, 'right_%s' % name, 'm_{right}(%s)' % name, right, 0.1 * mmin + 0.9 * mmax, mmin, mmax) if self.left.getMin() >= self.mass.getMax(): logger.error('PSNL_pdf(%s): invalid setting!' % name) if self.right.getMax() <= self.mass.getMax(): logger.error('PSNL_pdf(%): invalid setting!' % name) self.pdf = Ostap.Models.PhaseSpaceNL('psnl_%s' % name, 'PhaseSpaceNL(%s)' % name, self.mass, self.left, self.right, L, N)
def __init__( self, name, ## the name x, ## the variable shape=None, ## shape-parameter high=None, ## high-parameter low=0): ## low-parameter # PDF.__init__(self, name) # self.x = x self.mass = x ## ditto # self.shape = makeVar(shape, 'shape_%s' % name, '#chi_{Argus}(%s)' % name, shape, 1, 1.e-4, 20) self.high = makeVar(high, 'high_%s' % name, 'high_{Argus}(%s)' % name, high, 0.1 * self.x.getMin() + 0.9 * self.x.getMax(), self.x.getMin(), self.x.getMax()) _dm = self.x.getMax() - self.x.getMin() lmin = min(0, self.x.getMin() - 10 * _dm) lmax = self.x.getMax() + 10 * _dm self.low = makeVar(low, 'low_%s' % name, 'low_{Argus}(%s)' % name, low, 0.9 * self.x.getMin() + 0.1 * self.x.getMax(), lmin, lmax) logger.debug('ARGUS shape %s' % self.shape) logger.debug('ARGUS high %s' % self.high) logger.debug('ARGUS low %s' % self.low) self.pdf = Ostap.Models.Argus('arg_%s' % name, 'Argus(%s)' % name, self.x, self.shape, self.high, self.low)
def __init__( self, name, ## the name x, ## the variable theta=None, ## theta-parameter alpha=None, ## alpha-parameter beta=None, ## beta-parameter a=None): ## s-parameter # PDF.__init__(self, name) # self.x = x self.mass = x ## ditto # self.theta = makeVar(theta, 'theta_%s' % name, '#theta_{Amoroso}(%s)' % name, theta, 1, 1.e-3, 100) self.alpha = makeVar(alpha, 'alpha_%s' % name, '#alpha_{Amoroso}(%s)' % name, alpha, 1, 1.e-3, 100) self.beta = makeVar(beta, 'beta_%s' % name, '#beta_{Amoroso}(%s) ' % name, beta, 1, 1.e-3, 10) self.a = makeVar(a, 'a_%s' % name, 'a_{Amoroso}(%s)' % name, a, 1, -10, 10) logger.debug('Amoroso theta %s' % self.theta) logger.debug('Amoroso alpha %s' % self.alpha) logger.debug('Amoroso beta %s' % self.beta) logger.debug('Amoroso a %s' % self.a) self.pdf = Ostap.Models.Amoroso('amo_%s' % name, 'Amoroso(%s)' % name, self.x, self.theta, self.alpha, self.beta, self.a)
def __init__( self, name, ## the name x, ## the variable scale=1, ## scale-parameter delta=0): ## shift-parameter # PDF.__init__(self, name) # self.x = x self.mass = x ## ditto # self.scale = makeVar(scale, 'scale_%s' % name, '#theta_{Landau}(%s)' % name, scale, 1, -1000, 1000) _dm = self.x.getMax() - self.x.getMin() self.delta = makeVar(delta, 'delta_%s' % name, '#delta_{Landau}(%s)' % name, delta, 0, self.x.getMin() - 10 * _dm, self.x.getMax() + 10 * _dm) logger.debug('Landau scale %s' % self.scale) logger.debug('Landau delta %s' % self.delta) self.pdf = Ostap.Models.Landau('land_%s' % name, 'Landau(%s)' % name, self.x, self.scale, self.delta)
def __init__( self, name, ## the name mass, ## the variable power=2, ## degree of the polynomial alpha=None, ## x0=None): # PDF.__init__(self, name) # self.power = power self.mass = mass xmin = mass.getMin() xmax = mass.getMax() dx = xmax - xmin alpmx = 2000.0 / dx self.alpha = makeVar(alpha, 'alpha_%s' % name, 'alpha(%s)' % name, alpha, 0, -alpmx, alpmx) self.x0 = makeVar(x0, 'x0_%s' % name, 'x0(%s)' % name, x0, 0.5 * (xmax + xmin), xmin - 0.1 * dx, xmax + 0.1 * dx) # self.makePhis(power) self.pdf = Ostap.Models.PolySigmoid('ps_%s' % name, 'PolySigmoid(%s)' % name, self.mass, self.phi_list, self.mass.getMin(), self.mass.getMax(), self.alpha, self.x0)
def __init__( self, name, ## the name x, ## the variable alpha=None, ## shape-parameter delta=None, ## high-parameter x0=0): ## low-parameter # PDF.__init__(self, name) # self.x = x self.mass = x ## ditto # self.alpha = makeVar(alpha, 'alpha_%s' % name, '#alpha_{2e}(%s)' % name, alpha, 1, 1.e-4, 50) self.delta = makeVar(delta, 'delta_%s' % name, '#delta_{2e}(%s)' % name, delta, 1, 1.e-4, 50) xmin = self.x.getMin() xmax = self.x.getMin() dx = xmax - xmin self.x0 = makeVar(x0, 'x0_%s' % name, 'x0_{2e}(%s)' % name, x0, xmin, xmin - 0.1 * dx, xmax + 0.1 * dx) logger.debug('2expos alpha %s' % self.alpha) logger.debug('2expos delta %s' % self.delta) logger.debug('2expos x0 %s' % self.x0) self.pdf = Ostap.Models.TwoExpos('exp2_%s' % name, '2Expos(%s)' % name, self.x, self.alpha, self.delta, self.x0)
def __init__( self, pt, ## pT-variable (for fitting) mass=0, ## particle mass (may be fixed) n=None, ## shape parameter T=None, ## temperature parameter name=''): ## initialize the base PDF.__init__(self, name) if not isinstance(pt, ROOT.RooAbsReal): raise AttributeError("Tsallis(%s): invalid 'pt'-parameter %s" % (name, pt)) self.pt = pt self.m = self.pt self.mass = self.pt self.m0 = makeVar(mass, 'm0_%s' % name, 'm0(%s)' % name, mass, 0, 1e+6) self.n = makeVar(n, 'n_%s' % name, 'n(%s) ' % name, n, 0.01, 1000) self.n = makeVar(T, 'n_%s' % name, 'n(%s) ' % name, n, 1.e-3, 1e+6) self.pdf = Ostap.Models.Tsallis('tsallis_' + name, 'Tsallis(%s)' % name, self.pt, self.n, self.T, self.m0)
def __init__(self, name, xvar, right, x0, sigma): PDF.__init__(self, name, xvar=xvar) self.__x0 = self.make_var(x0, 'x0_%s' % name, '#x_{0}(%s)' % name, x0, x0) self.__sigma = self.make_var(sigma, 'csigma_%s' % name, '#sigma_{CB}(%s)' % name, sigma, sigma, 0, 1.e+6) self.__right = True if right else False self.pdf = Ostap.Models.CutOffGauss(self.roo_name('cofg_'), 'Gaussian cut-off %s' % self.name, self.xvar, self.right, self.x0, self.sigma) ## save the configuration self.config = { 'name': self.name, 'xvar': self.xvar, 'x0': self.x0, 'right': self.right, 'sigma': self.sigma, }
def __init__( self, pdf, ## the PDF to be convoluted resolution, ## the convolution/resolution xvar=None, ## the axis varable useFFT=True, ## use FastFourierTransform? nbins=1000000, ## #bins for FFT buffer=0.25, ## buffer fraction ## setBufferFraction nsigmas=6, ## number of sigmas for setConvolutionWindow name=''): ## the name self.__arg_pdf = pdf self.__arg_resolution = resolution self.__arg_xvar = xvar if isinstance(pdf, PDF): self.__old_pdf = pdf xvar = pdf.xvar elif isinstance(pdf, ROOT.RooAbsPdf) and xvar: self.__old_pdf = Generic1D_pdf(pdf, xvar) else: raise AttributeError("Convolution_pdf: invalid pdf/xvar %s/%s" % (pdf, xvar)) name = name if name else 'Cnv_%s' % pdf.name ## initialize the base PDF.__init__(self, name, xvar) em = pdf.pdf.extendMode() if 1 == em: self.warning("PDF ``canBeExtended''") elif 2 == em: self.error("PDF ``mustBeExtended''") ## make the actual convolution self.__cnv = Convolution(name=name, pdf=self.old_pdf.pdf, xvar=xvar, resolution=resolution, useFFT=useFFT, nbins=nbins, buffer=buffer, nsigmas=nsigmas) self.pdf = self.__cnv.pdf ## save configuration self.config = { 'name': self.name, 'xvar': self.xvar, 'pdf': self.old_pdf, 'resolution': self.cnv.resolution, 'useFFT': self.cnv.useFFT, 'nbins': self.cnv.nbinsFFT, 'buffer': self.cnv.buffer, 'nsigmas': self.cnv.nsigmas, }
def __init__( self, name, ## the name mass, ## the variable alpha=None, ## the slope of the first exponent delta=None, ## (alpha+delta) is the slope of the first exponent x0=0, ## f(x)=0 for x<x0 power=0, ## degree of polynomial tau=None): ## # PDF.__init__(self, name) # self.mass = mass self.power = power # mn, mx = mass.minmax() mc = 0.5 * (mn + mx) taumax = 100 # if not iszero(mn): taumax = 100.0 / abs(mn) if not iszero(mc): taumax = min(taumax, 100.0 / abs(mc)) if not iszero(mx): taumax = min(taumax, 100.0 / abs(mx)) # ## the exponential slope # self.alpha = makeVar(alpha, "alpha_%s" % name, "#alpha(%s)" % name, alpha, 1, 0, taumax) self.delta = makeVar(delta, "delta_%s" % name, "#delta(%s)" % name, delta, 1, 0, taumax) self.x0 = makeVar(x0, "x0_%s" % name, "x_{0}(%s)" % name, x0, mn, mn - 0.5 * (mx - mn), mx + 0.5 * (mx - mn)) # # if 0 >= self.power: self.phis = [] self.phi_list = ROOT.RooArgList() self.pdf = ROOT.RooExponential('exp_%s' % name, 'exp(%s)' % name, mass, self.tau) else: # self.makePhis(power) # self.pdf = Ostap.Models.TwoExpoPositive( '2expopos_%s' % name, '2expopos(%s)' % name, mass, self.alpha, self.delta, self.x0, self.phi_list, mass.getMin(), mass.getMax())
def __init__( self, name, ## the name x, ## the variable alpha=None, ## alpha-parameter beta=None, ## beta-parameter scale=1, ## scale-parameter delta=0): ## shift-parameter # PDF.__init__(self, name) # self.x = x self.mass = x ## ditto # self.alpha = makeVar(alpha, 'alpha_%s' % name, '#alpha_{#beta#prime}(%s)' % name, alpha, 1, 1.e-3, 1000) self.beta = makeVar(beta, 'beta_%s' % name, '#beta_{#beta#prime}(%s)' % name, beta, 1, 1.e-3, 1000) if self.alpha.getMin() <= 0: self.alpha.setMin(1.e-3) logger.warning('BetaPrime(%s): min(alpha) is set %s ' % (name, self.alpha.getMin())) if self.beta.getMin() <= 0: self.beta.setMin(1.e-3) logger.warning('BetaPrime(%s): min(beta) is set %s ' % (name, self.beta.getMin())) self.scale = makeVar(scale, 'scale_%s' % name, '#theta_{#beta#prime}(%s)' % name, scale, 1, -1000, 1000) _dm = self.x.getMax() - self.x.getMin() self.delta = makeVar(delta, 'delta_%s' % name, '#delta_{#beta#prime}(%s)' % name, delta, 0, self.x.getMin() - 10 * _dm, self.x.getMax() + 10 * _dm) logger.debug("Beta' alpha %s" % self.alpha) logger.debug("Beta' beta %s" % self.beta) logger.debug("Beta' scale %s" % self.scale) logger.debug("Beta' sdelta %s" % self.delta) self.pdf = Ostap.Models.BetaPrime('bp_%s' % name, 'BetaPrime(%s)' % name, self.x, self.alpha, self.beta, self.scale, self.delta)
def __init__( self, name, ## the name mass, ## the variable power=0, ## degree of polynomial tau=None, ## exponential slope the_phis=None): ## the phis... # PDF.__init__(self, name) # self.mass = mass self.power = power # mn, mx = mass.minmax() mc = 0.5 * (mn + mx) taumax = 100 # if not iszero(mn): taumax = 100.0 / abs(mn) if not iszero(mc): taumax = min(taumax, 100.0 / abs(mc)) if not iszero(mx): taumax = min(taumax, 100.0 / abs(mx)) # ## the exponential slope # self.tau = makeVar(tau, "tau_%s" % name, "tau(%s)" % name, tau, 0, -taumax, taumax) # if the_phis: ## copy phis self.makePhis(power, the_phis=the_phis) ## copy phis elif 0 >= self.power: self.phis = [] self.phi_list = ROOT.RooArgList() self.pdf = ROOT.RooExponential('exp_%s' % name, 'exp(%s)' % name, mass, self.tau) else: # self.makePhis(power) # self.pdf = Ostap.Models.ExpoPositive('expopos_%s' % name, 'expopos(%s)' % name, mass, self.tau, self.phi_list, mass.getMin(), mass.getMax())
def __init__( self, pdf, ## template PDF of "old" variabe new_var, ## old variable as function of a new variable jacob=None, ## absolute value of the Jacobian: |d(old)/d(new)| name=''): ## proposed name assert pdf and isinstance(pdf, PDF), 'Invalid PDF type %s' % type(pdf) assert new_var and isinstance( new_var, FUNC), 'Invalid new_var type %s' % type(new_var) xvar = new_var.xvar name = name if name else "Transform_%s" % pdf.name PDF.__init__(self, name, xvar=xvar) if not jacob: jacob = abs(new_var.dFdX()) assert isinstance(jacob, FUNC), 'Invalid Jacobian %s' % type(jacob) if not xvar in jacob: self.warning('Jacobian has does not depend on xvar!') self.__jacob = jacob self.__new_var = new_var self.__ori_pdf = pdf self.__clo_pdf = pdf.clone(xvar=new_var.fun) ## new PDF as a function self.__new_fun = var_mul(jacob.fun, self.__clo_pdf.pdf) from ostap.fitting.basic import make_pdf self.__new_pdf = make_pdf(self.__new_fun, [xvar], self.name + '_') ## finally the new PDF: self.pdf = self.__new_pdf.pdf self.config = { 'name': self.name, 'pdf': self.orig_pdf, 'new_var': self.new_var, 'jacob': self.jacob, } self.checked_keys.add('pdf') self.checked_keys.add('new_var') self.checked_keys.add('jacob')
def __init__( self, name, ## the name pdf, ## the PDF to be convoluted resolution, ## the resolution xvar=None, ## the axis varable useFFT=True, ## use FastFourierTransform? nbins=1000000, ## #bins for FFT buffer=0.25, ## buffer fraction ## setBufferFraction nsigmas=6): ## number of sigmas for setConvolutionWindow if isinstance(pdf, PDF): xvar = pdf.xvar elif isinstance(pdf, ROOT.RooAbsPdf) and isinstance( xvar, ROOT.RooAbsReal): pdf = Generic1D_pdf(pdf, xvar) else: raise AttributeError("Convolution_pdf: invalid pdf/xvar %s/%s" % (pdf, xvar)) ## initialize the base PDF.__init__(self, name, xvar) ## make the actual convolution self.__cnv = Convolution(name=name, pdf=pdf, xvar=xvar, resolution=resolution, useFFT=useFFT, nbins=nbins, buffer=buffer, nsigmas=nsigmas) self.pdf = self.__cnv.pdf ## save configuration self.config = { 'name': self.name, 'xvar': self.xvar, 'pdf': self.cnv.old_pdf, 'resolution': self.cnv.resolution, 'useFFT': self.cnv.useFFT, 'nbins': self.cnv.nbinsFFT, 'buffer': self.cnv.buffer, 'nsigmas': self.cnv.nsigmas, }
def __init__( self, name, ## the name mass, ## the variable m1, ## mass the first particle (const) m2, ## mass the second particle (const) m3, ## mass the third particle (const) m, ## mass of the whole system (const) L, ## orbital momenutm between (1,2) and 3 l=0): ## orbital momentum between 1 and 2 # ## initialize the base PDF.__init__(self, name) # self.mass = mass self.pdf = Ostap.Models.PhaseSpace23L('ps23l_%s' % name, 'PhaseSpace23L(%s)' % name, self.mass, m1, m2, m3, m, L, l)
def __init__( self, name, ## the name mass, ## the variable spline): ## the spline object Ostap::Math::ConvexOnlySpline # PDF.__init__(self, name) # self.spline = spline self.mass = mass # self.makePhis(spline.npars()) # self.pdf = Ostap.Models.ConvexOnlySpline('is_%s' % name, 'ConvexOnlySpline(%s)' % name, self.mass, self.spline, self.phi_list)
def __init__( self, name, ## the name x, ## the variable k=None, ## k-parameter theta=None, ## theta-parameter p=None, ## p-parameter low=None): ## low-parameter # PDF.__init__(self, name) # self.x = x self.mass = x ## ditto # self.k = makeVar(k, 'k_%s' % name, 'k_{#Gamma}(%s)' % name, k, 1, 1.e-3, 100) self.theta = makeVar(theta, 'theta_%s' % name, '#theta_{#Gamma}(%s)' % name, theta, 1, 1.e-3, 100) self.p = makeVar(p, 'p_%s' % name, 'p_{#Gamma}(%s)' % name, p, 1, 1.e-3, 6) self.low = makeVar(low, 'low_%s' % name, 'l_{#Gamma}(%s)' % name, low, min(0, x.getMin()), x.getMax()) if self.k.getMin() <= 0: self.k.setMin(1.e-3) logger.warning('GenGammaDist(%s): min(k) is set %s ' % (name, self.k.getMin())) if self.theta.getMin() <= 0: self.theta.setMin(1.e-3) logger.warning('GenGammaDist(%s): min(theta) is set %s ' % (name, self.theta.getMin())) if self.p.getMin() <= 0: self.p.setMin(1.e-3) logger.warning('GenGammaDist(%s): min(p) is set %s ' % (name, self.p.getMin())) self.pdf = Ostap.Models.GenGammaDist('ggd_%s' % name, 'GenGammaDist(%s)' % name, self.x, self.k, self.theta, self.p, self.low)
def __init__( self, name, ## the name mass, ## the varibale power=1): ## (half)degree of the polynomial # PDF.__init__(self, name) # self.power = power self.mass = mass # self.makePhis(power) self.pdf = Ostap.Models.PolyPositiveEven('ppe_%s' % name, 'PolyPositiveEven(%s)' % name, self.mass, self.phi_list, self.mass.getMin(), self.mass.getMax())
def __init__( self, name, ## the name mass, ## the varibale m1, ## the first mass (constant) m2): ## the second mass (constant) # ## initialize the base PDF.__init__(self, name) # if hasattr(mass, 'getMax') and mass.getMax() < abs(m1) + abs(m2): logger.error('PS2_pdf(%s): senseless setting of edges/threshold' % self.name) self.mass = mass self.pdf = Ostap.Models.PhaseSpace2('ps2_%s' % name, 'PhaseSpace2(%s)' % name, self.mass, m1, m2)
def __init__( self, name, ## the name mass, ## the variable power=2, ## degree of the polynomial convex=True): ## convex or concave ? # PDF.__init__(self, name) # self.power = power self.mass = mass self.convex = convex # self.makePhis(power) self.pdf = Ostap.Models.PolyConvexOnly('pp_%s' % name, 'PolyConvex(%s)' % name, self.mass, self.phi_list, self.mass.getMin(), self.mass.getMax(), self.convex)
def __init__( self, name, ## the name mass, ## the variable N, ## N left=None): # ## initialize the base PDF.__init__(self, name) # self.mass = mass self.left = makeVar(left, 'left_%s' % name, 'm_left(%s)' % name, None, mass.getMin(), mass.getMax()) if self.left.getMin() >= self.mass.getMax(): logger.error('PSLeft_pdf(%s): invalid setting!' % name) self.pdf = Ostap.Models.PhaseSpaceLeft('psl_%s' % name, 'PhaseSpaceLeft(%s)' % name, self.mass, self.left, N)
def __init__( self, name, ## the name mass, ## the variable power=2, ## degree of the polynomial increasing=True): ## increasing or decreasing ? # PDF.__init__(self, name) # self.power = power self.mass = mass self.increasing = increasing # self.makePhis(power) self.pdf = Ostap.Models.PolyMonothonic('pp_%s' % name, 'PolyMonothonic(%s)' % name, self.mass, self.phi_list, self.mass.getMin(), self.mass.getMax(), self.increasing)
def __init__( self, name, ## the name mass, ## the variable L, ## L N, ## N right=None): # ## initialize the base PDF.__init__(self, name) # self.mass = mass self.right = makeVar(right, 'right_%s' % name, 'm_{right}(%s)' % name, None, mass.getMin(), mass.getMax()) if self.right.getMax() <= self.mass.getMax(): logger.error('PSRight_pdf(%s): invalid setting!' % name) self.pdf = Ostap.Models.PhaseSpaceRight('psr_%s' % name, 'PhaseSpaceRight(%s)' % name, self.mass, self.right, L, N)
def __init__( self, name, ## the name x, ## the variable nu=None, ## nu-parameter lam=None, ## lambda-parameter alpha=None): ## nu-parameter # PDF.__init__(self, name) # self.x = x self.mass = x ## ditto # xmin = self.x.getMin() xmax = self.x.getMax() dx = xmax - xmin # self.nu = makeVar(nu, 'nu_%s' % name, '#nu_{#log#Gamma}(%s)' % name, nu, 0.5 * (xmin + xmax), xmin - 10 * dx, xmax + 10 * dx) self.lam = makeVar(lam, 'lambda_%s' % name, '#lambda_{#log#Gamma}(%s)' % name, lam, 2, -1000, 1000) self.alpha = makeVar(alpha, 'alpha_%s' % name, '#alpha_{#log#Gamma}(%s)' % name, alpha, 1, 1.e-3, 1000) if self.alpha.getMin() <= 0: self.alpha.setMin(1.e-3) logger.warning('LogGamma(%s): min(alpha) is set %s ' % (name, self.alpha.getMin())) logger.debug('LogGamma nu %s' % self.nu) logger.debug('LogGamma lambda %s' % self.lam) logger.debug('LogGamma alpha %s' % self.alpha) self.pdf = Ostap.Models.LogGamma('lg_%s' % name, 'LogGamma(%s)' % name, self.x, self.nu, self.lam, self.alpha)
def __init__(self, pdf, xvar=None, fraction=1.e-5, name=''): if isinstance(pdf, PDF): self.__old_pdf = pdf if xvar and not xvar is pdf.xvar: self.warning("mismatch in xvar?") xvar = pdf.xvar elif insinstance(pdf, ROOT.RooAbsPdf) and xvar: self.__old_pdf = Generic1D_pdf(pdf, xvar=xvar) else: raise TypeError("Unknown type of pdf %s/%s" % (pdf, type(pdf))) assert isinstance(xvar, ROOT.RooAbsReal), "``xvar'' must be ROOT.RooAbsReal" name = name if name else self.generate_name('Adjust1D_' + self.old_pdf.name) ## initialize the base PDF.__init__(self, name=name, xvar=xvar) em = self.old_pdf.pdf.extendMode() if 1 == em: self.warning("PDF ``canBeExtended''") elif 2 == em: self.warning("PDF ``mustBeExtended''") ## make the real adjustment self.__adjustment = Adjust1D(name, pdf=self.old_pdf.pdf, xvar=xvar, fraction=fraction) self.pdf = self.adjustment.pdf self.config = { 'xvar': self.xvar, 'name': self.name, 'pdf': self.old_pdf, 'fraction': self.fraction }
def __init__( self, name, ## the name mass, ## the varibale phasespace, ## Ostap::Math::PhaseSpaceNL power=1): ## degree of the polynomial # PDF.__init__(self, name) # self.mass = mass self.ps = phasespace ## Ostap::Math::PhaseSpaceNL self.power = power # self.makePhis(power) # self.pdf = Ostap.Models.PhaseSpacePol( 'pspol_%s' % name, 'PhaseSpacePol(%s)' % name, self.mass, self.ps, ## Ostap::Math::PhaseSpaceNL self.phi_list)
def __init__( self, pt, ## pT-variable (for fitting) mass=0, ## particle mass (may be fixed) b=None, ## slope parameter name=''): ## initialize the base PDF.__init__(self, name) if not isinstance(pt, ROOT.RooAbsReal): raise AttributeError("QGSM(%s): invalid 'pt'-parameter %s" % (name, pt)) self.pt = pt self.m = self.pt self.mass = self.pt self.m0 = makeVar(mass, 'm0_%s' % name, 'm0(%s)' % name, mass, 0, 1e+6) self.b = makeVar(b, 'b_%s' % name, 'b(%s) ' % name, b, 0., 1e+6) self.pdf = Ostap.Models.QGSM('qgsm_' + name, 'QGSM(%s)' % name, self.pt, self.b, self.m0)
def __init__ ( self , pdf , ## the PDF to be convoluted resolution , ## the convolution/resolution xvar = None , ## the axis varable useFFT = True , ## use FastFourierTransform? nbins = 2**14 , ## #bins for FFT buffer = 0.25 , ## buffer fraction ## setBufferFraction bufstrat = None , ## "Buffer strategy" : (0,1,2) nsigmas = 6 , ## number of sigmas for setConvolutionWindow name = '' ) : ## the name self.__arg_pdf = pdf self.__arg_resolution = resolution self.__arg_xvar = xvar if isinstance ( pdf , PDF ) : self.__old_pdf = pdf xvar = pdf.xvar elif isinstance ( pdf , ROOT.RooAbsPdf ) and xvar : self.__old_pdf = Generic1D_pdf ( pdf , xvar ) else : raise AttributeError ("Convolution_pdf: invalid pdf/xvar %s/%s" % ( pdf , xvar ) ) em = self.old_pdf.pdf.extendMode () if 1 == em : self.warning ( "PDF ``canBeExtended''" ) elif 2 == em : self.error ( "PDF ``mustBeExtended''" ) ## make the actual convolution if isinstance ( resolution , Convolution ) : assert resolution.xvar is xvar, "Mismatch in ``xvar'': %s vs %s" % ( xvar , resolution.xvar ) self.__cnv = resolution else : self.__cnv = Convolution ( name = '' , pdf = self.old_pdf.pdf , xvar = xvar , resolution = resolution , useFFT = useFFT , nbins = nbins , buffer = buffer , bufstrat = bufstrat , nsigmas = nsigmas ) name = name if name else self.generate_name ( prefix = 'Cnv_%s@%s_' % ( pdf.name , self.resolution.name ) ) ## initialize the base PDF.__init__ ( self , name , xvar ) ## the actual convoluted PDF self.pdf = self.__cnv.pdf ## save configuration self.config = { 'name' : self.name , 'xvar' : self.xvar , 'pdf' : self.old_pdf , 'resolution' : self.cnv.resolution , 'useFFT' : self.cnv.useFFT , 'nbins' : self.cnv.nbinsFFT , 'buffer' : self.cnv.buffer , 'bufstrat' : self.cnv.bufstrat , 'nsigmas' : self.cnv.nsigmas , }