class TestCuts(unittest.TestCase): def setUp(self): self.cuts = Cuts([('cut3', '300'), ('cut1', '100'), ('cut2', '200')]) def test_odict(self): '''Test the OrderedDict class to make sure it is suitable to be used for Cuts''' d = OrderedDict([('b', 1), ('a', 2), ('c', 3)]) self.assertListEqual(d.values(), [1, 2, 3]) self.assertListEqual(d.keys(), ['b', 'a', 'c']) self.assertEqual(d['c'], 3) d.pop('a') self.assertListEqual(d.keys(), ['b', 'c']) self.assertListEqual(d.values(), [1, 3]) def test_cuts(self): self.assertEqual(str(self.cuts), '300 && 100 && 200') self.cuts.pop('cut1') self.assertEqual(str(self.cuts), '300 && 200') self.cuts['cut4'] = '400' self.assertEqual(str(self.cuts), '300 && 200 && 400')
import pprint # higgs cut_gen_htautau = 'abs(genboson2_1_pdgid)==15' cut_gen_hww = 'abs(genboson2_1_pdgid)==24' cut_gen_hzz = 'abs(genboson2_1_pdgid)==23' cut_gen_hbb = 'abs(genboson2_1_pdgid)==5' cut_gen_hcc = 'abs(genboson2_1_pdgid)==4' cut_gen_hgg = 'abs(genboson2_1_pdgid)==21' from fcc_ee_higgs.plot.cuts import Cuts cuts_gen = Cuts([ ('cut_gen_htautau', cut_gen_htautau), ('cut_gen_hww', cut_gen_hww), ('cut_gen_hzz', cut_gen_hzz), ('cut_gen_hbb', cut_gen_hbb), ('cut_gen_hcc', cut_gen_hcc), ('cut_gen_hgg', cut_gen_hgg), ]) def signal_contamination(tree, cut, filename=None): nsel = float(tree.GetEntries(cut)) the_file = None results = [] for cutname, dmode in cuts_gen.iteritems(): nseldmode = tree.GetEntries('&&'.join([cut, dmode])) contamination = nseldmode / nsel * 100. the_str = '{} : {} %'.format(cutname, contamination) results.append(the_str) print the_str
deltaZZ = '(deltaZZ>10)' btag = '((hadjet1_higgsmaker*hadjet1_b + \ hadjet2_higgsmaker*hadjet2_b + hadjet3_higgsmaker*hadjet3_b + \ hadjet4_higgsmaker*hadjet4_b)==2)' mZ = '(mZedJet > 80 && mZedJet < 110)' # mZ = '(mZedJet > 82 && mZedJet < 102)' # mZ = '(mZedJet > 85 && mZedJet < 115)' mH = '(mHJet > 100)' cuts = Cuts([ ('no_lep', no_lep), ('njets', njets), ('jet_id', jet_id), ('vismass', vismass), ('chi2', chi2), ('deltaWW', deltaWW), ('deltaZZ', deltaZZ), ('btag', btag), ('mZ', mZ), # ('mH', mH), ]) if var == 'mZedJet': del cuts['mZ'] elif var == 'deltaWW': del cuts['deltaWW'] bins = 50, 0, 100 elif var == 'deltaZZ': del cuts['deltaZZ'] bins = 50, 0, 100 elif var == 'vismass':
cut_lep_nptcsnotzed = '(n_particles_not_zed>6)' cut_nophoton = '((jets_1_e<0 || jets_1_22_e/jets_1_e<0.95) && \ (jets_2_e<0 || jets_2_22_e/jets_2_e<0.95) && \ (jets_3_e<0 || jets_3_22_e/jets_3_e<0.95) && \ (jets_4_e<0 || jets_4_22_e/jets_4_e<0.95))' from fcc_ee_higgs.plot.cuts_gen import * cuts_lep = Cuts([ # ('cut_gen_ww_had', cut_gen_ww_had), ('cut_lepiso', cut_lepiso), ('cut_z_mass', cut_z_mass), ('cut_z_kine', cut_z_kine), ('cut_z_flavour', cut_z_flavour), ('cut_lep_nleps', cut_lep_nleps), ('cut_lep_njets', cut_lep_njets), # ('cut_lep_missinge', cut_lep_missinge), ('cut_nophoton', cut_nophoton), ('cut_lep_nptcsnotzed', cut_lep_nptcsnotzed), ('cut_not_hbb', cut_not_hbb), ## ('cut_nophoton', cut_nophoton) ]) cuts = cuts_lep if var == 'sel_zeds_m': del cuts['cut_z_mass'] elif var == 'missing_energy_e': bins = (50, 0, 100) del cuts['cut_lep_missinge'] cut = str(cuts)
cut_hadr_njets_lep3 = '(njets_nophoton>=4)' cut_lep_nleps = '(n_iso_leptons_not_zed>=1)' cut_lep_missinge = '(missing_energy_e>30)' cut_tau = '(n_jets==2 && missing_energy_e>50 && n_iso_leptons_not_zed==0)' ## cut_hww = '({} || {} || {})'.format(cut_hadr, cut_lep, cut_tau) ##cut_w_3body = 'abs(higgses_r_m - recoil_m)<15' from fcc_ee_higgs.plot.cuts_gen import * cuts_had = Cuts([ # ('cut_gen_ww_had', cut_gen_ww_had), ('cut_lepiso', cut_lepiso), ('cut_z_mass', cut_z_mass), ('cut_z_kine', cut_z_kine), ('cut_z_flavour', cut_z_flavour), ('cut_hadr_njets', cut_hadr_njets), ('cut_hadr_nptcs', cut_hadr_nptcs), ('cut_hadr_nolep', cut_hadr_nolep), ('cut_not_hbb', cut_not_hbb), ('cut_nophoton', cut_nophoton) ]) cuts_had_lep3 = Cuts([ # ('cut_gen_ww_had', cut_gen_ww_had), ('cut_lepiso', cut_lepiso), ('cut_z_mass', cut_z_mass), ('cut_z_kine', cut_z_kine), ('cut_z_flavour', cut_z_flavour), ('cut_hadr_njets', cut_hadr_njets_lep3), ('cut_hadr_nptcs', cut_hadr_nptcs), ('cut_hadr_nolep', cut_hadr_nolep),
cut_lepiso = '(sel_iso_leptons_1_iso_e/sel_iso_leptons_1_e<0.2 && \ sel_iso_leptons_2_iso_e/sel_iso_leptons_2_e<0.2 )' cut_lepiso_comb = '((sel_iso_leptons_1_iso_e/sel_iso_leptons_1_e + \ sel_iso_leptons_2_iso_e/sel_iso_leptons_2_e)<0.4 )' cut_tautau = '(abs(higgs_r_m-125)>15)' from fcc_ee_higgs.plot.cuts_gen import * cuts = Cuts([ ## ('cut_gen', cut_gen_htautau), ('cut_2leps', cut_2leps), ('cut_of', cut_of), ('cut_os', cut_os), ('cut_zedlep_m', cut_zedlep_m), # ('cut_zedlep_e', cut_zedlep_e), ('cut_misse', cut_misse), ('cut_zedhad_m', cut_zedhad_m), ('cut_jetid', cut_jetid_2), ('cut_lepiso', cut_lepiso_comb), ('cut_tautau', cut_tautau) ]) if var == 'zeds_m': del cuts['cut_zedhad_m'] bins = 50, 0, 150 if var == 'missing_energy_e': del cuts['cut_misse'] bins = 50, 0, 150 if var == 'zeds_lep_m': del cuts['cut_zedlep_m']
def setUp(self): self.cuts = Cuts([('cut3', '300'), ('cut1', '100'), ('cut2', '200')])
##cut_htautau_or = '(((jets_1_211_num+jets_1_11_num+jets_1_13_num)==1 || (jets_1_211_num+jets_1_11_num+jets_1_13_num)==3) || \ ## ((jets_2_211_num+jets_2_11_num+jets_2_13_num)==1 || (jets_2_211_num+jets_2_11_num+jets_2_13_num)==3))' ##cut_htautau_1 = '((jets_1_211_num+jets_1_11_num+jets_1_13_num)==1 || (jets_1_211_num+jets_1_11_num+jets_1_13_num)==3)' ##cut_missm = 'missing_energy_m/recoil_m<0.8' ##cut_rm4l = '!((second_zeds_1_pdgid==-second_zeds_2_pdgid) && (abs(second_zeds_1_pdgid)==13 || abs(second_zeds_1_pdgid)==11))' ##cut_leppt = '(zeds_1_pt>10 && zeds_2_pt>10)' cut_gen_htautau = 'abs(genboson2_1_pdgid)==15' cut_gen_hww = 'abs(genboson2_1_pdgid)==24' cut_gen_hbb = 'abs(genboson2_1_pdgid)==5' cuts = Cuts([ ('cut_zqq', cut_zqq), # ('cut_htautau', cut_htautau), ('cut_htautau_1prong', cut_htautau_1prong), ('cut_zqq_acol', cut_zqq_acol), ('cut_zqq_acol_2', cut_zqq_acol_2), ('cut_zqq_2_WW', cut_zqq_2_WW), ('cut_zqq_jets', cut_zqq_jets), # ('cut_zedll', cut_zedll) ('cut_zedll_2', cut_zedll_2), ('cut_tau_iso', cut_tau_iso), # ('cut_zqq_acop', cut_zqq_acop) # ('cut_jete_WW', cut_jete_WW) # ('cut_jetn_WW', cut_jetn_WW) # ('cut_gen_htautau', cut_gen_htautau) # ('cut_htautau_or', cut_htautau_or), # gain in precision! to investigate: try an or- nice but contamination is large of course... ]) cut = str(cuts)
##cut_missm = 'missing_energy_m/recoil_m<0.8' cut_rm4l = '!((second_zeds_1_pdgid==-second_zeds_2_pdgid) && (abs(second_zeds_1_pdgid)==13 || abs(second_zeds_1_pdgid)==11))' ##cut_leppt = '(zeds_1_pt>10 && zeds_2_pt>10)' cut_hbb = get_cut_hbb(b_wp[0], b_wp[1], ' || ') ##cut_w_misse = '(missing_energy_e<70)' cut_mvaww = '(mva > -0.4)' recoilm = '(recoil_m>110)' cut_vise = '(jets_1_e>0 && jets_2_e>0 && jets_1_e + jets_2_e>10)' cuts = Cuts([ # ('cut_lepiso', cut_lepiso), ('cut_z_mass', cut_z_mass), ('cut_z_kine', cut_z_kine), ('cut_met_angle', cut_met_angle), ('cut_z_flavour', cut_z_flavour), ('cut_rad2', cut_rad2), ('cut_rad', cut_rad), # gain in precision! to investigate: try an or- nice but contamination is large of course... ('cut_rm4l', cut_rm4l), # ('cut_mvaww', cut_mvaww), ('cut_vise', cut_vise) ]) if var == 'zeds_m' and 'cut_z_mass' in cuts: del cuts['cut_z_mass'] elif var == 'mva': del cuts['cut_mvaww'] if channel == 'bb': cuts['cut_hbb'] = cut_hbb elif channel == 'tautau':
from fcc_ee_higgs.plot.cuts import Cuts cut_missmass = '(missing_energy_m>87. && missing_energy_m<130.)' cut_h_pz = '(abs(missing_energy_pz)<50.)' cut_h_pt = '(missing_energy_pt>10.)' cut_h_acol = '(higgses_acol>100.)' cut_h_cross = '(higgses_cross>10.)' cut_ffbar_gamma = '(jets_1_22_e/jets_1_e<0.9 && jets_2_22_e/jets_2_e<0.9)' cut_ffbar_e = '(jets_1_11_e/jets_1_e<0.9 && jets_2_11_e/jets_2_e<0.9)' cut_ffbar_mu = '(jets_1_13_e/jets_1_e<0.9 && jets_2_13_e/jets_2_e<0.9)' cut_ffbar_hpm = '(jets_1_211_num>3. && jets_2_211_num>3.)' cuts = Cuts([ ('cut_hbb', cut_hbb), ('cut_h_pz', cut_h_pz), ('cut_h_pt', cut_h_pt), ('cut_h_acol', cut_h_acol), ('cut_h_cross', cut_h_cross), ('cut_missmass', cut_missmass), ('cut_ffbar_hpm', cut_ffbar_hpm), ## ('cut_ffbar_gamma', cut_ffbar_gamma), ## ('cut_ffbar_e', cut_ffbar_e), ## ('cut_ffbar_mu', cut_ffbar_mu), ]) if var == 'missing_energy_m': del cuts['cut_missmass'] cut = str(cuts)
cut_not_hbb = '!({})'.format(cut_hbb) cut_w_misse = '(missing_energy_e<70)' cut_w_4body = 'abs(higgses_r_m - recoil_m)<15' from fcc_ee_higgs.plot.cuts_gen import cut_gen_htautau ZH.xSection *= 1.04 cuts = Cuts([ # ('cut_gen_htautau', cut_gen_htautau), ('cut_lepiso', cut_lepiso), ('cut_z_mass', cut_z_mass), ('cut_z_kine', cut_z_kine), ('cut_z_flavour', cut_z_flavour), # ('cut_rad2', cut_rad2), # ('cut_rad', cut_rad), ('cut_htautau', cut_htautau), # ('cut_htautau_or', cut_htautau_or), # gain in precision! to investigate: try an or- nice but contamination is large of course... ('cut_rm4l', cut_rm4l), # ('cut_w_misse', cut_w_misse) ('cut_w_4body', cut_w_4body), ('cut_not_hbb', cut_not_hbb) ]) if var == 'sel_zeds_m': del cuts['cut_z_mass'] elif var == 'higgses_r_m - recoil_m': del cuts['cut_w_3body'] bins = 50, -200, 200 cut = str(cuts)
cut_notau = '!(\ (sel_iso_taus_0_e>0 && sel_iso_taus_0_iso_e/sel_iso_taus_0_e<0.2) || \ (sel_iso_taus_1_e>0 && sel_iso_taus_1_iso_e/sel_iso_taus_1_e<0.2) || \ (sel_iso_taus_2_e>0 && sel_iso_taus_2_iso_e/sel_iso_taus_2_e<0.2) || \ (sel_iso_taus_3_e>0 && sel_iso_taus_3_iso_e/sel_iso_taus_3_e<0.2) \ )' def get_cut_notau(): strings = [] for i in range(4): strings.append('(n_sel_iso_taus<={i} || sel_iso_taus_{i}_iso_e/sel_iso_taus_{i}_e<0.2)'.format(i=i)) return ' && '.join(strings) ##cut_notau = get_cut_notau() cuts = Cuts([ ('cut_missmass', cut_missmass), ('cut_misse', cut_misse), ('cut_theta', cut_theta), ('cut_mwstar', cut_mwstar), ('cut_jete', cut_jete), ('cut_not_hbb', cut_not_hbb), ('cut_higgs_acol', cut_higgs_acol), ('cut_notau', cut_notau) ]) cut = str(cuts) # cut = ''