RE: TF2 SetRange

From: <nguler_at_jlab.org>
Date: Tue, 23 Nov 2010 13:21:00 -0500


Great,
It worked nicely and life is much better now. Thank you so much. Best Regards, - Nevzat

> Hi,
>
> In the method plot(...) you should do:
>
> [...]
> fitsim1_5->SetRange(...);
> fitsim1_5->SetMaximum(histsim->GetMaximum());
> [...]
> fitsim2_5->SetRange(...);
> fitsim2_5->SetMaximum(histsim->GetMaximum());
>
> Cheers,
> O.Couet
>
> -----Original Message-----
> From: nguler_at_jlab.org [mailto:nguler_at_jlab.org]
> Sent: Monday, November 22, 2010 9:40 PM
> To: Olivier Couet
> Cc: nguler_at_jlab.org; roottalk (Mailing list discussing all aspects of the ROOT
> system.)
> Subject: RE: [ROOT] TF2 SetRange
>
> Hello,
> I have ru the code successfully before I sent. I just tried again and it is
> running. I do the following:
>>root -b
> root [0] .L aImage_test.cc+
> root [1] all();
>
> In the directory, I have only two files: aImage_test.cc, ngldata.txt I got rid
> of the Makefile to simplify the situation. The files I sent before should be
> the same but incase somethings mixed up, I am sending the two files needed to
> run the code again.
>
> When you untar the file, nglcode.tar, you also need to gunzip the file
> ngldata.txt.gz inside that directory.. But I don't think that's the issue
> related to Seg Fault.
>
> The machine I am running the code is a powerful 64bit linux cluster. But, I
> don't have any big arrays stored in the code. I checked the parameter arrays
> and they look fine. I am wondering: Are you getting Seg fault while reading
> the file (in the while loop), or after that during fittings. The way I fill
> the histogram is a bit strange, but I had to use that method because I had to
> use TH2F. As I mentioned , using TGraph2D is very very slow for reasons I
> don't understand (there is also TGraph2D method in the same code called
> graph() but not used). Here is the code snipped for the part that I read the
> file and fill the histogram. I think this is the only part prone to Seg fault
> but as I said it works for me without ant seg fault:
>
>
> ifstream inFile_simdata;
> inFile_simdata.open("ngldata.txt",ios::in);
> i=0; j=0; N=0;
> while(inFile_simdata >> fJ)
> {
> fJ = fJ*1E13;
> iJ = int(fJ)/100;
> for(int c=0; c<iJ; c++)
> {
> histsim->Fill(double(i),double(j));
> }
> //cout << N << "\t" << i << "\t" << j << "\t" << fJ << endl;
> i++;
> N++;
> if(i==256) {i = 0; j++;}
> if(j==256) break;
> }
> inFile_simdata.close();
>
> Thanks again for your help.
> - Nevzat
>
>
>> Hello,
>> I compiled and link your program: I get a Seg Fault when I run it.
>> Using CINT I get the same thing.
>> Have you run what you sent me ?
>> May be there is still some files missing...
>> Olivier
>>
>> -----Original Message-----
>> From: nguler_at_jlab.org [mailto:nguler_at_jlab.org]
>> Sent: Friday, November 19, 2010 7:34 PM
>> To: Olivier Couet
>> Cc: nguler_at_jlab.org; roottalk (Mailing list discussing all aspects of
>> the ROOT
>> system.)
>> Subject: RE: [ROOT] TF2 SetRange
>>
>> Sorry I forgot to cleanup the Makefile itself. I removed some unused
>> libraries from the Makefile, also cleaned the code a bit more and
>> attached the whole package again. It should work now and produce a
>> .gif file. Actually, the Makefile is not necessary, the code can also
>> be loaded under root cint, in which case the subroutine to run is all();
>> Sorry for the confusion.
>> As a side note, I am using root version 5.26/00.
>> Thanks again for your help,
>> -Nevzat
>>
>>>
>>> When I do "make" I get:
>>>
>>> g++ -o aImage_nifv1 aImage_nifv1.cc -O -Wall -fPIC -pthread -m32
>>> -I/home/couet/root/include -L/home/couet/root/lib -lCore -lCint -lRIO
>>> -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript
>>> -lMatrix -lPhysics -lMathCore -lThread -lGui -pthread -lm -ldl
>>> -rdynamic -L -lMinuit -I/home/nguler/eg1b/inc -L
>>> g++: argument to `-L' missing
>>>
>>> make: *** [exe] Error 1
>>>
>>> It is because the variable CLAS_LIB is not defined in the Makefile....
>>> what should it be ?
>>>
>>> OC
>>>
>>> Org: CERN - European Laboratory for Particle Physics.
>>> Mail: 1211 Geneve 23 - Switzerland Mailbox: J25910
>>> E-Mail: Olivier.Couet_at_cern.ch Phone: +41 22
>>> 7676522
>>> WWW: http://cern.ch/Olivier.Couet/ Fax: +41 22
>>> 7670300
>>>
>>> On Thu, 18 Nov 2010, nguler_at_jlab.org wrote:
>>>
>>>> Hello,
>>>> I tried gStyle->SetHistTopMargin(0); but it did not change anything.
>>>> I attached a tar file which includes simplified code (I tried to
>>>> clean as much as possible), a data file input and a makefile to
>>>> compile (make test). I hope the file size is too big for roottalk.
>>>> I am using the subroutine plot() in the code.
>>>>
>>>> Thanks for your help.
>>>>
>>>> P.S. As a side note: The subroutine graph() is trying to do the same
>>>> thing as the plot() but by using TGraph2D. However, it is extremely
>>>> slow and the graph it generates has large pixels which create a low
>>>> resolution plot. I was thinking to ask this separately but might be
>>>> more appropriate now.
>>>>
>>>>
>>>>> Hello,
>>>>> You did not sent a running macro showing the problem so I can only
>>>>> guess what could be wrong.
>>>>> It could be the following: histograms are not drawn from Min to Max
>>>>> of their content. There is a margin on top, added to the maximum.
>>>>> It could be that this margin provokes the difference in Z. To
>>>>> suppress it do: gStyle->SetHistTopMargin(0); Cheers, O.Couet
>>>>>
>>>>> -----Original Message-----
>>>>> From: owner-roottalk_at_root.cern.ch
>>>>> [mailto:owner-roottalk_at_root.cern.ch]
>>>>> On Behalf Of nguler_at_jlab.org
>>>>> Sent: Wednesday, November 17, 2010 1:08 AM
>>>>> To: roottalk (Mailing list discussing all aspects of the ROOT
>>>>> system.)
>>>>> Subject: [ROOT] TF2 SetRange
>>>>>
>>>>> Hello All,
>>>>> I have 2D histograms with various peaks in each. I perform a
>>>>> gaussian fit on the peaks. For the fit to be successful, I have to
>>>>> set x,y ranges around the peaks while defining my TF2 object.
>>>>> Therefore, the range of my TF2 is different than the range of my
>>>>> TH2F. This becomes problem later when I plot the histogram and the
>>>>> fit results together on the same canvas. So, I rescale the
>>>>> histogram by using SetRange. To be more clear, I define TH2F:
>>>>> TH2F *histsim = new
>>>>> TH2F(histsimName,histsimName,256,0,256,256,0,256);
>>>>> Then define TF2:
>>>>> TF2 *fitsim = new TF2("fitsim",Gaus2D,0,80,75,125,5);
>>>>> And I fit and plot:
>>>>> histsim->Fit("fitsim","RN");
>>>>> histsim->Draw("surf4");
>>>>> fitsim->Draw("cont1, same");
>>>>> But the fitsim is plotted on a different scale and does not overlap
>>>>> with the peak anymore even if the fit is successful. So, instead I
>>>>> do the
>>>>> following:
>>>>> histsim->Fit("fitsim","RN");
>>>>> histsim->Draw("surf4");
>>>>> fitsim->SetRange(0,0,256,256); //// necessary to rescale to the
>>>>> histogram range
>>>>> fitsim->Draw("cont1, same");
>>>>> This plots the fitsim on correct x and y positions. However, the z
>>>>> height of the fit is still off-scale. How can I rescale the fit
>>>>> height so that it is the same as the peak height? I tried following:
>>>>> fitsim->SetRange(0,0,0, 256,256, fitsim->GetParameter(0)); But
>>>>> it did not have any visible effect, the z range of the fit is still
>>>>> very different than the z range of the histogram.
>>>>>
>>>>> I appreciate your suggestions. Thank you,
>>>>>
>>>>> - Nevzat Guler
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> - Nevzat Guler
>>>> (757) 553-8318
>>>
>>
>>
>> - Nevzat Guler
>> (757) 553-8318
>>
>>
>
>
> - Nevzat Guler
> (757) 553-8318
>
>

Received on Tue Nov 23 2010 - 19:21:12 CET

This archive was generated by hypermail 2.2.0 : Fri Nov 26 2010 - 17:50:01 CET