[ROOT] project a sub range of a histogram

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


Hello
does anybody know how to project subrange of a 2D histogram.
I tried using TCutG but somehow could not get the result.
The projection macro is attached. 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.

*****************************************************************************
Freedom can never be reached by the weak. 
Throw away all weakness. 
Tell your body that it is strong, tell your mind
that it is strong,and have unbounded faith and 
hope in yourself.--------Swami Vivekananda
************************************************************************
Mr. Debasish Das.                     
Exptl. Physics Division.                         
Variable Energy Cyclotron Centre.   
1/AF , BIDHAN NAGAR,
KOLKATA-700064.
INDIA.
Phone: +91-33-23371230(2315/2314)                    
 Fax:   +91-33-23346871     
Email: ddas@veccal.ernet.in
        d10_debasish@hotmail.com                     
URL:http://www.veccal.ernet.in/~pmd
       http://www.geocities.com/das10_deba
************************************************************************
  
...........................................................
"This I have seen in life-those who are overcautious about themselves fall into 
dangers at every step; those who are afraid of losing honor and respect, get 
only disgrace; and those who are always afraid of loss, always lose." 
--  Swami Vivekananda

----- Original Message -----
From: Vitor de Souza <vitor@astro.iag.usp.br>
Date: Tuesday, November 30, 2004 8:44 pm
Subject: Re: [ROOT] fixed step in fit

> Hi Eddy,
> I agree that a good minimizing algorithm change its step size.
> However, because of physical constraints a given parameter may not 
> be 
> allowed to assumed all values within a limit.
> Suppose you want to fit a parameter which for physical reasons can 
> only 
> assume integer values. In this case, one would like to  fix the 
> step 
> size to a integer value.
> In my case I would like to have parameter 1 of the fit only 
> assuming 
> mutiples of 100 in the interval between 500 and 1000.
> Is that possible ?
> Thanks,
> Vitor
> 
> Edmond Offermann wrote:
> 
> >Hi Vitor,
> >
> >I wonder why you want to fix the step size of the parameter search ?
> >An intelligent minimizing algorithm will change its step size !
> >
> >Eddy
> >
> >--- Vitor de Souza <vitor@astro.iag.usp.br> wrote:
> >
> >  
> >
> >>Dear all,
> >>I would like to fix the step size of a parameter in a fit.
> >>I am using the code below:
> >>
> >>static double vstart[npar]; // inital point
> >>static double step[npar];   // step size
> >>TMinuit * theMinuit = new TMinuit(npar); // 3 parameter fit       
> 	
> >>step[0]=10.0;
> >>step[1]=100.0;
> >>step[2]=1.0;
> >>theMinuit->mnparm(0,"n",vstart[0],step[0],0,0,ierflag);
> >>theMinuit->mnparm(1,"x",vstart[1],step[1],500,1000,ierflag);
> >>theMinuit->mnparm(2,"x0",vstart[2],step[2],0,0,ierflag);
> >>theMinuit->mnexcm("SET ERR", arglist,1,ierflag);
> >>double arglist[npar];
> >>int ierflag =0;
> >>arglist[0] = 1500;
> >>arglist[1] = 1.;
> >>theMinuit->mnexcm("MIGRAD", arglist , 2, ierflag);
> >>
> >>As far as I understood from the manual, the values set as step[] in
> >>the 
> >>command  theMinuit->mnparm( ) is the size of only the first step in
> >>the 
> >>fit procedure.
> >>Is there a way to fix the step size for the hole fit procedure ?
> >>Thank you,
> >>Vitor
> >>
> >>
> >>    
> >>
> >
> >  
> >
> 
> 
> 





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