32def Read2012Histograms(dirName,scaleEtaInter3Regions=False,scaleEtaInter2Regions=False):
33 removeInSitu = False
34 if not dirName.endswith("/"):
35 dirName = dirName + "/"
36
37
38 aSystFile = dirName + "JESUncertainty_2012.root"
39 systematicFile = TFile(aSystFile,"READ")
40
41 histos = {}
42 for key in systematicFile.GetKeyNames() :
43
44
45
46
47 jettype = key.split("_")[-1]
48 if jettype not in useJetCollections.keys() :
49 continue
50 elif useJetCollections[jettype] not in histos :
51 print "Adding extra dict..."
52 histos[useJetCollections[jettype]] = {}
53
54
55 systname = key.replace("_"+jettype,"")
56 if systname in haveUpdatedVersions :
57 continue
58
59 histo = systematicFile.Get(key)
60 histo.SetDirectory(0)
61
62 if key.find("EtaIntercalibration_Modelling")!=-1 and (scaleEtaInter3Regions or scaleEtaInter2Regions) :
63
64 print "OH NO!!!"
65 return
66
67
68 for xbin in range(histo.GetNbinsX()+2) :
69
70 for ybin in range(histo.GetNbinsY()+2) :
71 run1val = histo.GetBinContent(xbin,ybin)
72
73
74 if abs(histo.GetYaxis().GetBinCenter(ybin)) < 0.8 :
75 continue
76 elif 0.8 < abs(histo.GetYaxis().GetBinCenter(ybin)) < 2.5 :
77 if scaleEtaInter3Regions :
78 histo.SetBinContent(xbin,ybin,2.0*run1val)
79 else :
80 continue
81 else :
82 histo.SetBinContent(xbin,ybin,3.0*run1val)
83
84 if (key.find("LAr_")!=-1 or key.find("Zjet_")!=-1 or key.find("Gjet")!=-1) and removeInSitu :
85
86
87 for xbin in range(histo.GetNbinsX()+2) :
88 for ybin in range(histo.GetNbinsY()+2) :
89
90
91 if abs(histo.GetYaxis().GetBinCenter(ybin)) > 0.8 :
92 histo.SetBinContent(xbin,ybin,0.0)
93 else :
94 continue
95
96
97 if key.find("PunchThrough")!=-1 :
98
99
100 maxVal = histo.GetMaximum()
101 print "For punchthrough, using max val",maxVal
102
103
104 for xbin in range(histo.GetNbinsX()+2) :
105 for ybin in range(histo.GetNbinsY()+2) :
106 for zbin in range(histo.GetNbinsZ()+2) :
107
108
109
110
111
112
113
114
115 if histo.GetXaxis().GetBinCenter(xbin) < 50 or \
116 histo.GetYaxis().GetBinCenter(ybin) < 20 or \
117 histo.GetZaxis().GetBinCenter(zbin) > 2.7 :
118 histo.SetBinContent(xbin,ybin,zbin,0.0)
119
120 else :
121
122 histo.SetBinContent(xbin,ybin,zbin,maxVal)
123
124 if key.find("MC12") :
125
126 newhist = histo.Clone()
127 oldname = histo.GetName()
128 newname = oldname.replace("MC12","MC15")
129 newhist.SetName(newname)
130 newkey = systname.replace("MC12","MC15")
131 newhist.SetDirectory(0)
132 histos[useJetCollections[jettype]][newkey] = newhist
133 continue
134
135 histos[useJetCollections[jettype]][systname] = histo
136
137
138 return histos
139
140
141
142