4 from array
import array
8 import ProviderHistoHelpers
11 SystematicNameDictionary = {
12 'gammajetdphi' :
'Gjet_dPhi',
13 'gammajetgenerator' :
'Gjet_Generator',
14 'gammajetjvt' :
'Gjet_Jvt',
15 'gammajetoutofcone' :
'Gjet_OOC',
18 'gammajetphscalez' :
'Gjet_GamESZee',
19 'gammajetphsmear' :
'Gjet_GamEsmear',
20 'gammajetpurity' :
'Gjet_Purity',
21 'gammajetstat1' :
'Gjet_Stat1',
22 'gammajetstat2' :
'Gjet_Stat2',
23 'gammajetstat3' :
'Gjet_Stat3',
24 'gammajetstat4' :
'Gjet_Stat4',
25 'gammajetstat5' :
'Gjet_Stat5',
26 'gammajetstat6' :
'Gjet_Stat6',
27 'gammajetstat7' :
'Gjet_Stat7',
28 'gammajetstat8' :
'Gjet_Stat8',
29 'gammajetstat9' :
'Gjet_Stat9',
30 'gammajetstat10' :
'Gjet_Stat10',
31 'gammajetstat11' :
'Gjet_Stat11',
32 'gammajetstat12' :
'Gjet_Stat12',
33 'gammajetstat13' :
'Gjet_Stat13',
34 'gammajetstat14' :
'Gjet_Stat14',
35 'gammajetstat15' :
'Gjet_Stat15',
36 'gammajetsubleadingjet' :
'Gjet_Veto',
37 'zjetdphi' :
'Zjet_dPhi',
40 'zjetescalez' :
'Zjet_ElecESZee',
41 'zjetesmear' :
'Zjet_ElecEsmear',
42 'zjetgenerator' :
'Zjet_MC',
43 'zjetjvt' :
'Zjet_Jvt',
44 'zjetmuscale' :
'Zjet_MuScale',
45 'zjetmusmearid' :
'Zjet_MuSmearID',
46 'zjetmusmearms' :
'Zjet_MuSmearMS',
47 'zjetoutofcone' :
'Zjet_KTerm',
48 'zjetstat1' :
'Zjet_Stat1',
49 'zjetstat2' :
'Zjet_Stat2',
50 'zjetstat3' :
'Zjet_Stat3',
51 'zjetstat4' :
'Zjet_Stat4',
52 'zjetstat5' :
'Zjet_Stat5',
53 'zjetstat6' :
'Zjet_Stat6',
54 'zjetstat7' :
'Zjet_Stat7',
55 'zjetstat8' :
'Zjet_Stat8',
56 'zjetstat9' :
'Zjet_Stat9',
57 'zjetstat10' :
'Zjet_Stat10',
58 'zjetstat11' :
'Zjet_Stat11',
59 'zjetstat12' :
'Zjet_Stat12',
60 'zjetstat13' :
'Zjet_Stat13',
61 'zjetsubleadingjet' :
'Zjet_Veto',
65 'EMJES_R4' :
'AntiKt4Topo_EMJES',
66 'EMJES_R6' :
'AntiKt6Topo_EMJES',
67 'LCJES_R4' :
'AntiKt4Topo_LCJES',
68 'LCJES_R6' :
'AntiKt6Topo_LCJES'
72 if not dirName.endswith(
"/"):
73 dirName = dirName +
"/"
77 subDirs =
sorted(glob.glob(dirName+
"*"))
78 for aSubDirName
in subDirs:
81 for aDirDef,aJetDef
in jetDefDict.iteritems():
82 if aDirDef
in aSubDirName:
86 print "Failed to determine jet definition for directory:",aSubDirName
89 print "Jet definition is",jetDef
93 systFiles =
sorted(glob.glob(aSubDirName+
"/SystError_*.txt"))
94 for aSystFile
in systFiles:
96 systematicNameHandle = re.sub(aSubDirName+
"/SystError_",
"",aSystFile)
97 systematicNameHandle = re.sub(
".txt",
"",systematicNameHandle)
98 systematicName = SystematicNameDictionary[systematicNameHandle]
99 print "Making histogram %s --> %s"%(systematicNameHandle,systematicName)
102 systematicFile =
open(aSystFile,
"r")
107 for line
in systematicFile.readlines():
108 line = line.strip(
"\r\n")
109 lowEdge =
float(line.split()[0])
110 systVal =
float(line.split()[2].strip())
112 lowBinEdges.append(lowEdge)
113 systValues.append(systVal)
116 systematicFile.close()
119 lowBinEdges.append(2500.)
120 systValues.append(systValues[-1])
123 lowBinEdgesArray =
array(
'd',lowBinEdges)
124 systValuesArray =
array(
'd',systValues)
125 histoName = systematicName+
"_"+jetDef
126 histo1D = TH1D(histoName+
"_1D",histoName+
"_1D",len(lowBinEdges)-1,lowBinEdgesArray)
129 for iBin
in xrange(1,histo1D.GetNbinsX()+1):
130 histo1D.SetBinContent(iBin,systValues[iBin-1])
138 histos[jetDef][systematicName] = histo1D