4 from array
import array
11 from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
12 from ParseInsituInput
import ReadInSituHistograms
13 from ParsePileupInput
import ReadPileupHistograms
14 from ParseNonClosureInput
import ReadNonClosureHistograms
15 from ParseHighPtInput
import ReadHighPtHistograms,ReadHighPtHistogramsFromOldFile
16 from ParseFlavourInput
import ReadFlavourHistograms
17 from ParsebJESInput
import ReadBJESHistograms
18 from ParsePunchthroughInput
import ReadPunchthroughHistograms
21 from itertools
import groupby
23 return [
int(
''.
join(g))
if k
else ''.
join(g)
for k, g
in groupby(s[0], str.isdigit)]
47 freezeFlavourInPt =
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"
64 outBaselineFile =
"JESUncertainty_AllComponents_ICHEP2016.root"
65 inSituDir = sys.argv[1]
66 etaIntercalDir = sys.argv[2]
67 highPtDir = sys.argv[3]
68 nonclosureDir = sys.argv[4]
69 pileupDir = sys.argv[5]
70 flavourDir = sys.argv[6]
72 punchthroughDir = sys.argv[8]
75 if not outBaselineFile.endswith(
".root"):
76 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
78 if not os.path.exists(inSituDir):
79 print "InSitu directory does not exist:",inSituDir
81 if not os.path.exists(etaIntercalDir):
82 print "Eta intercalibration directory does not exist:",etaIntercalDir
84 if not os.path.exists(highPtDir):
85 print "HighPt directory does not exist:",highPtDir
87 if not os.path.exists(nonclosureDir):
88 print "MC nonclosure directory does not exist:",nonclosureDir
90 if not os.path.exists(pileupDir):
91 print "Pileup directory does not exist:",pileupDir
93 if not os.path.exists(flavourDir):
94 print "Flavour directory does not exist:",flavourDir
96 if not os.path.exists(bJESDir):
97 print "bJES directory does not exist:",bJESDir
99 if not os.path.exists(punchthroughDir):
100 print "Punchthrough directory does not exist:",punchthroughDir
104 currentDir = gDirectory
108 print "Reading inputs..."
120 print nonclosureHistos
123 print "Merging inputs..."
124 jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo",
"AntiKt4Topo_LCJES" :
"AntiKt4LCTopo"}
126 for 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()
140 print "Writing to output file",outBaselineFile,
"..."
141 baselineFile = TFile(outBaselineFile,
"RECREATE")
142 for 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())
150 gDirectory = currentDir