4 from array
import array
11 from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
12 from ParseInsituInput_MJB
import ReadInSituHistograms
13 from ParsePileupInput
import ReadPileupHistograms
14 from ParseFlavourInput
import ReadFlavourHistograms
15 from ParsePunchthroughInput
import ReadPunchthroughHistograms
16 from Parse2012Input
import Read2012Histograms
19 from itertools
import groupby
21 return [
int(
''.
join(g))
if k
else ''.
join(g)
for k, g
in groupby(s[0], str.isdigit)]
44 freezeFlavourInPt =
True
50 print "USAGE: Expected the following arguments"
51 print " 1. Directory path to V+jet calibrations"
52 print " 2. Eta intercalibration directory path"
53 print " 3. Pileup directory path"
54 print " 5. Flavour directory path"
55 print " 6. Punchthrough directory path"
58 outBaselineFile =
"JESUncertainty_forMJB.root"
59 theVPlusJetsDir = sys.argv[1]
60 etaIntercalDir = sys.argv[2]
61 pileupDir = sys.argv[3]
62 flavourDir = sys.argv[4]
63 punchthroughDir = sys.argv[5]
66 if not outBaselineFile.endswith(
".root"):
67 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
69 if not os.path.exists(theVPlusJetsDir):
70 print "V+jets directory does not exist:",theVPlusJetsDir
72 if not os.path.exists(etaIntercalDir):
73 print "Eta intercalibration directory does not exist:",etaIntercalDir
75 if not os.path.exists(pileupDir):
76 print "Pileup directory does not exist:",pileupDir
78 if not os.path.exists(flavourDir):
79 print "Flavour directory does not exist:",flavourDir
81 if not os.path.exists(punchthroughDir):
82 print "Punchthrough directory does not exist:",punchthroughDir
87 currentDir = gDirectory
91 print "Reading inputs..."
97 print "For pileup, got:"
98 for jetdef
in pileupHistos.keys() :
99 print "Jet def",jetdef
100 print pileupHistos[jetdef]
103 print "For flavour, got:"
104 for jetdef
in flavourHistos.keys() :
105 print "Jet def",jetdef
106 print flavourHistos[jetdef]
109 print "For punchthrough, got:"
110 for jetdef
in punchthroughHistos.keys() :
111 print "Jet def",jetdef
112 print punchthroughHistos[jetdef]
115 print "Merging inputs..."
116 jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo",
"AntiKt4Topo_LCJES" :
"AntiKt4LCTopo"}
118 for aJetDef
in jetDefs.keys():
120 systematics[aJetDef] = {}
121 dictsToUse = [punchthroughHistos,
127 for dictionary
in dictsToUse :
144 systematics[aJetDef].
update(dictionary[aJetDef].
items())
146 print "\nFor jet def",aJetDef,
"added:"
147 print systematics[aJetDef]
151 print "Writing to output file",outBaselineFile,
"..."
152 baselineFile = TFile(outBaselineFile,
"RECREATE")
153 for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
154 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
156 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
157 aSystHisto.Write(aSystHisto.GetTitle())
161 gDirectory = currentDir