diff --git a/CMGTools/H2TauTau/Colin/plot_MuRm.py b/CMGTools/H2TauTau/Colin/plot_MuRm.py index 5ec0cf185f571..0bfe135a5ef46 100644 --- a/CMGTools/H2TauTau/Colin/plot_MuRm.py +++ b/CMGTools/H2TauTau/Colin/plot_MuRm.py @@ -1,9 +1,5 @@ import math import os -from CMGTools.RootTools.treeComparator import * -from CMGTools.H2TauTau.proto.plotter.categories_TauMu import * -from CMGTools.RootTools.ReWeighter import ReWeighter -from CMGTools.RootTools.statistics.Value import Value canvas = None pad = None @@ -12,7 +8,8 @@ #TODO warning normalization def drawWithRatio(var, cut, t1, t2, w1, w2, nbins, xmin=0, xmax=200, var2=None): - comp = draw(var, cut, t1, t2, w1=w1, w2=w2, normalize=-1, nbins=nbins,xmin=xmin, xmax=xmax, var2=var2) + comp = draw(var, cut, t1, t2, w1=w1, w2=w2, normalize=-1, + nbins=nbins,xmin=xmin, xmax=xmax, var2=var2) return comp def addWeight(iwstr, wfnam): @@ -26,7 +23,7 @@ def addWeight(iwstr, wfnam): def lowHighMTRatio(hist, lognam, msg, lowmax=None, highmin=None, highmax=None): errlow = ROOT.Double() lowmin = 1 - if lowmax is None: lowmax = 4 + if lowmax is None: lowmax = 3 low = hist.IntegralAndError(lowmin,lowmax,errlow) errhigh = ROOT.Double() if highmin is None: highmin = 8 @@ -65,48 +62,71 @@ def lowHighMTRatio(hist, lognam, msg, lowmax=None, highmin=None, highmax=None): return vratio -def report( dirname, h1, h2, a1, a2, cut, highmin=None, highmax=None): - if dirname.find('Test')!=-1: +def report( dirname, comp, a1, a2, cut, highmin=None, highmax=None, force=False): + if force: os.system('rm -r ' + dirname) oldpwd = os.getcwd() os.mkdir(dirname) os.chdir(dirname) - r1 = lowHighMTRatio(h1, a1, cut, highmin=highmin, highmax=highmax) - r2 = lowHighMTRatio(h2, a2, cut, highmin=highmin, highmax=highmax) + r1 = lowHighMTRatio(comp.h1, a1, cut, highmin=highmin, highmax=highmax) + r2 = lowHighMTRatio(comp.h2, a2, cut, highmin=highmin, highmax=highmax) slog = open('scaling.txt','w') - sstr = 'scaling : {val}\n'.format(val = r1/r2) + rFactor = r1/r2 + sstr = 'scaling : {val}\n'.format(val = rFactor) print sstr slog.write( sstr ) slog.close() - - can.SaveAs('plot.png') + comp.pad_main.cd() + latex = TLatex() + latex.SetNDC() + latex.DrawLatex(0.6, 0.6, 'R={val:3.2f} #pm {err:3.2f}'.format(val=rFactor.val, err=rFactor.err)) + comp.can.SaveAs('plot.png') os.chdir(oldpwd) def systematicReport(basename): os.mkdir(basename) + # Moriond categories +## cuts = { +## 'Inclusive':cat_Inc, +## '0jet_low':' && '.join( [cat_Inc, cat_J0, 'l1_pt<40'] ), +## '0jet_high':' && '.join( [cat_Inc, cat_J0, 'l1_pt>40'] ), +## '1jet_low':' && '.join( [cat_Inc, cat_J1, 'l1_pt<40'] ), +## '1jet_high':' && '.join( [cat_Inc, cat_J1, 'l1_pt>40'] ), +## '2jet':' && '.join( [cat_Inc, cat_J2] ), +## } + # Summer 13 categories cuts = { 'Inclusive':cat_Inc, - '0jet_low':' && '.join( [cat_Inc, cat_J0, 'l1_pt<40'] ), - '0jet_high':' && '.join( [cat_Inc, cat_J0, 'l1_pt>40'] ), - '1jet_low':' && '.join( [cat_Inc, cat_J1, 'l1_pt<40'] ), - '1jet_high':' && '.join( [cat_Inc, cat_J1, 'l1_pt>40'] ), - '2jet':' && '.join( [cat_Inc, cat_J2] ), + '0jet_medium':' && '.join( [cat_Inc, cat_J0_medium, 'l1_pt>30'] ), + '0jet_high':' && '.join( [cat_Inc, cat_J0_high, 'l1_pt>30'] ), + '1jet_medium':' && '.join( [cat_Inc, cat_J1_medium, 'l1_pt>30'] ), + '1jet_high_lowhiggs':' && '.join( [cat_Inc, cat_J1_high_lowhiggs, 'l1_pt>30'] ), + '1jet_high_mediumhiggs':' && '.join( [cat_Inc, cat_J1_high_mediumhiggs, 'l1_pt>30'] ), + '1B':'&&'.join( [cat_Inc, cat_1BInclusive] ), + '0B':'&&'.join( [cat_Inc, cat_0B] ) + # think about tau pT cut!! + # 'vbf_tight':' && '.join( [cat_Inc, cat_VBF_tight] ), + # 'vbf_loose':' && '.join( [cat_Inc, cat_VBF_loose] ), } + for cut in cuts: - cuts[cut] = cuts[cut].replace('l1_looseMvaIso>0.5', 'l1_rawMvaIso>-0.5') + # cuts[cut] = cuts[cut].replace('l1_looseMvaIso>0.5', 'l1_rawMvaIso>-0.5') + cuts[cut] = cuts[cut].replace('l1_threeHitIso<1.5', 'l1_threeHitIso<10') + if a1.find('WJets')!=-1: + cuts[cut] += '&& (abs(genWnu_eta)<2. || genWnu_eta<-90)' - # import pdb; pdb.set_trace() for cutname, cut in cuts.iteritems(): highmin = 8 highmax = None - if cutname=='2jet': + if cutname.startswith('vbf'): highmin = 7 highmax = 12 # import pdb; pdb.set_trace() - h1, h2, hr, leg = drawWithRatio(var, cut, trees[a1], trees[a2], w1=w1, w2=w2, nbins=20, xmin=0, xmax=200, var2=var2) - report('/'.join([basename, cutname]), h1, h2, a1, a2, cut, + # h1, h2, hr, leg = drawWithRatio(var, cut, trees[a1], trees[a2], w1=w1, w2=w2, nbins=20, xmin=0, xmax=200, var2=var2) + comp = drawWithRatio(var, cut, trees[a1], trees[a2], w1=w1, w2=w2, nbins=20, xmin=0, xmax=200, var2=var2) + report('/'.join([basename, cutname]), comp, a1, a2, cut, highmin=highmin, highmax=highmax) if __name__ == '__main__': @@ -132,6 +152,19 @@ def systematicReport(basename): (options,args) = parser.parse_args() if len(args) !=3 : print 'pattern1 pattern2 var' + sys.exit(1) + + if options.report and os.path.isdir(options.report): + print options.report, ' already exists. quit' + sys.exit(2) + + # importing after test of argument validity + # not to waste time loading fwlite. + from CMGTools.RootTools.treeComparator import * + from CMGTools.H2TauTau.proto.plotter.categories_TauMu import * + from CMGTools.RootTools.ReWeighter import ReWeighter + from CMGTools.RootTools.statistics.Value import Value + from ROOT import TLatex p1 = args[0] p2 = args[1] @@ -144,17 +177,21 @@ def systematicReport(basename): trees[a2].SetTitle( a2 ) # beware weight! - cut = cat_Inc + ' && ' + cat_J1 + # cut = ' && '.join( [cat_Inc] ) + cut = ' && '.join( [cat_Inc, cat_VBF_Rel_20, 'l1_pt>30'] ) + # + '&&' + cat_0B + # cut = cat_Inc if a1.find('WJets')!=-1: - cut += '&& (abs(genWnu_eta)<2.4 || genWnu_eta<-90)' + cut += '&& (abs(genWnu_eta)<2. || genWnu_eta<-90)' # dr = 'sqrt((l1_eta-l2_eta)^2 + (l1_phi-l2_phi)^2)>2 - cut = cut.replace('l1_threeHitIso<1.5', 'l1_threeHitIso<999') + cut = cut.replace('l1_threeHitIso<1.5', 'l1_threeHitIso<10') # cut += ' && ' + dr w1 = '1' - if a1.find('WJets') != -1: - w1 = 'weight' w2 = 'weight' + if a1.find('WJets') != -1: + w1 = '1' + w2 = '1' var = args[2] var2 = options.var2 @@ -180,7 +217,8 @@ def systematicReport(basename): w2 = addWeight( w2, wfnam ) comp = drawWithRatio(var, cut, trees[a1], trees[a2], w1=w1, w2=w2, nbins=20, xmin=0, xmax=200, var2=var2) - + # report('Test', comp, a1, a2, cut, highmin=8) + if options.oweight: weightFile = shelve.open( options.oweight ) @@ -190,4 +228,8 @@ def systematicReport(basename): if options.report: - report(options.report, h1, h2, a1, a2, cut) + report(options.report, comp, a1, a2, cut, highmin=8) + else: + dir = 'Tmp_plot_MuRm' + report(dir, comp, a1, a2, cut, highmin=8, force=True) + diff --git a/CMGTools/H2TauTau/Colin/tauEle_2012_cfg.py b/CMGTools/H2TauTau/Colin/tauEle_2012_cfg.py index cec4d9b1c8574..48b9cb3b3adb0 100644 --- a/CMGTools/H2TauTau/Colin/tauEle_2012_cfg.py +++ b/CMGTools/H2TauTau/Colin/tauEle_2012_cfg.py @@ -15,10 +15,8 @@ syncntuple = True doThePlot = True -puFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012' - -puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/MC_Summer12_PU_S10-600bins.root' -puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/Data_Pileup_2012_ReReco-600bins.root' +puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/MC_Summer12_PU_S10-600bins.root' +puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/Data_Pileup_2012_ReRecoPixel-600bins.root' # vertexFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012/Vertices' # vertexFileData = '/'.join([vertexFileDir, 'vertices_data_2012A_2012B_start_195947.root']) @@ -114,6 +112,10 @@ verbose = False, ) +tauFakeRateWeighter = cfg.Analyzer( + 'TauFakeRateWeighter' + ) + tauWeighter = cfg.Analyzer( 'LeptonWeighter_tau', effWeight = hlt_tauEffWeight, @@ -246,6 +248,7 @@ pileUpAna, embedWeighter, tauDecayModeWeighter, + tauFakeRateWeighter, tauWeighter, eleWeighter, treeProducer @@ -276,6 +279,12 @@ # selectedComponents = [h for h in higgs if 'GGH' in h.name] # selectedComponents = [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] selectedComponents = [W1Jets_ext, W2Jets_ext, W3Jets_ext,WJets, W1Jets, W2Jets, W3Jets, W4Jets] + # selectedComponents = mc_higgs_susy + # selectedComponents += higgs + # selectedComponents += [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] + # selectedComponents = embed_list + # selectedComponents += [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] + # selectedComponents = data_list config = cfg.Config( components = selectedComponents, diff --git a/CMGTools/H2TauTau/Colin/tauEle_2012_down_cfg.py b/CMGTools/H2TauTau/Colin/tauEle_2012_down_cfg.py index 4b02a6feffc1e..bd2b45d4f4f1e 100644 --- a/CMGTools/H2TauTau/Colin/tauEle_2012_down_cfg.py +++ b/CMGTools/H2TauTau/Colin/tauEle_2012_down_cfg.py @@ -15,10 +15,8 @@ syncntuple = True doThePlot = True -puFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012' - -puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/MC_Summer12_PU_S10-600bins.root' -puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/Data_Pileup_2012_ReReco-600bins.root' +puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/MC_Summer12_PU_S10-600bins.root' +puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/Data_Pileup_2012_ReRecoPixel-600bins.root' # vertexFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012/Vertices' # vertexFileData = '/'.join([vertexFileDir, 'vertices_data_2012A_2012B_start_195947.root']) @@ -261,7 +259,10 @@ for comp in selectedComponents: comp.splitFactor = 1 comp.files = comp.files[:3] - +elif test==3: + # selectedComponents = mc_higgs_susy + # selectedComponents = [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] + selectedComponents = [HiggsVBF125] config = cfg.Config( components = selectedComponents, sequence = sequence ) diff --git a/CMGTools/H2TauTau/Colin/tauEle_2012_up_cfg.py b/CMGTools/H2TauTau/Colin/tauEle_2012_up_cfg.py index 7b18beb68e0ff..e844c79dff500 100644 --- a/CMGTools/H2TauTau/Colin/tauEle_2012_up_cfg.py +++ b/CMGTools/H2TauTau/Colin/tauEle_2012_up_cfg.py @@ -15,10 +15,8 @@ syncntuple = True doThePlot = True -puFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012' - -puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/MC_Summer12_PU_S10-600bins.root' -puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/Data_Pileup_2012_ReReco-600bins.root' +puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/MC_Summer12_PU_S10-600bins.root' +puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/Data_Pileup_2012_ReRecoPixel-600bins.root' # vertexFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012/Vertices' # vertexFileData = '/'.join([vertexFileDir, 'vertices_data_2012A_2012B_start_195947.root']) @@ -257,7 +255,11 @@ for comp in selectedComponents: comp.splitFactor = 1 comp.files = comp.files[:3] - +elif test==3: + # selectedComponents = mc_higgs_susy + # selectedComponents = [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] + selectedComponents = embed_list + selectedComponents += [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] config = cfg.Config( components = selectedComponents, sequence = sequence ) diff --git a/CMGTools/H2TauTau/Colin/tauMu_2011_cfg.py b/CMGTools/H2TauTau/Colin/tauMu_2011_cfg.py index 0ba3f942c9c75..6994a270ff941 100644 --- a/CMGTools/H2TauTau/Colin/tauMu_2011_cfg.py +++ b/CMGTools/H2TauTau/Colin/tauMu_2011_cfg.py @@ -13,25 +13,29 @@ # 1.0, 1.03, 0.97 tauScaleShift = 1.0 syncntuple = True +simulatedOnly = False # Useful for systematic shifts on simulated samples, e.g. JEC +doThePlot = True # Set to true for the plotting script -mc_vertexWeight = 'vertexWeightFall112011AB' -mc_tauEffWeight = None -mc_muEffWeight = None + +# Andrew Summer 13 (MC is identical to the previous one) +puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/MC_Fall11_PU_S6-500bins.root' +puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/Data_Pileup_2011_HCP-500bins.root' + +# vertexFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012/Vertices' +# vertexFileData = '/'.join([vertexFileDir, 'vertices_data_2012A_2012B_start_195947.root']) + +mc_vertexWeight = None mc_tauEffWeight_mc = 'effLooseTau15MC' mc_muEffWeight_mc = 'effIsoMu15MC' mc_tauEffWeight = 'effTau2011AB' mc_muEffWeight = 'effMu2011AB' - - -# selected by Andrew -# * 113591 * 203.66099 * 179452 * 387 * 587118487 * - - + + eventSelector = cfg.Analyzer( 'EventSelector', toSelect = [ - 587118487 + 105104 ] ) @@ -48,15 +52,25 @@ 'VertexAnalyzer', goodVertices = 'goodPVFilter', vertexWeight = mc_vertexWeight, - # fixedWeight = 1, - verbose = False + fixedWeight = 1, + verbose = False, ) embedWeighter = cfg.Analyzer( 'EmbedWeighter', + isRecHit = False, verbose = False ) +pileUpAna = cfg.Analyzer( + 'PileUpAnalyzer', + true = True + ) + +genErsatzAna = cfg.Analyzer( + 'GenErsatzAnalyzer', + verbose = False + ) TauMuAna = cfg.Analyzer( 'TauMuAnalyzer', @@ -69,6 +83,7 @@ iso2 = 0.1, m_min = 10, m_max = 99999, + dR_min = 0.5, triggerMap = pathsAndFilters, mvametsigs = 'mvaMETTauMu', verbose = False @@ -76,22 +91,36 @@ dyJetsFakeAna = cfg.Analyzer( 'DYJetsFakeAnalyzer', - leptonType = 13 + leptonType = 13, + src = 'genParticlesPruned', ) WNJetsAna = cfg.Analyzer( 'WNJetsAnalyzer', - verbose = False, - fractions = [ 0.752276599407, - 0.171668857336, - 0.0536961443722, - 0.0159474294633, - 0.00641100015491, - ], + verbose = False + ) + +NJetsAna = cfg.Analyzer( + 'NJetsAnalyzer', + fillTree = True, + verbose = False + ) + +WNJetsTreeAna = cfg.Analyzer( + 'WNJetsTreeAnalyzer' ) higgsWeighter = cfg.Analyzer( 'HiggsPtWeighter', + src = 'genParticlesPruned', + ) + +tauDecayModeWeighter = cfg.Analyzer( + 'TauDecayModeWeighter', + ) + +tauFakeRateWeighter = cfg.Analyzer( + 'TauFakeRateWeighter' ) tauWeighter = cfg.Analyzer( @@ -121,16 +150,24 @@ deltaEta = 3.5 ) -vbfAna = cfg.Analyzer( - 'VBFAnalyzer', - vbfMvaWeights = os.environ['CMSSW_BASE'] + '/src/CMGTools/H2TauTau/data/VBFMVA_BDTG_HCP_42X.weights.xml', + +jetAna = cfg.Analyzer( + 'JetAnalyzer', jetCol = 'cmgPFJetSel', jetPt = 20., jetEta = 4.7, - cjvPtCut = 30., btagSFseed = 123456, - relaxJetId = False, + relaxJetId = False, + jerCorr = False, + #jesCorr = 1., + ) + +vbfSimpleAna = cfg.Analyzer( + 'VBFSimpleAnalyzer', + vbfMvaWeights = '', + cjvPtCut = 30., **vbfKwargs + ) @@ -145,20 +182,17 @@ ######################################################################################### -# from CMGTools.H2TauTau.proto.samples.run2011.tauMu_ColinJun25 import * -# from CMGTools.H2TauTau.proto.samples.tauMu_ColinJul4 import * -# from CMGTools.H2TauTau.proto.samples.tauMu_Sync_ColinAug30 import * - -# from CMGTools.H2TauTau.proto.samples.tauMu_ColinSep20 import * -from CMGTools.H2TauTau.proto.samples.tauMu_Sync_Colin import * +from CMGTools.H2TauTau.proto.samples.tauMu_Sync_Colin import * ######################################################################################### +for mc in MC_list: + mc.puFileMC = puFileMC + mc.puFileData = puFileData -# MC_list = [WJets, W3Jets, DYJets, TTJets, HiggsVBF125, WW, WZ, ZZ] -# MC_list = copy.copy(MC) -# data_list = copy.copy(data_list_2011) -# embed_list = copy.copy(embed_list_2011) +for emb in embed_list_2011: + emb.puFileData = None + emb.puFileMC = None WNJetsAna.nevents = [ WJets.nGenEvents, W1Jets.nGenEvents, @@ -167,6 +201,9 @@ W4Jets.nGenEvents ] +# Fractions temporarily taken from Jose (29 May 2013): +WNJetsAna.fractions = [0.74392452, 0.175999, 0.0562617, 0.0168926, 0.00692218] + # selectedComponents = allsamples diboson_list = [ WWJetsTo2L2Nu, WZJetsTo2L2Q, @@ -177,54 +214,103 @@ T_tW, Tbar_tW ] + WJetsSoup = copy.copy(WJets) WJetsSoup.name = 'WJetsSoup' + +DYJetsSoup = copy.copy(DYJets) +DYJetsSoup.name = 'DYJetsSoup' + VVgroup = [comp.name for comp in diboson_list] -# higgs = [HiggsVBF125, HiggsGGH125, HiggsVH125] -selectedComponents = [WJetsSoup, TTJets, DYJets] -selectedComponents = [WJets, W1Jets, W2Jets, W3Jets, W4Jets, TTJets, DYJets] +if diboson_list == [] and doThePlot: + VVgroup = None # This is needed for the plotting script + higgs = mc_higgs -selectedComponents.extend( higgs ) + +selectedComponents = [TTJets, + DYJets, WJets, + W1Jets, W2Jets, W3Jets, W4Jets, + ] + +# FOR PLOTTING: +TTgroup = None +if doThePlot: + selectedComponents = [TTJets, #DYJets, #WJets, + WJetsSoup, + DYJets + ] + +if not doThePlot: + selectedComponents.extend( higgs ) + # selectedComponents.extend( mc_higgs_susy ) +else: + # pass + selectedComponents.extend( higgs ) + # selectedComponents.extend( mc_higgs_susy ) + selectedComponents.extend( diboson_list ) -selectedComponents.extend( data_list_2011 ) -selectedComponents.extend( embed_list_2011 ) + +if not simulatedOnly: + # selectedComponents.extend( data_list ) + selectedComponents.extend( embed_list_2011 ) + sequence = cfg.Sequence( [ -# eventSelector, - jsonAna, + # eventSelector, + jsonAna, triggerAna, - vertexAna, + vertexAna, TauMuAna, dyJetsFakeAna, - WNJetsAna, + # WNJetsAna, + # WNJetsTreeAna, + NJetsAna, higgsWeighter, - vbfAna, - embedWeighter, + jetAna, + vbfSimpleAna, + pileUpAna, + embedWeighter, + tauDecayModeWeighter, + tauFakeRateWeighter, tauWeighter, muonWeighter, - treeProducer + treeProducer, + # treeProducerXCheck ] ) if syncntuple: - sequence.append( treeProducerXCheck) + sequence.append( treeProducerXCheck) #Yes! +selectedComponents = [comp for comp in selectedComponents if comp.dataset_entries > 0] -test = 1 +test = 0 if test==1: - comp = HiggsVBF125 - # comp.files = comp.files[:2] + # comp = embed_Run2012C_22Jan + # comp = DYJets + # comp = HiggsGGH125 + # comp = HiggsSUSYGluGlu1000 + comp = W1Jets_ext + # comp = data_Run2012A selectedComponents = [comp] - comp.splitFactor = 14 + comp.splitFactor = 1 + # comp.files = comp.files[:10] + # comp.files = ['tauMu_fullsel_tree_CMG.root'] elif test==2: - selectedComponents = copy.copy(data_list_2011) - selectedComponents.extend(embed_list_2011) - selectedComponents.extend(MC_list[0:3]) - + selectedComponents = selectedComponents[:12] for comp in selectedComponents: comp.splitFactor = 1 - comp.files = comp.files[:3] - - + comp.files = comp.files[:5] +elif test==3: + # selectedComponents = [WJets, W1Jets, W2Jets, W3Jets, W4Jets] + # selectedComponents = higgs + # selectedComponents = data_list + # selectedComponents = embed_list + # selectedComponents += [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] + # selectedComponents = mc_higgs_susy + selectedComponents = [WJets, W1Jets, W2Jets, W3Jets, W4Jets, W1Jets_ext, W2Jets_ext, W3Jets_ext] + # selectedComponents += higgs + # selectedComponents += mc_higgs_susy + # selectedComponents = [DYJets] config = cfg.Config( components = selectedComponents, sequence = sequence ) diff --git a/CMGTools/H2TauTau/Colin/tauMu_2011_colin_cfg.py b/CMGTools/H2TauTau/Colin/tauMu_2011_colin_cfg.py new file mode 100644 index 0000000000000..0ba3f942c9c75 --- /dev/null +++ b/CMGTools/H2TauTau/Colin/tauMu_2011_colin_cfg.py @@ -0,0 +1,232 @@ +import copy +import os +import CMGTools.RootTools.fwlite.Config as cfg +from CMGTools.RootTools.fwlite.Config import printComps + +from CMGTools.H2TauTau.triggerMap import pathsAndFilters +from CMGTools.H2TauTau.proto.weights.weighttable import mu_id_taumu_2011, mu_iso_taumu_2011 +from CMGTools.H2TauTau.proto.samples.sampleShift import selectShift +from CMGTools.RootTools.RootTools import * + +# 'Nom', 'Up', 'Down', or None +shift = None +# 1.0, 1.03, 0.97 +tauScaleShift = 1.0 +syncntuple = True + +mc_vertexWeight = 'vertexWeightFall112011AB' +mc_tauEffWeight = None +mc_muEffWeight = None + +mc_tauEffWeight_mc = 'effLooseTau15MC' +mc_muEffWeight_mc = 'effIsoMu15MC' +mc_tauEffWeight = 'effTau2011AB' +mc_muEffWeight = 'effMu2011AB' + + +# selected by Andrew +# * 113591 * 203.66099 * 179452 * 387 * 587118487 * + + +eventSelector = cfg.Analyzer( + 'EventSelector', + toSelect = [ + 587118487 + ] + ) + + +jsonAna = cfg.Analyzer( + 'JSONAnalyzer', + ) + +triggerAna = cfg.Analyzer( + 'TriggerAnalyzer' + ) + +vertexAna = cfg.Analyzer( + 'VertexAnalyzer', + goodVertices = 'goodPVFilter', + vertexWeight = mc_vertexWeight, + # fixedWeight = 1, + verbose = False + ) + +embedWeighter = cfg.Analyzer( + 'EmbedWeighter', + verbose = False + ) + + +TauMuAna = cfg.Analyzer( + 'TauMuAnalyzer', + scaleShift1 = tauScaleShift, + pt1 = 20, + eta1 = 2.3, + iso1 = None, + pt2 = 17, + eta2 = 2.1, + iso2 = 0.1, + m_min = 10, + m_max = 99999, + triggerMap = pathsAndFilters, + mvametsigs = 'mvaMETTauMu', + verbose = False + ) + +dyJetsFakeAna = cfg.Analyzer( + 'DYJetsFakeAnalyzer', + leptonType = 13 + ) + +WNJetsAna = cfg.Analyzer( + 'WNJetsAnalyzer', + verbose = False, + fractions = [ 0.752276599407, + 0.171668857336, + 0.0536961443722, + 0.0159474294633, + 0.00641100015491, + ], + ) + +higgsWeighter = cfg.Analyzer( + 'HiggsPtWeighter', + ) + +tauWeighter = cfg.Analyzer( + 'LeptonWeighter_tau', + effWeight = mc_tauEffWeight, + effWeightMC = mc_tauEffWeight_mc, + lepton = 'leg1', + verbose = False, + disable = False, + ) + +muonWeighter = cfg.Analyzer( + 'LeptonWeighter_mu', + effWeight = mc_muEffWeight, + effWeightMC = mc_muEffWeight_mc, + lepton = 'leg2', + verbose = False, + disable = False, + idWeight = mu_id_taumu_2011, + isoWeight = mu_iso_taumu_2011 + ) + + + +# defined for vbfAna and eventSorter +vbfKwargs = dict( Mjj = 500, + deltaEta = 3.5 + ) + +vbfAna = cfg.Analyzer( + 'VBFAnalyzer', + vbfMvaWeights = os.environ['CMSSW_BASE'] + '/src/CMGTools/H2TauTau/data/VBFMVA_BDTG_HCP_42X.weights.xml', + jetCol = 'cmgPFJetSel', + jetPt = 20., + jetEta = 4.7, + cjvPtCut = 30., + btagSFseed = 123456, + relaxJetId = False, + **vbfKwargs + ) + + +treeProducer = cfg.Analyzer( + 'H2TauTauTreeProducerTauMu' + ) + +treeProducerXCheck = cfg.Analyzer( + 'H2TauTauSyncTree', + pt20 = False + ) + +######################################################################################### + +# from CMGTools.H2TauTau.proto.samples.run2011.tauMu_ColinJun25 import * +# from CMGTools.H2TauTau.proto.samples.tauMu_ColinJul4 import * +# from CMGTools.H2TauTau.proto.samples.tauMu_Sync_ColinAug30 import * + +# from CMGTools.H2TauTau.proto.samples.tauMu_ColinSep20 import * +from CMGTools.H2TauTau.proto.samples.tauMu_Sync_Colin import * + +######################################################################################### + + +# MC_list = [WJets, W3Jets, DYJets, TTJets, HiggsVBF125, WW, WZ, ZZ] +# MC_list = copy.copy(MC) +# data_list = copy.copy(data_list_2011) +# embed_list = copy.copy(embed_list_2011) + +WNJetsAna.nevents = [ WJets.nGenEvents, + W1Jets.nGenEvents, + W2Jets.nGenEvents, + W3Jets.nGenEvents, + W4Jets.nGenEvents + ] + +# selectedComponents = allsamples +diboson_list = [ WWJetsTo2L2Nu, + WZJetsTo2L2Q, + WZJetsTo3LNu, + ZZJetsTo2L2Nu, + ZZJetsTo2L2Q, + ZZJetsTo4L, + T_tW, + Tbar_tW + ] +WJetsSoup = copy.copy(WJets) +WJetsSoup.name = 'WJetsSoup' +VVgroup = [comp.name for comp in diboson_list] +# higgs = [HiggsVBF125, HiggsGGH125, HiggsVH125] +selectedComponents = [WJetsSoup, TTJets, DYJets] +selectedComponents = [WJets, W1Jets, W2Jets, W3Jets, W4Jets, TTJets, DYJets] +higgs = mc_higgs +selectedComponents.extend( higgs ) +selectedComponents.extend( diboson_list ) +selectedComponents.extend( data_list_2011 ) +selectedComponents.extend( embed_list_2011 ) + +sequence = cfg.Sequence( [ +# eventSelector, + jsonAna, + triggerAna, + vertexAna, + TauMuAna, + dyJetsFakeAna, + WNJetsAna, + higgsWeighter, + vbfAna, + embedWeighter, + tauWeighter, + muonWeighter, + treeProducer + ] ) + +if syncntuple: + sequence.append( treeProducerXCheck) + + +test = 1 +if test==1: + comp = HiggsVBF125 + # comp.files = comp.files[:2] + selectedComponents = [comp] + comp.splitFactor = 14 +elif test==2: + selectedComponents = copy.copy(data_list_2011) + selectedComponents.extend(embed_list_2011) + selectedComponents.extend(MC_list[0:3]) + + for comp in selectedComponents: + comp.splitFactor = 1 + comp.files = comp.files[:3] + + + +config = cfg.Config( components = selectedComponents, + sequence = sequence ) + +printComps(config.components, True) diff --git a/CMGTools/H2TauTau/Colin/tauMu_2012_cfg.py b/CMGTools/H2TauTau/Colin/tauMu_2012_cfg.py index 3cac6c10d1400..a57c0452d4858 100644 --- a/CMGTools/H2TauTau/Colin/tauMu_2012_cfg.py +++ b/CMGTools/H2TauTau/Colin/tauMu_2012_cfg.py @@ -16,20 +16,10 @@ simulatedOnly = False # Useful for systematic shifts on simulated samples, e.g. JEC doThePlot = True # Set to true for the plotting script -puFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012' - -# andrew HCP -# puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/28-09-12/MC_Summer12_PU_S10-600bins.root' -# puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/28-09-12/Data_Pileup_2012_HCP-600bins.root' - -# Andrew Moriond -# puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/07-01-13/MC_Summer12_PU_S10-600bins.root' -# puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/07-01-13/Data_Pileup_2012_Moriond-600bins.root' # Andrew Summer 13 (MC is identical to the previous one) -puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/MC_Summer12_PU_S10-600bins.root' -puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/Data_Pileup_2012_ReReco-600bins.root' - +puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/MC_Summer12_PU_S10-600bins.root' +puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/Data_Pileup_2012_ReRecoPixel-600bins.root' # vertexFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012/Vertices' # vertexFileData = '/'.join([vertexFileDir, 'vertices_data_2012A_2012B_start_195947.root']) @@ -134,6 +124,10 @@ 'TauDecayModeWeighter', ) +tauFakeRateWeighter = cfg.Analyzer( + 'TauFakeRateWeighter' + ) + tauWeighter = cfg.Analyzer( 'LeptonWeighter_tau', effWeight = mc_tauEffWeight, @@ -299,6 +293,7 @@ pileUpAna, embedWeighter, tauDecayModeWeighter, + tauFakeRateWeighter, tauWeighter, muonWeighter, treeProducer, @@ -317,6 +312,7 @@ # comp = HiggsGGH125 # comp = HiggsSUSYGluGlu1000 comp = W1Jets_ext + # comp = data_Run2012A selectedComponents = [comp] comp.splitFactor = 1 # comp.files = comp.files[:10] @@ -329,10 +325,14 @@ elif test==3: # selectedComponents = [WJets, W1Jets, W2Jets, W3Jets, W4Jets] # selectedComponents = higgs + # selectedComponents = data_list # selectedComponents = embed_list + # selectedComponents += [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] # selectedComponents = mc_higgs_susy - # selectedComponents = [WJets, W1Jets, W2Jets, W3Jets, W4Jets, W1Jets_ext, W2Jets_ext, W3Jets_ext] - selectedComponents = [W1Jets_ext, W2Jets_ext, W3Jets_ext] + selectedComponents = [WJets, W1Jets, W2Jets, W3Jets, W4Jets, W1Jets_ext, W2Jets_ext, W3Jets_ext] + # selectedComponents += higgs + # selectedComponents += mc_higgs_susy + # selectedComponents = [DYJets] config = cfg.Config( components = selectedComponents, sequence = sequence ) diff --git a/CMGTools/H2TauTau/Colin/tauMu_2012_tesdown_cfg.py b/CMGTools/H2TauTau/Colin/tauMu_2012_tesdown_cfg.py index 65a1627b323a2..06aa88b8e8bdb 100644 --- a/CMGTools/H2TauTau/Colin/tauMu_2012_tesdown_cfg.py +++ b/CMGTools/H2TauTau/Colin/tauMu_2012_tesdown_cfg.py @@ -16,19 +16,9 @@ simulatedOnly = False # Useful for systematic shifts on simulated samples, e.g. JEC doThePlot = True # Set to true for the plotting script -puFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012' - -# andrew HCP -# puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/28-09-12/MC_Summer12_PU_S10-600bins.root' -# puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/28-09-12/Data_Pileup_2012_HCP-600bins.root' - -# Andrew Moriond -# puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/07-01-13/MC_Summer12_PU_S10-600bins.root' -# puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/07-01-13/Data_Pileup_2012_Moriond-600bins.root' - # Andrew Summer 13 (MC is identical to the previous one) -puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/MC_Summer12_PU_S10-600bins.root' -puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/Data_Pileup_2012_ReReco-600bins.root' +puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/MC_Summer12_PU_S10-600bins.root' +puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/Data_Pileup_2012_ReRecoPixel-600bins.root' # vertexFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012/Vertices' @@ -304,7 +294,10 @@ # comp.splitFactor = 1 # comp.files = comp.files[:5] elif test==3: - selectedComponents = mc_higgs_susy + # selectedComponents = mc_higgs_susy + # selectedComponents = [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] + selectedComponents = embed_list + selectedComponents += [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] config = cfg.Config( components = selectedComponents, sequence = sequence ) diff --git a/CMGTools/H2TauTau/Colin/tauMu_2012_tesup_cfg.py b/CMGTools/H2TauTau/Colin/tauMu_2012_tesup_cfg.py index 8594604fdfc84..781c89db03e83 100644 --- a/CMGTools/H2TauTau/Colin/tauMu_2012_tesup_cfg.py +++ b/CMGTools/H2TauTau/Colin/tauMu_2012_tesup_cfg.py @@ -16,19 +16,9 @@ simulatedOnly = False # Useful for systematic shifts on simulated samples, e.g. JEC doThePlot = True # Set to true for the plotting script -puFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012' - -# andrew HCP -# puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/28-09-12/MC_Summer12_PU_S10-600bins.root' -# puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/28-09-12/Data_Pileup_2012_HCP-600bins.root' - -# Andrew Moriond -# puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/07-01-13/MC_Summer12_PU_S10-600bins.root' -# puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/07-01-13/Data_Pileup_2012_Moriond-600bins.root' - # Andrew Summer 13 (MC is identical to the previous one) -puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/MC_Summer12_PU_S10-600bins.root' -puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/12-06-13/Data_Pileup_2012_ReReco-600bins.root' +puFileMC = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/MC_Summer12_PU_S10-600bins.root' +puFileData = '/afs/cern.ch/user/a/agilbert/public/HTT_Pileup/13-09-13/Data_Pileup_2012_ReRecoPixel-600bins.root' # vertexFileDir = os.environ['CMSSW_BASE'] + '/src/CMGTools/RootTools/data/Reweight/2012/Vertices' @@ -302,7 +292,10 @@ # comp.splitFactor = 1 # comp.files = comp.files[:5] elif test==3: - selectedComponents = mc_higgs_susy + # selectedComponents = mc_higgs_susy + # selectedComponents = [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] + selectedComponents = embed_list + selectedComponents += [DYJets, DY1Jets, DY2Jets, DY3Jets, DY4Jets] config = cfg.Config( components = selectedComponents, sequence = sequence ) diff --git a/CMGTools/H2TauTau/Jan/EleTau/combineCards.py b/CMGTools/H2TauTau/Jan/EleTau/combineCards.py index 63a457f5e902a..9a8b333e134f6 100644 --- a/CMGTools/H2TauTau/Jan/EleTau/combineCards.py +++ b/CMGTools/H2TauTau/Jan/EleTau/combineCards.py @@ -15,14 +15,15 @@ 'eleTau_0jet_high.root', 'eleTau_0jet_medium.root', 'eleTau_1jet_high_mediumhiggs.root', - 'eleTau_0jet_low.root', - 'eleTau_1jet_high_lowhiggs.root', + # 'eleTau_0jet_low.root', + # 'eleTau_1jet_high_lowhiggs.root', 'eleTau_1jet_medium.root', 'eleTau_vbf_loose.root', 'eleTau_vbf_tight.root', ] - systs = ['_CMS_scale_t_etau_8TeV', '_QCDscale_ggH1in', '_CMS_htt_ZLScale_etau_8TeV'] + systs = ['_CMS_scale_t_etau_8TeV', '_QCDscale_ggH1in', '_CMS_htt_ZLScale_etau_8TeV', '_CMS_htt_WShape_etau_0jet_medium_8TeV', '_CMS_htt_WShape_etau_0jet_high_8TeV', '_CMS_htt_WShape_etau_1jet_medium_8TeV', '_CMS_htt_WShape_etau_1jet_high_mediumhiggs_8TeV', '_CMS_htt_WShape_etau_vbf_loose_8TeV', '_CMS_htt_WShape_etau_vbf_tight_8TeV', + '_CMS_htt_ZLScale_etau_8TeVSmeared'] else: inFiles = [ '{prefix}_eleTau_btag.root'.format(prefix=prefix), @@ -36,8 +37,8 @@ for f in inFiles: target = f.replace('.root', '.tmp.root') inFilesSys = [f] - inFilesSys += [f.replace('.root', sys+'Up.root') for sys in systs] - inFilesSys += [f.replace('.root', sys+'Down.root') for sys in systs] + inFilesSys += [f.replace('.root', sys+'Up.root') for sys in systs if os.path.isfile(f.replace('.root', sys+'Up.root'))] + inFilesSys += [f.replace('.root', sys+'Down.root') for sys in systs if os.path.isfile(f.replace('.root', sys+'Down.root'))] os.system('hadd {target} '.format(target=target)+' '.join(inFilesSys)) inFiles = [f.replace('.root', '.tmp.root') for f in inFiles] diff --git a/CMGTools/H2TauTau/Jan/EleTau/plot_H2TauTauDataMC_TauEle_All.py b/CMGTools/H2TauTau/Jan/EleTau/plot_H2TauTauDataMC_TauEle_All.py index 9b496e92dc8a1..7a98d9e080acf 100644 --- a/CMGTools/H2TauTau/Jan/EleTau/plot_H2TauTauDataMC_TauEle_All.py +++ b/CMGTools/H2TauTau/Jan/EleTau/plot_H2TauTauDataMC_TauEle_All.py @@ -4,6 +4,7 @@ import time import re import os +import string import ROOT from CMGTools.H2TauTau.proto.HistogramSet import histogramSet @@ -111,6 +112,7 @@ def makePlot( var, nbins, xmin, xmax, subtractBGForQCDShape=False, embedForSS=False, relSelection={}, osForWExtrapolation=True, incQCDYield=99999., qcdYieldInclusiveExtrapolation=False, dataComps={}, cutName='', isZeroB=False, isOneJet=False): print '\nMaking the plot:', var, 'cut', cut + print 'QCD setup', antiEleIsoForQCD, antiEleRlxTauIsoForQCD, subtractBGForQCDShape wJetScaleSS, wJetScaleOS, w_mt_ratio_ss, w_mt_ratio_os, w_mt_ratio = wInfo @@ -129,9 +131,15 @@ def makePlot( var, nbins, xmin, xmax, print 'correcting high->low mT extrapolation factor, OS', w_mt_ratio / w_mt_ratio_os osign.Hist(EWK).Scale( w_mt_ratio / w_mt_ratio_os ) if replaceW: + wweight = weight + if shift and 'WShape' in shift: + if 'Up' in shift: + wweight = 'weight*tauFakeRateWeightUp/tauFakeRateWeight' + elif 'Down' in shift: + wweight = 'weight*tauFakeRateWeightDown/tauFakeRateWeight' osign = replaceShapeInclusive(osign, var, anaDir, selComps['WJets'], weights, - oscut, weight, + oscut, wweight, embed, shift) print '\nINFO Replacing shapes' @@ -312,9 +320,10 @@ def drawAll(plots, outDir, blind, parameters, isMSSM=False): osQ.blindxmin = 60. osQ.blindxmax = 120. - varOutDir = outDir+parameters['cutName']+'/p'+str(iName) + varOutDir = outDir+parameters['cutName']+'/' if not os.path.exists(varOutDir): os.makedirs(varOutDir) + varOutDir += 'v'+string.lowercase[iName] if iName < 26 else 'v'+str(iName) if name != plot.var: varOutDir += name + '_' # drawOfficial(osQ, blind, plotprefix=varOutDir) @@ -334,7 +343,10 @@ def handleW( anaDir, selComps, weights, cut = cut.replace('mt<30', '1') cut = cut.replace('mt<20', '1') cut = cut.replace('mt<', 'mt<9999') - cut = cut.replace('mt>', 'mt>-0.00000') + # cut = cut.replace('mt>', 'mt>-0.00000') + + if 'mt>' in cut: + lowMTMax = highMTMax relCut = relCut.replace('mt<30', '1') relCut = relCut.replace('mt<20', '1') @@ -440,6 +452,10 @@ def handleW( anaDir, selComps, weights, dest="prefix", help="Prefix for datacards", default=None) + parser.add_option("-s", "--shift", + dest="shift", + help="Shift to apply specific systematics", + default=None) (options,args) = parser.parse_args() if len(args) != 2: @@ -464,7 +480,10 @@ def handleW( anaDir, selComps, weights, shift = 'Down' elif anaDir.endswith('_Up'): shift = 'Up' - + + if options.shift: + shift = options.shift + cfgFileName = args[1] cfgFile = open( cfgFileName, 'r' ) cfg = imp.load_source( 'cfg', cfgFileName, cfgFile) @@ -491,8 +510,10 @@ def handleW( anaDir, selComps, weights, XMAX = 2000. # QCD handling - antiEleIsoForQCD = cutstring.find('Xcat_VBF_looseX')!=-1 or cutstring.find('Xcat_VBFX')!=-1 or cutstring.find('Xcat_J0_mediumX')!=-1 or cutstring.find('Xcat_J0_highX')!=-1 or cutstring.find('Xcat_VBF_tightX')!=-1 or isBtag # no isOneJet for electron!! - antiEleRlxTauIsoForQCD = cutstring.find('Xcat_J1_high_mediumhiggsX')!=-1 #or cutstring.find('Xcat_VBF_tightX')!=-1 + antiEleIsoForQCD = cutstring.find('Xcat_VBF_looseX')!=-1 or cutstring.find('Xcat_VBFX')!=-1 or cutstring.find('Xcat_J0_highX')!=-1 or isBtag #or cutstring.find('Xcat_VBF_tightX')!=-1 + antiEleRlxTauIsoForQCD = cutstring.find('Xcat_J1_high_mediumhiggsX')!=-1 or cutstring.find('Xcat_VBF_tightX')!=-1 or cutstring.find('Xcat_J1_mediumX')!=-1 + + print 'QCD SETUP', antiEleIsoForQCD, antiEleRlxTauIsoForQCD antiEleRlxTauIsoForQCDYield = cutstring.find('Xcat_J1_high_mediumhiggsX')!=-1 or cutstring.find('Xcat_VBF_tightX')!=-1 @@ -551,6 +572,9 @@ def handleW( anaDir, selComps, weights, if isVBF or isOneJet or isBtag: replaceW = True + if options.shift and 'WShape' in options.shift: + replaceW = True + # Use OS+SS for W extrapolation in VBF if isVBF: osForWExtrapolation = False @@ -591,11 +615,12 @@ def handleW( anaDir, selComps, weights, # Calculate externally, need to recalculate if samples change # NOTE: Recalculation requires full QCD estimation including # BG subtraction and W estimation in SS region - # > python -i plot_H2TauTauDataMC_TauEle_All.py /data/steggema/Aug08TauEle/ tauEle_2012_cfg.py -C 'Xcat_IncX && mt<30' -H svfitMass -b + # > python -i plot_H2TauTauDataMC_TauEle_All.py /data/steggema/Sep19EleTau/ tauEle_2012_cfg.py -C 'Xcat_IncX && mt<30' -H svfitMass -b # > print osQCD if isVBF: - print 'WARNING, taking QCD yield from external calculation (Aug08TauEle)' - incQCDYield = 11251.0 + print 'WARNING, taking QCD yield from external calculation (Sep19EleTau)' + # incQCDYield = 11251.0 (Aug06) + incQCDYield = 3398.5 # with tau pt > 30 (Sep19EleTau) # The following parameters are the same for a given set of samples + a cut (= category) parameters = {'cut':options.cut, 'anaDir':anaDir, 'selComps':selComps, 'weights':weights, @@ -608,11 +633,9 @@ def handleW( anaDir, selComps, weights, if options.allPlots: drawAll(plots_All, 'Summer13StackPlotsJul19/', options.blind, parameters, isMSSM) else: + ssign, osign, ssQCD, osQCD = makePlot(options.hist, NBINS, XMIN, XMAX, **parameters) if makeQCDIsoPlots: qcdIsoPlots(options.hist, NBINS, XMIN, XMAX, parameters) - - ssign, osign, ssQCD, osQCD = makePlot(options.hist, NBINS, XMIN, XMAX, **parameters) - if blind and isMSSM: osQCD.blindxmin = 100. osQCD.blindxmax = 1000. @@ -624,5 +647,3 @@ def handleW( anaDir, selComps, weights, draw(osQCD, options.blind, channel='TauEle') datacards(osQCD, cutstring, shift, 'eleTau', prefix=options.prefix) # printDataVsQCDInfo(osQCD, ssQCD) - - diff --git a/CMGTools/H2TauTau/Jan/EleTau/plot_helper.py b/CMGTools/H2TauTau/Jan/EleTau/plot_helper.py index 40a28f4cd51e4..e752a753df886 100644 --- a/CMGTools/H2TauTau/Jan/EleTau/plot_helper.py +++ b/CMGTools/H2TauTau/Jan/EleTau/plot_helper.py @@ -11,10 +11,16 @@ def qcdIsoPlots(hist, NBINS, XMIN, XMAX, parameters): parameters['subtractBGForQCDShape'] = True parameters['antiEleIsoForQCD'] = False + # parameters['subtractBGForQCDShape'] = False + # parameters['antiEleIsoForQCD'] = True + parameters['antiEleRlxTauIsoForQCD'] = False ssignAM, osignAM, ssQCDAM, osQCDAM = makePlot( hist, NBINS, XMIN, XMAX, **parameters) parameters['subtractBGForQCDShape'] = False parameters['antiEleIsoForQCD'] = True + parameters['antiEleRlxTauIsoForQCD'] = False + # parameters['antiEleRlxTauIsoForQCD'] = True + ssignATM, osignATM, ssQCDATM, osQCDATM = makePlot( hist, NBINS, XMIN, XMAX, **parameters) # can = buildCanvasOfficial() @@ -31,6 +37,7 @@ def qcdIsoPlots(hist, NBINS, XMIN, XMAX, parameters): # hQCDAM.SetTitle('QCD SS #mu') # hQCDAM = osQCDAM.Hist('QCD').weighted + # hQCDAM.SetTitle('SS anti-#mu iso') hQCDAM.SetTitle('SS BG-sub') hQCDAM.GetXaxis().SetTitle('m_{#tau #tau} [GeV]') hQCDAM.GetYaxis().SetTitle('Events') @@ -41,6 +48,7 @@ def qcdIsoPlots(hist, NBINS, XMIN, XMAX, parameters): # hQCDATM = osQCDATM.Hist('QCD').weighted # hQCDATM.SetTitle('QCD SS #mu #tau') + hQCDATM.SetTitle('SS anti-#mu rel tau iso') hQCDATM.SetTitle('SS anti-#mu iso') # hQCDATM.SetTitle('QCD SS') hQCDATM.SetMarkerColor(2) diff --git a/CMGTools/H2TauTau/Jan/EleTau/runDatacardInput.py b/CMGTools/H2TauTau/Jan/EleTau/runDatacardInput.py index 31f1f296edc3b..0d2fc2fe53cf1 100644 --- a/CMGTools/H2TauTau/Jan/EleTau/runDatacardInput.py +++ b/CMGTools/H2TauTau/Jan/EleTau/runDatacardInput.py @@ -6,35 +6,35 @@ max_processes = 4 doSM = True -doMSSM = True +doMSSM = False catsSM = [] catsMSSM = [] if doSM: - catsSM = [ - 'Xcat_IncX && mt<30 && Xcat_J0_lowX && l1_decayMode==1', - 'Xcat_IncX && mt<30 && Xcat_J0_mediumX && l1_decayMode==1', - 'Xcat_IncX && mt<30 && Xcat_J0_highX && l1_decayMode==1', - 'Xcat_IncX && mt<30 && Xcat_J1_mediumX && met>30 && l1_decayMode==1', - 'Xcat_IncX && mt<30 && Xcat_J1_high_mediumhiggsX && met>30 && l1_decayMode==1', - 'Xcat_IncX && mt<30 && Xcat_J1_high_lowhiggsX && met>30 && l1_decayMode==1', - 'Xcat_IncX && mt<30 && Xcat_VBF_looseX && l1_decayMode==1', - 'Xcat_IncX && mt<30 && Xcat_VBF_tightX && l1_decayMode==1', -] + catsSM = { + 'Xcat_IncX && mt<30 && Xcat_J0_lowX':'0jet_low', + 'Xcat_IncX && mt<30 && Xcat_J0_mediumX':'0jet_medium', + 'Xcat_IncX && mt<30 && Xcat_J0_highX':'0jet_high', + 'Xcat_IncX && mt<30 && met>30 && Xcat_J1_mediumX':'1jet_medium', + 'Xcat_IncX && mt<30 && met>30 && Xcat_J1_high_mediumhiggsX':'1jet_high_mediumhiggs', + 'Xcat_IncX && mt<30 && met>30 && Xcat_J1_high_lowhiggsX':'1jet_high_lowhiggs', + 'Xcat_IncX && mt<30 && Xcat_VBF_looseX':'vbf_loose', + 'Xcat_IncX && mt<30 && Xcat_VBF_tightX':'vbf_tight', +} if doMSSM: - catsMSSM = [ - 'Xcat_IncX && mt<30 && Xcat_J1BX', - 'Xcat_IncX && mt<30 && Xcat_0BX' -] + catsMSSM = { + 'Xcat_IncX && mt<30 && Xcat_J1BX':'btag', + 'Xcat_IncX && mt<30 && Xcat_0BX':'nobtag' +} -dirUp = '/data/steggema/Aug08TauEle_Up/' #NOTE: Must end with Up -dirDown = '/data/steggema/Aug08TauEle_Down/' #NOTE: Must end with Down -dirNom = '/data/steggema/Aug08TauEle/' +dirUp = '/data/steggema/Sep19EleTau_Up/' #NOTE: Must end with Up +dirDown = '/data/steggema/Sep19EleTau_Down/' #NOTE: Must end with Down +dirNom = '/data/steggema/Sep19EleTau/' -dirGGH = '/data/steggema/Aug08TauEle/' +dirGGH = '/data/steggema/Sep19EleTau/' embedded = True @@ -60,7 +60,13 @@ argsZLUp = ['python', 'plot_H2TauTauMC.py', dirNom, 'tauEle_2012_cfg.py', '-C', cat, '-H', 'svfitMass*1.02', '-b', '-f', 'Ztt', '-s', 'CMS_htt_ZLScale_etau_8TeVUp', '-c', 'TauEle'] argsZLDown = ['python', 'plot_H2TauTauMC.py', dirNom, 'tauEle_2012_cfg.py', '-C', cat, '-H', 'svfitMass*0.98', '-b', '-f', 'Ztt', '-s', 'CMS_htt_ZLScale_etau_8TeVDown', '-c', 'TauEle'] - allArgs += [args, argsUp, argsDown, argsGGHUp, argsGGHDown, argsZLUp, argsZLDown] + argsZLSmeared = ['python', 'plot_H2TauTauMC.py', dirNom, 'tauEle_2012_cfg.py', '-C', cat, '-H', 'svfitMass.+l1_phi*1.9', '-b', '-f', 'Ztt', '-s', 'CMS_htt_ZLScale_etau_8TeVSmearedUp', '-c', 'TauEle'] + + argsWJetsUp = ['python', 'plot_H2TauTauDataMC_TauEle_All.py', dirNom, 'tauEle_2012_cfg.py', '-C', cat, '-H', 'svfitMass', '-b', '-s', 'CMS_htt_WShape_etau_{cat}_8TeVUp'.format(cat=catsSM[cat])] + argsWJetsDown = ['python', 'plot_H2TauTauDataMC_TauEle_All.py', dirNom, 'tauEle_2012_cfg.py', '-C', cat, '-H', 'svfitMass', '-b', '-s', 'CMS_htt_WShape_etau_{cat}_8TeVDown'.format(cat=catsSM[cat])] + + # allArgs += [args, argsUp, argsDown, argsGGHUp, argsGGHDown, argsZLUp, argsZLDown, argsWJetsUp, argsWJetsDown] + allArgs += [argsZLSmeared] for cat in catsMSSM: for mssmBinning in mssmBinnings: @@ -76,7 +82,10 @@ argsZLUp = ['python', 'plot_H2TauTauMC.py', dirNom, 'tauEle_2012_cfg.py', '-C', cat, '-H', 'svfitMass*1.02', '-b', '-f', 'Ztt', '-s', 'CMS_htt_ZLScale_etau_8TeVUp', '-k', mssmBinning, '-p', mssmBinning, '-c', 'TauEle', '-g', '125'] argsZLDown = ['python', 'plot_H2TauTauMC.py', dirNom, 'tauEle_2012_cfg.py', '-C', cat, '-H', 'svfitMass*0.98', '-b', '-f', 'Ztt', '-s', 'CMS_htt_ZLScale_etau_8TeVDown', '-k', mssmBinning, '-p', mssmBinning, '-c', 'TauEle', '-g', '125'] - allArgs += [args, argsUp, argsDown, argsGGHUp, argsGGHDown, argsZLUp, argsZLDown] + argsWJetsUp = ['python', 'plot_H2TauTauDataMC_TauEle_All.py', dirNom, 'tauEle_2012_cfg.py', '-C', cat, '-H', 'svfitMass', '-b', '-s', 'CMS_htt_WShape_etau_{cat}_8TeVUp'.format(cat=catsMSSM[cat]), '-k', mssmBinning, '-p', mssmBinning, '-g', '125'] + argsWJetsDown = ['python', 'plot_H2TauTauDataMC_TauEle_All.py', dirNom, 'tauEle_2012_cfg.py', '-C', cat, '-H', 'svfitMass', '-b', '-s', 'CMS_htt_WShape_etau_{cat}_8TeVDown'.format(cat=catsMSSM[cat]), '-k', mssmBinning, '-p', mssmBinning, '-g', '125'] + + allArgs += [args, argsUp, argsDown, argsGGHUp, argsGGHDown, argsZLUp, argsZLDown, argsWJetsUp, argsWJetsDown] for args in allArgs: diff --git a/CMGTools/H2TauTau/interface/TriggerEfficiency.h b/CMGTools/H2TauTau/interface/TriggerEfficiency.h index ff86862266443..6fcae07a226e1 100644 --- a/CMGTools/H2TauTau/interface/TriggerEfficiency.h +++ b/CMGTools/H2TauTau/interface/TriggerEfficiency.h @@ -255,31 +255,39 @@ class TriggerEfficiency { //COLIN: putting the junction at 1.4 as discussed with Josh double effIsoMu12(double pt, double eta){ - if(fabs(eta)<1.4) - return 0.901; //Barrel + if(fabs(eta)<0.8) + return 0.920; //Barrel + else if (fabs(eta) < 1.2) + return 0.868; else - return 0.863; //EndCap + return 0.845; //EndCap } double effIsoMu15(double pt, double eta){ - if(fabs(eta)<1.4) - return 0.901; + if(fabs(eta)<0.8) + return 0.917; + else if (fabs(eta) < 1.2) + return 0.871; else - return 0.863; + return 0.864; } double effIsoMu15eta2p1(double pt, double eta){ - if(fabs(eta)<1.4) - return efficiency(pt,15.06,0.55278,1.34236,1.003,3.36767); + if(fabs(eta)<0.8) + return efficiency(pt,15.9877,2.90938e-07,2.63922e-11,5.81194,0.906943); + else if(fabs(eta)<1.2) + return efficiency(pt,15.9995,1.35931e-07,7.88264e-11,4.60253,0.855461); else - return efficiency(pt,15.03175,0.866114,1.25009,1.63711,0.844906); + return efficiency(pt,15.9084,2.27242e-12,8.77174e-14,1.00241,12.9909); } double effIsoMu15MC(double pt, double eta){//should correspond to Fall11 MC - if(fabs(eta)<1.4) - return 0.917; - else - return 0.836; + if(fabs(eta)<0.8) + return 0.923; + else if (fabs(eta)<1.2) + return 0.879; + else + return 0.839; } diff --git a/CMGTools/H2TauTau/prod/h2TauTau_murm_cfg.py b/CMGTools/H2TauTau/prod/h2TauTau_murm_cfg.py index f7dfcb3ce135e..975ab89a422a0 100644 --- a/CMGTools/H2TauTau/prod/h2TauTau_murm_cfg.py +++ b/CMGTools/H2TauTau/prod/h2TauTau_murm_cfg.py @@ -1,4 +1,5 @@ import FWCore.ParameterSet.Config as cms +import pprint from CMGTools.Common.Tools.cmsswRelease import isNewerThan, cmsswIs44X,cmsswIs52X @@ -8,34 +9,30 @@ process = cms.Process("H2TAUTAU") -process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(20000) ) +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) process.maxLuminosityBlocks = cms.untracked.PSet( input = cms.untracked.int32(-1) ) # -1 : process all files -numberOfFilesToProcess = 140 +numberOfFilesToProcess = -1 debugEventContent = False #tau-mu, tau-ele, di-tau, all -channel = 'tau-mu' # 'tau-mu' #'tau-mu' 'all' 'tau-ele' +channel = 'tau-mu' # 'tau-mu' #'di-tau' 'all' 'tau-ele' jetRecalib = False -useCHS = False -#newSVFit enables the svfit mass reconstruction used for the H->tau tau analysis. -# if false, much faster processing but mass is wrong. -newSVFit = False +useCHS = False +newSVFit = False tauScaling = 0 -# increase to 1000 before running on the batch, to reduce size of log files -# on your account -reportInterval = 1000 +reportInterval = 500 print sep_line -print 'channel', channel -print 'jet recalib', jetRecalib -print 'useCHS', useCHS -print 'newSVFit', newSVFit +print 'channel' , channel +print 'jet recalib' , jetRecalib +print 'useCHS' , useCHS +print 'newSVFit' , newSVFit print 'tau scaling =', tauScaling ########## @@ -43,15 +40,20 @@ # Input & JSON ------------------------------------------------- +# dataset_user = 'cmgtools_group' +# dataset_name = '/GluGluToHToTauTau_M-120_8TeV-powheg-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/PAT_CMG_V5_16_0' +# dataset_user = 'cmgtools' +# dataset_name = '/WJetsToLNu_TuneZ2Star_8TeV-madgraph-tarball/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_16_0' -dataset_user = 'cbern' -# dataset_name = '/DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_16_0/DIMU_Colin_17Jun2013' -dataset_name = '/DY4JetsToLL_M-50_TuneZ2Star_8TeV-madgraph/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_16_0/DIMU_Colin_17Jun2013' -# dataset_name = '/TauPlusX/Run2012C-22Jan2013-v1/AOD/PAT_CMG_V5_16_0/DIMU_Colin_17Jun2013' - +#dataset_user = 'cmgtools' +#dataset_name = '/TauParked/Run2012D-22Jan2013-v1/AOD/PAT_CMG_V5_16_0' dataset_files = 'cmgTuple.*root' +dataset_user = 'cbern' +dataset_name = '/DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_16_0/DIMU_Colin_17Jun2013' +# dataset_name = '/TauPlusX/Run2012D-22Jan2013-v1/AOD/PAT_CMG_V5_16_0/DIMU_Colin_17Jun2013' + # creating the source from CMGTools.Production.datasetToSource import * process.source = datasetToSource( @@ -93,14 +95,66 @@ print sep_line from CMGTools.H2TauTau.tools.setupRecoilCorrection import setupRecoilCorrection -# WARNING DISABLING RECOIL CORRECTIONS FOR 2012!!! -setupRecoilCorrection( process, runOnMC, True, cmsswIs52X(), 'WJetsToLNu') + +recoilEnabled = True +setupRecoilCorrection( process, runOnMC, + enable=recoilEnabled, + is53X=isNewerThan('CMSSW_5_2_X'), + channel = channel, + mode='WJetsToLNu') + + +# Kinematic reweighting for the embedded samples from here https://twiki.cern.ch/twiki/bin/viewauth/CMS/MuonTauReplacementRecHit +# Can also put this into a separate file under tools + +isEmbedded = process.source.fileNames[0].find('embedded') != -1 + +if isEmbedded: + process.load('TauAnalysis.MCEmbeddingTools.embeddingKineReweight_cff') + + if channel == 'all': + print 'ERROR: not possible to run all the channels for the embedded samples right now' + + # for "standard" e+tau channel + if channel == 'tau-ele': + process.embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_ePtGt20tauPtGt18_recEmbedded.root") + process.tauElePath.insert(-1, process.embeddingKineReweightSequenceRECembedding) + + # for e+tau channel of "soft lepton" analysis + #embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_ePt9to30tauPtGt18_recEmbedded.root") + + # for "standard" mu+tau channel + if channel == 'tau-mu': + process.embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_muPtGt16tauPtGt18_recEmbedded.root") + process.tauMuPath.insert(-1, process.embeddingKineReweightSequenceRECembedding) + + # for mu+tau channel of "soft lepton" analysis + #embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_muPt7to25tauPtGt18_recEmbedded.root") + + # for tautau channel + if channel == 'di-tau': + process.embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_tautau_recEmbedded.root") + process.diTauPath.insert(-1, process.embeddingKineReweightSequenceRECembedding) + + print "Embedded samples; using kinematic reweighting file:", process.embeddingKineReweightRECembedding.inputFileName + + # for emu, mumu and ee channels + #embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_recEmbedding_emu.root") + # OUTPUT definition ---------------------------------------------------------- process.outpath = cms.EndPath() # generator ---------------------------------------------- -if not runOnMC: +if not runOnMC : + if not isEmbedded : + process.diTauPath.remove( process.cmgDiTauCor ) + process.cmgDiTauPtSel.src = cms.InputTag('mvaMETDiTau') + process.tauMuPath.remove( process.cmgTauMuCor ) ## boh + process.cmgTauMuTauPtSel.src = cms.InputTag('mvaMETTauMu') ## boh + process.tauElePath.remove( process.cmgTauEleCor ) ## boh + process.cmgTauEleTauPtSel.src = cms.InputTag('mvaMETTauEle') ## boh + process.tauMuPath.remove( process.genSequence ) process.tauElePath.remove( process.genSequence ) process.diTauPath.remove( process.genSequence ) @@ -118,6 +172,8 @@ verbose = cms.untracked.bool( False ) ) +# need to remove the leading jet corresponding to the removed muon + process.cmgPFJetSel = cms.EDProducer( "DeltaRVetoProducerPFJet", inputCollection = cms.InputTag('cmgPFJetSel'), @@ -144,42 +200,6 @@ verbose = cms.untracked.bool(False) ) - - -## process.pfMetForRegressionCor = cms.EDProducer( -## 'PFMetModificationProducer', -## candSrc = cms.InputTag('cmgMuonSel:removed'), -## metSrc = cms.InputTag('pfMetForRegression'), -## operator = cms.string('-') -## ) -## process.pfMetForRegression = cms.EDProducer( -## 'PFMetModificationProducer', -## candSrc = cms.InputTag('cmgMuonSel:correction'), -## metSrc = cms.InputTag('pfMetForRegressionCor'), -## operator = cms.string('-') -## ) - -## process.nopuMetCor = process.pfMetForRegressionCor.clone(metSrc='nopuMet') -## process.nopuMet = process.pfMetForRegression.clone(metSrc='nopuMetCor') -## process.pcMetCor = process.pfMetForRegressionCor.clone(metSrc='pcMet') -## process.pcMet = process.pfMetForRegression.clone(metSrc='pcMetCor') -## process.tkMetCor = process.pfMetForRegressionCor.clone(metSrc='tkMet') -## process.tkMet = process.pfMetForRegression.clone(metSrc='tkMetCor') - - -## process.pfMetModificationSequence = cms.Sequence( -## process.pfMetForRegressionCor + -## process.pfMetForRegression + -## process.nopuMetCor + -## process.nopuMet + -## process.pcMetCor + -## process.pcMet + -## process.tkMetCor + -## process.tkMet -## ) - - - process.pfMetForRegression = cms.EDProducer( 'PFMetModificationProducer', candSrc = cms.InputTag('cmgMuonSel:removed'), @@ -192,6 +212,8 @@ process.tkMet = process.pfMetForRegression.clone(metSrc='tkMet') +process.mvaMETTauMu.leadJetSrc = 'cmgPFJetSel' + process.pfMetModificationSequence = cms.Sequence( process.pfMetForRegression + process.nopuMet + @@ -206,9 +228,8 @@ process.pfMetModificationSequence ) +process.tauMuPath.insert(0, process.muRmSequence) -if 1: - process.tauMuPath.insert(0, process.muRmSequence) #Jose: process.schedule doesn't have a += operator? if channel=='all': @@ -242,7 +263,9 @@ print sep_line print 'INPUT:' print sep_line -print process.source.fileNames +pprint.pprint( process.source.fileNames[:5] ) +print '...' +print 'total number of files =', len(process.source.fileNames) print if runOnMC==False: print 'json:', json @@ -251,6 +274,7 @@ print 'PROCESSING' print sep_line print 'runOnMC:', runOnMC +print 'isEmbedded:', isEmbedded print print sep_line print 'OUPUT:' @@ -267,9 +291,10 @@ # process.recoilCorMETTauMu.verbose= True # systematic shift on tau energy scale -process.cmgTauScaler.cfg.nSigma = tauScaling +process.cmgDiTauCor.cfg.nSigma = tauScaling from CMGTools.H2TauTau.tools.setupOutput import * + if channel=='tau-mu' or channel=='all': addTauMuOutput( process, debugEventContent, addPreSel=False) if channel=='tau-ele' or channel=='all': @@ -335,14 +360,29 @@ if newSVFit: process.cmgTauMuCorSVFitPreSel.SVFitVersion = 2 process.cmgTauEleCorSVFitPreSel.SVFitVersion = 2 - process.cmgDiTauSVFit.SVFitVersion = 2 + process.cmgDiTauCorSVFitPreSel.SVFitVersion = 2 else: process.cmgTauMuCorSVFitPreSel.SVFitVersion = 1 process.cmgTauEleCorSVFitPreSel.SVFitVersion = 1 - process.cmgDiTauSVFit.SVFitVersion = 1 + process.cmgDiTauCorSVFitPreSel.SVFitVersion = 1 # process.tauMu_fullsel_tree_CMG.SelectEvents = cms.untracked.PSet() -process.cmgTauMu.cuts.baseline.tauLeg.iso = cms.string('leg1().tauID("byRawIsoMVA") > -9999') +# process.cmgTauMu.cuts.baseline.tauLeg.iso = cms.string('leg1().tauID("byRawIsoMVA") > 0.5') +# process.cmgTauMu.cuts.baseline.tauLeg.iso = cms.string('leg1().tauID("byRawIsoMVA") > -9999') +# process.cmgTauMu.cuts.baseline.tauLeg.iso = cms.string('leg1().tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits") < 10.') + +process.cmgTauMu.cuts.baseline.tauLeg.kinematics.pt = cms.string('leg1().pt() > 30.') + + +# process.cmgDiTau.cuts.baseline.tau1Leg.iso = cms.string('leg1().tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits") < 10.') +# process.cmgDiTau.cuts.baseline.tau2Leg.iso = cms.string('leg2().tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits") < 10.') +# process.cmgDiTau.cuts.baseline.tau1Leg.kinematics.pt = cms.string('leg1().pt()>35.') +# process.cmgDiTau.cuts.baseline.tau2Leg.kinematics.pt = cms.string('leg2().pt()>35.') +# process.cmgDiTau.cuts.baseline.tau1Leg.kinematics.eta = cms.string('abs(leg1().eta())<2.1') +# process.cmgDiTau.cuts.baseline.tau2Leg.kinematics.eta = cms.string('abs(leg2().eta())<2.1') + + + diff --git a/CMGTools/H2TauTau/prod/h2TauTau_mutau_cfg.py b/CMGTools/H2TauTau/prod/h2TauTau_mutau_cfg.py new file mode 100644 index 0000000000000..fdbf34139a0d6 --- /dev/null +++ b/CMGTools/H2TauTau/prod/h2TauTau_mutau_cfg.py @@ -0,0 +1,331 @@ +import FWCore.ParameterSet.Config as cms + +from CMGTools.Common.Tools.cmsswRelease import isNewerThan, cmsswIs44X,cmsswIs52X + +sep_line = '-'*70 + +########## CONTROL CARDS + +process = cms.Process("H2TAUTAU") + +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(5000) ) + +process.maxLuminosityBlocks = cms.untracked.PSet( + input = cms.untracked.int32(-1) + ) + +# -1 : process all files +numberOfFilesToProcess = 10 + +debugEventContent = False + +#tau-mu, tau-ele, di-tau, all +channel = 'tau-mu' # 'tau-mu' #'di-tau' 'all' 'tau-ele' +jetRecalib = False +useCHS = False +#newSVFit enables the svfit mass reconstruction used for the H->tau tau analysis. +# if false, much faster processing but mass is wrong. +newSVFit = True +tauScaling = 0 +applyESCorr = True +# increase to 1000 before running on the batch, to reduce size of log files +# on your account +reportInterval = 1000 + +print sep_line +print 'channel', channel +print 'jet recalib', jetRecalib +print 'useCHS', useCHS +print 'newSVFit', newSVFit +print 'tau scaling =', tauScaling + +########## + + + +# Input & JSON ------------------------------------------------- + + +dataset_user = 'cmgtools' + + +# dataset_name = '/VBF_HToTauTau_M-125_7TeV-powheg-pythia6-tauola/Fall11-PU_S6_START42_V14B-v1/AODSIM/V5_B/PAT_CMG_V5_6_0_B' +# dataset_name = '/VBF_HToTauTau_M-125_8TeV-powheg-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_14_0' +# dataset_name = '/VBF_HToTauTau_M-125_8TeV-powheg-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_16_0' +# dataset_name = '/TauPlusX/Run2012A-22Jan2013-v1/AOD/PAT_CMG_V5_16_0' +# dataset_name = '/DoubleMu/StoreResults-Run2012A_22Jan2013_v1_RHembedded_trans1_tau115_ptelec1_20had1_18_v1-f456bdbb960236e5c696adfe9b04eaae/USER/V5_B/PAT_CMG_V5_16_0' + + +# /GluGluToHToTauTau_M-125_8TeV-powheg-pythia6/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_14_0 + +#dataset_user = 'cmgtools_group' +#dataset_name = '/WH_ZH_TTH_HToTauTau_M-125_8TeV-pythia6-tauola/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_14_0' + +#dataset_name = '/DoubleMuParked/StoreResults-Run2012D_22Jan2013_v1_PFembedded_trans1_tau116_ptmu1_16had1_18_v1-5ef1c0fd428eb740081f19333520fdc8/USER/V5_B/PAT_CMG_V5_16_0' +dataset_name = '/DYJetsToLL_M-50_TuneZ2Star_8TeV-madgraph-tarball/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_16_0' + +#dataset_name = '/WJetsToLNu_TuneZ2Star_8TeV-madgraph-tarball/Summer12_DR53X-PU_S10_START53_V7A-v1/AODSIM/V5_B/PAT_CMG_V5_16_0' + +dataset_user = 'steggema' +# dataset_name = '/Radion_hh_tautaubb_LR3tevLHC8_glufusion_MR300_GENSIM_19082013/caber-Radion_hh_tautaubb_LR3tevLHC8_glufusion_MR300_20082013_AODSIM-c8f8ed334db8a7d6f56c62266b1dfa5b/USER/PAT_CMG_V5_16_0' +dataset_name = '/AbelianZprime_hh_TauTauBB_LHC8_M700_GENSIM_29082012/caber-Radion_hh_TauTauBB_LHC8_M700_31082013_AODSIM-c8f8ed334db8a7d6f56c62266b1dfa5b/USER/PAT_CMG_V5_16_0' + +dataset_files = 'cmgTuple.*root' + +# creating the source +from CMGTools.Production.datasetToSource import * +process.source = datasetToSource( + dataset_user, + dataset_name, + dataset_files, + ) + +process.source.inputCommands=cms.untracked.vstring( + 'keep *', + 'drop cmgStructuredPFJets_cmgStructuredPFJetSel__PAT' + ) + + +# process.source.fileNames = ['file:VBF_HToTauTau.root'] + +# restricting the number of files to process to a given number +if numberOfFilesToProcess>0: + process.source.fileNames = process.source.fileNames[:numberOfFilesToProcess] + + +###ProductionTaskHook$$$ + +runOnMC = process.source.fileNames[0].find('Run201')==-1 and process.source.fileNames[0].find('embedded')==-1 + + + +# Sequence & path definition ------------------------------------------------- + + +# set up JSON --------------------------------------------------------------- +if runOnMC==False: + from CMGTools.H2TauTau.tools.setupJSON import setupJSON + json = setupJSON(process) + + +# load the channel paths ------------------------------------------- +process.load('CMGTools.H2TauTau.h2TauTau_cff') + +# setting up the recoil correction according to the input file --------------- + +print sep_line +from CMGTools.H2TauTau.tools.setupRecoilCorrection import setupRecoilCorrection + +recoilEnabled = True +setupRecoilCorrection( process, runOnMC, + enable=recoilEnabled, is53X=isNewerThan('CMSSW_5_2_X')) + + +# Kinematic reweighting for the embedded samples from here https://twiki.cern.ch/twiki/bin/viewauth/CMS/MuonTauReplacementRecHit +# Can also put this into a separate file under tools + +isEmbedded = process.source.fileNames[0].find('embedded') != -1 + +isRHEmbedded = process.source.fileNames[0].find('RHembedded') != -1 + +if isEmbedded and isRHEmbedded: + process.load('TauAnalysis.MCEmbeddingTools.embeddingKineReweight_cff') + + if channel == 'all': + print 'ERROR: not possible to run all the channels for the embedded samples right now' + + # for "standard" e+tau channel + if channel == 'tau-ele': + process.embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_ePtGt20tauPtGt18_recEmbedded.root") + process.tauElePath.insert(-1, process.embeddingKineReweightSequenceRECembedding) + + # for e+tau channel of "soft lepton" analysis + #embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_ePt9to30tauPtGt18_recEmbedded.root") + + # for "standard" mu+tau channel + if channel == 'tau-mu': + process.embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_muPtGt16tauPtGt18_recEmbedded.root") + process.tauMuPath.insert(-1, process.embeddingKineReweightSequenceRECembedding) + + # for mu+tau channel of "soft lepton" analysis + #embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_muPt7to25tauPtGt18_recEmbedded.root") + + # for tautau channel + if channel == 'di-tau': + process.embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_tautau_recEmbedded.root") + process.diTauPath.insert(-1, process.embeddingKineReweightSequenceRECembedding) + + print "Embedded samples; using kinematic reweighting file:", process.embeddingKineReweightRECembedding.inputFileName + + # for emu, mumu and ee channels + #embeddingKineReweightRECembedding.inputFileName = cms.FileInPath("TauAnalysis/MCEmbeddingTools/data/embeddingKineReweight_recEmbedding_emu.root") + + +# OUTPUT definition ---------------------------------------------------------- +process.outpath = cms.EndPath() + +# don't apply Tau ES corrections for data (but do for embedded) or processes not containing real taus + +signalTauProcess = (process.source.fileNames[0].find('HToTauTau') != -1) or (process.source.fileNames[0].find('DY') != -1) or isEmbedded + +# UPDATE: Only apply Tau ES corrections for embedded +# signalTauProcess = isEmbedded + +# if not runOnMC and not isEmbedded: +if not signalTauProcess or not applyESCorr: + print 'Not applying tau ES corrections as no process with real simulated taus or tau ES switched off' + process.tauMuPath.remove( process.cmgTauMuCor ) + process.cmgTauMuTauPtSel.src = cms.InputTag('mvaMETTauMu') + # process.diTauPath.remove( process.cmgDiTauCorPreSel ) + process.mvaMETDiTau.src = cms.InputTag('cmgDiTauPreSel') + process.tauElePath.remove( process.cmgTauEleCor ) + process.cmgTauEleTauPtSel.src = cms.InputTag('mvaMETTauEle') +else: + print 'Apply tau ES corrections' + +# generator ---------------------------------------------- +if not runOnMC: + process.tauMuPath.remove( process.genSequence ) + process.tauElePath.remove( process.genSequence ) + process.diTauPath.remove( process.genSequence ) + + +#Jose: process.schedule doesn't have a += operator? +if channel=='all': + process.schedule = cms.Schedule( + process.tauMuPath, + process.tauElePath, + # process.muElePath, + process.diTauPath, + process.outpath + ) +elif channel=='tau-mu': + process.schedule = cms.Schedule( + process.tauMuPath, + process.outpath + ) +elif channel=='tau-ele': + process.schedule = cms.Schedule( + process.tauElePath, + process.outpath + ) +elif channel=='di-tau': + process.schedule = cms.Schedule( + process.diTauPath, + process.outpath + ) +else: + raise ValueError('unrecognized channel') + + + +print sep_line +print 'INPUT:' +print sep_line +print process.source.fileNames +print +if runOnMC==False: + print 'json:', json +print +print sep_line +print 'PROCESSING' +print sep_line +print 'runOnMC:', runOnMC +print +print sep_line +print 'OUPUT:' +print sep_line +justn = 30 +# print 'baseline selection EDM output'.ljust(justn), baselineName +# print 'basic selection EDM output'.ljust(justn), basicName +# print 'histograms output'.ljust(justn), histName +# print 'Debug event content'.ljust(justn), debugEventContent + +# you can enable printouts of most modules like this: +# process.cmgTauMuCorSVFitPreSel.verbose = True +# process.mvaMETTauMu.verbose = True +# process.recoilCorMETTauMu.verbose= True + +# systematic shift on tau energy scale +# process.cmgTauScaler.cfg.nSigma = tauScaling + +from CMGTools.H2TauTau.tools.setupOutput import * +if channel=='tau-mu' or channel=='all': + addTauMuOutput( process, debugEventContent, addPreSel=False) +if channel=='tau-ele' or channel=='all': + addTauEleOutput( process, debugEventContent, addPreSel=False) +## if channel=='mu-ele' or channel=='all': +## addMuEleOutput( process, debugEventContent, addPreSel=False) +if channel=='di-tau' or channel=='all': + addDiTauOutput( process, debugEventContent, addPreSel=False) + + + + +# Message logger setup. +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.FwkReport.reportEvery = reportInterval +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(False) ) + + +# Jet recalibration + +if jetRecalib: + process.load('Configuration.StandardSequences.Services_cff') + process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + GT = None + if runOnMC: + if cmsswIs44X(): + GT = 'START44_V13::All' + else: + GT = 'START52_V10::All' + else: + if cmsswIs44X(): + GT = 'GR_R_44_V15::All' + else: + GT = 'GR_R_52_V8::All' + process.GlobalTag.globaltag = GT + from CMGTools.Common.miscProducers.cmgPFJetCorrector_cfi import cmgPFJetCorrector + process.cmgPFJetSel = cmgPFJetCorrector.clone(src='cmgPFJetSel', + payload='AK5PF') + process.cmgPFJetSelCHS = cmgPFJetCorrector.clone(src='cmgPFJetSelCHS', + payload='AK5PFchs') + + if runOnMC: + process.cmgPFJetSel.levels = cms.vstring('L1FastJet','L2Relative','L3Absolute') + process.cmgPFJetSelCHS.levels = cms.vstring('L1FastJet','L2Relative','L3Absolute') + else: + process.cmgPFJetSel.levels = cms.vstring('L1FastJet','L2Relative','L3Absolute','L2L3Residual') + process.cmgPFJetSelCHS.levels = cms.vstring('L1FastJet','L2Relative','L3Absolute','L2L3Residual') + + process.tauMuPath.insert(0, process.cmgPFJetSel) + process.tauElePath.insert(0, process.cmgPFJetSel) + process.diTauPath.insert(0, process.cmgPFJetSel) + + process.tauMuPath.insert(0, process.cmgPFJetSelCHS) + process.tauElePath.insert(0, process.cmgPFJetSelCHS) + process.diTauPath.insert(0, process.cmgPFJetSelCHS) + + print sep_line + print 'Jet recalibration with GLOBAL TAG', GT + +if useCHS: + process.cmgPFJetForRecoil.src = 'cmgPFJetSelCHS' + +if newSVFit: + process.cmgTauMuCorSVFitPreSel.SVFitVersion = 2 + process.cmgTauEleCorSVFitPreSel.SVFitVersion = 2 + process.cmgDiTauCorSVFitPreSel.SVFitVersion = 2 +else: + process.cmgTauMuCorSVFitPreSel.SVFitVersion = 1 + process.cmgTauEleCorSVFitPreSel.SVFitVersion = 1 + process.cmgDiTauCorSVFitPreSel.SVFitVersion = 1 + +# process.tauMu_fullsel_tree_CMG.SelectEvents = cms.untracked.PSet() + +# process.cmgTauMu.cuts.baseline.tauLeg.iso = cms.string('leg1().tauID("byRawIsoMVA") > 0.5') +process.cmgTauMu.cuts.baseline.tauLeg.iso = cms.string('leg1().tauID("byRawIsoMVA") > -9999') +process.cmgTauMu.cuts.baseline.tauLeg.iso = cms.string('leg1().tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits") < 10.') +if 'Higgs' in dataset_name or 'HToTauTau' in dataset_name or isEmbedded: + process.cmgTauMu.cuts.baseline.tauLeg.iso = cms.string('leg1().tauID("byCombinedIsolationDeltaBetaCorrRaw3Hits") < 1.5') +process.cmgTauMu.cuts.baseline.tauLeg.kinematics.pt = cms.string('leg1().pt() > 10.') diff --git a/CMGTools/H2TauTau/python/objects/cmgDiTauCor_cfi.py b/CMGTools/H2TauTau/python/objects/cmgDiTauCor_cfi.py new file mode 100644 index 0000000000000..a5ccf0c48e3bb --- /dev/null +++ b/CMGTools/H2TauTau/python/objects/cmgDiTauCor_cfi.py @@ -0,0 +1,24 @@ +import FWCore.ParameterSet.Config as cms + +cmgDiTauCorFactory = cms.PSet( + # leg1 and leg2 are dummy collections here + leg1Collection = cms.InputTag(''), + leg2Collection = cms.InputTag(''), + #metCollection = cms.InputTag('recoilCorrectedMET'), + diObjectCollection = cms.InputTag('cmgDiTauSel'), + nSigma = cms.double(0), + uncertainty = cms.double(0.03), + shift1ProngNoPi0 = cms.double(0.), + shift1Prong1Pi0 = cms.double(0.012), ## 1.5% +1.0% by Phil for summer 13 (WARINING THIS +1.0% has been turned off) https://indico.cern.ch/getFile.py/access?contribId=24&sessionId=4&resId=0&materialId=slides&confId=252865 + ptDependence1Pi0 = cms.double(0.), + shift3Prong = cms.double(0.012), + ptDependence3Prong = cms.double(0.), + shiftMet = cms.bool(True), + shiftTaus = cms.bool(True) +) + +cmgDiTauCor = cms.EDFilter( + "DiTauUpdatePOProducer", + cfg = cmgDiTauCorFactory.clone(), + cuts = cms.PSet() + ) diff --git a/CMGTools/H2TauTau/python/objects/cmgMuEleCor_cfi.py b/CMGTools/H2TauTau/python/objects/cmgMuEleCor_cfi.py new file mode 100644 index 0000000000000..f0caa287c055f --- /dev/null +++ b/CMGTools/H2TauTau/python/objects/cmgMuEleCor_cfi.py @@ -0,0 +1,22 @@ +import FWCore.ParameterSet.Config as cms + +cmgMuEleCorFactory = cms.PSet( + # leg1 and leg2 are dummy collections here + leg1Collection = cms.InputTag(''), + leg2Collection = cms.InputTag(''), + metCollection = cms.InputTag('recoilCorrectedMET'), + diObjectCollection = cms.InputTag('cmgMuEleSel'), + nSigma = cms.double(0), + uncertainty = cms.double(0.03), + shift1ProngNoPi0 = cms.double(0.), + shift1Prong1Pi0 = cms.double(0.), + ptDependence1Pi0 = cms.double(0.), + shift3Prong = cms.double(0.), + ptDependence3Prong = cms.double(0.) +) + +cmgMuEleCor = cms.EDFilter( + "MuEleUpdatePOProducer", + cfg = cmgMuEleCorFactory.clone(), + cuts = cms.PSet() + ) diff --git a/CMGTools/H2TauTau/python/objects/cmgTauEleCor_cfi.py b/CMGTools/H2TauTau/python/objects/cmgTauEleCor_cfi.py new file mode 100644 index 0000000000000..845e775a2ef9e --- /dev/null +++ b/CMGTools/H2TauTau/python/objects/cmgTauEleCor_cfi.py @@ -0,0 +1,22 @@ +import FWCore.ParameterSet.Config as cms + +cmgTauEleCorFactory = cms.PSet( + diObjectCollection = cms.InputTag('cmgTauEleSel'), + nSigma = cms.double(0), + uncertainty = cms.double(0.03), + shift1ProngNoPi0 = cms.double(0.), + # shift1Prong1Pi0 = cms.double(0.025), + shift1Prong1Pi0 = cms.double(0.012), #Phil's update + ptDependence1Pi0 = cms.double(0.000), + # 0.012 according to the TWiki + shift3Prong = cms.double(0.012), + ptDependence3Prong = cms.double(0.000), + shiftMet = cms.bool(True), + shiftTaus = cms.bool(True) +) + +cmgTauEleCor = cms.EDFilter( + "TauEleUpdatePOProducer", + cfg = cmgTauEleCorFactory.clone(), + cuts = cms.PSet() + ) diff --git a/CMGTools/H2TauTau/python/objects/cmgTauMuCor_cfi.py b/CMGTools/H2TauTau/python/objects/cmgTauMuCor_cfi.py new file mode 100644 index 0000000000000..d380dd41475ab --- /dev/null +++ b/CMGTools/H2TauTau/python/objects/cmgTauMuCor_cfi.py @@ -0,0 +1,26 @@ +import FWCore.ParameterSet.Config as cms + +cmgTauMuCorFactory = cms.PSet( + # leg1 and leg2 are dummy collections here + leg1Collection = cms.InputTag(''), + leg2Collection = cms.InputTag(''), + #metCollection = cms.InputTag('recoilCorrectedMET'), + diObjectCollection = cms.InputTag('cmgTauMuSel'), + nSigma = cms.double(0), + uncertainty = cms.double(0.03), + shift1ProngNoPi0 = cms.double(0.), + # shift1Prong1Pi0 = cms.double(0.015), + shift1Prong1Pi0 = cms.double(0.012), #Phil's update + ptDependence1Pi0 = cms.double(0.000), + # 0.012 according to the TWiki + shift3Prong = cms.double(0.012), + ptDependence3Prong = cms.double(0.000), + shiftMet = cms.bool(True), + shiftTaus = cms.bool(True) +) + +cmgTauMuCor = cms.EDFilter( + "TauMuUpdatePOProducer", + cfg = cmgTauMuCorFactory.clone(), + cuts = cms.PSet() + ) diff --git a/CMGTools/H2TauTau/python/objects/diTauObjectsMVAMET_cff.py b/CMGTools/H2TauTau/python/objects/diTauObjectsMVAMET_cff.py index 168519f05677f..3777927d23dc1 100644 --- a/CMGTools/H2TauTau/python/objects/diTauObjectsMVAMET_cff.py +++ b/CMGTools/H2TauTau/python/objects/diTauObjectsMVAMET_cff.py @@ -3,14 +3,13 @@ from CMGTools.Common.Tools.cmsswRelease import cmsswIs44X,cmsswIs52X from CMGTools.Common.diTau_cff import * from CMGTools.H2TauTau.objects.diTauCuts_cff import * -from CMGTools.Common.factories.cmgDiTauCor_cfi import cmgDiTauCor +from CMGTools.H2TauTau.objects.cmgDiTauCor_cfi import cmgDiTauCor from CMGTools.H2TauTau.objects.diTauSVFit_cfi import diTauSVFit from CMGTools.Common.eventCleaning.goodPVFilter_cfi import goodPVFilter from CMGTools.Utilities.metRecoilCorrection.metRecoilCorrection_cff import * from CMGTools.Utilities.mvaMET.mvaMET_cff import * from CMGTools.Common.factories.cmgBaseMETFromPFMET_cfi import cmgBaseMETFromPFMET - # build diTau ---------------------------------------------------------- cmgDiTau.cuts = diTauCuts.clone() cmgDiTau.cfg.metsigCollection = cms.InputTag('') diff --git a/CMGTools/H2TauTau/python/objects/tauEleObjectsMVAMET_cff.py b/CMGTools/H2TauTau/python/objects/tauEleObjectsMVAMET_cff.py index f9e23a3323cdc..3f1bf863b9f65 100644 --- a/CMGTools/H2TauTau/python/objects/tauEleObjectsMVAMET_cff.py +++ b/CMGTools/H2TauTau/python/objects/tauEleObjectsMVAMET_cff.py @@ -7,7 +7,7 @@ from CMGTools.Utilities.metRecoilCorrection.metRecoilCorrection_cff import * -from CMGTools.Common.factories.cmgTauEleCor_cfi import cmgTauEleCor +from CMGTools.H2TauTau.objects.cmgTauEleCor_cfi import cmgTauEleCor from CMGTools.H2TauTau.objects.tauEleSVFit_cfi import tauEleSVFit from CMGTools.Common.Tools.cmsswRelease import cmsswIs44X,cmsswIs52X @@ -52,7 +52,7 @@ # Correct tau pt (after MVA MET according to current baseline) -from CMGTools.Common.factories.cmgTauEleCor_cfi import cmgTauEleCor +from CMGTools.H2TauTau.objects.cmgTauEleCor_cfi import cmgTauEleCor cmgTauEleCor = cmgTauEleCor.clone() cmgTauEleCor.cfg.diObjectCollection = cms.InputTag('mvaMETTauEle') diff --git a/CMGTools/H2TauTau/python/objects/tauMuObjectsMVAMET_cff.py b/CMGTools/H2TauTau/python/objects/tauMuObjectsMVAMET_cff.py index 44801523597a3..c0a30f47eac75 100644 --- a/CMGTools/H2TauTau/python/objects/tauMuObjectsMVAMET_cff.py +++ b/CMGTools/H2TauTau/python/objects/tauMuObjectsMVAMET_cff.py @@ -7,7 +7,7 @@ from CMGTools.Utilities.metRecoilCorrection.metRecoilCorrection_cff import * -from CMGTools.Common.factories.cmgTauMuCor_cfi import cmgTauMuCor +from CMGTools.H2TauTau.objects.cmgTauMuCor_cfi import cmgTauMuCor from CMGTools.H2TauTau.objects.tauMuSVFit_cfi import tauMuSVFit from CMGTools.Common.Tools.cmsswRelease import cmsswIs44X,cmsswIs52X @@ -54,7 +54,7 @@ # Correct tau pt (after MVA MET according to current baseline) -from CMGTools.Common.factories.cmgTauMuCor_cfi import cmgTauMuCor +from CMGTools.H2TauTau.objects.cmgTauMuCor_cfi import cmgTauMuCor cmgTauMuCor = cmgTauMuCor.clone() cmgTauMuCor.cfg.diObjectCollection = cms.InputTag('mvaMETTauMu') diff --git a/CMGTools/H2TauTau/python/proto/analyzers/H2TauTauTreeProducerTauEle.py b/CMGTools/H2TauTau/python/proto/analyzers/H2TauTauTreeProducerTauEle.py index 595defc114332..02da25ed1aabd 100644 --- a/CMGTools/H2TauTau/python/proto/analyzers/H2TauTauTreeProducerTauEle.py +++ b/CMGTools/H2TauTau/python/proto/analyzers/H2TauTauTreeProducerTauEle.py @@ -47,6 +47,10 @@ def declareVariables(self): var( tr, 'hqtWeightDown') var( tr, 'NJetWeight') var( tr, 'zllWeight') + + var( tr, 'tauFakeRateWeight') + var( tr, 'tauFakeRateWeightUp') + var( tr, 'tauFakeRateWeightDown') var( tr, 'nVert') @@ -129,6 +133,10 @@ def process(self, iEvent, event): fill(tr, 'hqtWeightUp', event.higgsPtWeightUp) fill(tr, 'hqtWeightDown', event.higgsPtWeightDown) + fill(tr, 'tauFakeRateWeightUp', event.tauFakeRateWeightUp) + fill(tr, 'tauFakeRateWeightDown', event.tauFakeRateWeightDown) + fill(tr, 'tauFakeRateWeight', event.tauFakeRateWeight) + if hasattr(event, 'NJetWeight'): fill(tr, 'NJetWeight', event.NJetWeight) fill(tr, 'zllWeight', event.zllWeight) @@ -142,10 +150,11 @@ def process(self, iEvent, event): fill(tr, 'leptonAccept', event.leptonAccept) fill(tr, 'thirdLeptonVeto', event.thirdLeptonVeto) - for p in event.genParticles: - if p.pdgId() in [23, 25, 35, 36, 37]: - fill(tr, 'genMass', p.mass()) - break + if hasattr(event, 'genParticles'): + for p in event.genParticles: + if p.pdgId() in [23, 25, 35, 36, 37]: + fill(tr, 'genMass', p.mass()) + break if hasattr( event, 'genZs'): if len(event.genZs): diff --git a/CMGTools/H2TauTau/python/proto/analyzers/H2TauTauTreeProducerTauMu.py b/CMGTools/H2TauTau/python/proto/analyzers/H2TauTauTreeProducerTauMu.py index 263582522447c..ac4faaafc810b 100644 --- a/CMGTools/H2TauTau/python/proto/analyzers/H2TauTauTreeProducerTauMu.py +++ b/CMGTools/H2TauTau/python/proto/analyzers/H2TauTauTreeProducerTauMu.py @@ -16,7 +16,8 @@ def declareVariables(self): var( tr, 'lumi', int) var( tr, 'evt', int) var( tr, 'NUP', int) - + var( tr, 'rho') + bookDiLepton(tr) var( tr, 'pfmet') @@ -47,6 +48,10 @@ def declareVariables(self): var( tr, 'hqtWeightUp') var( tr, 'hqtWeightDown') var( tr, 'NJetWeight') + + var( tr, 'tauFakeRateWeight') + var( tr, 'tauFakeRateWeightUp') + var( tr, 'tauFakeRateWeightDown') var( tr, 'nVert') @@ -84,6 +89,7 @@ def process(self, iEvent, event): #C uncomment when reactivating WNJetsAnalyzer if hasattr(event, 'NUP'): fill( tr, 'NUP', event.NUP) + fill( tr, 'rho', event.rho) fillDiLepton( tr, event.diLepton ) @@ -135,6 +141,12 @@ def process(self, iEvent, event): if hasattr( event, 'NJetWeight'): fill(tr, 'NJetWeight', event.NJetWeight) + fill(tr, 'tauFakeRateWeightUp', event.tauFakeRateWeightUp) + fill(tr, 'tauFakeRateWeightDown', event.tauFakeRateWeightDown) + fill(tr, 'tauFakeRateWeight', event.tauFakeRateWeight) + + + if hasattr( event, 'vertexWeight'): fill(tr, 'vertexWeight', event.vertexWeight) fill(tr, 'nVert', len(event.vertices) ) @@ -145,10 +157,12 @@ def process(self, iEvent, event): fill(tr, 'thirdLeptonVeto', event.thirdLeptonVeto) - for p in event.genParticles: - if p.pdgId() in [23, 25, 35, 36, 37]: - fill(tr, 'genMass', p.mass()) - break + + if hasattr(event, 'genParticles'): + for p in event.genParticles: + if p.pdgId() in [23, 25, 35, 36, 37]: + fill(tr, 'genMass', p.mass()) + break if hasattr( event, 'genZs'): if len(event.genZs): diff --git a/CMGTools/H2TauTau/python/proto/analyzers/TauFakeRateWeighter.py b/CMGTools/H2TauTau/python/proto/analyzers/TauFakeRateWeighter.py new file mode 100644 index 0000000000000..02d51eb66e527 --- /dev/null +++ b/CMGTools/H2TauTau/python/proto/analyzers/TauFakeRateWeighter.py @@ -0,0 +1,45 @@ +from CMGTools.RootTools.fwlite.Analyzer import Analyzer +from CMGTools.RootTools.fwlite.AutoHandle import AutoHandle +from CMGTools.RootTools.statistics.Average import Average +from CMGTools.Common.Tools.cmsswRelease import cmsswIs44X,cmsswIs52X + +class TauFakeRateWeighter( Analyzer ): + '''Gets tau decay mode efficiency weight and puts it in the event''' + + def __init__(self, cfg_ana, cfg_comp, looperName): + super(TauFakeRateWeighter,self).__init__(cfg_ana, cfg_comp, looperName) + + + def beginLoop(self): + print self, self.__class__ + super(TauFakeRateWeighter,self).beginLoop() + self.averages.add('weight', Average('weight') ) + + def process(self, iEvent, event): + self.weight = 1 + + # print 'FR weighter', self.cfg_comp.name + wNames = ['WJets', 'W1Jets', 'W2Jets', 'W3Jets','W4Jets'] + # Not strictly correct, but this is agreed upon for Summer 2013: + for name in wNames: + if self.cfg_comp.name.startswith(name): + tauPt = event.diLepton.leg1().pt() + if tauPt > 200.: + tauPt = 200. + + self.weight = 1.15743 + (-0.00736136) * tauPt + (4.3699e-05) * tauPt * tauPt + (-1.188e-07) * tauPt * tauPt * tauPt + + # print 'W sample, weight:', self.weight + + event.tauFakeRateWeightUp = self.weight + 0.5 * (1. - self.weight) + event.tauFakeRateWeightDown = self.weight - 0.5 * (1. - self.weight) + + event.eventWeight *= self.weight + event.tauFakeRateWeight = self.weight + + if self.cfg_ana.verbose: + print 'TauFakeRateWeighter', event.diLepton.leg1().pt(), self.cfg_comp.name, self.weight + + self.averages['weight'].add( self.weight ) + return True + diff --git a/CMGTools/H2TauTau/python/proto/analyzers/ntuple.py b/CMGTools/H2TauTau/python/proto/analyzers/ntuple.py index b9e2531d8ae25..f97d8a4bae135 100644 --- a/CMGTools/H2TauTau/python/proto/analyzers/ntuple.py +++ b/CMGTools/H2TauTau/python/proto/analyzers/ntuple.py @@ -248,6 +248,8 @@ def bookJet( tree, pName ): var(tree, '{pName}_puMvaSimple'.format(pName=pName)) var(tree, '{pName}_puMvaCutBased'.format(pName=pName)) var(tree, '{pName}_looseJetId'.format(pName=pName)) + var(tree, '{pName}_btagMVA'.format(pName=pName)) + var(tree, '{pName}_area'.format(pName=pName)) var(tree, '{pName}_genJetPt'.format(pName=pName)) def fillJet( tree, pName, jet ): @@ -257,6 +259,8 @@ def fillJet( tree, pName, jet ): fill(tree, '{pName}_puMvaSimple'.format(pName=pName), jet.puMva('simple')) fill(tree, '{pName}_puMvaCutBased'.format(pName=pName), jet.puMva('cut-based')) fill(tree, '{pName}_looseJetId'.format(pName=pName), jet.looseJetId()) + fill(tree, '{pName}_btagMVA'.format(pName=pName), jet.btagMVA) + fill(tree, '{pName}_area'.format(pName=pName), jet.jetArea()) if hasattr(jet, 'genJet') and jet.genJet: fill(tree, '{pName}_genJetPt'.format(pName=pName), jet.genJet.pt()) diff --git a/CMGTools/H2TauTau/python/proto/plotter/H2TauTauDataMC.py b/CMGTools/H2TauTau/python/proto/plotter/H2TauTauDataMC.py index 96af3a7a331fb..fa35c79adcaf1 100644 --- a/CMGTools/H2TauTau/python/proto/plotter/H2TauTauDataMC.py +++ b/CMGTools/H2TauTau/python/proto/plotter/H2TauTauDataMC.py @@ -95,37 +95,9 @@ def _BuildHistogram(self, tfile, comp, compName, varName, cut, layer ): if varName == 'visMass' or varName == 'svfitMass': print 'Shifting visMass and svfitMass by sqrt(0.97) for', comp.name var = varName + '* sqrt(0.97)' - else: - raise ValueError( self.shift + ' is not recognized. Use None, "Up" or "Down".') - - - if varName == 'abs_l1_eta_l2_eta': - var = 'abs(l1_eta-l2_eta)' - elif varName == 'abs_l1_eta_j1_eta': - var = 'abs(l1_eta-jet1_eta)' - elif varName == 'abs_l2_eta_j1_eta': - var = 'abs(l2_eta-jet1_eta)' - elif varName == 'deltaPhi_l1_l2': - var = 'abs((l1_phi - l2_phi > TMath::Pi()) * (l1_phi - l2_phi - 2 * TMath::Pi()) + (l1_phi - l2_phi < - TMath::Pi()) * (l1_phi - l2_phi + 2 * TMath::Pi()) + (abs(l1_phi - l2_phi) <= TMath::Pi()) * (l1_phi - l2_phi))' - elif varName == 'deltaPhi_l1_j1': - var = 'abs((l1_phi - jet1_phi > TMath::Pi()) * (l1_phi - jet1_phi - 2 * TMath::Pi()) + (l1_phi - jet1_phi < - TMath::Pi()) * (l1_phi - jet1_phi + 2 * TMath::Pi()) + (abs(l1_phi - jet1_phi) <= TMath::Pi()) * (l1_phi - jet1_phi))' - elif varName == 'deltaPhi_l2_j1': - var = 'abs((l2_phi - jet1_phi > TMath::Pi()) * (l2_phi - jet1_phi - 2 * TMath::Pi()) + (l2_phi - jet1_phi < - TMath::Pi()) * (l2_phi - jet1_phi + 2 * TMath::Pi()) + (abs(l2_phi - jet1_phi) <= TMath::Pi()) * (l2_phi - jet1_phi))' - - # hack to account for the shift determined for HCP, see: - # https://indico.cern.ch/getFile.py/access?contribId=38&resId=0&materialId=slides&confId=212612 + # else: + # raise ValueError( self.shift + ' is not recognized. Use None, "Up" or "Down".') - # FIXME - no correction as of now (summer13) - # if isNewerThan('CMSSW_5_2_0'): - # # Andrew doesn't do the shift in 2011. - # if compName == 'Ztt_ZL' and self.treeName.find('TauEle') != -1: - # if varName == 'visMass' or varName == 'svfitMass': - # print 'Shifting visMass and svfitMass by 1.015 for', compName - # var = varName + '* 1.015' -## else: -## if compName == 'Ztt_ZL': -## weight = weight + '/zllWeight' -## weight = weight + '*((l1_decayMode==1)*1.3 + (l1_decayMode!=1)*1.0)' tree.Project( histName, var, '{weight}*({cut})'.format(cut=cut, weight=weight) ) diff --git a/CMGTools/H2TauTau/python/proto/plotter/binning.py b/CMGTools/H2TauTau/python/proto/plotter/binning.py index 260d7a2ccd63d..c38ed64084240 100644 --- a/CMGTools/H2TauTau/python/proto/plotter/binning.py +++ b/CMGTools/H2TauTau/python/proto/plotter/binning.py @@ -11,6 +11,15 @@ binning_svfitMass_mssm = array([0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., 130., 140., 150., 160., 170., 180., 190., 200., 225., 250., 275., 300., 325., 350., 400., 450., 500., 550., 600., 650., 700., 750., 800., 850., 900., 950., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1800., 2000.]) binning_svfitMass_finer_mssm = array([0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., 130., 140., 150., 160., 170., 180., 190., 200., 225., 250., 275., 300., 325., 350., 400., 450., 500., 550., 600., 650., 700., 750., 800., 850., 900., 950., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1800., 2000.]) +# Binning for l+tau +binning_svfitMass_mssm = array([0., 20., 40., 60., 80., 100., 120., 140., 160., 180., 200., 250., 300., 350., 400., 500., 700., 1000., 1500.]) +binning_svfitMass_mssm_nobtag = array([0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., 130., 140., 150., 160., 170., 180., 190., 200., 225., 250., 275., 300., 325., 350., 400., 500., 700., 1000., 1500]) + +binning_svfitMass_finer_mssm = array([0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., 130., 140., 150., 160., 170., 180., 190., 200., 225., 250., 275., 300., 325., 350., 400., 500., 700., 1000., 1500.]) +binning_svfitMass_mssm2013 = array([0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., 130., 140., 150., 160., 170., 180., 190., 200., 225., 250., 275., 300., 325., 350., 400., 450., 500., 550., 600., 650., 700., 750., 800., 850., 900., 950., 1000., 1100., 1200., 1300., 1400., 1500., 1600., 1800., 2000.]) + + + ## DATACARD SYNCH # binning_svfitMass_mssm = array([0., 20., 40., 60., 80., 100., 120., 140., 160., 180., 200., 250., 300., 350., 400.]) # binning_svfitMass_finer_mssm = array([0., 10., 20., 30., 40., 50., 60., 70., 80., 90., 100., 110., 120., 130., 140., 150., 160., 170., 180., 190., 200., 225., 250., 275., 300., 325., 350., 400.]) diff --git a/CMGTools/H2TauTau/python/proto/plotter/categories_TauEle.py b/CMGTools/H2TauTau/python/proto/plotter/categories_TauEle.py index 1bfdceb08e85e..51533c1f7b1ec 100644 --- a/CMGTools/H2TauTau/python/proto/plotter/categories_TauEle.py +++ b/CMGTools/H2TauTau/python/proto/plotter/categories_TauEle.py @@ -6,7 +6,7 @@ from CMGTools.Common.Tools.cmsswRelease import cmsswIs44X,cmsswIs52X from CMGTools.Common.Tools.cmsswRelease import isNewerThan -pt1 = 20 +pt1 = 30 pt2 = 20 # 2011 if isNewerThan('CMSSW_5_2_0'): pt2 = 24 #2012 diff --git a/CMGTools/H2TauTau/python/proto/plotter/categories_TauMu.py b/CMGTools/H2TauTau/python/proto/plotter/categories_TauMu.py index 2653a1da64bd2..202c89612fae0 100644 --- a/CMGTools/H2TauTau/python/proto/plotter/categories_TauMu.py +++ b/CMGTools/H2TauTau/python/proto/plotter/categories_TauMu.py @@ -5,7 +5,7 @@ from CMGTools.Common.Tools.cmsswRelease import cmsswIs44X,cmsswIs52X -pt1 = 20 +pt1 = 30 pt2 = 17 # 2011 if cmsswIs52X(): pt2 = 20 # 2012, check that @@ -55,8 +55,9 @@ def cutstr_rlxtaumuiso(cutstr, tauIsoCut, muIsoCut): cat_Inc_AntiMuAntiTauIsoJan = str(inc_sig).replace('l2_relIso05<0.1','l2_relIso05>0.2 && l2_relIso05<0.5').replace('l1_threeHitIso<1.5', 'l1_threeHitIso>1.5 && l1_threeHitIso<10.0') cat_Inc_AntiMuRlxTauIsoJan = str(inc_sig).replace('l2_relIso05<0.1','l2_relIso05>0.2 && l2_relIso05<0.5').replace('l1_threeHitIso<1.5', 'l1_threeHitIso<10.0') #cat_Inc_AntiTauIso = str(inc_sig).replace('l1_looseMvaIso>0.5', 'l1_looseMvaIso<0.5') -cat_Inc_AntiTauIso = str(inc_sig).replace('l1_threeHitIso<1.5', 'l1_threeHitIso>1.5') # && l1_threeHitIso<10.0') +# cat_Inc_AntiTauIso = str(inc_sig).replace('l1_threeHitIso<1.5', 'l1_threeHitIso>1.5') # && l1_threeHitIso<10.0') cat_Inc_AntiTauIsoJan = str(inc_sig).replace('l1_threeHitIso<1.5', 'l1_threeHitIso>1.5 && l1_threeHitIso<10.0') +cat_Inc_AntiTauIso = str(inc_sig).replace('l1_threeHitIso<1.5', 'l1_threeHitIso>1.5 && l1_threeHitIso<5.0') cat_Inc_RlxMuTauIso_b = str(inc_sig).replace('l2_relIso05<0.1','l2_relIso05<0.5').replace('l1_looseMvaIso>0.5', 'l1_rawMvaIso>0.5') cat_Inc = str(inc_sig) diff --git a/CMGTools/H2TauTau/python/proto/plotter/categories_common.py b/CMGTools/H2TauTau/python/proto/plotter/categories_common.py index db179bb5f40d2..7c8cccfc265ef 100644 --- a/CMGTools/H2TauTau/python/proto/plotter/categories_common.py +++ b/CMGTools/H2TauTau/python/proto/plotter/categories_common.py @@ -33,8 +33,9 @@ cat_J0_oldlow = cat_J0 + ' && l1_pt<=40.' cat_J0_oldhigh = cat_J0 + ' && l1_pt>40.' -cat_VBF_tight = 'nJets>=2 && nBJets==0 && VBF_nCentral==0 && VBF_mjj>700 && abs(VBF_deta)>4. && pthiggs>100.' -cat_VBF_loose = cat_VBF + '&& nBJets==0 && !({VBF_tight})'.format(VBF_tight=cat_VBF_tight) +cat_VBF_tight = 'nJets>=2 && l1_pt>30. && nBJets==0 && VBF_nCentral==0 && VBF_mjj>700 && abs(VBF_deta)>4. && pthiggs>100.' +cat_VBF_loose = cat_VBF + ' && l1_pt>30. && nBJets==0 && !({VBF_tight})'.format(VBF_tight=cat_VBF_tight) +cat_J2B0 = 'nJets>=2 && l1_pt>30. && nBJets==0' def replaceCategories(cutstr, categories): for catname, cat in categories.iteritems(): @@ -46,6 +47,7 @@ def replaceCategories(cutstr, categories): 'Xcat_VBF_Rel_30X':cat_VBF_Rel_30, 'Xcat_VBF_Rel_20X':cat_VBF_Rel_20, 'Xcat_J2X':cat_J2, + 'Xcat_J2B0X':cat_J2B0, 'Xcat_J1X':cat_J1, 'Xcat_J1BX':cat_J1B, 'Xcat_J0X':cat_J0, diff --git a/CMGTools/H2TauTau/python/proto/plotter/datacards.py b/CMGTools/H2TauTau/python/proto/plotter/datacards.py index 0d5920986f885..b42bbf497ef6c 100644 --- a/CMGTools/H2TauTau/python/proto/plotter/datacards.py +++ b/CMGTools/H2TauTau/python/proto/plotter/datacards.py @@ -188,6 +188,9 @@ def datacards(plot, cutstring, shift, channel='muTau', prefix=None, energy='8TeV continue else: if 'SUSY' in myName: continue + + if shift and 'WShape' in shift and not 'WJets' in myName: + continue rogerName = datacards_aliases.get(myName, None) if 'btag' in category and rogerName: diff --git a/CMGTools/H2TauTau/python/proto/plotter/plotinfo.py b/CMGTools/H2TauTau/python/proto/plotter/plotinfo.py index 1e6cf6d33f9f0..6800868388377 100644 --- a/CMGTools/H2TauTau/python/proto/plotter/plotinfo.py +++ b/CMGTools/H2TauTau/python/proto/plotter/plotinfo.py @@ -11,17 +11,17 @@ def __init__(self, var, nbins, xmin, xmax): plots_All = { - 'l2_pt': PlotInfo('l2_pt', 100, 0, 200), + 'l2_pt': PlotInfo('l2_pt', 20, 0, 200), 'l2_eta': PlotInfo('l2_eta', 50, -3, 3), 'l2_relIso05': PlotInfo('l2_relIso05', 50, 0, 0.5), 'l2_charge': PlotInfo('l2_charge', 3, -1.5, 1.5), - 'l1_pt': PlotInfo('l1_pt', 100, 0, 200), + 'l1_pt': PlotInfo('l1_pt', 20, 0, 200), 'l1_eta': PlotInfo('l1_eta', 50, -3, 3), 'l1_charge': PlotInfo('l1_charge', 3, -1.5, 1.5), - 'l1_threeHitIso': PlotInfo('l1_threeHitIso', 50, 0., 10.), + 'l1_threeHitIso': PlotInfo('l1_threeHitIso', 25, 0., 10.), 'l1_decayMode':PlotInfo('l1_decayMode', 15, -0.5, 14.5), 'l1_mass':PlotInfo('l1_mass', 30, 0., 2.), - 'mt': PlotInfo('mt', 50, 0, 150), + 'mt': PlotInfo('mt', 10, 0, 150), 'visMass': PlotInfo('visMass', 50, 0, 200), 'svfitMass': PlotInfo('svfitMass', 50, 0, 300), 'svfitMassFewerBins': PlotInfo('svfitMass', 30, 0, 300), @@ -37,8 +37,8 @@ def __init__(self, var, nbins, xmin, xmax): 'pthiggs': PlotInfo('pthiggs', 50, 0., 150.), 'deltaEtaL1L2': PlotInfo('deltaEtaL1L2', 20, 0., 5.), 'deltaRL1L2': PlotInfo('deltaRL1L2', 20, 0., 5.), - 'abs_l1_eta_j1_eta': PlotInfo('abs_l1_eta_j1_eta', 20, 0., 5.), - 'abs_l2_eta_j1_eta': PlotInfo('abs_l2_eta_j1_eta', 20, 0., 5.), + #'abs_l1_eta_j1_eta': PlotInfo('abs_l1_eta_j1_eta', 20, 0., 5.), + #'abs_l2_eta_j1_eta': PlotInfo('abs_l2_eta_j1_eta', 20, 0., 5.), 'deltaPhiL1L2' : PlotInfo('deltaPhiL1L2', 25, -3.141593, 3.141593), 'deltaPhiL1LMET' : @@ -47,12 +47,12 @@ def __init__(self, var, nbins, xmin, xmax): PlotInfo('deltaPhiL2MET', 25, -3.141593, 3.141593), 'deltaRL1L2' : PlotInfo('deltaRL1L2', 25, 0., 5.), - 'deltaPhi_l1_j1' : - PlotInfo('deltaPhi_l1_j1', 25, 0., 3.141593), + # 'deltaPhi_l1_j1' : + # PlotInfo('deltaPhi_l1_j1', 25, 0., 3.141593), # 'deltaPhi_j1_met' : # PlotInfo('deltaPhi_j1_met', 25, 0., 3.141593), - 'deltaPhi_l2_j1' : - PlotInfo('deltaPhi_l2_j1', 25, 0., 3.141593), + # 'deltaPhi_l2_j1' : + # PlotInfo('deltaPhi_l2_j1', 25, 0., 3.141593), 'jet1_pt': PlotInfo('jet1_pt', 30, 0, 300), 'bjet1_pt': PlotInfo('bjet1_pt', 30, 0, 300), @@ -83,14 +83,15 @@ def __init__(self, var, nbins, xmin, xmax): 'nVert', 'deltaEtaL1L2', 'deltaRL1L2', - 'abs_l1_eta_j1_eta', - 'abs_l2_eta_j1_eta', + #'abs_l1_eta_j1_eta', + #'abs_l2_eta_j1_eta', 'deltaPhiL1L2' , 'deltaPhiL1LMET', 'deltaPhiL2LMET' , 'deltaRL1L2' , - 'deltaPhi_l1_j1', - 'deltaPhi_l2_j1',] + # 'deltaPhi_l1_j1', + # 'deltaPhi_l2_j1', + ] plots_J0 = { 'l2_pt': PlotInfo('l2_pt', 100, 0, 200), diff --git a/CMGTools/H2TauTau/python/proto/plotter/plotmod.py b/CMGTools/H2TauTau/python/proto/plotter/plotmod.py index ca48fab284d33..8f4dbee7937c0 100644 --- a/CMGTools/H2TauTau/python/proto/plotter/plotmod.py +++ b/CMGTools/H2TauTau/python/proto/plotter/plotmod.py @@ -121,6 +121,7 @@ def fW(mtplot, dataName, xmin, xmax, VVgroup=None, channel = 'TauMu'): wjet = copy.deepcopy(mtplot.Hist(dataName)) oldIntegral = wjet.Integral(True, xmin, xmax) + error_data = math.sqrt(oldIntegral) wjet.Add(mtplot.Hist('Ztt'), -1) wjet.Add(mtplot.Hist('Ztt_ZL'), -1) wjet.Add(mtplot.Hist('Ztt_ZJ'), -1) @@ -131,9 +132,37 @@ def fW(mtplot, dataName, xmin, xmax, VVgroup=None, channel = 'TauMu'): subtrIntegral = wjet.Integral(True, xmin, xmax) + print 'Subtracted BG', oldIntegral - subtrIntegral + relSysError = 0.1 * (oldIntegral - subtrIntegral)/subtrIntegral print 'W+Jets, high MT: Relative error due to BG subtraction', relSysError + relSysError = 0.05 * mtplot.Hist('Ztt').Integral(True, xmin, xmax) + + # print 'Error due to Ztt subtraction', relSysError/subtrIntegral + + relSysError = math.sqrt(relSysError**2 + 0.05*0.05*(mtplot.Hist('Ztt_ZJ').Integral(True, xmin, xmax)**2)) + + # print 'Plus ZJ subtraction', relSysError/subtrIntegral + + relSysError = math.sqrt(relSysError**2 + 0.2*0.2*(mtplot.Hist('Ztt_ZL').Integral(True, xmin, xmax)**2)) + + # print 'Plus ZL subtraction', relSysError/subtrIntegral + + relSysError = math.sqrt(relSysError**2 + 0.2*0.2*(mtplot.Hist('Ztt_TL').Integral(True, xmin, xmax)**2)) + + # print 'Plus TL subtraction', relSysError/subtrIntegral + + relSysError = math.sqrt(relSysError**2 + 0.1*0.1 * (mtplot.Hist('TTJets').Integral(True, xmin, xmax)**2)) + # print 'Plus TT subtraction', relSysError/subtrIntegral + if VVgroup: + relSysError = math.sqrt(relSysError**2 + 0.3*0.3*mtplot.Hist('VV').Integral(True, xmin, xmax)**2) + # print 'Plus VV subtraction', relSysError/subtrIntegral + print 'W+Jets, high MT: Absolute error due to BG subtraction with smaller DY uncertainties', relSysError + relSysError = relSysError/subtrIntegral + print 'W+Jets, high MT: Relative error due to BG subtraction with smaller DY uncertainties', relSysError + # print 'W+Jets, high MT: Contribution from ttbar', 0.1*mtplot.Hist('TTJets').Integral(True, xmin, xmax)/subtrIntegral + mtplot.AddHistogram( 'Data-DY-TT-VV', wjet.weighted, 1010) mtplot.Hist('Data-DY-TT-VV').stack = False # with a nice pink color @@ -143,9 +172,9 @@ def fW(mtplot, dataName, xmin, xmax, VVgroup=None, channel = 'TauMu'): data_integral = mtplot.Hist('Data-DY-TT-VV').Integral(True, xmin, xmax) - error_data = Double(0.) + error_tmp = Double(0.) error_mc = Double(0.) - data_integral_jan = mtplot.Hist('Data-DY-TT-VV').weighted.IntegralAndError(mtplot.Hist('Data-DY-TT-VV').weighted.FindFixBin(xmin), mtplot.Hist('Data-DY-TT-VV').weighted.FindFixBin(xmax)-1, error_data) + data_integral_jan = mtplot.Hist('Data-DY-TT-VV').weighted.IntegralAndError(mtplot.Hist('Data-DY-TT-VV').weighted.FindFixBin(xmin), mtplot.Hist('Data-DY-TT-VV').weighted.FindFixBin(xmax)-1, error_tmp) if data_integral_jan != data_integral: print 'WARNING, not the same integral in w+jets estimation' @@ -183,12 +212,13 @@ def w_lowHighMTRatio( var, anaDir, print mt.weighted.FindBin(lowMTMax)-1, mt.weighted.FindBin(highMTMin), mt.weighted.FindBin(highMTMax) - print 'MT ratio', mt_ratio, '+-', math.sqrt(error_low**2/mt_low**2 + error_high**2/mt_high**2) * mt_ratio - # print 'MT ratio', mt_low_jan/mt_high_jan, '+-', math.sqrt(error_low**2/mt_low**2 + error_high**2/mt_high**2) * mt_ratio - print 'Integrals: low', mt_low, '+-', error_low, 'high', mt_high, '+-', error_high - # print 'Integrals: low', mt_low_jan, '+-', error_low, 'high', mt_high_jan, '+-', error_high - print 'Relative errors: low', error_low/mt_low, 'high', error_high/mt_high - print 'TOTAL RELATIVE ERROR:', math.sqrt(error_low**2/mt_low**2 + error_high**2/mt_high**2), '\n' + if mt_high > 0. and mt_low > 0.: + print 'MT ratio', mt_ratio, '+-', math.sqrt(error_low**2/mt_low**2 + error_high**2/mt_high**2) * mt_ratio + # print 'MT ratio', mt_low_jan/mt_high_jan, '+-', math.sqrt(error_low**2/mt_low**2 + error_high**2/mt_high**2) * mt_ratio + print 'Integrals: low', mt_low, '+-', error_low, 'high', mt_high, '+-', error_high + # print 'Integrals: low', mt_low_jan, '+-', error_low, 'high', mt_high_jan, '+-', error_high + print 'Relative errors: low', error_low/mt_low, 'high', error_high/mt_high + print 'TOTAL RELATIVE ERROR:', math.sqrt(error_low**2/mt_low**2 + error_high**2/mt_high**2), '\n' return mt_ratio @@ -241,7 +271,8 @@ def plot_W(anaDir, comps, weights, print 'W SCALE FACTOR SS:' data_SS, mc_SS = fW( mtSS, 'Data', xmin, xmax, VVgroup) - fW_SS = data_SS / mc_SS + + fW_SS = data_SS / mc_SS if mc_SS else -1. print 'fW_SS=',fW_SS,'fW_OS=',fW_OS diff --git a/CMGTools/H2TauTau/python/proto/plotter/rootutils.py b/CMGTools/H2TauTau/python/proto/plotter/rootutils.py index 0f713888e4604..cba52b3f6b82d 100644 --- a/CMGTools/H2TauTau/python/proto/plotter/rootutils.py +++ b/CMGTools/H2TauTau/python/proto/plotter/rootutils.py @@ -174,20 +174,21 @@ def CMSPrelim(plot, pad, channel ): keeper = [] -def draw(plot, doBlind=True, channel='TauMu', plotprefix = None, SetLogy = 0): +def draw(plot, doBlind=True, channel='TauMu', plotprefix = None, SetLogy = 0, mssm=False): print plot Stack.STAT_ERRORS = True blindxmin = None blindxmax = None - doBlind = (plot.varName == 'svfitMass' or plot.varName == 'visMass') and doBlind if doBlind: - blindxmin = 100 - blindxmax = 160 - if hasattr(plot, 'blindxmin'): - blindxmin = plot.blindxmin - if hasattr(plot, 'blindxmax'): - blindxmax = plot.blindxmax - plot.Blind(blindxmin, blindxmax, False) + if plot.varName == 'svfitMass': + blindxmin = 100 + if mssm: + blindxmax = 1000. + else: + blindxmax = 160 + elif plot.varName == 'visMass': + blindxmin = 70 + blindxmax = 100 titles = xtitles if channel=='TauEle': titles = xtitles_TauEle @@ -202,8 +203,8 @@ def draw(plot, doBlind=True, channel='TauMu', plotprefix = None, SetLogy = 0): pad.SetLogy (SetLogy) plot.DrawStack('HIST') h = plot.supportHist - h.GetXaxis().SetLabelColor(0) - h.GetXaxis().SetLabelSize(0) + h.GetXaxis().SetLabelColor(1) + h.GetXaxis().SetLabelSize(1) gevperbin = h.GetXaxis().GetBinWidth(1) h.GetYaxis().SetTitle('Events') h.GetYaxis().SetTitleOffset(1.4) @@ -212,27 +213,26 @@ def draw(plot, doBlind=True, channel='TauMu', plotprefix = None, SetLogy = 0): ratio.legendOn = False if doBlind: ratio.Blind(blindxmin, blindxmax, True) - ratio.DrawRatioStack('HIST', ymin=0.4, ymax=1.6) - hr = ratio.stack.totalHist - plot.ratioTotalHist = hr - # hr.weighted.Fit('pol1') + plot.Blind(blindxmin, blindxmax, False) + ratio.DrawDataOverMCMinus1(-0.2, 0.2) + hr = ratio.dataOverMCHist hr.GetYaxis().SetNdivisions(4) - hr.GetYaxis().SetTitle('Exp./Obs.') hr.GetYaxis().SetTitleSize(0.1) - hr.GetYaxis().SetTitleOffset(0.5) + hr.GetYaxis().SetTitleOffset(0.7) hr.GetXaxis().SetTitle('{xtitle}'.format(xtitle=xtitle)) hr.GetXaxis().SetTitleSize(0.13) hr.GetXaxis().SetTitleOffset(0.9) - rls = 0.075 + rls = 0.1 hr.GetYaxis().SetLabelSize(rls) hr.GetXaxis().SetLabelSize(rls) - hr.GetYaxis().SetRangeUser(0.5, 1.5) + h.GetXaxis().SetLabelColor(0) + h.GetXaxis().SetLabelSize(0) padr.Update() # blinding - if plot.blindminx: + if doBlind: pad.cd() max = plot.stack.totalHist.GetMaximum() - box = TBox( plot.blindminx, 0, plot.blindmaxx, max ) + box = TBox( blindxmin, 0, blindxmax, max ) box.SetFillColor(1) box.SetFillStyle(3004) box.Draw() @@ -246,6 +246,7 @@ def draw(plot, doBlind=True, channel='TauMu', plotprefix = None, SetLogy = 0): else : plotname = plotprefix + '_' + plot.varName can.SaveAs( plotname + '.png') pad.SetLogy (0) + return ratio def buildCanvasOfficial(): @@ -263,10 +264,17 @@ def drawOfficial(plot, doBlind=False, channel='TauMu', plotprefix = None, ymin = Stack.STAT_ERRORS = False blindxmin = None blindxmax = None - doBlind = (plot.varName == 'svfitMass') and doBlind if doBlind: - blindxmin = 100 - blindxmax = 160 + if plot.varName == 'svfitMass': + blindxmin = 100 + if mssm: + blindxmax = 1000. + else: + blindxmax = 160 + elif plot.varName == 'visMass': + blindxmin = 70 + blindxmax = 90 + plot.Blind(blindxmin, blindxmax, False) titles = xtitles if channel=='TauEle': diff --git a/CMGTools/H2TauTau/python/proto/samples/run2012/data.py b/CMGTools/H2TauTau/python/proto/samples/run2012/data.py index 78bd7a2eb953d..3799950fe4a30 100644 --- a/CMGTools/H2TauTau/python/proto/samples/run2012/data.py +++ b/CMGTools/H2TauTau/python/proto/samples/run2012/data.py @@ -5,15 +5,16 @@ data_Run2012A = cfg.DataComponent( name = 'data_Run2012A', files = [], - intLumi = 96.404 + 396.906 + 395.991, #double-checked with Jose + # intLumi = 96.404 + 396.906 + 395.991, # old lumi + intLumi = 94.676 + 390.113 + 391.376, # pixel lumi triggers = [], json = None ) data_Run2012B = cfg.DataComponent( name = 'data_Run2012B', files = [], - # intLumi = 4403., # FIXME: x-check running - intLumi = 4429., + # intLumi = 4429., # old lumi + intLumi = 4411., # pixel lumi triggers = [], json = None ) @@ -22,7 +23,8 @@ data_Run2012C = cfg.DataComponent( name = 'data_Run2012C', files = [], - intLumi = 1783. + 5087. + 282.692, #double-checked with Jose + # intLumi = 1783. + 5087. + 282.692, # old lumi + intLumi = 1734. + 5041. + 279.843, # pixel lumi triggers = [], json = None ) @@ -30,7 +32,8 @@ data_Run2012D = cfg.DataComponent( name = 'data_Run2012D', files = [], - intLumi = 7318., #double-checked with Jose + # intLumi = 7318., # old lumi + intLumi = 7369., # pixel lumi triggers = [], ) @@ -41,6 +44,8 @@ data_Run2012D, ] +# Replace lumiCalc2.py by pixelLumiCalc.py below for pixel lumi +# # # 2012 D # # lumiCalc2.py --begin 203777 --end 208687 -i $Json2012 recorded --hltpath HLT_IsoMu17_eta2p1_LooseIsoPFTau20_* | grep HLT_IsoMu17_eta2p1_LooseIsoPFTau20 diff --git a/CMGTools/H2TauTau/python/proto/samples/run2012/tauMu_MuRm_ColinJun19.py b/CMGTools/H2TauTau/python/proto/samples/run2012/tauMu_MuRm_ColinJun19.py index 361525af3d593..4d58011996714 100644 --- a/CMGTools/H2TauTau/python/proto/samples/run2012/tauMu_MuRm_ColinJun19.py +++ b/CMGTools/H2TauTau/python/proto/samples/run2012/tauMu_MuRm_ColinJun19.py @@ -14,7 +14,7 @@ from CMGTools.H2TauTau.proto.samples.run2012.triggers_tauMu import data_triggers, mc_triggers aliases = { - + # '/WJets.*START53.*NewRecoil.*':'WJets', '/DYJets.*START53.*NewRecoil.*':'DYJets', '/DY1Jets.*START53.*NewRecoil.*':'DY1Jets', '/DY2Jets.*START53.*NewRecoil.*':'DY2Jets', @@ -24,8 +24,8 @@ '/TauPlusX/Run2012A-22Jan2013-v1.*':'data_Run2012A', '/TauPlusX/Run2012B-22Jan2013-v1.*':'data_Run2012B', - '/TauPlusX/Run2012C-22Jan2013-v1.*':'data_Run2012C_v2', - '/TauPlusX/Run2012D-22Jan2013-v1.*':'data_Run2012D_v1', + '/TauPlusX/Run2012C-22Jan2013-v1.*':'data_Run2012C', + '/TauPlusX/Run2012D-22Jan2013-v1.*':'data_Run2012D', } @@ -38,8 +38,10 @@ allsamples.extend( embed_list ) -connect( allsamples, '/DY%Jets%TAUMU_MuRm_%Colin_%Jun13', 'tauMu.*root', aliases, cache=True, verbose=False) +connect( allsamples, '%TAUMU_MuRm_%Colin_%Jun13', 'tauMu.*root', aliases, cache=True, verbose=False) +connect( [WJets], '%TAUMU_NewRecoil_RelTauIso_Colin_1Jul13', 'tauMu.*root', + {'/WJets.*START53.*NewRecoil.*':'WJets'}, cache=True, verbose=False) dy_nevents = [ DYJets.nGenEvents, DY1Jets.nGenEvents, @@ -73,4 +75,3 @@ for c in allsamples: c.splitFactor = splitFactor(c, 5e4) - diff --git a/CMGTools/H2TauTau/python/proto/samples/run2012/tauMu_MuRm_ColinSep13.py b/CMGTools/H2TauTau/python/proto/samples/run2012/tauMu_MuRm_ColinSep13.py new file mode 100644 index 0000000000000..1672a9e8d1507 --- /dev/null +++ b/CMGTools/H2TauTau/python/proto/samples/run2012/tauMu_MuRm_ColinSep13.py @@ -0,0 +1,138 @@ +import itertools +from CMGTools.RootTools.fwlite.Config import printComps +from CMGTools.H2TauTau.proto.samples.connect import connect +from CMGTools.H2TauTau.proto.samples.splitFactor import splitFactor +from CMGTools.RootTools.json.jsonPick import jsonPick +from CMGTools.H2TauTau.officialJSONS import jsonMap + +from CMGTools.H2TauTau.proto.samples.run2012.data import * +from CMGTools.H2TauTau.proto.samples.run2012.embed import * +from CMGTools.H2TauTau.proto.samples.run2012.ewk import * +from CMGTools.H2TauTau.proto.samples.run2012.diboson import * +from CMGTools.H2TauTau.proto.samples.run2012.higgs import * +from CMGTools.H2TauTau.proto.samples.run2012.higgs_susy import * + +from CMGTools.H2TauTau.proto.samples.run2012.triggers_tauMu import data_triggers, mc_triggers, embed_triggers + +aliases = { + '/VBF_HToTauTau.*START53.*':'HiggsVBF', + '/VBFHToTauTau.*START53.*':'HiggsVBF', + '/GluGluToHToTauTau.*START53.*':'HiggsGGH', + '/WH_ZH_TTH_HToTauTau.*START53.*':'HiggsVH', + '/SUSYBB.*START53.*':'HiggsSUSYBB', + '/SUSYGluGluTo.*START53.*':'HiggsSUSYGluGlu', + '/DYJets.*START53.*':'DYJets', + '/DY1JetsToLL_M-50_TuneZ2Star_8TeV-madgraph.*START53.*':'DY1Jets', + '/DY2JetsToLL_M-50_TuneZ2Star_8TeV-madgraph.*START53.*':'DY2Jets', + '/DY3JetsToLL_M-50_TuneZ2Star_8TeV-madgraph.*START53.*':'DY3Jets', + '/DY4JetsToLL_M-50_TuneZ2Star_8TeV-madgraph.*START53.*':'DY4Jets', + # '/WJetsToLNu_TuneZ2Star_8TeV-madgraph-tarball/Summer12-PU_S7_START53_V9-v1.*':'WJets', + '/WJets.*START53_V7.*':'WJets', + '/W1Jets.*START53_V7.*':'W1Jets', + '/W2Jets.*START53_V7.*':'W2Jets', + '/W3Jets.*START53_V7.*':'W3Jets', + '/W4Jets.*START53_V7.*':'W4Jets', + '/W1Jets.*START53_V19.*':'W1Jets_ext', + '/W2Jets.*START53_V19.*':'W2Jets_ext', + '/W3Jets.*START53_V19.*':'W3Jets_ext', + '/TTJets_MassiveBinDECAY_TuneZ2star_8TeV.*START53.*':'TTJets', + '/TTJets_FullLeptMGDecays_8TeV.*START53.*':'TTJetsFullLept', + '/TTJets_SemiLeptMGDecays_8TeV.*START53.*':'TTJetsSemiLept', + '/TTJets_HadronicMGDecays_8TeV.*START53.*':'TTJetsHadronic', + '/TauPlusX/Run2012A-22Jan2013-v1.*':'data_Run2012A', + '/TauPlusX/Run2012B-22Jan2013-v1.*':'data_Run2012B', + '/TauPlusX/Run2012C-22Jan2013-v1.*':'data_Run2012C', + '/TauPlusX/Run2012D-22Jan2013-v1.*':'data_Run2012D', + '/T_tW-channel.*START53.*':'T_tW', + '/Tbar_tW-channel.*START53.*':'Tbar_tW', + '/WWJetsTo2L2Nu.*START53.*':'WWJetsTo2L2Nu', + '/WZJetsTo2L2Q.*START53.*':'WZJetsTo2L2Q', + '/WZJetsTo3LNu.*START53.*':'WZJetsTo3LNu', + '/WW_TuneZ2star.*START53.*':'WW', + '/WZ_TuneZ2star.*START53.*':'WZ', + '/ZZ_TuneZ2star.*START53.*':'ZZ', + '/ZZJetsTo2L2Nu.*START53.*':'ZZJetsTo2L2Nu', + '/ZZJetsTo2L2Q.*START53.*':'ZZJetsTo2L2Q', + '/ZZJetsTo4L.*START53.*':'ZZJetsTo4L', + '/DoubleMu/StoreResults-Run2012A_22Jan2013_v1_PFembedded_trans1_tau116_ptmu1_16had1_18_v1.*':'embed_Run2012A_22Jan', + '/DoubleMuParked/StoreResults-Run2012B_22Jan2013_v1_PFembedded_trans1_tau116_ptmu1_16had1_18_v1.*':'embed_Run2012B_22Jan', + '/DoubleMuParked/StoreResults-Run2012C_22Jan2013_v1_PFembedded_trans1_tau116_ptmu1_16had1_18_v1.*':'embed_Run2012C_22Jan', + '/DoubleMuParked/StoreResults-Run2012D_22Jan2013_v1_PFembedded_trans1_tau116_ptmu1_16had1_18_v1.*':'embed_Run2012D_22Jan', + # '/DoubleMu/StoreResults-Run2012A_22Jan2013_v1_RHembedded_trans1_tau116_ptmu1_16had1_18_v1.*':'embed_Run2012A_22Jan', + # '/DoubleMuParked/StoreResults-Run2012D_22Jan2013_v1_RHembedded_trans1_tau116_ptmu1_16had1_18_v1.*':'embed_Run2012B_22Jan', + # '/DoubleMuParked/StoreResults-Run2012C_22Jan2013_v1_RHembedded_trans1_tau116_ptmu1_16had1_18_v1.*':'embed_Run2012C_22Jan', + # '/DoubleMuParked/StoreResults-Run2012B_22Jan2013_v1_RHembedded_trans1_tau116_ptmu1_16had1_18_v1.*':'embed_Run2012D_22Jan', + } + + +mc_ewk = [] +mc_ewk += mc_dy +mc_ewk += t_mc_ewk +mc_ewk += mc_w +mc_ewk += mc_w_ext + +MC_list = copy.copy( mc_ewk ) +# MC_list.append(mc_dy_ext) +# MC_list.extend( mc_higgs ) +# MC_list.extend( mc_higgs_susy ) +MC_list.extend( mc_diboson ) + +allsamples = copy.copy( MC_list ) +allsamples.extend( data_list ) +# allsamples.extend( embed_list ) + +mc_repro = [] +mc_repro += mc_dy +mc_repro += mc_higgs +mc_repro += mc_higgs_susy + +# pattern = '%TAUMU_MuRm_NoRecoil_Colin15Sep' +# pattern = '%TAUMU_MuRm_LeadJets_Colin16Sep' +pattern = '%TAUMU_MuRm_RecFix_Colin17Sep' +connect( allsamples, pattern, 'tauMu.*root', aliases, cache=True, verbose=False) + +# connect( embed_list, '%TAUMU_SVFitVEGAS_Aug07_steggema', 'tauMu.*root', aliases, cache=True, verbose=False) +# connect( mc_repro, '%TAUMU_SVFitVEGAS_Aug26_steggema', 'tauMu.*root', aliases, cache=True, verbose=False) + +# allsamples.extend( embed_list ) +# allsamples.extend( mc_repro ) +# MC_list.extend( mc_repro ) + +# Attach number of generated events for stitching +dy_nevents = [ DYJets.nGenEvents, + DY1Jets.nGenEvents, + DY2Jets.nGenEvents, + DY3Jets.nGenEvents, + DY4Jets.nGenEvents + ] +for dy in mc_dy: + dy.nevents = dy_nevents + +# Attach number of generated events for stitching +w_nevents = [ WJets.nGenEvents, + W1Jets.nGenEvents+W1Jets_ext.nGenEvents, + W2Jets.nGenEvents+W2Jets_ext.nGenEvents, + W3Jets.nGenEvents+W3Jets_ext.nGenEvents, + W4Jets.nGenEvents + ] +for w in mc_w+mc_w_ext: + w.nevents = w_nevents + +print [(s.name, s.dataset_entries) for s in allsamples if s.dataset_entries] +print [(s.name, s.dataset_entries) for s in allsamples if not s.dataset_entries] + +for mc in MC_list: + mc.triggers = mc_triggers + # allsamples.append(mc) +for data in data_list: + if len(data.files): + data.json = jsonPick( data.files[0], jsonMap) + data.triggers = data_triggers + # allsamples.append(data) +for embed in embed_list: + if len(embed.files): + embed.json = jsonPick( embed.files[0], jsonMap) + embed.triggers = embed_triggers + # No trigger requirements for embedded samples +for c in allsamples: + c.splitFactor = splitFactor(c, 5e3) diff --git a/CMGTools/RootTools/python/DataMC/DataMCPlot.py b/CMGTools/RootTools/python/DataMC/DataMCPlot.py index ad6e95b212342..44c5d0b3c1a8f 100644 --- a/CMGTools/RootTools/python/DataMC/DataMCPlot.py +++ b/CMGTools/RootTools/python/DataMC/DataMCPlot.py @@ -33,9 +33,9 @@ def __init__(self, name): self.stack = None self.legendOn = True self.legend = None - self.legendBorders = 0.13,0.46,0.44,0.89 - self.lastDraw = None - self.lastDrawArgs = None + self.legendBorders = 0.17,0.46,0.44,0.89 + # self.lastDraw = None + # self.lastDrawArgs = None self.stack = None self.nostack = None self.blindminx = None @@ -61,7 +61,6 @@ def AddHistogram(self, name, histo, layer=0, legendLine = None): self.histosDict[name] = tmp # tmp.AddEntry( self.legend, legendLine) - def Group(self, groupName, namesToGroup, layer=None, style=None): '''Group all histos with names in namesToGroup into a single histo with name groupName. All histogram properties are taken @@ -148,8 +147,8 @@ def DrawNormalized(self, opt=''): self.DrawLegend() if TPad.Pad(): TPad.Pad().Update() - self.lastDraw = 'DrawNormalized' - self.lastDrawArgs = [ opt ] + # self.lastDraw = 'DrawNormalized' + # self.lastDrawArgs = [ opt ] def Draw(self, opt = ''): '''All histograms are drawn.''' @@ -166,8 +165,8 @@ def Draw(self, opt = ''): self.DrawLegend() if TPad.Pad(): TPad.Pad().Update() - self.lastDraw = 'Draw' - self.lastDrawArgs = [ opt ] + # self.lastDraw = 'Draw' + # self.lastDrawArgs = [ opt ] def CreateLegend(self, ratio=False): @@ -214,9 +213,35 @@ def DrawRatio(self, opt=''): self.DrawLegend( ratio=True ) if TPad.Pad(): TPad.Pad().Update() - self.lastDraw = 'DrawRatio' - self.lastDrawArgs = [ opt ] + # self.lastDraw = 'DrawRatio' + # self.lastDrawArgs = [ opt ] + + def DrawDataOverMCMinus1(self, ymin=-0.5, ymax=0.5): + stackedHists = [] + dataHist = None + for hist in self._SortedHistograms(): + if hist.stack is False: + dataHist = hist + continue + stackedHists.append( hist ) + self._BuildStack( stackedHists, ytitle='Data/MC') + mcHist = self.stack.totalHist + self.dataOverMCHist = copy.deepcopy(dataHist) + self.dataOverMCHist.Add(mcHist, -1) + self.dataOverMCHist.Divide( mcHist ) + self.dataOverMCHist.Draw() + yaxis = self.dataOverMCHist.GetYaxis() + yaxis.SetRangeUser(ymin, ymax) + yaxis.SetTitle('Data/MC - 1') + yaxis.SetNdivisions(5) + fraclines= 0.2 + if ymax <= 0.2 or ymin>=-0.2: + fraclines = 0.1 + self.DrawRatioLines(self.dataOverMCHist, fraclines, 0.) + if TPad.Pad(): + TPad.Pad().Update() + def DrawRatioStack(self,opt='', xmin=None, xmax=None, ymin=None, ymax=None): @@ -248,11 +273,10 @@ def DrawRatioStack(self,opt='', ratio.obj.Draw('same') self.ratios.append( ratio ) self.DrawLegend( ratio=True ) - self.DrawRatioLines(denom, xmin, xmax) + self.DrawRatioLines(denom, 0.2, 1) if TPad.Pad(): TPad.Pad().Update() - self.lastDraw = 'DrawRatioStack' - self.lastDrawArgs = [ opt, ymin, ymax] + def DrawNormalizedRatioStack(self,opt='', xmin=None, xmax=None, @@ -287,25 +311,23 @@ def DrawNormalizedRatioStack(self,opt='', ratio.obj.Draw('same') self.ratios.append( ratio ) self.DrawLegend( ratio=True ) - self.DrawRatioLines(denom, xmin,xmax) + self.DrawRatioLines(denom, 0.2, 1) if TPad.Pad(): TPad.Pad().Update() - self.lastDraw = 'DrawNormalizedRatioStack' - self.lastDrawArgs = [ opt ] + # self.lastDraw = 'DrawNormalizedRatioStack' + # self.lastDrawArgs = [ opt ] - def DrawRatioLines(self, hist, xmin, xmax, frac=0.2): + def DrawRatioLines(self, hist, frac=0.2, y0=1.): '''Draw a line at y = 1, at 1+frac, and at 1-frac. - hist is used to get the y axis range.''' - if xmin is None: - xmin = hist.obj.GetXaxis().GetXmin() - if xmax is None: - xmax = hist.obj.GetXaxis().GetXmax() + hist is used to get the x axis range.''' + xmin = hist.obj.GetXaxis().GetXmin() + xmax = hist.obj.GetXaxis().GetXmax() line = TLine() - line.DrawLine(xmin, 1, xmax, 1) - line.DrawLine(xmin, 1+frac, xmax, 1+frac) - line.DrawLine(xmin, 1-frac, xmax, 1-frac) + line.DrawLine(xmin, y0, xmax, y0) + line.DrawLine(xmin, y0+frac, xmax, y0+frac) + line.DrawLine(xmin, y0-frac, xmax, y0-frac) def DrawStack(self, opt='', @@ -346,8 +368,8 @@ def DrawStack(self, opt='', self.DrawLegend() if TPad.Pad(): TPad.Pad().Update() - self.lastDraw = 'DrawStack' - self.lastDrawArgs = [ opt ] + # self.lastDraw = 'DrawStack' + # self.lastDrawArgs = [ opt ] def DrawNormalizedStack(self, opt='', @@ -365,8 +387,9 @@ def DrawNormalizedStack(self, opt='', self.DrawLegend() if TPad.Pad(): TPad.Pad().Update() - self.lastDraw = 'DrawNormalizedStack' - self.lastDrawArgs = [ opt ] + # self.lastDraw = 'DrawNormalizedStack' + # self.lastDrawArgs = [ opt ] + def Rebin(self, factor): '''Rebin, and redraw.''' @@ -376,24 +399,10 @@ def Rebin(self, factor): for hist in self.histos: hist.Rebin(factor) self.axisWasSet = False -## if self.lastDraw == 'DrawStack': -## self.DrawStack( *self.lastDrawArgs) -## elif self.lastDraw == 'DrawNormalizedStack': -## self.DrawNormalizedStack( *self.lastDrawArgs) -## elif self.lastDraw == 'DrawRatioStack': -## self.DrawRatioStack( *self.lastDrawArgs) -## elif self.lastDraw == 'DrawNormalizedRatioStack': -## self.DrawNormalizedRatioStack( *self.lastDrawArgs) -## elif self.lastDraw == 'Draw': -## self.Draw(*self.lastDrawArgs) -## elif self.lastDraw == 'DrawNormalized': -## self.DrawNormalized(*self.lastDrawArgs) -## elif self.lastDraw == 'DrawRatio': -## self.DrawRatio(*self.lastDrawArgs) def NormalizeToBinWidth(self): - '''Normalize each Histogram's bin to the bin width.''' + '''Normalize each Histograms bin to the bin width.''' for hist in self.histos: hist.NormalizeToBinWidth() @@ -422,3 +431,58 @@ def __str__(self): tmp.append( 'Stack yield = {integ:7.1f}'.format( integ=self.stack.integral ) ) return '\n'.join( tmp ) + +if __name__ == '__main__': + + from ROOT import TH1F, TCanvas, gPad + from CMGTools.RootTools.Style import sBlue, sGreen, sRed, sData, formatPad + + plot = DataMCPlot('plot') + + mult = 10000 + h1 = TH1F('h1','h1', 100,-5,5) + h1.FillRandom('gaus', 1*mult ) + h2 = TH1F('h2','h2', 100,-5,5) + h2.FillRandom('pol0', 1*mult ) + h3 = TH1F('h3','h3', 100,-5,5) + h3.FillRandom('pol0', 1*mult ) + + sBlue.formatHisto(h1) + sGreen.formatHisto(h2) + sRed.formatHisto(h3) + + plot.AddHistogram('signal', h1) + plot.AddHistogram('bgd1', h2) + plot.AddHistogram('bgd2', h3) + + plot.Hist('signal').layer = 4 + plot.Hist('bgd1').layer = 1 + plot.Hist('bgd2').layer = 2 + + + h4 = TH1F('h4','h4', 100,-5,5) + h4.Sumw2() + sData.formatHisto(h4) + + plot._BuildStack(plot.histos) + dataModel = plot.stack.totalHist.obj + for i in range(0, int(dataModel.GetEntries())): + rnd = dataModel.GetRandom() + h4.Fill(rnd) + + plot.AddHistogram('data', h4) + plot.Hist('data').stack=False + + c1 = TCanvas('c1') + formatPad(c1) + plot.DrawStack('HIST') + + c2 = TCanvas('c2') + formatPad(c2) + ratioplot = copy.copy(plot) + ratioplot.DrawRatioStack('HIST', ymin=0.6, ymax=1.5) + + c3 = TCanvas('c3') + formatPad(c3) + ratio2 = copy.copy(plot) + ratio2.DrawDataOverMCMinus1() diff --git a/CMGTools/RootTools/python/DataMC/Histogram.py b/CMGTools/RootTools/python/DataMC/Histogram.py index 9709f6714a131..8ee1a6cc6d7ea 100644 --- a/CMGTools/RootTools/python/DataMC/Histogram.py +++ b/CMGTools/RootTools/python/DataMC/Histogram.py @@ -63,6 +63,10 @@ def Rebin(self, factor): '''Rebins by factor''' self.obj.Rebin( factor ) self.weighted.Rebin(factor) + + def Divide(self, other): + self.obj.Divide( other.obj) + self.weighted.Divide( other.weighted ) def NormalizeToBinWidth(self): '''Divides each bin content and error by the bin size''' diff --git a/CMGTools/RootTools/python/DataMC/Stack.py b/CMGTools/RootTools/python/DataMC/Stack.py index 026ff21a154fb..538ba1347b700 100644 --- a/CMGTools/RootTools/python/DataMC/Stack.py +++ b/CMGTools/RootTools/python/DataMC/Stack.py @@ -32,6 +32,10 @@ def Add(self, hist): # one MUST do a deepcopy here. self.hists.append( copy.deepcopy(hist) ) self.integral += hist.Yield( weighted=True ) + if self.totalHist is None: + self.totalHist = copy.deepcopy( hist ) + elif hist.layer<1000: + self.totalHist.Add( hist ) def Draw(self, opt='', xmin=None, xmax=None, ymin = None, ymax=None): @@ -57,11 +61,11 @@ def _Draw( self, opt, hists, xmin, xmax, ymin, ymax): # hist = hists[0] hist = self.totalHist # hist.Draw('hist') - #hist.Draw(opt) #### riccardo + hist.Draw(opt) #### riccardo if self.ytitle is not None: hist.GetYaxis().SetTitle( self.ytitle ) - #self.obj.Draw( opt+'same' ) ### riccardo - self.obj.Draw( opt ) ### riccardo + self.obj.Draw( opt+'same' ) ### riccardo + #self.obj.Draw( opt ) ### riccardo # need to redraw the axes, which are now "under" # the stacked histograms. hist.Draw('axissame') diff --git a/CMGTools/RootTools/python/HistComparator.py b/CMGTools/RootTools/python/HistComparator.py index cfd2c27f4c3d0..b734a59e00405 100644 --- a/CMGTools/RootTools/python/HistComparator.py +++ b/CMGTools/RootTools/python/HistComparator.py @@ -56,7 +56,7 @@ def set(self, name, h1, h2, title1=None, title2=None): self.ratio.SetStats(0) - def draw(self, simple=False): + def draw(self, simple=False, opt2='', opt1=''): '''The canvas is created if needed.''' # import pdb; pdb.set_trace() if simple!=self.simple_state: @@ -71,8 +71,9 @@ def draw(self, simple=False): self.pad_main.Draw() self.pad_ratio.Draw() self.pad_main.cd() - self.h2.Draw() - self.h1.Draw('same') + self.h2.SetStats(0) + self.h2.Draw(opt2) + self.h1.Draw(opt1+'same') self.h2.GetYaxis().SetRangeUser(1e-3, self.ymax(self.h1, self.h2)*1.2) self.h2.GetYaxis().SetLabelSize(0.045) diff --git a/CMGTools/RootTools/python/Style.py b/CMGTools/RootTools/python/Style.py index 532e3b70abfe0..52edb75807634 100644 --- a/CMGTools/RootTools/python/Style.py +++ b/CMGTools/RootTools/python/Style.py @@ -54,9 +54,9 @@ def formatPad( pad ): sBlack = Style() sData = Style(fillStyle=0, markerSize=1.3) -sBlue = Style(lineColor=4, markerColor=4) -sGreen = Style(lineColor=8, markerColor=8) -sRed = Style(lineColor=2, markerColor=2) +sBlue = Style(markerColor=4, fillColor=4) +sGreen = Style(markerColor=8, fillColor=8) +sRed = Style(markerColor=2, fillColor=2) sYellow = Style(lineColor=1, markerColor=5, fillColor=5) sViolet = Style(lineColor=1, markerColor=kViolet, fillColor=kViolet) diff --git a/CMGTools/RootTools/python/analyzers/DiTriggerAnalyzer.py b/CMGTools/RootTools/python/analyzers/DiTriggerAnalyzer.py new file mode 100644 index 0000000000000..9bfadfd841be1 --- /dev/null +++ b/CMGTools/RootTools/python/analyzers/DiTriggerAnalyzer.py @@ -0,0 +1,168 @@ +from CMGTools.RootTools.fwlite.Analyzer import Analyzer +from CMGTools.RootTools.fwlite.AutoHandle import AutoHandle +from CMGTools.RootTools.statistics.Counter import Counter +from CMGTools.RootTools.utils.TriggerList import TriggerList +from CMGTools.RootTools.utils.TriggerMatching import selTriggerObjects +from CMGTools.RootTools.physicsobjects.PhysicsObjects import TriggerObject + +class TriggerAnalyzer( Analyzer ): + '''Access to trigger information, and trigger selection''' + + def declareHandles(self): + super(TriggerAnalyzer, self).declareHandles() + + self.handles['cmgTriggerObjectSel'] = AutoHandle( + 'cmgTriggerObjectSel', + 'std::vector' + ) + + self.handles['cmgTriggerObjectListSel'] = AutoHandle( + 'cmgTriggerObjectListSel', + 'std::vector' + ) + + def beginLoop(self): + super(TriggerAnalyzer,self).beginLoop() + self.triggerList = TriggerList( self.cfg_comp.triggers ) + if hasattr(self.cfg_comp,'vetoTriggers'): + self.vetoTriggerList = TriggerList( self.cfg_comp.vetoTriggers ) + else: + self.vetoTriggerList = None + + self.counters.addCounter('Trigger') + self.counters.counter('Trigger').register('All events') + self.counters.counter('Trigger').register('HLT') + + + def process(self, iEvent, event): + self.readCollections( iEvent ) + + #if iEvent.eventAuxiliary().id().event() in notPassed : + # print 'before anything' + # import pdb ; pdb.set_trace() + + + event.triggerObject = self.handles['cmgTriggerObjectSel'].product()[0] + run = iEvent.eventAuxiliary().id().run() + lumi = iEvent.eventAuxiliary().id().luminosityBlock() + eventId = iEvent.eventAuxiliary().id().event() + + event.run = run + event.lumi = lumi + event.eventId = eventId + + ## if component is embed return (has no trigger obj) RHEMB will have trigger! + if self.cfg_comp.isEmbed and len(self.cfg_comp.triggers)==0 : + return True + +## if self.cfg_ana.verbose: +## self.printTriggerObject( event.triggerObject ) + + self.counters.counter('Trigger').inc('All events') + # import pdb; pdb.set_trace() + usePrescaled = False + if hasattr( self.cfg_ana, 'usePrescaled'): + usePrescaled = self.cfg_ana.usePrescaled + + # import pdb; pdb.set_trace() + + ### want to check whether more than one unprescaled trigger has been fired + hltPathVec = [] + + self.triggerList = TriggerList( self.cfg_comp.triggers ) + + passed, hltPath = self.triggerList.triggerPassed(event.triggerObject, + run, lumi, self.cfg_comp.isData, + self.cfg_comp.isEmbed, + usePrescaled = usePrescaled) + + if passed and not hltPath == None: + hltPathVec.append(hltPath) + + + if passed and not hltPath == None: + for tr in self.cfg_comp.triggers : + if tr in hltPathVec : + for triggerToRemove in self.triggerList.triggerList : + if triggerToRemove.name == tr : + self.triggerList.triggerList.remove(triggerToRemove) + + passed2, hltPath2 = self.triggerList.triggerPassed(event.triggerObject, + run, lumi, self.cfg_comp.isData, + self.cfg_comp.isEmbed, + usePrescaled = usePrescaled) + if passed2 and not hltPath2 == None: + hltPathVec.append(hltPath2) + + event.hltPaths = set(hltPathVec) + + #Check the veto! + veto=False + if self.vetoTriggerList is not None: + veto,hltVetoPath = self.vetoTriggerList.triggerPassed(event.triggerObject, + run,lumi,self.cfg_comp.isData, + self.cfg_comp.isEmbed, + usePrescaled = usePrescaled) + + # Check if events needs to be skipped if no trigger is found (useful for generator level studies) + keepFailingEvents = False + #keepFailingEvents = True + if hasattr( self.cfg_ana, 'keepFailingEvents'): + keepFailingEvents = self.cfg_ana.keepFailingEvents + if not passed or (passed and veto): + event.passedTriggerAnalyzer = False + if not keepFailingEvents: + #if iEvent.eventAuxiliary().id().event() in notPassed : + # print 'before anything' + # import pdb ; pdb.set_trace() + return False + else: + event.passedTriggerAnalyzer = True + + #import pdb ; pdb.set_trace() + event.hltPath = hltPath + + + ### Riccardo: I want the trigger objects corresponding to the trigger I want to fire even if it has not been fired + if hltPath is not None : + trigObjs = map( TriggerObject, self.handles['cmgTriggerObjectListSel'].product()) + # selecting the trigger objects used in this path + event.triggerObjects = selTriggerObjects( trigObjs, hltPath ) + elif keepFailingEvents : + event.triggerObjects = [] + for hltPath in self.cfg_comp.triggers : + trigObjs = map( TriggerObject, self.handles['cmgTriggerObjectListSel'].product()) + event.triggerObjects.extend( selTriggerObjects( trigObjs, hltPath, skipPath=True ) ) + hltPath = None + #import pdb ; pdb.set_trace() + +# if hltPath is not None: +# trigObjs = map( TriggerObject, +# self.handles['cmgTriggerObjectListSel'].product()) +# # selecting the trigger objects used in this path +# event.triggerObjects = selTriggerObjects( trigObjs, hltPath ) + + self.counters.counter('Trigger').inc('HLT') + event.TriggerFired = 1 + return True + + def write(self): + print 'writing TriggerAnalyzer' + super(TriggerAnalyzer, self).write() + self.triggerList.write( self.dirName ) + + def __str__(self): + tmp = super(TriggerAnalyzer,self).__str__() + triglist = str( self.triggerList ) + return '\n'.join( [tmp, triglist ] ) + + +## def printTriggerObject(self, object): +## '''FIXME : we need a trigger object class in physicsobjects.''' +## print 'trig obj', object.pdgId(), object.pt(), object.charge(), object.eta(), object.phi() +## for name in object.getSelectionNames(): +## hasSel = object.getSelection( name ) +## if self.cfg_ana.verbose==1 and hasSel: +## print name, hasSel +## elif self.cfg_ana.verbose==2: +## print name, hasSel diff --git a/CMGTools/RootTools/python/analyzers/JetAnalyzer.py b/CMGTools/RootTools/python/analyzers/JetAnalyzer.py index c3ab19e0711dd..b06f9c5c552a3 100644 --- a/CMGTools/RootTools/python/analyzers/JetAnalyzer.py +++ b/CMGTools/RootTools/python/analyzers/JetAnalyzer.py @@ -210,7 +210,10 @@ def jesCorrection(self, jet, scale=0.): jet.scaleEnergy(totalScale) def testJetID(self, jet): - jet.puJetIdPassed = jet.puJetId(wp53x=True) + if self.is2012: + jet.puJetIdPassed = jet.puJetId(wp53x=True) + else: + jet.puJetIdPassed = jet.puJetId(wp53x=False, use2011=True) jet.pfJetIdPassed = jet.looseJetId() if self.cfg_ana.relaxJetId: diff --git a/CMGTools/RootTools/python/treeComparator.py b/CMGTools/RootTools/python/treeComparator.py index 22fbcffa2cab3..49629c5ab505a 100644 --- a/CMGTools/RootTools/python/treeComparator.py +++ b/CMGTools/RootTools/python/treeComparator.py @@ -50,7 +50,7 @@ def draw(var1=None, cut=1, t1=None, t2=None, w1='1', w2='1', h2.Scale( normalize ) sBlue.markerStyle = 25 sBlue.formatHisto(h2) - sBlack.formatHisto(h1) + sData.formatHisto(h1) h2.SetFillStyle(1001) h2.SetFillColor(5) h1.SetMarkerSize(0.8) @@ -69,7 +69,7 @@ def draw(var1=None, cut=1, t1=None, t2=None, w1='1', w2='1', print 'number of selected rows:', t1.GetSelectedRows(), t2.GetSelectedRows() comparator = HistComparator(var1, h1, h2) - comparator.draw() + comparator.draw(opt2='e2') return comparator diff --git a/CMGTools/RootTools/python/utils/TriggerList.py b/CMGTools/RootTools/python/utils/TriggerList.py index 4b87346173942..7d5d3de19c3c2 100644 --- a/CMGTools/RootTools/python/utils/TriggerList.py +++ b/CMGTools/RootTools/python/utils/TriggerList.py @@ -26,13 +26,15 @@ def __init__(self, triggerList): self.triggerList.append( trig ) fileName = '/'.join( [os.environ['CMSSW_BASE'], 'src/CMGTools/RootTools/python/utils/triggerEvolution_all.txt']) - datasets = ['TauPlusX'] + #datasets = ['TauPlusX'] + # FIXME: This is tau-specific. + datasets = ['Tau','TauParked','DoubleMu','DoubleMuParked','TauPlusX','SingleMu'] self.menus = Menus( fileName, datasets ) self.run = -1 self.triggerJSON = TriggerJSON() self.rltInfo = RLTInfo() - def restrictList(self, run, triggerList ): + def restrictList(self, run, triggerList, isData, isEmbed=False): '''Restrict the trigger list to the list of unprescaled triggers in this run. Seriously speeds up the code.''' @@ -41,7 +43,23 @@ def restrictList(self, run, triggerList ): # return triggerList if run != self.run: try: - selMenus = self.menus.findUnprescaledPaths(run, 'TauPlusX') + #import pdb ; pdb.set_trace() + if isData : + selMenus = self.menus.findUnprescaledPaths(run, 'Tau') + try : + selMenus = self.menus.findUnprescaledPaths(run, 'TauPlusX') + selMenus2 = self.menus.findUnprescaledPaths(run, 'TauParked') + selMenus += selMenus2 + except : + pass + if isEmbed : + selMenus = self.menus.findUnprescaledPaths(run, 'DoubleMu') + try : + selMenus2 = self.menus.findUnprescaledPaths(run, 'DoubleMuParked') + selMenus += selMenus2 + except : + pass + #import pdb ; pdb.set_trace() self.unprescaledPaths = set( path.name for path in selMenus ) self.restrictedTriggerList = [trigger \ for trigger in triggerList \ @@ -55,19 +73,22 @@ def restrictList(self, run, triggerList ): if len( self.triggerList ) != 0: print 'run', run, ': no path from the user list found in the list of unprescaled paths from the trigger DB. The latter could be wrong, using the user trigger list.' self.restrictedTriggerList = self.triggerList + #import pdb ; pdb.set_trace() return self.restrictedTriggerList def triggerPassed(self, triggerObject, run, lumi, - isData, usePrescaled=False): + isData, isEmbed=False, usePrescaled=False): '''returns true if at least one of the triggers in the triggerlist passes. run is provided to call restrictList. if usePrescaled is False (DEFAULT), only the unprescaled triggers are considered. if triggerList is None (DEFAULT), oneself triggerlist is used. ''' - + + #import pdb ; pdb.set_trace() + triggerList = self.triggerList - if isData: - triggerList = self.restrictList( run, self.triggerList ) + if isData or isEmbed: + triggerList = self.restrictList( run, self.triggerList, isData, isEmbed ) if len(triggerList)==0: # no trigger specified, accepting all events return True, None @@ -76,6 +97,7 @@ def triggerPassed(self, triggerObject, run, lumi, for trigger in triggerList: trigger.inc('events tested') # if triggerObject.getSelectionRegExp( trigger.name ): + #import pdb ; pdb.set_trace() passedName, prescaleFactor = self.getSelectionRegExp( triggerObject, trigger.name ) if passedName is not None: # prescaleFactor = triggerObject.getPrescale( passedName ) @@ -87,6 +109,7 @@ def triggerPassed(self, triggerObject, run, lumi, firstTrigger = trigger.name self.triggerJSON.setdefault(trigger.name, set()).add( run ) self.rltInfo.add( trigger.name, run, lumi ) + # don't break, need to test all triggers in the list # break return passed, firstTrigger diff --git a/CMGTools/RootTools/python/utils/TriggerMatching.py b/CMGTools/RootTools/python/utils/TriggerMatching.py index 3666f0a09c840..edb2a587cf4f0 100644 --- a/CMGTools/RootTools/python/utils/TriggerMatching.py +++ b/CMGTools/RootTools/python/utils/TriggerMatching.py @@ -1,32 +1,41 @@ import fnmatch +import math from CMGTools.RootTools.utils.DeltaR import deltaR2 - def triggerMatched( object, triggerObjects, path, filter, - dR2Max=0.089999, pdgIds=None): + dR2Max=0.089999, dRMax=0., pdgIds=None, index=False): '''The default dR2Max is 0.3^2''' - # import pdb; pdb.set_trace() eta = object.eta() phi = object.phi() # to speed up the code, could sort the triggerObjects by decreasing pT # when they are produced - for trigObj in triggerObjects: - if trigObj.hasPath( path ) and \ + for i, trigObj in enumerate(triggerObjects): + if trigObj.hasPath( path ) and \ trigObj.hasSelection( filter ) and \ + dRMax == 0. and \ deltaR2( eta, phi, trigObj.eta(), trigObj.phi() ) < dR2Max: - if pdgIds is None or \ - abs(trigObj.pdgId()) in pdgIds: - return True - return False + if pdgIds is None or abs(trigObj.pdgId()) in pdgIds: + if index : return True, i + else : return True + if trigObj.hasPath( path ) and \ + trigObj.hasSelection( filter ) and \ + dRMax > 0. and \ + math.sqrt(deltaR2( eta, phi, trigObj.eta(), trigObj.phi() )) < dRMax: + if pdgIds is None or abs(trigObj.pdgId()) in pdgIds: + if index : return True, i + else : return True + + if index : return False, -99 + else : return False -def selTriggerObjects( trigObjs, path, filter=None): +def selTriggerObjects( trigObjs, path, filter=None, skipPath=False): '''Selects trigger objects used in path, and passing filter. If filter is None, only checks path. path can contain a wildcard.''' selObjs = [] for trigObj in trigObjs: # if not trigObj.hasSelection( path ): continue - if not trigObj.hasPath( path ): continue + if not (trigObj.hasPath( path ) or skipPath) : continue if filter is not None and \ not trigObj.hasSelection( filter ): continue selObjs.append( trigObj ) diff --git a/CMGTools/RootTools/python/utils/fileComparator.py b/CMGTools/RootTools/python/utils/fileComparator.py index d571862e15236..5738f1daeabf4 100644 --- a/CMGTools/RootTools/python/utils/fileComparator.py +++ b/CMGTools/RootTools/python/utils/fileComparator.py @@ -98,7 +98,8 @@ def _drawHists(self, h1, h2, h1name): if title1 is None: title1 = self.info1.name if title2 is None: - title2 = self.info2.name + title2 = self.info2.name + # import pdb; pdb.set_trace() if not self.hcomp: self.hcomp = HistComparator(h1name,h1, h2, title1, title2) else: diff --git a/CMGTools/Utilities/interface/RecoilCorrectedMETProducer.h b/CMGTools/Utilities/interface/RecoilCorrectedMETProducer.h index 876867ffa50dc..4d0114adab1e4 100644 --- a/CMGTools/Utilities/interface/RecoilCorrectedMETProducer.h +++ b/CMGTools/Utilities/interface/RecoilCorrectedMETProducer.h @@ -228,7 +228,7 @@ void RecoilCorrectedMETProducer::produce(edm::Event & iEvent, cons double met = uncMet; double metphi = uncMetPhi; - jetMult = nJets( *jetH, recBoson, deltaRCut_ ); + jetMult = nJets( *jetH, recBoson, deltaRCut_); double zero = 0.; @@ -283,8 +283,8 @@ template< typename RecBosonType > int RecoilCorrectedMETProducer< RecBosonType >::nJets( const JetCollectionType& jets, const RecBosonType& boson, float deltaR) { - //COLIN : check that I should really remove jets matched to both legs - // when working with Ws. + // H->tau tau Summer 13 convention: Remove only lepton from jets, not tau, + // when working with Ws. Not clear what to do for fully-hadronic if(verbose_) { std::cout<<"\tMatching jets to boson legs"<::nJets( const JetCollectionType& for(unsigned iJet = 0; iJet deltaR2 && dR2leg2 > deltaR2) { diff --git a/CMGTools/Utilities/python/metRecoilCorrection/recoilCorrectedMETTauEle_cfi.py b/CMGTools/Utilities/python/metRecoilCorrection/recoilCorrectedMETTauEle_cfi.py index 025e3047cb3c1..1dd6be6e3e45a 100644 --- a/CMGTools/Utilities/python/metRecoilCorrection/recoilCorrectedMETTauEle_cfi.py +++ b/CMGTools/Utilities/python/metRecoilCorrection/recoilCorrectedMETTauEle_cfi.py @@ -22,8 +22,8 @@ correctionType = cms.int32(2), fileCorrectTo = cms.string(rootfile_dir + 'recoilfit_wjets53X_20pv_njet.root'), # you should not have to change the files below - fileZmmData = cms.string(rootfile_dir + 'recoilfit_datamm53X_20pv_njet.root'), - fileZmmMC = cms.string(rootfile_dir + 'recoilfit_zmm53X_20pv_njet.root'), + fileZmmData = cms.string(rootfile_dir + 'recoilfit_datamm53XRR_2012_njet.root'), # Phil's new re-reco corrections; whhy no 20pv + fileZmmMC = cms.string(rootfile_dir + 'recoilfit_zmm53XRR_2012_njet.root'), # Phil's new re-reco corrections enable = cms.bool(True), force = cms.bool(False), verbose = cms.untracked.bool( False )