2 from array
import array
6 import ProviderHistoHelpers
10 SystematicNameDictionary = {
11 'gammajetdphi' :
'Gjet_dPhi',
12 'gammajetgenerator' :
'Gjet_Generator',
13 'gammajetjvt' :
'Gjet_Jvt',
14 'gammajetshower' :
'Gjet_ShowerTopology',
15 'gammajetphscalez' :
'Gjet_GamESZee',
16 'gammajetphsmear' :
'Gjet_GamEsmear',
17 'gammajetpurity' :
'Gjet_Purity',
18 'gammajetstat1' :
'Gjet_Stat1',
19 'gammajetstat2' :
'Gjet_Stat2',
20 'gammajetstat3' :
'Gjet_Stat3',
21 'gammajetstat4' :
'Gjet_Stat4',
22 'gammajetstat5' :
'Gjet_Stat5',
23 'gammajetstat6' :
'Gjet_Stat6',
24 'gammajetstat7' :
'Gjet_Stat7',
25 'gammajetstat8' :
'Gjet_Stat8',
26 'gammajetstat9' :
'Gjet_Stat9',
27 'gammajetstat10' :
'Gjet_Stat10',
28 'gammajetstat11' :
'Gjet_Stat11',
29 'gammajetstat12' :
'Gjet_Stat12',
30 'gammajetstat13' :
'Gjet_Stat13',
31 'gammajetstat14' :
'Gjet_Stat14',
32 'gammajetstat15' :
'Gjet_Stat15',
33 'gammajetstat16' :
'Gjet_Stat16',
34 'gammajetsubleadingjet' :
'Gjet_Veto',
35 'zjetdphi' :
'Zjet_dPhi',
36 'zjetescale' :
'Zjet_ElecESZee',
37 'zjetesmear' :
'Zjet_ElecEsmear',
38 'zjetgenerator' :
'Zjet_MC',
39 'zjetjvt' :
'Zjet_Jvt',
40 'zjetmuscale' :
'Zjet_MuScale',
41 'zjetmusmearid' :
'Zjet_MuSmearID',
42 'zjetmusmearms' :
'Zjet_MuSmearMS',
43 'zjetmusagittares' :
'Zjet_MuSagittaRes',
44 'zjetmusagittarho' :
'Zjet_MuSagittaRho',
45 'zjetelstat1' :
'Zjet_ElecStat1',
46 'zjetelstat2' :
'Zjet_ElecStat2',
47 'zjetelstat3' :
'Zjet_ElecStat3',
48 'zjetelstat4' :
'Zjet_ElecStat4',
49 'zjetelstat5' :
'Zjet_ElecStat5',
50 'zjetelstat6' :
'Zjet_ElecStat6',
51 'zjetelstat7' :
'Zjet_ElecStat7',
52 'zjetelstat8' :
'Zjet_ElecStat8',
53 'zjetelstat9' :
'Zjet_ElecStat9',
54 'zjetelstat10' :
'Zjet_ElecStat10',
55 'zjetelstat11' :
'Zjet_ElecStat11',
56 'zjetelstat12' :
'Zjet_ElecStat12',
57 'zjetelstat13' :
'Zjet_ElecStat13',
58 'zjetelstat14' :
'Zjet_ElecStat14',
59 'zjetmustat1' :
'Zjet_MuStat1',
60 'zjetmustat2' :
'Zjet_MuStat2',
61 'zjetmustat3' :
'Zjet_MuStat3',
62 'zjetmustat4' :
'Zjet_MuStat4',
63 'zjetmustat5' :
'Zjet_MuStat5',
64 'zjetmustat6' :
'Zjet_MuStat6',
65 'zjetmustat7' :
'Zjet_MuStat7',
66 'zjetmustat8' :
'Zjet_MuStat8',
67 'zjetmustat9' :
'Zjet_MuStat9',
68 'zjetmustat10' :
'Zjet_MuStat10',
69 'zjetmustat11' :
'Zjet_MuStat11',
70 'zjetmustat12' :
'Zjet_MuStat12',
71 'zjetmustat13' :
'Zjet_MuStat13',
72 'zjetmustat14' :
'Zjet_MuStat14',
73 'zjetsubleadingjet' :
'Zjet_Veto',
74 'zjetshower' :
'Zjet_ShowerTopology',
78 'EMJES_R4' :
'AntiKt4Topo_EMJES',
79 'LCJES_R4' :
'AntiKt4Topo_LCJES',
80 'PFJES_R4' :
'AntiKt4PFlow_EMJES'
84 if not dirName.endswith(
"/"):
85 dirName = dirName +
"/"
89 subDirs =
sorted(glob.glob(dirName+
"*"))
90 subDirs = [i
for i
in subDirs
if os.path.isdir(os.path.join(os.getcwd(), i))]
91 for aSubDirName
in subDirs:
94 for aDirDef,aJetDef
in jetDefDict.iteritems():
95 if aDirDef
in aSubDirName:
99 print "Failed to determine jet definition for directory:",aSubDirName
102 print "Jet definition is",jetDef
106 systFiles =
sorted(glob.glob(aSubDirName+
"/SystError_*.txt"))
107 for aSystFile
in systFiles:
109 if not "SystError_" in aSystFile :
113 systematicNameHandle = re.sub(aSubDirName+
"/SystError_",
"",aSystFile)
114 systematicNameHandle = re.sub(
".txt",
"",systematicNameHandle)
115 systematicName = SystematicNameDictionary[systematicNameHandle]
116 print "Making histogram %s --> %s"%(systematicNameHandle,systematicName)
119 systematicFile =
open(aSystFile,
"r")
124 for line
in systematicFile.readlines():
125 line = line.strip(
"\r\n")
126 lowEdge =
float(line.split()[0])
127 systVal =
float(line.split()[2].strip())
129 lowBinEdges.append(lowEdge)
130 systValues.append(systVal)
133 systematicFile.close()
136 lowBinEdges.append(2500.)
137 systValues.append(systValues[-1])
140 lowBinEdgesArray =
array(
'd',lowBinEdges)
141 systValuesArray =
array(
'd',systValues)
142 histoName = systematicName+
"_"+jetDef
143 histo1D = TH1D(histoName+
"_1D",histoName+
"_1D",len(lowBinEdges)-1,lowBinEdgesArray)
146 for iBin
in xrange(1,histo1D.GetNbinsX()+1):
147 histo1D.SetBinContent(iBin,systValues[iBin-1])
155 histos[jetDef][systematicName] = histo1D