def save(self, filename_out, shuffle=True): """ Saves the observable definitions, observable values, and event weights in a MadMiner file. The parameter, benchmark, and morphing setup is copied from the file provided during initialization. Nuisance benchmarks found in the HepMC file are added. Parameters ---------- filename_out : str Path to where the results should be saved. shuffle : bool, optional If True, events are shuffled before being saved. That's important when there are multiple distinct samples (e.g. signal and background). Default value: True. Returns ------- None """ if self.observations is None or self.weights is None: logger.warning("No observations to save!") return logger.debug("Loading HDF5 data from %s and saving file to %s", self.filename, filename_out) # Save nuisance parameters and benchmarks weight_names = list(self.weights.keys()) logger.debug("Weight names: %s", weight_names) save_nuisance_setup_to_madminer_file( filename_out, weight_names, self.nuisance_parameters, reference_benchmark=self.reference_benchmark, copy_from=self.filename, ) # Save events save_events_to_madminer_file( filename_out, self.observables, self.observations, self.weights, self.events_sampling_benchmark_ids, self.signal_events_per_benchmark, self.background_events, ) if shuffle: combine_and_shuffle([filename_out], filename_out)
def save(self, filename_out): """ Saves the observable definitions, observable values, and event weights in a MadMiner file. The parameter, benchmark, and morphing setup is copied from the file provided during initialization. Nuisance benchmarks found in the LHE file are added. Parameters ---------- filename_out : str Path to where the results should be saved. Returns ------- None """ if self.observations is None or self.weights is None: logger.warning("No events to save!") return logger.debug("Loading HDF5 data from %s and saving file to %s", self.filename, filename_out) # Save nuisance parameters and benchmarks weight_names = list(self.weights.keys()) logger.debug("Weight names: %s", weight_names) save_nuisance_setup_to_madminer_file( filename_out, weight_names, self.nuisance_parameters, reference_benchmark=self.reference_benchmark, copy_from=self.filename, ) # Save events save_events_to_madminer_file( filename_out, self.observables, self.observations, self.weights, self.events_sampling_benchmark_ids, self.signal_events_per_benchmark, self.background_events, )