4 from array
import array
8 import ProviderHistoHelpers
10 SystematicNameDictionary = {
11 'Xcalib_50nsVs25ns_AntiKt4EMTopo':
'Xcalib_50nsVs25ns',
12 'Xcalib_5Vs4sample_AntiKt4EMTopo':
'Xcalib_5Vs4sample',
13 'Xcalib_TopoClustering_AntiKt4EMTopo':
'Xcalib_TopoClustering',
14 'Xcalib_EarlyData_AntiKt4EMTopo':
'Xcalib_EarlyData',
15 'Xcalib_NoiseThreshold_AntiKt4EMTopo':
'Xcalib_NoiseThreshold',
16 'Xcalib_UnderlyingEvent_AntiKt4EMTopo':
'Xcalib_UnderlyingEvent'
20 '' :
'AntiKt4Topo_EMJES',
23 def ReadCrossCalHistograms(dirName,scaleCrossCalVal=1.0,freezeCrossCalAll=False,freezeCrossCalBarrel=False,freezeCrossCalCentral=False):
24 if not dirName.endswith(
"/"):
25 dirName = dirName +
"/"
29 files =
sorted(glob.glob(dirName+
"*.root"))
30 for aFileName
in files:
33 for aFileDef,aJetDef
in jetDefDict.iteritems():
34 if aFileDef
in aFileName:
38 print "Failed to determine jet definition for file:",aFileName
44 inFile = TFile(aFileName,
"READ")
46 for histName
in inFile.GetKeyNames():
49 if 'valid' in histName :
52 systematicName = SystematicNameDictionary[histName]+
"_"+jetDef
53 histo = inFile.Get(histName)
55 print "Failed to get histogram:",systematicName
57 histo.SetName(systematicName+
"_old")
59 if freezeCrossCalAll
or freezeCrossCalBarrel
or freezeCrossCalCentral :
61 for xbin
in range(histo.GetNbinsX()+2) :
64 for ybin
in range(histo.GetNbinsY()+2) :
67 eta = abs(histo.GetYaxis().GetBinCenter(ybin))
69 freezeval = histo.GetBinContent(xbin,ybin)
71 if (eta < 2.5
and freezeCrossCalBarrel)
or freezeCrossCalAll :
72 histo.SetBinContent(xbin,ybin,freezeval*scaleCrossCalVal)
74 histo.SetBinContent(xbin,ybin,0)
80 histoSym.SetDirectory(0)
83 if '50nsVs25ns' in histName :
84 CentralHist = histo.Clone()
85 CentralHist.SetName(
"Central_holder")
86 ForwardHist = histo.Clone()
87 ForwardHist.SetName(
"Forward_holder")
89 for xbin
in range(histo.GetNbinsX()+2) :
92 for ybin
in range(histo.GetNbinsY()+2) :
95 eta = abs(histo.GetYaxis().GetBinCenter(ybin))
97 freezeval = histo.GetBinContent(xbin,ybin)
98 ForwardHist.SetBinContent(xbin,ybin,0.0)
99 CentralHist.SetBinContent(xbin,ybin,freezeval)
101 ForwardHist.SetBinContent(xbin,ybin,freezeval)
102 CentralHist.SetBinContent(xbin,ybin,0.0)
107 CentralSym.SetDirectory(0)
108 histos[jetDef][SystematicNameDictionary[histName]+
"_Central"] = CentralSym
111 ForwardSym.SetDirectory(0)
112 histos[jetDef][SystematicNameDictionary[histName]+
"_Forward"] = ForwardSym
115 if 'EarlyData' in histName :
116 ForwardHist = histo.Clone()
117 ForwardHist.SetName(
"EarlyData_Forward_holder")
119 for xbin
in range(histo.GetNbinsX()+2) :
121 for ybin
in range(histo.GetNbinsY()+2) :
124 eta = abs(histo.GetYaxis().GetBinCenter(ybin))
126 ForwardHist.SetBinContent(xbin,ybin,0.0)
131 ForwardSym.SetDirectory(0)
132 histos[jetDef][SystematicNameDictionary[histName]+
"_Forward"] = ForwardSym
133 histos[jetDef][SystematicNameDictionary[histName]] = histoSym
136 histos[jetDef][SystematicNameDictionary[histName]] = histoSym
144 if not dirName.endswith(
"/"):
145 dirName = dirName +
"/"
149 files =
sorted(glob.glob(dirName+
"*.root"))
150 for aFileName
in files:
153 for aFileDef,aJetDef
in jetDefDict.iteritems():
154 if aFileDef
in aFileName:
158 print "Failed to determine jet definition for file:",aFileName
163 inFile = TFile(aFileName,
"READ")
164 for histName
in inFile.GetKeyNames():
165 if 'valid' not in histName :
167 dictkey = histName.replace(
"valid_",
"")
168 systematicName =
"valid_"+SystematicNameDictionary[dictkey]+
"_"+jetDef
169 histo = inFile.Get(histName)
171 print "Failed to get histogram:",systematicName
173 histo.SetName(systematicName+
"_old")
178 histoSym.SetDirectory(0)
179 histos[jetDef][SystematicNameDictionary[dictkey]] = histoSym