diff --git a/framework/plotter.py b/framework/plotter.py index 85f2a0117126c..2fe63bf14bdec 100644 --- a/framework/plotter.py +++ b/framework/plotter.py @@ -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() diff --git a/wmass/controlPlots/controlPlots.py b/wmass/controlPlots/controlPlots.py index 3ac38428ba9fd..ef6ef8157fecc 100644 --- a/wmass/controlPlots/controlPlots.py +++ b/wmass/controlPlots/controlPlots.py @@ -30,7 +30,9 @@ 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']) @@ -38,9 +40,8 @@ def run(self,d): 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') diff --git a/wmass/controlPlots/defs.py b/wmass/controlPlots/defs.py index 6adf596bb7069..eaa34e395b2af 100644 --- a/wmass/controlPlots/defs.py +++ b/wmass/controlPlots/defs.py @@ -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 }, @@ -129,7 +130,7 @@ ROOT.ROOT.EnableImplicitMT(48) from controlPlots import * -""" + inputDir = '/gpfs/ddn/cms/user/bianchi/NanoAOD2016-TEST/' # mc samples @@ -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()