Saving histograms into a pdf / png format directly from ROOT

Aren’t you missing the leading slash when you define dir?

Try this:

dir = "/eos/home/tcarnaha/UL_2018/ ROOT.TFile(dir+"fits_data/muon/generalTracks/Z/Run2018_UL/AltBkg/NUM_LooseID_DEN_genTracks/NUM_LooseID_DEN_genTracks_abseta_1_pt_2.root")

Does that work?

For getall to work, take a look at Loop over all objects in a ROOT file