2 from array
import array
6 import ProviderHistoHelpers
8 SystematicNameDictionary = {
9 'Xcalib_50nsVs25ns_AntiKt4EMTopo':
'Xcalib_50nsVs25ns',
10 'Xcalib_5Vs4sample_AntiKt4EMTopo':
'Xcalib_5Vs4sample',
11 'Xcalib_TopoClustering_AntiKt4EMTopo':
'Xcalib_TopoClustering',
12 'Xcalib_EarlyData_AntiKt4EMTopo':
'Xcalib_EarlyData',
13 'Xcalib_NoiseThreshold_AntiKt4EMTopo':
'Xcalib_NoiseThreshold',
14 'Xcalib_UnderlyingEvent_AntiKt4EMTopo':
'Xcalib_UnderlyingEvent'
18 '' :
'AntiKt4Topo_EMJES',
21 def ReadCrossCalHistograms(dirName,scaleCrossCalVal=1.0,freezeCrossCalAll=False,freezeCrossCalBarrel=False,freezeCrossCalCentral=False):
22 if not dirName.endswith(
"/"):
23 dirName = dirName +
"/"
27 files =
sorted(glob.glob(dirName+
"*.root"))
28 for aFileName
in files:
31 for aFileDef,aJetDef
in jetDefDict.iteritems():
32 if aFileDef
in aFileName:
36 print "Failed to determine jet definition for file:",aFileName
42 inFile = TFile(aFileName,
"READ")
44 for histName
in inFile.GetKeyNames():
47 if 'valid' in histName :
50 systematicName = SystematicNameDictionary[histName]+
"_"+jetDef
51 histo = inFile.Get(histName)
53 print "Failed to get histogram:",systematicName
55 histo.SetName(systematicName+
"_old")
57 if freezeCrossCalAll
or freezeCrossCalBarrel
or freezeCrossCalCentral :
59 for xbin
in range(histo.GetNbinsX()+2) :
62 for ybin
in range(histo.GetNbinsY()+2) :
65 eta = abs(histo.GetYaxis().GetBinCenter(ybin))
67 freezeval = histo.GetBinContent(xbin,ybin)
69 if (eta < 2.5
and freezeCrossCalBarrel)
or freezeCrossCalAll :
70 histo.SetBinContent(xbin,ybin,freezeval*scaleCrossCalVal)
72 histo.SetBinContent(xbin,ybin,0)
78 histoSym.SetDirectory(0)
81 if '50nsVs25ns' in histName :
82 CentralHist = histo.Clone()
83 CentralHist.SetName(
"Central_holder")
84 ForwardHist = histo.Clone()
85 ForwardHist.SetName(
"Forward_holder")
87 for xbin
in range(histo.GetNbinsX()+2) :
90 for ybin
in range(histo.GetNbinsY()+2) :
93 eta = abs(histo.GetYaxis().GetBinCenter(ybin))
95 freezeval = histo.GetBinContent(xbin,ybin)
96 ForwardHist.SetBinContent(xbin,ybin,0.0)
97 CentralHist.SetBinContent(xbin,ybin,freezeval)
99 ForwardHist.SetBinContent(xbin,ybin,freezeval)
100 CentralHist.SetBinContent(xbin,ybin,0.0)
105 CentralSym.SetDirectory(0)
106 histos[jetDef][SystematicNameDictionary[histName]+
"_Central"] = CentralSym
109 ForwardSym.SetDirectory(0)
110 histos[jetDef][SystematicNameDictionary[histName]+
"_Forward"] = ForwardSym
113 if 'EarlyData' in histName :
114 ForwardHist = histo.Clone()
115 ForwardHist.SetName(
"EarlyData_Forward_holder")
117 for xbin
in range(histo.GetNbinsX()+2) :
119 for ybin
in range(histo.GetNbinsY()+2) :
122 eta = abs(histo.GetYaxis().GetBinCenter(ybin))
124 ForwardHist.SetBinContent(xbin,ybin,0.0)
129 ForwardSym.SetDirectory(0)
130 histos[jetDef][SystematicNameDictionary[histName]+
"_Forward"] = ForwardSym
131 histos[jetDef][SystematicNameDictionary[histName]] = histoSym
134 histos[jetDef][SystematicNameDictionary[histName]] = histoSym
142 if not dirName.endswith(
"/"):
143 dirName = dirName +
"/"
147 files =
sorted(glob.glob(dirName+
"*.root"))
148 for aFileName
in files:
151 for aFileDef,aJetDef
in jetDefDict.iteritems():
152 if aFileDef
in aFileName:
156 print "Failed to determine jet definition for file:",aFileName
161 inFile = TFile(aFileName,
"READ")
162 for histName
in inFile.GetKeyNames():
163 if 'valid' not in histName :
165 dictkey = histName.replace(
"valid_",
"")
166 systematicName =
"valid_"+SystematicNameDictionary[dictkey]+
"_"+jetDef
167 histo = inFile.Get(histName)
169 print "Failed to get histogram:",systematicName
171 histo.SetName(systematicName+
"_old")
176 histoSym.SetDirectory(0)
177 histos[jetDef][SystematicNameDictionary[dictkey]] = histoSym