def make_data_tuple(event): vector_list = [] for jet in event['jets']: vec = LV.from_ptetaphie( jet['vbf_candidates_pT'], jet['vbf_candidates_eta'], jet['vbf_candidates_phi'], jet['vbf_candidates_E'] ) vector_list.append(vec) return( prepare_tuple(vector_list) )
marker='.', color='green') #_plots['rocs'].add_marker('mjjmax', 1000, annotation='1000 GeV', marker='.', color='blue') #_plots['rocs_2jet'].add_marker('mjjSL', 735, annotation='735 GeV', marker='*', color='red') #_plots['rocs_3jet'].add_marker('mjjSL', 735, annotation='735 GeV', marker='*', color='red') _output_branches = [ 'run_number', 'event_number', 'mc_sf', 'ntag', 'njets', 'n_vbf_candidates', ('jets', [ 'vbf_candidates_E', 'vbf_candidates_pT', 'vbf_candidates_eta', 'vbf_candidates_phi' ]) ] _output_branches += [f'FoxWolfram{i}' for i in _fw_moments] make_reco_vector = lambda jet: LV.from_ptetaphie(jet['resolvedJets_pt'], jet[ 'resolvedJets_eta'], jet['resolvedJets_phi'], jet['resolvedJets_E']) make_nano_vector = lambda jet: LV.from_ptetaphie(jet['vbf_candidates_pT'], jet[ 'vbf_candidates_eta'], jet['vbf_candidates_phi'], jet['vbf_candidates_E']) def process_events(events, skip_num=0, bgd=False, cvv_value=-1): basic_efficiency_count = [0, 0, 0] num_jets = [0] * 20 num_shared = 0 num_not_shared = 0 num_pt_matched = 0 num_pt_not_matched = 0 num_negative_weighted = 0 for event_index, event in enumerate(events): if event_index < skip_num: continue weight = event['mc_sf'][0]
'nresolvedJets', ( 'resolved_jets', [ 'resolvedJets_pt', 'resolvedJets_phi', 'resolvedJets_eta', 'resolvedJets_E', #resolved pt in GeV 'resolvedJets_HadronConeExclTruthLabelID', 'resolvedJets_is_DL1r_FixedCutBEff_77' ]) ] _output_branches = ['event_number'] make_reco_vector = lambda jet: LV.from_ptetaphie(jet['resolvedJets_pt'], jet[ 'resolvedJets_eta'], jet['resolvedJets_phi'], jet['resolvedJets_E']) def get_vbf_jet_info(non_b_tagged_jets): vbf_jet_info = {'x': [], 'y': [], 'c': []} if len(non_b_tagged_jets) > 1: mjj_pair = max([ ((pair[0] + pair[1]).mass, pair) for pair in itertools.combinations(non_b_tagged_jets, 2) ])[1] color = 'white' if abs(mjj_pair[0].eta - mjj_pair[1].eta) > 3 else 'black' vbf_jet_info['x'] = [mjj_pair[0].eta, mjj_pair[1].eta] vbf_jet_info['y'] = [mjj_pair[0].phi, mjj_pair[1].phi] vbf_jet_info['c'] = [color, color] return vbf_jet_info
import itertools from uproot_methods import TLorentzVector as LV _fourvec_names = [ f'vbf_candidates_{v}' for v in ['pT', 'eta', 'phi', 'E'] ] make_vector_list = lambda datarow: [ LV.from_ptetaphie(*vec) for vec in zip(*datarow[_fourvec_names]) ] def valid_vbf(datarow): vector_list = make_vector_list(datarow) Deta = max([ ( (i+j).mass, abs(i.eta-j.eta) ) for i,j in itertools.combinations(vector_list, 2) ])[1] return Deta > 3 def get_features_mjj_deta(datarow): vector_list = make_vector_list(datarow) pair_list = [ (i,j) for i,j in itertools.combinations(vector_list, 2) ] if len(pair_list) > 0: mjj_deta_pair_list = [ ( (i+j).mass, abs(i.eta-j.eta) ) for i,j in pair_list] mjj_deta_pair_list.sort(reverse=True) prepared_features = [ mjj_deta_pair_list[0][0], mjj_deta_pair_list[0][1] ] else: prepared_features = [-1,-1] return prepared_features