import ROOT import glob for root_file in glob.glob("/data/userdata/jguiang/temp/*.root"): # Load file tfile = ROOT.TFile(root_file) ttree = tfile.Get("Events") tbranch = ttree.GetBranch("nLHEReweightingWeight") # Loop over all entries in the tree counts = set([entry.nLHEReweightingWeight for entry in ttree]) if len(counts) > 1 or len(counts) == 0 or counts != set([120]): print("Something's weird here: ") print(root_file) print(counts)