4 from array
import array
8 import ProviderHistoHelpers
14 SystematicNameDictionary = {
15 'gammajetdphi' :
'Gjet_dPhi',
16 'gammajetgenerator' :
'Gjet_Generator',
17 'gammajetjvt' :
'Gjet_JVT',
18 'gammajetoutofcone' :
'Gjet_OOC',
21 'gammajetphscalez' :
'Gjet_GamESZee',
22 'gammajetphsmear' :
'Gjet_GamEsmear',
23 'gammajetpurity' :
'Gjet_Purity',
24 'gammajetstat1' :
'Gjet_Stat1',
25 'gammajetstat2' :
'Gjet_Stat2',
26 'gammajetstat3' :
'Gjet_Stat3',
27 'gammajetstat4' :
'Gjet_Stat4',
28 'gammajetstat5' :
'Gjet_Stat5',
29 'gammajetstat6' :
'Gjet_Stat6',
30 'gammajetstat7' :
'Gjet_Stat7',
31 'gammajetstat8' :
'Gjet_Stat8',
32 'gammajetstat9' :
'Gjet_Stat9',
33 'gammajetstat10' :
'Gjet_Stat10',
34 'gammajetstat11' :
'Gjet_Stat11',
35 'gammajetstat12' :
'Gjet_Stat12',
36 'gammajetstat13' :
'Gjet_Stat13',
37 'gammajetstat14' :
'Gjet_Stat14',
38 'gammajetstat15' :
'Gjet_Stat15',
39 'gammajetsubleadingjet' :
'Gjet_Veto',
40 'mjbalpha' :
'MJB_Alpha',
41 'mjbbeta' :
'MJB_Beta',
42 'mjbfrag' :
'MJB_Fragmentation',
43 'mjbptasymm' :
'MJB_Asym',
44 'mjbptthreshold' :
'MJB_Threshold',
45 'mjbstat1' :
'MJB_Stat1',
46 'mjbstat2' :
'MJB_Stat2',
47 'mjbstat3' :
'MJB_Stat3',
48 'mjbstat4' :
'MJB_Stat4',
49 'mjbstat5' :
'MJB_Stat5',
50 'mjbstat6' :
'MJB_Stat6',
51 'mjbstat7' :
'MJB_Stat7',
52 'mjbstat8' :
'MJB_Stat8',
53 'mjbstat9' :
'MJB_Stat9',
54 'mjbstat10' :
'MJB_Stat10',
55 'mjbstat11' :
'MJB_Stat11',
56 'mjbstat12' :
'MJB_Stat12',
57 'mjbstat13' :
'MJB_Stat13',
58 'mjbstat14' :
'MJB_Stat14',
59 'mjbstat15' :
'MJB_Stat15',
60 'mjbstat16' :
'MJB_Stat16',
61 'zjetdphi' :
'Zjet_dPhi',
64 'zjetescalez' :
'Zjet_ElecESZee',
65 'zjetesmear' :
'Zjet_ElecEsmear',
66 'zjetgenerator' :
'Zjet_MC',
68 'zjetjvt' :
'Zjet_JVT',
69 'zjetmuscale' :
'Zjet_MuScale',
70 'zjetmusmearid' :
'Zjet_MuSmearID',
71 'zjetmusmearms' :
'Zjet_MuSmearMS',
72 'zjetoutofcone' :
'Zjet_KTerm',
73 'zjetstat1' :
'Zjet_Stat1',
74 'zjetstat2' :
'Zjet_Stat2',
75 'zjetstat3' :
'Zjet_Stat3',
76 'zjetstat4' :
'Zjet_Stat4',
77 'zjetstat5' :
'Zjet_Stat5',
78 'zjetstat6' :
'Zjet_Stat6',
79 'zjetstat7' :
'Zjet_Stat7',
80 'zjetstat8' :
'Zjet_Stat8',
81 'zjetstat9' :
'Zjet_Stat9',
82 'zjetstat10' :
'Zjet_Stat10',
83 'zjetstat11' :
'Zjet_Stat11',
84 'zjetstat12' :
'Zjet_Stat12',
85 'zjetstat13' :
'Zjet_Stat13',
86 'zjetsubleadingjet' :
'Zjet_Veto',
89 'etaintercalibrationmodelling' :
'InSituProp_EtaIntercalModelling',
90 'etaintercalibrationtotalstat' :
'InSituProp_EtaIntercalStat',
91 'flavorcomposition' :
'InSituProp_FlavorComposition',
92 'flavorresponse' :
'InSituProp_FlavorResponse',
93 'pileupoffsetmu' :
'InSituProp_PileupOffsetMu',
94 'pileupoffsetnpv' :
'InSituProp_PileupOffsetNPV',
95 'pileupptterm' :
'InSituProp_PileupPtTerm',
96 'pileuprhotopology' :
'InSituProp_PileupRhoTopology',
97 'punchthroughmc15' :
'InSituProp_PunchThroughMC',
101 'EMJES_R4' :
'AntiKt4Topo_EMJES',
103 'LCJES_R4' :
'AntiKt4Topo_LCJES',
108 if not dirName.endswith(
"/"):
109 dirName = dirName +
"/"
113 subDirs =
sorted(glob.glob(dirName+
"*/"))
114 for aSubDirName
in subDirs:
117 for aDirDef,aJetDef
in jetDefDict.iteritems():
118 if aDirDef
in aSubDirName:
122 print "Failed to determine jet definition for directory:",aSubDirName
127 systFiles =
sorted(glob.glob(aSubDirName+
"/SystError_*.txt"))
128 for aSystFile
in systFiles:
130 aSubDirName = aSubDirName.rstrip(
"/")
131 systematicNameHandle = aSystFile.replace(aSubDirName+
"/SystError_",
"")
132 systematicNameHandle = systematicNameHandle.replace(
".txt",
"")
133 systematicName = SystematicNameDictionary[systematicNameHandle]
134 print "Making histogram %s --> %s"%(systematicNameHandle,systematicName)
137 systematicFile =
open(aSystFile,
"r")
142 for line
in systematicFile.readlines():
143 line = line.strip(
"\r\n")
144 lowEdge =
float(line.split()[0])
145 systVal =
float(line.split()[2].strip())
147 lowBinEdges.append(lowEdge)
148 systValues.append(systVal)
151 systematicFile.close()
154 lowBinEdges.append(2500.)
155 systValues.append(systValues[-1])
158 lowBinEdgesArray =
array(
'd',lowBinEdges)
159 systValuesArray =
array(
'd',systValues)
160 histoName = systematicName+
"_"+jetDef
161 histo1D = TH1D(histoName+
"_1D",histoName+
"_1D",len(lowBinEdges)-1,lowBinEdgesArray)
164 for iBin
in xrange(1,histo1D.GetNbinsX()+1):
165 histo1D.SetBinContent(iBin,systValues[iBin-1])
167 histos[jetDef][systematicName] = histo1D