def testme(wbin=15, q2bin=5): sigsbparms = fitbin(wbin, q2bin) if sigsbparms: (haccdists, herrdists) = applythresholds(h4_a, 0.01) haccdists.Draw() wait() # virtual photon flux factors and cc-cut efficiency factors # already applied in h6maker.h! # ... but not in DH_H6Maker.h h2e = applyacc(wbin, q2bin, *sigsbparms) vals = ibins2vals(wbin, q2bin) (wval, wlo, whi) = (vals[0][0], vals[0][1], vals[0][2]) (q2val, q2lo, q2hi) = (vals[1][0], vals[1][1], vals[1][2]) d2wq2 = (whi-wlo)*(q2hi-q2lo) branch = 0.891 lum = 19.844*(1e6) h2e.Scale(1/(d2wq2*branch*lum)) h2e.Scale(1/vgflux(wval, q2val)) hcost = h2e.ProjectionY(str(h2e.GetName().replace('h2costphi', 'hcost')), 0, -1, 'e') hcost.Scale(1, 'width') h2e.Scale(1, 'width') hcost.SetDirectory(fout) errh2e = r.Double(0) inth2e = h2e.IntegralAndError(1, h2e.GetNbinsX(), 1, h2e.GetNbinsY(), errh2e, 'width') foutrecs.write(',%.0f,%.0f,%s\n' % (inth2e, errh2e, hcost.GetName())) foutrecs.close() fout.Write() fout.Close()
q2high = float(re.findall(re_string, hist.GetTitle())[1][0]) return ((wlow+whigh)/2, (q2low+q2high)/2, whigh-wlow, q2high-q2low) f = r.TFile('~/projects/phys-ana-omega/h3maker-hn-now8.root') hs0 = f.Get('hs1') h = hs0.GetHists()[4] (w, q2, dw, dq2) = wq2fromtitle(h) hacc = f.Get('hq2w_eff_acc') heff = f.Get('hq2w_eff_cc') gidx = hacc.FindBin(w, q2) acc = hacc.GetBinContent(gidx) eff = heff.GetBinContent(gidx) flx = vgflux(w, q2) brf = 0.891 lum = 19.844 dmmp = 0.01 etarange = (0.5, 0.6) omegarange = (0.7, 0.9) fbgskip = [etarange, omegarange] # bgwrapper = RejectWrapper(r.TF1('fbg', 'pol2', 0.4, 1.2), fbgskip) bgwrapper = RejectWrapper(r.TF1('fbg', 'pol4', 0.4, 1.2), fbgskip) fbgrej = bgwrapper.newtf1 fbg = bgwrapper.tf1 # fbgw = RejectWrapper(r.TF1('fbg', 'pol2', 0.4, 1.2), fbgskip) # fbg = r.TF1('fbg', 'pol2', 0.4, 1.2) # fbg = r.TF1('fbg', d_pol2, 0.4, 1.2, 3) # fbg.rejranges = fbgskip
for q2bin in range(q2start, h6_e.GetAxis(idims.q2).GetNbins()+1): if hq2w_e.GetBinContent(wbin, q2bin) > 100 and hq2w_t.GetBinContent(wbin, q2bin) > 100: sigsbparms = fitbin(wbin, q2bin) if sigsbparms: (haccdists, herrdists) = applythresholds(h4_a, 0.01) haccdists.Draw() wait() # cc-cut efficiency factors already applied in h6maker.h! h2e = applyacc(wbin, q2bin, *sigsbparms) vals = ibins2vals(wbin, q2bin) (wval, wlo, whi) = (vals[0][0], vals[0][1], vals[0][2]) (q2val, q2lo, q2hi) = (vals[1][0], vals[1][1], vals[1][2]) d2wq2 = (whi-wlo)*(q2hi-q2lo) branch = 0.891 lum = 19.844*(1e6) h2e.Scale(1/(d2wq2*branch*lum)) h2e.Scale(1/vgflux(wval, q2val)) hcost = h2e.ProjectionY(str(h2e.GetName().replace('h2costphi', 'hcost')), 0, -1, 'e') hcost.Scale(1, 'width') h2e.Scale(1, 'width') hcost.SetDirectory(fout) errh2e = r.Double(0) inth2e = h2e.IntegralAndError(1, h2e.GetNbinsX(), 1, h2e.GetNbinsY(), errh2e, 'width') # foutrecs.write(',%.0f,%.0f\n' % (inth2e, errh2e)) foutrecs.write(',%.0f,%.0f,%s\n' % (inth2e, errh2e, hcost.GetName())) foutrecs.close() fout.Write() fout.Close()