Пример #1
0
    def get_unbound_pdf(self, name, title):
        """Get the physics PDF.

        Return:
            ROOT.BifurcatedCB.

        """
        return load_pdf_by_name('BifurcatedCB')(
            name, title, *(self.get_observables() + self.get_fit_parameters()))
Пример #2
0
    def get_unbound_pdf(self, name, title):
        """Get the physics PDF.

        Return:
            ROOT.RooIpatia2.

        """
        return load_pdf_by_name('RooIpatia2', True)(
            name, title, *(self.get_observables() + self.get_fit_parameters()))
Пример #3
0
def action_BLINDRATIO(name, title, action_params, external_vars):
    """Configure a ratio between two variables.

    The first is the numerator, the second the denominator. At least needs to be a shared variable,
    and currently two constrained variables are not possible.
    The third is a randomization string; the fourth a mean and the fifth a width.

    """
    from analysis.utils.pdf import load_pdf_by_name
    Ratio = load_pdf_by_name('RooRatio')

    if len(action_params) != 5:
        raise ValueError(
            "Wrong number of arguments for BLINDRATIO -> {}".format(
                action_params))
    if not any(v.startswith('@') for v in action_params):
        raise ValueError(
            "At least one parameter of a BLINDRATIO must be a reference")
    constraint = None
    processed_vars = []
    for variable in action_params[:2]:
        if variable.startswith('@'):
            processed_variable, const = external_vars[variable[1:]]
            if const:
                if not constraint:
                    constraint = const
                else:
                    raise NotImplementedError(
                        "Two constrained variables in SCALE are not allowed")
        elif ':' in variable:
            from analysis.fit.result import FitResult
            fit_name, var_name = variable.split(':')
            result = FitResult.from_yaml_file(fit_name)
            try:
                value = result.get_fit_parameter(var_name)[0]
            except KeyError:
                value = result.get_const_parameter(var_name)
            processed_variable = ROOT.RooFit.RooConst(value)
        else:
            processed_variable = ROOT.RooFit.RooConst(float(variable))
        processed_vars.append(processed_variable)
    parameter = Ratio(name, title, *processed_vars)
    blind_str, blind_central, blind_sigma = action_params[2:]
    ref_var = deepcopy(parameter)
    parameter = ROOT.RooUnblindPrecision(name + "_blind", title + "_blind",
                                         blind_str, float(blind_central),
                                         float(blind_sigma), ref_var)
    return parameter, constraint
Пример #4
0
def action_RATIO(name, title, action_params, external_vars):
    """Configure a ratio between two variables.

    The first is the numerator, the second the denomiator. At least needs to be a shared variable,
    and currently two constrained variables are not possible.

    """
    from analysis.utils.pdf import load_pdf_by_name
    Ratio = load_pdf_by_name('RooRatio')

    if len(action_params) != 2:
        raise ValueError(
            "Wrong number of arguments for RATIO -> {}".format(action_params))
    if not any(v.startswith('@') for v in action_params):
        raise ValueError(
            "At least one parameter of a RATIO must be a reference")
    constraint = None
    processed_vars = []
    for variable in action_params:
        if variable.startswith('@'):
            processed_variable, const = external_vars[variable[1:]]
            if const:
                if not constraint:
                    constraint = const
                else:
                    raise NotImplementedError(
                        "Two constrained variables in SCALE are not allowed")
        elif ':' in variable:
            from analysis.fit.result import FitResult
            fit_name, var_name = variable.split(':')
            result = FitResult.from_yaml_file(fit_name)
            try:
                value = result.get_fit_parameter(var_name)[0]
            except KeyError:
                value = result.get_const_parameter(var_name)
            processed_variable = ROOT.RooFit.RooConst(value)
        else:
            processed_variable = ROOT.RooFit.RooConst(float(variable))
        processed_vars.append(processed_variable)
    parameter = Ratio(name, title, *processed_vars)
    return parameter, constraint