create_asimov.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import os
  2. import numpy as np
  3. #################################################################################
  4. # User defined
  5. multiply = 100
  6. data_path = 'DATA/generated_histograms'
  7. histo_name = 'hist_range_110-160_nbin-25_'
  8. labels = ['Background', 'Signal', 'Data']
  9. #################################################################################
  10. # Load data
  11. pldict = {}
  12. for label in labels:
  13. fileName = os.path.join(data_path, histo_name + label + '.npz')
  14. with np.load(fileName, 'rb') as data:
  15. bin_centers = data['bin_centers']
  16. bin_edges = data['bin_edges']
  17. bin_values = data['bin_values']
  18. bin_errors = data['bin_errors']
  19. pldict[label] = [bin_centers, bin_edges, bin_values, bin_errors]
  20. #################################################################################
  21. # Add multiple of signal to Data and Signal
  22. pldict['Data'][2] += multiply * pldict['Signal'][2]
  23. pldict['Data'][3] = np.sqrt(pldict['Data'][3]**2 + pldict['Signal'][3]**2)
  24. pldict['Signal'][2] += multiply * pldict['Signal'][2]
  25. pldict['Signal'][3] = multiply * pldict['Signal'][3]
  26. #################################################################################
  27. # Save Asimov data
  28. for label in labels:
  29. fileName = histo_name + 'Asimov' + label + '.npz'
  30. np.savez(
  31. os.path.join(data_path, fileName),
  32. bin_centers=pldict[label][0],
  33. bin_edges=pldict[label][1],
  34. bin_values=pldict[label][2],
  35. bin_errors=pldict[label][3]
  36. )