Re: Finding minimum of an axis

From: James Jackson <James.Jackson_at_cern.ch>
Date: Sun, 11 Nov 2007 21:35:45 +0000


Hi all,

Thanks for the replies, but I have already tried that, and I get a return value of 0 when the axis clearly starts at -6:

http://www.onlineclienttest.co.uk/plot.png

The histogram was filled with successive calls to SetBinContent, rather than calls to Fill - would this impact the behavior of this call? The histogram is created in the following function:

// CreateDeltaHist
TH1F* CreateDeltaHist(TH1F *hist1, TH1F *hist2, string name) {

    Int_t nBins = hist1->GetNbinsX();
    Double_t lowVal = hist1->GetBinLowEdge(1);     Double_t highVal = hist1->GetBinLowEdge(nBins) + hist1-  >GetBinWidth(nBins);

    TH1F *delta = new TH1F(name.c_str(), "", nBins, lowVal, highVal);     Double_t x, y, xErr, yErr, diff, diffErr;     for(Int_t i = 1; i <= hist1->GetNbinsX(); ++i)     {

       x = hist1->GetBinContent(i);
       y = hist2->GetBinContent(i);
       xErr = hist1->GetBinError(i);
       yErr = hist2->GetBinError(i);

       diff = (x - y) * 100.0;
       diffErr = <long line snipped>;
       delta->SetBinContent(i, diff);
       delta->SetBinError(i, diffErr);

    }
    return delta;
}

and displayed with the following code snippet:

// Create delta hist

    TH1F *deltaHist = CreateDeltaHist(alMass, boMass, "boaldiff");     deltaHist->GetYaxis()->SetTitle("#\delta (\%/5 GeV)");     deltaHist->GetXaxis()->SetTitle("M_{e^{+}e^{-}} (GeV/c^{2})");

    // Display mass histograms
    TCanvas *c1 = new TCanvas("c1", "imposed", 700, 400);

    deltaHist->SetMarkerStyle(7);
    deltaHist->SetMarkerSize(1);
    deltaHist->SetMarkerColor(kBlue);
    deltaHist->SetLineColor(kBlue);
    deltaHist->Draw("HIST");

    c1->Update();
    cout << "min: " << deltaHist->GetYaxis()->GetXmin() << endl;

Where the final call is printing "min: 0"

Any ideas?

Regards,
James.

On 11 Nov 2007, at 20:38, Ahsan, Mahsana wrote:

> Hi James,

>

> You can do
>

> myHist->GetYaxis()->GetXmin();
>

> for the Y-axis.
>

> cheers,
> Mahsana
>
>

> -----Original Message-----
> From: owner-roottalk_at_root.cern.ch on behalf of James Jackson
> Sent: Sun 11/11/2007 2:02 PM
> To: roottalk_at_root.cern.ch
> Subject: [ROOT] Finding minimum of an axis
>

> Hi,
>

> If I have a histogram (TH1F), how can I find out the minimum value of
> the plotted Y axis? For the X axis, the following works:
>

> myHist->GetXaxis()->GetXmin()
>

> however I can find no analog for the Y axis (i.e. GetYmin()), and
> also find it strange that concepts such as 'X' are implicit in the
> implementation of TAxis!
>

> Any suggestions welcome...
>

> Regards,
> James Jackson.

>
> Received on Sun Nov 11 2007 - 22:36:05 CET

This archive was generated by hypermail 2.2.0 : Mon Nov 12 2007 - 05:50:02 CET