4 from array
import array
11 from Parse2012Input
import Read2012Histograms
12 from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
13 from ParseInsituInput
import ReadInSituHistograms
14 from ParsePileupInput
import ReadPileupHistograms
15 from ParseNonClosureInput
import ReadNonClosureHistograms
16 from ParseHighPtInput
import ReadHighPtHistograms,ReadHighPtHistogramsFromOldFile
17 from ParseFlavourInput
import ReadFlavourHistograms
18 from ParsebJESInput
import ReadBJESHistograms
19 from ParsePunchthroughInput
import ReadPunchthroughHistograms
22 from itertools
import groupby
24 return [
int(
''.
join(g))
if k
else ''.
join(g)
for k, g
in groupby(s[0], str.isdigit)]
48 freezeFlavourInPt =
True
54 print "USAGE: Expected the following arguments"
55 print " 1. InSitu directory path"
56 print " 2. Eta intercalibration directory path"
57 print " 3. Path or directory for single-particle: currently 2012 recommendation"
58 print " 4. MC nonclosure directory path"
59 print " 5. Pileup directory path"
60 print " 6. Flavour directory path"
61 print " 7. bJES directory path"
62 print " 8. Punchthrough directory path"
65 outBaselineFile =
"JESUncertainty_AllComponents_Moriond2016.root"
66 inSituDir = sys.argv[1]
67 etaIntercalDir = sys.argv[2]
68 highPtDir = sys.argv[3]
69 nonclosureDir = sys.argv[4]
70 pileupDir = sys.argv[5]
71 flavourDir = sys.argv[6]
73 punchthroughDir = sys.argv[8]
76 if not outBaselineFile.endswith(
".root"):
77 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
79 if not os.path.exists(inSituDir):
80 print "InSitu directory does not exist:",inSituDir
82 if not os.path.exists(etaIntercalDir):
83 print "Eta intercalibration directory does not exist:",etaIntercalDir
85 if not os.path.exists(highPtDir):
86 print "HighPt directory does not exist:",highPtDir
88 if not os.path.exists(nonclosureDir):
89 print "MC nonclosure directory does not exist:",nonclosureDir
91 if not os.path.exists(pileupDir):
92 print "Pileup directory does not exist:",pileupDir
94 if not os.path.exists(flavourDir):
95 print "Flavour directory does not exist:",flavourDir
97 if not os.path.exists(bJESDir):
98 print "bJES directory does not exist:",bJESDir
100 if not os.path.exists(punchthroughDir):
101 print "Punchthrough directory does not exist:",punchthroughDir
105 currentDir = gDirectory
109 print "Reading inputs..."
122 print "Merging inputs..."
123 jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo"}
125 for aJetDef
in jetDefs.keys():
127 print etaIntercalHistos
129 systematics[aJetDef] = dict(
130 inSituHistos[aJetDef].
items() +
131 etaIntercalHistos[aJetDef].
items() +
132 highPtHistos[aJetDef].
items() +
133 nonclosureHistos[aJetDef].
items() +
134 pileupHistos[aJetDef].
items() +
135 flavourHistos[aJetDef].
items() +
136 bJESHistos[aJetDef].
items() +
137 punchthroughHistos[aJetDef].
items()
141 print "Writing to output file",outBaselineFile,
"..."
142 baselineFile = TFile(outBaselineFile,
"RECREATE")
143 for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
144 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
146 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
147 aSystHisto.Write(aSystHisto.GetTitle())
151 gDirectory = currentDir