2 from array
import array
9 from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
10 from ParseInsituInput_MJB
import ReadInSituHistograms
11 from ParsePileupInput
import ReadPileupHistograms
12 from ParseFlavourInput
import ReadFlavourHistograms
13 from ParsePunchthroughInput
import ReadPunchthroughHistograms
14 from Parse2012Input
import Read2012Histograms
17 from itertools
import groupby
19 return [
int(
''.
join(g))
if k
else ''.
join(g)
for k, g
in groupby(s[0], str.isdigit)]
41 freezeFlavourInPt =
False
58 print "USAGE: Expected the following arguments"
59 print " 1. Directory path to V+jet calibrations"
60 print " 2. Eta intercalibration directory path"
61 print " 3. Pileup directory path"
62 print " 5. Flavour directory path"
63 print " 6. Punchthrough directory path"
66 outBaselineFile =
"JESUncertainty_forMJB.root"
67 theVPlusJetsDir = sys.argv[1]
68 etaIntercalDir = sys.argv[2]
69 pileupDir = sys.argv[3]
70 flavourDir = sys.argv[4]
71 punchthroughDir = sys.argv[5]
74 if not outBaselineFile.endswith(
".root"):
75 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
77 if not os.path.exists(theVPlusJetsDir):
78 print "V+jets directory does not exist:",theVPlusJetsDir
80 if not os.path.exists(etaIntercalDir):
81 print "Eta intercalibration directory does not exist:",etaIntercalDir
83 if not os.path.exists(pileupDir):
84 print "Pileup directory does not exist:",pileupDir
86 if not os.path.exists(flavourDir):
87 print "Flavour directory does not exist:",flavourDir
89 if not os.path.exists(punchthroughDir):
90 print "Punchthrough directory does not exist:",punchthroughDir
95 currentDir = gDirectory
99 print "Reading inputs..."
111 print "Merging inputs..."
112 jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo",
"AntiKt4PFlow_EMJES" :
"AntiKt4EMPFlow"}
114 for aJetDef
in jetDefs.keys():
116 systematics[aJetDef] = {}
117 dictsToUse = [punchthroughHistos,
123 for dictionary
in dictsToUse :
126 systematics[aJetDef].
update(dictionary[aJetDef].
items())
128 print systematics[aJetDef]
132 print "Writing to output file",outBaselineFile,
"..."
133 baselineFile = TFile(outBaselineFile,
"RECREATE")
134 for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
135 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
137 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
138 aSystHisto.Write(aSystHisto.GetTitle())
142 gDirectory = currentDir