[ROOT] project a sub range of a histogram

From: ddas@veccal.ernet.in
Date: Wed Dec 01 2004 - 12:35:29 MET


 Hello
 does anybody know how to project subrange of a 2D histogram.
 I tried using TCutG but somehow could not get the result.
 I wanted to change by Projection X from value1 to value2 and then plot that part only.
 Also if somebody can explain what this SetPoint means.

 Example:

 {
    TCanvas *c = new TCanvas("c","example",0,0,700,600);
    c->Divide(1,2);

    TCutG *gcut = new TCutG("gcut",8);
    gcut->SetPoint(0,-0.646552,0.932203);
    gcut->SetPoint(1,-1.26437,0.105932);
    gcut->SetPoint(2,-0.574713,-1.10169);
    gcut->SetPoint(3,0.948276,-0.338983);
    gcut->SetPoint(4,1.07759,0.720339);
    gcut->SetPoint(5,-0.316092,-0.0847458);
    gcut->SetPoint(6,-0.45977,0.402542);
    gcut->SetPoint(7,-0.646552,0.932203);

    TFile f("hsimple.root")
    TH2F *hpxpy = (TH2F*)f.Get("hpxpy");
    TH1D *hppx = hpxpy->ProjectionX("",1,40,"[gcut]");

    c->cd(1);
    hpxpy->SetFillColor(kBlue);
    hpxpy->DrawCopy("box");
    hpxpy->SetFillColor(kRed);
    hpxpy->Draw("same box [gcut]");

    c->cd(2);
    hppx->Draw();
 }


 thanks again
 debasish.

 



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET