Adapt background function script to take TChain (i.e. multiple files) as input