4 from array
import array
11 from ParseEtaIntercalInput
import ReadEtaIntercalibrationHistograms
12 from ParseInsituInput
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)]
43 scaleEtaInter3Regions =
True
44 scaleEtaInter2Regions =
False
45 freezeCrossCalAll =
True
46 freezeCrossCalBarrel =
False
47 freezeCrossCalCentral =
False
48 freezeFlavourInPt =
True
52 print "USAGE: Expected the following arguments"
53 print " 1. Directory path to V+jet calibrations"
54 print " 2. Eta intercalibration directory path"
55 print " 3. Pileup directory path"
56 print " 5. Flavour directory path"
57 print " 6. Old 2012 file from which to get punchthrough"
60 outBaselineFile =
"JESUncertainty_forMJB.root"
61 theVPlusJetsDir = sys.argv[1]
62 etaIntercalDir = sys.argv[2]
63 pileupDir = sys.argv[3]
64 flavourDir = sys.argv[4]
65 the2012Dir = sys.argv[5]
68 if not outBaselineFile.endswith(
".root"):
69 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
71 if not os.path.exists(theVPlusJetsDir):
72 print "V+jets directory does not exist:",theVPlusJetsDir
74 if not os.path.exists(etaIntercalDir):
75 print "Eta intercalibration directory does not exist:",etaIntercalDir
77 if not os.path.exists(pileupDir):
78 print "Pileup directory does not exist:",pileupDir
80 if not os.path.exists(flavourDir):
81 print "Flavour directory does not exist:",flavourDir
83 if not os.path.exists(the2012Dir) :
84 print "No 2012 file:",the2012Dir
88 currentDir = gDirectory
92 print "Reading inputs..."
101 punchthroughHistos = {}
102 for key
in the2012Histos :
103 innerDict = the2012Histos[key]
105 for name
in innerDict.keys() :
106 if "PunchThrough" in name :
107 newDict[name] = innerDict[name]
108 punchthroughHistos[key] = newDict
111 print "Merging inputs..."
112 jetDefs = {
"AntiKt4Topo_EMJES" :
"AntiKt4EMTopo",
"AntiKt4Topo_LCJES" :
"AntiKt4LCTopo"}
114 for aJetDef
in jetDefs.keys():
116 systematics[aJetDef] = {}
117 dictsToUse = [punchthroughHistos,
123 for dictionary
in dictsToUse :
127 if aJetDef
not in dictionary.keys() :
128 useInstead = dictionary[
"AntiKt4Topo_EMJES"]
132 for item
in useInstead.keys() :
133 thisHist = useInstead[item].Clone()
134 thisHistName = useInstead[item].GetName().
replace(
"EM",
"LC")
135 thisHist.SetName(thisHistName)
136 myNewDict[item] = thisHist
138 dictionary[aJetDef] = myNewDict
140 systematics[aJetDef].
update(dictionary[aJetDef].
items())
143 print "Writing to output file",outBaselineFile,
"..."
144 baselineFile = TFile(outBaselineFile,
"RECREATE")
145 for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
146 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
148 aSystHisto.SetTitle(aSystName+
"_"+jetDefs[aJetDef])
149 aSystHisto.Write(aSystHisto.GetTitle())
153 gDirectory = currentDir