11from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
12from ParseInsituInput_MJB
import ReadInSituHistograms
13from ParsePileupInput
import ReadPileupHistograms
14from ParseFlavourInput
import ReadFlavourHistograms
15from ParsePunchthroughInput
import ReadPunchthroughHistograms
16from Parse2012Input
import Read2012Histograms
19from itertools
import groupby
21 return [int(
''.join(g))
if k
else ''.join(g)
for k, g
in groupby(s[0], str.isdigit)]
44freezeFlavourInPt =
True
50 print "USAGE: Expected the following arguments"
51 print " 1. Directory path to V+jet calibrations"
52 print " 2. Eta intercalibration directory path"
53 print " 3. Pileup directory path"
54 print " 5. Flavour directory path"
55 print " 6. Punchthrough directory path"
58outBaselineFile =
"JESUncertainty_forMJB.root"
59theVPlusJetsDir = sys.argv[1]
60etaIntercalDir = sys.argv[2]
61pileupDir = sys.argv[3]
62flavourDir = sys.argv[4]
63punchthroughDir = sys.argv[5]
66if not outBaselineFile.endswith(
".root"):
67 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
69if not os.path.exists(theVPlusJetsDir):
70 print "V+jets directory does not exist:",theVPlusJetsDir
72if not os.path.exists(etaIntercalDir):
73 print "Eta intercalibration directory does not exist:",etaIntercalDir
75if not os.path.exists(pileupDir):
76 print "Pileup directory does not exist:",pileupDir
78if not os.path.exists(flavourDir):
79 print "Flavour directory does not exist:",flavourDir
81if not os.path.exists(punchthroughDir):
82 print "Punchthrough directory does not exist:",punchthroughDir
87currentDir = gDirectory
91print "Reading inputs..."
94theVPlusJetsHistos = ReadInSituHistograms(theVPlusJetsDir)
95etaIntercalHistos = ReadEtaIntercalibrationHistograms(etaIntercalDir)
96pileupHistos = ReadPileupHistograms(pileupDir)
97print "For pileup, got:"
98for jetdef
in pileupHistos.keys() :
99 print "Jet def",jetdef
100 print pileupHistos[jetdef]
102flavourHistos = ReadFlavourHistograms(flavourDir,freezeFlavourInPt)
103print "For flavour, got:"
104for jetdef
in flavourHistos.keys() :
105 print "Jet def",jetdef
106 print flavourHistos[jetdef]
108punchthroughHistos = ReadPunchthroughHistograms(punchthroughDir)
109print "For punchthrough, got:"
110for jetdef
in punchthroughHistos.keys() :
111 print "Jet def",jetdef
112 print punchthroughHistos[jetdef]
115print "Merging inputs..."
116jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo",
"AntiKt4Topo_LCJES" :
"AntiKt4LCTopo"}
118for aJetDef
in jetDefs.keys():
120 systematics[aJetDef] = {}
121 dictsToUse = [punchthroughHistos,
127 for dictionary
in dictsToUse :
144 systematics[aJetDef].update(dictionary[aJetDef].items())
146 print "\nFor jet def",aJetDef,
"added:"
147 print systematics[aJetDef]
151print "Writing to output file",outBaselineFile,
"..."
152baselineFile = TFile(outBaselineFile,
"RECREATE")
153for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
154 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
156 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
157 aSystHisto.Write(aSystHisto.GetTitle())
161gDirectory = currentDir