31def ReadPunchthroughHistograms(dirName):
32 if not dirName.endswith("/"):
33 dirName = dirName + "/"
34
35
36 rootFileList = sorted(glob.glob(dirName+"*.root"))
37 if len(rootFileList) != 1:
38 print "Found a number of root files not equal to 1 in dir:",dirName
39 return None
40 rootFile = TFile(rootFileList[0],"READ")
41
42 histos = {}
43 for aJetDef,aJetDefProv in jetDefDict.iteritems():
44 histos[aJetDefProv] = {}
45
46 for histName in rootFile.GetKeyNames():
47 if aJetDef not in histName: continue
48 for aKey,aVal in SystematicNameDictionary.iteritems():
49 histName = aJetDef+"_"+aKey
50 histo = rootFile.Get(histName)
51 if histo is None:
52 print "Failed to get histogram:",histName
53 return None
54 histo.SetName(aVal+"_"+aJetDefProv)
55 histo.SetDirectory(0)
56
57 histos[aJetDefProv][aVal] = histo
58
59
60 rootFile.Close()
61
62
76
77 return histos
78