Re: [ROOT] Problem drawing functions

From: Jiri Masik (Jiri.Masik@cern.ch)
Date: Tue Jul 23 2002 - 16:08:51 MEST


Hi Alberto,

this behaviour is common if a histogram is filled with NaNs.
put cout << Val << endl; in TrajAnt to see what's going on.
cheers 

Jiri

Alberto Garcia Raboso <Alberto.Garcia.Raboso@cern.ch> writes:

> You're right. It still doesn't work.
> 
> Regards,
> 
> Alberto
> 
> Fons Rademakers wrote:
> > 
> > Does this still not work? Could be an AFS cache issue.
> > 
> > Cheers, Fons.
> > 
> > On Fri, 2002-07-19 at 19:35, Alberto Garcia Raboso wrote:
> > > Hi,
> > >
> > > I'm trying two draw two functions in the same Pad using the code given
> > > below. 5 minutes ago, it worked. But now, without changing anything, it
> > > doesn't. I get the message <<Warning in <TCanvas::ResizePad>: c1 height
> > > changed from 0 to 10>> and no graph.
> > >
> > > I've got not to get the error dropping out the option "same" when
> > > drawing fun.
> > >
> > > I'm running v. 3.03/02 on lxplus.
> > >
> > > Any idea? Thanks in advance.
> > >
> > > Alberto
> > >
> > > THE CODE:
> > >
> > > #include "TMath.h"
> > > #include "TF1.h"
> > > #include "TCanvas.h"
> > >
> > > void fit()
> > > {
> > >       // Parameters of the function
> > >       Double_t par[5] = {145.0, 145.0, 295.0, 8550.0, 5200.0};
> > >       Double_t parAnt[3] = {-17.649, 4.905, 4.020};
> > >       // Create canvas
> > >       TCanvas *c1 = new TCanvas("c1","Fitting functions",1000,800);
> > >       // Function
> > >       TF1 *fun = new TF1("fitfun",TrajFunc,-700,700,5);
> > >       TF1 *fun2 = new TF1("fitant",TrajAnt,-700,700,3);
> > >       fun->SetParameters(par);
> > >       fun2->SetParameters(parAnt);
> > >       // Draw function
> > >       c1->SetGridx();
> > >       c1->SetGridy();
> > >       fun2->SetLineColor(6);
> > >       fun2->Draw();
> > > //    fun->Draw("same");
> > >       c1->Update();
> > > }
> > >
> > > Double_t TrajFunc(Double_t *x, Double_t *par)
> > > {
> > >               Double_t Raiz, Term1, Term2, Term3, Val;
> > >
> > >               Raiz = TMath::Sqrt( par[3] * par[3] - TMath::Power((par[2] - par[3]) *
> > > TMath::Sin(x[0]/512), 2) );
> > >               Term1 = - par[0] * TMath::Tan(x[0]/512);
> > >               Term2 = par[1] * TMath::Sin(x[0]/512) / ( Raiz * TMath::Abs(par[2] -
> > > par[3]) );
> > >               Term3 = TMath::Sin(x[0]/512) * ( par[2]  * par[2] - 2 * par[2] *
> > > par[3]) / ( par[3] * TMath::Cos(x[0]/512) + Raiz );
> > >               Val = - TMath::ATan((Term1 + Term2 + Term3) / par[4]);
> > >
> > >               return Val;
> > > }
> > >
> > >
> > > Double_t TrajAnt(Double_t *x, Double_t *par)
> > > {
> > >               if(TMath::Abs(x[0]) < 10e-6)
> > >                       return 0.0;
> > >
> > >         Double_t Phi1, Phi2, Val;
> > >
> > >               Phi2 = TMath::ACos( (par[0] + par[1] * par[1]) / ( (par[1] *
> > > TMath::Sqrt( TMath::Power((par[2] -
> > > par[0]/par[2])/(2*TMath::Sin(x[0]/512)), 2) + par[0] ) ) ) );
> > >               Phi1 = TMath::ACos( (par[0] + par[2] * par[2]) / ( (par[2] *
> > > TMath::Sqrt( TMath::Power((par[2] -
> > > par[0]/par[2])/(2*TMath::Sin(x[0]/512)), 2) + par[0] ) ) ) );
> > >               Val = -TMath::Sign(1.0, x[0]) * (Phi2 - Phi1);
> > >
> > >               return Val;
> > > }
> > --
> > Org:    CERN, European Laboratory for Particle Physics.
> > Mail:   1211 Geneve 23, Switzerland
> > E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
> > WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:00 MET