Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a model for double gaussian? #9

Open
ch2ohch2oh opened this issue Nov 15, 2019 · 0 comments
Open

Add a model for double gaussian? #9

ch2ohch2oh opened this issue Nov 15, 2019 · 0 comments

Comments

@ch2ohch2oh
Copy link

Can we have a model for double Gaussian? A double Gaussian is the sum of two Gaussians with the same mean. I tried the code below but it did not work.

class DoubleGauss(pyroofit.PDF):
    def __init__(self,
                 observable,
                 mean = (-1, 0, 1),
                 sigma = (0, 1),
                 sigma_ratio = (1, 10),
                 name = 'double_gaussian',
                 **kwds):
        # observable is the variable in the dataframe i.e. mass
        super(DoubleGauss, self).__init__(name = name, **kwds)
        
        x = self.add_observable(observable)
        
        # Add parameters
        mean = self.add_parameter(mean, "mean")
        sigma1 = self.add_parameter(sigma, "sigma1")
        s2overs1 = self.add_parameter(sigma_ratio, "s2overs1")
        sigma2 = ROOT.RooFormulaVar("sigma2", "sigma2", "@0 * @1", ROOT.RooArgList(sigma1, s2overs1))
        sigma2 = self.add_parameter(sigma2, "sigma2")
        sig1 = Gauss(x, mean, sigma1, name = 'Narrow Gaussian')
        sig2 = Gauss(x, mean, sigma2, name = 'Wide Gaussian')
        total = sig1 + sig2
        self.roo_pdf = total.roo_pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant