def get_predicts( mcf ) : v = mc_variables() p = pc.predictions_to_make() predicts = [] for predict in p : opts = v[predict] predicts.append( MCContribution( mcf, v[predict] ) ) return predicts
def get_contribs( mcf ) : v = mc_variables() c = pc.contributions_to_make() contribs = [] for contrib in c : opts = v[contrib] contribs.append( MCContribution( mcf, v[contrib] ) ) return contribs
def init_var_indices(self): vars = v.mc_variables() # one will need indices: first of KO's (to find the other 21); m_neutralino; ssi with whith the normal X^2 was calculated self.KOssi_cen50_index = vars["KOsigma_pp^SI_cen50"].get_index(self.mcf) self.KOssi_unc50_14_index = vars["KOsigma_pp^SI_unc50_14"].get_index(self.mcf) self.KOssi_unc50_7_index = vars["KOsigma_pp^SI_unc50_7"].get_index(self.mcf) self.mneu1_index = vars["neu1"].get_index(self.mcf) if self.lhood_name is not None: self.xenon_ssi_index = vars[self.xenon_ssi_sn].get_index(self.mcf) print self.mneu1_index, self.xenon_ssi_index
def get_plots(mcf) : v = mc_variables() plots = pc.plots_to_make() for plane, opts in plots.iteritems() : assert len(plane) == len( opts["ranges"] ) == len( opts["nbins"] ), \ "Wrong option numbers for plots (dimensionality doesnt match ranges and/or bins" d = {} for plot_vars, options in plots.iteritems() : d[tuple([ v[var] for var in plot_vars])] = options spaces = [ MCSpace( mcf, MCV, opts ) for (MCV, opts) in d.iteritems() ] return spaces
def fill_n_dim_hisogram(chain,n_dim_histo_list,space_dict,mcf): mc_vars = variables.mc_variables() # this gets all mc-variabls space_vars = [ [mc_vars[sn] for sn in short_names ] for short_names in space_dict ] begin = 0 # end = chain.GetEntries() end = 10000 prog = ProgressBar(begin, end, 77, mode='fixed', char='#') for entry in xrange(begin,end) : chi2 = get_chi2(chain,mcf) for histo, vars in zip(n_dim_histo_list, space_vars ) : coord=get_and_coordinates(vars,chain,mcf) fill_histo(entry,chi2,coord)
def calculate_entry_histograms( plots, chain ) : ##assert canvas is not None, "Canvas must be specified in calculate_histograms" # setup our 2d histos vars = v.mc_variables() # KOhack class gets initiated, because it has to be checked "if KOhack is applied" KOhack=KOhack_class(plots[0].mcf) histos = [] chi2histos = [] for p in plots : hname = histo_name( p.short_names, entry_histo_prefix ) cname = histo_name( p.short_names, chi2_histo_prefix ) entryhisto = initialize_histo( p,hname,entry=True ) chi2histo = initialize_histo( p,cname,chi2 =True ) histos.append(entryhisto) chi2histos.append(chi2histo) if check_entry_KO_hack(p,KOhack): KOhack.init_hack(p) nentries = chain.GetEntries() prog = ProgressBar(0, nentries+1, 77, mode='fixed', char='#') for entry in range(0,nentries+1) : prog.increment_amount() print prog,'\r', stdout.flush() chain.GetEntry(entry) for h, c, plot in zip( histos, chi2histos, plots ) : vals_list = get_values_list_from_chain_and_histo(chain,plot,vars,s,KOhack,h) for vals in vals_list: nbins = plot.bins ibin = h.FindBin(*vals) max_bin = h.FindBin(*plot.max_vals) if ibin != 0 and ibin < max_bin : chi2 = get_modified_entry_chi2(vals,chain,KOhack) if chi2 < c.GetBinContent(ibin) : c.SetBinContent(ibin, chi2) h.SetBinContent(ibin, entry) print return histos