from typing import List


def set_process_tracking(template: str, channels: List[str]) -> str:
    """This function replaces the template placeholder for the process tracking with the correct process tracking.

    Args:
        template: The template to be modified.
        channels: The list of channels to be used.

    Returns:
        The modified template.
    """
    tracking = ""
    for channel in channels:
        tracking += "    ULong64_t {ch}_processed = 0;\n".format(ch=channel)
        tracking += "    std::mutex {ch}_bar_mutex;\n".format(ch=channel)
        tracking += "    auto c_{ch} = {ch}_df_final.Count();\n".format(ch=channel)
        tracking += "    c_{ch}.OnPartialResultSlot(quantile, [&{ch}_bar_mutex, &{ch}_processed, &quantile](unsigned int /*slot*/, ULong64_t /*_c*/) {{".format(
            ch=channel
        )
        tracking += (
            "\n        std::lock_guard<std::mutex> lg({ch}_bar_mutex);\n".format(
                ch=channel
            )
        )
        tracking += "        {ch}_processed += quantile;\n".format(ch=channel)
        tracking += '        Logger::get("main - {ch} Channel")->info("{{}} Events processed ...", {ch}_processed);\n'.format(
            ch=channel
        )
        tracking += "    });\n"
    return template.replace("{PROGRESS_CALLBACK}", tracking)