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
import glob


options.evt_max = -1
n_files_per_cat = 1
decay = "B"
options.ntuple_file = f"data/param_data_{decay}.root"
options.input_type = "ROOT"
if decay == "B":
    options.input_files = glob.glob("/auto/data/guenther/Bd_Kstee/*.xdigi")
elif decay == "D":
    options.input_files = glob.glob("/auto/data/guenther/Dst_D0ee/*.xdigi")

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


def run_tracking_param_debug():
    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"),
    )

    data = [param_data]

    return Reconstruction("run_tracking_debug", data)


run_reconstruction(options, run_tracking_param_debug)
