nuDict = {} if args.old_pid: nuDict = {'nue':66,'numu':68,'nutau':133,'nue_bar':67,'numu_bar':69,'nutau_bar':134} else: nuDict = {'nue':12,'numu':14,'nutau':16,'nue_bar':-12,'numu_bar':-14,'nutau_bar':-16} # Now do CC events, and write to file: cc_cut_list = cut_list + [('I3MCWeightDict','InteractionType',1)] nc_cut_list = cut_list + [('I3MCWeightDict','InteractionType',2)] for flavor in data_files.keys(): data = tables.openFile(data_files[flavor]['filename'],'r') ############# # First do nu: cuts_cc = get_arb_cuts(data,cc_cut_list,nuIDList=[nuDict[flavor]],mcnu=args.mcnu) arrays_cc = get_reco_arrays(data,cuts_cc,data_files[flavor]['nfiles'], reco_string=args.mn_reco,mcnu=args.mcnu) logging.warn("flavor %s number of CC events: %d"%(flavor,np.sum(cuts_cc))) cuts_nc = get_arb_cuts(data,nc_cut_list,nuIDList=[nuDict[flavor]],mcnu=args.mcnu) arrays_nc = get_reco_arrays(data,cuts_nc,data_files[flavor]['nfiles'], reco_string=args.mn_reco,mcnu=args.mcnu) logging.warn("flavor %s number of NC events: %d"%(flavor,np.sum(cuts_nc))) logging.info("Saving %s..."%flavor) write_to_hdf5(outfilename,flavor,arrays_cc,arrays_nc) ################ # Next do nu_bar: flav_bar = flavor+'_bar'
if args.all_cz: # Then use all sky, don't remove simulated downgoing events: cut_sim_down = False solid_angle = 4.0*np.pi # Loop over all neutrino flavours, and get cc Aeff: for flav,val in nuDict.items(): logging.info("Loading data for %s..."%flav) data = LoadData(args.data_dir,args.geom_str,flav) cc_cuts = list(s1_s2_cuts) cc_cuts.append(("I3MCWeightDict","InteractionType",1)) cc_cuts.append((args.mcnu,"type",val)) cut_list = get_arb_cuts(data,cc_cuts,mcnu=args.mcnu,cut_sim_down=cut_sim_down) logging.info(" NEvents: %d"%np.sum(cut_list)) if 'nue' in flav: nfiles = args.nfiles_nue elif 'numu' in flav: nfiles = args.nfiles_numu elif 'nutau' in flav: nfiles = args.nfiles_nutau else: raise ValueError("Unrecognized flav: %s"%flav) aeff_cc,aeff_cc_err,xedges = get_aeff1D(data,cut_list,ebins,nfiles, mcnu=args.mcnu,solid_angle=solid_angle) aeff_list.append(aeff_cc) aeff_err_list.append(aeff_cc_err) flavor_list.append(flav)
elif args.nocuts: logging.warn("Using no selection cuts!") cut_list = [] elif args.custom: logging.warn("Using CUSTOM cuts: %s..."%args.custom_str) cut_list = eval(args.custom_str) else: logging.warn("No cuts selected!") # Should never happen! # First do all NC events combined-must keep filehandle open dummy_fh = [tables.openFile(f,mode='r') for f in data_files.values()] data_nc = HDFChain(data_files.values()) nc_cut_list = cut_list + [('I3MCWeightDict','InteractionType',2)] cuts_nc = get_arb_cuts(data_nc,nc_cut_list,mcnu=args.mcnu) arrays_nc = get_reco_arrays(data_nc,cuts_nc,reco_string=args.mn_reco, mcnu=args.mcnu) logging.warn("NC number of events: %d"%np.sum(cuts_nc)) # Now do CC events, and write to file: cc_cut_list = cut_list + [('I3MCWeightDict','InteractionType',1)] for flavor in data_files.keys(): data = tables.openFile(data_files[flavor],'r') cuts_cc = get_arb_cuts(data,cc_cut_list,mcnu=args.mcnu) arrays_cc = get_reco_arrays(data,cuts_cc,reco_string=args.mn_reco, mcnu=args.mcnu) logging.warn("flavor %s number of events: %d"%(flavor,np.sum(cuts_cc))) logging.info("Saving %s..."%flavor)
if args.all_cz: # Then use all sky, don't remove simulated downgoing events: cut_sim_down = False solid_angle = 4.0*np.pi # Loop over all neutrino flavours, and get cc Aeff: for flav,val in nuDict.items(): logging.info("Loading data for %s..."%flav) data = LoadData(args.data_dir,args.geom_str,flav) cc_cuts = list(s1_s2_cuts) cc_cuts.append(("I3MCWeightDict","InteractionType",1)) cc_cuts.append((args.mcnu,"type",val)) cut_list = get_arb_cuts(data,cc_cuts,mcnu=args.mcnu,cut_sim_down=cut_sim_down) logging.info(" NEvents: %d"%np.sum(cut_list)) if 'nue' in flav: nfiles = args.ne elif 'numu' in flav: nfiles = args.nmu elif 'nutau' in flav: nfiles = args.ntau else: raise ValueError("Unrecognized flav: %s"%flav) aeff_cc,aeff_cc_err,xedges = get_aeff1D(data,cut_list,ebins,nfiles, mcnu=args.mcnu,solid_angle=solid_angle) aeff_list.append(aeff_cc) aeff_err_list.append(aeff_cc_err) flavor_list.append(flav)
elif args.cutsV4: logging.warn("Using cuts V4...") cut_list.append(('Cuts_V4_Step1','value',True)) cut_list.append(('Cuts_V4_Step2','value',True)) elif args.cutsV5: logging.warn("Using cuts V5...") cut_list.append(('Cuts_V5_Step1','value',True)) cut_list.append(('Cuts_V5_Step2','value',True)) # First do all NC events combined-must keep filehandle open dummy_fh = [tables.openFile(f,mode='r') for f in data_files.values()] data_nc = HDFChain(data_files.values()) nc_cut_list = cut_list + [('I3MCWeightDict','InteractionType',2)] cuts_nc = get_arb_cuts(data_nc,nc_cut_list) arrays_nc = get_reco_arrays(data_nc,cuts_nc,reco_string=args.mn_reco) logging.warn("NC number of events: %d"%np.sum(cuts_nc)) # Now do CC events, and write to file: cc_cut_list = cut_list + [('I3MCWeightDict','InteractionType',1)] for flavor in data_files.keys(): data = tables.openFile(data_files[flavor],'r') cuts_cc = get_arb_cuts(data,cc_cut_list) arrays_cc = get_reco_arrays(data,cuts_cc,reco_string=args.mn_reco) logging.warn("flavor %s number of events: %d"%(flavor,np.sum(cuts_cc))) logging.info("Saving %s..."%flavor) write_to_hdf5(outfilename,flavor,arrays_cc,arrays_nc)
elif args.nocuts: logging.warn("Using no selection cuts!") cut_list = [] elif args.custom: logging.warn("Using CUSTOM cuts: %s..." % args.custom_str) cut_list = eval(args.custom_str) else: logging.warn("No cuts selected!") # Should never happen! # First do all NC events combined-must keep filehandle open dummy_fh = [tables.openFile(f, mode='r') for f in data_files.values()] data_nc = HDFChain(data_files.values()) nc_cut_list = cut_list + [('I3MCWeightDict', 'InteractionType', 2)] cuts_nc = get_arb_cuts(data_nc, nc_cut_list, mcnu=args.mcnu) arrays_nc = get_reco_arrays(data_nc, cuts_nc, reco_string=args.mn_reco, mcnu=args.mcnu) logging.warn("NC number of events: %d" % np.sum(cuts_nc)) # Now do CC events, and write to file: cc_cut_list = cut_list + [('I3MCWeightDict', 'InteractionType', 1)] for flavor in data_files.keys(): data = tables.openFile(data_files[flavor], 'r') cuts_cc = get_arb_cuts(data, cc_cut_list, mcnu=args.mcnu) arrays_cc = get_reco_arrays(data, cuts_cc, reco_string=args.mn_reco,