# flake8: noqa
from Moore import options, run_reconstruction
from Moore.config import Reconstruction
from PyConf.Algorithms import PrParameterisationData
from RecoConf.data_from_file import mc_unpackers
from PyConf.application import make_data_with_FetchDataFromFile
from RecoConf.mc_checking import make_links_lhcbids_mcparticles_tracking_system
from RecoConf.event_filters import require_gec

import glob


decay = "B"

options.evt_max = -1

options.ntuple_file = f"data/param_data_{decay}_default_thesis.root"


if decay == "B":
    options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi")
elif decay == "BJpsi":
    options.input_files = glob.glob("/auto/data/guenther/Bd_JpsiKst_ee/*.xdigi")
elif decay == "D":
    options.input_files = glob.glob("/auto/data/guenther/Dst_D0ee/*.xdigi")
elif decay == "test2":
    options.input_files = [
        "/auto/data/guenther/Bd_JpsiKst_ee/00143565_00000009_1.xdigi"
    ]
elif decay == "test":
    options.input_files = ["/auto/data/guenther/Bd_Kstee/00151673_00000002_1.xdigi"]

options.input_type = "ROOT"

options.dddb_tag = "dddb-20210617"
options.conddb_tag = "sim-20210617-vc-md100"
options.simulation = True


def run_tracking_param_debug():
    links_to_hits = make_links_lhcbids_mcparticles_tracking_system()

    param_data = PrParameterisationData(
        MCParticles=mc_unpackers()["MCParticles"],
        MCVPHits=mc_unpackers()["MCVPHits"],
        MCFTHits=mc_unpackers()["MCFTHits"],
        zRef=8520.0,
        TrackInfo=make_data_with_FetchDataFromFile(
            "/Event/MC/TrackInfo", "LHCb::MCProperty"
        ),
    )

    data = [param_data]

    return Reconstruction("run_tracking_debug", data, [require_gec()])


run_reconstruction(options, run_tracking_param_debug)
