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