quantiles.C

Go to the documentation of this file.
00001 void quantiles() {
00002    // demo for quantiles
00003    // Authors: Rene Brun, Eddy Offermann
00004    
00005    const Int_t nq = 100;
00006    const Int_t nshots = 10;
00007    Double_t xq[nq];  // position where to compute the quantiles in [0,1]
00008    Double_t yq[nq];  // array to contain the quantiles
00009    for (Int_t i=0;i<nq;i++) xq[i] = Float_t(i+1)/nq;
00010 
00011    TGraph *gr70 = new TGraph(nshots);
00012    TGraph *gr90 = new TGraph(nshots);
00013    TGraph *gr98 = new TGraph(nshots);
00014    TH1F *h = new TH1F("h","demo quantiles",50,-3,3);
00015    
00016    for (Int_t shot=0;shot<nshots;shot++) {
00017       h->FillRandom("gaus",50);
00018       h->GetQuantiles(nq,yq,xq);
00019       gr70->SetPoint(shot,shot+1,yq[70]);
00020       gr90->SetPoint(shot,shot+1,yq[90]);
00021       gr98->SetPoint(shot,shot+1,yq[98]);
00022    }
00023    
00024    //show the original histogram in the top pad
00025    TCanvas *c1 = new TCanvas("c1","demo quantiles",10,10,600,900);
00026    c1->SetFillColor(41);
00027    c1->Divide(1,3);
00028    c1->cd(1);
00029    h->SetFillColor(38);
00030    h->Draw();
00031    
00032    // show the final quantiles in the middle pad
00033    c1->cd(2);
00034    gPad->SetFrameFillColor(33);
00035    gPad->SetGrid();
00036    TGraph *gr = new TGraph(nq,xq,yq);
00037    gr->SetTitle("final quantiles");
00038    gr->SetMarkerStyle(21);
00039    gr->SetMarkerColor(kRed);
00040    gr->SetMarkerSize(0.3);
00041    gr->Draw("ap");
00042    
00043    // show the evolution of some  quantiles in the bottom pad
00044    c1->cd(3);
00045    gPad->SetFrameFillColor(17);
00046    gPad->DrawFrame(0,0,nshots+1,3.2);
00047    gPad->SetGrid();
00048    gr98->SetMarkerStyle(22);
00049    gr98->SetMarkerColor(kRed);
00050    gr98->Draw("lp");
00051    gr90->SetMarkerStyle(21);
00052    gr90->SetMarkerColor(kBlue);
00053    gr90->Draw("lp");
00054    gr70->SetMarkerStyle(20);
00055    gr70->SetMarkerColor(kMagenta);
00056    gr70->Draw("lp");
00057    // add a legend
00058    TLegend *legend = new TLegend(0.85,0.74,0.95,0.95);
00059    legend->SetTextFont(72);
00060    legend->SetTextSize(0.05);
00061    legend->AddEntry(gr98," q98","lp");
00062    legend->AddEntry(gr90," q90","lp");
00063    legend->AddEntry(gr70," q70","lp");
00064    legend->Draw();
00065 }
00066 

Generated on Tue Jul 5 15:44:50 2011 for ROOT_528-00b_version by  doxygen 1.5.1