def process_ang_data(self): start_time = time.time() # Use IO helper class to convert ROOT TTree into a SeriesGroupBy object # of fastjet particles per event print('--- {} seconds ---'.format(time.time() - start_time)) io = process_io.ProcessIO(input_file=self.input_file, track_tree_name='tree_Particle') self.df_fjparticles = io.load_data(m=self.track_mass, random_mass=self.track_random_mass) self.nEvents = len(self.df_fjparticles.index) self.nTracks = len(io.track_df.index) print('--- {} seconds ---'.format(time.time() - start_time)) # Initialize configuration and histograms self.initialize_config() self.initializeHistograms() print(self) # Find jets and fill histograms print('Find jets...') self.analyzeEvents() # Plot histograms print('Save histograms...') process_base.ProcessBase.save_output_objects(self) print('--- {} seconds ---'.format(time.time() - start_time))
def init_df(self): # Use IO helper class to convert truth-level ROOT TTree into # a SeriesGroupBy object of fastjet particles per event self.io = process_io.ProcessIO(input_file=self.input_file, output_dir=self.output_dir, tree_dir='PWGHF_TreeCreator', track_tree_name='tree_Particle_gen') self.df_fjparticles = self.io.load_dataframe() self.nTracks_truth = len(self.df_fjparticles) print("DataFrame loaded from data.") print(self.df_fjparticles) # Initialize a list of histograms to be written to file self.hist_list = []
def load_file(self): input_file = random.choice(self.list_of_files) if self.remove_used_file: self.list_of_files.remove(input_file) print('Opening Pb-Pb file: {}'.format(input_file)) io = process_io.ProcessIO(input_file=input_file, track_tree_name=self.track_tree_name, is_pp=self.is_pp, min_cent=self.min_centrality, max_cent=self.max_centrality, use_ev_id_ext=self.use_ev_id_ext) self.current_file_df = io.load_data(m=self.m, offset_indices=True) self.current_file_nevents = len(self.current_file_df.index) self.current_event_index = 0
def process_data(self): self.start_time = time.time() # Use IO helper class to convert ROOT TTree into a SeriesGroupBy object of fastjet particles per event print('--- {} seconds ---'.format(time.time() - self.start_time)) io = process_io.ProcessIO(input_file=self.input_file, track_tree_name='tree_Particle', is_pp=self.is_pp, use_ev_id_ext=True) self.df_fjparticles = io.load_data(m=self.m) self.nEvents = len(self.df_fjparticles.index) self.nTracks = len(io.track_df.index) print('--- {} seconds ---'.format(time.time() - self.start_time)) # Initialize histograms self.initialize_output_objects() # Create constituent subtractor, if configured if not self.is_pp: 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('Analyze events...') 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_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_ang_mc(self): start_time = time.time() # Initialize configuration self.initialize_config() # ------------------------------------------------------------------------ # Use IO helper class to convert detector-level ROOT TTree into # a SeriesGroupBy object of fastjet particles per event print('--- {} seconds ---'.format(time.time() - start_time)) io_det = process_io.ProcessIO( input_file=self.input_file, tree_dir="", track_tree_name="tree_Particle", event_tree_name="tree_event_char", use_ev_id_ext=False) df_fjparticles_det = io_det.load_data( m=self.track_mass, reject_tracks_fraction=self.reject_tracks_fraction, random_mass=self.track_random_mass) self.nEvents_det = len(df_fjparticles_det.index) self.nTracks_det = len(io_det.track_df.index) print('--- {} seconds ---'.format(time.time() - 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="", track_tree_name="tree_Particle_gen", event_tree_name="tree_event_char", use_ev_id_ext=False) df_fjparticles_truth = io_truth.load_data(m=self.track_mass, random_mass=self.track_random_mass) self.nEvents_truth = len(df_fjparticles_truth.index) self.nTracks_truth = len(io_truth.track_df.index) print('--- {} seconds ---'.format(time.time() - 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) 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('--- {} seconds ---'.format(time.time() - start_time)) # ------------------------------------------------------------------------ # Initialize histograms self.initializeHistograms() # Create constituent subtractor, if configured if self.do_constituent_subtraction: self.constituent_subtractor = \ CEventSubtractor(max_distance=self.max_distance, 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) print(self) # Find jets and fill histograms print('Find jets...') self.analyzeEvents() # Plot histograms print('Save histograms...') process_base.ProcessBase.save_output_objects(self) print('--- {} seconds ---'.format(time.time() - 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()