Angular analysis of B+->K*+(K+pi0)mumu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
840 B

  1. import numpy as np
  2. from hep_ml.reweight import BinsReweighter
  3. def select_feature(feature: np.ndarray, limits: tuple[float, float]) -> tuple[np.ndarray, list]:
  4. selection_indices = []
  5. for index, value in enumerate(feature):
  6. if value > limits[0] and value < limits[1]:
  7. selection_indices.append(index)
  8. return feature[selection_indices], selection_indices
  9. def reweight_feature(original_feature: list, target_feature: list, n_bins: int, n_neighs: int = 2):
  10. original_weights = np.ones(len(original_feature))
  11. bin_reweighter = BinsReweighter(n_bins = n_bins, n_neighs = n_neighs)
  12. bin_reweighter.fit(original = original_feature, target = target_feature, original_weight = original_weights)
  13. return bin_reweighter.predict_weights(original = original_feature, original_weight = original_weights)