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
16 from ParseFlavourInput
import ReadFlavourHistograms
17 from ParsebJESInput
import ReadBJESHistograms
18 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)]
28 print "USAGE: Expected the following arguments"
29 print " 1. Eta intercalibration directory path"
30 print " 2. InSitu directory path"
31 print " 3. Pileup directory path"
32 print " 4. MC nonclosure directory path"
33 print " 5. HighPt directory path"
34 print " 6. Flavour directory path"
35 print " 7. bJES directory path"
36 print " 8. Punchthrough directory path"
39 outBaselineFile =
"JESUncertainty_BaseComponents_2012.root"
40 outMultijetFile =
"MJESUncertainty_2012.root"
41 etaIntercalDir = sys.argv[1]
42 inSituDir = sys.argv[2]
43 pileupDir = sys.argv[3]
44 nonclosureDir = sys.argv[4]
45 highPtDir = sys.argv[5]
46 flavourDir = sys.argv[6]
48 punchthroughDir = sys.argv[8]
51 if not outBaselineFile.endswith(
".root"):
52 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
54 if not outMultijetFile.endswith(
".root"):
55 print "Output multijet ROOT file doesn't appear to be a root file:",outMultijetFile
57 if not os.path.exists(etaIntercalDir):
58 print "Eta intercalibration directory does not exist:",etaIntercalDir
60 if not os.path.exists(inSituDir):
61 print "InSitu directory does not exist:",inSituDir
63 if not os.path.exists(pileupDir):
64 print "Pileup directory does not exist:",pileupDir
66 if not os.path.exists(nonclosureDir):
67 print "MC nonclosure directory does not exist:",nonclosureDir
69 if not os.path.exists(highPtDir):
70 print "HighPt directory does not exist:",highPtDir
72 if not os.path.exists(flavourDir):
73 print "Flavour directory does not exist:",flavourDir
75 if not os.path.exists(bJESDir):
76 print "bJES directory does not exist:",bJESDir
78 if not os.path.exists(punchthroughDir):
79 print "Punchthrough directory does not exist:",punchthroughDir
83 currentDir = gDirectory
88 print "Reading inputs..."
101 print "Merging inputs..."
102 jetDefs = [
"AntiKt4Topo_EMJES",
"AntiKt4Topo_LCJES",
"AntiKt6Topo_EMJES",
"AntiKt6Topo_LCJES"]
104 for aJetDef
in jetDefs:
105 systematics[aJetDef] = dict(
106 etaIntercalHistos[aJetDef].
items() +
107 inSituHistos[aJetDef].
items() +
108 pileupHistos[aJetDef].
items() +
109 nonclosureHistos[aJetDef].
items() +
110 highPtHistos[aJetDef].
items() +
111 flavourHistos[aJetDef].
items() +
112 bJESHistos[aJetDef].
items() +
113 punchthroughHistos[aJetDef].
items()
117 print "Writing to output file..."
118 baselineFile = TFile(outBaselineFile,
"RECREATE")
119 multijetFile = TFile(outMultijetFile,
"RECREATE")
120 for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
121 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
122 if "bJES" in aSystName
or "flavor" in aSystName
or "Flavor" in aSystName
or "PunchThrough" in aSystName
or "Close" in aSystName:
127 aSystHisto.SetTitle(aSystName+
"_"+aJetDef)
128 aSystHisto.Write(aSystHisto.GetTitle())
133 gDirectory = currentDir