def main(): parser = argparse.ArgumentParser(description='pythia8 fastjet on the fly', prog=os.path.basename(__file__)) pyconf.add_standard_pythia_args(parser) args = parser.parse_args() # print the banner first fj.ClusterSequence.print_banner() print() # set up our jet definition and a jet selector jet_R0 = 0.4 jet_def = fj.JetDefinition(fj.antikt_algorithm, jet_R0) jet_selector = fj.SelectorPtMin(5.0) & fj.SelectorAbsEtaMax(2) print(jet_def) all_jets = [] # mycfg = ['PhaseSpace:pThatMin = 100'] mycfg = [] pythia = pyconf.create_and_init_pythia_from_args(args, mycfg) if args.nev < 100: args.nev = 100 for i in tqdm.tqdm(range(args.nev)): if not pythia.next(): continue parts = pythiafjext.vectorize(pythia, True, -1, 1, False) jets = jet_selector(jet_def(parts)) all_jets.extend(jets) pythia.stat() jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 1.0) lund_gen = fjcontrib.LundGenerator(jet_def_lund) print('making lund diagram for all jets...') lunds = [lund_gen.result(j) for j in all_jets] print('listing lund plane points... Delta, kt - for {} selected jets'.format(len(all_jets))) for l in lunds: print ('- jet pT={0:5.2f} eta={1:5.2f}'.format(l[0].pair().perp(), l[0].pair().eta())) print (' Deltas={}'.format([s.Delta() for s in l])) print (' kts={}'.format([s.Delta() for s in l])) print ( ) print('[i] reclustering and using soft drop...') jet_def_rc = fj.JetDefinition(fj.cambridge_algorithm, 1.0) print('Reclustering:', jet_def_rc) rc = fjcontrib.Recluster(jet_def_rc, True) sd = fjcontrib.SoftDrop(0, 0.1, 1.0) for i,j in enumerate(all_jets): j_rc = rc.result(j) print() print('- [{0:3d}] orig pT={1:10.3f} reclustered pT={2:10.3f}'.format(i, j.perp(), j_rc.perp())) j_sd = sd.result(j) print(' |-> after soft drop pT={0:10.3f} delta={1:10.3f}'.format(j_sd.perp(), j_sd.perp() - j.perp())) sd_info = fjcontrib.get_SD_jet_info(j_sd) print(" |-> SD jet params z={0:10.3f} dR={1:10.3f} mu={2:10.3f}".format(sd_info.z, sd_info.dR, sd_info.mu))
pythia = create_and_init_pythia(sconfig_pythia) # print the banner first fj.ClusterSequence.print_banner() print() # set up our jet definition and a jet selector jet_R0 = 0.4 jet_def = fj.JetDefinition(fj.antikt_algorithm, jet_R0) jet_selector = fj.SelectorPtMin(100.0) & fj.SelectorPtMax( 200.0) & fj.SelectorAbsEtaMax(1) sd = fjcontrib.SoftDrop(0, 0.1, 1.0) all_jets = [] for iEvent in tqdm(range(10), 'event'): if not pythia.next(): continue parts = pyfj.vectorize(pythia, True, -1, 1, False) jets = jet_selector(jet_def(parts)) all_jets.extend(jets) all_sd_jets = [sd.result(j) for j in all_jets] pts = [j.pt() for j in all_jets] sd_pts = [j.pt() for j in all_sd_jets] sd_delta_pt = [delta for delta in deltas(all_jets, all_sd_jets)] nangs0 = [pyfj.angularity(j, 0.) for j in all_jets] jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 1.0) lund_gen = fjcontrib.LundGenerator(jet_def_lund) lunds = [lund_gen.result(j) for j in all_jets] print('listing lund plane points... Delta, kt - for {} selected jets'.format( len(all_jets)))
fj.ClusterSequence.print_banner() print() # set up our jet definition and a jet selector jet_R0 = 0.4 jet_def = fj.JetDefinition(fj.antikt_algorithm, jet_R0) jet_selector = fj.SelectorPtMin(100.0) & fj.SelectorPtMax( 200.0) & fj.SelectorAbsEtaMax(1) sd = fjcontrib.SoftDrop(0, 0.1, 1.0) all_jets = [] all_jets_py = [] all_parts = [] for iEvent in tqdm(range(1000), 'event'): if not pythia.next(): continue parts = pythiafjext.vectorize(pythia, True, -1, 1, False) all_parts.append(fjpsj.pyfj_list(parts)) jets = fj.sorted_by_pt(jet_selector(jet_def(parts))) ev_jets_py = [] for idx, j in enumerate(jets): j.set_user_index(idx) jpy = fjpsj.pyfj_from_psj(j) ev_jets_py.append(jpy) all_jets_py.append(ev_jets_py) all_jets.extend(jets) print('found jets:', len(all_jets), len(all_jets_py)) joblib.dump(all_jets_py, 'testing.joblib') # print_jets(all_jets_py) read_jets = joblib.load('testing.joblib') # print_jets(read_jets)
def main(): parser = argparse.ArgumentParser(description='pythia8 fastjet on the fly', prog=os.path.basename(__file__)) pyconf.add_standard_pythia_args(parser) parser.add_argument('--ignore-mycfg', help="ignore some settings hardcoded here", default=False, action='store_true') args = parser.parse_args() # print the banner first fj.ClusterSequence.print_banner() print() # set up our jet definition and a jet selector jet_R0 = 0.4 jet_def = fj.JetDefinition(fj.antikt_algorithm, jet_R0) jet_selector = fj.SelectorPtMin(100.0) & fj.SelectorAbsEtaMax(1) print(jet_def) all_jets = [] mycfg = ['PhaseSpace:pThatMin = 100'] if args.ignore_mycfg: mycfg = [] pythia = pyconf.create_and_init_pythia_from_args(args, mycfg) if not pythia: print("[e] pythia initialization failed.") return if args.nev < 100: args.nev = 100 for i in tqdm.tqdm(range(args.nev)): if not pythia.next(): continue parts = pythiafjext.vectorize(pythia, True, -1, 1, False) jets = jet_selector(jet_def(parts)) all_jets.extend(jets) pythia.stat() jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 1.0) lund_gen = fjcontrib.LundGenerator(jet_def_lund) print('making lund diagram for all jets...', lund_gen.description()) lunds = [lund_gen.result(j) for j in all_jets] print( 'listing lund plane points... Delta, kt - for {} selected jets'.format( len(all_jets))) for l in lunds: print('- jet pT={0:5.2f} eta={1:5.2f}'.format(l[0].pair().perp(), l[0].pair().eta())) print(' Deltas={}'.format([s.Delta() for s in l])) print(' kts={}'.format([s.kt() for s in l])) print() dy_groomer = fjcontrib.DynamicalGroomer(jet_def_lund) print(dy_groomer.description()) dy_groomed = [dy_groomer.result(j, 2) for j in all_jets] print('listing results from dynamical grooming...') for l in dy_groomed: print(l, ' kt={}'.format(l.kt())) for j in all_jets: rdyng2 = dy_groomer.result(j, 2) rdyng1 = dy_groomer.result(j, 1) print('jet', j) print('- all splits kts:', sorted([s.kt() for s in dy_groomer.lund_splits()], reverse=True)) print('- dynG kt a=1:', rdyng1.kt(), 'a=2:', rdyng2.kt()) print() return print('[i] reclustering and using soft drop...') jet_def_rc = fj.JetDefinition(fj.cambridge_algorithm, 0.1) print('Reclustering:', jet_def_rc) rc = fjcontrib.Recluster(jet_def_rc, True) sd = fjcontrib.SoftDrop(0, 0.1, 1.0) for i, j in enumerate(all_jets): j_rc = rc.result(j) print() print('- [{0:3d}] orig pT={1:10.3f} reclustered pT={2:10.3f}'.format( i, j.perp(), j_rc.perp())) j_sd = sd.result(j) print(' |-> after soft drop pT={0:10.3f} delta={1:10.3f}'.format( j_sd.perp(), j_sd.perp() - j.perp())) sd_info = fjcontrib.get_SD_jet_info(j_sd) print( " |-> SD jet params z={0:10.3f} dR={1:10.3f} mu={2:10.3f}".format( sd_info.z, sd_info.dR, sd_info.mu))
def main(): parser = argparse.ArgumentParser(description='pythia8 fastjet on the fly', prog=os.path.basename(__file__)) parser.add_argument('-o', '--output', help='output file name', default='pythia_lund_sd.root', type=str) pyconf.add_standard_pythia_args(parser) args = parser.parse_args() # print the banner first fj.ClusterSequence.print_banner() print() # set up our jet definition and a jet selector jet_R0 = 0.4 jet_def = fj.JetDefinition(fj.antikt_algorithm, jet_R0) jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 1.0) lund_gen = fjcontrib.LundGenerator(jet_def_lund) sd = fjcontrib.SoftDrop(0, 0.1, 1.0) jet_selector = fj.SelectorPtMin(10) & fj.SelectorAbsEtaMax(1) print(jet_def) fout = r.TFile(args.output, 'RECREATE') fout.cd() tnjets = r.TNtuple('jets', 'jets', 'iev:nj:pt:eta:phi:f5:f6:f5dR:f6dR:proc:xsec') tnjets_sd = r.TNtuple('jets_sd', 'jets_sd', 'iev:nj:pt:f5:f6:f5dR:f6dR:proc:xsec:pt_sd:z:dR:mu') tnlund = r.TNtuple('lund', 'lund', "iev:nj:pt:f5:f6:f5dR:f6dR:ns:pts:delta:kt") nbins = 20 lbins = logbins(10, 500, nbins) hjpt = r.TH1F('hjpt', 'hjpt', nbins, lbins) hjptq = r.TH1F('hjptq', 'hjptq', nbins, lbins) hjptg = r.TH1F('hjptg', 'hjptg', nbins, lbins) hjptsd = r.TH1F('hjptsd', 'hjptsd', nbins, lbins) hjptsdq = r.TH1F('hjptsdq', 'hjptsdq', nbins, lbins) hjptsdg = r.TH1F('hjptsdg', 'hjptsdg', nbins, lbins) hjptsdkt10 = r.TH1F('hjptsdkt10', 'hjptsdkt10', nbins, lbins) hjptsdqkt10 = r.TH1F('hjptsdqkt10', 'hjptsdqkt10', nbins, lbins) hjptsdgkt10 = r.TH1F('hjptsdgkt10', 'hjptsdgkt10', nbins, lbins) hjptsdkt30 = r.TH1F('hjptsdkt30', 'hjptsdkt30', nbins, lbins) hjptsdqkt30 = r.TH1F('hjptsdqkt30', 'hjptsdqkt30', nbins, lbins) hjptsdgkt30 = r.TH1F('hjptsdgkt30', 'hjptsdgkt30', nbins, lbins) hjptktsd = r.TH2F('hjptktsd', 'hjptktsd', 50, 0, 500, 50, 0, 500) mycfg = [] pythia = pyconf.create_and_init_pythia_from_args(args, mycfg) if args.nev < 100: args.nev = 100 for i in tqdm.tqdm(range(args.nev)): if not pythia.next(): continue parts = pythiafjext.vectorize(pythia, True, -2, 2, False) jets = fj.sorted_by_pt(jet_selector(jet_def(parts))) f5 = pythia.event[5] f6 = pythia.event[6] f5psj = fj.PseudoJet(f5.px(), f5.py(), f5.pz(), f5.e()) f6psj = fj.PseudoJet(f6.px(), f6.py(), f6.pz(), f6.e()) iproc = pythia.info.code() xsec = pythia.info.sigmaGen() for nj, j in enumerate(jets): f5dR = f5psj.delta_R(j) f6dR = f6psj.delta_R(j) tnjets.Fill(i, nj, j.pt(), j.eta(), j.phi(), f5.id(), f6.id(), f5dR, f6dR, iproc, xsec) lund = lund_gen.result(j) for ns, s in enumerate(lund): tnlund.Fill(i, nj, j.pt(), f5.id(), f6.id(), f5dR, f6dR, ns, s.pair().perp(), s.Delta(), s.kt()) j_sd = sd.result(j) sd_info = fjcontrib.get_SD_jet_info(j_sd) tnjets_sd.Fill(i, nj, j.pt(), f5.id(), f6.id(), f5dR, f6dR, iproc, xsec, j_sd.pt(), sd_info.z, sd_info.dR, sd_info.mu) # fill the histograms f = None if f5dR < 0.4: f = f5 if f6dR < 0.4: f = f6 if f is not None: kt = sd_info.z * j_sd.perp() hjpt.Fill(j.pt()) if sd_info.z >= 0: hjptsd.Fill(j.pt()) if kt > 10: hjptsdkt10.Fill(j.pt()) if kt > 30: hjptsdkt30.Fill(j.pt()) if f.id() != 21: hjptq.Fill(j.pt()) if sd_info.z >= 0: hjptsdq.Fill(j.pt()) if kt > 10: hjptsdqkt10.Fill(j.pt()) if kt > 30: hjptsdqkt30.Fill(j.pt()) else: hjptg.Fill(j.pt()) if sd_info.z >= 0: hjptsdg.Fill(j.pt()) if kt > 10: hjptsdgkt10.Fill(j.pt()) if kt > 30: hjptsdgkt30.Fill(j.pt()) pythia.stat() fout.cd() hjptq_r = hjptq.Clone('hjptq_r') hjptq_r.Sumw2() hjptq_r.Divide(hjpt) hjptg_r = hjptg.Clone('hjptg_r') hjptg_r.Sumw2() hjptg_r.Divide(hjpt) hjptsdq_r = hjptsdq.Clone('hjptsdq_r') hjptsdq_r.Sumw2() hjptsdq_r.Divide(hjptsd) hjptsdg_r = hjptsdg.Clone('hjptsdg_r') hjptsdg_r.Sumw2() hjptsdg_r.Divide(hjptsd) hjptsdqkt10_r = hjptsdqkt10.Clone('hjptsdqkt10_r') hjptsdqkt10_r.Sumw2() hjptsdqkt10_r.Divide(hjptsdkt10) hjptsdgkt10_r = hjptsdgkt10.Clone('hjptsdgkt10_r') hjptsdgkt10_r.Sumw2() hjptsdgkt10_r.Divide(hjptsdkt10) hjptsdqkt30_r = hjptsdqkt30.Clone('hjptsdqkt30_r') hjptsdqkt30_r.Sumw2() hjptsdqkt30_r.Divide(hjptsdkt30) hjptsdgkt30_r = hjptsdgkt30.Clone('hjptsdgkt30_r') hjptsdgkt30_r.Sumw2() hjptsdgkt30_r.Divide(hjptsdkt30) fout.Write() fout.Close()