|
| 1 | +#!/usr/bin/python3 |
| 2 | + |
| 3 | +import matplotlib.pyplot as plt |
| 4 | +import numpy as np |
| 5 | +import argparse |
| 6 | +import math |
| 7 | +import os.path |
| 8 | +from matplotlib.backends.backend_pdf import PdfPages |
| 9 | + |
| 10 | +import ROOT |
| 11 | + |
| 12 | +labelsize = 15 |
| 13 | +plt.rc('font', family='serif', size=labelsize) |
| 14 | +plt.rc('xtick', labelsize=labelsize) |
| 15 | +plt.rc('ytick', labelsize=labelsize) |
| 16 | +plt.rc('text', usetex=True) |
| 17 | + |
| 18 | + |
| 19 | +def check_woff(atm, zenith, wobble, nsb, pdf): |
| 20 | + print('check_woff({}, {}, {}, {})'.format(atm, zenith, wobble, nsb)) |
| 21 | + |
| 22 | + woff_rad = list() |
| 23 | + for i_split in range(10): |
| 24 | + run = str(961201 + i_split) |
| 25 | + try: |
| 26 | + filename = ( |
| 27 | + '/lustre/fs23/group/veritas/V6_DESY/EffAreaTesting/v501/CARE/V6_ATM' |
| 28 | + + str(atm) + '_gamma_ze' + str(zenith) |
| 29 | + + '_TL5035MA20/ze' + str(zenith) + 'deg_offset' + str(wobble) + 'deg_NSB' |
| 30 | + + str(nsb) + 'MHz/' + run + '.root' |
| 31 | + ) |
| 32 | + |
| 33 | + if not os.path.isfile(filename): |
| 34 | + # print('File {} does not exists'.format(filename)) |
| 35 | + continue |
| 36 | + |
| 37 | + try: |
| 38 | + file = ROOT.TFile.Open(filename) |
| 39 | + except: |
| 40 | + print('Could not open file {}'.format(filename)) |
| 41 | + continue |
| 42 | + |
| 43 | + for entry in file.showerpars: |
| 44 | + if float(entry.Xoff[0]) > -99 and not float(entry.Xoff[0]) == 0.: |
| 45 | + woff_rad.append(math.sqrt(entry.Xoff[0]**2 + entry.Yoff[0]**2)) |
| 46 | + except: |
| 47 | + print('Could not read file for run {}'.format(run)) |
| 48 | + continue |
| 49 | + |
| 50 | + mean_woff = np.sum(woff_rad) / len(woff_rad) |
| 51 | + diff = math.fabs(mean_woff - float(wobble)) |
| 52 | + sigma = np.std(woff_rad) |
| 53 | + |
| 54 | + fig = plt.figure(figsize=(8, 6), tight_layout=True) |
| 55 | + |
| 56 | + ax = plt.gca() |
| 57 | + ax.set_title('NSB = {}, mu = {:.3f}, sigma = {:.3f}'.format(nsb, mean_woff, sigma)) |
| 58 | + ax.set_xlabel('Woff') |
| 59 | + |
| 60 | + ax.hist(woff_rad, bins=np.linspace(0.0, 2.5, 100)) |
| 61 | + |
| 62 | + pdf.savefig(fig) |
| 63 | + plt.close() |
| 64 | + |
| 65 | + return |
| 66 | + |
| 67 | + |
| 68 | +if __name__ == '__main__': |
| 69 | + |
| 70 | + parser = argparse.ArgumentParser( |
| 71 | + description='Plot Eff Area for a certain zenith angle simulation set.' |
| 72 | + ) |
| 73 | + parser.add_argument( |
| 74 | + '-z', |
| 75 | + '--zenith', |
| 76 | + help='Zenith angle (in deg)', |
| 77 | + type=str, |
| 78 | + required=True, |
| 79 | + choices=['00', '20', '30', '35', '40', '45', '50', '55', '60'] |
| 80 | + ) |
| 81 | + parser.add_argument( |
| 82 | + '-a', |
| 83 | + '--atm', |
| 84 | + help='Atm (61 or 62)', |
| 85 | + type=str, |
| 86 | + required=True, |
| 87 | + choices=['61', '62'] |
| 88 | + ) |
| 89 | + parser.add_argument( |
| 90 | + '-w', |
| 91 | + '--wobble', |
| 92 | + help='Wobble offset', |
| 93 | + type=float, |
| 94 | + required=False, |
| 95 | + choices=[0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0] |
| 96 | + ) |
| 97 | + zenith = parser.parse_args().zenith |
| 98 | + atm = parser.parse_args().atm |
| 99 | + wob = parser.parse_args().wobble |
| 100 | + |
| 101 | + if wob is None: |
| 102 | + all_wobble = [0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0] |
| 103 | + figName = 'figures/Woff_atm{}_ze{}.pdf'.format(atm, zenith) |
| 104 | + else: |
| 105 | + all_wobble = [wob] |
| 106 | + figName = 'figures/Woff_atm{}_ze{}_wob{}.pdf'.format(atm, zenith, wob) |
| 107 | + |
| 108 | + all_nsb = [50, 75, 100, 130, 160, 200, 250, 300, 350, 400, 450] |
| 109 | + # all_nsb = [400] |
| 110 | + |
| 111 | + with PdfPages(figName) as pdf: |
| 112 | + for nsb in all_nsb: |
| 113 | + for wob in all_wobble: |
| 114 | + check_woff(atm, zenith, wob, nsb, pdf) |
0 commit comments