11from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
12from ParseInsituInput
import ReadInSituHistograms
13from ParsePileupInput
import ReadPileupHistograms
14from ParseNonClosureInput
import ReadNonClosureHistograms
15from ParseHighPtInput
import ReadHighPtHistograms,ReadHighPtHistogramsFromOldFile
16from ParseFlavourInput
import ReadFlavourHistograms
17from ParsebJESInput
import ReadBJESHistograms
18from ParsePunchthroughInput
import ReadPunchthroughHistograms
21from itertools
import groupby
23 return [int(
''.join(g))
if k
else ''.join(g)
for k, g
in groupby(s[0], str.isdigit)]
47freezeFlavourInPt =
True
53 print "USAGE: Expected the following arguments"
54 print " 1. InSitu directory path"
55 print " 2. Eta intercalibration directory path"
56 print " 3. Path or directory for single-particle: currently 2012 recommendation"
57 print " 4. MC nonclosure directory path"
58 print " 5. Pileup directory path"
59 print " 6. Flavour directory path"
60 print " 7. bJES directory path"
61 print " 8. Punchthrough directory path"
64outBaselineFile =
"JESUncertainty_AllComponents_ICHEP2016.root"
65inSituDir = sys.argv[1]
66etaIntercalDir = sys.argv[2]
67highPtDir = sys.argv[3]
68nonclosureDir = sys.argv[4]
69pileupDir = sys.argv[5]
70flavourDir = sys.argv[6]
72punchthroughDir = sys.argv[8]
75if not outBaselineFile.endswith(
".root"):
76 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
78if not os.path.exists(inSituDir):
79 print "InSitu directory does not exist:",inSituDir
81if not os.path.exists(etaIntercalDir):
82 print "Eta intercalibration directory does not exist:",etaIntercalDir
84if not os.path.exists(highPtDir):
85 print "HighPt directory does not exist:",highPtDir
87if not os.path.exists(nonclosureDir):
88 print "MC nonclosure directory does not exist:",nonclosureDir
90if not os.path.exists(pileupDir):
91 print "Pileup directory does not exist:",pileupDir
93if not os.path.exists(flavourDir):
94 print "Flavour directory does not exist:",flavourDir
96if not os.path.exists(bJESDir):
97 print "bJES directory does not exist:",bJESDir
99if not os.path.exists(punchthroughDir):
100 print "Punchthrough directory does not exist:",punchthroughDir
104currentDir = gDirectory
108print "Reading inputs..."
111inSituHistos = ReadInSituHistograms(inSituDir)
112etaIntercalHistos = ReadEtaIntercalibrationHistograms(etaIntercalDir)
113highPtHistos = ReadHighPtHistogramsFromOldFile(highPtDir)
114nonclosureHistos = ReadNonClosureHistograms(nonclosureDir,
True)
115pileupHistos = ReadPileupHistograms(pileupDir)
116flavourHistos = ReadFlavourHistograms(flavourDir,freezeFlavourInPt)
117bJESHistos = ReadBJESHistograms(bJESDir)
118punchthroughHistos = ReadPunchthroughHistograms(punchthroughDir)
120print nonclosureHistos
123print "Merging inputs..."
124jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo",
"AntiKt4Topo_LCJES" :
"AntiKt4LCTopo"}
126for aJetDef
in jetDefs.keys():
128 systematics[aJetDef] = dict(
129 inSituHistos[aJetDef].items() +
130 etaIntercalHistos[aJetDef].items() +
131 highPtHistos[aJetDef].items() +
132 nonclosureHistos[aJetDef].items() +
133 pileupHistos[aJetDef].items() +
134 flavourHistos[aJetDef].items() +
135 bJESHistos[aJetDef].items() +
136 punchthroughHistos[aJetDef].items()
140print "Writing to output file",outBaselineFile,
"..."
141baselineFile = TFile(outBaselineFile,
"RECREATE")
142for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
143 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
145 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
146 aSystHisto.Write(aSystHisto.GetTitle())
150gDirectory = currentDir