2 from array
import array
6 import ProviderHistoHelpers
12 SystematicNameDictionary = {
13 'gammajetdphi' :
'Gjet_dPhi',
14 'gammajetgenerator' :
'Gjet_Generator',
15 'gammajetjvt' :
'Gjet_Jvt',
16 'gammajetshower' :
'Gjet_ShowerTopology',
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 'gammajetstat16' :
'Gjet_Stat16',
36 'gammajetsubleadingjet' :
'Gjet_Veto',
37 'mjbalpha' :
'MJB_Alpha',
38 'mjbbeta' :
'MJB_Beta',
39 'mjbfrag' :
'MJB_Fragmentation',
41 'mjbptasymm' :
'MJB_Asym',
42 'mjbptthreshold' :
'MJB_Threshold',
43 'mjbstat1' :
'MJB_Stat1',
44 'mjbstat2' :
'MJB_Stat2',
45 'mjbstat3' :
'MJB_Stat3',
46 'mjbstat4' :
'MJB_Stat4',
47 'mjbstat5' :
'MJB_Stat5',
48 'mjbstat6' :
'MJB_Stat6',
49 'mjbstat7' :
'MJB_Stat7',
50 'mjbstat8' :
'MJB_Stat8',
51 'mjbstat9' :
'MJB_Stat9',
52 'mjbstat10' :
'MJB_Stat10',
53 'mjbstat11' :
'MJB_Stat11',
54 'mjbstat12' :
'MJB_Stat12',
55 'mjbstat13' :
'MJB_Stat13',
56 'mjbstat14' :
'MJB_Stat14',
57 'mjbstat15' :
'MJB_Stat15',
58 'mjbstat16' :
'MJB_Stat16',
59 'mjbstat17' :
'MJB_Stat17',
60 'mjbstat18' :
'MJB_Stat18',
61 'mjbstat19' :
'MJB_Stat19',
62 'mjbstat20' :
'MJB_Stat20',
63 'mjbstat21' :
'MJB_Stat21',
64 'mjbstat22' :
'MJB_Stat22',
65 'mjbstat23' :
'MJB_Stat23',
66 'mjbstat24' :
'MJB_Stat24',
67 'mjbstat25' :
'MJB_Stat25',
68 'mjbstat26' :
'MJB_Stat26',
69 'mjbstat27' :
'MJB_Stat27',
70 'mjbstat28' :
'MJB_Stat28',
71 'zjetdphi' :
'Zjet_dPhi',
72 'zjetescale' :
'Zjet_ElecESZee',
73 'zjetesmear' :
'Zjet_ElecEsmear',
74 'zjetgenerator' :
'Zjet_MC',
75 'zjetjvt' :
'Zjet_Jvt',
76 'zjetmuscale' :
'Zjet_MuScale',
77 'zjetmusmearid' :
'Zjet_MuSmearID',
78 'zjetmusmearms' :
'Zjet_MuSmearMS',
79 'zjetmusagittares' :
'Zjet_MuSagittaRes',
80 'zjetmusagittarho' :
'Zjet_MuSagittaRho',
81 'zjetelstat1' :
'Zjet_ElecStat1',
82 'zjetelstat2' :
'Zjet_ElecStat2',
83 'zjetelstat3' :
'Zjet_ElecStat3',
84 'zjetelstat4' :
'Zjet_ElecStat4',
85 'zjetelstat5' :
'Zjet_ElecStat5',
86 'zjetelstat6' :
'Zjet_ElecStat6',
87 'zjetelstat7' :
'Zjet_ElecStat7',
88 'zjetelstat8' :
'Zjet_ElecStat8',
89 'zjetelstat9' :
'Zjet_ElecStat9',
90 'zjetelstat10' :
'Zjet_ElecStat10',
91 'zjetelstat11' :
'Zjet_ElecStat11',
92 'zjetelstat12' :
'Zjet_ElecStat12',
93 'zjetelstat13' :
'Zjet_ElecStat13',
94 'zjetelstat14' :
'Zjet_ElecStat14',
95 'zjetmustat1' :
'Zjet_MuStat1',
96 'zjetmustat2' :
'Zjet_MuStat2',
97 'zjetmustat3' :
'Zjet_MuStat3',
98 'zjetmustat4' :
'Zjet_MuStat4',
99 'zjetmustat5' :
'Zjet_MuStat5',
100 'zjetmustat6' :
'Zjet_MuStat6',
101 'zjetmustat7' :
'Zjet_MuStat7',
102 'zjetmustat8' :
'Zjet_MuStat8',
103 'zjetmustat9' :
'Zjet_MuStat9',
104 'zjetmustat10' :
'Zjet_MuStat10',
105 'zjetmustat11' :
'Zjet_MuStat11',
106 'zjetmustat12' :
'Zjet_MuStat12',
107 'zjetmustat13' :
'Zjet_MuStat13',
108 'zjetmustat14' :
'Zjet_MuStat14',
109 'zjetsubleadingjet' :
'Zjet_Veto',
110 'zjetshower' :
'Zjet_ShowerTopology',
113 'etaintercalibrationmodelling' :
'InSituProp_EtaIntercalModelling',
114 'etaintercalibrationnonclosurehighe' :
'InSituProp_EtaIntercalNonClosureHighE',
115 'etaintercalibrationnonclosureposeta' :
'InSituProp_EtaIntercalNonClosurePosEta',
116 'etaintercalibrationnonclosurenegeta' :
'InSituProp_EtaIntercalNonClosureNegEta',
117 'etaintercalibrationofcs' :
'InSituProp_EtaIntercalOFCs',
118 'etaintercalibrationtotalstat' :
'InSituProp_EtaIntercalStat',
119 'flavorcomposition' :
'InSituProp_FlavorComposition',
120 'flavorresponse' :
'InSituProp_FlavorResponse',
121 'pileupoffsetmu' :
'InSituProp_PileupOffsetMu',
122 'pileupoffsetnpv' :
'InSituProp_PileupOffsetNPV',
123 'pileupptterm' :
'InSituProp_PileupPtTerm',
124 'pileuprhotopology' :
'InSituProp_PileupRhoTopology',
125 'punchthroughmc16' :
'InSituProp_PunchThroughMC',
129 'EMJES_R4' :
'AntiKt4Topo_EMJES',
130 'PFJES_R4' :
'AntiKt4PFlow_EMJES'
134 if not dirName.endswith(
"/"):
135 dirName = dirName +
"/"
139 print os.listdir(dirName)
143 subDirs =
sorted(glob.glob(dirName+
"*/"))
144 print "Checking subdirs",subDirs
145 for aSubDirName
in subDirs:
148 for aDirDef,aJetDef
in jetDefDict.iteritems():
149 if aDirDef
in aSubDirName:
153 print "Failed to determine jet definition for directory:",aSubDirName
158 systFiles =
sorted(glob.glob(aSubDirName+
"/SystError_*.txt"))
159 for aSystFile
in systFiles:
161 aSubDirName = aSubDirName.rstrip(
"/")
162 systematicNameHandle = aSystFile.replace(aSubDirName+
"/SystError_",
"")
163 systematicNameHandle = systematicNameHandle.replace(
".txt",
"")
164 systematicName = SystematicNameDictionary[systematicNameHandle]
165 print "Making histogram %s --> %s"%(systematicNameHandle,systematicName)
168 systematicFile =
open(aSystFile,
"r")
173 for line
in systematicFile.readlines():
174 line = line.strip(
"\r\n")
175 lowEdge =
float(line.split()[0])
176 systVal =
float(line.split()[2].strip())
178 lowBinEdges.append(lowEdge)
179 systValues.append(systVal)
182 systematicFile.close()
185 lowBinEdges.append(2500.)
186 systValues.append(systValues[-1])
189 lowBinEdgesArray =
array(
'd',lowBinEdges)
190 systValuesArray =
array(
'd',systValues)
191 histoName = systematicName+
"_"+jetDef
192 histo1D = TH1D(histoName+
"_1D",histoName+
"_1D",len(lowBinEdges)-1,lowBinEdgesArray)
195 for iBin
in xrange(1,histo1D.GetNbinsX()+1):
196 histo1D.SetBinContent(iBin,systValues[iBin-1])
198 histos[jetDef][systematicName] = histo1D