def makePlots(variables, cuts, total_weight, all_samples, samples, friend_func, mode='control', dc_postfix='', make_plots=True, optimisation=False): sample_names = set() ams_dict = {} from CMGTools.H2TauTau.proto.plotter.cut import Cut # def_iso_cut = inc_sig_tau1_iso & inc_sig_tau2_iso iso_cuts = { # 'vvtight':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>5.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>5.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>3.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>3.5')), 'vtight_relax2nd': (Cut('l1_byIsolationMVArun2v1DBoldDMwLT>4.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>4.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>4.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>2.5')), 'loose_not_vtight': (Cut( 'l1_byIsolationMVArun2v1DBoldDMwLT>1.5 && l1_byIsolationMVArun2v1DBoldDMwLT<4.5' ) & Cut( 'l2_byIsolationMVArun2v1DBoldDMwLT>1.5&&l2_byIsolationMVArun2v1DBoldDMwLT<4.5' ), Cut('l1_byIsolationMVArun2v1DBoldDMwLT<1.5 && l1_byIsolationMVArun2v1DBoldDMwLT>0.5' ) & Cut('l2_byIsolationMVArun2v1DBoldDMwLT<1.5 && l2_byIsolationMVArun2v1DBoldDMwLT>0.5' )), 'one_loose_other_vtight': (Cut( '(l1_byIsolationMVArun2v1DBoldDMwLT>4.5 && (l2_byIsolationMVArun2v1DBoldDMwLT>1.5&&l2_byIsolationMVArun2v1DBoldDMwLT<4.5)) || (l2_byIsolationMVArun2v1DBoldDMwLT>4.5 && (l1_byIsolationMVArun2v1DBoldDMwLT>1.5&&l1_byIsolationMVArun2v1DBoldDMwLT<4.5)) ' ), Cut('l1_byIsolationMVArun2v1DBoldDMwLT<1.5 && l1_byIsolationMVArun2v1DBoldDMwLT>0.5' ) & Cut('l2_byIsolationMVArun2v1DBoldDMwLT<1.5 && l2_byIsolationMVArun2v1DBoldDMwLT>0.5' )), # 'vtight':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>4.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>4.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>2.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>2.5')), # 'tight':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>3.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>3.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>3.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>1.5')), # 'medium':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>2.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>2.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>0.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>0.5')), # 'loose':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>1.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>1.5'), Cut('1')), # 'vloose':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>0.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>0.5'), Cut('1')), } # iso_cuts = { # 'l1_vvtight':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>5.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>4.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>5.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>3.5')), # 'l1_vtight':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>4.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>4.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>4.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>2.5')), # 'l1_tight':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>3.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>4.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>3.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>1.5')), # 'l1_medium':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>2.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>4.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>2.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>0.5')), # 'l1_loose':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>1.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>4.5'), Cut('l1_byIsolationMVArun2v1DBoldDMwLT>1.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>0.5')), # 'l1_vloose':(Cut('l1_byIsolationMVArun2v1DBoldDMwLT>0.5') & Cut('l2_byIsolationMVArun2v1DBoldDMwLT>4.5'),Cut('l1_byIsolationMVArun2v1DBoldDMwLT>0.5') & Cut('1')), # } for cut in cuts: for iso_cut_name, (iso_cut, max_iso_cut) in iso_cuts.items(): # iso and charge cuts, need to have them explicitly for the QCD estimation # max_iso_cut = Cut('l1_byIsolationMVArun2v1DBoldDMwLT > 2.5 && l2_byIsolationMVArun2v1DBoldDMwLT > 2.5') iso_sideband_cut = (~iso_cut) & max_iso_cut charge_cut = Cut('l1_charge != l2_charge') isSS = 'SS' in cut.name all_samples_qcd = qcd_estimation( cut.cut & iso_sideband_cut & (charge_cut if not isSS else ~charge_cut), # shape sideband cut.cut & iso_cut & (~charge_cut), # norm sideband 1 cut.cut & iso_sideband_cut & (~charge_cut), # norm sideband 2 all_samples if mode in ['mssm'] else samples, int_lumi, total_weight, verbose=verbose, friend_func=friend_func) # now include charge and isolation too the_cut = MyCut( cut.name + iso_cut_name, cut.cut & iso_cut & (charge_cut if not isSS else ~charge_cut)) # for variable in variables: cfg_total = HistogramCfg(name=the_cut.name, vars=variables, cfgs=all_samples_qcd, cut=str(the_cut.cut), lumi=int_lumi, weight=total_weight) # all_samples_qcd[-1].vars = variables if mode == 'mva_train': createTrees(cfg_total, '/data1/steggema/tt/MVATrees', verbose=True) continue plots = createHistograms(cfg_total, verbose=True, friend_func=friend_func) for variable in variables: plot = plots[variable.name] plot.Group('Single t', [ 'T_tWch', 'TBar_tWch', 'TToLeptons_tch_powheg', 'TBarToLeptons_tch_powheg' ]) # 'TToLeptons_sch', plot.Group('VV', [ 'VVTo2L2Nu', 'ZZTo2L2Q', 'WWTo1L1Nu2Q', 'WZTo1L3Nu', 'ZZTo4L', 'WZTo2L2Q', 'WZTo1L1Nu2Q', 'Single t' ]) # 'WZTo3L', plot.Group( 'ZTT', ['ZTT', 'ZTT1Jets', 'ZTT2Jets', 'ZTT3Jets', 'ZTT4Jets']) plot.Group('ZJ', ['ZJ', 'ZJ1Jets', 'ZJ2Jets', 'ZJ3Jets', 'ZJ4Jets']) plot.Group('ZL', ['ZL', 'ZL1Jets', 'ZL2Jets', 'ZL3Jets', 'ZL4Jets']) plot.Group( 'W', ['WJetsToLNu', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']) plot.Group('Electroweak', ['W', 'VV', 'Single t', 'ZJ']) if optimisation: plot.DrawStack('HIST') print plot for signal_hist in plot.SignalHists(): sample_names.add(signal_hist.name) ams = ams_hists_rebin(signal_hist.weighted, plot.BGHist().weighted) if variable.name == 'mt_total_mssm' and signal_hist.name == 'ggH1800': print ams_hists_rebin(signal_hist.weighted, plot.BGHist().weighted, debug=True) # import pdb; pdb.set_trace() ams_dict[variable.name + '__' + the_cut.name + '__' + signal_hist.name + '_'] = ams if not make_plots: continue blindxmin = 0.7 if 'mva' in variable.name else None blindxmax = 1.00001 if 'mva' in variable.name else None if variable.name == 'mt2': blindxmin = 60. blindxmax = variable.binning['xmax'] if variable.name == 'mt_sum': blindxmin = 250. blindxmax = variable.binning['xmax'] if variable.name == 'mt_total': blindxmin = 200. blindxmax = variable.binning['xmax'] plot_dir = 'plot_' + the_cut.name HistDrawer.draw(plot, channel='#tau_{h}#tau_{h}', plot_dir=plot_dir, blindxmin=blindxmin, blindxmax=blindxmax) # HistDrawer.drawRatio(plot, channel='#tau_{h}#tau_{h}') plot.UnGroup('Electroweak') #, ['W', 'VV', 'Single t', 'ZJ']) plot.Group('VV', ['VV', 'Single t']) if variable.name in [ 'mt_total', 'svfit_mass', 'mt_total_mssm', 'mt_total_mssm_fine' ]: plot.WriteDataCard( filename=plot_dir + '/htt_tt.inputs-sm-13TeV_{var}{postfix}.root'.format( var=variable.name, postfix=dc_postfix), dir='tt_' + cut.name, mode='UPDATE') # Save AMS dict import pickle pickle.dump(ams_dict, open('opt.pkl', 'wb')) if optimisation: print '\nOptimisation results:' all_vals = ams_dict.items() for sample_name in sample_names: vals = [v for v in all_vals if sample_name + '_' in v[0]] vals.sort(key=itemgetter(1)) for key, item in vals: print item, key print '\nBy variable' for variable in variables: name = variable.name print '\nResults for variable', name for key, item in vals: if key.startswith(name + '__'): print item, key
# variables = [ # VariableCfg(name='mvis', binning={'nbinsx':35, 'xmin':0, 'xmax':350}, unit='GeV', xtitle='m_{vis}') # ] for cut_name in cuts: if qcd_from_same_sign and not 'SS' in cut_name : cfg_example = HistogramCfg(name='example', var=None, cfgs=samples_qcdfromss, cut=inc_cut, lumi=lumi, weight=total_weight) else: cfg_example = HistogramCfg(name='example', var=None, cfgs=samples, cut=inc_cut, lumi=lumi, weight=total_weight) cfg_example.cut = cuts[cut_name] if qcd_from_same_sign and not 'SS' in cut_name: qcd.cut = cuts[cut_name].replace('l1_charge != l2_charge', 'l1_charge == l2_charge') cfg_example.vars = variables if qcd_from_same_sign: qcd.vars = variables # Can put into function but we will not want it by default if we take normalisations from e.g. high MT plots = createHistograms(cfg_example, verbose=True) for variable in variables: plot = plots[variable.name] plot.Group('VV', ['WWTo1L1Nu2Q', 'WZTo1L1Nu2Q', 'WZTo1L3Nu', 'WZTo2L2Q', 'VVTo2L2Nu', 'ZZTo2L2Q', 'ZZTo4L']) plot.Group('Single t', ['T_tWch', 'TBar_tWch', 'TBarToLeptons_tch_powheg', 'TToLeptons_tch_powheg']) plot.Group('ZLL', ['ZL', 'ZJ'], style=plot.Hist('ZL').style) plot.Group('W', ['W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']) plot.Group('Electroweak', ['W', 'VV', 'Single t']) base_dir = 'plotsG/' if data2016G else 'plots/' HistDrawer.draw(plot, plot_dir=base_dir+cut_name, channel='e#mu')
def makePlots(variables, cuts, total_weight, sample_dict, hist_dict, qcd_from_same_sign, w_qcd_mssm_method, mt_cut, friend_func, dc_postfix, make_plots=True): for cut in cuts: if qcd_from_same_sign and not 'SS' in cut.name and not w_qcd_mssm_method: cfg_main = HistogramCfg(name=cut.name, var=None, cfgs=sample_dict['samples_qcdfromss'], cut=cut.cut, lumi=int_lumi, weight=total_weight) elif w_qcd_mssm_method: cfg_main = HistogramCfg(name=cut.name, var=None, cfgs=sample_dict['samples_mssm_method'], cut=cut.cut, lumi=int_lumi, weight=total_weight) hist_dict[ 'wjets'].cut = cut.cut # since wjets is a sub-HistogramCfg else: cfg_main = HistogramCfg(name=cut.name, var=None, cfgs=sample_dict['all_samples'], cut=cut.cut, lumi=int_lumi, weight=total_weight) if qcd_from_same_sign and not 'SS' in cut.name: hist_dict['qcd'].cut = cut.cut.replace('l1_charge != l2_charge', 'l1_charge == l2_charge') if w_qcd_mssm_method: hist_dict['stacknow_highmt_os'].name = 'HighMTOS' + cut.name hist_dict['stacknow_highmt_ss'].name = 'HighMTSS' + cut.name hist_dict['wjets_incl_os'].name = 'WInclOS' + cut.name hist_dict['wjets_incl_ss'].name = 'WInclSS' + cut.name hist_dict['wjets_highmt_os'].name = 'WHighMTOS' + cut.name hist_dict['wjets_ss'].name = 'WJetsSS' + cut.name hist_dict['qcd'].cut = cut.cut.replace('l1_charge != l2_charge', 'l1_charge == l2_charge') hist_dict['wjets_ss'].cut = cut.cut.replace( 'l1_charge != l2_charge', 'l1_charge == l2_charge') hist_dict['stacknow_highmt_os'].cut = cut.cut.replace( mt_cut, 'mt>70') + '&& mt>70' hist_dict['stacknow_highmt_ss'].cut = cut.cut.replace( 'l1_charge != l2_charge', 'l1_charge == l2_charge').replace( mt_cut, 'mt>70') + '&& mt>70' hist_dict['wjets_incl_os'].cut = cut.cut.replace(mt_cut, '1.') hist_dict['wjets_incl_ss'].cut = cut.cut.replace( 'l1_charge != l2_charge', 'l1_charge == l2_charge').replace(mt_cut, '1.') hist_dict['wjets_highmt_os'].cut = cut.cut.replace( mt_cut, 'mt>70') + '&& mt>70' plot_w_os = createHistogram(hist_dict['wjets_incl_os'], verbose=False, friend_func=friend_func) plot_w_ss = createHistogram(hist_dict['wjets_incl_ss'], verbose=False, friend_func=friend_func) r_w_os_ss = plot_w_os.GetStack().totalHist.Yield( ) / plot_w_ss.GetStack().totalHist.Yield() print 'Inclusive W OS/SS ratio:', r_w_os_ss plot_highmt_os = createHistogram(hist_dict['stacknow_highmt_os'], all_stack=True, verbose=False, friend_func=friend_func) plot_highmt_ss = createHistogram(hist_dict['stacknow_highmt_ss'], all_stack=True, verbose=False, friend_func=friend_func) createDefaultGroups(plot_highmt_os) createDefaultGroups(plot_highmt_ss) yield_highmt_os = plot_highmt_os.GetStack().totalHist.Yield() yield_highmt_ss = plot_highmt_ss.GetStack().totalHist.Yield() plot_w_highmt_os = createHistogram(hist_dict['wjets_highmt_os'], verbose=False, friend_func=friend_func) yield_w_highmt_os = plot_w_highmt_os.GetStack().totalHist.Yield() if r_w_os_ss < r_qcd_os_ss: print 'WARNING, OS/SS ratio larger for QCD than for W+jets!', r_w_os_ss, r_qcd_os_ss yield_estimation = r_w_os_ss * (yield_highmt_os - r_qcd_os_ss * yield_highmt_ss) / ( r_w_os_ss - r_qcd_os_ss) print 'High MT W+jets estimated yield', yield_estimation print 'High MT W+jets MC yield', yield_w_highmt_os w_sf = 0. if yield_w_highmt_os: w_sf = yield_estimation / yield_w_highmt_os else: print 'Warning: no MC events in high MT W+jets' print 'W+jets scale factor:', w_sf, '\n' if cut.name == 'vbf_highmva0': print 'VBF very tight category, fixing W+jets SF to 1' w_sf = 1. hist_dict['wjets'].total_scale = w_sf hist_dict['wjets_ss'].total_scale = -w_sf cfg_main.vars = variables if qcd_from_same_sign: hist_dict[ 'qcd'].vars = variables # Can put into function but we will not want it by default if we take normalisations from e.g. high MT if w_qcd_mssm_method: hist_dict[ 'wjets'].vars = variables # Can put into function but we will not want it by default if we take normalisations from e.g. high MT hist_dict['qcd'].vars = variables hist_dict['wjets_ss'].vars = variables for variable in variables: if variable.name in [ 'svfit_mass', 'svfit_transverse_mass', 'mvis' ] and 'mssm' in mode: if cut.name in ['inclusive', 'nobtag']: variable.binning = binning_mssm elif cut.name in ['btag']: variable.binning = binning_mssm_btag plots = createHistograms(cfg_main, verbose=False, friend_func=friend_func) for variable in variables: # for plot in plots.itervalues(): plot = plots[variable.name] createDefaultGroups(plot) if not w_qcd_mssm_method: plot.Group('W', ['W', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']) # plot.Group('Electroweak', ['Diboson', 'W']) # plot.Group('Single t', ['T_tWch', 'TBar_tWch', 'TToLeptons_sch', 'TToLeptons_tch']) # plot.Group('ZLL', ['Ztt_ZL', 'Ztt_ZJ'], style=plot.Hist('Ztt_ZL').style) if make_plots: HistDrawer.draw(plot, plot_dir='plots/' + cut.name) if variable.name in [ 'mvis', 'svfit_transverse_mass', 'svfit_mass', 'mva', 'mva2div1', 'mva1', 'mva2', 'l2_nc_ratio' ]: plot.WriteDataCard( filename='datacard_{mode}_{var}.root'.format( mode=mode, var=variable.name), dir='mt_' + cut.name, mode='UPDATE', postfix=dc_postfix) #mt = mu-tau
def makePlots(variables, cuts, total_weight, sample_dict, hist_dict, qcd_from_same_sign, w_qcd_mssm_method, mt_cut, friend_func, dc_postfix, make_plots=True, create_trees=False): ams_dict = {} sample_names = set() for cut in cuts: if qcd_from_same_sign and not 'SS' in cut.name and not w_qcd_mssm_method: cfg_main = HistogramCfg(name=cut.name, var=None, cfgs=sample_dict['samples_qcdfromss'], cut=cut.cut, lumi=int_lumi, weight=total_weight) elif w_qcd_mssm_method: cfg_main = HistogramCfg(name=cut.name, var=None, cfgs=sample_dict['samples_mssm_method'], cut=cut.cut, lumi=int_lumi, weight=total_weight) hist_dict[ 'wjets'].cut = cut.cut # since wjets is a sub-HistogramCfg else: cfg_main = HistogramCfg(name=cut.name, var=None, cfgs=sample_dict['all_samples'], cut=cut.cut, lumi=int_lumi, weight=total_weight) if qcd_from_same_sign and not 'SS' in cut.name: hist_dict['qcd'].cut = cut.cut.replace('l1_charge != l2_charge', 'l1_charge == l2_charge') if w_qcd_mssm_method: estimateQCDWMSSM(hist_dict, cut, mt_cut, friend_func=friend_func, r_qcd_os_ss=r_qcd_os_ss) cfg_main.vars = variables if qcd_from_same_sign: hist_dict[ 'qcd'].vars = variables # Can put into function but we will not want it by default if we take normalisations from e.g. high MT if w_qcd_mssm_method: hist_dict[ 'wjets'].vars = variables # Can put into function but we will not want it by default if we take normalisations from e.g. high MT hist_dict['qcd'].vars = variables hist_dict['wjets_ss'].vars = variables for variable in variables: if variable.name in [ 'svfit_mass', 'svfit_transverse_mass', 'mvis' ] and 'mssm' in mode: if cut.name in ['inclusive', 'nobtag']: variable.binning = binning_mssm elif cut.name in ['btag']: variable.binning = binning_mssm_btag if create_trees: createTrees(cfg_main, '/data1/steggema/mt/MVATrees', verbose=True) continue plots = createHistograms(cfg_main, verbose=False, friend_func=friend_func) for variable in variables: # for plot in plots.itervalues(): plot = plots[variable.name] createDefaultGroups(plot) if not w_qcd_mssm_method: plot.Group('W', ['W', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets']) plot.Group('Electroweak', ['VV', 'W']) # plot.Group('Single t', ['T_tWch', 'TBar_tWch', 'TToLeptons_sch', 'TToLeptons_tch']) plot.Group('ZTT', ['ZTT', 'ZJ'], style=plot.Hist('ZTT').style) if make_plots: HistDrawer.draw(plot, plot_dir='plots/' + cut.name) if variable.name in [ 'mvis', 'svfit_transverse_mass', 'svfit_mass', 'mva', 'mva2div1', 'mva1', 'mva2', 'l2_nc_ratio' ]: plot.WriteDataCard( filename='datacard_{mode}_{var}.root'.format( mode=mode, var=variable.name), dir='mt_' + cut.name, mode='UPDATE', postfix=dc_postfix) #mt = mu-tau for signal_hist in plot.SignalHists(): sample_names.add(signal_hist.name) ams_dict[variable.name + '__' + cut.name + '__' + signal_hist.name + '_'] = ams_hists( signal_hist.weighted, plot.BGHist().weighted) print '\nOptimisation results:' all_vals = ams_dict.items() for sample_name in sample_names: vals = [v for v in all_vals if sample_name + '_' in v[0]] vals.sort(key=itemgetter(1)) for key, item in vals: print item, key print '\nBy variable' for variable in variables: name = variable.name print '\nResults for variable', name for key, item in vals: if key.startswith(name + '__'): print item, key
name='loose_data', var=None, cfgs=samples, cut=inc_cut, lumi=int_lumi, weight=total_weight + '*( (is_data>0.5) - (abs(tau1_gen_pdgId)==15))') cfg_tight.cut = cuts[cut_name][0] cfg_loose.cut = cuts[cut_name][1] cfg_tight_data.cut = cuts[cut_name][0] cfg_loose_data.cut = cuts[cut_name][1] for cfg in [cfg_tight, cfg_loose, cfg_tight_data, cfg_loose_data]: cfg.vars = variables plots_tight = createHistograms(cfg_tight, verbose=True) plots_loose = createHistograms(cfg_loose, verbose=True) plots_tight_data = createHistograms(cfg_tight_data, verbose=True, all_stack=True) plots_loose_data = createHistograms(cfg_loose_data, verbose=True, all_stack=True) for variable in variables: plot_tight = plots_tight[variable.name] plot_loose = plots_loose[variable.name] plot_tight_data = plots_tight_data[variable.name] plot_loose_data = plots_loose_data[variable.name] for plot in [plot_tight, plot_loose, plot_tight_data, plot_loose_data]: plot.Group('VV', [ 'WWTo1L1Nu2Q', 'WZTo1L1Nu2Q', 'WZTo1L3Nu', 'WZTo2L2Q',
# cuts.append(myCut('bdt0p9' , 'bdt_score > 0.9')) cuts.append(myCut('mauro_bdt', '1.')) variables = generic_vars sample_names = set() for cut in cuts: cfg_total = HistogramCfg(name=cut.name, vars=variables, cfgs=all_samples, cut=str(cut.cut), lumi=int_lumi, weight=total_weight) plots = createHistograms( cfg_total, verbose=True, ) for variable in variables: if variable.name == 'cand_refit_tau_mass' or variable.name == 'cand_tau_mass': blindxmin = 1.777 - 0.040 blindxmax = 1.777 + 0.040 else: blindxmin = None blindxmax = None plot = plots[variable.name] # override HTT default style plot.histPref = histPref plot._ApplyPrefs() HistDrawer.draw(plot, channel='',
cut.cut & iso_cut & (charge_cut if not isSS else ~charge_cut)) # for variable in variables: cfg_total = HistogramCfg(name=cut.name, vars=variables, cfgs=all_samples_qcd, cut=str(cut.cut), lumi=int_lumi, weight=total_weight) # all_samples_qcd[-1].vars = variables if mode == 'mva_train': createTrees(cfg_total, '/data1/steggema/tt/MVATrees', verbose=True) continue plots = createHistograms(cfg_total, verbose=True, friend_func=friend_func) for variable in variables: plot = plots[variable.name] plot.Group('Single t', [ 'T_tWch', 'TBar_tWch', 'TToLeptons_tch_powheg', 'TBarToLeptons_tch_powheg' ]) # 'TToLeptons_sch', plot.Group('VV', [ 'VVTo2L2Nu', 'ZZTo2L2Q', 'WWTo1L1Nu2Q', 'WZTo1L3Nu', 'ZZTo4L', 'WZTo2L2Q', 'WZTo1L1Nu2Q', 'Single t' ]) # 'WZTo3L', # plot.Group('ZTT', ['ZTT', 'ZTT1Jets', 'ZTT2Jets', 'ZTT3Jets', 'ZTT4Jets']) # plot.Group('ZJ', ['ZJ', 'ZJ1Jets', 'ZJ2Jets', 'ZJ3Jets', 'ZJ4Jets']) # plot.Group('ZL', ['ZL', 'ZL1Jets', 'ZL2Jets', 'ZL3Jets', 'ZL4Jets']) plot.Group('W', ['WJetsToLNu', 'W1Jets', 'W2Jets', 'W3Jets', 'W4Jets'])