Re: seg fault in TF2::GetSave

From: Lorenzo Moneta <Lorenzo.Moneta_at_cern.ch>
Date: Mon, 25 Feb 2008 10:01:21 +0100


Hi,

  I don't understand this. The values of [x1, x2] and [y1, y2] should be double and not int.
Anyway, they should be converted automatically to doubles when calling the TF2 constructor.
  I would need a running program reproducing your segmentation fault in order to understand it,

  Regards

  Lorenzo
On Feb 23, 2008, at 2:30 AM, OKUMURA, Akira wrote:

> Hello Lorenzo,
>
> After processing many input files, I found that my program
> reproduces the same problem to other inputs. But it seems to work
> properly after changing the argument of TF2::TF2.
>
> Before:
> TF2 f2ab("f2ab", Gauss2D_AB, x1, x2, y1, y2, 7);
>
> After:
> TF2 f2ab("f2ab", Gauss2D_AB, x1-.5, x2+.5, y1-.5, y2+.5, 7);
>
> here, x1, x2, y1, y2 are Int_t. And the range of TH2D to be fitted
> was [x1, x2] and [y1, y2].
>
> I am not sure if this program can process ALL input files correctly.
>
> Do you think this is related to the segmentation fault?
>
> Regards
>
> OKUMURA, Akira oxon_at_icrr.u-tokyo.ac.jp
> Institute for Cosmic Ray Research, University of Tokyo
> 5-1-5 Kashiwanoha Kashiwa Chiba 277-8582 Japan
> Phone/Fax : +81 4-7136-3153
> Skype : okumura.akira
>
> On 2008/02/21, at 23:35, Lorenzo Moneta wrote:
>> Hello Akira,
>>
>> in order to look at your problem, could you please send me a
>> minimal code showing the problem.
>> I would need the histograms for fitting.
>>
>>
>> When you call TH1::Fit I would use however directly the function
>> pointer instead of using the function name:
>>
>> hist[j*kRN + i]->Fit(f2ab, "0");
>>
>>
>> Regards,
>>
>> Lorenzo
>>
>>
>> On Feb 22, 2008, at 1:05 AM, OKUMURA, Akira wrote:
>>
>>> Hello ROOTers
>>>
>>> I encounter a segmentation violation when I fit a TH2D with a TF2.
>>> It does not always happen but it depends on the parameter which I
>>> set at start.
>>>
>>> Here is the error message and the part of my C++ program (not
>>> macro).
>>>
>>> Does anyone have any help or suggestion?
>>>
>>> Regards
>>>
>>> SL 5.0 64 bit + ROOT 5.18.00
>>>
>>> *** Break *** segmentation violation
>>> Using host libthread_db library "/lib64/libthread_db.so.1".
>>> Attaching to program: /proc/13189/exe, process 13189
>>> [Thread debugging using libthread_db enabled]
>>> [New Thread 46912569828368 (LWP 13189)]
>>> 0x000000388fa94155 in waitpid () from /lib64/libc.so.6
>>> #1 0x000000388fa3bb73 in do_system () from /lib64/libc.so.6
>>> #2 0x00002aaaaad04462 in TUnixSystem::StackTrace ()
>>> from /usr/local/root/lib/libCore.so
>>> #3 0x00002aaaaad035f3 in TUnixSystem::DispatchSignals ()
>>> from /usr/local/root/lib/libCore.so
>>> #4 <signal handler called>
>>> #5 0x00002aaaac2979ff in TF2::GetSave () from /usr/local/root/lib/
>>> libHist.so
>>> #6 0x00002aaaac28e956 in TF1::EvalPar () from /usr/local/root/lib/
>>> libHist.so
>>> #7 0x00002aaaac297f80 in TF2::Save () from /usr/local/root/lib/
>>> libHist.so
>>> #8 0x00002aaaac2d03ca in TH1::Fit () from /usr/local/root/lib/
>>> libHist.so
>>> #9 0x0000000000407459 in PinHoleAnalysis (par=
>>> {phi = 0.17042275908451404, x = 1498.0452872360352, y =
>>> 967.125451801472
>>> 08, a = {35.695154566427355, -0.19497820602855465,
>>> 0.0038895382511709678}},
>>> hist=<value optimized out>, res=<value optimized out>) at
>>> catanal.cxx:243
>>> #10 0x0000000000407baf in main (argc=<value optimized out>,
>>> argv=<value optimized out>) at catanal.cxx:96
>>>
>>>
>>> ===========================
>>> 228 TF2* f2ab = new TF2(Form("f2ab-%d-%d", i, j),
>>> Gauss2D_AB, x1, x2,
>>> y1, y2, 7);
>>> 229
>>> 230 for(int k=0; k<5; k++){
>>> 231 f2ab->SetParameter(k, f2rough->GetParameter(k));
>>> 232 f2ab->SetParLimits(k, fitpar_min[k], fitpar_max[k]);
>>> 233 f2ab->SetParName(k, fitpar_name[k]);
>>> 234 } // k
>>> 235
>>> 236 f2ab->SetParameter(5, f2rough->GetParameter(4)); // sy
>>> => s
>>> 237 f2ab->SetParameter(6, 0.); // rho => 0
>>> 238 f2ab->SetParLimits(5, fitpar_min[5], fitpar_max[5]);
>>> 239 f2ab->SetParLimits(6, fitpar_min[6], fitpar_max[6]);
>>> 240 f2ab->SetParName(5, fitpar_name[5]);
>>> 241 f2ab->SetParName(6, fitpar_name[6]);
>>> 242
>>> 243 hist[j*kRN + i]->Fit(Form("f2ab-%d-%d", i, j), "0");
>>>
>>> double Gauss2D_AB(double* x_, double* par)
>>> {
>>> // z = f(A, mu_x, mu_y, BG, sigma_x, sigma_y, rho)
>>> double x = x_[0];
>>> double y = x_[1];
>>> double A = par[0];
>>> double mx = par[1];
>>> double my = par[2];
>>> double bg = par[3];
>>> double sx = par[4];
>>> double sy = par[5];
>>> double rho = par[6];
>>>
>>> double z = A/(2*TMath::Pi()*sx*sy*sqrt(1-rho*rho))*
>>> exp(-0.5/(1-rho*rho)*(pow((x-mx)/sx, 2) + pow((y-my)/sy, 2)
>>> - 2*rho*(x-mx)*(y-my)/sx/sy)) + bg;
>>>
>>> return z;
>>> }
>>> ===========================
>>>
>>> OKUMURA, Akira oxon_at_icrr.u-tokyo.ac.jp
>>> Institute for Cosmic Ray Research, University of Tokyo
>>> 5-1-5 Kashiwanoha Kashiwa Chiba 277-8582 Japan
>>> Phone/Fax : +81 4-7136-3153
>>> Skype : okumura.akira
>>>
>>
>
Received on Mon Feb 25 2008 - 10:02:11 CET

This archive was generated by hypermail 2.2.0 : Tue Feb 26 2008 - 17:50:01 CET