9from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
10from ParseInsituInput_MJB
import ReadInSituHistograms
11from ParsePileupInput
import ReadPileupHistograms
12from ParseFlavourInput
import ReadFlavourHistograms
13from ParsePunchthroughInput
import ReadPunchthroughHistograms
14from Parse2012Input
import Read2012Histograms
17from itertools
import groupby
19 return [int(
''.join(g))
if k
else ''.join(g)
for k, g
in groupby(s[0], str.isdigit)]
41freezeFlavourInPt =
False
58 print "USAGE: Expected the following arguments"
59 print " 1. Directory path to V+jet calibrations"
60 print " 2. Eta intercalibration directory path"
61 print " 3. Pileup directory path"
62 print " 5. Flavour directory path"
63 print " 6. Punchthrough directory path"
66outBaselineFile =
"JESUncertainty_forMJB.root"
67theVPlusJetsDir = sys.argv[1]
68etaIntercalDir = sys.argv[2]
69pileupDir = sys.argv[3]
70flavourDir = sys.argv[4]
71punchthroughDir = sys.argv[5]
74if not outBaselineFile.endswith(
".root"):
75 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
77if not os.path.exists(theVPlusJetsDir):
78 print "V+jets directory does not exist:",theVPlusJetsDir
80if not os.path.exists(etaIntercalDir):
81 print "Eta intercalibration directory does not exist:",etaIntercalDir
83if not os.path.exists(pileupDir):
84 print "Pileup directory does not exist:",pileupDir
86if not os.path.exists(flavourDir):
87 print "Flavour directory does not exist:",flavourDir
89if not os.path.exists(punchthroughDir):
90 print "Punchthrough directory does not exist:",punchthroughDir
95currentDir = gDirectory
99print "Reading inputs..."
102theVPlusJetsHistos = ReadInSituHistograms(theVPlusJetsDir)
103etaIntercalHistos = ReadEtaIntercalibrationHistograms(etaIntercalDir)
104pileupHistos = ReadPileupHistograms(pileupDir)
106flavourHistos = ReadFlavourHistograms(flavourDir,freezeFlavourInPt)
108punchthroughHistos = ReadPunchthroughHistograms(punchthroughDir)
111print "Merging inputs..."
112jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo",
"AntiKt4PFlow_EMJES" :
"AntiKt4EMPFlow"}
114for aJetDef
in jetDefs.keys():
116 systematics[aJetDef] = {}
117 dictsToUse = [punchthroughHistos,
123 for dictionary
in dictsToUse :
126 systematics[aJetDef].update(dictionary[aJetDef].items())
128 print systematics[aJetDef]
132print "Writing to output file",outBaselineFile,
"..."
133baselineFile = TFile(outBaselineFile,
"RECREATE")
134for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
135 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
137 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
138 aSystHisto.Write(aSystHisto.GetTitle())
142gDirectory = currentDir