32 def Read2012Histograms(dirName,scaleEtaInter3Regions=False,scaleEtaInter2Regions=False):
34 if not dirName.endswith(
"/"):
35 dirName = dirName +
"/"
38 aSystFile = dirName +
"JESUncertainty_2012.root"
39 systematicFile = TFile(aSystFile,
"READ")
42 for key
in systematicFile.GetKeyNames() :
47 jettype = key.split(
"_")[-1]
48 if jettype
not in useJetCollections.keys() :
50 elif useJetCollections[jettype]
not in histos :
51 print "Adding extra dict..."
52 histos[useJetCollections[jettype]] = {}
55 systname = key.replace(
"_"+jettype,
"")
56 if systname
in haveUpdatedVersions :
59 histo = systematicFile.Get(key)
62 if key.find(
"EtaIntercalibration_Modelling")!=-1
and (scaleEtaInter3Regions
or scaleEtaInter2Regions) :
68 for xbin
in range(histo.GetNbinsX()+2) :
70 for ybin
in range(histo.GetNbinsY()+2) :
71 run1val = histo.GetBinContent(xbin,ybin)
74 if abs(histo.GetYaxis().GetBinCenter(ybin)) < 0.8 :
76 elif 0.8 < abs(histo.GetYaxis().GetBinCenter(ybin)) < 2.5 :
77 if scaleEtaInter3Regions :
78 histo.SetBinContent(xbin,ybin,2.0*run1val)
82 histo.SetBinContent(xbin,ybin,3.0*run1val)
84 if (key.find(
"LAr_")!=-1
or key.find(
"Zjet_")!=-1
or key.find(
"Gjet")!=-1)
and removeInSitu :
87 for xbin
in range(histo.GetNbinsX()+2) :
88 for ybin
in range(histo.GetNbinsY()+2) :
91 if abs(histo.GetYaxis().GetBinCenter(ybin)) > 0.8 :
92 histo.SetBinContent(xbin,ybin,0.0)
97 if key.find(
"PunchThrough")!=-1 :
100 maxVal = histo.GetMaximum()
101 print "For punchthrough, using max val",maxVal
104 for xbin
in range(histo.GetNbinsX()+2) :
105 for ybin
in range(histo.GetNbinsY()+2) :
106 for zbin
in range(histo.GetNbinsZ()+2) :
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)
122 histo.SetBinContent(xbin,ybin,zbin,maxVal)
124 if key.find(
"MC12") :
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
135 histos[useJetCollections[jettype]][systname] = histo