int compare_tex(value v1, value v2) { GLuint i1 = TEX(v1); GLuint i2 = TEX(v2); if(i1 < i2) return -1; else if(i1 == i2) return 0; else return 1; }
static void TXP( void *cc, const float *texcoord, int unit, float *result ) { /* I think that TEX needs to undo the perspective divide which has * already occurred. In the meantime, TXP is correct to do this: */ TEX( cc, texcoord, unit, result ); }
static boolean nve4_validate_tic(struct nvc0_context *nvc0, unsigned s) { struct nouveau_bo *txc = nvc0->screen->txc; struct nouveau_pushbuf *push = nvc0->base.pushbuf; unsigned i; boolean need_flush = FALSE; for (i = 0; i < nvc0->num_textures[s]; ++i) { struct nv50_tic_entry *tic = nv50_tic_entry(nvc0->textures[s][i]); struct nv04_resource *res; const boolean dirty = !!(nvc0->textures_dirty[s] & (1 << i)); if (!tic) { nvc0->tex_handles[s][i] |= NVE4_TIC_ENTRY_INVALID; continue; } res = nv04_resource(tic->pipe.texture); if (tic->id < 0) { tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic); PUSH_SPACE(push, 16); BEGIN_NVC0(push, NVE4_P2MF(DST_ADDRESS_HIGH), 2); PUSH_DATAh(push, txc->offset + (tic->id * 32)); PUSH_DATA (push, txc->offset + (tic->id * 32)); BEGIN_NVC0(push, NVE4_P2MF(LINE_LENGTH_IN), 2); PUSH_DATA (push, 32); PUSH_DATA (push, 1); BEGIN_1IC0(push, NVE4_P2MF(EXEC), 9); PUSH_DATA (push, 0x1001); PUSH_DATAp(push, &tic->tic[0], 8); need_flush = TRUE; } else if (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) { BEGIN_NVC0(push, NVC0_3D(TEX_CACHE_CTL), 1); PUSH_DATA (push, (tic->id << 4) | 1); } nvc0->screen->tic.lock[tic->id / 32] |= 1 << (tic->id % 32); res->status &= ~NOUVEAU_BUFFER_STATUS_GPU_WRITING; res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; nvc0->tex_handles[s][i] &= ~NVE4_TIC_ENTRY_INVALID; nvc0->tex_handles[s][i] |= tic->id; if (dirty) BCTX_REFN(nvc0->bufctx_3d, TEX(s, i), res, RD); } for (; i < nvc0->state.num_textures[s]; ++i) { nvc0->tex_handles[s][i] |= NVE4_TIC_ENTRY_INVALID; nvc0->textures_dirty[s] |= 1 << i; } nvc0->state.num_textures[s] = nvc0->num_textures[s]; return need_flush; }
// INPUT a texture ID // OUTPUT nothing, deletes the texture CAMLprim value caml_destroy_texture(value id) { CAMLparam1(id); glDeleteTextures(1, &TEX(id)); CAMLreturn(Val_unit); }
// INPUT a binding point and a texture id option // OUTPUT nothing, binds the texture CAMLprim value caml_bind_texture(value point, value tex_opt) { CAMLparam2(point, tex_opt); if(tex_opt == Val_none) glBindTexture(Target_val(point), 0); else glBindTexture(Target_val(point), TEX(Some_val(tex_opt))); CAMLreturn(Val_unit); }
static boolean nvc0_validate_tic(struct nvc0_context *nvc0, int s) { uint32_t commands[32]; struct nouveau_pushbuf *push = nvc0->base.pushbuf; struct nouveau_bo *txc = nvc0->screen->txc; unsigned i; unsigned n = 0; boolean need_flush = FALSE; for (i = 0; i < nvc0->num_textures[s]; ++i) { struct nv50_tic_entry *tic = nv50_tic_entry(nvc0->textures[s][i]); struct nv04_resource *res; const boolean dirty = !!(nvc0->textures_dirty[s] & (1 << i)); if (!tic) { if (dirty) commands[n++] = (i << 1) | 0; continue; } res = nv04_resource(tic->pipe.texture); if (tic->id < 0) { tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic); PUSH_SPACE(push, 17); BEGIN_NVC0(push, NVC0_M2MF(OFFSET_OUT_HIGH), 2); PUSH_DATAh(push, txc->offset + (tic->id * 32)); PUSH_DATA (push, txc->offset + (tic->id * 32)); BEGIN_NVC0(push, NVC0_M2MF(LINE_LENGTH_IN), 2); PUSH_DATA (push, 32); PUSH_DATA (push, 1); BEGIN_NVC0(push, NVC0_M2MF(EXEC), 1); PUSH_DATA (push, 0x100111); BEGIN_NIC0(push, NVC0_M2MF(DATA), 8); PUSH_DATAp(push, &tic->tic[0], 8); need_flush = TRUE; } else if (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) { BEGIN_NVC0(push, NVC0_3D(TEX_CACHE_CTL), 1); PUSH_DATA (push, (tic->id << 4) | 1); } nvc0->screen->tic.lock[tic->id / 32] |= 1 << (tic->id % 32); res->status &= ~NOUVEAU_BUFFER_STATUS_GPU_WRITING; res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; if (!dirty) continue; commands[n++] = (tic->id << 9) | (i << 1) | 1; BCTX_REFN(nvc0->bufctx_3d, TEX(s, i), res, RD); } for (; i < nvc0->state.num_textures[s]; ++i) commands[n++] = (i << 1) | 0; nvc0->state.num_textures[s] = nvc0->num_textures[s]; if (n) { BEGIN_NIC0(push, NVC0_3D(BIND_TIC(s)), n); PUSH_DATAp(push, commands, n); } nvc0->textures_dirty[s] = 0; return need_flush; }
intnat hash_tex(value v) { GLuint i = TEX(v); return i; }
void finalise_tex(value v) { glDeleteTextures(1,&TEX(v)); }
#include "i420_to_rgb.hpp" DEC_COMMON_VARS(); TEMP yuv; yuv.x = TEX(coord, texture[1], 2D); yuv.z = yuv.x - coef_g.a; yuv.x = TEX(coord, texture[2], 2D); yuv.w = yuv.x - coef_b.a; yuv.x = yuv.z * param0.z; yuv.y = yuv.w * param0.w; yuv.y = yuv.x + yuv.y; yuv.x = yuv.z * param0.w; yuv.w = yuv.w * param0.z; yuv.z = yuv.w - yuv.x; yuv.x = TEX(coord, texture[0], 2D); yuv.x = yuv - coef_r.a; yuv = yuv * param0.xyyz; yuv.x = yuv + coord.z; output.r = DP3(yuv, coef_r); output.g = DP3(yuv, coef_g); output.b = DP3(yuv, coef_b); output.a = 1.0;
// ---------------------------------------------------------------------- void invertedMuonID2Comb(string era = "2016BF", float bdt = -99., TH1D *hBd = 0, TH1D *hBs = 0) { if ("all" == era) { invertedMuonID2Comb("2016BF"); invertedMuonID2Comb("2016GH"); invertedMuonID2Comb("2011"); invertedMuonID2Comb("2012"); return; } TFile *fd(0), *fm0(0), *fm1(0); float bdtcut(0.); cout << "======================================================================" << endl; if (era == "2016BF") { fd = TFile::Open("/scratch/ursl/bmm4/s01/bmm-data-bmmCharmonium2016BF-s01.root"); fm0 = TFile::Open("/scratch/ursl/bmm4/s01/bmm-mc-RunIISpring16DR80-BdToMuMu-2016BF-s01.root"); fm1 = TFile::Open("/scratch/ursl/bmm4/s01/bmm-mc-RunIISpring16DR80-BsToMuMu-2016BF-s01.root"); if (bdt < -1.) { bdtcut = 0.30; } else { bdtcut = bdt; } } else if (era == "2016GH") { fd = TFile::Open("/scratch/ursl/bmm4/s01/bmm-data-bmmCharmonium2016GH-s01.root"); fm0 = TFile::Open("/scratch/ursl/bmm4/s01/bmm-mc-RunIISpring16DR80-BdToMuMu-2016GH-s01.root"); fm1 = TFile::Open("/scratch/ursl/bmm4/s01/bmm-mc-RunIISpring16DR80-BsToMuMu-2016GH-s01.root"); if (bdt < -1.) { bdtcut = 0.31; } else { bdtcut = bdt; } } else if (era == "2012") { fd = TFile::Open("/scratch/ursl/bmm4/s01/bmm-data-bmmMuOnia2012-s01.root"); fm0 = TFile::Open("/scratch/ursl/bmm4/s01/bmm-mc-Winter17_private-BdToMuMu-s01.root"); fm1 = TFile::Open("/scratch/ursl/bmm4/s01/bmm-mc-Winter17_private-BsToMuMu-s01.root"); if (bdt < -1.) { bdtcut = 0.34; } else { bdtcut = bdt; } } else if (era == "2011") { fd = TFile::Open("/scratch/ursl/bmm4/s01/bmm-data-bmmMuOnia2011-s01.root"); fm0 = TFile::Open("/scratch/ursl/bmm4/s01/bmm-mc-Summer17_private-BdToMuMu-s01.root"); fm1 = TFile::Open("/scratch/ursl/bmm4/s01/bmm-mc-Summer17_private-BsToMuMu-s01.root"); if (bdt < -1.) { bdtcut = 0.28; } else { bdtcut = bdt; } } TTree *td = (TTree*)fd->Get("candAnaMuMu/events"); TTree *tm0 = (TTree*)fm0->Get("candAnaMuMu/events"); TTree *tm1 = (TTree*)fm1->Get("candAnaMuMu/events"); TH1D *hd0 = new TH1D("hd0", "mass", 60, 4.8, 6.0); TH1D *hm0 = new TH1D("hm0", "mass", 60, 4.8, 6.0); TH1D *hm1 = new TH1D("hm1", "mass", 60, 4.8, 6.0); int ichan(0); string cut(Form("chan==%d && !gmuid &&hlt1&&tos&&l1t &&bdt>%4.3f && m < 6 && m > 4.8", ichan, bdtcut)); cout << cut << endl; td->Draw("m>>hd0", cut.c_str()); tm0->Draw("m>>hm0", cut.c_str()); tm1->Draw("m>>hm1", cut.c_str()); c0->Clear(); // c0->Divide(2,2); // c0->cd(1); hd0->Draw("hist"); // B0 -> mu mu // c0->cd(2); hm0->Fit("gaus"); double p0 = hm0->GetFunction("gaus")->GetParameter(1); double s0 = hm0->GetFunction("gaus")->GetParameter(2); cout << "p0: " << p0 << " s0: " << s0 << endl; // Bs -> mu mu // c0->cd(3); hm1->Fit("gaus"); double p1 = hm1->GetFunction("gaus")->GetParameter(1); double s1 = hm1->GetFunction("gaus")->GetParameter(2); cout << "p1: " << p1 << " s1: " << s1 << endl; // c0->cd(4); TH1D *hFit = (TH1D*)hd0->Clone("hFit"); hFit->SetTitle(""); hFit->SetMinimum(0.); TF1 *f1 = new TF1("f1", adhocfunction, 4.8, 6.0, 7); f1->SetParameter(0, 1); f1->SetParLimits(0, 0., 1000.); f1->SetParameter(1, p0); f1->FixParameter(1, p0); f1->SetParameter(2, s0); f1->FixParameter(2, s0); f1->SetParameter(3, 1); f1->SetParLimits(3, 0., 1000.); f1->SetParameter(4, p1); f1->FixParameter(4, p1); f1->SetParameter(5, s1); f1->FixParameter(5, s1); f1->SetParameter(6, 1); hFit->Fit(f1, "RL", "", 5.1, 6.0); double nb0 = hFit->GetFunction("f1")->GetParameter(0); double eb0 = hFit->GetFunction("f1")->GetParError(0); double nbs = hFit->GetFunction("f1")->GetParameter(3); double ebs = hFit->GetFunction("f1")->GetParError(3); double nco = hFit->GetFunction("f1")->GetParameter(6); double eco = hFit->GetFunction("f1")->GetParError(6); TF1 *f0 = (TF1*)hm0->GetFunction("gaus")->Clone("f0"); TF1 *fs = (TF1*)hm1->GetFunction("gaus")->Clone("fs"); f0->SetParameter(0, nb0); f0->SetLineColor(kRed+2); fs->SetParameter(0, nbs); fs->SetLineColor(kBlue); f0->Draw("same"); fs->Draw("same"); tl->DrawLatexNDC(0.10, 0.92, era.c_str()); tl->DrawLatexNDC(0.40, 0.92, Form("BDT > %3.2f", bdtcut)); double iB0 = f0->Integral(5.1, 5.6); double iBs = fs->Integral(5.1, 5.6); float nB0 = f0->Integral(5.2, 5.3)/hFit->GetBinWidth(1); float nB0E = eb0/nb0*nB0; float nBs = fs->Integral(5.3, 5.45)/hFit->GetBinWidth(1); float nBsE = ebs/nbs*nBs; double iComb = nco*(6.0-5.6); double ratioVs(0.); double relErrs(0.); double ratioEs(0.01); double ratioVd(0.); double relErrd(0.); double ratioEd(0.01); if (iComb > 1.e-3) { ratioVs = iBs/iComb; relErrs = TMath::Sqrt((ebs/nbs)*(ebs/nbs) + (eco/nco)*(eco/nco)); ratioEs = relErrs * ratioVs; ratioVd = iB0/iComb; relErrd = TMath::Sqrt((eb0/nb0)*(eb0/nb0) + (eco/nco)*(eco/nco)); ratioEd = relErrd * ratioVd; } cout << "ratio of B0/comb: " << iB0 << "/" << iComb << " = " << ratioVd << " +/- " << ratioEd << " relErr: " << relErrd << endl; cout << "ratio of Bs/comb: " << iBs << "/" << iComb << " = " << ratioVs << " +/- " << ratioEs << " relErr: " << relErrs << endl; ofstream TEX(Form("invertedMuonIDStudies.tex"), ios::app); TEX << Form("\\vdef{%ss01:nb0:bdt%3.2f:chan%d} {%3.1f}", era.c_str(), bdtcut, ichan, nB0) << endl; TEX << Form("\\vdef{%ss01:eb0:bdt%3.2f:chan%d} {%3.1f}", era.c_str(), bdtcut, ichan, nB0E) << endl; TEX << Form("\\vdef{%ss01:nbs:bdt%3.2f:chan%d} {%3.1f}", era.c_str(), bdtcut, ichan, nBs) << endl; TEX << Form("\\vdef{%ss01:ebs:bdt%3.2f:chan%d} {%3.1f}", era.c_str(), bdtcut, ichan, nBsE) << endl; TEX.close(); c0->SaveAs(Form("invertedMuonIDcomb-%s-%3.2f.pdf", era.c_str(), bdtcut)); if (hBd) { hBd->SetBinContent(hBd->FindBin(bdtcut), ratioVd); hBd->SetBinError(hBd->FindBin(bdtcut), ratioEd); } if (hBs) { hBs->SetBinContent(hBs->FindBin(bdtcut), ratioVs); hBs->SetBinError(hBs->FindBin(bdtcut), ratioEs); } }