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(80.0) & fj.SelectorPtMax( 100.0) & fj.SelectorAbsEtaMax(1) # jet_selector = fj.SelectorPtMin(40.0) & fj.SelectorPtMax(200.0) &fj.SelectorAbsEtaMax(1) print(jet_def) all_jets = [] mycfg = ['PhaseSpace:pThatMin = 80'] # mycfg = ['PhaseSpace:pThatMin = 40'] if args.ignore_mycfg: mycfg = [] pythia = pyconf.create_and_init_pythia_from_args(args, mycfg) if not pythia: perror("pythia initialization failed.") return jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 1.0) lund_gen = fjcontrib.LundGenerator(jet_def_lund) print(lund_gen.description()) dy_groomer = fjcontrib.DynamicalGroomer(jet_def_lund) print(dy_groomer.description()) # sd = fjcontrib.SoftDrop(0, 0.1, 1.0) sd = fjcontrib.SoftDrop(0, 0.2, 1.0) print(sd) # jet_def_rc01 = fj.JetDefinition(fj.cambridge_algorithm, 0.1) # jet_def_rc02 = fj.JetDefinition(fj.cambridge_algorithm, 0.2) # print (jet_def_rc01) # print (jet_def_rc02) # rc = fjcontrib.Recluster(jet_def_rc, True) jet_def_rc01 = fj.JetDefinition(fj.antikt_algorithm, 0.1) jet_def_rc02 = fj.JetDefinition(fj.antikt_algorithm, 0.2) print(jet_def_rc01) print(jet_def_rc02) #rc = fjcontrib.Recluster(jet_def_rc, True) # tw = treewriter.RTreeWriter(name = 'lsjvsx', file_name = 'leadsj_vs_x.root') tw = treewriter.RTreeWriter(name='lsjvsx', file_name='leadsj_vs_x_bias80.root') 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) partons = pythiafjext.vectorize_select(pythia, [pythiafjext.kParton], 0, True) parts = pythiafjext.vectorize_select( pythia, [pythiafjext.kFinal, pythiafjext.kCharged], 0, False) # parts = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal], 0, False) jets = jet_selector(jet_def(parts)) # for j in tqdm.tqdm(jets): for j in jets: j_type = match_dR(j, partons, jet_R0 / 2.) j_sd = sd.result(j) sd_info = fjcontrib.get_SD_jet_info(j_sd) rc_sjets01 = fj.sorted_by_pt(jet_def_rc01(j.constituents())) rc_sjets02 = fj.sorted_by_pt(jet_def_rc02(j.constituents())) tw.fill_branches( j=j, lund=[ls for ls in lund_gen.result(j)], dyg1=dy_groomer.result(j, 1), sd=j_sd, sd_z=sd_info.z, sd_mu=sd_info.mu, sd_Delta=sd_info.dR, lsjet01=rc_sjets01[0], nsjet01=len(rc_sjets01), sjet01=rc_sjets01, lsjet02=rc_sjets02[0], nsjet02=len(rc_sjets02), sjet02=rc_sjets02, ppid=j_type[0], pquark=j_type[1], pglue=j_type[2] # this is redundancy ) tw.fill_tree() pythia.stat() tw.write_and_close()
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('--nw', help="no warn", default=False, action='store_true') parser.add_argument('--ignore-mycfg', help="ignore some settings hardcoded here", default=False, action='store_true') parser.add_argument('--enable-background', help="enable background calc", default=False, action='store_true') parser.add_argument('--output', help="output file name", default='leadsj_vs_x_output.root', type=str) # for background parser.add_argument('--cent-bin', help="centraility bin 0 is the 0-5 percent most central bin", type=int, default=0) parser.add_argument('--seed', help="pr gen seed", type=int, default=1111) parser.add_argument('--harmonics', help="set harmonics flag (0 : v1 - v5) , (1 : v2 - v5) , (2: v3 - v5) , (3: v1 - v4) , (4: v1 - v3) , (5: uniform dN/dphi no harmonics) , (6 : v1 - v2 , v4 - v5) , (7 : v1 - v3 , v5) , (8 : v1 , v3 - v5) , (9 : v1 only) , (10 : v2 only) , (11 : v3 only) , (12 : v4 only) , (13 : v5 only)", type=int, default=5) parser.add_argument('--eta', help="set eta range must be uniform (e.g. abs(eta) < 0.9, which is ALICE TPC fiducial acceptance)", type=float, default=0.9) parser.add_argument('--qa', help="PrintOutQAHistos", default=False, action='store_true') parser.add_argument('--dRmax', default=0.25, type=float) parser.add_argument('--alpha', default=0, type=float) 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(args.py_pthatmin) & fj.SelectorPtMax(1000.0) & fj.SelectorAbsEtaMax(args.eta - jet_R0) # jet_selector = fj.SelectorPtMin(40.0) & fj.SelectorPtMax(200.0) &fj.SelectorAbsEtaMax(1) print(jet_def) all_jets = [] # mycfg = ['PhaseSpace:pThatMin = 80'] # mycfg = ['PhaseSpace:pThatMin = 40'] mycfg = [''] if args.ignore_mycfg: mycfg = [] pythia = pyconf.create_and_init_pythia_from_args(args, mycfg) if not pythia: perror("pythia initialization failed.") return jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 1.0) lund_gen = fjcontrib.LundGenerator(jet_def_lund) print (lund_gen.description()) dy_groomer = fjcontrib.DynamicalGroomer(jet_def_lund) print (dy_groomer.description()) # sd = fjcontrib.SoftDrop(0, 0.1, 1.0) sd01 = fjcontrib.SoftDrop(0, 0.1, 1.0) print (sd01) sd02 = fjcontrib.SoftDrop(0, 0.2, 1.0) print (sd02) # jet_def_rc01 = fj.JetDefinition(fj.cambridge_algorithm, 0.1) # jet_def_rc02 = fj.JetDefinition(fj.cambridge_algorithm, 0.2) # print (jet_def_rc01) # print (jet_def_rc02) # rc = fjcontrib.Recluster(jet_def_rc, True) jet_def_rc01 = fj.JetDefinition(fj.antikt_algorithm, 0.1) jet_def_rc02 = fj.JetDefinition(fj.antikt_algorithm, 0.2) print (jet_def_rc01) print (jet_def_rc02) #rc = fjcontrib.Recluster(jet_def_rc, True) # tw = treewriter.RTreeWriter(name = 'lsjvsx', file_name = 'leadsj_vs_x.root') tw = treewriter.RTreeWriter(name = 'lsjvsx', file_name = args.output) tgbkg = None be = None if args.enable_background: # ROOT.gSystem.Load("libpyjetty_TennGen.dylib") # tgbkg = ROOT.TennGen() # //constructor # tgbkg.SetCentralityBin(args.cent_bin) # //centraility bin 0 is the 0-5 % most central bin # tgbkg.SetRandomSeed(args.seed) # //setting the seed # tgbkg.SetHarmonics(args.harmonics) # // set harmonics flag (0 : v1 - v5) , (1 : v2 - v5) , (2: v3 - v5) , (3: v1 - v4) , (4: v1 - v3) , (5: uniform dN/dphi no harmonics) , (6 : v1 - v2 , v4 - v5) , (7 : v1 - v3 , v5) , (8 : v1 , v3 - v5) , (9 : v1 only) , (10 : v2 only) , (11 : v3 only) , (12 : v4 only) , (13 : v5 only) # tgbkg.SetEtaRange(args.eta) # //set eta range must be uniform (e.g. |eta| < 0.9, which is ALICE TPC fiducial acceptance) # tgbkg.PrintOutQAHistos(args.qa) # # tgbkg.InitializeBackground() # from pyjetty.mputils import BoltzmannEvent be = BoltzmannEvent(mean_pt=0.7, multiplicity=2000 * args.eta * 2, max_eta=max_eta, max_pt=100) print(be) from pyjetty.mputils import CEventSubtractor, CSubtractorJetByJet cs = CEventSubtractor(alpha=args.alpha, max_distance=args.dRmax, max_eta=args.eta, bge_rho_grid_size=0.25, max_pt_correct=100) print(cs) 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) partons = pythiafjext.vectorize_select(pythia, [pythiafjext.kParton], 0, True) parts = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal, pythiafjext.kCharged], 0, False) # parts = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal], 0, False) jets = jet_selector(jet_def(parts)) # for j in tqdm.tqdm(jets): for j in jets: j_type = match_dR(j, partons, jet_R0 / 2.) if j_type[0] is None: if args.nw: continue pwarning('Jet with no parton label') continue j_sd02 = sd02.result(j) sd02_info = fjcontrib.get_SD_jet_info(j_sd02) j_sd01 = sd01.result(j) sd01_info = fjcontrib.get_SD_jet_info(j_sd01) rc_sjets01 = fj.sorted_by_pt(jet_def_rc01(j.constituents())) rc_sjets02 = fj.sorted_by_pt(jet_def_rc02(j.constituents())) tw.fill_branches( j = j, lund = [ls for ls in lund_gen.result(j)], dyg1 = dy_groomer.result(j, 1), sd01 = j_sd01, sd01_z = sd01_info.z, sd01_mu = sd01_info.mu, sd01_Delta = sd01_info.dR, sd02 = j_sd02, sd02_z = sd02_info.z, sd02_mu = sd02_info.mu, sd02_Delta = sd02_info.dR, # breaking compatibility # sd = j_sd, # sd_z = sd_info.z, # sd_mu = sd_info.mu, # sd_Delta = sd_info.dR, lsjet01 = rc_sjets01[0], nsjet01 = len(rc_sjets01), sjet01 = rc_sjets01, lsjet02 = rc_sjets02[0], nsjet02 = len(rc_sjets02), sjet02 = rc_sjets02, ppid = j_type[0], pquark = j_type[1], pglue = j_type[2], # this is redundancy pycode = pythia.info.code(), pysigmagen = pythia.info.sigmaGen(), pysigmaerr = pythia.info.sigmaErr(), pyid1 = pythia.info.id1pdf(), pyid2 = pythia.info.id1pdf(), pyx1 = pythia.info.x1pdf(), pyx2 = pythia.info.x2pdf(), pypdf1 = pythia.info.pdf1(), pyQfac = pythia.info.QFac(), pyalphaS = pythia.info.alphaS(), pypthat = pythia.info.pTHat(), pymhat = pythia.info.mHat() ) if be: bg_parts = be.generate(offset=10000) full_event = bg_parts tmp = [full_event.push_back(psj) for psj in j.constituents()] if cs: cs_parts = cs.process_event(full_event) rho = cs.bge_rho.rho() bg_jets = fj.sorted_by_pt(jet_def(cs_parts)) for bj in bg_jets: if fjtools.matched_pt(bj, j) > 0.5: pass tw.fill_tree() pythia.stat() tw.write_and_close()
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__)) pyconf.add_standard_pythia_args(parser) parser.add_argument('--ignore-mycfg', help="ignore some settings hardcoded here", default=False, action='store_true') parser.add_argument('--output', help="output file name", default="test_hjet_parton.root", type=str) parser.add_argument('--no-tt', help="do not require TT to accept the event", default=False, action='store_true') parser.add_argument('--charged', help="analyze only the charged particles of the FS", default=False, action='store_true') parser.add_argument('--max-jet-pt', help="maximum jet pT to consider", type=float, default=100.) args = parser.parse_args() # print the banner first fj.ClusterSequence.print_banner() print() # set up our jet definition and a jet selector hadron_eta_max = 2.0 jet_R0 = 0.4 jet_def = fj.JetDefinition(fj.antikt_algorithm, jet_R0) jet_selector = fj.SelectorPtMin(10.0) & fj.SelectorPtMax( args.max_jet_pt) & fj.SelectorAbsEtaMax(hadron_eta_max - jet_R0) # jet_selector = fj.SelectorPtMin(40.0) & fj.SelectorPtMax(200.0) &fj.SelectorAbsEtaMax(hadron_eta_max - jet_R0) hTT6_selector = fj.SelectorPtMin(6) & fj.SelectorPtMax( 7) & fj.SelectorAbsEtaMax(hadron_eta_max) hTT12_selector = fj.SelectorPtMin(12) & fj.SelectorPtMax( 50) & fj.SelectorAbsEtaMax(hadron_eta_max) hTT20_selector = fj.SelectorPtMin(20) & fj.SelectorPtMax( 50) & fj.SelectorAbsEtaMax(hadron_eta_max) pythia_fs_part_selection = [pythiafjext.kFinal] if args.charged is True: pwarning('running with charged particles in the final state') pythia_fs_part_selection.append(pythiafjext.kCharged) print(jet_def) all_jets = [] # mycfg = ['PhaseSpace:pThatMin = 80'] # mycfg = ['PhaseSpace:pThatMin = 6'] # mycfg = ['PhaseSpace:pThatMin = 12'] # mycfg = ['PhaseSpace:pThatMin = 40'] mycfg = [] if args.ignore_mycfg: mycfg = [] pythia = pyconf.create_and_init_pythia_from_args(args, mycfg) if not pythia: perror("pythia initialization failed.") return jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 1.0) lund_gen = fjcontrib.LundGenerator(jet_def_lund) print(lund_gen.description()) dy_groomer = fjcontrib.DynamicalGroomer(jet_def_lund) print(dy_groomer.description()) # sd = fjcontrib.SoftDrop(0, 0.1, 1.0) sd = fjcontrib.SoftDrop(0, 0.2, 1.0) print(sd) # jet_def_rc01 = fj.JetDefinition(fj.cambridge_algorithm, 0.1) # jet_def_rc02 = fj.JetDefinition(fj.cambridge_algorithm, 0.2) # print (jet_def_rc01) # print (jet_def_rc02) # rc = fjcontrib.Recluster(jet_def_rc, True) jet_def_rc01 = fj.JetDefinition(fj.antikt_algorithm, 0.1) jet_def_rc02 = fj.JetDefinition(fj.antikt_algorithm, 0.2) print(jet_def_rc01) print(jet_def_rc02) #rc = fjcontrib.Recluster(jet_def_rc, True) # tw = treewriter.RTreeWriter(name = 'lsjvsx', file_name = 'leadsj_vs_x.root') tw = treewriter.RTreeWriter(name='lsjvsx', file_name=args.output) zero_psj = fj.PseudoJet(0, 0, 10, 10) if args.nev < 100: args.nev = 100 t = tqdm.tqdm(total=args.nev) while t.n < args.nev: if not pythia.next(): continue # information about the leading process # print(pythia.info.code(), pythia.info.nameProc(pythia.info.code())) # continue # parts = pythiafjext.vectorize(pythia, True, -1, 1, False) partons = pythiafjext.vectorize_select(pythia, [pythiafjext.kParton], 0, True) # parts = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal, pythiafjext.kCharged], 0, False) # parts = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal], 0, False) parts = pythiafjext.vectorize_select(pythia, pythia_fs_part_selection, 0, False) hTT6 = zero_psj hTT6s = fj.sorted_by_pt(hTT6_selector(parts)) if len(hTT6s) > 0: hTT6 = hTT6s[0] hTT12 = zero_psj hTT12s = fj.sorted_by_pt(hTT12_selector(parts)) if len(hTT12s) > 0: hTT12 = hTT12s[0] hTT20 = zero_psj hTT20s = fj.sorted_by_pt(hTT20_selector(parts)) if len(hTT20s) > 0: hTT20 = hTT20s[0] if args.no_tt is False: if hTT12.perp() < 1 and hTT6.perp() < 1 and hTT20.perp() < 1: continue jets = jet_selector(jet_def(parts)) # for j in tqdm.tqdm(jets): for j in jets: t.update(1) j_type = match_dR(j, partons, jet_R0 / 2.) if j_type[0] is None: continue j_sd = sd.result(j) sd_info = fjcontrib.get_SD_jet_info(j_sd) rc_sjets01 = fj.sorted_by_pt(jet_def_rc01(j.constituents())) rc_sjets02 = fj.sorted_by_pt(jet_def_rc02(j.constituents())) tw.fill_branches( j=j, mult=len(parts), lund=[ls for ls in lund_gen.result(j)], dyg1=dy_groomer.result(j, 1), sd=j_sd, sd_z=sd_info.z, sd_mu=sd_info.mu, sd_Delta=sd_info.dR, lsjet01=rc_sjets01[0], nsjet01=len(rc_sjets01), sjet01=rc_sjets01, lsjet02=rc_sjets02[0], nsjet02=len(rc_sjets02), sjet02=rc_sjets02, hTT6=hTT6, hTT12=hTT12, hTT20=hTT20, dphi6=j.delta_phi_to(hTT6), dphi12=j.delta_phi_to(hTT12), dphi20=j.delta_phi_to(hTT20), ppid=j_type[0], pquark=j_type[1], pglue=j_type[2], # this is redundancy pycode=pythia.info.code(), pysigmagen=pythia.info.sigmaGen(), pysigmaerr=pythia.info.sigmaErr(), pyid1=pythia.info.id1pdf(), pyid2=pythia.info.id1pdf(), pyx1=pythia.info.x1pdf(), pyx2=pythia.info.x2pdf(), pypdf1=pythia.info.pdf1(), pyQfac=pythia.info.QFac(), pyalphaS=pythia.info.alphaS(), pypthat=pythia.info.pTHat(), pymhat=pythia.info.mHat()) tw.fill_tree() t.close() pythia.stat() tw.write_and_close()
def main(): parser = argparse.ArgumentParser(description='pythia8 fastjet on the fly', prog=os.path.basename(__file__)) pyconf.add_standard_pythia_args(parser) # could use --py-seed parser.add_argument('--fj-R', help='jet finder R', default=0.8, type=float) parser.add_argument('--user-seed', help='pythia seed', default=1111, type=int) parser.add_argument('--output', default="pythia_dyngroom_test_output.root", type=str) parser.add_argument('--min-jet-pt', help='jet pt selection', default=450., type=float) parser.add_argument('--max-jet-pt', help='jet pt selection', default=1000., type=float) args = parser.parse_args() if args.user_seed < 0: args.user_seed = 1111 pinfo('user seed for pythia', args.user_seed) # mycfg = ['PhaseSpace:pThatMin = 100'] mycfg = ['Random:setSeed=on', 'Random:seed={}'.format(args.user_seed)] mycfg.append('HadronLevel:all=off') pythia = pyconf.create_and_init_pythia_from_args(args, mycfg) if args.nev < 100: args.nev = 100 # print the banner first fj.ClusterSequence.print_banner() print() # set up our jet definition and a jet selector jet_R0 = args.fj_R jet_def = fj.JetDefinition(fj.antikt_algorithm, jet_R0) print(jet_def) # hadron level - ALICE max_eta_hadron = 3. pwarning('max eta for particles after hadronization set to', max_eta_hadron) parts_selector_h = fj.SelectorAbsEtaMax(max_eta_hadron) jet_selector = fj.SelectorPtMin(args.min_jet_pt) & fj.SelectorPtMax( args.max_jet_pt) & fj.SelectorAbsEtaMax(max_eta_hadron - 1.05 * jet_R0) max_eta_parton = max_eta_hadron + 2. * jet_R0 pwarning('max eta for partons set to', max_eta_parton) parts_selector_p = fj.SelectorAbsEtaMax(max_eta_parton) outf = ROOT.TFile(args.output, 'recreate') outf.cd() t = ROOT.TTree('t', 't') tw = RTreeWriter(tree=t) jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 1.0) dy_groomer = fjcontrib.DynamicalGroomer(jet_def_lund) print(dy_groomer.description()) # event loop for iev in tqdm.tqdm(range(args.nev)): if not pythia.next(): continue # parts_pythia_p = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal], add_particle_info = True) parts_pythia_p = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal], 0, True) parts_pythia_p_selected = parts_selector_p(parts_pythia_p) hstatus = pythia.forceHadronLevel() if not hstatus: pwarning('forceHadronLevel false event', iev) continue # parts_pythia_h = pythiafjext.vectorize_select(pythia, [pythiafjext.kHadron, pythiafjext.kCharged]) # parts_pythia_h = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal], add_particle_info = True) parts_pythia_h = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal], 0, True) parts_pythia_h_selected = parts_selector_h(parts_pythia_h) jets_p = jet_selector(fj.sorted_by_pt(jet_def(parts_pythia_p))) jets_h = jet_selector(fj.sorted_by_pt(jet_def(parts_pythia_h))) for j in jets_p: tw.fill_branch('iev', iev) tw.fill_branch('parton_j', j) for a in [0.1, 1.0, 2.0]: dy_groomed = dy_groomer.result(j, a) if dy_groomed.pair().pt() > 0: tw.fill_branch('parton_j_logkt_dg{:.1f}'.format(a), ROOT.TMath.Log(dy_groomed.kt())) tw.fill_branch('parton_j_log1odR_dg{:.1f}'.format(a), ROOT.TMath.Log(1 / dy_groomed.Delta())) max_pt_groomed = dy_groomer.max_pt_softer(j) if max_pt_groomed.pair().pt() > 0: tw.fill_branch('parton_j_logkt_max_pt_softer', ROOT.TMath.Log(max_pt_groomed.kt())) tw.fill_branch('parton_j_log1odR_max_pt_softer', ROOT.TMath.Log(1 / max_pt_groomed.Delta())) max_z_groomed = dy_groomer.max_z(j) if max_z_groomed.pair().pt() > 0: tw.fill_branch('parton_j_logkt_max_z', ROOT.TMath.Log(max_z_groomed.kt())) tw.fill_branch('parton_j_log1odR_max_z', ROOT.TMath.Log(1 / max_z_groomed.Delta())) max_kt_groomed = dy_groomer.max_kt(j) if max_kt_groomed.pair().pt() > 0: tw.fill_branch('parton_j_logkt_max_kt', ROOT.TMath.Log(max_kt_groomed.kt())) tw.fill_branch('parton_j_log1odR_max_kt', ROOT.TMath.Log(1 / max_kt_groomed.Delta())) max_kappa_groomed = dy_groomer.max_kappa(j) if max_kappa_groomed.pair().pt() > 0: tw.fill_branch('parton_j_logkt_max_kappa', ROOT.TMath.Log(max_kappa_groomed.kt())) tw.fill_branch('parton_j_log1odR_max_kappa', ROOT.TMath.Log(1 / max_kappa_groomed.Delta())) for j in jets_h: tw.fill_branch('hadron_j', j) for a in [0.1, 1.0, 2.0]: dy_groomed = dy_groomer.result(j, a) if dy_groomed.pair().pt() > 0: tw.fill_branch('hadron_j_logkt_dg{:.1f}'.format(a), ROOT.TMath.Log(dy_groomed.kt())) tw.fill_branch('hadron_j_log1odR_dg{:.1f}'.format(a), ROOT.TMath.Log(1 / dy_groomed.Delta())) max_pt_groomed = dy_groomer.max_pt_softer(j) if max_pt_groomed.pair().pt() > 0: tw.fill_branch('hadron_j_logkt_max_pt_softer', ROOT.TMath.Log(max_pt_groomed.kt())) tw.fill_branch('hadron_j_log1odR_max_pt_softer', ROOT.TMath.Log(1 / max_pt_groomed.Delta())) max_z_groomed = dy_groomer.max_z(j) if max_z_groomed.pair().pt() > 0: tw.fill_branch('hadron_j_logkt_max_z', ROOT.TMath.Log(max_z_groomed.kt())) tw.fill_branch('hadron_j_log1odR_max_z', ROOT.TMath.Log(1 / max_z_groomed.Delta())) max_kt_groomed = dy_groomer.max_kt(j) if max_kt_groomed.pair().pt() > 0: tw.fill_branch('hadron_j_logkt_max_kt', ROOT.TMath.Log(max_kt_groomed.kt())) tw.fill_branch('hadron_j_log1odR_max_kt', ROOT.TMath.Log(1 / max_kt_groomed.Delta())) max_kappa_groomed = dy_groomer.max_kappa(j) if max_kappa_groomed.pair().pt() > 0: tw.fill_branch('hadron_j_logkt_max_kappa', ROOT.TMath.Log(max_kappa_groomed.kt())) tw.fill_branch('hadron_j_log1odR_max_kappa', ROOT.TMath.Log(1 / max_kappa_groomed.Delta())) if len(jets_p) > 0 or len(jets_h) > 0: tw.fill_tree() pythia.stat() outf.Write() outf.Close()
def main(): parser = argparse.ArgumentParser(description='pythia8 fastjet on the fly', prog=os.path.basename(__file__)) pyconf.add_standard_pythia_args(parser) # could use --py-seed parser.add_argument('--fj-R', help='jet finder R', default=0.8, type=float) parser.add_argument('--user-seed', help='pythia seed', default=-1, type=int) parser.add_argument('--output', default='{}.root'.format(os.path.basename(__file__)), type=str) parser.add_argument('--min-jet-pt', help='jet pt selection', default=50., type=float) parser.add_argument('--max-jet-pt', help='jet pt selection', default=1000., type=float) parser.add_argument('--npart-min', help='minimum npart in Argantyr', default=2, type=int) args = parser.parse_args() if args.user_seed < 0: args.user_seed = -1 mycfg = [] else: pinfo('user seed for pythia', args.user_seed) # mycfg = ['PhaseSpace:pThatMin = 100'] mycfg = ['Random:setSeed=on', 'Random:seed={}'.format(args.user_seed)] pythia = pyconf.create_and_init_pythia_from_args(args, mycfg) if args.nev < 100: args.nev = 100 # print the banner first fj.ClusterSequence.print_banner() print() # set up our jet definition and a jet selector jet_R0 = args.fj_R jet_def = fj.JetDefinition(fj.antikt_algorithm, jet_R0) print(jet_def) # hadron level - ALICE max_eta_hadron = 3. pwarning('max eta for particles after hadronization set to', max_eta_hadron) parts_selector_h = fj.SelectorAbsEtaMax(max_eta_hadron) jet_selector = fj.SelectorPtMin(args.min_jet_pt) & fj.SelectorPtMax( args.max_jet_pt) & fj.SelectorAbsEtaMax(max_eta_hadron - 1.05 * jet_R0) parts_selector_cent = fj.SelectorAbsEtaMax(5.) & fj.SelectorAbsEtaMin(3.) hepmc2output = '{}.hepmc2.dat'.format(args.output.replace('.root', '')) pyhepmc2writer = pythiaext.Pythia8HepMC2Wrapper(hepmc2output) outf = ROOT.TFile(args.output, 'recreate') outf.cd() t = ROOT.TTree('t', 't') tw = RTreeWriter(tree=t) tch = ROOT.TTree('tch', 'tch') twch = RTreeWriter(tree=tch) te = ROOT.TTree('te', 'te') twe = RTreeWriter(tree=te) jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 1.0) dy_groomer = fjcontrib.DynamicalGroomer(jet_def_lund) print(dy_groomer.description()) sds = [] sd01 = fjcontrib.SoftDrop(0, 0.1, 1.0) sd02 = fjcontrib.SoftDrop(0, 0.2, 1.0) sds.append(sd01) sds.append(sd02) # event loop for iev in tqdm.tqdm(range(args.nev)): if not pythia.next(): continue twe.clear() tw.clear() twch.clear() weight = pythia.info.weight() if args.py_PbPb: # from main113.cc # Also fill the number of (absorptively and diffractively) # wounded nucleaons. nw = pythia.info.hiinfo.nAbsTarg() + pythia.info.hiinfo.nDiffTarg( ) + pythia.info.hiinfo.nAbsProj() + pythia.info.hiinfo.nDiffProj() fill_ncoll_branches(pythia, twe) else: nw = 2 twe.fill_branch('nw', nw) twe.fill_branch('w', weight) parts_pythia_h = pythiafjext.vectorize_select(pythia, [pythiafjext.kFinal], 0, False) parts_pythia_h_selected = parts_selector_h(parts_pythia_h) parts_pythia_ch = pythiafjext.vectorize_select( pythia, [pythiafjext.kFinal, pythiafjext.kCharged], 0, False) parts_pythia_ch_selected = parts_selector_h(parts_pythia_ch) nch_total = len(parts_pythia_ch) twe.fill_branch('nch', nch_total) ncharged_fwd = len(parts_selector_cent(parts_pythia_ch)) twe.fill_branch('nchfwd', ncharged_fwd) twe.fill_branch('iev', iev) if args.py_PbPb and args.npart_min > nw: twe.fill_tree() continue if args.py_PbPb: pyhepmc2writer.fillEvent(pythia) # do the rest only if centrality right tw.fill_branch('iev', iev) tw.fill_branch('w', weight) twch.fill_branch('iev', iev) twch.fill_branch('w', weight) jets_h = jet_selector(fj.sorted_by_pt(jet_def(parts_pythia_h))) jets_h_ch = jet_selector(fj.sorted_by_pt(jet_def(parts_pythia_ch))) [ fill_branches(tw, j, dy_groomer, alphas=[0.1, 1.0, 2.0], sds=sds) for j in jets_h ] if len(jets_h) > 0: tw.fill_tree() if args.py_PbPb is False: pyhepmc2writer.fillEvent(pythia) [ fill_branches(twch, j, dy_groomer, alphas=[0.1, 1.0, 2.0], sds=sds) for j in jets_h_ch ] if len(jets_h_ch) > 0: twch.fill_tree() twe.fill_tree() pythia.stat() outf.Write() outf.Close()
def analyze_groomed_jet(self, grooming_setting, jet, jetR, R_max): # Check additional acceptance criteria if not self.utils.is_det_jet_accepted(jet): return jet_pt_ungroomed = jet.pt() grooming_label = self.utils.grooming_label(grooming_setting) # Construct SD groomer, and groom jet if 'sd' in grooming_setting: zcut = grooming_setting['sd'][0] beta = grooming_setting['sd'][1] sd = fjcontrib.SoftDrop(beta, zcut, jetR) jet_def_recluster = fj.JetDefinition(fj.cambridge_algorithm, jetR) reclusterer = fjcontrib.Recluster(jet_def_recluster) sd.set_reclustering(True, reclusterer) if self.debug_level > 2: print('SoftDrop groomer is: {}'.format(sd.description())) jet_sd = sd.result(jet) # Construct Dynamical groomer, and groom jet if 'dg' in grooming_setting: a = grooming_setting['dg'][0] jet_def_lund = fj.JetDefinition(fj.cambridge_algorithm, 2 * jetR) dy_groomer = fjcontrib.DynamicalGroomer(jet_def_lund) if self.debug_level > 2: print('Dynamical groomer is: {}'.format( dy_groomer.description())) jet_dg_lund = dy_groomer.result(jet, a) jet_dg = jet_dg_lund.pair() # Compute groomed observables if 'sd' in grooming_setting: # If both SD and DG are specified, first apply DG, then SD if 'dg' in grooming_setting: if jet_dg.has_constituents(): jet_groomed = sd.result(jet_dg) else: return else: jet_groomed = jet_sd sd_info = fjcontrib.get_SD_jet_info(jet_groomed) theta_g = sd_info.dR / jetR zg = sd_info.z elif 'dg' in grooming_setting: jet_groomed = jet_dg # (https://phab.hepforge.org/source/fastjetsvn/browse/contrib/contribs/LundPlane/tags/1.0.3/LundGenerator.hh) dR = jet_dg_lund.Delta() theta_g = dR / jetR zg = jet_dg_lund.z() # Fill histograms if R_max: suffix = '_Rmax{}'.format(R_max) else: suffix = '' if grooming_setting in self.obs_grooming_settings['theta_g']: getattr( self, 'h_theta_g_JetPt_R{}_{}{}'.format( jetR, grooming_label, suffix)).Fill(jet_pt_ungroomed, theta_g) if grooming_setting in self.obs_grooming_settings['zg']: getattr(self, 'h_zg_JetPt_R{}_{}{}'.format( jetR, grooming_label, suffix)).Fill(jet_pt_ungroomed, zg) # Fill jet axis difference if 'jet_axis' in self.observable_list: # Recluster with WTA (with larger jet R) jet_def_wta = fj.JetDefinition(fj.cambridge_algorithm, 2 * jetR) jet_def_wta.set_recombination_scheme(fj.WTA_pt_scheme) if self.debug_level > 2: print('WTA jet definition is:', jet_def_wta) reclusterer_wta = fjcontrib.Recluster(jet_def_wta) jet_wta = reclusterer_wta.result(jet) self.fill_jet_axis_histograms(jet, jet_groomed, jet_wta, jetR, grooming_setting, grooming_label)