<commit_before>from .. import Load, DirFromEnv, Nminus1Cut

newRatioComparer = Load('RatioComparison')
plotter          = newRatioComparer()


def SetupFromEnv(aPlotter=plotter):
    """A function that sets up a plotter after sourcing a config file.

    @param aPlotter is the plotter to setup. Defaults to plotter in this module.
    """
    from ..CommonTools.FileConfigReader import SetupConfigFromEnv, SetFunctionFromEnv

    SetupConfigFromEnv(aPlotter)

    DirFromEnv('CrombieOutPlotDir')
    SetFunctionFromEnv([
            (aPlotter.SetOutDirectory, 'CrombieOutPlotDir'),
            ])


def SetCuts(category1, region1, region2, category2=None, aPlotter=plotter):
    """ Sets cuts based on category and region.

    @param category1 is the category of the analysis being used.
    @param region1 is the region of the numerator.
    @param region2 is the region of the denominator.
    @param category2 if set, is the category of the denominator.
                     Otherwise, the category is assumed to be the same
    @param aPlotter is the plotter that is having its cuts set.
                    Default is the plotter defined in this module.
    """

    category2 = category2 or category1

    from ..LoadConfig import cuts

    numerator_cut = cuts.cut(category1, region1)
    denominator_cut = cuts.cut(category2, region2)

    aPlotter.AddRatioCuts(numerator_cut + ' && ' + cuts.dataMCCuts(region1, True),
                          denominator_cut + ' && ' + cuts.dataMCCuts(region2, True),
                          aPlotter.kData, 'Data', 1)

    aPlotter.AddRatioCuts(numerator_cut + ' * ' + cuts.dataMCCuts(region1, False),
                          denominator_cut + ' * ' + cuts.dataMCCuts(region2, False),
                          aPlotter.kBackground, 'MC', 2)

    aPlotter.SetDataIndex(0)
    aPlotter.SetRatioIndex(1)<commit_msg>Add Nminus1 cut.<commit_after>from .. import Load, DirFromEnv, Nminus1Cut

newRatioComparer = Load('RatioComparison')
plotter          = newRatioComparer()


def SetupFromEnv(aPlotter=plotter):
    """A function that sets up a plotter after sourcing a config file.

    @param aPlotter is the plotter to setup. Defaults to plotter in this module.
    """
    from ..CommonTools.FileConfigReader import SetupConfigFromEnv, SetFunctionFromEnv

    SetupConfigFromEnv(aPlotter)

    DirFromEnv('CrombieOutPlotDir')
    SetFunctionFromEnv([
            (aPlotter.SetOutDirectory, 'CrombieOutPlotDir'),
            ])


def SetCuts(category1, region1, region2, category2=None, aPlotter=plotter, Nminus1=''):
    """ Sets cuts based on category and region.

    @param category1 is the category of the analysis being used.
    @param region1 is the region of the numerator.
    @param region2 is the region of the denominator.
    @param category2 if set, is the category of the denominator.
                     Otherwise, the category is assumed to be the same
    @param aPlotter is the plotter that is having its cuts set.
                    Default is the plotter defined in this module.
    @param Nminus1 is a parameter to not cut on
    """

    from ..LoadConfig import cuts

    category2 = category2 or category1

    aPlotter.Reset()

    numerator_cut = Nminus1Cut(cuts.cut(category1, region1), Nminus1) if Nminus1 else cuts.cut(category1, region1)
    denominator_cut = Nminus1Cut(cuts.cut(category2, region2), Nminus1) if Nminus1 else cuts.cut(category2, region2)

    aPlotter.AddRatioCuts(numerator_cut + ' && ' + cuts.dataMCCuts(region1, True),
                          denominator_cut + ' && ' + cuts.dataMCCuts(region2, True),
                          aPlotter.kData, 'Data', 1)

    aPlotter.AddRatioCuts(numerator_cut + ' * ' + cuts.dataMCCuts(region1, False),
                          denominator_cut + ' * ' + cuts.dataMCCuts(region2, False),
                          aPlotter.kBackground, 'MC', 2)

    aPlotter.SetDataIndex(0)
    aPlotter.SetRatioIndex(1)
{'fraction_non_alphanumeric': 0.08491761723700887, 'fraction_numerical': 0.015462610899873257, 'mean_word_length': 2.8199419167473376, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5318277', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1152, 'n_words': 338}