Ignore:
Timestamp:
10/19/06 21:39:08 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhflux/MHAlpha.cc

    r8016 r8136  
    885885}
    886886
     887void MHAlpha::DrawNicePlot(Bool_t newc, const char *title)
     888{
     889    if (!newc && !fDisplay)
     890        return;
     891
     892    if (!fOffData)
     893        return;
     894
     895    // Open and setup canvas/pad
     896    TCanvas &c = newc ? *new TCanvas : fDisplay->AddTab("ThetsSq");
     897
     898    c.SetBorderMode(0);
     899    c.SetFrameBorderMode(0);
     900    c.SetFillColor(kWhite);
     901
     902    c.SetLeftMargin(0.12);
     903    c.SetRightMargin(0.01);
     904    c.SetBottomMargin(0.16);
     905    c.SetTopMargin(0.18);
     906
     907    c.SetGridy();
     908
     909    gStyle->SetOptStat(0);
     910
     911    // Get on-data
     912    TH1D *hon = (TH1D*)fHist.ProjectionZ("Proj", -1, 9999, -1, 9999, "E");
     913    hon->SetDirectory(NULL);
     914    hon->SetBit(kCanDelete);
     915    hon->SetMarkerSize(0);
     916    hon->SetLineWidth(2);
     917    hon->SetLineColor(kBlack);
     918    hon->SetMarkerColor(kBlack);
     919
     920    // Get off-data
     921    TH1D *hoff = 0;
     922    if (fOffData)
     923    {
     924        hoff = (TH1D*)fOffData->ProjectionZ("ProjOff", -1, 9999, -1, 9999, "E");
     925        hoff->SetDirectory(NULL);
     926        hoff->SetBit(kCanDelete);
     927        hoff->SetFillColor(17);
     928        hoff->SetMarkerSize(0);
     929        hoff->SetLineColor(kBlack);
     930        hoff->SetMarkerColor(kBlack);
     931    }
     932
     933    // Setup plot which is drawn first
     934    TH1D *h = hoff ? hoff : hon;
     935    h->GetXaxis()->SetLabelSize(0.06);
     936    h->GetXaxis()->SetTitleSize(0.06);
     937    h->GetXaxis()->SetTitleOffset(0.95);
     938    h->GetYaxis()->SetLabelSize(0.06);
     939    h->GetYaxis()->SetTitleSize(0.06);
     940    h->GetYaxis()->CenterTitle();
     941    h->SetYTitle("Counts");
     942    h->SetTitleSize(0.07);
     943    h->SetTitle("");
     944
     945    const Double_t imax = fFit.GetSignalIntegralMax();
     946    if (imax<1)
     947        h->GetXaxis()->SetRangeUser(0, 0.6*0.6);
     948
     949    // scale off-data
     950    fFit.Scale(*hoff, *hon);
     951
     952    hon->SetMinimum(0);
     953    hoff->SetMinimum(0);
     954
     955    // draw data
     956    if (hoff)
     957    {
     958        hoff->SetMaximum(TMath::Max(hon->GetMaximum(),hoff->GetMaximum())*1.1);
     959        hoff->Draw("bar");
     960        hon->Draw("same");
     961    }
     962    else
     963    {
     964        hon->SetMaximum();
     965        hon->Draw();
     966    }
     967
     968    // draw a preliminary tag
     969    TLatex text;
     970    text.SetTextColor(kWhite);
     971    text.SetBit(TLatex::kTextNDC);
     972    text.SetTextSize(0.07);
     973    text.SetTextAngle(2.5);
     974    text.DrawLatex(0.45, 0.2, "preliminary");
     975    //enum { kTextNDC = BIT(14) };
     976
     977    // draw line showing cut
     978    TLine line;
     979    line.SetLineColor(14);
     980    line.SetLineStyle(7);
     981    line.DrawLine(imax, 0, imax, h->GetMaximum());
     982
     983    // Add a title above the plot
     984    TPaveText *pave=new TPaveText(0.12, 0.83, 0.99, 0.975, "blNDC");
     985    pave->SetBorderSize(1);
     986    pave->SetLabel(title);
     987
     988    char txt[1000];
     989    TText *ptxt;
     990    sprintf(txt, " ");
     991    ptxt = pave->AddText(txt);
     992    ptxt->SetTextAlign(23);
     993
     994    sprintf(txt, "Significance %.1f\\sigma,  off-scale %.2f  (\\omega=%.2f\\circ)",
     995            fFit.GetSignificance(), fFit.GetScaleFactor(), fFit.GetGausSigma());
     996    ptxt = pave->AddText(txt);
     997    ptxt->SetTextAlign(23);
     998
     999    sprintf(txt, "%.1f excess events,  %.1f background events",
     1000            fFit.GetEventsExcess(), fFit.GetEventsBackground());
     1001    ptxt = pave->AddText(txt);
     1002    ptxt->SetTextAlign(23);
     1003    pave->SetBit(kCanDelete);
     1004    pave->Draw();
     1005}
    8871006
    8881007Bool_t MHAlpha::Finalize()
Note: See TracChangeset for help on using the changeset viewer.