2 from array
import array
6 import ProviderHistoHelpers
10 return [key.GetName()
for key
in gDirectory.GetListOfKeys()]
11 TFile.GetKeyNames = GetKeyNames
13 SystematicNames_timeinvariant = {
14 'EtaIntercalibration_TotalSyst' :
'EtaIntercalibration_TotalSyst',\
17 SystematicNames_timedependent = {
18 'E_4TeV' :
'EtaIntercalibration_NonClosure_highE',\
19 'Eta_2p4_to_2p6' :
'EtaIntercalibration_NonClosure_posEta',\
20 'Eta_m2p6_to_m2p4' :
'EtaIntercalibration_NonClosure_negEta'
24 'AntiKt4EMTopo' :
'AntiKt4Topo_EMJES',
25 'AntiKt4EMPFlow' :
'AntiKt4PFlow_EMJES',
32 openFile = TFile.Open(filename,
"READ")
33 dirName =
"StatNuisanceParams"
34 stat_keys = openFile.GetKeyNames(dirName)
37 for thing
in jetDefDict.keys() :
38 if thing
in filename :
41 for key
in stat_keys :
42 hist = openFile.Get(dirName+
"/"+key)
45 save_name =
"EtaIntercalibration_"+key
46 hist.SetName(save_name+
"_"+jet_def)
47 hist.SetTitle(save_name+
"_"+jet_def)
49 dictionary[jetDefDict[jet_def]][save_name] = hist
54 if not dirName.endswith(
"/"):
55 dirName = dirName +
"/"
60 files =
sorted(glob.glob(dirName+
"*{0}*.root".
format(year)))
61 for aFileName
in files:
64 for aFileDef,aJetDef
in jetDefDict.iteritems():
65 if aFileDef
in aFileName:
69 print "Failed to determine jet definition for file:",aFileName
71 if jetDef
not in histos.keys() :
75 inFile = TFile(aFileName,
"READ")
76 contents = inFile.GetKeyNames()
79 SystematicNames = SystematicNames_timedependent
81 SystematicNames = SystematicNames_timeinvariant
83 for aName
in SystematicNames.keys():
84 if not "NonClosure" in SystematicNames[aName] :
86 getsystematicName = aName +
"_" + jetDef.replace(
"Topo",
"")
88 getsystematicName = aName +
"_" + jetDef.replace(
"4PFlow",
"4EMPFlow").
replace(
"_EMJES",
"_PFlowJES")
90 getsystematicName = aName
92 if not getsystematicName
in contents :
95 histo = inFile.Get(getsystematicName)
97 systematicName = SystematicNames[aName] +
"_" + jetDef
98 histo.SetName(systematicName+
"_old")
102 histoNew.SetDirectory(0)
103 histos[jetDef][SystematicNames[aName]] = histoNew
109 for aName,storeName
in SystematicNames.iteritems():
110 for aJetDef
in histos.keys():
111 if not storeName
in histos[aJetDef].
keys() :
112 print "Failed to find histogram:", storeName,
"for jet definition",aJetDef
116 for thisDef
in jetDefDict.keys() :
117 files =
sorted(glob.glob(dirName+
"*{0}*_statErr_*{1}*.root".
format(year,thisDef)))
119 print "Did not find right number of stat term files!"
127 print "Histos out here"