4 from array
import array
11 from ParseCurrentFile
import ReadCurrentHistograms
14 from itertools
import groupby
16 return [
int(
''.
join(g))
if k
else ''.
join(g)
for k, g
in groupby(s[0], str.isdigit)]
35 print "USAGE: Expected the following arguments"
36 print " 1. Directory path to share directory for current 2015 recommendations"
39 outBaselineFile =
"JESUncertaintyComponentsForReductions.root"
41 theCurrentDir = sys.argv[1]
44 if not outBaselineFile.endswith(
".root"):
45 print "Output baseline ROOT file doesn't appear to be a root file:",outBaselineFile
47 if not os.path.exists(theCurrentDir):
48 print "2012 directory does not exist:",theCurrentDir
52 currentDir = gDirectory
56 print "Reading inputs..."
61 print theCurrentHistos
64 print "Merging inputs..."
65 jetDefs = [
"AntiKt4EMTopo"]
68 for aJetDef
in jetDefs :
69 systematics[aJetDef] = dict(
70 theCurrentHistos[aJetDef].
items()
74 print "Writing to output file",outBaselineFile,
"..."
75 baselineFile = TFile(outBaselineFile,
"RECREATE")
77 for aJetDef,aSyst
in sorted(systematics.iteritems(),key=natural_sort):
78 for aSystName,aSystHisto
in sorted(aSyst.iteritems(),key=natural_sort):
80 if (aSystName.startswith(
"LAr")
or\
81 aSystName.startswith(
"Zjet")
or\
82 aSystName.startswith(
"Gjet")
or\
83 aSystName.startswith(
"MJB")
or\
84 aSystName.startswith(
"SingleParticle")
or\
85 aSystName.startswith(
"Xcalib")) :
86 if type(aSystHisto)
is TH1D :
87 aSystHisto.SetTitle(aSystName+
"_"+aJetDef)
88 aSystHisto.Write(aSystHisto.GetTitle())
89 elif type(aSystHisto)
is TH2D :
90 newHist = aSystHisto.ProjectionX()
92 newHist.SetDirectory(0)
93 for xbin
in range(aSystHisto.GetNbinsX()) :
96 for ybin
in range(aSystHisto.GetNbinsY()) :
97 thisval = aSystHisto.GetBinContent(xbin,ybin)
98 if math.fabs(thisval) > math.fabs(largest) :
99 if "50nsVs25ns_Central" in aSystName :
100 print "New largest at ",xbin,
",",ybin,
":",thisval
102 newHist.SetBinContent(xbin,largest)
103 newHist.SetTitle(aSystName+
"_"+aJetDef)
104 newHist.Write(newHist.GetTitle())
106 print "Unexpected type!"
109 print "Leaving out histo",aSystName
114 gDirectory = currentDir