def METHOD_NAME(dir_name, **kwargs):
    pp.RandomGenerator.get().set_seed(1234)
    buf = {}
    for key in kwargs:
        if key == "dEdx" and kwargs[key] is True:
            f_dEdx = open(dir_name + "Mupair_dEdx.txt", "w")
            buf["dEdx"] = [f_dEdx, [""]]
        if key == "dNdx" and kwargs[key] is True:
            f_dNdx = open(dir_name + "Mupair_dNdx.txt", "w")
            buf["dNdx"] = [f_dNdx, [""]]
        if key == "stoch" and kwargs[key] is True:
            f_stoch = open(dir_name + "Mupair_e.txt", "w")
            buf["stoch"] = [f_stoch, [""]]
    for particle in particle_defs:
        for medium in mediums:
            for cut in cuts:
                for param in params:
                    args = {
                        "parametrization": param,
                        "particle_def": particle,
                        "target": medium,
                        "cuts": cut,
                        "interpolate": False
                    }
                    xsection = pp.crosssection.make_crosssection(**args)
                    for key in buf:
                        buf[key][1] = [""]
                        for energy in energies:
                            if key == "dEdx":
                                result = [str(xsection.calculate_dEdx(energy))]
                            if key == "dNdx":
                                result = [str(xsection.calculate_dNdx(energy))]
                            if key == "stoch":
                                rnd1 = pp.RandomGenerator.get().random_double()
                                rnd2 = pp.RandomGenerator.get().random_double()
                                components = medium.components
                                comp = components[int(rnd2*len(components))]
                                dNdx_for_comp = xsection.calculate_dNdx(energy, comp.hash);
                                if np.isfinite(cut.ecut) or cut.vcut < 1:
                                    result = xsection.calculate_stochastic_loss(
                                        comp.hash, energy, rnd1*dNdx_for_comp)
                                else:
                                    result = 0
                                result = [str(rnd1), str(rnd2), str(result)]
                            buf[key][1].append(particle.name)
                            buf[key][1].append(medium.name)
                            buf[key][1].append(str(cut.ecut))
                            buf[key][1].append(str(cut.vcut))
                            buf[key][1].append(str(multiplier))
                            buf[key][1].append(str(energy))
                            buf[key][1].append(xsection.param_name)
                            buf[key][1].extend(result)
                            buf[key][1].append("\n")
                        buf[key][0].write("\t".join(buf[key][1]))