4 from array
import array
8 import ProviderHistoHelpers
11 SystematicNameDictionary = {
12 'gammajetdphi' :
'Gjet_dPhi',
13 'gammajetgenerator' :
'Gjet_Generator',
14 'gammajetoutofcone' :
'Gjet_OOC',
15 'gammajetphscalemat' :
'Gjet_GamESmaterial',
16 'gammajetphscaleps' :
'Gjet_GamESpresampler',
17 'gammajetphscalez' :
'Gjet_GamESZee',
18 'gammajetphsmear' :
'Gjet_GamEsmear',
19 'gammajetpurity' :
'Gjet_Purity',
20 'gammajetstat1' :
'Gjet_Stat1',
21 'gammajetstat2' :
'Gjet_Stat2',
22 'gammajetstat3' :
'Gjet_Stat3',
23 'gammajetstat4' :
'Gjet_Stat4',
24 'gammajetstat5' :
'Gjet_Stat5',
25 'gammajetstat6' :
'Gjet_Stat6',
26 'gammajetstat7' :
'Gjet_Stat7',
27 'gammajetstat8' :
'Gjet_Stat8',
28 'gammajetstat9' :
'Gjet_Stat9',
29 'gammajetstat10' :
'Gjet_Stat10',
30 'gammajetstat11' :
'Gjet_Stat11',
31 'gammajetstat12' :
'Gjet_Stat12',
32 'gammajetstat13' :
'Gjet_Stat13',
33 'gammajetstat14' :
'Gjet_Stat14',
34 'gammajetstat15' :
'Gjet_Stat15',
35 'gammajetsubleadingjet' :
'Gjet_Veto',
36 'gammajetjvt' :
'Gjet_Jvt',
37 'mjbalpha' :
'MJB_Alpha',
38 'mjbbeta' :
'MJB_Beta',
39 'mjbmodelling' :
'MJB_Fragmentation',
40 'mjbptasymm' :
'MJB_Asym',
41 'mjbptthreshold' :
'MJB_Threshold',
42 'mjbstat1' :
'MJB_Stat1',
43 'mjbstat2' :
'MJB_Stat2',
44 'mjbstat3' :
'MJB_Stat3',
45 'mjbstat4' :
'MJB_Stat4',
46 'mjbstat5' :
'MJB_Stat5',
47 'mjbstat6' :
'MJB_Stat6',
48 'mjbstat7' :
'MJB_Stat7',
49 'mjbstat8' :
'MJB_Stat8',
50 'mjbstat9' :
'MJB_Stat9',
51 'mjbstat10' :
'MJB_Stat10',
52 'mjbstat11' :
'MJB_Stat11',
53 'zjetdphi' :
'Zjet_dPhi',
54 'zjetescalemat' :
'Zjet_ElecESmaterial',
55 'zjetescaleps' :
'Zjet_ElecESpresampler',
56 'zjetescalez' :
'Zjet_ElecESZee',
57 'zjetesmear' :
'Zjet_ElecEsmear',
58 'zjetgenerator' :
'Zjet_MC',
59 'zjetjvf' :
'Zjet_JVF',
60 'zjetmuscale' :
'Zjet_MuScale',
61 'zjetmusmearid' :
'Zjet_MuSmearID',
62 'zjetmusmearms' :
'Zjet_MuSmearMS',
63 'zjetoutofcone' :
'Zjet_KTerm',
64 'zjetstat1' :
'Zjet_Stat1',
65 'zjetstat2' :
'Zjet_Stat2',
66 'zjetstat3' :
'Zjet_Stat3',
67 'zjetstat4' :
'Zjet_Stat4',
68 'zjetstat5' :
'Zjet_Stat5',
69 'zjetstat6' :
'Zjet_Stat6',
70 'zjetstat7' :
'Zjet_Stat7',
71 'zjetstat8' :
'Zjet_Stat8',
72 'zjetstat9' :
'Zjet_Stat9',
73 'zjetstat10' :
'Zjet_Stat10',
74 'zjetstat11' :
'Zjet_Stat11',
75 'zjetstat12' :
'Zjet_Stat12',
76 'zjetstat13' :
'Zjet_Stat13',
77 'zjetsubleadingjet' :
'Zjet_Veto',
78 'zjetjvt' :
'Zjet_Jvt',
82 'EMJES_R4' :
'AntiKt4Topo_EMJES',
83 'EMJES_R6' :
'AntiKt6Topo_EMJES',
84 'LCJES_R4' :
'AntiKt4Topo_LCJES',
85 'LCJES_R6' :
'AntiKt6Topo_LCJES'
89 if not dirName.endswith(
"/"):
90 dirName = dirName +
"/"
94 subDirs =
sorted(glob.glob(dirName+
"*"))
95 for aSubDirName
in subDirs:
98 for aDirDef,aJetDef
in jetDefDict.iteritems():
99 if aDirDef
in aSubDirName:
103 print "Failed to determine jet definition for directory:",aSubDirName
108 systFiles =
sorted(glob.glob(aSubDirName+
"/SystError_*.txt"))
109 for aSystFile
in systFiles:
111 systematicNameHandle = re.sub(aSubDirName+
"/SystError_",
"",aSystFile)
112 systematicNameHandle = re.sub(
".txt",
"",systematicNameHandle)
113 systematicName = SystematicNameDictionary[systematicNameHandle]
117 systematicFile =
open(aSystFile,
"r")
122 for line
in systematicFile.readlines():
123 line = line.strip(
"\r\n")
124 lowEdge =
float(line.split()[0])
125 systVal =
float(line.split()[2].strip())
127 lowBinEdges.append(lowEdge)
128 systValues.append(systVal)
131 systematicFile.close()
134 lowBinEdges.append(2500.)
135 systValues.append(systValues[-1])
138 lowBinEdgesArray =
array(
'd',lowBinEdges)
139 systValuesArray =
array(
'd',systValues)
140 histoName = systematicName+
"_"+jetDef
141 histo1D = TH1D(histoName+
"_1D",histoName+
"_1D",len(lowBinEdges)-1,lowBinEdgesArray)
144 for iBin
in xrange(1,histo1D.GetNbinsX()+1):
145 histo1D.SetBinContent(iBin,systValues[iBin-1])
153 histos[jetDef][systematicName] = histo1D