def process_mc(self): self.start_time = time.time() # ------------------------------------------------------------------------ # Use IO helper class to convert detector-level ROOT TTree into # a SeriesGroupBy object of fastjet particles per event print('--- {} seconds ---'.format(time.time() - self.start_time)) if self.fast_simulation: tree_dir = '' else: tree_dir = 'PWGHF_TreeCreator' io_det = process_io.ProcessIO(input_file=self.input_file, tree_dir=tree_dir, track_tree_name='tree_Particle', use_ev_id_ext=False, is_jetscape=self.jetscape, event_plane_range=self.event_plane_range) df_fjparticles_det = io_det.load_data( m=self.m, reject_tracks_fraction=self.reject_tracks_fraction) self.nEvents_det = len(df_fjparticles_det.index) self.nTracks_det = len(io_det.track_df.index) print('--- {} seconds ---'.format(time.time() - self.start_time)) # If jetscape, store also the negative status particles (holes) if self.jetscape: io_det_holes = process_io.ProcessIO( input_file=self.input_file, tree_dir=tree_dir, track_tree_name='tree_Particle', use_ev_id_ext=False, is_jetscape=self.jetscape, holes=True, event_plane_range=self.event_plane_range) df_fjparticles_det_holes = io_det_holes.load_data( m=self.m, reject_tracks_fraction=self.reject_tracks_fraction) self.nEvents_det_holes = len(df_fjparticles_det_holes.index) self.nTracks_det_holes = len(io_det_holes.track_df.index) print('--- {} seconds ---'.format(time.time() - self.start_time)) # ------------------------------------------------------------------------ # Use IO helper class to convert truth-level ROOT TTree into # a SeriesGroupBy object of fastjet particles per event io_truth = process_io.ProcessIO( input_file=self.input_file, tree_dir=tree_dir, track_tree_name='tree_Particle_gen', use_ev_id_ext=False, is_jetscape=self.jetscape, event_plane_range=self.event_plane_range) df_fjparticles_truth = io_truth.load_data(m=self.m) self.nEvents_truth = len(df_fjparticles_truth.index) self.nTracks_truth = len(io_truth.track_df.index) print('--- {} seconds ---'.format(time.time() - self.start_time)) # If jetscape, store also the negative status particles (holes) if self.jetscape: io_truth_holes = process_io.ProcessIO( input_file=self.input_file, tree_dir=tree_dir, track_tree_name='tree_Particle_gen', use_ev_id_ext=False, is_jetscape=self.jetscape, holes=True, event_plane_range=self.event_plane_range) df_fjparticles_truth_holes = io_truth_holes.load_data( m=self.m, reject_tracks_fraction=self.reject_tracks_fraction) self.nEvents_truth_holes = len(df_fjparticles_truth_holes.index) self.nTracks_truth_holes = len(io_truth_holes.track_df.index) print('--- {} seconds ---'.format(time.time() - self.start_time)) # ------------------------------------------------------------------------ # Now merge the two SeriesGroupBy to create a groupby df with [ev_id, run_number, fj_1, fj_2] # (Need a structure such that we can iterate event-by-event through both fj_1, fj_2 simultaneously) # In the case of jetscape, we merge also the hole collections fj_3, fj_4 print( 'Merge det-level and truth-level into a single dataframe grouped by event...' ) if self.jetscape: self.df_fjparticles = pandas.concat([ df_fjparticles_det, df_fjparticles_truth, df_fjparticles_det_holes, df_fjparticles_truth_holes ], axis=1) self.df_fjparticles.columns = [ 'fj_particles_det', 'fj_particles_truth', 'fj_particles_det_holes', 'fj_particles_truth_holes' ] else: self.df_fjparticles = pandas.concat( [df_fjparticles_det, df_fjparticles_truth], axis=1) self.df_fjparticles.columns = [ 'fj_particles_det', 'fj_particles_truth' ] print('--- {} seconds ---'.format(time.time() - self.start_time)) # ------------------------------------------------------------------------ # Set up the Pb-Pb embedding object if not self.is_pp and not self.thermal_model: self.process_io_emb = process_io_emb.ProcessIO_Emb( self.emb_file_list, track_tree_name='tree_Particle', m=self.m) # ------------------------------------------------------------------------ # Initialize histograms if not self.dry_run: self.initialize_output_objects() # Create constituent subtractor, if configured if self.do_constituent_subtraction: self.constituent_subtractor = [ CEventSubtractor( max_distance=R_max, alpha=self.alpha, max_eta=self.max_eta, bge_rho_grid_size=self.bge_rho_grid_size, max_pt_correct=self.max_pt_correct, ghost_area=self.ghost_area, distance_type=fjcontrib.ConstituentSubtractor.deltaR) for R_max in self.max_distance ] print(self) # Find jets and fill histograms print('Find jets...') self.analyze_events() # Plot histograms print('Save histograms...') process_base.ProcessBase.save_output_objects(self) print('--- {} seconds ---'.format(time.time() - self.start_time))
def process_demo(self): # Use IO helper class to convert detector-level ROOT TTree into # a SeriesGroupBy object of fastjet particles per event tree_dir = 'PWGHF_TreeCreator' event_tree_name = 'tree_event_char' io_det = process_io.ProcessIO(input_file=self.input_file_Pythia, tree_dir=tree_dir, track_tree_name='tree_Particle', event_tree_name=event_tree_name, is_pp=True, min_cent=0., max_cent=10., use_ev_id_ext=False) df_fjparticles_det = io_det.load_data(reject_tracks_fraction=0.) self.nEvents_det = len(df_fjparticles_det.index) self.nTracks_det = len(io_det.track_df.index) print('nEvents in detector-level PYTHIA: {}'.format(self.nEvents_det)) print('nTracks in detector-level PYTHIA: {}'.format(self.nTracks_det)) # ------------------------------------------------------------------------ # Use IO helper class to convert truth-level ROOT TTree into # a SeriesGroupBy object of fastjet particles per event io_truth = process_io.ProcessIO(input_file=self.input_file_Pythia, tree_dir=tree_dir, track_tree_name='tree_Particle_gen', event_tree_name=event_tree_name, is_pp=True, use_ev_id_ext=False) df_fjparticles_truth = io_truth.load_data() self.nEvents_truth = len(df_fjparticles_truth.index) self.nTracks_truth = len(io_truth.track_df.index) print('nEvents in truth-level PYTHIA: {}'.format(self.nEvents_truth)) print('nTracks in truth-level PYTHIA: {}'.format(self.nTracks_truth)) # ------------------------------------------------------------------------ # Now merge the two SeriesGroupBy to create a groupby df with [ev_id, run_number, fj_1, fj_2] # (Need a structure such that we can iterate event-by-event through both fj_1, fj_2 simultaneously) print( 'Merge det-level and truth-level into a single dataframe grouped by event...' ) self.df_fjparticles = pandas.concat( [df_fjparticles_det, df_fjparticles_truth], axis=1) self.df_fjparticles.columns = [ 'fj_particles_det', 'fj_particles_truth' ] print(self.df_fjparticles) # ------------------------------------------------------------------------ # Set up the Pb-Pb embedding object self.process_io_emb = process_io_emb.ProcessIO_Emb( self.emb_file_list, track_tree_name='tree_Particle', min_cent=0., max_cent=10.) # ------------------------------------------------------------------------ self.analyze_events()