53def ReadEtaIntercalibrationHistograms(dirName,year=""):
54 if not dirName.endswith("/"):
55 dirName = dirName + "/"
56
57
58
59 histos = {}
60 files = sorted(glob.glob(dirName+"*{0}*.root".format(year)))
61 for aFileName in files:
62
63 jetDef = ""
64 for aFileDef,aJetDef in jetDefDict.iteritems():
65 if aFileDef in aFileName:
66 jetDef = aJetDef
67 break
68 if jetDef == "":
69 print "Failed to determine jet definition for file:",aFileName
70 return None
71 if jetDef not in histos.keys() :
72 histos[jetDef] = {}
73
74
75 inFile = TFile(aFileName,"READ")
76 contents = inFile.GetKeyNames()
77
78 if year :
79 SystematicNames = SystematicNames_timedependent
80 else :
81 SystematicNames = SystematicNames_timeinvariant
82
83 for aName in SystematicNames.keys():
84 if not "NonClosure" in SystematicNames[aName] :
85 if "Topo" in jetDef :
86 getsystematicName = aName + "_" + jetDef.replace("Topo","")
87 else :
88 getsystematicName = aName +
"_" + jetDef.replace(
"4PFlow",
"4EMPFlow").
replace(
"_EMJES",
"_PFlowJES")
89 else :
90 getsystematicName = aName
91
92 if not getsystematicName in contents :
93 continue
94
95 histo = inFile.Get(getsystematicName)
96
97 systematicName = SystematicNames[aName] + "_" + jetDef
98 histo.SetName(systematicName+"_old")
99
100
102 histoNew.SetDirectory(0)
103 histos[jetDef][SystematicNames[aName]] = histoNew
104
105
106 inFile.Close()
107
108
109 for aName,storeName in SystematicNames.iteritems():
110 for aJetDef in histos.keys():
111 if not storeName in histos[aJetDef].keys() :
112 print "Failed to find histogram:", storeName,"for jet definition",aJetDef
113
114
115 if year :
116 for thisDef in jetDefDict.keys() :
117 files = sorted(glob.glob(dirName+"*{0}*_statErr_*{1}*.root".format(year,thisDef)))
118 if len(files) != 1 :
119 print "Did not find right number of stat term files!"
120 print files
121 exit(1)
122 filename = files[0]
123 print histos
124 histos = ReadEtaIntercalibrationDetailedStats(filename, histos)
125 print histos
126
127 print "Histos out here"
128 print histos
129 print "\n"
130 return histos
std::string replace(std::string s, const std::string &s2, const std::string &s3)
ExtendPtRangeOfHisto(histo, histoName)