int main(int argc, char *argv[]) { TApplication *a = new TApplication("app", &argc, argv); TCanvas *c1 = makegraph(); a->Run(); return 0; }
main(int argc, char **argv) { FILE *infile; char *rv; char *badinpstr = "badly formed input file %s, continuing\n"; if (argc == 1) { printf("itm <spec-file0> <spec-file1> ....\n\n"); return; } while (--argc) { if (rv = makegraph(*(++argv))) { fprintf(stderr,"Error processing file %s: %s\n",*argv,rv); } } /* while on argc */ exit(0); }
int peos_create_instance(char *model_file,peos_resource_t *resources,int num_resources) { peos_context_t *context; if ((context = find_free_entry()) == NULL) { return -1; } if ((context->process_graph = makegraph(model_file)) != NULL) { context->pid = peos_get_pid(context); context->num_resources = num_resources; context -> resources = resources; strcpy(context->model, model_file); context->status = PEOS_READY; initialize_graph(context->process_graph, context->pid); return (context->pid); } return -1; }
int main() { char line[BUFSIZ]; int row[BUFSIZ]; int opt = 0; FILE* file= NULL; //char* fn = NULL; int ncol= 0; int tmp = 0; graph* g = NULL; int* ap = NULL; // pointer within g->adjmtx router* r = NULL; int fromto[2] = { 0, 0 }; for (;;) { printf("\n%s\n", menu); switch (readNat(&opt)) { case 0: freegraph(&g); goto END; case 1: printf("%s\n", prompt1); //fn = readFilename(); if ((file = fopen(readFilename(), "r")) == NULL) { printf("File not found.\n"); break; } // file is opened while (getaline(line, BUFSIZ, file)) {//printf("while ...\n"); tmp = 0; if ((tmp = linetoints(line, row)) > 0) { if (ncol == 0) {// 1st row ncol = tmp; if (g != NULL) freegraph(&g); // g == NULL g = makegraph(ncol); ap = g->adjmtx + intcpy(g->adjmtx, row, ncol); } else if (ncol == tmp) { ap += intcpy(ap, row, ncol); } else { printf("File content invalid: different number of elements on different rows.\n"); break; } } } ncol = 0; fclose(file); //if (isvalidgraph(g)) {// graph is created printf("Original routing table is as follows:\n"); printgraph(g); /*} else { freegraph(&g); printf("File content invalid: elements on upper-left to bottom-right diagonal are not all-zero, "); printf("or, the upper-right half of the matrix and the bottom-left half are not symmetric.\n"); }*/ break; case 2: if (g == NULL) { printf("There is no data currently.\nPlease use option 1 to read a routing table data file first.\n"); break; } printf("%s\n", prompt2); if (readNat(&tmp) < 0 || tmp > g->size) { printf("Not a valid router id.\n"); break; } r = makerouter(tmp, g->size); buildtable(r, g); printf("The routing table for router %d is:\n", r->id); printrouter(r); freerouter(r); break; case 3: if (g == NULL) { printf("There is no data currently.\nPlease use option 1 to read a routing table data file first.\n"); break; } printf("%s\n", prompt3); if (read2Nats(fromto) < 0 || fromto[0] > g->size || fromto[1] > g->size) { printf("Invalid input. Please follow the format:\n\tvalid_src_router_id valid_dest_router_id.\n"); break; } // fromto[2] is valid r = makerouter(fromto[0], g->size); dijkstra(g, r->id, r->varray); printpath(r, fromto[1]); freerouter(r); break; default: printf("%s\n", prompt0); break; } } END: return 0; }
TGraphAsymmErrors* makeJetIDcut(int ilist, int dataType){ int ilistw; if(ilist== 6) { JetID = "Max p_{T}^{charged}/p_{T}^{jet}"; JetIDcut[0]=0.05; JetIDcut[1]=1; ilistw=1;} else if(ilist== 7) { JetID = "#Sum p_{T}^{charged}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.6;} else if(ilist== 8) { JetID = "Max p_{T}^{neutral}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.08;} else if(ilist== 9) { JetID = "#Sum p_{T}^{neutral}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.15;} else if(ilist== 10) { JetID = "Max p_{T}^{photons}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.50;} else if(ilist== 11) { JetID = "#Sum p_{T}^{photons}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.3;} else if(ilist== 12) { JetID = "(#Sigma p_{T}^{charged}+#Sigma p_{T}^{photons}+#Sigma p_{T}^{neutral}+#Sigma p_{T}^{#mu}+#Sigma p_{T}^{e})/p_{T}^{jet}";JetIDcut[0]=0; JetIDcut[1]=1.01; ilistw=3;} else if(ilist== 13) { JetID = "(#Sigma p_{T}^{charged}+#Sigma p_{T}^{photons}+#Sigma p_{T}^{neutral}+#Sigma p_{T}^{#mu}+#Sigma p_{T}^{e})/p_{T}^{raw}"; JetIDcut[0]=0;JetIDcut[1]=1.13;} else if(ilist== 14) { JetID = "Max p_{T}^{neutral} /Max(#Sigma p_{T}^{charged},#Sigma p_{T}^{neutral})";JetIDcut[0]=0;JetIDcut[1]=0.975;ilistw=2;} if(ilist==12 || ilist==13 || ilist==14 ){ double binbound_JetID[]={0,0.2,0.4,0.6,0.7,0.8,0.84,0.86,0.88,0.9,0.92,0.94,0.96,0.98,1.0,1.02,1.04,1.06,1.1,1.15,1.2,1.3,1.4,1.6,1.8,2.};} else{ double binbound_JetID[]={0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.};} //double binbound_JetID[]={0,0.025,0.05,0.075,0.1,0.125,0.15,0.175,0.2,0.225,0.25,0.275,0.3,0.325,0.35,0.375,0.4,0.425,0.45,0.475,0.5}; int Nbin_JetID=sizeof(binbound_JetID)/sizeof(double)-1; TString JetIDName=JetIDNameList[ilist]; TString histonameIDData=Form("jetpt%s",JetIDName.Data()); TH2F* hdata2F=(TH2F*)fDataPPbJetID->Get(histonameIDData); TH2F *hPPb2D= (TH2F*)fMCPPb->Get(Form("jetpt%s",JetIDName.Data())); TH2F *hPPb2D_real= (TH2F*)fMCPPb->Get(Form("jetpt%s_real",JetIDName.Data())); TH2F *hPPb2D_fake= (TH2F*)fMCPPb->Get(Form("jetpt%s_fake",JetIDName.Data())); const double binbound_pt_coarse[]={0,30,70,150,200,600}; const int Nbin_pt_coarse=sizeof(binbound_pt_coarse)/sizeof(double)-1; const double xrange_JetID[2]={binbound_JetID[0]+1e-4,binbound_JetID[Nbin_JetID]-1e-4}; xrange_JetIDcut[0]=JetIDcut[0]+1e-4; xrange_JetIDcut[1]=JetIDcut[1]-1e-4; //TH1D* hPPb_pt=hPPb2D->ProjectionX("hPPb_pt",hPPb2D->GetYaxis()->FindBin(xrange_JetID[0]),hPPb2D->GetYaxis()->FindBin(xrange_JetID[1])); TH1D* hPPb_pt=hPPb2D->ProjectionX("hPPb_pt"); TH1D* hPPb_pt_real=hPPb2D_real->ProjectionX("hPPb_pt_real"); TH1D* hPPb_pt_fake=hPPb2D_fake->ProjectionX("hPPb_pt_fake"); TH1D* hPPb_JetIDcut_pt=hPPb2D->ProjectionX("hPPb_JetIDcut_pt",hPPb2D->GetYaxis()->FindBin(xrange_JetIDcut[0]),hPPb2D->GetYaxis()->FindBin(xrange_JetIDcut[1])); TH1D* hPPb_JetIDcut_pt_real=hPPb2D_real->ProjectionX("hPPb_JetIDcut_pt_real",hPPb2D_real->GetYaxis()->FindBin(xrange_JetIDcut[0]),hPPb2D_real->GetYaxis()->FindBin(xrange_JetIDcut[1])); TH1D* hPPb_JetIDcut_pt_fake=hPPb2D_fake->ProjectionX("hPPb_JetIDcut_pt_fake",hPPb2D_fake->GetYaxis()->FindBin(xrange_JetIDcut[0]),hPPb2D_fake->GetYaxis()->FindBin(xrange_JetIDcut[1])); hPPb_JetIDcut_pt_real = (TH1D*)hPPb_JetIDcut_pt_real->Rebin(Nbin_pt,hPPb_JetIDcut_pt_real->GetName(),binbound_pt); hPPb_JetIDcut_pt = (TH1D*)hPPb_JetIDcut_pt->Rebin(Nbin_pt,hPPb_JetIDcut_pt->GetName(),binbound_pt); hPPb_pt_real = (TH1D*)hPPb_pt_real->Rebin(Nbin_pt,hPPb_pt_real->GetName(),binbound_pt); hPPb_pt = (TH1D*)hPPb_pt->Rebin(Nbin_pt,hPPb_pt->GetName(),binbound_pt); TGraphAsymmErrors *g = new TGraphAsymmErrors(); TH1D* histo1=(TH1D*)hdata2F->ProjectionX("histo1",hdata2F->GetYaxis()->FindBin(xrange_JetIDcut[0]),hdata2F->GetYaxis()->FindBin(xrange_JetIDcut[1])); TH1D* histo2=(TH1D*)hdata2F->ProjectionX("histo2"); histo1=(TH1D*)histo1->Rebin(Nbin_pt,"histo1",binbound_pt); histo2=(TH1D*)histo2->Rebin(Nbin_pt,"histo2",binbound_pt); normalizeByBinWidth(histo1); normalizeByBinWidth(histo2); g=makegraph(histo1,histo2); g->SetMarkerSize(1.5); TGraphAsymmErrors *gfake = new TGraphAsymmErrors(); TGraphAsymmErrors *greal = new TGraphAsymmErrors(); TGraphAsymmErrors *ginc = new TGraphAsymmErrors(); TH1D* ratio_hPPb_JetIDcutvsnocut_pt=(TH1D*)hPPb_JetIDcut_pt->Clone("ratio_hPPb_JetIDcut_ptcutvsnocut_pt"); ginc=makegraph(ratio_hPPb_JetIDcutvsnocut_pt,hPPb_pt); ginc->SetMarkerSize(1.5); /*TH1D* ratio_hPPb_JetIDcutvsnocut_pt_fake=(TH1D*)hPPb_JetIDcut_pt_fake->Clone("ratio_hPPb_JetIDcutvsnocut_pt_fake"); TH1D* cl_hPPb_pt_fake=(TH1D*)hPPb_pt_fake->Clone("cl_hPPb_pt_fake"); cl_hPPb_pt_fake=(TH1D*)cl_hPPb_pt_fake->Rebin(Nbin_pt_coarse,"cl_hPPb_pt_fake",binbound_pt_coarse); ratio_hPPb_JetIDcutvsnocut_pt_fake=(TH1D*)ratio_hPPb_JetIDcutvsnocut_pt_fake->Rebin(Nbin_pt_coarse,"ratio_hPPb_JetIDcutvsnocut_pt_fake",binbound_pt_coarse); normalizeByBinWidth(ratio_hPPb_JetIDcutvsnocut_pt_fake); normalizeByBinWidth(cl_hPPb_pt_fake); gfake=makegraph(ratio_hPPb_JetIDcutvsnocut_pt_fake,cl_hPPb_pt_fake); gfake->SetMarkerSize(1.5); gfake->SetMarkerStyle(20); gfake->SetMarkerColor(2); gfake->SetLineColor(2); TH1D* ratio_hPPb_JetIDcutvsnocut_pt_real=(TH1D*)hPPb_JetIDcut_pt_real->Clone("ratio_hPPb_JetIDcutvsnocut_pt_real"); greal=makegraph(ratio_hPPb_JetIDcutvsnocut_pt_real,hPPb_pt_real); greal->SetMarkerSize(1.5); greal->SetMarkerStyle(29); greal->SetMarkerColor(4); greal->SetLineColor(4); */ T->SetNDC(); T->SetTextAlign(12); T->SetTextSize(0.03); T->SetTextColor(1); T->SetTextFont(42); if(ilistw==2){ if(dataType==1) T->DrawLatex(0.22,0.98-ilistw*0.05,Form("Cut %d: %.2f<%s<%.3f",ilistw,JetID.Data(),xrange_JetIDcut[0],xrange_JetIDcut[1]));} else{ if(dataType==1) T->DrawLatex(0.22,0.98-ilistw*0.05,Form("Cut %d: %.2f<%s<%.2f",ilistw,JetID.Data(),xrange_JetIDcut[0],xrange_JetIDcut[1]));} if(dataType==1) return g; else return ginc; }
void overlayoneJetIDcut(){ gStyle->SetErrorX(0); gStyle->SetOptStat(kFALSE); int ilist=12; int ilistw; TString JetID, Unit; double JetIDcut[2]; if(ilist== 6) { JetID = "Max p_{T}^{charged}/p_{T}^{jet}"; JetIDcut[0]=0.05; JetIDcut[1]=1; ilistw=1;} else if(ilist== 7) { JetID = "#Sum p_{T}^{charged}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.6;} else if(ilist== 8) { JetID = "Max p_{T}^{neutral}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.08;} else if(ilist== 9) { JetID = "#Sum p_{T}^{neutral}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.15;} else if(ilist== 10) { JetID = "Max p_{T}^{photons}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.50;} else if(ilist== 11) { JetID = "#Sum p_{T}^{photons}/p_{T}^{jet}"; JetIDcut[0] = 0; JetIDcut[1]=0.3;} else if(ilist== 12) { JetID = "(#Sigma p_{T}^{charged}+#Sigma p_{T}^{photons}+#Sigma p_{T}^{neutral}+#Sigma p_{T}^{#mu}+#Sigma p_{T}^{e})/p_{T}^{jet}";JetIDcut[0]=0; JetIDcut[1]=1.01; ilistw=3;} else if(ilist== 13) { JetID = "(#Sigma p_{T}^{charged}+#Sigma p_{T}^{photons}+#Sigma p_{T}^{neutral}+#Sigma p_{T}^{#mu}+#Sigma p_{T}^{e})/p_{T}^{raw}"; JetIDcut[0]=0;JetIDcut[1]=1.13;} else if(ilist== 14) { JetID = "Max p_{T}^{neutral} /Max(#Sigma p_{T}^{charged},#Sigma p_{T}^{neutral})";JetIDcut[0]=0;JetIDcut[1]=0.975;ilistw=2;} if(ilist==12 || ilist==13 || ilist==14 ){ double binbound_JetID[]={0,0.2,0.4,0.6,0.7,0.8,0.84,0.86,0.88,0.9,0.92,0.94,0.96,0.98,1.0,1.02,1.04,1.06,1.1,1.15,1.2,1.3,1.4,1.6,1.8,2.};} else{ double binbound_JetID[]={0,0.05,0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7,0.75,0.8,0.85,0.9,0.95,1.};} //double binbound_JetID[]={0,0.025,0.05,0.075,0.1,0.125,0.15,0.175,0.2,0.225,0.25,0.275,0.3,0.325,0.35,0.375,0.4,0.425,0.45,0.475,0.5}; int Nbin_JetID=sizeof(binbound_JetID)/sizeof(double)-1; const int Neta=8; const TString etabinname[Neta]={"12_22","7_12","3_7","-3_3","-7_-3","-12_-7","-22_-12","-10_10"}; const double etabin[Neta]={1.0,0.5,0.4,0.6,0.4,0.5,1,2}; const TString etastring[Neta]={"-2.2<#eta_{CM}<-1.2","-1.2<#eta_{CM}<-0.7","-0.7<#eta_{CM}<-0.3","-0.3<#eta_{CM}<0.3","0.3<#eta_{CM}<0.7","0.7<#eta_{CM}<1.2","1.2<#eta_{CM}<2.2","-1.0<#eta_{CM}<1.0"}; int ieta=7; TString JetIDName=JetIDNameList[ilist]; TString histonameID=Form("jetpt%sEtaBin%s",JetIDName.Data(),etabinname[ieta].Data()); TH2F* hdata2F=(TH2F*)fDataPPbJetID->Get(histonameID); const double xrange_JetID[2]={binbound_JetID[0]+1e-4,binbound_JetID[Nbin_JetID]-1e-4}; xrange_JetIDcut[0]=JetIDcut[0]+1e-4; xrange_JetIDcut[1]=JetIDcut[1]-1e-4; TGraphAsymmErrors *g = new TGraphAsymmErrors(); TH1D* histo1=(TH1D*)hdata2F->ProjectionX("histo1",hdata2F->GetYaxis()->FindBin(xrange_JetIDcut[0]),hdata2F->GetYaxis()->FindBin(xrange_JetIDcut[1])); TH1D* histo2=(TH1D*)hdata2F->ProjectionX("histo2"); histo1=(TH1D*)histo1->Rebin(Nbin_pt,"histo1",binbound_pt); histo2=(TH1D*)histo2->Rebin(Nbin_pt,"histo2",binbound_pt); normalizeByBinWidth(histo1); normalizeByBinWidth(histo2); histo1->SetMarkerStyle(20); histo1->SetMarkerSize(1.5); histo1->SetMarkerColor(1); histo1->SetLineColor(1); histo2->SetMarkerStyle(24); histo2->SetMarkerSize(1.5); histo2->SetMarkerColor(2); histo2->SetLineColor(2); g=makegraph(histo1,histo2); g->SetMarkerSize(1.5); c1 = new TCanvas("c1","",400,700); makeMultiPanelCanvas(c1,1,2,-0.15,0,0.22,0.16,0.03); TLatex *T=new TLatex(); T->SetNDC(); T->SetTextAlign(12); T->SetTextSize(0.03); T->SetTextColor(1); T->SetTextFont(42); T->DrawLatex(0.22,0.98-ilistw*0.05,Form("Cut: %.2f<%s<%.2f",JetID.Data(),xrange_JetIDcut[0],xrange_JetIDcut[1])); TH1F* hFrame=new TH1F("","",1000,0,1000); c1->cd(1)->SetLogy(); hFrame->SetLineColor(0); hFrame->GetXaxis()->SetRangeUser(25,600); hFrame->GetYaxis()->SetTitle("#frac{dN}{dp_{T}}"); hFrame->GetXaxis()->SetTitle(""); hFrame->GetYaxis()->SetRangeUser(0.11,1e8); fixedFontHist(hFrame,1.7,2.8); hFrame->DrawCopy(); histo1->Draw("same"); histo2->Draw("same"); TLegend *leg1=new TLegend(0.65,0.72,0.85,0.85); leg1->SetBorderSize(0); leg1->SetFillColor(0); leg1->SetTextSize(0.04); leg1->AddEntry(histo2,"Before Cut","lp"); leg1->AddEntry(histo1,"After Cut","lp"); leg1->Draw("same"); c1->cd(2); g->SetMarkerStyle(20); g->SetMarkerColor(1); g->SetLineColor(1); T->SetTextSize(0.06); hFrame->GetYaxis()->SetTitle("Cut Efficiency"); hFrame->GetYaxis()->SetRangeUser(0.82,1.025); hFrame->GetXaxis()->SetTitle("p_{T}^{jet} (GeV/c)"); hFrame->DrawCopy(); g->Draw("Psame"); T->DrawLatex(0.5,0.25,etastring[ieta]); TLine *l =new TLine(25,1,600,1); l->SetLineStyle(2); l->SetLineColor(1); l->Draw("same"); c1->Print(Form("pic/overlay_best_JetIDcut.png")); c1->Print(Form("pic/overlay_best_JetIDcut.pdf")); }