Skip to content

Commit

Permalink
Merge pull request #12 from emanca/dev
Browse files Browse the repository at this point in the history
solving problem in normalisation
  • Loading branch information
emanca authored Mar 7, 2019
2 parents 37e300b + 28704bb commit f3ecb0b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions framework/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def plotStack(self):
c.SetTicks(0, 1)
c.cd()

hs.Draw("HIST")
hdata.Draw("same")
hdata.Draw("")
hs.Draw("HIST same")

legend.Draw()

Expand Down
9 changes: 5 additions & 4 deletions wmass/controlPlots/controlPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ def run(self,d):
runs = RDF('Runs', self.file)

if self.dataType == 'mc':
genEventSumw = runs.Mean("genEventSumw").GetValue()
genEventSumw = runs.Sum("genEventSumw").GetValue()
print (1.*self.xsec)/genEventSumw, 'lumiweight', genEventSumw, 'genEventSumw', self.xsec, 'xsec'
#genEventSumw=1

self.d = d.Filter(self.selections[self.dataType]['cut'])

# define mc specific weights

if self.dataType == 'mc':

self.d = self.d.Define('lumiweight', '{L}/({genEventSumw}/{xsec})'.format(L=self.targetLumi, genEventSumw = genEventSumw, xsec = self.xsec))\
.Define("Generator_weight_norm","Generator_weight/fabs(Generator_weight)")\
.Define('totweight', 'lumiweight*Generator_weight_norm*{}'.format(self.selections[self.dataType]['weight']))
self.d = self.d.Define('lumiweight', '({L}*{xsec})/({genEventSumw})'.format(L=self.targetLumi, genEventSumw = genEventSumw, xsec = self.xsec))\
.Define('totweight', 'lumiweight*Generator_weight*{}'.format(self.selections[self.dataType]['weight']))

else:
self.d = self.d.Define('totweight', '1')
Expand Down
7 changes: 4 additions & 3 deletions wmass/controlPlots/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
'variables': {
'corrected_pt': ('muon pt', 100, 20, 100), # variable to plot: (title of x axis, number of bins, xLow, xUp)
'eta': ('muon eta', 100, -2.5, 2.5),
#'corrected_MET_nom_mt':('mt',100, 30, 100), #not working in this version of samples

},

Expand All @@ -129,7 +130,7 @@
ROOT.ROOT.EnableImplicitMT(48)

from controlPlots import *
"""

inputDir = '/gpfs/ddn/cms/user/bianchi/NanoAOD2016-TEST/'

# mc samples
Expand Down Expand Up @@ -160,10 +161,10 @@
p.branch(nodeToStart = 'input', nodeToEnd = 'controlPlotsPlus',outputFile="data_plus.root", modules = [controlPlots(selections = selections['signalplus'], variables = variables, dataType = 'data', xsec = 1, file = inputDir+'SingleMuon'+'/tree.root')])
p.branch(nodeToStart = 'input', nodeToEnd = 'controlPlotsMinus',outputFile="data_minus.root", modules = [controlPlots(selections = selections['signalminus'], variables = variables, dataType = 'data', xsec = 1, file = inputDir+'SingleMuon'+'/tree.root')])
p.getOutput()
"""

from plotter import plotter

plt = plotter(outdir= 'TESTstack', folder = 'TEST', fileList = ['W_plus.root', 'DY_plus.root', 'ttbar_plus.root', 'diboson_plus.root', 'QCD_plus.root', 'data_plus.root'], norm = 2.7)
plt = plotter(outdir= 'TESTstack', folder = 'TEST', fileList = ['DY_plus.root', 'ttbar_plus.root', 'diboson_plus.root','W_plus.root','QCD_plus.root', 'data_plus.root'], norm = 2.7)
plt.plotStack()


Expand Down

0 comments on commit f3ecb0b

Please sign in to comment.