11from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
12from ParseInsituInput
import ReadInSituHistograms
13from ParsePileupInput
import ReadPileupHistograms
14from ParseNonClosureInput
import ReadNonClosureHistograms
15from ParseHighPtInput
import ReadHighPtHistograms
16from ParseFlavourInput
import ReadFlavourHistograms
17from ParsebJESInput
import ReadBJESHistograms
18from ParsePunchthroughInput
import ReadPunchthroughHistograms
22from itertools
import groupby
24 return [int(
''.join(g))
if k
else ''.join(g)
for k, g
in groupby(s[0], str.isdigit)]
28 print "USAGE: Expected the following arguments"
29 print " 1. Eta intercalibration directory path"
30 print " 2. InSitu directory path"
31 print " 3. Pileup directory path"
32 print " 4. MC nonclosure directory path"
33 print " 5. HighPt directory path"
34 print " 6. Flavour directory path"
35 print " 7. bJES directory path"
36 print " 8. Punchthrough directory path"
39outBaselineFile =
"JESUncertainty_BaseComponents_2012.root"
40outMultijetFile =
"MJESUncertainty_2012.root"
41etaIntercalDir = sys.argv[1]
42inSituDir = sys.argv[2]
43pileupDir = sys.argv[3]
44nonclosureDir = sys.argv[4]
45highPtDir = sys.argv[5]
46flavourDir = sys.argv[6]
48punchthroughDir = sys.argv[8]
51if not outBaselineFile.endswith(
".root"):
52 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
54if not outMultijetFile.endswith(
".root"):
55 print "Output multijet ROOT file doesn't appear to be a root file:",outMultijetFile
57if not os.path.exists(etaIntercalDir):
58 print "Eta intercalibration directory does not exist:",etaIntercalDir
60if not os.path.exists(inSituDir):
61 print "InSitu directory does not exist:",inSituDir
63if not os.path.exists(pileupDir):
64 print "Pileup directory does not exist:",pileupDir
66if not os.path.exists(nonclosureDir):
67 print "MC nonclosure directory does not exist:",nonclosureDir
69if not os.path.exists(highPtDir):
70 print "HighPt directory does not exist:",highPtDir
72if not os.path.exists(flavourDir):
73 print "Flavour directory does not exist:",flavourDir
75if not os.path.exists(bJESDir):
76 print "bJES directory does not exist:",bJESDir
78if not os.path.exists(punchthroughDir):
79 print "Punchthrough directory does not exist:",punchthroughDir
83currentDir = gDirectory
88print "Reading inputs..."
89etaIntercalHistos = ReadEtaIntercalibrationHistograms(etaIntercalDir)
90inSituHistos = ReadInSituHistograms(inSituDir)
91pileupHistos = ReadPileupHistograms(pileupDir)
92nonclosureHistos = ReadNonClosureHistograms(nonclosureDir)
93highPtHistos = ReadHighPtHistograms(highPtDir)
94flavourHistos = ReadFlavourHistograms(flavourDir)
95bJESHistos = ReadBJESHistograms(bJESDir)
96punchthroughHistos = ReadPunchthroughHistograms(punchthroughDir)
101print "Merging inputs..."
102jetDefs = [
"AntiKt4Topo_EMJES",
"AntiKt4Topo_LCJES",
"AntiKt6Topo_EMJES",
"AntiKt6Topo_LCJES"]
104for aJetDef
in jetDefs:
105 systematics[aJetDef] = dict(
106 etaIntercalHistos[aJetDef].items() +
107 inSituHistos[aJetDef].items() +
108 pileupHistos[aJetDef].items() +
109 nonclosureHistos[aJetDef].items() +
110 highPtHistos[aJetDef].items() +
111 flavourHistos[aJetDef].items() +
112 bJESHistos[aJetDef].items() +
113 punchthroughHistos[aJetDef].items()
117print "Writing to output file..."
118baselineFile = TFile(outBaselineFile,
"RECREATE")
119multijetFile = TFile(outMultijetFile,
"RECREATE")
120for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
121 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
122 if "bJES" in aSystName
or "flavor" in aSystName
or "Flavor" in aSystName
or "PunchThrough" in aSystName
or "Close" in aSystName:
127 aSystHisto.SetTitle(aSystName+
"_"+aJetDef)
128 aSystHisto.Write(aSystHisto.GetTitle())
133gDirectory = currentDir