2 from array
import array
9 from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
10 from ParseInsituInput_MJB
import ReadInSituHistograms
11 from ParsePileupInput
import ReadPileupHistograms
12 from ParseHighPtInput
import ReadHighPtHistograms,ReadHighPtHistogramsFromOldFile
13 from ParseFlavourInput
import ReadFlavourHistograms
14 from ParsebJESInput
import ReadBJESHistograms
15 from ParsePunchthroughInput
import ReadPunchthroughHistograms
16 from CreateNonClosureInput
import CreateNonClosureHistograms
19 from itertools
import groupby
21 return [
int(
''.
join(g))
if k
else ''.
join(g)
for k, g
in groupby(s[0], str.isdigit)]
45 freezeFlavourInPt =
False
51 print "USAGE: Expected the following arguments"
52 print " 1. InSitu directory path"
53 print " 2. Eta intercalibration directory path"
54 print " 3. Path or directory for single-particle: currently 2012 recommendation"
55 print " 5. Pileup directory path"
56 print " 6. Flavour directory path"
57 print " 7. bJES directory path"
58 print " 8. Punchthrough directory path"
61 outBaselineFile =
"JESUncertainty_AllComponents.root"
62 inSituDir = sys.argv[1]
63 etaIntercalDir = sys.argv[2]
64 highPtDir = sys.argv[3]
65 pileupDir = sys.argv[4]
66 flavourDir = sys.argv[5]
68 punchthroughDir = sys.argv[7]
71 if not outBaselineFile.endswith(
".root"):
72 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
74 if not os.path.exists(inSituDir):
75 print "InSitu directory does not exist:",inSituDir
77 if not os.path.exists(etaIntercalDir):
78 print "Eta intercalibration directory does not exist:",etaIntercalDir
80 if not os.path.exists(highPtDir):
81 print "HighPt directory does not exist:",highPtDir
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(bJESDir):
90 print "bJES directory does not exist:",bJESDir
92 if not os.path.exists(punchthroughDir):
93 print "Punchthrough directory does not exist:",punchthroughDir
97 currentDir = gDirectory
101 print "Reading inputs..."
114 print "Merging inputs..."
115 jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo",
"AntiKt4PFlow_EMJES" :
"AntiKt4EMPFlow"}
117 for aJetDef
in jetDefs.keys():
119 systematics[aJetDef] = dict(
120 inSituHistos[aJetDef].
items() +
121 etaIntercalHistos[aJetDef].
items() +
122 highPtHistos[aJetDef].
items() +
123 pileupHistos[aJetDef].
items() +
124 flavourHistos[aJetDef].
items() +
125 bJESHistos[aJetDef].
items() +
126 punchthroughHistos[aJetDef].
items() +
127 nonClosureHists[aJetDef].
items()
131 print "Writing to output file",outBaselineFile,
"..."
132 baselineFile = TFile(outBaselineFile,
"RECREATE")
133 for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
134 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
136 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
137 aSystHisto.Write(aSystHisto.GetTitle())
141 gDirectory = currentDir