71def ReadInSituHistograms(dirName):
72 if not dirName.endswith("/"):
73 dirName = dirName + "/"
74
75
76 histos = {}
77 subDirs = sorted(glob.glob(dirName+"*"))
78 for aSubDirName in subDirs:
79
80 jetDef = ""
81 for aDirDef,aJetDef in jetDefDict.iteritems():
82 if aDirDef in aSubDirName:
83 jetDef = aJetDef
84 break
85 if jetDef == "":
86 print "Failed to determine jet definition for directory:",aSubDirName
87 continue
88 else :
89 print "Jet definition is",jetDef
90 histos[jetDef] = {}
91
92
93 systFiles = sorted(glob.glob(aSubDirName+"/SystError_*.txt"))
94 for aSystFile in systFiles:
95
96 systematicNameHandle = re.sub(aSubDirName+"/SystError_","",aSystFile)
97 systematicNameHandle = re.sub(".txt","",systematicNameHandle)
98 systematicName = SystematicNameDictionary[systematicNameHandle]
99 print "Making histogram %s --> %s"%(systematicNameHandle,systematicName)
100
101
102 systematicFile = open(aSystFile,"r")
103
104
105 lowBinEdges = []
106 systValues = []
107 for line in systematicFile.readlines():
108 line = line.strip("\r\n")
109 lowEdge = float(line.split()[0])
110 systVal = float(line.split()[2].
strip())
111
112 lowBinEdges.append(lowEdge)
113 systValues.append(systVal)
114
115
116 systematicFile.close()
117
118
119 lowBinEdges.append(2500.)
120 systValues.append(systValues[-1])
121
122
123 lowBinEdgesArray =
array(
'd',lowBinEdges)
124 systValuesArray =
array(
'd',systValues)
125 histoName = systematicName+"_"+jetDef
126 histo1D = TH1D(histoName+"_1D",histoName+"_1D",len(lowBinEdges)-1,lowBinEdgesArray)
127
128
129 for iBin
in xrange(1,histo1D.GetNbinsX()+1):
130 histo1D.SetBinContent(iBin,systValues[iBin-1])
131
132
133
134
135
136
137
138 histos[jetDef][systematicName] = histo1D
139
140
141
142
143
144
145
146
147
148
149 return histos
150
151
152
153
void xrange(TH1 *h, bool symmetric)