def test_cxx(args): reader = aleph.Reader(args.input) nev = aleph_utils.get_n_events(args.input) for i in tqdm(range(nev)): if reader.read_next_event(): e = reader.get_event() else: pinfo('no more events to read') break
def get_n_events(fname): ic = 0 info_file = fname + '.info' cobj = ConfigObj(info_file) try: ic = int(cobj['nevents']) except KeyError: print('[i] counting events in', fname) reader = aleph.Reader(fname) while reader.read_next_event(): ic += 1 cobj['nevents'] = ic cobj.write() print('[i] info file', info_file, ic) return ic
def main(): aleph_file = "/Volumes/two/data/aleph/LEP1Data1992_recons_aftercut-001.aleph" if len(sys.argv) > 1: aleph_file = sys.argv[1] if not os.path.exists(aleph_file): print('[error] {} file does not exists'.format(aleph_file)) return 0 fj.ClusterSequence.print_banner() print() all_jets = [] reader = aleph.Reader(aleph_file) nev = aleph_utils.get_n_events(aleph_file) pbar = tqdm(total=nev) partSelector = KineSelectorFactory(absetamax=2) jetSelector = KineSelectorFactory(absetamax=2, ptmin=10) fjev = FJEvent(R=0.4, algorithm=fj.antikt_algorithm, jet_selector=jetSelector, particle_selector=partSelector) rtanalysis = RT() while reader.read_next_event(): e = reader.get_event() vparts = e.get_particles_vdoubles() df = pd.DataFrame(vparts, columns=aleph.Particle.descr()) parts = fjext.vectorize_px_py_pz_e(df['px'].values, df['py'].values, df['pz'].values, df['e'].values) fjev.run_jet_finder_csaa(particles=parts, evid=e.get_header().n()) njets = len(fjev.inclusive_jets) if njets > 0: # print("njets = {} df:{}".format(njets, len(_jets_df))) _jets_df = fjev.jets_df # R_T analysis on charged tracks df_charged = df.loc[df['pwflag'] != 0] rtanalysis.process_event(df_charged, fjev.leading_pt_jet(), e.get_header().n()) pbar.update() if pbar.n > 1000: break pbar.close() all_jets = fjev.get_pandas() joblib.dump(all_jets, 'test_jets.joblib') joblib.dump(rtanalysis.get_pandas(), 'test_rt.joblib')
aleph_file = sys.argv[1] # aleph.dump(aleph_file, 2, False); # aleph.dump(aleph_file, -1, True); # 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(0.0) & fj.SelectorPtMax(200.0) & fj.SelectorAbsEtaMax(1) jet_selector = fj.SelectorPtMin(0.0) & fj.SelectorPtMax(200.0) all_jets = [] reader = aleph.Reader(aleph_file) nev = aleph_utils.get_n_events(aleph_file) pbar = tqdm(total=nev) dt_stats = [] while reader.read_next_event(): e = reader.get_event() aleph_parts = e.get_particles() pbar.update() start = time.time() old_loop(e) end = time.time() dt_old = end - start