fsig, axsig = plt.subplots() if efficiencynorm == 'y' and exposurenorm == 'y': addinfo = 'expo and efficiency' if efficiencynorm == 'y' and exposurenorm == 'n': addinfo = 'efficiency only' if efficiencynorm == 'n' and exposurenorm == 'y': addinfo = 'expo only' if efficiencynorm == 'n' and exposurenorm == 'n': addinfo = 'raw' fspec.suptitle(str(names)+ ' Emin = ' + str(E1) + ' DLL cut: ' +str(dlllimit) + ' DC cut: ' +str(dclimvalue) + addinfo) first = True for runs,n in zip(allruns,names): # get the format of the dataframe df = utils.initialize_dataframe(exemplepath) # merge the runs df = utils.mergeruns(runs,folder,fname,df) expo = 0 for r in runs: expo += utils.getrunexposure(r,extnr) rmexpo = utils.removedexpofromDC(r,dfDC,dclimvalue) # print 'rmexpo = ' , rmexpo expo -= rmexpo # print 'expo = ', expo dfsel = df.query(constant.basecuts + ' & ' + dllcut + '&' + fidcut + '&' + Ecut ) for imc in imcuts: dfsel = dfsel.query(imc) rate = float(len(dfsel))/expo errrate = np.sqrt(float(len(dfsel)))/expo a_rate = np.append(a_rate,rate)
#runs = ['run100ks1','run100ks2','run100ks3','run30ks1','run30ks2'] runs = ['run100ks1', 'run100ks2', 'run100ks3', 'run30ks1', 'run30ks2'] runsall = [ 'run100ks1', 'run100ks2', 'run100ks3', 'run30ks1', 'run30ks2', 'run30ks4' ] #runs = ['run30ks4'] dlllimit = -23 fname = 'data' folder = constant.basefolders[4] exemplepath = '/Users/gaior/DAMIC/data/official4/cryoOFF_100000s-IntW800_OS_1x100_run2/pkl/data.pkl' # get the format of the dataframe dfmoriond = utils.initialize_dataframe(exemplepath) dfall = utils.initialize_dataframe(exemplepath) dflast = utils.initialize_dataframe(exemplepath) # merge the runs dfmoriond = utils.mergeruns(runs, folder, fname, dfmoriond) dfall = utils.mergeruns(runsall, folder, fname, dfall) dflast = utils.mergeruns(['run30ks4'], folder, fname, dflast) #define the cut related to the DLL dllcut = ' ll - llc < ' + str(dlllimit) fidcut = 'sigma > 0.3 & sigma < 0.8' # perform dfsel = dfall.query(constant.basecuts + ' & ' + dllcut + '&' + fidcut) dfselM = dfmoriond.query(constant.basecuts + ' & ' + dllcut + '&' + fidcut) dfselL = dflast.query(constant.basecuts + ' & ' + dllcut + '&' + fidcut) dfselM.to_pickle(constant.outfolder + 'event/' + 'evmoriond.pkl') dfsel.to_pickle(constant.outfolder + 'event/' + 'evall.pkl') dfselL.to_pickle(constant.outfolder + 'event/' + 'ev_run30ks4.pkl') print 'my event = ', dfsel.shape[0]
names = ['run30ks5'] allruns = [run30ks5] extnr = len(constant.extensionlist) a_rate = np.array([]) a_errrate = np.array([]) fspec, axspec = plt.subplots() first = True for runs, n in zip(allruns, names): # get the format of the dataframe df = utils.initialize_dataframe(exemplepath) dfb = utils.initialize_dataframe(exemplepath) # merge the runs df = utils.mergeruns(runs, folder, fname, df) dfb = utils.mergeruns(runs, folder, fnameblank, dfb) # dfsel = df.query(constant.basecuts) # dfselb = dfb.query(constant.basecuts) dfsel = df.query(constant.basecuts + ' & ' + fidcut) dfselb = dfb.query(constant.basecuts + ' & ' + fidcut) for imc in imcuts: dfsel = dfsel.query(imc) dfselb = dfselb.query(imc) plt.hist(dfsel.ll - dfsel.llc, bins=bins, histtype='step', log=True) plt.hist(dfselb.ll - dfselb.llc, bins=bins, histtype='step', log=True) plt.show()
# parser = argparse.ArgumentParser() # parser.add_argument("datatype", type=str, nargs='?',choices=['sim', 'data', 'blank'] ,help="type of data tag") # args = parser.parse_args() # datatype = args.datatype iteration = 4 #runs = ['run100ks1','run100ks2','run100ks3','run30ks1','run30ks2'] #runs = ['run100ks1','run100ks2','run100ks3','run30ks1','run30ks2'] runs = ['run30ks4'] dlllimit = -20 fname = 'data' folder = constant.basefolders[4] exemplepath = '/Users/gaior/DAMIC/data/official4/cryoOFF_100000s-IntW800_OS_1x100_run2/pkl/data.pkl' # get the format of the dataframe dfall = utils.initialize_dataframe(exemplepath) # merge the runs dfall = utils.mergeruns(runs,folder,fname,dfall) #define the cut related to the DLL dllcut = ' ll - llc < ' + str(dlllimit) # perform cuts #dfsel = dfall.query(constant.basecuts + ' & ' + dllcut) dfsel = dfall.query(constant.basecuts + ) firstbin = -50 step = 0.2 lastbin = 0 bins = np.arange(firstbin, lastbin, step) rangehigh = [-12,-8,-6] cols = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'] for lv,c in zip(rangehigh,cols): n,b,p = plt.hist(dfsel['ll']-dfsel['llc'],bins,lw=0,histtype='step') cbins = b[:-1] + float(step)/2 #integral = step*sum(n)
#runs = ['run30ks4'] dlllimit = -30 fname = 'data' folder = constant.basefolders[4] exemplepath = '/Users/gaior/DAMIC/data/official4/cryoOFF_100000s-IntW800_OS_1x100_run2/pkl/data.pkl' fidcut = 'sigma > 0.3 & sigma < 0.8' dlllimits = [-23, -30, -40] fmts = ['o', 's', 'x'] for dlllimit, fmt in zip(dlllimits, fmts): dllcut = ' ll - llc < ' + str(dlllimit) a_rate = np.array([]) a_errrate = np.array([]) for r in runsall: df = utils.initialize_dataframe(exemplepath) df = utils.mergeruns([r], folder, fname, df) listofid = pd.unique(df.RUNID) print ' run : ', r print ' nr of run == ', len(listofid) #define the cut related to the DLL # perform dfsel = df.query(constant.basecuts + ' & ' + dllcut + '&' + fidcut) rinfo = constant.runinfo[r] # exposure = rinfo[0]*rinfo[1] exposure = rinfo[0] * len(listofid) print 'exposure = ', exposure, ' s' evnr = dfsel.shape[0] print 'evnr = ', evnr rate = evnr / exposure errrate = np.sqrt(evnr) / exposure a_rate = np.append(a_rate, rate)