ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/GeneralToolBox.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/GeneralToolBox.C (file contents):
Revision 1.25 by buchmann, Mon Dec 10 16:40:13 2012 UTC vs.
Revision 1.41 by buchmann, Fri Apr 26 07:00:24 2013 UTC

# Line 66 | Line 66 | namespace PlottingSetup {
66      bool is2012=true;
67      bool is53reco=true;
68      bool openBox = true;
69 +    vector<TH1F*> FakeHistoHeap;
70 +    bool DrawMetSignalRegionMllLines=false; // whether to draw the lines in mll plots for the MET signal region
71 +    float ConsideredZWidth=20;
72   }
73  
74   bool dopng=false;
# Line 92 | Line 95 | void write_error(string funcname, string
95   void write_info(string funcname, string text);
96   string get_directory();
97   bool Contains(string wholestring, string findme);
98 + TH1F* CollapseStack(THStack stack,TString hname);
99   //-------------------------------------------------------------------------------------
100  
101   template<typename U>
# Line 259 | Line 263 | void ensure_directory_exists(string this
263    }
264   }
265  
266 + void DeleteStack(THStack mcstack) {
267 +  TH1F* h;
268 +  TIter nextHist(mcstack.GetHists());
269 +  while ( h = (TH1F*)nextHist() ) {
270 +    h->Delete();
271 +  }
272 +  delete h;
273 + }
274 +
275 +
276   void DeadEnd(string message) {
277    dout << endl;
278    dout << "\033[1;31m     _                _                  _  " << endl;
# Line 427 | Line 441 | void CompleteSave(TVirtualPad *can, stri
441  
442  
443   void setlumi(float l) {
444 < generaltoolboxlumi=l;
444 >  generaltoolboxlumi=l;
445   }
446  
447   int write_first_line(vector<vector<string> > &entries) {
# Line 585 | Line 599 | void DrawPrelim(float writelumi=generalt
599    string prel=" Preliminary";
600    if(PlottingSetup::PaperMode) prel="";
601    //prelimtext << "CMS Preliminary 2011 , #sqrt{s}= 7 TeV, L= O(1) fb^{-1}"; //temporary replacement
602 <  if(PlottingSetup::is53reco) prel += " 53X";
602 > //  if(PlottingSetup::is53reco) prel += " 53X";
603    string energy="7 TeV";
604    if(PlottingSetup::is2012) energy="8 TeV";
605    if(writelumi == 0) {
606      if(isMC) prelimtext << "CMS Simulation, #sqrt{s} = " << energy;
607      else prelimtext << "CMS" << prel << ", #sqrt{s} = " << energy;
608    } else {
609 <    if(isMC) prelimtext << "CMS Simulation, #sqrt{s} = " << energy << ", L_{int} = " << std::setprecision(3) <<writelumi<<" "<<barn<<"^{-1}";
610 <     else prelimtext << "CMS" << prel << ", #sqrt{s} = " << energy << ", L_{int} = " << std::setprecision(3) <<writelumi<<" "<<barn<<"^{-1}";
609 >    if(isMC) prelimtext << "CMS Simulation, #sqrt{s} = " << energy << ", #scale[0.6]{#int}L dt = " << std::setprecision(3) <<writelumi<<" "<<barn<<"^{-1}";
610 >     else prelimtext << "CMS" << prel << ", #sqrt{s} = " << energy << ", #scale[0.6]{#int}L dt = " << std::setprecision(3) <<writelumi<<" "<<barn<<"^{-1}";
611    }
612    TPaveText *eventSelectionPaveText = new TPaveText(0.27, 0.93,0.77, 1.0,"blNDC");
613    eventSelectionPaveText->SetFillStyle(4000);
# Line 1224 | Line 1238 | bool Contains(string wholestring, string
1238    else return false;
1239   }
1240  
1241 +
1242   //////////////////////////////////////////////////////////////////////////////
1243   //
1244   // http://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-run-time-in-c
# Line 1236 | Line 1251 | bool Contains(string wholestring, string
1251   /* usage:
1252   double vm2, rss2;
1253   process_mem_usage(vm2, rss2);
1254 < cout << "Memory usage: VM: " << vm << "; RSS: " << rss << endl;
1254 > cout << "Memory usage: VM: " << vm2 << "; RSS: " << rss2 << endl;
1255   */
1256  
1257   void process_mem_usage(double& vm_usage, double& resident_set)
# Line 1295 | Line 1310 | TGraphAsymmErrors* produce_ratio_graph(T
1310   }
1311  
1312  
1313 + TLatex* WriteSelection(int njets) {
1314 +  string sel="Loose selection";
1315 +  if(njets==3) sel="Low E_{T}^{miss} selection";
1316 +  assert(njets==2||njets==3);
1317 +  TLatex *sele = new TLatex(0.97,0.135,sel.c_str());
1318 +  sele->SetNDC(true);
1319 +  sele->SetTextColor(TColor::GetColor("#848484"));
1320 +  sele->SetTextFont(42);
1321 +  sele->SetTextAlign(32);
1322 +  sele->SetTextSize(0.03);
1323 +  sele->SetTextAngle(270);
1324 +  return sele;
1325 + }
1326 +
1327   Double_t MarcosChi2TestX(const TH1* h1, const TH1* h2, Double_t &chi2, Int_t &ndf, Int_t &igood, Option_t *option)
1328   {
1329  
# Line 1317 | Line 1346 | Double_t MarcosChi2TestX(const TH1* h1,
1346     return prob;
1347   }
1348  
1349 < void save_with_ratio(TH1F *nominator, TH1F *denominator, TVirtualPad *canvas, string savemeas, bool do_bpred_ratio=false, bool extendrange=false, string yaxistitle="ratio",TH1F *syshisto=NULL) {
1349 > void Save_With_Ratio(TH1F *nominator, TH1F *denominator, TVirtualPad *orig_canvas, string savemeas, bool do_bpred_ratio=false, bool extendrange=false, string yaxistitle="ratio",TH1F *syshisto=NULL) {
1350    //this function saves the pad being passed as well as a new one including the ratio.
1351 <  CompleteSave(canvas,savemeas);
1352 <
1351 >  
1352 >  orig_canvas->cd();
1353 >  orig_canvas->Update();
1354 >  CompleteSave(orig_canvas,savemeas);
1355 >  TVirtualPad *canvas = (TVirtualPad*) orig_canvas->Clone("TempCanvas");//otherwise the Ratio_main_canvas will own our pad and destroy it upon deletion
1356 >  
1357    float bottommargin=gStyle->GetPadBottomMargin();
1358    float canvas_height=gStyle->GetCanvasDefH();
1359    float canvas_width=gStyle->GetCanvasDefW();
# Line 1331 | Line 1364 | void save_with_ratio(TH1F *nominator, TH
1364    
1365    float xstretchfactor=((1-ratiospace)*(1-gStyle->GetPadTopMargin()))/((1)*ratiospace);
1366    
1367 <  TCanvas *main_canvas = new TCanvas("main_canvas","main_canvas",(Int_t)canvas_width,(Int_t)(canvas_height*(1+ratiospace)));
1367 >  TCanvas *Ratio_main_canvas = new TCanvas("Ratio_main_canvas","Ratio_main_canvas",(Int_t)canvas_width,(Int_t)(canvas_height*(1+ratiospace)));
1368    TPad *mainpad = new TPad("mainpad","mainpad",0,1-(1.0/(1+ratiospace)),1,1);//top (main) pad
1369    TPad *coverpad = new TPad("coverpad","coverpad",gStyle->GetPadLeftMargin()-0.008,1-(1.0/(1+ratiospace))-0.04,1,1-(1.0/(1+ratiospace))+0.103);//pad covering up the x scale
1370    TPad *bottompad = new TPad("bottompad", "Ratio Pad",0,0,1,(1-(1-bottommargin)/(1+ratiospace))-0.015); //bottom pad
1371    
1372 <  main_canvas->Range(0,0,1,1);
1373 <  main_canvas->SetBorderSize(0);
1374 <  main_canvas->SetFrameFillColor(0);
1342 <  
1372 >  Ratio_main_canvas->Range(0,0,1,1);
1373 >  Ratio_main_canvas->SetBorderSize(0);
1374 >  Ratio_main_canvas->SetFrameFillColor(0);
1375    mainpad->Draw();
1376    mainpad->cd();
1377    mainpad->Range(0,0,1,1);
# Line 1349 | Line 1381 | void save_with_ratio(TH1F *nominator, TH
1381    canvas->Range(0,0,1,1);
1382    canvas->Draw("same");
1383    mainpad->Modified();
1384 <  main_canvas->cd();
1384 >  Ratio_main_canvas->cd();
1385    coverpad->Draw();
1386    coverpad->cd();
1387    coverpad->Range(0,0,1,1);
# Line 1357 | Line 1389 | void save_with_ratio(TH1F *nominator, TH
1389    coverpad->SetBorderSize(0);
1390    coverpad->SetFrameFillColor(0);
1391    coverpad->Modified();
1392 <  main_canvas->cd();
1392 >  Ratio_main_canvas->cd();
1393    bottompad->SetTopMargin(ratiotopmargin);
1394    bottompad->SetBottomMargin(ratiobottommargin);
1395    bottompad->Draw();
# Line 1366 | Line 1398 | void save_with_ratio(TH1F *nominator, TH
1398    bottompad->SetFillColor(kWhite);
1399    TH1F *ratio = (TH1F*)nominator->Clone(GetNumericHistoName().c_str());
1400    ratio->Divide(denominator);
1369
1370
1401    TGraphAsymmErrors *eratio;
1402    TH1F *SystDown;
1403    TH1F *SystUp;
# Line 1405 | Line 1435 | void save_with_ratio(TH1F *nominator, TH
1435         SystUp->SetLineColor(TColor::GetColor("#006DE1"));
1436    }
1437    eratio->SetFillColor(TColor::GetColor("#00ADE1"));
1408
1438    ratio->SetTitle("");
1439    ratio->GetYaxis()->SetRangeUser(0.0,2.0);
1440    if(do_bpred_ratio) ratio->GetYaxis()->SetRangeUser(0.0,2.0);
# Line 1423 | Line 1452 | void save_with_ratio(TH1F *nominator, TH
1452    ratio->GetYaxis()->SetNdivisions(502,false);
1453    ratio->SetFillColor(TColor::GetColor("#58D3F7"));
1454    ratio->SetMarkerSize(0);
1455 <  ratio->Draw("e2");
1455 >  ratio->Draw("e20");
1456 >  
1457 >  TGraphAsymmErrors *ratio_center = (TGraphAsymmErrors*)eratio->Clone("ratio_center");
1458 >  for(int i=0;i<ratio_center->GetN();i++) {
1459 >    ratio_center->SetPointError(i,ratio_center->GetErrorXlow(i),ratio_center->GetErrorXhigh(i),0.005,0.005);
1460 >  }
1461 >  ratio_center->SetFillColor(TColor::GetColor("#006381"));
1462 >  
1463    if(syshisto!=0) {
1464   //    sysratio->Draw("2");
1465   //    eratio->Draw("2,same");
1466 <    eratio->Draw("2");
1466 >    eratio->Draw("20");
1467      SystDown->Draw("histo,same");
1468      SystUp->Draw("histo,same");
1469    } else {
1470 <    eratio->Draw("2");
1470 >    eratio->Draw("20");
1471    }
1472 +  ratio_center->Draw("20");
1473    ratio->Draw("same,axis");
1474    TLine *oneline = new TLine(ratio->GetXaxis()->GetBinLowEdge(1),1,ratio->GetXaxis()->GetBinLowEdge(ratio->GetNbinsX())+ratio->GetXaxis()->GetBinWidth(ratio->GetNbinsX()),1);
1475    oneline->SetLineStyle(2);
1476    oneline->SetLineColor(kBlue);
1477    oneline->Draw("same");
1478 <
1479 <  main_canvas->cd();
1480 <  main_canvas->Modified();
1481 <  main_canvas->cd();
1482 <  main_canvas->SetSelected(main_canvas);
1478 >  if(PlottingSetup::DrawMetSignalRegionMllLines) {
1479 >    cout << "Drawing extra lines in ratio this time around ... " << endl;
1480 >    float RatioYMax=2.0;
1481 >    if(extendrange) RatioYMax=4.0;
1482 >    
1483 >    TLine *SRline   = new TLine(70,0,70,RatioYMax);
1484 >    TLine *ZLowLine = new TLine(91.2-PlottingSetup::ConsideredZWidth,0,91.2-PlottingSetup::ConsideredZWidth,RatioYMax);
1485 >    TLine *ZHiLine  = new TLine(91.2+PlottingSetup::ConsideredZWidth,0,91.2+PlottingSetup::ConsideredZWidth,RatioYMax);
1486 >  
1487 >    SRline->SetLineStyle(2);
1488 >    ZLowLine->SetLineStyle(2);
1489 >    ZHiLine->SetLineStyle(2);
1490 >    SRline->SetLineColor(kGray+2);
1491 >    ZLowLine->SetLineColor(kGray+2);
1492 >    ZHiLine->SetLineColor(kGray+2);
1493 >    SRline->Draw();
1494 >    ZLowLine->Draw();
1495 >    ZHiLine->Draw();
1496 >  }
1497 >      
1498 >  Ratio_main_canvas->cd();
1499 >  Ratio_main_canvas->Modified();
1500 >  Ratio_main_canvas->cd();
1501 >  Ratio_main_canvas->SetSelected(Ratio_main_canvas);
1502    
1503 <  CompleteSave(main_canvas,savemeas+"_withratio");
1503 >  CompleteSave(Ratio_main_canvas,savemeas+"_withratio");
1504    bottompad->cd();
1505    
1506    Double_t chi2;
# Line 1472 | Line 1528 | void save_with_ratio(TH1F *nominator, TH
1528    CompleteRatio->SetTextAlign(31);
1529    CompleteRatio->Draw();
1530    
1531 <  CompleteSave(main_canvas,savemeas+"_withratio_and_Chi2");
1531 >  CompleteSave(Ratio_main_canvas,savemeas+"_withratio_and_Chi2");
1532  
1533   //  float KS   = nominator->KolmogorovTest(denominator);
1534   //  stringstream KStext;
1535   //  Chi2text << "KS = " << KS << endl;
1536   //cout << "Found : " << KStext.str() << endl;
1537  
1538 +  delete eratio;
1539 +  delete ratio_center;
1540 +  delete ratio;
1541 +  delete Ratio_main_canvas;
1542 + }
1543  
1544 <  delete main_canvas;
1544 > void Save_With_Ratio_And_Line(TH1F *nominator, TH1F *denominator, TVirtualPad *orig_canvas, string savemeas, bool do_bpred_ratio=false, bool extendrange=false, string yaxistitle="ratio",TH1F *syshisto=NULL) {
1545 >  PlottingSetup::ConsideredZWidth=10.0;
1546 >  PlottingSetup::DrawMetSignalRegionMllLines=true;
1547 >  Save_With_Ratio(nominator, denominator, orig_canvas, savemeas, do_bpred_ratio, extendrange, yaxistitle,syshisto);
1548 >  PlottingSetup::DrawMetSignalRegionMllLines=false;
1549 > }
1550 >  
1551 > void Save_With_Ratio_And_Line(TH1F *nominator, THStack denominator, TVirtualPad *canvas, string savemeas, bool do_bpred_ratio=false) {
1552 >  TH1F *denominator_histo = (TH1F*) CollapseStack(denominator,"TemporaryStack");
1553 >  Save_With_Ratio_And_Line(nominator, denominator_histo, canvas, savemeas, do_bpred_ratio);
1554 >  delete denominator_histo;
1555   }
1556  
1557 < void save_with_ratio_and_sys_band(TH1F *nominator, TH1F *denominator, TVirtualPad *canvas, string savemeas, bool do_bpred_ratio=false, bool extendrange=false, string yaxistitle="ratio",TH1F *syshisto=NULL) {
1557 > void save_with_ratio_and_sys_band(float ConsideredZWidth, TH1F *nominator, TH1F *denominator, TVirtualPad *orig_canvas, string savemeas, bool do_bpred_ratio=false, bool extendrange=false, string yaxistitle="ratio",TH1F *syshisto=NULL) {
1558    //this function saves the pad being passed as well as a new one including the SysRatio.
1559 <  CompleteSave(canvas,savemeas);
1559 >  orig_canvas->cd();
1560 >  orig_canvas->Update();
1561 >  CompleteSave(orig_canvas,savemeas);
1562 >  
1563 >  TVirtualPad *canvas = (TVirtualPad*) orig_canvas->Clone("TempCanvas");//otherwise the Ratio_main_canvas will own our pad and destroy it upon deletion
1564  
1565    float bottommargin=gStyle->GetPadBottomMargin();
1566    float canvas_height=gStyle->GetCanvasDefH();
# Line 1497 | Line 1572 | void save_with_ratio_and_sys_band(TH1F *
1572    
1573    float xstretchfactor=((1-ratiospace)*(1-gStyle->GetPadTopMargin()))/((1)*ratiospace);
1574    
1575 <  TCanvas *main_canvas = new TCanvas("main_canvas","main_canvas",(Int_t)canvas_width,(Int_t)(canvas_height*(1+ratiospace)));
1575 >  TCanvas *Ratio_main_canvas = new TCanvas("Ratio_main_canvas","Ratio_main_canvas",(Int_t)canvas_width,(Int_t)(canvas_height*(1+ratiospace)));
1576    TPad *mainpad = new TPad("mainpad","mainpad",0,1-(1.0/(1+ratiospace)),1,1);//top (main) pad
1577    TPad *coverpad = new TPad("coverpad","coverpad",gStyle->GetPadLeftMargin()-0.008,1-(1.0/(1+ratiospace))-0.04,1,1-(1.0/(1+ratiospace))+0.103);//pad covering up the x scale
1578    TPad *bottompad = new TPad("bottompad", "Ratio Pad",0,0,1,(1-(1-bottommargin)/(1+ratiospace))-0.015); //bottom pad
1579    
1580 <  main_canvas->Range(0,0,1,1);
1581 <  main_canvas->SetBorderSize(0);
1582 <  main_canvas->SetFrameFillColor(0);
1580 >  Ratio_main_canvas->Range(0,0,1,1);
1581 >  Ratio_main_canvas->SetBorderSize(0);
1582 >  Ratio_main_canvas->SetFrameFillColor(0);
1583    
1584    mainpad->Draw();
1585    mainpad->cd();
# Line 1515 | Line 1590 | void save_with_ratio_and_sys_band(TH1F *
1590    canvas->Range(0,0,1,1);
1591    canvas->Draw("same");
1592    mainpad->Modified();
1593 <  main_canvas->cd();
1593 >  Ratio_main_canvas->cd();
1594    coverpad->Draw();
1595    coverpad->cd();
1596    coverpad->Range(0,0,1,1);
# Line 1523 | Line 1598 | void save_with_ratio_and_sys_band(TH1F *
1598    coverpad->SetBorderSize(0);
1599    coverpad->SetFrameFillColor(0);
1600    coverpad->Modified();
1601 <  main_canvas->cd();
1601 >  Ratio_main_canvas->cd();
1602    bottompad->SetTopMargin(ratiotopmargin);
1603    bottompad->SetBottomMargin(ratiobottommargin);
1604    bottompad->Draw();
# Line 1537 | Line 1612 | void save_with_ratio_and_sys_band(TH1F *
1612    TGraphAsymmErrors *eratio;
1613    TGraphAsymmErrors *SysEnvelope = new TGraphAsymmErrors();
1614    
1540  if(!do_bpred_ratio) eratio = produce_ratio_graph(ratio);
1541  else {
1542     bool using_data=false;
1543     if((int)savemeas.find("Data")>0) using_data=true;
1544     eratio = histRatio(nominator,denominator,using_data,PlottingSetup::global_ratio_binning,false);
1545     if(syshisto!=0) {
1546       for(int i=1;i<=syshisto->GetNbinsX();i++) {
1547         SysEnvelope->SetPoint(i-1,syshisto->GetBinCenter(i),1.0);
1548         SysEnvelope->SetPointError(i-1,syshisto->GetBinWidth(i),syshisto->GetBinWidth(i),syshisto->GetBinContent(i),syshisto->GetBinContent(i));
1549       }
1550       SysEnvelope->SetFillColor(TColor::GetColor("#006DE1"));
1551     }
1552     for(int i=1;i<=ratio->GetNbinsX();i++) {
1553        ratio->SetBinContent(i,0);
1554        ratio->SetBinError(i,0);
1555     }
1556    
1557  }
1558  
1615    if(syshisto && !do_bpred_ratio) {
1616         for(int i=1;i<=syshisto->GetNbinsX();i++) {
1617 +         float dx=syshisto->GetBinWidth(i)/2.0;
1618 +         float dy=syshisto->GetBinContent(i);
1619 +         if(dy<0.01) dy=0.07;
1620           SysEnvelope->SetPoint(i-1,syshisto->GetBinCenter(i),1.0);
1621 <         SysEnvelope->SetPointError(i-1,syshisto->GetBinWidth(i),syshisto->GetBinWidth(i),syshisto->GetBinContent(i),syshisto->GetBinContent(i));
1621 >         SysEnvelope->SetPointError(i-1,dx,dx,dy,dy);
1622         }
1623         SysEnvelope->SetFillColor(TColor::GetColor("#006DE1"));
1624    }
# Line 1580 | Line 1639 | void save_with_ratio_and_sys_band(TH1F *
1639    ratio->GetYaxis()->SetTitleSize(xstretchfactor*gStyle->GetTitleSize());
1640    ratio->GetYaxis()->SetNdivisions(502,false);
1641    ratio->SetFillColor(TColor::GetColor("#58D3F7"));
1642 <  ratio->Draw("e1");
1642 >  ratio->Draw("e0");
1643    
1644    if(syshisto!=0) {
1586    ratio->Draw("");
1645      SysEnvelope->SetFillColor(TColor::GetColor("#FE9A2E"));
1646 <    SysEnvelope->Draw("2,same");
1647 <    ratio->Draw("e1,same");
1646 >    SysEnvelope->Draw("2,0,same");
1647 >    ratio->Draw("e0,same");
1648    } else {
1649 <    eratio->Draw("1");
1649 >    eratio->Draw("0");
1650    }
1651    ratio->Draw("same,axis");
1652    TLine *oneline = new TLine(ratio->GetXaxis()->GetBinLowEdge(1),1,ratio->GetXaxis()->GetBinLowEdge(ratio->GetNbinsX())+ratio->GetXaxis()->GetBinWidth(ratio->GetNbinsX()),1);
1653    oneline->SetLineStyle(2);
1654    oneline->SetLineColor(kBlue);
1655    oneline->Draw("same");
1598
1599  main_canvas->cd();
1600  main_canvas->Modified();
1601  main_canvas->cd();
1602  main_canvas->SetSelected(main_canvas);
1656    
1657 <  CompleteSave(main_canvas,savemeas+"_withSysRatio");
1657 >  
1658 >  
1659 >  if(ConsideredZWidth>0.1) {
1660 >    cout << "Drawing extra lines in ratio this time around ... " << endl;
1661 >    float RatioYMax=2.0;
1662 >    if(extendrange) RatioYMax=4.0;
1663 >    
1664 >    TLine *SRline   = new TLine(70,0,70,RatioYMax);
1665 >    TLine *ZLowLine = new TLine(91.2-ConsideredZWidth,0,91.2-ConsideredZWidth,RatioYMax);
1666 >    TLine *ZHiLine  = new TLine(91.2+ConsideredZWidth,0,91.2+ConsideredZWidth,RatioYMax);
1667 >  
1668 >    SRline->SetLineStyle(2);
1669 >    ZLowLine->SetLineStyle(2);
1670 >    ZHiLine->SetLineStyle(2);
1671 >    SRline->SetLineColor(kGray+2);
1672 >    ZLowLine->SetLineColor(kGray+2);
1673 >    ZHiLine->SetLineColor(kGray+2);
1674 >    SRline->Draw();
1675 >    ZLowLine->Draw();
1676 >    ZHiLine->Draw();
1677 >  }
1678 >
1679 >  Ratio_main_canvas->cd();
1680 >  Ratio_main_canvas->Modified();
1681 >  Ratio_main_canvas->cd();
1682 >  Ratio_main_canvas->SetSelected(Ratio_main_canvas);
1683 >  
1684 >  CompleteSave(Ratio_main_canvas,savemeas+"_withSysRatio");
1685    bottompad->cd();
1686    
1687    Double_t chi2;
# Line 1628 | Line 1708 | void save_with_ratio_and_sys_band(TH1F *
1708    CompleteRatio->SetTextAlign(31);
1709    CompleteRatio->Draw();
1710    
1711 <  CompleteSave(main_canvas,savemeas+"_withSysRatio_and_Chi2");
1712 <
1713 <  delete main_canvas;
1711 >  CompleteSave(Ratio_main_canvas,savemeas+"_withSysRatio_and_Chi2");
1712 >  delete Ratio_main_canvas;
1713 >  delete ratio;
1714   }
1715  
1716 < TH1F* CollapseStack(THStack stack,TString hname="base") {
1716 > TH1F* CollapseStack(THStack stack,TString hname="CollapsedStack") {
1717     TH1F *bhist = ((TH1F*)((stack.GetHists())->At(0)));
1718     TH1F *basehisto = (TH1F*)bhist->Clone(hname);
1719     TIter next(stack.GetHists());
# Line 1647 | Line 1727 | TH1F* CollapseStack(THStack stack,TStrin
1727     return basehisto;
1728   }
1729  
1730 < void save_with_ratio(TH1F *nominator, THStack denominator, TVirtualPad *canvas, string savemeas, bool do_bpred_ratio=false) {
1731 <  save_with_ratio(nominator, CollapseStack(denominator), canvas, savemeas, do_bpred_ratio);
1730 > void Save_With_Ratio(TH1F *nominator, THStack denominator, TVirtualPad *canvas, string savemeas, bool do_bpred_ratio=false) {
1731 >  TH1F *denominator_histo = (TH1F*) CollapseStack(denominator);
1732 >  Save_With_Ratio(nominator, denominator_histo, canvas, savemeas, do_bpred_ratio);
1733 >  delete denominator_histo;
1734   }
1735  
1736   void flag_this_change(string function, int line, int checked=0) {
# Line 1833 | Line 1915 | string removefunnystring(string name) {
1915    name=ReplaceCharacter(name,"]","_");
1916    name=ReplaceCharacter(name,"{","_");
1917    name=ReplaceCharacter(name,"}","_");
1918 +  name=ReplaceCharacter(name,"(","_");
1919 +  name=ReplaceCharacter(name,")","_");
1920 +  name=ReplaceCharacter(name," ","_");
1921    name=ReplaceCharacter(name,".","_");
1922    name=ReplaceCharacter(name,",","_");
1923    name=ReplaceCharacter(name,";","_");
# Line 1873 | Line 1958 | TPolyLine* GetFitUncertaintyShape(TF1 *f
1958    y[nPoints]=y[0];
1959    
1960    TPolyLine *l = new TPolyLine(nPoints+1,x,y);
1961 <  l->SetFillColor(TColor::GetColor("#5858FA"));
1962 <  l->SetLineColor(TColor::GetColor("#5858FA"));
1961 >  l->SetFillColor(TColor::GetColor("#A2A2FA"));
1962 >  l->SetLineColor(TColor::GetColor("#A2A2FA"));
1963    l->SetLineWidth(1);
1964    return l;
1965   }  
1966  
1967 + //code for ReplaceAll copied from
1968 + //http://stackoverflow.com/questions/5343190/c-how-do-i-replace-all-instances-of-of-a-string-with-another-string
1969 + string ReplaceAll(string str, string from, string to) {
1970 +    size_t start_pos = 0;
1971 +    while((start_pos = str.find(from, start_pos)) != std::string::npos) {
1972 +         str.replace(start_pos, from.length(), to);
1973 +         start_pos += to.length(); // ...
1974 +    }
1975 +    return str;
1976 + }
1977  
1978   TPolyLine* GetFitUncertaintyShape(TH1 *histo, string fitname, float low, float high) {
1979    TF1 *fit = (TF1*)histo->GetFunction(fitname.c_str());
# Line 1974 | Line 2069 | void FindMinMax(TGraphErrors *gr, float
2069      if(potmax>max) max=potmax;
2070    }
2071   }
2072 +
2073 +
2074 + void CleanLegends() {
2075 +  for(int ihist=(int)PlottingSetup::FakeHistoHeap.size()-1;ihist>=0;ihist--) {
2076 +    PlottingSetup::FakeHistoHeap[ihist]->Delete();
2077 +    PlottingSetup::FakeHistoHeap.pop_back();
2078 +  }
2079 + }
2080 +
2081 + string DigitsAfterComma(float number, int digits) {
2082 +  float temp=number*pow(10.0,digits);
2083 +  temp=int(temp)/pow(10.0,digits);
2084 +  return any2string(temp);
2085 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines