/************************************************************************* * This function is the entry point of the initial partitioning algorithm. * This algorithm assembles the graph to all the processors and preceed * serially. **************************************************************************/ idx_t Mc_Diffusion(ctrl_t *ctrl, graph_t *graph, idx_t *vtxdist, idx_t *where, idx_t *home, idx_t npasses) { idx_t h, i, j; idx_t nvtxs, nedges, ncon, pass, iter, domain, processor; idx_t nparts, mype, npes, nlinks, me, you, wsize; idx_t nvisited, nswaps = -1, tnswaps, done, alldone = -1; idx_t *rowptr, *colind, *diff_where, *sr_where, *ehome, *map, *rmap; idx_t *pack, *unpack, *match, *proc2sub, *sub2proc; idx_t *visited, *gvisited; real_t *transfer, *npwgts, maxdiff, minflow, maxflow; real_t lbavg, oldlbavg, ubavg, *lbvec; real_t *diff_flows, *sr_flows; real_t diff_lbavg, sr_lbavg, diff_cost, sr_cost; idx_t *rbuffer, *sbuffer; idx_t *rcount, *rdispl; real_t *solution, *load, *workspace; matrix_t matrix; graph_t *egraph; if (graph->ncon > 3) return 0; WCOREPUSH; nvtxs = graph->nvtxs; nedges = graph->nedges; ncon = graph->ncon; nparts = ctrl->nparts; mype = ctrl->mype; npes = ctrl->npes; ubavg = ravg(ncon, ctrl->ubvec); /* initialize variables and allocate memory */ lbvec = rwspacemalloc(ctrl, ncon); diff_flows = rwspacemalloc(ctrl, ncon); sr_flows = rwspacemalloc(ctrl, ncon); load = rwspacemalloc(ctrl, nparts); solution = rwspacemalloc(ctrl, nparts); npwgts = graph->gnpwgts = rwspacemalloc(ctrl, ncon*nparts); matrix.values = rwspacemalloc(ctrl, nedges); transfer = matrix.transfer = rwspacemalloc(ctrl, ncon*nedges); proc2sub = iwspacemalloc(ctrl, gk_max(nparts, npes*2)); sub2proc = iwspacemalloc(ctrl, nparts); match = iwspacemalloc(ctrl, nparts); rowptr = matrix.rowptr = iwspacemalloc(ctrl, nparts+1); colind = matrix.colind = iwspacemalloc(ctrl, nedges); rcount = iwspacemalloc(ctrl, npes); rdispl = iwspacemalloc(ctrl, npes+1); pack = iwspacemalloc(ctrl, nvtxs); unpack = iwspacemalloc(ctrl, nvtxs); rbuffer = iwspacemalloc(ctrl, nvtxs); sbuffer = iwspacemalloc(ctrl, nvtxs); map = iwspacemalloc(ctrl, nvtxs); rmap = iwspacemalloc(ctrl, nvtxs); diff_where = iwspacemalloc(ctrl, nvtxs); ehome = iwspacemalloc(ctrl, nvtxs); wsize = gk_max(sizeof(real_t)*nparts*6, sizeof(idx_t)*(nvtxs+nparts*2+1)); workspace = (real_t *)gk_malloc(wsize, "Mc_Diffusion: workspace"); graph->ckrinfo = (ckrinfo_t *)gk_malloc(nvtxs*sizeof(ckrinfo_t), "Mc_Diffusion: rinfo"); /* construct subdomain connectivity graph */ matrix.nrows = nparts; SetUpConnectGraph(graph, &matrix, (idx_t *)workspace); nlinks = (matrix.nnzs-nparts) / 2; visited = iwspacemalloc(ctrl, matrix.nnzs); gvisited = iwspacemalloc(ctrl, matrix.nnzs); for (pass=0; pass<npasses; pass++) { rset(matrix.nnzs*ncon, 0.0, transfer); iset(matrix.nnzs, 0, gvisited); iset(matrix.nnzs, 0, visited); iter = nvisited = 0; /* compute ncon flow solutions */ for (h=0; h<ncon; h++) { rset(nparts, 0.0, solution); ComputeLoad(graph, nparts, load, ctrl->tpwgts, h); lbvec[h] = (rmax(nparts, load)+1.0/nparts) * (real_t)nparts; ConjGrad2(&matrix, load, solution, 0.001, workspace); ComputeTransferVector(ncon, &matrix, solution, transfer, h); } oldlbavg = ravg(ncon, lbvec); tnswaps = 0; maxdiff = 0.0; for (i=0; i<nparts; i++) { for (j=rowptr[i]; j<rowptr[i+1]; j++) { maxflow = rmax(ncon, transfer+j*ncon); minflow = rmin(ncon, transfer+j*ncon); maxdiff = (maxflow - minflow > maxdiff) ? maxflow - minflow : maxdiff; } } while (nvisited < nlinks) { /* compute independent sets of subdomains */ iset(gk_max(nparts, npes*2), UNMATCHED, proc2sub); CSR_Match_SHEM(&matrix, match, proc2sub, gvisited, ncon); /* set up the packing arrays */ iset(nparts, UNMATCHED, sub2proc); for (i=0; i<npes*2; i++) { if (proc2sub[i] == UNMATCHED) break; sub2proc[proc2sub[i]] = i/2; } iset(npes, 0, rcount); for (i=0; i<nvtxs; i++) { domain = where[i]; processor = sub2proc[domain]; if (processor != UNMATCHED) rcount[processor]++; } rdispl[0] = 0; for (i=1; i<npes+1; i++) rdispl[i] = rdispl[i-1] + rcount[i-1]; iset(nvtxs, UNMATCHED, unpack); for (i=0; i<nvtxs; i++) { domain = where[i]; processor = sub2proc[domain]; if (processor != UNMATCHED) unpack[rdispl[processor]++] = i; } SHIFTCSR(i, npes, rdispl); iset(nvtxs, UNMATCHED, pack); for (i=0; i<rdispl[npes]; i++) { ASSERT(unpack[i] != UNMATCHED); domain = where[unpack[i]]; processor = sub2proc[domain]; if (processor != UNMATCHED) pack[unpack[i]] = i; } /* Compute the flows */ if (proc2sub[mype*2] != UNMATCHED) { me = proc2sub[2*mype]; you = proc2sub[2*mype+1]; ASSERT(me != you); for (j=rowptr[me]; j<rowptr[me+1]; j++) { if (colind[j] == you) { visited[j] = 1; rcopy(ncon, transfer+j*ncon, diff_flows); break; } } for (j=rowptr[you]; j<rowptr[you+1]; j++) { if (colind[j] == me) { visited[j] = 1; for (h=0; h<ncon; h++) { if (transfer[j*ncon+h] > 0.0) diff_flows[h] = -1.0 * transfer[j*ncon+h]; } break; } } nswaps = 1; rcopy(ncon, diff_flows, sr_flows); iset(nvtxs, 0, sbuffer); for (i=0; i<nvtxs; i++) { if (where[i] == me || where[i] == you) sbuffer[i] = 1; } egraph = ExtractGraph(ctrl, graph, sbuffer, map, rmap); if (egraph != NULL) { icopy(egraph->nvtxs, egraph->where, diff_where); for (j=0; j<egraph->nvtxs; j++) ehome[j] = home[map[j]]; RedoMyLink(ctrl, egraph, ehome, me, you, sr_flows, &sr_cost, &sr_lbavg); if (ncon <= 4) { sr_where = egraph->where; egraph->where = diff_where; nswaps = BalanceMyLink(ctrl, egraph, ehome, me, you, diff_flows, maxdiff, &diff_cost, &diff_lbavg, 1.0/(real_t)nvtxs); if ((sr_lbavg < diff_lbavg && (diff_lbavg >= ubavg-1.0 || sr_cost == diff_cost)) || (sr_lbavg < ubavg-1.0 && sr_cost < diff_cost)) { for (i=0; i<egraph->nvtxs; i++) where[map[i]] = sr_where[i]; } else { for (i=0; i<egraph->nvtxs; i++) where[map[i]] = diff_where[i]; } } else { for (i=0; i<egraph->nvtxs; i++) where[map[i]] = egraph->where[i]; } gk_free((void **)&egraph->xadj, &egraph->nvwgt, &egraph->adjncy, &egraph, LTERM); } /* Pack the flow data */ iset(nvtxs, UNMATCHED, sbuffer); for (i=0; i<nvtxs; i++) { domain = where[i]; if (domain == you || domain == me) sbuffer[pack[i]] = where[i]; } } /* Broadcast the flow data */ gkMPI_Allgatherv((void *)&sbuffer[rdispl[mype]], rcount[mype], IDX_T, (void *)rbuffer, rcount, rdispl, IDX_T, ctrl->comm); /* Unpack the flow data */ for (i=0; i<rdispl[npes]; i++) { if (rbuffer[i] != UNMATCHED) where[unpack[i]] = rbuffer[i]; } /* Do other stuff */ gkMPI_Allreduce((void *)visited, (void *)gvisited, matrix.nnzs, IDX_T, MPI_MAX, ctrl->comm); nvisited = isum(matrix.nnzs, gvisited, 1)/2; tnswaps += GlobalSESum(ctrl, nswaps); if (iter++ == NGD_PASSES) break; } /* perform serial refinement */ Mc_ComputeSerialPartitionParams(ctrl, graph, nparts); Mc_SerialKWayAdaptRefine(ctrl, graph, nparts, home, ctrl->ubvec, 10); /* check for early breakout */ for (h=0; h<ncon; h++) { lbvec[h] = (real_t)(nparts) * npwgts[rargmax_strd(nparts,npwgts+h,ncon)*ncon+h]; } lbavg = ravg(ncon, lbvec); done = 0; if (tnswaps == 0 || lbavg >= oldlbavg || lbavg <= ubavg + 0.035) done = 1; alldone = GlobalSEMax(ctrl, done); if (alldone == 1) break; } /* ensure that all subdomains have at least one vertex */ /* iset(nparts, 0, match); for (i=0; i<nvtxs; i++) match[where[i]]++; done = 0; while (done == 0) { done = 1; me = iargmin(nparts, match); if (match[me] == 0) { if (ctrl->mype == PE) printf("WARNING: empty subdomain %"PRIDX" in Mc_Diffusion\n", me); you = iargmax(nparts, match); for (i=0; i<nvtxs; i++) { if (where[i] == you) { where[i] = me; match[you]--; match[me]++; done = 0; break; } } } } */ /* now free memory and return */ gk_free((void **)&workspace, (void **)&graph->ckrinfo, LTERM); graph->gnpwgts = NULL; graph->ckrinfo = NULL; WCOREPOP; return 0; }
int main() { ic::Plot::SetHTTStyle(); std::string dir="/vols/cms04/pjd12/invcmssws/CMSSW_7_1_5/src/HiggsAnalysis/CombinedLimit/exocombcards/"; std::vector<Scan> scans; // scans.push_back({"higgsCombinefullScan.MultiDimFit.mH125.root", "Observed", 1, nullptr}); // scans.push_back({"higgsCombineexpected.MultiDimFit.mH125.root", "Exp. for SM H", 32, nullptr}); // scans.push_back({"higgsCombinenoBBBScan.MultiDimFit.mH125.root", "no bbb syst.", 38, nullptr}); scans.push_back({dir+"higgsCombineCombExp.MultiDimFit.mH125.root", "Exp. for SM H", 1, nullptr}); scans.push_back({dir+"higgsCombineCombObs.MultiDimFit.mH125.root", "Obs. for SM H", 1, nullptr}); TCanvas c1("canvas","canvas"); std::vector<TLine *> lines; TLegend *leg = new TLegend(0.65,0.75,0.9,0.9,"","brNDC"); unsigned counter = 0; for (auto & sc : scans) { TFile f1(sc.file.c_str()); TTree *t1 = dynamic_cast<TTree*>(f1.Get("limit")); double best1 = 0.0; TString res; sc.gr = new TGraph(ExtractGraph(t1, best1)); if(counter==1){ auto x1 = GetCrossings(*(sc.gr), 1.0); auto x2 = GetCrossings(*(sc.gr), 3.84); lines.push_back(new TLine(x1[0],0,x1[0],1.0)); lines.back()->SetLineColor(2); lines.back()->SetLineWidth(2); lines.push_back(new TLine(x2[0],0,x2[0],3.84)); lines.back()->SetLineColor(2); lines.back()->SetLineWidth(2); } sc.gr->SetLineColor(sc.color); sc.gr->SetLineWidth(3); sc.gr->Draw(counter ? "LSAME" : "AL"); TString leg_text = "#splitline{"+sc.label+"}{"+res+"}"; leg->AddEntry(sc.gr, leg_text, "L"); counter++; } // c1.cd(); // // g1.Print(); // g1.SetLineColor(1); // g1.SetLineWidth(2); // // g1.SetMarkerColor(7); // g1.Draw("AC"); scans[0].gr->SetMaximum(9); scans[0].gr->SetMinimum(0.); scans[0].gr->GetXaxis()->SetRangeUser(0., 0.9); scans[0].gr->GetXaxis()->SetTitle("BR_{inv}"); scans[0].gr->GetXaxis()->SetTitleOffset(1.1); scans[0].gr->GetXaxis()->SetNdivisions(1005,true); scans[0].gr->GetXaxis()->SetLabelSize(0.05); scans[0].gr->GetYaxis()->SetLabelSize(0.05); scans[0].gr->GetXaxis()->SetLabelOffset(0.02); scans[0].gr->GetYaxis()->SetLabelOffset(0.02); scans[0].gr->GetYaxis()->SetTitle("-2 #Delta ln L"); scans[0].gr->SetLineStyle(2); scans[0].gr->SetLineColor(1); leg->SetBorderSize(1); leg->SetTextFont(42); leg->SetTextSize(0.03); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); leg->Draw(); lines.push_back(new TLine(0.,1,0.9,1.0)); lines.back()->SetLineColor(2); lines.push_back(new TLine(0.,3.84,0.9,3.84)); lines.back()->SetLineColor(2); // for (auto l : lines) l->Draw(); DrawCMSLogoTest(&c1,"CMS","preliminary",10); TLatex lat = TLatex(); lat.SetNDC(); lat.SetTextSize(0.04); lat.SetTextFont(42); TLatex lat2 = TLatex(); lat2.SetNDC(); lat2.SetTextSize(0.03); lat2.SetTextFont(42); lat.DrawLatex(0.2,0.73,"Combination of all"); lat.DrawLatex(0.2,0.68,"H#rightarrow inv. channels"); c1.Update(); c1.SaveAs("scan.pdf"); return 0; }
int main() { ModTDRStyle(); std::vector<Scan> scans; //scans.push_back({"higgsCombinefullScan.MultiDimFit.mH125.root", "with syst.", 1, nullptr}); //scans.push_back({"higgsCombinefastScan.MultiDimFit.mH125.root", "no syst.", 32, nullptr}); //scans.push_back({"higgsCombinenoBBBScan.MultiDimFit.mH125.root", "no bbb syst.", 38, nullptr}); // scans.push_back({"thesis/higgsCombineFullScan.MultiDimFit.mH125.root", "Stat+Syst+Theory", 1, nullptr}); scans.push_back({"higgsCombineFullScan.MultiDimFit.mH125.root", "Mass Scan", kAzure-4, nullptr}); // scans.push_back({"higgsCombineStatOnly.MultiDimFit.mH125.root", "Stat Only", kBlue+1, nullptr}); //scans.push_back({"thesis/higgsCombineStatAndTh.MultiDimFit.mH125.root", "Stat+Theory", 39, nullptr}); TCanvas c1("canvas","canvas"); std::vector<TLine *> lines; TLegend *leg = new TLegend(0.37,0.65,0.73,0.9,"","brNDC"); unsigned counter = 0; for (auto & sc : scans) { TFile f1(sc.file.c_str()); TTree *t1 = dynamic_cast<TTree*>(f1.Get("limit")); double best1 = 0.0; sc.gr = new TGraph(ExtractGraph(t1, best1)); auto x1 = GetCrossings(*(sc.gr), 1.0); TString res; if (x1.size() == 2) { double err = (x1[1]-x1[0])/2.0; std::cout << "Best fit is: " << best1 << " +/- " << err << std::endl; lines.push_back(new TLine(x1[0],0,x1[0],1.0)); lines.back()->SetLineColor(sc.color); lines.back()->SetLineWidth(2); lines.push_back(new TLine(x1[1],0,x1[1],1.0)); lines.back()->SetLineColor(sc.color); lines.back()->SetLineWidth(2); res = TString::Format("%.1f#pm%.1f",best1,err); } sc.gr->SetLineColor(sc.color); sc.gr->SetLineWidth(3); sc.gr->Draw(counter ? "LSAME" : "AL"); TString leg_text = "#splitline{"+sc.label+"}{"+res+"}"; leg->AddEntry(sc.gr, leg_text, "L"); counter++; } // c1.cd(); // // g1.Print(); // g1.SetLineColor(1); // g1.SetLineWidth(2); // // g1.SetMarkerColor(7); // g1.Draw("AC"); scans[0].gr->SetMaximum(4); scans[0].gr->GetXaxis()->SetRangeUser(110, 130); // scans[0].gr->GetXaxis()->SetTitle("Signal Strength, #mu"); scans[0].gr->GetXaxis()->SetTitle("m_{H} [GeV]"); scans[0].gr->GetYaxis()->SetTitle("-2 #Delta ln L"); scans[0].gr->GetXaxis()->SetTitleFont(62); scans[0].gr->GetYaxis()->SetTitleFont(62); leg->SetBorderSize(1); leg->SetTextFont(42); leg->SetTextSize(0.03); leg->SetLineColor(0); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); leg->Draw(); lines.push_back(new TLine(110,1,130,1)); lines.back()->SetLineColor(2); for (auto l : lines) l->Draw(); TLatex *title_latex = new TLatex(); title_latex->SetNDC(); title_latex->SetTextSize(0.035); title_latex->SetTextFont(62); title_latex->SetTextAlign(31); double height = 0.94; title_latex->DrawLatex(0.95,height,"19.7 fb^{-1} (8 TeV) + 4.9 fb^{-1} (7 TeV)"); title_latex->SetTextAlign(11); title_latex->DrawLatex(0.17,height,"H#rightarrow#tau#tau"); title_latex->SetTextSize(0.08); title_latex->DrawLatex(0.21, 0.25, "#mu#tau_{h}"); c1.Update(); c1.SaveAs("scan.pdf"); return 0; }