def setup_beam(self): self.particles_in = [] for emittance in self.emittance_list: bz = field.get_field_value(0., 0., self.tracker_z, 0.)[2] if abs(bz) < 1e-3: bz = 3e-3 p = 140. mass = xboa.common.pdg_pid_to_mass[13] beta = p / 150. / bz alpha = 0. q = 1. ellipse = Bunch.build_penn_ellipse(emittance, mass, beta, alpha, p, 0., bz, q) #events = Bunch.new_hit_shell(7, ellipse, ["x", "px", "y", "py"], "", defaults) mean = numpy.array([0.] * 4) events = numpy.random.multivariate_normal(mean, ellipse, self.n_events) for event in events: hit = self.event_from_four_vector(event) if hit != None: self.particles_in.append(hit) else: continue print "Generated", len(self.particles_in), "events"
def get_analysis(datasets, name, tof01_min_max, data_dir, p_bins, tkd_cut, do_globals): plot_dir = data_dir + "/plots_" + name + "/" plot_dir = plot_dir.replace(" ", "_") min_p = min([min(a_bin) for a_bin in p_bins]) max_p = max([max(a_bin) for a_bin in p_bins]) cov_us = Bunch.build_penn_ellipse(1., xboa.common.pdg_pid_to_mass[13], 250., 0., (min_p + max_p) / 2., 0., 3.e-3, 1.).tolist() cov_ds = Bunch.build_penn_ellipse(1., xboa.common.pdg_pid_to_mass[13], 250., 0., (min_p + max_p) / 2., 0., 2.e-3, 1.).tolist() return { "plot_dir": plot_dir, # makedirs and then put plots in this directory. Removes any old plots there!!! "tof0_n_sp": 1, # number of space points required in TOF0 "tof1_n_sp": 1, # number of space points required in TOF1 "tof12_cut_low": 32., # TOF12 cut lower bound "tof12_cut_high": 39., # TOF12 cut upper bound "delta_tof01_lower": -1., # Delta TOF01 cut lower bound "delta_tof01_upper": 1.5, # Delta TOF01 cut upper bound "delta_tof12_lower": -5., # Delta TOF01 cut lower bound "delta_tof12_upper": 5., # Delta TOF01 cut upper bound "tof01_cut_low": tof01_min_max[0], # TOF01 cut lower bound "tof01_cut_high": tof01_min_max[1], # TOF01 cut upper bound "tof01_tramline_lower": -15. + 70, # p_tof01 - p_tku "tof01_tramline_upper": +15. + 70, # p_tof01 - p_tku "p_bins": p_bins, # set of momentum bins; for now really it is just a lower and upper bound "p_bins_alt": [[100, 180]], # alternative momentum cut "p_tot_ds_low": tkd_cut[0], # downstream momentum cut lower bound "p_tot_ds_high": tkd_cut[1], # downstream momentum cut upper bound "reco_files": rogers_mc_file_names(datasets), # list of strings to be handed to glob "name": name, # appears on plots "color": 4, # not used "pid": -13, # assume pid of tracks following TOF cut "pvalue_threshold": 0.02, # minimum allowed pvalue for pvalue cut "tku_chi2_threshold": 8.0, # maximum allowed chi2/dof for chi2 cut "tkd_chi2_threshold": 4.0, # BUGGGGGGGGG # maximum allowed chi2/dof for chi2 cut "amplitude_corrections": None, "amplitude_systematics": {}, "field_uncertainty": 0.02, "amplitude_chi2": False, "amplitude_mc": True, "weight_tof01_source": "output/2017-02_mc_weighting/plots_3-140-empty/tof01_weights", "weight_tof01_target": "output/2017-02_reco_weighting/plots_3-140-10069/tof01_weights", "weight_tof01_mode": "sample_using_distribution", "amplitude_systematic_reference": None, "amplitude_inefficiency_cutoff": 50., "amplitude_recon_systematic_sources": {}, "amplitude_performance_systematic_sources": {}, "tku_fiducial_radius": 150., "tkd_fiducial_radius": 150., "cov_fixed_us": None, #cov_us, "cov_fixed_ds": None, #cov_ds, "amplitude_algorithm": "binned", "fractional_emittance_mc": True, "fractional_emittance_corrections": False, "fractional_emittance_systematics": {}, "fractional_emittance_corrections_draw": True, "fractional_emittance_systematics_draw": True, "density_mc": True, # True if pure Monte Carlo "density_corrections_cutoff": .5, # Cutoff above which correction is averaged "density_corrections": None, # Path to the correction file "density_systematics": {}, # Density systematic uncertainty dictionary "density_corrections_draw": True, # True if density correctoins are to be drawn "density_systematics_draw": True, # True if density systematics are to be drawn "density_sections": False, # True if density sections are to be printed "density_use_capped": True, # True if density sections are to be printed "do_magnet_alignment": False, "do_efficiency": False, #True, "do_fractional_emittance": False, #True, "do_amplitude": False, #True, "do_density": True, "do_density_rogers": True, "do_extrapolation": False, "do_globals": False, #do_globals, "do_mc": False, #True, "do_plots": False, #True, "do_cuts_plots": False, #True, "do_tof01_weighting": False, "do_optics": False, "do_data_recorder": False, }