void plotPerCategory(){ gStyle->SetOptStat(0); gStyle->SetOptTitle(0); // setTDRStyle(); gStyle->SetPadTopMargin (0.04); gStyle->SetPadBottomMargin(0.12); gStyle->SetPadRightMargin (0.05); gStyle->SetPadLeftMargin (0.12); gStyle->SetTitleSize(0.04, "XYZ"); gStyle->SetTitleXOffset(1.1); gStyle->SetTitleYOffset(1.45); gStyle->SetPalette(1); gStyle->SetNdivisions(505); TCanvas* c1; TH1F* framework; TH2F* framework2d; TLegend* LEG, *LEGTH; TGraph* Ref; string Directories[]={"cards_SB13TeV_cp1.00_brn0.00", "cards_SB13TeV_GGF_cp1.00_brn0.00", "cards_SB13TeV_VBF_cp1.00_brn0.00"}; for(unsigned int D=0;D<sizeof(Directories)/sizeof(string);D++){ string Dir = Directories[D]; string prod = "pp"; if(Dir.find("GGF")!=std::string::npos)prod="gg"; if(Dir.find("VBF")!=std::string::npos)prod="qq"; bool strengthLimit = false; if(prod=="pp")strengthLimit=true; c1 = new TCanvas("c", "c",600,600); c1->SetLogy(true); framework = new TH1F("Graph","Graph",1,190,1510); framework->SetStats(false); framework->SetTitle(""); framework->GetXaxis()->SetTitle("Higgs boson mass [GeV]"); if(strengthLimit){ framework->GetYaxis()->SetTitle("#mu = #sigma_{95%} / #sigma_{th}"); framework->GetYaxis()->SetRangeUser(1E-2,1E3); }else{ framework->GetYaxis()->SetTitle((string("#sigma_{95%} (") + prod + " #rightarrow H #rightarrow ZZ) (fb)").c_str()); framework->GetYaxis()->SetRangeUser(1E1,1E5); } framework->GetYaxis()->SetTitleOffset(1.40); framework->Draw(); LEG = new TLegend(0.70,0.70,0.95,0.94); LEG->SetFillStyle(0); LEG->SetBorderSize(0); LEG->SetHeader("Observed:"); TLegend* LEGExp = NULL; LEGExp = new TLegend(0.45,0.70,0.70,0.94); LEGExp->SetFillStyle(0); LEGExp->SetBorderSize(0); LEGExp->SetHeader("Expected:"); getGraph("=0 Jet" , 2, 2, 1, LEG , NULL, 2, Dir+ "_eq0jets/Stength_LimitSummary")->Draw("C same"); getGraph("#geq1 Jets" , 4, 2, 1, LEG , NULL, 2, Dir+"_geq1jets/Stength_LimitSummary")->Draw("C same"); getGraph("VBF" , 6, 2, 1, LEG , NULL, 2, Dir+ "_vbf/Stength_LimitSummary")->Draw("C same"); getGraph("Combined" , 1, 2, 1, LEG , NULL, 2, Dir+ "/Stength_LimitSummary")->Draw("C same"); getGraph("=0 Jet" , 2, 2, 2, LEGExp , NULL, 1, Dir+ "_eq0jets/Stength_LimitSummary")->Draw("C same"); getGraph("#geq1 Jets" , 4, 2, 2, LEGExp , NULL, 1, Dir+"_geq1jets/Stength_LimitSummary")->Draw("C same"); getGraph("VBF" , 6, 2, 2, LEGExp , NULL, 1, Dir+ "_vbf/Stength_LimitSummary")->Draw("C same"); getGraph("Combined" , 1, 2, 2, LEGExp , NULL, 1, Dir+ "/Stength_LimitSummary")->Draw("C same"); // LEGTH->Draw("same"); LEGExp ->Draw("same"); LEG ->Draw("same"); /* char LumiLabel[1024]; sprintf(LumiLabel,"CMS preliminary, #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}",13.0,2.3); TPaveText *pave = new TPaveText(0.1,0.96,0.94,0.99,"NDC"); pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextAlign(32); pave->SetTextFont(42); pave->AddText(LumiLabel); pave->Draw("same");*/ utils::root::DrawPreliminary(2268.759, 13, gPad->GetLeftMargin(),gPad->GetBottomMargin(),gPad->GetRightMargin(),gPad->GetTopMargin()+0.025); if(strengthLimit){ TLine* SMLine = new TLine(framework->GetXaxis()->GetXmin(),1.0,framework->GetXaxis()->GetXmax(),1.0); SMLine->SetLineWidth(2); SMLine->SetLineStyle(1); SMLine->SetLineColor(4); SMLine->Draw("same C"); }else{ TGraph* THXSec = Hxswg::utils::getXSec(Dir); THXSec->SetLineWidth(2); THXSec->SetLineStyle(1); THXSec->SetLineColor(4); scaleGraph(THXSec, 1000); //convert cross-section to fb THXSec->Draw("same C"); } c1->SaveAs((Dir+"/perCat_FinalPlot.png").c_str()); c1->SaveAs((Dir+"/perCat_FinalPlot.pdf").c_str()); c1->SaveAs((Dir+"/perCat_FinalPlot.C" ).c_str()); } /* for(unsigned int D=0;D<sizeof(Directories)/sizeof(string);D++){ string Dir = Directories[D]; c1 = new TCanvas("c", "c",600,600); c1->SetLogy(true); framework = new TH1F("Graph","Graph",1,150,1050); framework->SetStats(false); framework->SetTitle(""); framework->GetXaxis()->SetTitle("Higgs boson mass [GeV]"); // framework->GetYaxis()->SetTitle("#mu = #sigma_{95%} / #sigma_{th}"); // framework->GetYaxis()->SetTitle("#sigma_{95%} (fb)"); framework->GetYaxis()->SetTitle("#sigma_{95%} (pp #rightarrow H #rightarrow ZZ) (fb)"); framework->GetYaxis()->SetTitleOffset(1.40); framework->GetYaxis()->SetRangeUser(1E1,1E4); framework->Draw(); LEG = new TLegend(0.70,0.70,0.95,0.94); LEG->SetFillStyle(0); LEG->SetBorderSize(0); // LEG->SetHeader("Expected @95% C.L."); LEGTH = new TLegend(0.45,0.70,0.70,0.94); LEGTH->SetFillStyle(0); LEGTH->SetBorderSize(0); LEGTH->SetHeader("Theoretical"); // getGraph("SM-like" , 1, 2, 1, LEG , NULL, 1, Dir+ "/Stength_LimitSummary")->Draw("C same"); getGraph("C'=1.0" , 2, 2, 2, LEG , NULL, 1, Dir+"_cp1.00_brn0.00/Stength_LimitSummary")->Draw("C same"); getGraph("C'=0.8" , 4, 2, 2, LEG , NULL, 1, Dir+"_cp0.80_brn0.00/Stength_LimitSummary")->Draw("C same"); getGraph("C'=0.6" , 6, 2, 2, LEG , NULL, 1, Dir+"_cp0.60_brn0.00/Stength_LimitSummary")->Draw("C same"); getGraph("C'=0.4" , 7, 2, 2, LEG , NULL, 1, Dir+"_cp0.40_brn0.00/Stength_LimitSummary")->Draw("C same"); getGraph("C'=0.2" , 8, 2, 2, LEG , NULL, 1, Dir+"_cp0.20_brn0.00/Stength_LimitSummary")->Draw("C same"); // LEGTH->Draw("same"); LEG ->Draw("same"); char LumiLabel[1024]; sprintf(LumiLabel,"CMS preliminary, #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}",13.0,2.2); TPaveText *pave = new TPaveText(0.1,0.96,0.94,0.99,"NDC"); pave->SetBorderSize(0); pave->SetFillStyle(0); pave->SetTextAlign(32); pave->SetTextFont(42); pave->AddText(LumiLabel); pave->Draw("same"); TLine* SMLine = new TLine(framework->GetXaxis()->GetXmin(),1.0,framework->GetXaxis()->GetXmax(),1.0); SMLine->SetLineWidth(2); SMLine->SetLineStyle(1); SMLine->SetLineColor(4); // SMLine->Draw("same C"); c1->SaveAs((Dir+"/perC_FinalPlot.png").c_str()); c1->SaveAs((Dir+"/perC_FinalPlot.pdf").c_str()); c1->SaveAs((Dir+"/perC_FinalPlot.C" ).c_str()); } */ }
/* twopi_layout: */ void twopi_layout(Agraph_t * g) { Agnode_t *ctr = 0; char *s; int setRoot = 0; pointf sc; int doScale = 0; int r; if (agnnodes(g) == 0) return; twopi_init_graph(g); s = agget(g, "root"); if ((s = agget(g, "root"))) { if (*s) { ctr = agfindnode(g, s); if (!ctr) { agerr(AGWARN, "specified root node \"%s\" was not found.", s); agerr(AGPREV, "Using default calculation for root node\n"); setRoot = 1; } } else { setRoot = 1; } } if ((s = agget(g, "scale")) && *s) { if ((r = sscanf (s, "%lf,%lf",&sc.x,&sc.y))) { if (r == 1) sc.y = sc.x; doScale = 1; if (Verbose) fprintf (stderr, "scale = (%f,%f)\n", sc.x, sc.y); } } if (agnnodes(g)) { Agraph_t **ccs; Agraph_t *sg; Agnode_t *c = NULL; Agnode_t *n; int ncc; int i; ccs = ccomps(g, &ncc, 0); if (ncc == 1) { c = circleLayout(g, ctr); if (setRoot && !ctr) ctr = c; n = agfstnode(g); free(ND_alg(n)); ND_alg(n) = NULL; if (doScale) scaleGraph (g, c, sc); adjustNodes(g); spline_edges(g); } else { pack_info pinfo; getPackInfo (g, l_node, CL_OFFSET, &pinfo); pinfo.doSplines = 0; for (i = 0; i < ncc; i++) { sg = ccs[i]; if (ctr && agcontains(sg, ctr)) c = ctr; else c = 0; nodeInduce(sg); c = circleLayout(sg, c); if (setRoot && !ctr) ctr = c; if (doScale) scaleGraph (sg, c, sc); adjustNodes(sg); } n = agfstnode(g); free(ND_alg(n)); ND_alg(n) = NULL; packSubgraphs(ncc, ccs, g, &pinfo); spline_edges(g); } for (i = 0; i < ncc; i++) { agdelete(g, ccs[i]); } free(ccs); } if (setRoot) agset (g, "root", agnameof (ctr)); dotneato_postprocess(g); }
int main( int argc, char* argv[] ) { ZGDrawTools::setStyle(); std::string axisName; if( sigmaTimesBR ) //axisName = "95\% CL UL on #sigma #times BR(A#rightarrowZ#gamma#rightarrowl^{+}l^{-}#gamma) [fb]"; axisName = "#sigma(pp#rightarrowA+X#rightarrowZ#gamma+X, Z#rightarrowl^{+}l^{-}) [fb]"; else axisName = "#sigma(pp#rightarrowA+X#rightarrowZ#gamma+X) [fb]"; //axisName = "95\% CL UL on #sigma #times BR(A#rightarrowZ#gamma) [fb]"; TFile* file = TFile::Open("limit_plots.root"); TGraphAsymmErrors* gr_exp = (TGraphAsymmErrors*)file->Get("expected"); TGraphAsymmErrors* gr_exp_1sigma = (TGraphAsymmErrors*)file->Get("oneSigma"); TGraphAsymmErrors* gr_exp_2sigma = (TGraphAsymmErrors*)file->Get("twoSigma"); TGraphAsymmErrors* gr_obs = (TGraphAsymmErrors*)file->Get("observed"); if( !sigmaTimesBR ) { scaleGraph( gr_exp ); scaleGraph( gr_exp_1sigma ); scaleGraph( gr_exp_2sigma ); scaleGraph( gr_obs ); } gr_obs->SetLineWidth(2); gr_exp->SetLineWidth(2); gr_exp->SetLineStyle(2); gr_exp_1sigma->SetLineWidth(0); gr_exp_1sigma->SetFillColor(8); gr_exp_2sigma->SetLineWidth(0); gr_exp_2sigma->SetFillColor(219); TCanvas* c1 = new TCanvas( "c1", "", 600, 600 ); c1->cd(); float yMax = 150.; if( sigmaTimesBR ) yMax = 5.; TH2D* h2_axes = new TH2D("axes", "", 10, 200., 1200., 10, 0., yMax ); h2_axes->SetYTitle( axisName.c_str() ); h2_axes->SetXTitle( "Resonance Mass [GeV]"); h2_axes->GetXaxis()->SetNdivisions(1006); h2_axes->Draw(); gr_exp_2sigma->Draw("E3 same"); gr_exp_1sigma->Draw("E3 same"); gr_exp ->Draw("L same"); gr_obs ->Draw("L same"); gr_exp_1sigma->SetLineWidth(0); gr_exp_2sigma->SetLineWidth(0); gr_exp_1sigma->SetLineStyle(0); gr_exp_2sigma->SetLineStyle(0); TLegend* legend; std::string title = "Narrow Signal Model"; legend = new TLegend( 0.55, 0.6 , 0.9, 0.9 ); legend->SetFillColor(0); legend->SetTextSize(0.038); legend->SetTextFont(42); legend->SetHeader(title.c_str()); legend->AddEntry( gr_obs, "95% CL limit", "L" ); legend->AddEntry( gr_exp, "Median Expected", "L" ); legend->AddEntry( gr_exp_1sigma, "68% Expected", "F" ); legend->AddEntry( gr_exp_2sigma, "95% Expected", "F" ); legend->Draw("same"); TPaveText* label_cms = new TPaveText(0.143,0.96,0.27,0.965, "brNDC"); label_cms->SetBorderSize(0); label_cms->SetFillColor(kWhite); label_cms->SetTextSize(0.042); label_cms->SetTextAlign(11); // align left label_cms->SetTextFont(42); label_cms->AddText( "CMS" ); label_cms->Draw("same"); TPaveText* label_top = new TPaveText(0.4,0.959,0.975,0.963, "brNDC"); label_top->SetBorderSize(0); label_top->SetFillColor(kWhite); label_top->SetTextSize(0.038); label_top->SetTextAlign(31); // align right label_top->SetTextFont(42); // label_top->SetTextFont(62); label_top->AddText("19.7 fb^{-1} (8 TeV)"); label_top->Draw("same"); gPad->RedrawAxis(); c1->SaveAs( "limitPlot8TeV.eps" ); c1->SaveAs( "limitPlot8TeV.pdf" ); return 0; }
void plotLimit(string outputDir="./", TString inputs="", TString inputs_blinded="", TString inputXSec="", bool strengthLimit=true, bool blind=false, double energy=7, double luminosity=5.035, TString legendName="ee and #mu#mu channels") { setTDRStyle(); gStyle->SetPadTopMargin (0.05); gStyle->SetPadBottomMargin(0.12); gStyle->SetPadRightMargin (0.16); gStyle->SetPadLeftMargin (0.14); gStyle->SetTitleSize(0.04, "XYZ"); gStyle->SetTitleXOffset(1.1); gStyle->SetTitleYOffset(1.45); gStyle->SetPalette(1); gStyle->SetNdivisions(505); //get the limits from the tree TFile* file = TFile::Open(inputs); printf("Looping on %s\n",inputs.Data()); if(!file) return; if(file->IsZombie()) return; TFile* file_blinded = TFile::Open(inputs_blinded); printf("Looping on %s\n",inputs_blinded.Data()); if(!file_blinded) return; if(file_blinded->IsZombie()) return; TTree* tree_blinded = (TTree*)file_blinded->Get("limit"); tree_blinded->GetBranch("mh" )->SetAddress(&Tmh ); tree_blinded->GetBranch("limit" )->SetAddress(&Tlimit ); tree_blinded->GetBranch("limitErr" )->SetAddress(&TlimitErr); tree_blinded->GetBranch("quantileExpected")->SetAddress(&TquantExp); TGraph* ExpLimitm2 = getLimitGraph(tree_blinded,0.025); TGraph* ExpLimitm1 = getLimitGraph(tree_blinded,0.160); TGraph* ExpLimit = getLimitGraph(tree_blinded,0.500); TGraph* ExpLimitp1 = getLimitGraph(tree_blinded,0.840); TGraph* ExpLimitp2 = getLimitGraph(tree_blinded,0.975); file_blinded->Close(); TTree* tree = (TTree*)file->Get("limit"); tree->GetBranch("mh" )->SetAddress(&Tmh ); tree->GetBranch("limit" )->SetAddress(&Tlimit ); tree->GetBranch("limitErr" )->SetAddress(&TlimitErr); tree->GetBranch("quantileExpected")->SetAddress(&TquantExp); TGraph* ObsLimit = getLimitGraph(tree,-1 ); file->Close(); FILE* pFileSStrenght = fopen((outputDir+"SignalStrenght").c_str(),"w"); std::cout << "Printing Signal Strenght" << std::endl; for(int i=0;i<ExpLimit->GetN();i++){ double M = ExpLimit->GetX()[i]; std::cout << "Mass: " << M << "; ExpLimit: " << ExpLimit->Eval(M) << std::endl; printf("$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ \\\\\\hline\n",M, ExpLimit->Eval(M), ExpLimitm1->Eval(M), ExpLimitp1->Eval(M), ExpLimitm2->Eval(M), ExpLimitp2->Eval(M)); fprintf(pFileSStrenght, "$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ & $%8.6E$ \\\\\\hline\n",M, ExpLimit->Eval(M), ExpLimitm1->Eval(M), ExpLimitp1->Eval(M), ExpLimitm2->Eval(M), ExpLimitp2->Eval(M), ObsLimit->Eval(M)); if(int(ExpLimit->GetX()[i])%50!=0)continue; //printf("%f ",ObsLimit->Eval(M)); }printf("\n"); fclose(pFileSStrenght); //get the pValue inputs = inputs.ReplaceAll("/LimitTree", "/PValueTree"); file = TFile::Open(inputs); printf("Looping on %s\n",inputs.Data()); if(!file) return; if(file->IsZombie()) return; tree = (TTree*)file->Get("limit"); tree->GetBranch("limit" )->SetAddress(&Tlimit ); TGraph* pValue = getLimitGraph(tree,-1); file->Close(); //make TH Cross-sections string suffix = outputDir; TGraph* THXSec = Hxswg::utils::getXSec(outputDir); scaleGraph(THXSec, 1000); //convert cross-section to fb double cprime=1.0; double brnew=0.0; double XSecScaleFactor = 1.0; if(suffix.find("_cp")!=string::npos){ sscanf(suffix.c_str()+suffix.find("_cp"), "_cp%lf_brn%lf", &cprime, &brnew); XSecScaleFactor = pow(cprime,2) * (1-brnew); } //XSecScaleFactor = 0.001; //pb to fb scaleGraph(THXSec, XSecScaleFactor); string prod = "pp_SM"; if(outputDir.find("ggH")!=std::string::npos)prod="gg"; if(outputDir.find("qqH")!=std::string::npos)prod="qq"; if(outputDir.find("ppH")!=std::string::npos)prod="pp"; strengthLimit = false; if(prod=="pp_SM")strengthLimit=true; //TGraph *XSecMELA = Hxswg::utils::getXSecMELA(cprime); //Hxswg::utils::multiplyGraph( ObsLimit, XSecMELA); //Hxswg::utils::multiplyGraph( ExpLimitm2, XSecMELA); //Hxswg::utils::multiplyGraph( ExpLimitm1, XSecMELA); //Hxswg::utils::multiplyGraph( ExpLimit, XSecMELA); //Hxswg::utils::multiplyGraph( ExpLimitp1, XSecMELA); //Hxswg::utils::multiplyGraph( ExpLimitp2, XSecMELA); //Scale exclusion XSec in fb scaleGraph(ObsLimit , 0.001); //pb to fb scaleGraph(ExpLimitm2, 0.001); //pb to fb scaleGraph(ExpLimitm1, 0.001); //pb to fb scaleGraph(ExpLimit , 0.001); //pb to fb scaleGraph(ExpLimitp1, 0.001); //pb to fb scaleGraph(ExpLimitp2, 0.001); //pb to fb //scal eTH cross-section and limits according to scale factor //this only apply to NarrowResonnance case if(strengthLimit){ Hxswg::utils::divideGraph(ObsLimit , THXSec); Hxswg::utils::divideGraph(ExpLimitm2 , THXSec); Hxswg::utils::divideGraph(ExpLimitm1 , THXSec); Hxswg::utils::divideGraph(ExpLimit , THXSec); Hxswg::utils::divideGraph(ExpLimitp1 , THXSec); Hxswg::utils::divideGraph(ExpLimitp2 , THXSec); Hxswg::utils::divideGraph(THXSec , THXSec); } //limits in terms of signal strength TCanvas* c = new TCanvas("c", "c",800,800); c->SetGridx(); c->SetGridy(); TH1F* framework = new TH1F("Graph","Graph",1,strengthLimit?199:199,2500); //3000); framework->SetStats(false); framework->SetTitle(""); framework->GetXaxis()->SetTitle("M_{H} [GeV]"); framework->GetYaxis()->SetTitleOffset(1.70); if(strengthLimit){ framework->GetYaxis()->SetTitle("#mu = #sigma_{95%} / #sigma_{th}"); framework->GetYaxis()->SetRangeUser(1E-4,1E3); c->SetLogy(true); }else{ framework->GetYaxis()->SetTitle((string("#sigma_{95%} (") + prod +" #rightarrow H #rightarrow ZZ) (pb)").c_str()); framework->GetYaxis()->SetRangeUser(1E-3,1E3); c->SetLogy(true); } framework->GetXaxis()->SetLabelOffset(0.007); framework->GetXaxis()->SetLabelSize(0.03); framework->GetXaxis()->SetTitleOffset(1.0); framework->GetXaxis()->SetTitleFont(42); framework->GetXaxis()->SetTitleSize(0.035); framework->GetYaxis()->SetLabelFont(42); framework->GetYaxis()->SetLabelOffset(0.007); framework->GetYaxis()->SetLabelSize(0.03); framework->GetYaxis()->SetTitleOffset(1.3); framework->GetYaxis()->SetTitleFont(42); framework->GetYaxis()->SetTitleSize(0.035); framework->Draw(); TGraph* TGObsLimit = ObsLimit; TGObsLimit->SetLineWidth(2); TGraph* TGExpLimit = ExpLimit; TGExpLimit->SetLineWidth(2); TGExpLimit->SetLineStyle(2); TCutG* TGExpLimit1S = GetErrorBand("1S", ExpLimitm1, ExpLimitp1); TCutG* TGExpLimit2S = GetErrorBand("2S", ExpLimitm2, ExpLimitp2); TGExpLimit2S->SetFillColor(5); THXSec->SetLineWidth(2); THXSec->SetLineStyle(1); THXSec->SetLineColor(4); TGExpLimit->SetLineColor(1); TGExpLimit->SetLineStyle(2); TGObsLimit->SetLineWidth(2); TGObsLimit->SetMarkerStyle(20); TGExpLimit2S->Draw("fc same"); TGExpLimit1S->Draw("fc same"); if(!blind) TGObsLimit->Draw("same P"); TGExpLimit->Draw("same c"); /*if(strengthLimit){ TLine* SMLine = new TLine(framework->GetXaxis()->GetXmin(),1.0,framework->GetXaxis()->GetXmax(),1.0); SMLine->SetLineWidth(2); SMLine->SetLineStyle(1); SMLine->SetLineColor(4); SMLine->Draw("same C"); }else{ THXSec->Draw("same C"); }*/ utils::root::DrawPreliminary(luminosity, energy, c); TLegend* LEG = new TLegend(0.55,0.75,0.85,0.95); LEG->SetHeader(""); LEG->SetFillColor(0); LEG->SetFillStyle(0); LEG->SetTextFont(42); LEG->SetBorderSize(0); //LEG->AddEntry(THXSec , "Th prediction" ,"L"); LEG->AddEntry(TGExpLimit , "median expected" ,"L"); LEG->AddEntry(TGExpLimit1S , "expected #pm 1#sigma" ,"F"); LEG->AddEntry(TGExpLimit2S , "expected #pm 2#sigma" ,"F"); if(!blind) LEG->AddEntry(TGObsLimit , "observed" ,"LP"); LEG->Draw(); c->RedrawAxis(); c->SaveAs((outputDir+"Limit.png").c_str()); c->SaveAs((outputDir+"Limit.C").c_str()); c->SaveAs((outputDir+"Limit.pdf").c_str()); //save a summary of the limits FILE* pFileSum = fopen((outputDir+"LimitSummary").c_str(),"w"); for(int i=0;i<TGExpLimit->GetN();i++){ double M = ExpLimit->GetX()[i]; fprintf(pFileSum, "$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ & $%8.6E$ & Th=$%8.6E$ & pValue=$%8.6E$\\\\\\hline\n",M, ExpLimit->Eval(M), ExpLimitm1->Eval(M), ExpLimitp1->Eval(M), ExpLimitm2->Eval(M), ExpLimitp2->Eval(M), ObsLimit->Eval(M), (THXSec!=NULL)?THXSec->Eval(M):-1, pValue->Eval(M)); if(int(ExpLimit->GetX()[i])%50!=0)continue; printf("%f ",ObsLimit->Eval(M)); }printf("\n"); fclose(pFileSum); pFileSum = fopen((outputDir+"LimitRange").c_str(),"w"); fprintf(pFileSum, "EXPECTED LIMIT --> "); printLimits(pFileSum,TGExpLimit, TGExpLimit->GetX()[0], TGExpLimit->GetX()[TGExpLimit->GetN()-1]); if(!blind) fprintf(pFileSum, "OBSERVED LIMIT --> "); printLimits(pFileSum,TGObsLimit, TGObsLimit->GetX()[0], TGObsLimit->GetX()[TGObsLimit->GetN()-1]); fprintf(pFileSum, "Exp Limits for Model are: "); for(int i=0;i<TGExpLimit->GetN();i++){if(int(TGExpLimit->GetX()[i])%50==0) fprintf(pFileSum, "%f+-%f ",TGExpLimit->GetY()[i], (ExpLimitp1->GetY()[i]-ExpLimitm1->GetY()[i])/2.0);}fprintf(pFileSum,"\n"); if(!blind) { fprintf(pFileSum, "Obs Limits for Model are: "); for(int i=0;i<TGObsLimit->GetN();i++){if(int(TGObsLimit->GetX()[i])%50==0) fprintf(pFileSum, "%f ",TGObsLimit->GetY()[i]);}fprintf(pFileSum,"\n"); } fclose(pFileSum); }
void drawBeamSpotGraph (TDirectory* directory, TH1* refHisto, const char* name, const char* fname, float* runSummary = 0) { TGraphErrors* graph = directory->Get(name); if ( graph==0 ) return; gStyle->SetOptFit(1); gStyle->SetOptStat(0); char newName[64]; newName[0] = 'c'; strcpy(&newName[1],name); std::string fullName(name); if ( fname ) fullName += fname; else fullName += directory->GetName(); TCanvas* c = new TCanvas(fullName.c_str(),fullName.c_str()); newName[0] = 'h'; TH1* h = refHisto->Clone(newName); h->Reset(); h->SetTitle(name); std::string xTitle("Luminosity block / "); xTitle += directory->GetName(); h->GetXaxis()->SetTitle(xTitle->c_str()); // int nb = h->GetNbinsX(); // if ( nb>50 ) { // int iscale = nb/50+1; // TAxis* xaxis = h->GetXaxis(); // for ( int i=1; i<=h->GetNbinsX(); ++i ) { // if ( (i-1)%iscale ) xaxis->SetBinLabel(i,""); // } // } TAxis* yaxis = h->GetYaxis(); float scale(1); if ( strcmp(name,"x")==0 ) { yaxis->SetTitle("PV x position [mm]"); scale = 10.; } else if ( strcmp(name,"y")==0 ) { yaxis->SetTitle("PV y position [mm]"); scale = 10.; } else if ( strcmp(name,"z")==0 ) { yaxis->SetTitle("PV z position [cm]"); } else if ( strcmp(name,"ex")==0 ) { yaxis->SetTitle("PV x width [#mum]"); scale = 10000.; } else if ( strcmp(name,"ey")==0 ) { yaxis->SetTitle("PV y width [#mum]"); scale = 10000.; } else if ( strcmp(name,"ez")==0 ) { yaxis->SetTitle("PV z width [cm]"); } else if ( strcmp(name,"corrxy")==0 ) { yaxis->SetTitle("PV x-y correlation"); } else if ( strcmp(name,"dxdz")==0 ) { yaxis->SetTitle("PV slope dx/dz [10^{-3}]"); scale = 1000.; } else if ( strcmp(name,"dydz")==0 ) { yaxis->SetTitle("PV slope dy/dz [10^{-3}]"); scale = 1000.; } scaleGraph(graph,scale); double xmin,xmax,ymin,ymax; graph->ComputeRange(xmin,ymin,xmax,ymax); h->SetMinimum((ymax+ymin)/2.-2.*(ymax-ymin)/2.); h->SetMaximum((ymax+ymin)/2.+2.*(ymax-ymin)/2.); h->Draw(); graph->SetMarkerStyle(20); // graph->SetMarkerColor(2); // graph->SetLineColor(2); graph->Draw("P"); graph->Fit("pol1","same"); graph->GetFunction("pol1")->SetLineStyle(2); graph->GetFunction("pol1")->SetLineWidth(2); TF1* fit = graph->GetFunction("pol1"); cout << "Pol1 fit chi2 = " << fit->GetChisquare() << " " << fit->GetNDF() << endl; // string epsName = fullName + ".eps"; // c->SaveAs(epsName.c_str()); // string pngName = fullName + ".png"; // c->SaveAs(pngName.c_str()); if ( runSummary ) { TF1* fit = graph->GetFunction("pol1"); runSummary[0] = fit->GetChisquare(); runSummary[1] = fit->GetNDF(); runSummary[2] = fit->GetParameter(0); runSummary[3] = fit->GetParError(0); runSummary[4] = fit->GetParameter(1); runSummary[5] = fit->GetParError(1); } }