9from ParseEtaIntercalInput_detailed
import ReadEtaIntercalibrationHistograms
10from ParseInsituInput
import ReadInSituHistograms
11from ParsePileupInput
import ReadPileupHistograms
12from ParseNonClosureInput
import ReadNonClosureHistograms
13from ParseHighPtInput
import ReadHighPtHistograms,ReadHighPtHistogramsFromOldFile
14from ParseFlavourInput
import ReadFlavourHistograms
15from ParsebJESInput
import ReadBJESHistograms
16from ParsePunchthroughInput
import ReadPunchthroughHistograms
17from CopyJERHists
import ReadJERHistograms
20from itertools
import groupby
22 return [int(
''.join(g))
if k
else ''.join(g)
for k, g
in groupby(s[0], str.isdigit)]
46freezeFlavourInPt =
False
52 print "USAGE: Expected the following arguments"
53 print " 1. InSitu directory path"
54 print " 2. Eta intercalibration directory path"
55 print " 3. Path or directory for single-particle: currently 2012 recommendation"
56 print " 4. MC nonclosure directory path"
57 print " 5. Pileup directory path"
58 print " 6. Flavour directory path"
59 print " 7. bJES directory path"
60 print " 8. Punchthrough directory path"
63outBaselineFile =
"JESUncertainty_AllComponents_{0}.root"
64inSituDir = sys.argv[1]
65etaIntercalDir = sys.argv[2]
66highPtDir = sys.argv[3]
67nonclosureDir = sys.argv[4]
68pileupDir = sys.argv[5]
69flavourDir = sys.argv[6]
71punchthroughDir = sys.argv[8]
72oldJERFile = sys.argv[9]
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
102if not os.path.exists(oldJERFile) :
103 print "You need to specify a file to pick up JER from!",oldJERFile
106currentDir = gDirectory
110print "Reading inputs..."
113inSituHistos = ReadInSituHistograms(inSituDir)
114etaIntercalHistos_20152016 = ReadEtaIntercalibrationHistograms(etaIntercalDir,
"2015_16_")
115etaIntercalHistos_2017 = ReadEtaIntercalibrationHistograms(etaIntercalDir,
"2017_")
116etaIntercalHistos_general = ReadEtaIntercalibrationHistograms(etaIntercalDir,
"")
117highPtHistos = ReadHighPtHistogramsFromOldFile(highPtDir)
118nonclosureHistos = ReadNonClosureHistograms(nonclosureDir,
True)
119pileupHistos = ReadPileupHistograms(pileupDir)
120flavourHistos = ReadFlavourHistograms(flavourDir,freezeFlavourInPt)
121bJESHistos = ReadBJESHistograms(bJESDir)
122punchthroughHistos = ReadPunchthroughHistograms(punchthroughDir)
123JERHistos = ReadJERHistograms(oldJERFile)
126print "Merging inputs..."
127jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo",
'AntiKt4PFlow_EMJES' :
'AntiKt4EMPFlow'}
130for years
in (
"2015_16",
"2017") :
131 systematics[years] = {}
132 for aJetDef
in jetDefs.keys():
134 etaIntercalHistos_timeDep = etaIntercalHistos_2017
if "2017" in years
else etaIntercalHistos_20152016
136 systematics[years][aJetDef] = dict(
137 inSituHistos[aJetDef].items() +
138 etaIntercalHistos_timeDep[aJetDef].items() +
139 etaIntercalHistos_general[aJetDef].items() +
140 highPtHistos[aJetDef].items() +
141 nonclosureHistos[aJetDef].items() +
142 pileupHistos[aJetDef].items() +
143 flavourHistos[aJetDef].items() +
144 bJESHistos[aJetDef].items() +
145 punchthroughHistos[aJetDef].items()
150for years
in (
"2015_16",
"2017") :
151 outFileName = outBaselineFile.format(years)
152 print "Writing to output file",outFileName,
"..."
153 baselineFile = TFile(outFileName,
"RECREATE")
154 theseHists = systematics[years]
155 for aJetDef,aSyst
in sorted(theseHists.iteritems(),key=natural_sort):
156 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
158 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
159 aSystHisto.Write(aSystHisto.GetTitle())
162 for aJetDef,aSyst
in sorted(JERHistos.iteritems(),key=natural_sort):
163 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
164 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
165 aSystHisto.Write(aSystHisto.GetTitle())
169 gDirectory = currentDir