2 from array
import array
6 import ProviderHistoHelpers
9 useJetCollections = {
"AntiKt4EMTopo":
"AntiKt4Topo_EMJES",
"AntiKt4LCTopo":
"AntiKt4Topo_LCJES"}
11 haveUpdatedVersions = [
"FlavorResponse",
20 "RelativeNonClosure_AFII",
21 "RelativeNonClosure_MC12",
22 "EtaIntercalibration_Modelling",
23 "EtaIntercalibration_TotalStat",]
27 return [key.GetName()
for key
in gDirectory.GetListOfKeys()]
28 TFile.GetKeyNames = GetKeyNames
30 def Read2012Histograms(dirName,scaleEtaInter3Regions=False,scaleEtaInter2Regions=False):
32 if not dirName.endswith(
"/"):
33 dirName = dirName +
"/"
36 aSystFile = dirName +
"JESUncertainty_2012.root"
37 systematicFile = TFile(aSystFile,
"READ")
40 for key
in systematicFile.GetKeyNames() :
45 jettype = key.split(
"_")[-1]
46 if jettype
not in useJetCollections.keys() :
48 elif useJetCollections[jettype]
not in histos :
49 print "Adding extra dict..."
50 histos[useJetCollections[jettype]] = {}
53 systname = key.replace(
"_"+jettype,
"")
54 if systname
in haveUpdatedVersions :
57 histo = systematicFile.Get(key)
60 if key.find(
"EtaIntercalibration_Modelling")!=-1
and (scaleEtaInter3Regions
or scaleEtaInter2Regions) :
66 for xbin
in range(histo.GetNbinsX()+2) :
68 for ybin
in range(histo.GetNbinsY()+2) :
69 run1val = histo.GetBinContent(xbin,ybin)
72 if abs(histo.GetYaxis().GetBinCenter(ybin)) < 0.8 :
74 elif 0.8 < abs(histo.GetYaxis().GetBinCenter(ybin)) < 2.5 :
75 if scaleEtaInter3Regions :
76 histo.SetBinContent(xbin,ybin,2.0*run1val)
80 histo.SetBinContent(xbin,ybin,3.0*run1val)
82 if (key.find(
"LAr_")!=-1
or key.find(
"Zjet_")!=-1
or key.find(
"Gjet")!=-1)
and removeInSitu :
85 for xbin
in range(histo.GetNbinsX()+2) :
86 for ybin
in range(histo.GetNbinsY()+2) :
89 if abs(histo.GetYaxis().GetBinCenter(ybin)) > 0.8 :
90 histo.SetBinContent(xbin,ybin,0.0)
95 if key.find(
"PunchThrough")!=-1 :
98 maxVal = histo.GetMaximum()
99 print "For punchthrough, using max val",maxVal
102 for xbin
in range(histo.GetNbinsX()+2) :
103 for ybin
in range(histo.GetNbinsY()+2) :
104 for zbin
in range(histo.GetNbinsZ()+2) :
113 if histo.GetXaxis().GetBinCenter(xbin) < 50
or \
114 histo.GetYaxis().GetBinCenter(ybin) < 20
or \
115 histo.GetZaxis().GetBinCenter(zbin) > 2.7 :
116 histo.SetBinContent(xbin,ybin,zbin,0.0)
120 histo.SetBinContent(xbin,ybin,zbin,maxVal)
122 if key.find(
"MC12") :
124 newhist = histo.Clone()
125 oldname = histo.GetName()
126 newname = oldname.replace(
"MC12",
"MC15")
127 newhist.SetName(newname)
128 newkey = systname.replace(
"MC12",
"MC15")
129 newhist.SetDirectory(0)
130 histos[useJetCollections[jettype]][newkey] = newhist
133 histos[useJetCollections[jettype]][systname] = histo