Re: Problem with a script for fitting

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Wed, 18 Jan 2012 19:35:14 +0100


Hi,

You probably shouldn't call fra->Delete() - you didn't allocate it. Any reason for calling it?

Axel.

On 1/18/12 7:00 PM, perfetto_at_na.infn.it wrote:
> Hello Rooters,
>
> I have a problem with the following script that must do repeated fit (in
> the example I put i < 5), but after the first good fit, it goes in error:
> *** Break *** segmentation violation.
> Is there anyone can help me ?
>
> Thanks in advance
> Francesco.
>
> #include <TF1>
> #include <TFile>
> #include <TMath>
> #include <TCanvas>
> #include <TString>
>
> using namespace std;
>
> void linearity(){
>
> ofstream out;
> out.open("risultati_fit.txt", ios::out | ios::app);
>
> TFile *_file0 = TFile::Open("/data/singlepe/Run000290.root");
> Double_t mean, xmin, xmax, res;
>
> for (Int_t i = 0; i < 5; i++) {
>
> Events->Draw( Form("channels[%d].regions[0].integral >> fra", i) );
>
> mean = fra->GetMean();
> xmin = mean - 1000;
> xmax = mean + 1000;
>
> res = fra->Fit("gaus","S","",xmin,xmax)->GetParams()[1];
>
> // out << setw(8) << setprecision(5) << res;
> // out << setw(12) << setprecision(12) << times << endl;
>
> fra->Delete();
>
> }
> out.close();
> }
>
> This is the complete error I got:
>
> root [0] .L prova.C
> root [1] linearity()
> Warning in <TClass::TClass>: no dictionary for class EventData is available
> Warning in <TClass::TClass>: no dictionary for class ChannelData is available
> Warning in <TClass::TClass>: no dictionary for class Baseline is available
> Warning in <TClass::TClass>: no dictionary for class Roi is available
> <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
> FCN=18.6681 FROM MIGRAD STATUS=CONVERGED 109 CALLS 110 TOTAL
> EDM=5.952e-09 STRATEGY= 1 ERROR MATRIX ACCURATE
> EXT PARAMETER STEP FIRST
> NO. NAME VALUE ERROR SIZE DERIVATIVE
> 1 Constant 4.66387e+03 2.81500e+01 4.19283e-02 -4.42114e-06
> 2 Mean -1.95190e+04 1.04697e+01 2.17082e-02 5.93821e-06
> 3 Sigma 1.14300e+03 2.28939e+01 1.50480e-05 -5.82229e-03
>
> *** Break *** segmentation violation
>
>
>
> ===========================================================
> There was a crash.
> This is the entire stack trace of all threads:
> ===========================================================
> #0 0x0000003cf82aa77e in waitpid () from /lib64/libc.so.6
> #1 0x0000003cf823e329 in do_system () from /lib64/libc.so.6
> #2 0x00007f9ece2619cf in TUnixSystem::StackTrace() () from
> /cern/root-5.26/lib/libCore.so.5.26
> #3 0x00007f9ece262934 in TUnixSystem::DispatchSignals(ESignals) () from
> /cern/root-5.26/lib/libCore.so.5.26
> #4 <signal handler called>
> #5 0x00007f9ece248360 in TCint::FindSpecialObject(char const*,
> Cint::G__ClassInfo*, void**, void**) () from
> /cern/root-5.26/lib/libCore.so.5.26
> #6 0x00007f9ecd6a2145 in G__APIGetSpecialObject_layer1 () from
> /cern/root-5.26/lib/libCint.so.5.26
> #7 0x00007f9ecd7f0d80 in G__getvariable () from
> /cern/root-5.26/lib/libCint.so.5.26
> #8 0x00007f9ecd6b5b43 in G__exec_asm () from
> /cern/root-5.26/lib/libCint.so.5.26
> #9 0x00007f9ecd775873 in G__exec_loop () from
> /cern/root-5.26/lib/libCint.so.5.26
> #10 0x00007f9ecd771129 in G__exec_statement () from
> /cern/root-5.26/lib/libCint.so.5.26
> #11 0x00007f9ecd72136a in G__interpret_func () from
> /cern/root-5.26/lib/libCint.so.5.26
> #12 0x00007f9ecd70ebbb in G__getfunction () from
> /cern/root-5.26/lib/libCint.so.5.26
> #13 0x00007f9ecd6eb8fa in G__getitem () from
> /cern/root-5.26/lib/libCint.so.5.26
> #14 0x00007f9ecd6f1181 in G__getexpr () from
> /cern/root-5.26/lib/libCint.so.5.26
> #15 0x00007f9ecd76e7fa in G__exec_statement () from
> /cern/root-5.26/lib/libCint.so.5.26
> #16 0x00007f9ecd6d823e in G__exec_tempfile_core () from
> /cern/root-5.26/lib/libCint.so.5.26
> #17 0x00007f9ecd6d84de in G__exec_tempfile_fp () from
> /cern/root-5.26/lib/libCint.so.5.26
> #18 0x00007f9ecd779e69 in G__process_cmd () from
> /cern/root-5.26/lib/libCint.so.5.26
> #19 0x00007f9ece24de26 in TCint::ProcessLine(char const*,
> TInterpreter::EErrorCode*) () from /cern/root-5.26/lib/libCore.so.5.26
> #20 0x00007f9ece1a1041 in TApplication::ProcessLine(char const*, bool,
> int*) () from /cern/root-5.26/lib/libCore.so.5.26
> #21 0x00007f9ecd041588 in TRint::HandleTermInput() () from
> /cern/root-5.26/lib/libRint.so.5.26
> #22 0x00007f9ece25fa4e in TUnixSystem::CheckDescriptors() () from
> /cern/root-5.26/lib/libCore.so.5.26
> #23 0x00007f9ece25fd31 in TUnixSystem::DispatchOneEvent(bool) () from
> /cern/root-5.26/lib/libCore.so.5.26
> #24 0x00007f9ece1edfa6 in TSystem::InnerLoop() () from
> /cern/root-5.26/lib/libCore.so.5.26
> #25 0x00007f9ece1ef92b in TSystem::Run() () from
> /cern/root-5.26/lib/libCore.so.5.26
> #26 0x00007f9ece19f69f in TApplication::Run(bool) () from
> /cern/root-5.26/lib/libCore.so.5.26
> #27 0x00007f9ecd041955 in TRint::Run(bool) () from
> /cern/root-5.26/lib/libRint.so.5.26
> #28 0x000000000040107c in main ()
> ===========================================================
>
>
> The lines below might hint at the cause of the crash.
> If they do not help you then please submit a bug report at
> http://root.cern.ch/bugs. Please post the ENTIRE stack trace
> from above as an attachment in addition to anything else
> that might help us fixing this issue.
> ===========================================================
> #5 0x00007f9ece248360 in TCint::FindSpecialObject(char const*,
> Cint::G__ClassInfo*, void**, void**) () from
> /cern/root-5.26/lib/libCore.so.5.26
> ===========================================================
>
>
> Root > Function linearity() busy flag cleared
>
>
Received on Wed Jan 18 2012 - 19:35:20 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 18 2012 - 23:50:01 CET