void writef(File *f) { Posn n; char *name; int i, samename, newfile; ulong dev; uvlong qid; long mtime, appendonly, length; newfile = 0; samename = Strcmp(&genstr, &f->name) == 0; name = Strtoc(&f->name); i = statfile(name, &dev, &qid, &mtime, 0, 0); if(i == -1) newfile++; else if(samename && (f->dev!=dev || f->qidpath!=qid || f->mtime<mtime)){ f->dev = dev; f->qidpath = qid; f->mtime = mtime; warn_S(Wdate, &genstr); free(name); return; } if(genc) free(genc); genc = Strtoc(&genstr); if((io=create(genc, 1, 0666L)) < 0) error_r(Ecreate, genc); dprint("%s: ", genc); if(statfd(io, 0, 0, 0, &length, &appendonly) > 0 && appendonly && length>0){ free(name); error(Eappend); } n = writeio(f); if(f->name.s[0]==0 || samename){ if(addr.r.p1==0 && addr.r.p2==f->b.nc) f->cleanseq = f->seq; state(f, f->cleanseq==f->seq? Clean : Dirty); } if(newfile) dprint("(new file) "); if(addr.r.p2>0 && filereadc(f, addr.r.p2-1)!='\n') warn(Wnotnewline); closeio(n); if(f->name.s[0]==0 || samename){ if(statfile(name, &dev, &qid, &mtime, 0, 0) > 0){ f->dev = dev; f->qidpath = qid; f->mtime = mtime; checkqid(f); } } free(name); }
void make1DLimit(TString combine_dir,TString type= "WH",bool blind=true){ //TString combine_dir = "test_runSusyHgg/signalInj_sms_ChiWH_0_175/"; //WH wh_limits.push_back(wh_125); wh_limits.push_back(wh_150); wh_limits.push_back(wh_175); wh_limits.push_back(wh_200); //HH hh_limits.push_back(hh_125); hh_limits.push_back(hh_150); hh_limits.push_back(hh_175); hh_limits.push_back(hh_200); TGraph obser( (200-125)/25 ); TGraph graph( (200-125)/25 ); TGraphAsymmErrors error( (200-125)/25 ); TGraphAsymmErrors error2S( (200-125)/25 ); TGraph obser_r( (200-125)/25 ); TGraph graph_r( (200-125)/25 ); TGraphAsymmErrors error_r( (200-125)/25 ); TGraphAsymmErrors error_r2S( (200-125)/25 ); TGraphErrors* theo = 0; if(type=="WH") theo = getTheoXSec("xsecs/CharginoNeutralino.txt"); else theo = getTheoXSec("xsecs/Higgsino_ElectroHiggs.txt"); //else theo = getTheoXSec("/home/amott/HggApp/SusyHgg/xsecs/Higgsino.txt"); for(int m=125;m<=200;m+=25) { int i=(m-125)/25; TFile limit_file(Form("%s/higgsCombineChi%s_0_%d.Asymptotic.mH120.root",combine_dir.Data(),type.Data(),m) ); TTree *limit_tree = (TTree*)limit_file.Get("limit"); TTreeFormula limit_form("get_limit","limit",limit_tree); float down_2s = -1; float down = -1; float exp = -1; float up = -1; float up_2s = -1; float obs = -1; if( type == "WH" ) { down_2s = wh_limits.at(i)[0]; down = wh_limits.at(i)[1]; exp = wh_limits.at(i)[2]; up = wh_limits.at(i)[3]; up_2s = wh_limits.at(i)[4]; obs = wh_limits.at(i)[5]; } else if ( type == "HH") { down_2s = hh_limits.at(i)[0]; down = hh_limits.at(i)[1]; exp = hh_limits.at(i)[2]; up = hh_limits.at(i)[3]; up_2s = hh_limits.at(i)[4]; obs = hh_limits.at(i)[5]; } else { std::cerr << "UNRECOGNIZED OPTION!!! QUITTING" << std::endl; } if(i==0) m+=5; //first point is actually at m=130 graph.SetPoint(i,float(m), exp); error.SetPoint(i,float(m), exp); error2S.SetPoint(i, float(m), exp); error.SetPointError(i, 0, 0, exp-down, up-exp); error2S.SetPointError(i, 0 , 0 , exp-down_2s, up_2s-exp); graph_r.SetPoint(i,float(m),exp/theo->Eval(m)); error_r.SetPoint(i,float(m),exp/theo->Eval(m)); error_r2S.SetPoint(i,float(m),exp/theo->Eval(m)); error_r.SetPointError(i,0,0,(exp-down)/theo->Eval(m),(up-exp)/theo->Eval(m)); error_r2S.SetPointError(i, 0, 0, (exp-down_2s)/theo->Eval(m), (up_2s-exp)/theo->Eval(m) ); obser.SetPoint(i,float(m),obs); obser_r.SetPoint(i,float(m),obs/theo->Eval(m)); if(i==0) m-=5; } TCanvas cv; cv.SetLogy(); cv.SetGrid(1,1); theo->SetMaximum(1e2); theo->SetMinimum(1e-2); theo->GetYaxis()->SetLabelSize(0.05); theo->GetYaxis()->SetTitleSize(0.06); theo->GetYaxis()->SetTitleOffset(0.8); theo->GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); theo->GetXaxis()->SetTitle("m_{chargino} (GeV)"); if(type=="HH") theo->GetXaxis()->SetTitle("m_{neutralino} (GeV)"); theo->SetFillColor(kBlue); theo->SetLineStyle(kDotted); theo->SetLineWidth(2); error.SetMaximum(1e2); error.SetMinimum(1e-2); error.GetYaxis()->SetLabelSize(0.04); error.GetYaxis()->SetTitleSize(0.06); error.GetYaxis()->SetTitleOffset(0.8); error.GetXaxis()->SetLabelSize(0.04); error.GetXaxis()->SetTitleSize(0.05); error.GetXaxis()->SetTitleOffset(0.9); error.GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)"); error.GetXaxis()->SetTitle("m_{chargino} (GeV)"); if(type=="HH") error.GetXaxis()->SetTitle("m_{neutralino} (GeV)"); error.SetFillColor(kGreen); error2S.SetFillColor(kYellow); error2S.SetTitle(""); error.SetTitle(""); error.Draw("A3"); error2S.Draw("3SAME"); error.Draw("3"); theo->SetTitle(""); theo->Draw("3C"); graph.SetLineStyle(kDashed); graph.SetLineWidth(2.0); graph.SetTitle(""); graph.Draw("C"); obser.SetLineStyle(1); obser.SetLineWidth(2.0); obser.SetTitle(""); if(!blind) obser.Draw("C"); TLegend leg(0.65,0.65,0.89,0.89); leg.SetFillColor(0); leg.SetBorderSize(0); leg.AddEntry(&graph,"expected","l"); leg.AddEntry(&error,"expected #pm1#sigma","F"); leg.AddEntry(&error2S,"expected #pm2#sigma","F"); leg.AddEntry(theo,"theoretical","f"); if(!blind) leg.AddEntry(&obser,"observed","l"); leg.Draw("SAME"); TLatex latex; latex.SetNDC(); latex.SetTextAngle(0); latex.SetTextColor(kBlack); float extraTextSize = extraOverCmsTextSize*cmsSize; latex.SetTextFont(lumifont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(lumix, lumiy,lumiText); latex.SetTextFont(cmsTextFont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(cmsx, cmsy, CMSText); latex.SetTextFont(extraTextFont); latex.SetTextAlign(31); latex.SetTextSize(extraTextSize); latex.DrawLatex(extrax, extray, extraText); TString infix=(blind ? "" : "_OBS"); cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.png"); cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.pdf"); cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.C"); error_r.SetMaximum(1e2); error_r.SetMinimum(1e-2); error_r.SetTitle(""); error_r.GetYaxis()->SetLabelSize(0.04); error_r.GetYaxis()->SetTitleSize(0.06); error_r.GetYaxis()->SetTitleOffset(0.8); error_r.GetXaxis()->SetLabelSize(0.04); error_r.GetXaxis()->SetTitleSize(0.05); error_r.GetXaxis()->SetTitleOffset(0.9); error_r.GetYaxis()->SetTitle("#sigma_{95%}/#sigma_{NLO}"); if(type=="HH") error_r.GetXaxis()->SetTitle("m_{neutralino} (GeV)"); else error_r.GetXaxis()->SetTitle("m_{chargino} (GeV)"); error_r.SetFillColor(kGreen); error_r2S.SetFillColor(kYellow); error_r2S.SetTitle(""); error_r.Draw("A3"); error_r2S.Draw("3SAME"); error_r.Draw("3SAME"); graph_r.SetLineStyle(kDashed); graph_r.SetLineWidth(2); graph_r.SetTitle(""); graph_r.Draw("C"); TLine l(125,1,205,1); l.SetLineWidth(3); l.SetLineColor(kBlue); //l.Draw("SAME"); obser_r.SetLineWidth(2); if(!blind) obser_r.Draw("C"); leg.Draw("SAME"); //lbl.SetY(0.20); //leg.SetY1NDC(0.28); //leg.SetY2NDC(0.43); //prelim.Draw(); //lbl.Draw(); latex.SetTextFont(lumifont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(lumix, lumiy,lumiText); latex.SetTextFont(cmsTextFont); latex.SetTextAlign(31); latex.SetTextSize(cmsSize); latex.DrawLatex(cmsx, cmsy, CMSText); latex.SetTextFont(extraTextFont); latex.SetTextAlign(31); latex.SetTextSize(extraTextSize); latex.DrawLatex(extrax, extray, extraText); cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.png"); cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.pdf"); cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.C"); }
int START_HERE(int argc,char *argv[]) { /* Byte Order This code is just for little-endian :( */ int word = 1; char *p =(char*) & word ; if(p[0] == 1){ printf("Is Little Endian\n"); } else { printf("Is Big Endian STOP ...\n"); exit(0); } if(argc <= 1 ){ ak_usage(); return 0; } /* Bootstrap */ if(compare_str(argv[1] , "-bs" )){ /*Is big ?.. > 512*/ b_strap_sz(argv[2]); printf(" %s -> %s \n",argv[2],argv[3]); char code_mbr[RUTINE_OCT]; int file_d = open (argv[2], O_RDONLY ); /* Return the file descriptor */ /* Read 440 B and save in code_mbr */ error_r( read(file_d, code_mbr, RUTINE_OCT ) , argv[2] ); close(file_d); char buff_mag[2]= { 0x55, 0xaa } ; int fd = open (argv[3], O_WRONLY ); lseek (fd,0 , SEEK_SET ); error_w( write(fd, code_mbr, RUTINE_OCT ),argv[3] ); /* Write magic */ lseek (fd ,510, SEEK_SET ); error_w( write(fd, buff_mag, 2 ), argv[3] ); close(file_d); return 0; } /* Write BOOT_LOADER */ if( compare_str(argv[1] , "-ak" )){ printf(" %s -> %s \n",argv[2],argv[3]); char buffer_lb_loader[AKERNELLOADER_SZ ]; /* Buffer */ int fd_lb_loader = open (argv[2], O_RDONLY ); /* Return the file descriptor */ /* Read size( AKERNELLOADER_SZ ) and save in buffer */ error_r( read(fd_lb_loader, buffer_lb_loader, AKERNELLOADER_SZ ) , argv[2] ); close(fd_lb_loader); int fd_transfer = open (argv[3], O_WRONLY ); lseek (fd_transfer ,512, SEEK_SET ); error_w( write(fd_transfer, buffer_lb_loader,AKERNELLOADER_SZ ), argv[3] ); close(fd_lb_loader); return 0; } if( compare_str(argv[1] , "-v" )){ puts("Akernelloader version:"_ak_version); return 0; } ak_usage(); /* help */ }